Skip to content

Selecting commands via completion outside of Embark ​

If you like this completion interface for exploring key bindings for Embark actions, you may want to use it elsewhere in Emacs. You can use Embark’s completion-based command prompter to list:

  • key bindings under a prefix,
  • local key bindings, or
  • all key bindings.

To use it for key bindings under a prefix (you can use this to replace the ‘which-key’ package, for example), use this configuration:

emacs-lisp
(setq prefix-help-command #'embark-prefix-help-command)

Now, when you have started on a prefix sequence such as ‘C-x’ or ‘C-c’, pressing ‘C-h’ will bring up the Embark version of the built-in ‘prefix-help-command’, which will list the keys under that prefix and their bindings, and lets you select the one you wanted with completion, or by key binding if you press ‘embark-keymap-prompter-key’.

If you like this kind of prefix help, but want it to appear automatically after a delay, like ‘which-key-mode’ does by default, you can use ‘embark-auto-prefix-help-mode’ (independently of whether you also use the above setting for ‘prefix-help-command’ or not).

To list local or global key bindings, use the command ‘embark-bindings’. You can bind that to ‘C-h b’, which is the default key binding for the built-in ‘describe-bindings’ command, which this command can replace. By default, ‘embark-bindings’ lists local key bindings, typically those bound in the major mode keymap; to get global bindings as well, call it with a ‘C-u’ prefix argument.