tags:

views:

85

answers:

3

I came up with a elisp function, and tried to match a key to the file.

(defun loadtopics ()
  "Load the topics.org file"
  (interactive)
  (load "../topics.org"))
(global-set-key (kbd "C-c C-a") 'loadtopics)

The problem is it's hard to find an unallocated key combination.

  • Is there any easy way to find key combinations that are not assigned?
  • What method do you use for assigning the key to elisp code you made?
  • Is it possible to assign multiple control key, i.e 'C-c C-a C-b C-x' or similar?
+8  A: 

The sequences beginning with C-c letter and F5 through F9 are reserved for users to rebind. No built in modes or 3rd party packages should be overriding those, so they are perfect for user specific global key bindings. See Key Binding Conventions in the emacs manual.

ataylor
+2  A: 

If you have an extra modifier key available, like option on the Mac or the Windows key on a PC, you can map it to the "super" or "hyper" modifier in Emacs and use it without fear of colliding with any built-in sequences. For example, some of my key mappings that use super include:

(global-set-key [(super s)] 'shell)
(global-set-key [(super \\)] 'find-file-at-point)
(global-set-key [(super meta p)] 'emms-pause)
(global-set-key [(super ?!)] 'shell-command-with-?-expansion)

That last one is a command I wrote that works like shell-command except that it expands question marks in the command text into the full path to the current buffer, like dired-do-shell-command does.

Sean
+2  A: 

I've been meaning to try this elisp library for a while.

From the code's commentaries :

The only entry point is describe-unbound-keys'; it prompts for the maximum ;; complexity to allow, which should probably be at least 5 to find enough ;; keys to be worthwhile. Lisp may call justunbound-keys' to get a list of ;; key representations suitable for `define-key'.

julien