autokey / autokey

AutoKey, a desktop automation utility for Linux and X11.
https://autokey.github.io/index.html
GNU General Public License v3.0
3.4k stars 191 forks source link

expand abbreviations even after ' or ( #303

Open DoctorSubtilis opened 5 years ago

DoctorSubtilis commented 5 years ago

Classification:

Feature

Reproducibility:

Always

Version

AutoKey version: Gtk 0.95.1 (also occurs in 0.95.6 with GTK and Qt front ends)

Installed via: (PPA, pip3, …): Kubuntu package

Linux Distribution: Kubuntu 18.04

Summary

Abbreviations don't expand after the «'», or the «(».
It would be very useful (in particular in some languages)

Steps to Reproduce (if applicable)

Expected Results

Actual Results

josephj11 commented 5 years ago

I'm not sure if it will make a difference, but you should try this with the latest release, 0.95.6. That part of the code has been worked on, but still has issues. Installation instructions are here.

DoctorSubtilis commented 5 years ago

Thank you. I will try: but in Kubuntu 18.04 how should I do? Add a PPA?

josephj11 commented 5 years ago

I fixed the broken link in my last comment and added a link to installation instructions. Sorry about that. We don't have a working PPA these days.

DoctorSubtilis commented 5 years ago

Installed the 0.95.6: but unfortunately the problem is not solved. Nothing has changed. I believe that you should add this as new feature (enhancement).
Thank you

josephj11 commented 5 years ago

Just tried it here in a terminal window and I can confirm that this does not work as expected. Thomas will have to take a look at it, but it looks more like a bug than an enhancement to me.

bjohas commented 5 years ago

I'm on 0.95.7 and I've got the same issue, i.e.

(abbrev

is not expanded.

Mayn thanks!

luziferius commented 4 years ago

Hmm. I think this is related to what is considered part of a word. By default, Trigger when typed as part of a word is disabled in the Abbreviation settings. So if ( is considered to be part of a word, then the abbreviation won’t trigger. I tried checking that option and AutoKey started expanding the Phrase even after typing (abbrev. So clearly ( is seen as part of a word, which is arguably odd. AutoKey uses a Python regular expression to do this character classification.

Let’s dig in the code a bit: https://github.com/autokey/autokey/blob/86e7a85d723753143f78e0684290a362bf6789c6/lib/autokey/model.py#L110-L121 The last line quoted references this static default value: https://github.com/autokey/autokey/blob/86e7a85d723753143f78e0684290a362bf6789c6/lib/autokey/model.py#L35 The Python documentation https://docs.python.org/3/library/re.html says this about [] and \w:

[]  Used to indicate a set of characters.

and

\w   For Unicode (str) patterns:
Matches Unicode word characters;
this includes most characters that can be part of a word in any language,
as well as numbers and the underscore.
If the ASCII flag is used, only [a-zA-Z0-9_] is matched.

During experimentation I tried to set a different set of characters as 'word characters', by overwriting the Trigger on: field. I think [^\W()] should work. But while trying that out, the GTK GUI broke. See #315. If that is resolved, it may be possible to just use [^\W()] or similar, which will exclude () from the set of characters seen as part of words.

DoctorSubtilis commented 4 years ago

Good news. In KDE Neon, Plasma 5.17, now if I set an abbr to expand by "all non-word" I can expand (abbr -> (abbreviation.
Eventually it works!

luziferius commented 4 years ago

@DoctorSubtilis You are using KDE Neon with Plasma 5.17? Great! Can you please try the Qt5 GUI once? It crashes on my systems somewhere in automatically generated code that initializes a GUI class and I have no idea whether this is caused by my system or is a general issue with new KDE/Qt versions. If you try, please report failure or success back in #313

DoctorSubtilis commented 4 years ago

I see only autokey-gtk in synaptic... But why you ask me? Can't you do it yourself, in virtualbox i.g.?

luziferius commented 4 years ago

Last times I tried it was unbearably slow (systemd even timed out starting jobs during boot, etc…). Well I found the cause for #313, so don’t mind.

DoctorSubtilis commented 4 years ago

These last times abbrevation after '(' or any other punctuation sign, doesn't work any more: or rather, it works one time: if you re-save that item (that abbreviation), it works, but only for one time.
Very strange...