devil icon indicating copy to clipboard operation
devil copied to clipboard

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

Open wesnel opened this issue 2 years ago • 2 comments

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!

wesnel avatar Oct 24 '23 21:10 wesnel

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.

susam avatar Oct 24 '23 21:10 susam

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.

wesnel avatar Oct 25 '23 00:10 wesnel