Skip to content

Instantly share code, notes, and snippets.

@bjorne
Created September 27, 2012 21:35
Show Gist options
  • Save bjorne/3796607 to your computer and use it in GitHub Desktop.
Save bjorne/3796607 to your computer and use it in GitHub Desktop.
Show free key bindings in Emacs (for the current mode)
(setq free-keys-modifiers (list "C" "M" "C-M"))
(setq free-keys-keys "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,/§1234567890-=[];'\\`±!@#$%^&*()_+}{:\"|?><~")
(defun free-keys ()
(interactive)
(let ((buf (get-buffer-create "*Free keys*")))
(display-buffer buf)
(with-current-buffer buf
(erase-buffer)
(mapc (lambda (modifier)
(insert "\nFree keys with modifier " modifier "\n=========================\n")
(mapc (lambda (key)
(let* ((full-name
(concat modifier "-" (char-to-string key)))
(binding
(key-binding (read-kbd-macro full-name))))
(when (not binding)
(insert
full-name
" maps to "
(symbol-name binding)
"\n"))))
free-keys-keys))
free-keys-modifiers)
(setq buffer-read-only t)
(make-local-variable 'buffer-read-only)
(goto-char 0))))
(provide 'free-keys)
@rejeep
Copy link

rejeep commented Sep 28, 2012

Sweeet! Add C-c and C-x to modifier keys. Also, make sure q kills the free keys buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment