Normally, dynamic abbrev expansion ignores case when searching for expansions. That is, the expansion need not agree in case with the word you are expanding.
This feature is controlled by the variable
dabbrev-case-fold-search. If it is
t, case is ignored in this search; if it is
nil, the word and the expansion must match in case. If the value is
case-fold-search (the default), then the variable
case-fold-search controls whether to ignore case while searching for expansions (see Lax Search).
Normally, dynamic abbrev expansion preserves the case pattern of the dynamic abbrev you are expanding, by converting the expansion to that case pattern.
dabbrev-case-replace controls whether to preserve the case pattern of the dynamic abbrev. If it is
t, the dynamic abbrev’s case pattern is preserved in most cases; if it is
nil, the expansion is always copied verbatim. If the value is
case-replace (the default), then the variable
case-replace controls whether to copy the expansion verbatim (see Replacement and Lax Matches).
However, if the expansion contains a complex mixed case pattern, and the dynamic abbrev matches this pattern as far as it goes, then the expansion is always copied verbatim, regardless of those variables. Thus, for example, if the buffer contains
variableWithSillyCasePattern, and you type
v a M-/, it copies the expansion verbatim including its case pattern.
dabbrev-abbrev-char-regexp, if non-
nil, controls which characters are considered part of a word, for dynamic expansion purposes. The regular expression must match just one character, never two or more. The same regular expression also determines which characters are part of an expansion. The (default) value
nil has a special meaning: dynamic abbrevs (i.e. the word at point) are made of word characters, but their expansions are looked for as sequences of word and symbol characters. This is generally appropriate for expanding symbols in a program source and also for human-readable text in many languages, but may not be what you want in a text buffer that includes unusual punctuation characters; in that case, the value
"\\sw" might produce better results.
In shell scripts and makefiles, a variable name is sometimes prefixed with ‘
$’ and sometimes not. Major modes for this kind of text can customize dynamic abbrev expansion to handle optional prefixes by setting the variable
dabbrev-abbrev-skip-leading-regexp. Its value should be a regular expression that matches the optional prefix that dynamic abbrev expression should ignore. The default is
nil, which means no characters should be skipped.