I like emacs, I like keybindings. I also like the command line and have a lot of keybindings.
Is it possible to dump emacs keybindings to standard out so that I can search them with things like grep?
Edit: Ideally the output would "play well with command line tools" and be "machine readable". Something like:
"C-x s" save-buffer fundamental-mode "C-a" beginning-of-line fundamental-mode
would be nice.
Edit: As people have pointed out the keybindings in emacs vary depending upon current buffer and position. I would like the "current" bindings, where this is defined as the selected buffer in the last selected frame. These can be accessed programmatically from emacsclient:
(emacsclient --eval "(buffer-file-name (window-buffer (selected-window)))" | tr -d '"')
To make clear what I already have thought of, and to give interested readers clues.
The following script dumps functions to standard out in a similar way:
It uses "emacsclient -eval" for the purpose.
I am aware that the
describe-bindings function. When I looked at this before the code seemed a little "specific purpose without easy to understand general functions".
I am aware the which-key emacs mode which list keybindings as you type them, so this code might be easy to modify.
This code might be kind of readable.
Use emacs self-documentation to find keybindings
I am quite aware of the the ability to search function names and find keybindings associated with functions. The utility is that keybindings represent "functions that I am aware of and have used before".
Also the the prefix keys that I have used for keybindings represent an indexing of some descriptions (these functions are related to such and such)