diff options
| author | Mountain Man <43313373+MountainMan1312@users.noreply.github.com> | 2023-05-29 23:47:23 -0400 |
|---|---|---|
| committer | Mountain Man <43313373+MountainMan1312@users.noreply.github.com> | 2023-05-29 23:47:23 -0400 |
| commit | f63e6d04893e3f5026fd33f69b5cadebda7c549a (patch) | |
| tree | df2744827b4f1d47974d92051fd2b5cfdf41e4d6 | |
| parent | Ignore `tramp` file (diff) | |
| download | mmosmacs-f63e6d04893e3f5026fd33f69b5cadebda7c549a.tar.gz mmosmacs-f63e6d04893e3f5026fd33f69b5cadebda7c549a.tar.bz2 mmosmacs-f63e6d04893e3f5026fd33f69b5cadebda7c549a.zip | |
Add function and keybinds to list all bindings for KEY
| -rw-r--r-- | init.el | 19 |
1 files changed, 19 insertions, 0 deletions
| @@ -1001,6 +1001,25 @@ | |||
| 1001 | ;; minibuffer or a popup window. | 1001 | ;; minibuffer or a popup window. |
| 1002 | ;; --------------------------------- | 1002 | ;; --------------------------------- |
| 1003 | 1003 | ||
| 1004 | ;; Define function and keybind to list all bindings of a certain key | ||
| 1005 | (defun mm/print-all-bindings-for-key (key) | ||
| 1006 | "Output all bindings for KEY in *MESSAGES*." | ||
| 1007 | (interactive "kEnter key sequence: ") | ||
| 1008 | (mapc (lambda (pair) | ||
| 1009 | (when (cdr pair) | ||
| 1010 | (message "%S: %S" (car pair) (cdr pair)))) | ||
| 1011 | (mapcar (lambda (keymap) | ||
| 1012 | (cons keymap | ||
| 1013 | (let ((binding (lookup-key (eval keymap) key))) | ||
| 1014 | (and (not (numberp binding)) binding)))) | ||
| 1015 | (let (atoms) | ||
| 1016 | (mapatoms (lambda (a) | ||
| 1017 | (when (keymapp (and (boundp a) (eval a))) | ||
| 1018 | (push a atoms)))) | ||
| 1019 | atoms)))) | ||
| 1020 | (global-set-key (kbd "C-h C-u k") 'mm/print-all-bindings-for-key) | ||
| 1021 | |||
| 1022 | |||
| 1004 | ;; Define fixed version of `keyboard-escape-quit' which does not close | 1023 | ;; Define fixed version of `keyboard-escape-quit' which does not close |
| 1005 | ;; windows or change their layout. | 1024 | ;; windows or change their layout. |
| 1006 | (defun mm/keyboard-escape-quit-keep-windows () | 1025 | (defun mm/keyboard-escape-quit-keep-windows () |