Misc

Writing Commands

#Syntax

(defun command-name (args)
"documentation" (interactive "template")
body)

#Example

(defun this-line-to-top-of-window (line)
    "Reposition current line to top of window.
With prefix argument LINE, put point on LINE."
    (interactive "P")
    (recenter (if (null line)
                  0
              (prefix-numeric-value line))))

The interactive spec says how to read arguments interactively. Type C-h f interactive RET for more details.

Spelling Check

- -
M-$ Check spelling of current word
M-x ispell-region Check spelling of all words in region
M-x ispell-buffer Check spelling of entire buffer
M-x flyspell-mode Toggle on-the-fly spell checking

Abbrevs

- -
C-x a g Add global abbrev
C-x a l Add mode-local abbrev
C-x a i g Add global expansion for this abbrev
C-x a i l Add mode-local expansion for this abbrev
C-x a e Explicitly expand abbrev
M-/ Expand previous word dynamically

Simple Customization

- -
M-x customize customize variables and faces
Making global key bindings in Emacs Lisp:
(global-set-key (kbd "C-c g") ’search-forward)
(global-set-key (kbd "M-#") ’query-replace-regexp)

Commands Dealing with Emacs Lisp

- -
C-x C-e Eval sexp before point
C-M-x Eval current defun
M-x eval-region Eval region
M-: Read and eval minibuffer
M-x load-library Load a Lisp library from load-path

Miscellaneous

- -
C-u num Numeric argument
M-- Negative argument
C-q char Quoted insert

Registers

- -
C-x r s Save region in register
C-x r i Insert register contents into buffer
C-x r SPC Save value of point in register
C-x r j Jump to point saved in register

International Character Sets

- -
C-x RET l specify principal language
M-x list-input-methods show all input methods
C-\ enable or disable input method
C-x RET c set coding system for next command
M-x list-coding-systems show all coding systems
M-x prefer-coding-system choose preferred coding system

Shells

- -
M-! Execute a shell command
M-& Execute a shell command asynchronously
M- Run a shell command on the region
C-u M- Filter region through a shell command
M-x shell Start a shell in window shell
Comments