问题
To help me learn to work with various emacs modes, I would like to have a second monitor with a little HTML page that is used for showing me what sorts of things I can type or key-chord on whatever I'm currently looking at in emacs.
So how can I get a list of all the commands or key-chords available to me in my current mode?
回答1:
Someone else will no doubt tell you how to get a cheatsheet such as you request (well, here is info about that too).
But if you want something that tells you dynamically what keys are available in the current context, no matter what it is, then this is what I have to offer:
C-h m
tells you about the current (major) mode.C-h b
tells you about currently available keys.The Icicles feature key completion gives you access to all of the currently available key sequences, via key
S-TAB
. If you use a prefix key first, thenS-TAB
, then you see all the completions of that prefix key. You can move up and down the key hierarchy, including even menu items, to see all possible keys. You can useC-M-RET
to get help (info about) any given key that is available. Here is some more about this feature of showing you all currently possible key bindings.
回答2:
I would very much like to know good answer to this question myself! At present I am using this simple function to display key bindings for the current major mode in *Help on keys*
buffer:
(defun describe-current-bindings (mode)
"Show key bindings for the current major mode in *Help on keys* buffer."
(interactive)
(with-current-buffer (get-buffer-create "*Help on keys*")
(erase-buffer)
(insert (documentation mode))))
And then use defadvice
to call the function automatically whenever I switch buffers or windows:
(defadvice switch-to-buffer (after display-keys-buffer activate)
(describe-current-bindings major-mode))
(defadvice select-window (after display-keys-window activate)
(describe-current-bindings major-mode))
Now I can open *Help on keys*
buffer in another frame and move that frame to my second monitor.
If you use other functions to switch windows (from windmove
package, etc) you may need to add defadvice
for them as well.
回答3:
Try the pacakge help-fns+.el
, there are some useful functions: describe-mode
- "Display documentation of current major mode and minor modes.", describe-keymap
- "Describe bindings in KEYMAP, a variable whose value is a keymap.", etc. For example,
(describe-keymap 'global-map) ;; global bindings
(describe-keymap 'emacs-lisp-mode-map) ;; major mode bindings
(describe-keymap 'smartparens-mode-map) ;; minor mode bindings
来源:https://stackoverflow.com/questions/19601206/how-do-i-get-a-list-of-all-the-currently-available-commands-and-hotkeys