Difference between revisions of "Discoverability"

From WikEmacs
Jump to navigation Jump to search
(→‎Hydra: img)
(→‎Packages: which-key)
Line 10: Line 10:
  
 
= Packages =
 
= Packages =
 +
 +
== Which-key (and guide-key) ==
 +
 +
You start a shortcut but you're unsure ? You want to know what are the other shortcuts available in the current major mode ? Or even global shortcuts ? You can discover all this with [https://github.com/justbur/emacs-which-key#additional-commands which-key].
 +
 +
Once you have installed it (it's in [[melpa]]), activate it with '''M-x which-key-mode''', start a keybinding (say "C-c") but don't finish it and wait for 1s (the default): now which-key will open a pop-up that lists all keybindings that follow "C-c".
 +
 +
This packages improves on [https://github.com/kai2nenobu/guide-key guide-key] in a few ways: It has pages to scroll through instead of taking up your whole screen, more options, and the ability to see all the "top-level" bindings.
 +
 +
However, it requires at least Emacs version 24.4, whereas guide-key is compatible with earlier versions.
  
 
== Hydra ==
 
== Hydra ==

Revision as of 11:02, 6 June 2016

This page will try to list emacs' features and packages that help in auto discoverability. So if you don't know much about emacs' keybindings, commands, i.e., potential, you can have the information come to you and you just have to let you guide.

Emacs builtins

Emacs by default is built around this idea of discoverability. It is self-documented. See C-h ?.

Emacs 25

Emacs 25 comes with even better introspection (see this article).

Packages

Which-key (and guide-key)

You start a shortcut but you're unsure ? You want to know what are the other shortcuts available in the current major mode ? Or even global shortcuts ? You can discover all this with which-key.

Once you have installed it (it's in melpa), activate it with M-x which-key-mode, start a keybinding (say "C-c") but don't finish it and wait for 1s (the default): now which-key will open a pop-up that lists all keybindings that follow "C-c".

This packages improves on guide-key in a few ways: It has pages to scroll through instead of taking up your whole screen, more options, and the ability to see all the "top-level" bindings.

However, it requires at least Emacs version 24.4, whereas guide-key is compatible with earlier versions.

Hydra

An Hydra is a great package by abo-abo that "can be used to tie related commands into a family of short bindings with a common prefix - a Hydra."

You can pick hydras around (see the wiki on github). Some of them "just" group keybindings together, others provide a full list of a mode to help discoverability (for example, the ibuffer Hydra can be called immediately when we enter ibuffer mode and show all keybindings).

Hydras are also very easy to write. This is a simple one:

(defhydra hydra-zoom (global-map "<f2>")
  "zoom"
  ("g" text-scale-increase "in")
  ("l" text-scale-decrease "out"))

This is the screenshot of a more complete one:

Hydra-buffer.png