I'm trying to create an emmet-like minor mode that will trigger on SPC (or TAB) if the previous text is expandable, but I don't want to completely override bindings that already exist for the key.

How can I 'layer' my functionality over existing configuration?

(if (should-activate-p)

There are various ways you could approach this, but one in particular seems more or less designed for the purpose.

You define the key using the menu-item syntax, with a :filter function that returns the command to be called. If the function returns nil, Emacs treats it as undefined in that keymap, and continues looking for a binding in the lower-priority maps.

Some examples are:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.