1. Overview
As you are probably aware, Emacs does various sorts of completion, if
you ask it to. For instance, if you hit C-x C-f to find a file,
then (once you are in the minibuffer) if you hit the TAB key, Emacs
completes the file name if there is a unique completion. Lightning
completion offers an improvement to this, an improvement in several
ways:
-
Once lightning completion is initiated, it remains active until a
completion is found, or until turned off. If I have three files,
`alphabet', `alpo', and `bozo', and I initiate completion
on file names, if I hit a, then `alp' is inserted; hitting
h would then produce `alphabet', and hitting o would
produce `alpo'. Similarly, hitting b at the start, instead
of a, would have produced `bozo'. This sort of completion,
in which completion is always on--you don't have to keep hitting the
SPC or TAB key to complete--is called "dynamic"
completion.
-
Lightning completion takes effect only if Emacs is idle for a length of
time specified by the variable
lc-complete-idle-time-default, the
default value of which is 0.5 seconds. So in the above example, you can
type "alph" or "alpha" or "alphab"; then if you wait for half a second,
Emacs will automatically complete it for you. This is a new feature of
lightning completion; if you are used to the old version, you can set
this delay to be 0. If you are a slow typist and you don't want Emacs
completing unless you take a very deliberate pause, you can set it to
something like 2.
-
Lightning completion can be initiated anywhere, not just in the
minibuffer. If I'm writing email to someone, and I want to include the
path name for some file, I type the first few letters of the path, then
run the function
completing-insert-file-name, and I'm in
lightning completion mode. There are similar function calls for
completion on buffer names, lisp objects, lisp functions, lisp
variables, and the contents of the kill ring.
Some remarks:
-
Dynamic completion, like any completion, has a nice side-effect: you can
use long (and hence descriptive) file names, variable names, function
names, whatever, because you hardly ever have to type the whole thing
in. So I don't mind that my directory structure in my account is deep
and the directories have long names--I can find the file
`~/tex/work/papers/hovey-strickland/axiomatic.tex' with 6
keystrokes: one each for "t", "w", "p", "h", and "a", and then
RET. (One also gets in the habit of trying to arrange it so that
each of one's files in any given directory starts with a different
letter.)
-
If you mainly use lightning completion with file names and if you edit
the same files over and over again, you will quickly learn exactly which
characters you have to type to find each file. In this case, you might
want to set
lc-complete-idle-time-default to be close to zero.
If you don't want to bother learning this, and if you are worried that
lightning completion will make you watch the screen all the time to see
what has been completed and what hasn't, then you should set
lc-complete-idle-time-default to be a larger number, so that
completions only occur after a good pause.
-
Lightning completion is also one of the main ingredients to
Ultra-TeX mode, a major mode for typing TeX documents. Most
TeX commands start with a backslash, so in that mode, hitting "\"
starts lightning completion on TeX commands. The Ultra-TeX
package is available from
http://www.math.washington.edu/~palmieri/Emacs/ultratex.html.
-
This package should be compatible with GNU Emacs 19, GNU Emacs 20, and
XEmacs ("should be compatible" means that I've at least tried it out a
bit with each one of these, without running into problems). I mostly
use GNU Emacs 20, so I know it works there. I expect it to work pretty
well with XEmacs, too, but I don't use GNU Emacs 19 anymore, and I don't
test this package very vigorously there.
-
Dynamic completion is an acquired taste. It can be rather off-putting
at the start, especially with a short
lc-complete-idle-time-default, but once you get used to it, it's
just wonderful.
In the following sections, I describe what functions to call to start
lightning completion, which keys do what once completion is engaged, how
to automate things a bit (e.g., so that find-file automatically
uses lightning completion on file names), and how to install all of
this.
This document was generated
on September, 30 2005
using texi2html