Previous: , Up: Abbrevs   [Contents][Index]

29.7 Customizing Dynamic Abbreviation

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 Search Case).

Normally, dynamic abbrev expansion preserves the case pattern of the dynamic abbrev you are expanding, by converting the expansion to that case pattern.

The variable 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 Case).

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.

The variable 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 value nil has a special meaning: dynamic abbrevs are made of word characters, but expansions are made of word and symbol characters.

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.


Previous: , Up: Abbrevs   [Contents][Index]