Go to the first, previous, next, last section, table of contents.

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. If you set dabbrev-case-fold-search to nil, then the word and the expansion must match in case.

The value of dabbrev-case-fold-search may be any expression. Dynamic abbrev expansion evaluates that expression, and ignores case while searching if its value is not nil. The default value of dabbrev-case-fold-search is case-fold-search, so normally the value of case-fold-search controls the decision. The reason why dynamic abbrev expansion normally ignores case when searching for expansions is that normally the value of case-fold-search is t.

Normally, dynamic abbrev expansion preserves the case pattern of the word you are expanding, by converting the expansion to that case pattern. If you set dabbrev-case-replace to nil, the expansion is copied without conversion.

The variables dabbrev-case-fold-search and dabbrev-case-replace are handled in a special way. Their values are actually Lisp expressions which are evaluated each time a decision needs to be made. If the expression's value is non-nil, then case is ignored in searching, or converted on replacement, respectively. If the expression's value is nil, case is not ignored or not converted. The default values let the variables case-fold-search (see section Searching and Case) and case-replace (see section Replace Commands and Case) control what to do.

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: abbreviations 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 abbreviation 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 abbreviation should ignore.


Go to the first, previous, next, last section, table of contents.