Home : Emacs tips :
[this section is under construction. it's well-covered in the emacs
texinfo doc, though, so i may decide not to finish it. -- rgr,
There are many ways to customise emacs, including the following, from
simplest to most complicated:
All of these can be put in your .emacs file so that they
persist from session to session.
- Setting variables.
- Rebinding keys.
- Writing keyboard macros.
- Defining hook functions.
- Writing emacs lisp code.
The .emacs file
emacs loads the .emacs file from your home directory every time
you start emacs. This file should contain a series of emacs lisp
(also known as forms or, more obscurely, symbolic
expressions or sexps), each of which is evaluated in
turn. Each expression is of the form:
- a self-defining constant (integer, floating point number, or
string surrounded by double quotes);
Variables may be set with the M-x set-variable command,
which prompts for the variable name, and then a value.
(global-set-key "\C-cb" 'bury-buffer)
or, for a keybinding that is specific to mail-mode:
(define-key mail-mode-map "\C-cb" 'bury-buffer)
Writing keyboard macros
Since you can bind a string of characters that invoke commands to a key,
the way to save a keyboard macro is like this:
(global-set-key "\C-cf" "This is some inserted text.
It occupies two lines\n")
Remember that ordinary characters are commands that insert themselves.
Defining hook functions
Writing emacs lisp code
If you've been keeping up with the preceding discussion, then you're
already reading emacs lisp code.
The minimum command would look like this:
(defun foo-command ()
(insert "This is some inserted text.
It occupies two lines\n"))
(global-set-key "\C-cf" 'foo-command)
You could then invoke foo-command by typing "C-c f", in
Last modified: Sun Jun 18 22:33:41 EDT 2000