WARNING: Abv is unfinished and under heavy development. APIs, file formats, and internal structures may change without notice.
Abv (short for abbrev) lets you type short keys and get full text.
It replaces Emacs’ built-in abbrev package with tables that know
which buffers they belong to, and it can go much further: given a model
of a natural language, it works out by itself which key every word
should get, so that keys are short, easy to type on your keyboard, and
related words get related keys.
This README is the short version. The Info manual (abv.texi,
M-x abv-manual inside Emacs) explains the architecture, every
command, and the internals.
At its simplest, Abv behaves like abbrev. You define that tbh
stands for “to be honest”, type tbh, run abv-expand, and the text
is replaced. Which definitions apply depends on the buffer: a table
for emacs-lisp-mode answers in Lisp buffers, the table of your
current language answers everywhere you write prose.
With a language table you stop defining abbreviations by hand. You tell Abv a word:
M-x abv-add-dwim RET unbelievable RET
Abv recognizes the word as un + believe + able, looks up which
key each of these morphs has on your typing layout, keeps as few of
them as it can while staying unambiguous, and binds the resulting
short key to the word. Because believe keeps its key in “believer”
and “believable”, the keys of a word family resemble each other, and
you learn a few hundred morph keys instead of tens of thousands of
arbitrary strings.
Expansion then does more than substitute text. Abv capitalizes a word
at the start of a sentence, turns “a” into “an” where needed, and lets
you inflect while typing: one key for “define” plus a short
grammatical suffix yields “defines”, “defined” or “we define”, so
inflected forms need no keys of their own. And abv-expand expands a
whole sentence of keys at once, working out from the punctuation what
you just finished typing.
The first level does not require the second.
- Basic — a replacement for native
abbrev: manage abbrev tables, set parents, control capitalization, and expand abbrevs with awareness of major and minor modes. Every property of a table (parents, override level, capitalization policy, prefix) is declared in one place and applied automatically. - Linguistic — auto-generate abbrevs for a natural language (English and German definitions ship with Abv) from a model of that language: its script, morphology, syntax, and corpus-derived frequency statistics. Abv decomposes words into morphs (prefixes, roots, suffixes, infixes), assigns them to ergonomic positions on a typing layout, generates compact keys, and binds them as abbrevs.
Abv is not yet packaged for package.el; install it from a checkout,
together with ei-interface, which provides the interactive choice
interface. It also needs dash and dictionary from MELPA.
cd ~/.emacs.d/site-lisp/
git clone <repository-url> abv
git clone <repository-url> ei-interfaceThen, in your Emacs configuration:
(add-to-list 'load-path "~/.emacs.d/site-lisp/ei-interface")
(add-to-list 'load-path "~/.emacs.d/site-lisp/abv")
(require 'abv)
(abv-mode 1)
;; Abv binds no keys of its own; bind at least these:
(global-set-key (kbd "M-'") #'abv-expand)
(global-set-key (kbd "C-M-'") #'abv-add-dwim)
(global-set-key (kbd "C-c '") #'abv-add)Abv requires Emacs 30.1 or later.
- Enable Abv with
M-x abv-mode. This loads the current collection from disk and sets up mode-change hooks. - If you have existing Emacs abbrev tables, import them:
M-x abv-fileand choose “Import Emacs abbrev tables”. - Add an abbrev: place point after a word, run
M-x abv-addand choose “Abbrev from the region or the word before point”. - Expand by typing a key and running
abv-expand, which works out from the context how much to expand. - Ask what is going on:
M-x abv-inforeports which tables answer in the current buffer,M-x abv-look-upfinds the key of an expansion.
- Give the collection a layout. Without Daselt, run
M-x abv-qwerty-set-current-layout. - Create a language table, either from scratch or by converting an
imported table with
M-x abv-language-table-integrate, and make its language current withM-x abv-switch-language. - Add words:
M-x abv-add-dwimfor one, andM-x abv-addwith “Words from the plain-text dictionary” for many. - Once the table has grown, let
M-x abv-retuneredistribute the keys so that the words you use most get the best ones.
Everything Abv knows lives in one object, the collection. It is
loaded when abv-mode starts and saved after every editing command.
collection |-- tables ............. what expands to what, and where | |-- major-mode tables (one buffer type each) | |-- minor-mode tables (switched on and off) | |-- name tables (proper names) | `-- language tables (generated from a language model) | `-- sublingual tables (a domain's extra vocabulary) |-- layout ............. your keyboard, and one typing graph | per language: which morph has which key |-- parse data ......... the special characters of typed input |-- options ............ input prefixes, completion, activity `-- runtime state ...... current language, last visible mode
Three questions organize the system, and each has one owner:
- What does this key expand to? A table: a mapping from keys to expansions, wrapping an Emacs abbrev table.
- Which tables answer here, and in what order? The collection. Every table has an activation rule (its major mode is current, its minor mode is on, its language is the current one, or you activated it in this buffer) and an override level that ranks it. A table that does not know a key hands the question to its parents.
- Which key should this word get? The language model together with the layout. The language supplies a script, morph data and a syntax; the layout records, per language, which morph is typed with which key.
The language model is independent of your keyboard, and the layout is independent of your vocabulary: you can change keyboards and have every key regenerated, or add a domain vocabulary without touching the language.
When you add a word to a language table, Abv has to find it a key:
"unbelievable"
| filter is it merely an inflected form of a known word?
| classify adjective
| extract (un . prefix) (believe . root) (able . suffix)
| score rank the candidate decompositions
| review you (or an LLM) confirm or correct
v
morph-sequence
| distill keep the morphs needed to stay unambiguous
v
distillate
| type look each morph up in the typing graph
| embellish resolve remaining collisions
v
key ---- bind ---> table
This decides each word’s key when the word arrives, which is fair to
the words already there but not optimal overall. abv-retune
therefore revisits a whole table at once and seats all words together,
weighing typing effort, how much a key resembles its word, how often
you actually use the word, and the cost of changing a key you have
already learned.
A handful of entry points cover everyday use; most of them open a menu of more specific actions.
| Command | Description |
|---|---|
abv-expand | Expand the word before point, else dispatch on context |
abv-add-dwim | Add what fits the active tables (a word, by default) |
abv-add | Choose a thing to add (abbrev, name, morph, parent, …) |
abv-edit-dwim | Edit what fits the active tables (the word at point) |
abv-edit | Choose a thing to edit (morph-sequence, typing, word syntax, …) |
abv-remove | Choose a thing to remove or prune |
abv-file | Save, load, back up, restore, import; cache upkeep |
abv-info | Reports: active tables, abbrev counts |
abv-look-up | Find the key of an expansion |
abv-activate / abv-deactivate | Buffer-locally toggle tables |
abv-switch-language | Change the current language |
abv-retune | Reassign the keys of a whole language table |
abv-manual | Open the Info manual |
- Sublingual tables hold a domain’s vocabulary (technical terms, jargon). They share the parent language’s morphs and script but keep their own word types, distillate and entries, so a medical-terminology table can use the English model while its expansions stay separate and take precedence.
- Programming and LaTeX tables are major-mode tables that know the structures of their mode, such as LaTeX math and environments.
- Terminal buffers: Abv expands inside
vterm.
- Daselt — a typing-layout system based on layered coordinate grids,
which Abv is designed to work with. It is optional:
abv-qwerty.elprovides a layout for ordinary keyboards and doubles as a worked example for writing your own. ei-interface— the completion-driven drill-down you see when choosing, adding, editing or removing something. Required.gptel— when available, Abv can ask an LLM to classify words, suggest morph boundaries, check syntax, and iteratively improve the scoring that ranks candidate decompositions (abv-tune). The LLM proposes and you dispose: proposals arrive in editable review buffers. Nothing requires an LLM; every LLM-assisted step has a manual counterpart.
The manual is abv.texi, built to abv.info and abv.html next to
the sources. abv-mode registers the directory with Info, so
M-x abv-manual and C-h i g (abv) RET both find it. To rebuild:
makeinfo abv.texi
makeinfo --html --no-split abv.texiIts chapter “How Abv Fits Together” is the map; if you only read one chapter, read that one.
eldev -q compile # byte-compile
timeout 600 eldev -q -T -C test # all tests
timeout 300 eldev -q -T -C test -f abv-morph-tests.el # one fileAbv is unfinished. Known gaps:
- English is the reference language definition; German is much thinner, and other languages need to be contributed.
- Distillation and key assignment are tuned on English.
- Error handling in long-running batch operations (adding thousands of words at once) is still rudimentary.
- Test coverage is incomplete.
GPL-3+. See the file headers for details.