Emacs comes with
M-( bound to
M-) runs the command
‘move-past-close-and-reindent’. These commands are very useful in Emacs for writing Lisp. Using them takes some getting used to. The binding of
M-( also appears in other modes, including CcMode.
As an example, consider having to type the definition for the Fibonacci number in Emacs Lisp.
(defun fib (n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
Here are those keys pretty-printed (see EmacsKeyNotation):
M-( defun SPC fib M-( n M-) M-( if M-( < SPC n SPC 2 M-) n C-j M-( + M-( fib M-( - SPC n SPC 1 M-) M-) M-( fib M-( - SPC n SPC 2 C-M-e
Here they are as a listing (as seen in the
*Edit Macro* buffer of KeyboardMacros):
(global-set-key "\M-'" 'insert-quotations) (global-set-key "\M-\"" 'insert-quotes) (global-set-key (kbd "C-'") 'insert-backquote) (defun insert-quotations (&optional arg) "Enclose following ARG sexps in quotation marks. Leave point after open-paren." (interactive "*P") (insert-pair arg ?\' ?\')) (defun insert-quotes (&optional arg) "Enclose following ARG sexps in quotes. Leave point after open-quote." (interactive "*P") (insert-pair arg ?\" ?\")) (defun insert-backquote (&optional arg) "Enclose following ARG sexps in quotations with backquote. Leave point after open-quotation." (interactive "*P") (insert-pair arg ?\` ?\'))