Emacs Code
This page contains the Emacs lisp packages I develop and maintain (see below for details):
-
Predictive completion package
-
Completion UI package
-
Automatic Overlays package
-
heap.el (heaps)
-
tstree.el (ternary search tree)
-
dict-tree.el (dictionaries)
Predictive Completion Minor-Mode
The Emacs predictive completion package adds a new minor-mode to the GNU Emacs editor. When enabled, predictive mode exploits the redundancy inherent in languages in order to complete words you are typing before you've finished typing them (somewhat like the IntelliSense feature in some IDEs). It is highly customisable, and works happily alongside other Emacs major modes. See the documentation for more details.
Documentation
Full documentation is available in a variety of formats, for download and viewing online.
If you're just interested in using predictive completion mode, you should read the user guide. The programmer guide contains low-level information for people who want to write their own lisp code to enhance predictive mode, for instance to make predictive completion work in other major modes.
User Guide
-
Web documentation
-
HTML download (gzipped tar
file)
-
Info document (gzipped)
-
ASCII text (gzipped)
-
PDF file
-
Postscript file (gzipped)
-
Texinfo source
Programmer Guide
Mathias Dahl has also posted a nice tutorial about using predictive mode on his blog.
Download and Installation
The current release of the predictive completion package is version 0.21 (released July 2008). However, it's still under active development at the moment, so don't forget to check back here for updates every so often.
See the Obtaining and Installing section of the manual for installation instructions.
Bugs and Feature Requests
Right now, the predictive completion package is very much beta software, and needs bug testing by as many people as possible. Even reports of which versions of Emacs it works with would be useful at this stage (but check here first to make sure your version isn't already listed). Note that it will never work under Emacs versons older than the 21.x series.
So far, it is known to work under:
- GNU Emacs version 21.4 under Linux
- GNU Emacs CVS, multi-tty branch under Linux
- GNU Emacs version 21.3 under Windows XP
Currently, it doesn't work under XEmacs
Bugs, feature requests, and any other feedback should be addressed to toby-predictive@dr-qubit.org. (Note that this address is protected by TMDA spam-reduction software. The first time you send an email, you will have to verify your address by replying to a confirmation message.)
A list of known bugs and feature suggestions is included in the manual.
Completion User Interface
The Completion User Interface package provides user-interface functions for in-buffer completion.
Typically, a lot of code in packages providing some kind of text completion deals with the user interface. The goal is that all packages providing in-buffer (and possibly also mini-buffer) completion should use this package to provide a common user interface, freeing them to concentrate on finding the completions in the first place. The Emacs user can then customise the interface once-and-for-all to suit their tastes, rather than separately customising each package.
Documentation
The functions provided by this package are well documented using
Emacs' built-in documentation features. But basically, a completion
package just has to set the completion-function variable
to a function that takes two arguments, a string prefix
and an integer maxnum, and returns a list of at
most maxnum completion candidates for
the prefix string. (It should return all possible
completion candidates if maxnum is nil.) The
rest is taken care of!
Alternatively, a package can define a completion minor-mode using
the convenience macro completion-define-minor-mode,
passing it a function with the properties described above. The other
arguments are identical to those of the built-in
function define-minor-mode.
Various completion mechanisms are provided, all of which can be separately enabled, disabled and tweaked by the Emacs user via customisation variables:
- Dynamic completion: provisionally inserts the best completion candidate in the buffer, highlighting the completed portion.
- Completion hotkeys: single-key selection of a completion.
- Cycling: cycle through completion candidates.
- Tab-completion: "traditional" expansion to longest common substring.
- Help-echo: display a list of completion candidates in the echo-area.
- Tooltip: display a list of completion candidates in a tool-tip located below the point.
- Completion menu: allow completion candidates to be selected from a drop-down menu located below the point.
Download and Installation
The current release of the Completion User Interface package is version 0.9 (released July 2008). However, it's still under active development at the moment, so don't forget to check back here for updates every so often.
To install, simply save the file to a directory in your Emacs
load-path.
Automatic Overlays
The Automatic Overlays package allows you to define overlays that are created (and updated and destroyed) automatically when text in a buffer matches a regular expression.
Various classes of automatic overlay are provided, to make it easy to define matches for different text regions: words, lines, regions enclosed by start and end tags, or regions enclosed by delimiters. You can also define your own custom classes.
The overlays are updated just before any buffer modification. The built in overlay classes only update as much as is necessary to ensure that overlays covering the point are consistent. Therefore the overlays at the point are guaranteed to be correct before any buffer modification takes place there, but updating the overlays takes very little time and causes no noticeable delay.
Documentation
Full documentation is available in a variety of formats, for download or for viewing online. Since Auto-Overlays is an Elisp library, intended to be used by other Elisp packages, the documentation is aimed at Elisp programmers, not Emacs users.
Auto-Overlay Manual
-
Web documentation
-
HTML download (gzipped tar
file)
-
Info document (gzipped)
-
ASCII text (gzipped)
-
PDF file
-
Postscript file (gzipped)
-
Texinfo source (gzipped tar
file)
Download and Installation
The current release of the Automatic Overlays package is version 0.10.2 (released July 2008). However, it's still under active development at the moment, so don't forget to check back here for updates every so often.
To install, simply extract the files to a directory in your Emacs
load-path.
Data Structures
These packages provide basic (and not so basic) data structures.
Documentation
The functions these packages provide are well documented using Emacs' built-in documentation features.
A heap is a form of efficient self-sorting tree. In particular, the root node is guaranteed to be the highest-ranked entry in the tree. (The comparison function used for ranking the data can, of course, be freely defined). They are often used as priority queues, for scheduling tasks in order of importance.
A ternary search tree stores data associated with "strings" (not necessarily the string data type; any ordered sequence of elements is also valid). It stores them in such a way that both storage size and data lookup are reasonably space- and time- efficient, respectively. But more importantly, returning all strings with a given prefix in alphabetical or any other sort-order is also time-efficient.
The dictionary structures are a hybrid between ternary search trees and hash tables. If prefix searches are required, data is stored in a ternary search tree, but results that take particularly long to retrieve are cached in hash tables, which are automatically kept synchronised with the tree (immediately, not in idle-time). If prefix searches are not required, data is just stored in a hash table. The dictionary package provides persistent storage of the data structures in files, and various other convenience features.
Download and Installation
Each package requires the ones above it in the list. They are all relatively stable, though bug-fixes and new features are added occasionally. (Latest releases: July 2008).
To install, simply copy the files to a directory in your
Emacs load-path.