oantolin / embark

Emacs Mini-Buffer Actions Rooted in Keymaps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All keys are accepted in Org buffers

minad opened this issue · comments

Hi Omar,

I've observed some special behavior when acting in Org buffers (on Org elements or other targets). When pressing a non-existing key I don't get the "Not an action" error message. Instead the pressed key is inserted. Do you also observe this and have an idea what could be causing this? Thanks!

I know what's going on. As a compromise between my philosophy of extreme freedom ("you can use any keybinding you have to specify the action") and users wanting some guard rails ("I'd like to be limited to just the keybindings in the action map, please"), Embark makes self-insert-command a special case, and won't let you use it as an action printing instead an error message. But org replaces self-insert-command with its own command, one that Embark doesn't treat specially.

I think I'll just extend the compromise to include org-self-insert-command.

Thanks! I suggest to instead use a regexp self-insert-command\\' against the command name. Afaik many such modified self insertion commands exist. Corfu faces a similar issue when checking commands which trigger auto completion, see https://github.com/minad/corfu/blob/130098094c446d6f3c019b5d1804f7805317b177/corfu.el#L173.

Not sure if there is an easier way with pcase:

(pcase cmd
  ((and (pred symbolp)
        (guard (string-match-p "self-insert-command\\'"
                               (symbol-name cmd))))
   ...))

Mmh, I do have at least one more command ending in self-insert-command, so I'll make the generalization. I think your way is basically the only way in pcase. There is a regexp pattern but it won't match symbol names, I think.