Mastering Key Bindings in Emacs
masteringemacs.org
Mastering Key Bindings in Emacs
1–10 of 20 posts
Re: Mastering Key Bindings in Emacs
#2Re: Mastering Key Bindings in Emacs
#3Re: Mastering Key Bindings in Emacs
#4Re: Mastering Key Bindings in Emacs
#5Re: Mastering Key Bindings in Emacs
#6Re: Mastering Key Bindings in Emacs
#7What I would really like is an Emacs macro that would just insert the appropriate keybinding code for use in an .emacs file -- there doesn't seem to be one but it seems like it would be an obvious help. Or is this one of those Emacs things that is obvious and everyone knows but me?
(global-set-key (kbd "keybinding") 'function-you-want-it-to-call)
The article goes into the significance of global-set-key vs. local-set-key; until you have more specific intentions, global-set-key is probably what you want.I've done a couple sessions teaching developers in using Emacs, and one point I always stress is that the Emacs help system is exhaustive, but you have to learn how it's organized. (It uses funny terminology sometimes.)
Re: Mastering Key Bindings in Emacs
#8What I would really like is an Emacs macro that would just insert the appropriate keybinding code for use in an .emacs file -- there doesn't seem to be one but it seems like it would be an obvious help. Or is this one of those Emacs things that is obvious and everyone knows but me?
(defun insert-key-sequence (key-repr)
"Reads a literal key sequence from the user
and inserts a representation of it at point,
suitable for `global-set-key' or `local-set-key'."
(interactive "KKey sequence? ")
(prin1 key-repr (current-buffer))
(insert " "))
(add-hook 'emacs-lisp-mode-hook
#'(lambda ()
(local-set-key "\C-ck" #'insert-key-sequence)))
(run-hooks 'emacs-lisp-mode-hook)
Unfortunately it doesn't seem to work for mouse chords.Re: Mastering Key Bindings in Emacs
#9I have to admit that my current major Emacs trouble is moving between Linux and OSX. Switching meta and hyper causes me major brain-fry (alt is immediately left of the space bar on every keyboard but those made by Apple).
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'none)
(setq mac-pass-command-to-system nil)