The abbrev facility described above operates automatically as you insert text, but all abbrevs must be defined explicitly. By contrast, dynamic abbrevs allow the meanings of abbreviations to be determined automatically from the contents of the buffer, but dynamic abbrev expansion happens only when you request it explicitly.
Expand the word in the buffer before point as a dynamic abbrev,
by searching in the buffer for words starting with that abbreviation
Complete the word before point as a dynamic abbrev
For example, if the buffer contains ‘does this follow ’ and you
type f o M-/, the effect is to insert ‘follow’ because that
is the last word in the buffer that starts with ‘fo’. A numeric
argument to M-/ says to take the second, third, etc. distinct
expansion found looking backward from point. Repeating M-/
searches for an alternative expansion by looking farther back. After
scanning all the text before point, it searches the text after point.
dabbrev-limit, if non-
nil, specifies how far
away in the buffer to search for an expansion.
After scanning the current buffer, M-/ normally searches other
buffers, unless you have set
For finer control over which buffers to scan, customize the variable
dabbrev-ignored-buffer-regexps. Its value is a list of regular
expressions. If a buffer’s name matches any of these regular
expressions, dynamic abbrev expansion skips that buffer.
A negative argument to M-/, as in C-u - M-/, says to search first for expansions after point, then other buffers, and consider expansions before point only as a last resort. If you repeat the M-/ to look for another expansion, do not specify an argument. Repeating M-/ cycles through all the expansions after point and then the expansions before point.
After you have expanded a dynamic abbrev, you can copy additional words that follow the expansion in its original context. Simply type SPC M-/ for each additional word you want to copy. The spacing and punctuation between words is copied along with the words.
The command C-M-/ (
completion of a dynamic abbrev. Instead of trying the possible
expansions one by one, it finds all of them, then inserts the text
that they have in common. If they have nothing in common, C-M-/
displays a list of completions, from which you can select a choice in
the usual manner. See Completion.
Dynamic abbrev expansion is completely independent of Abbrev mode; the expansion of a word with M-/ is completely independent of whether it has a definition as an ordinary abbrev.