susam / devil

Emacs minor mode that intercepts and translates keystrokes to provide a modifier-free non-modal editing experience
https://susam.github.io/devil/
Other
167 stars 9 forks source link

Use of devil when the modifier is in the middle of a keybinding #18

Open wesnel opened 11 months ago

wesnel commented 11 months ago

I apologize if the title of this issue is confusing, but hopefully an example will illustrate what I mean:

Is there a way for me to trigger keybindings such as <f1> C-a using devil? Currently, typing <f1> , will result in the error <f1> , is undefined rather than activating the devil prompt.

Instead, I would like to be able to do <f1> , a and have devil translate that to <f1> C-a.

Thanks!

susam commented 11 months ago

Sorry, this type of translation is not supported by Devil. The reason is that the devil-key (which is , by default) is an actual key binding that runs a command named devil which then reads a Devil key sequence and translates it to Emacs key sequences and commands.

Since <f1> , represents a completely different key sequence under the <f1> prefix, Devil does not get a chance to run when this key sequence is typed.

I believe a workaround for this could be to type , h , a instead.

wesnel commented 11 months ago

Thanks for the fast response @susam. That's what I suspected.

Did you experiment with different approaches for implementing devil? The , keybinding approach is elegant and makes sense. However, I'm trying to learn more about Emacs, and I was interested in knowing if it were possible to implement devil by instead advising a function like this-single-command-keys. I imagine that it could be possible to handle the edge case I described in this issue if we were always able to "intercept" the most recent key, but I'm sure this approach could add complexity. I was just curious! Thanks for your time.