espanso
espanso copied to clipboard
Add option to discard the trigger character
I use
"eml" -> "email address"
but when triggered with space I get
"eml" -> "email address "
That extra space at the end causes a fight between me and the backspace to undo feature when all I want to do is remove the trigger character.
Hey @shaneknysh,
Thank you for the feedback! Not sure how we can solve it exactly, are you using the word
option?
In the meanwhile, a little trick you could use is pressing the "shift" key before the backspace, which disables the undo feature for that match
Cheers :)
I'm having the same issue. I think it would be great to have an option to suppress the trigger character (space) when using the word
option (I think that is how it works with autohotkey). Anyway, thanks for the great utility!
@joonro Sounds good, thank you! I'll investigate, it shouldn't be too hard to implement, although I can't give you any estimate date :)
Is this still a problem with the recent release?
Yes
Thank you for replying after so long! Does:
- trigger: ":eml "
replace: email address
meet your needs, or have I misunderstood the problem?
No.
Adding a space to the trigger doesn't remove the trigger character after triggering it only adds an additional character to the precursor
"eml " -> "email address" when triggered with space I get "eml " -> "email address "
"eml " -> "email address "<--- this space at the end is the issue.
If I am filling in a contact form this is the desired text entry
typed text | desired result
---------------------------
tab | enter email field
eml | "eml" entered into email field
space | "eml" is expanded to "email address"
tab | leave email field
actual text entry
typed text | desired result
---------------------------
tab | enter email field
eml | "eml" entered into email field
space | "eml" is expanded to "email address "
tab | leave email field, email address displays an error as an invalid email address
actual text entry
typed text | desired result
---------------------------
tab | enter email field
eml | "eml" entered into email field
space | "eml" is expanded to "email address "
backspace | "email address " is reverted to "eml"
work around text entry
typed text | desired result
---------------------------
tab | enter email field
eml | "eml" entered into email field
space | "eml" is expanded to "email address "
shift | cancels the revert option
backspace | "email address " is corrected to "email address"
tab | leave email field
Thank you. That's very helpful.
It's not what happens here with the code I posted, or if I use - regex:
instead of - trigger:
:
":eml "
gets replaced by "email address"
with no space suffix, which is what should happen, and I think is what you want?
I presume your contact form is in a specialist program? Does the same space suffix occur if you try the trigger in a plain text editor?
Have you tried changing the backend using the force_mode:
trigger options?
I will test again later but I was still getting the additional space this morning.
What mode are you using? I think my config is set to keys but I can't check right now.
I will test again later but I was still getting the additional space this morning.
What mode are you using? I think my config is set to keys but I can't check right now.
My (Linux Mint Xfce) default is Clipboard
except for my terminal (Auto
), and LibreOffice Calc (Inject
).
To save repeatedly editing default.yml
, the force_mode:
options are useful for testing individual triggers to determine if an app-specific configuration, or global change to default.yml
, might be helpful.
I will test with clipboard and update.
I wrote my config and replacements long before individual trigger option was added.
Changed my config from "keys" to "clipboard" to "auto" and I still get "email address "
also tested before and after updating from 2.1.x to 2.2.1 and I still get the trigger character.
does case matter? Keys vs keys etc
force_mode:
accepts clipboard
or keys
. I haven't tried changing the case. For backend:
it's Clipboard
, Inject
or Auto
but it's only worth changing this global setting if you find a general change beneficial.
You could try generating an intermediate echo:
variable for the email address before outputting the variable - I've seen that help once.
What's your OS and the program concerned?
Do you always get the extra spaces (in other editors/word-processors/terminal, etc.)?
I always get the trigger character its not an space being injected
typed text | result
---------------------------
space | "eml" is expanded to "email address "
, | "eml" is expanded to "email address,"
. | "eml" is expanded to "email address."
The trigger character is inserted by design but there are cases when it is not wanted
Only if you're using word: true
should it leave the word_separator
(it's useful for entering triggers within blocks of text) but if you're not (and you don't need it for a single-field input) you shouldn't. I'd need to see your actual trigger code.
default.yml
# Automatically generated by espanso migration tool
# Original file: default.yml
backend: Clipboard
toggle_key: RIGHT_ALT
auto_restart: true
undo_backspace: true
contact.yml
matches:
- trigger: eml
replace: email address
word: true
If you take out word: true
it should work as you want, but you may wish to add a disambiguation character on the beginning of your trigger to prevent it expanding in general text (not that there are any words in common use that ChatGPT could come up with in this instance).
I have tested word: true / false but that was quite some time ago.
I don't want to turn off undo I use it when I get an expansion I don't want like if I am typing eml in this response.
Where did you use -regex
I'm not familiar with that setting?
I didn't use - regex:
here but did mention that it works.
Apologies for mentioning undo_backspace
- I misread your code. When I noticed, I edited my addition in the GitHub Issue thread, but you won't have seen it if you're relying on the emails.
Adding a space character works for me. However, I prefer to stick with word: true
and add $|$
at the end of the replacement text.
This still keeps the trigger character but moves the cursor to be in front of the trigger character
So instead of
replaced word |
you get
replaced word|
so instead of having to hit [backspace] to remove the trigger character you need to hit [delete]
On Mon, Jul 1, 2024, 9:39 PM StewCam @.***> wrote:
Adding a space character works for me although for a more "pure" Espanso solution I prefer sticking with word: true and adding $|$ at the end of the replacement text.
— Reply to this email directly, view it on GitHub https://github.com/espanso/espanso/issues/626#issuecomment-2201817973, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABGVGNFI6NNOOQBB37PQ4LZKIOFPAVCNFSM4ZRYJUM2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRQGE4DCNZZG4ZQ . You are receiving this because you were mentioned.Message ID: @.***>
@shaneknysh Yes, although it does allow you to avoid that fight between backspace and undo!
@shaneknysh If you want to avoid the trailing space altogether you add $
to your word separators and then enter your replacement text as ending in $|
. On triggering with $
you should then get the desired replacement text without either $|
or a trailing space (tested).
It's not a trailing space it's a trailing replacement character.
On Tue, Jul 2, 2024, 12:07 AM StewCam @.***> wrote:
@shaneknysh https://github.com/shaneknysh If you want to avoid the trailing space altogether you add $ to your word separators and then enter your replacement text as ending in $|. On triggering with $ you should then get the desired replacement text without either $| or a trailing space (tested).
— Reply to this email directly, view it on GitHub https://github.com/espanso/espanso/issues/626#issuecomment-2202012060, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABGVGKJUKM2FD5NLI7VAZLZKI7R7AVCNFSM4ZRYJUM2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRQGIYDCMRQGYYA . You are receiving this because you were mentioned.Message ID: @.***>
@shaneknysh Yes, but you should find that the replacement character (word separator) $
will combine with the replacement text ending in $|
to give you what you want. The strings $|
and $
eat each other when they meet.
Still occuring.
I think Espanso is working as it should, and you may need to adjust your code, along the lines discussed, to make it do what you want. Espanso doesn't have trigger characters, by the way.
I'm glad espanso doesn't have trigger characters.
How would you like me to refer to the character I type to trigger a replacement with espanso?
You can close this as won't fix or working as intended but it is not fixed. The behavior is still present. The solutions presented are workarounds and do not repress the inclusion on the "character typed that triggers a replacement."
the $| "fix" only works if the "character typed to trigger replacement" is a space and I found it did not work at all in online forms asking for email address.