Commit 3f7ba267 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

Minor clarifications.

(Dabbrev Customization): Talk about "dynamic abbrev expansion",
not "dynamic abbrevs" as if they were a kind of abbrev.
parent b6a71fbb
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
A defined @dfn{abbrev} is a word which @dfn{expands}, if you insert A defined @dfn{abbrev} is a word which @dfn{expands}, if you insert
it, into some different text. Abbrevs are defined by the user to expand it, into some different text. Abbrevs are defined by the user to expand
in specific ways. For example, you might define @samp{foo} as an abbrev in specific ways. For example, you might define @samp{foo} as an abbrev
expanding to @samp{find outer otter}. Then you would be able to insert expanding to @samp{find outer otter}. Then you could insert
@samp{find outer otter } into the buffer by typing @kbd{f o o @samp{find outer otter } into the buffer by typing @kbd{f o o
@key{SPC}}. @key{SPC}}.
...@@ -20,9 +20,9 @@ to expand the letters in the buffer before point by looking for other ...@@ -20,9 +20,9 @@ to expand the letters in the buffer before point by looking for other
words in the buffer that start with those letters. @xref{Dynamic words in the buffer that start with those letters. @xref{Dynamic
Abbrevs}. Abbrevs}.
``Hippie'' expansion generalizes abbreviation expansion. @xref{Hippie ``Hippie'' expansion generalizes abbreviation expansion.
Expand, , Hippie Expansion, autotype, Features for Automatic @xref{Hippie Expand, , Hippie Expansion, autotype, Features for
Typing}. Automatic Typing}.
@menu @menu
* Abbrev Concepts:: Fundamentals of defined abbrevs. * Abbrev Concepts:: Fundamentals of defined abbrevs.
...@@ -57,16 +57,16 @@ turns Abbrev mode on if the argument is positive, off otherwise. ...@@ -57,16 +57,16 @@ turns Abbrev mode on if the argument is positive, off otherwise.
on when the variable is non-@code{nil}. The variable @code{abbrev-mode} on when the variable is non-@code{nil}. The variable @code{abbrev-mode}
automatically becomes local to the current buffer when it is set. automatically becomes local to the current buffer when it is set.
Abbrev definitions can be @dfn{mode-specific}---active only in one major Abbrevs can have @dfn{mode-specific} definitions, active only in one major
mode. Abbrevs can also have @dfn{global} definitions that are active in mode. Abbrevs can also have @dfn{global} definitions that are active in
all major modes. The same abbrev can have a global definition and various all major modes. The same abbrev can have a global definition and various
mode-specific definitions for different major modes. A mode-specific mode-specific definitions for different major modes. A mode-specific
definition for the current major mode overrides a global definition. definition for the current major mode overrides a global definition.
Abbrevs can be defined interactively during the editing session. Lists Yu can define abbrevs interactively during the editing session. You
of abbrev definitions can also be saved in files and reloaded in later can also save lists of abbrev definitions in files for use in later
sessions. Some users keep extensive lists of abbrevs that they load in sessions. Some users keep extensive lists of abbrevs that they load
every session. in every session.
@node Defining Abbrevs @node Defining Abbrevs
@section Defining Abbrevs @section Defining Abbrevs
...@@ -88,8 +88,7 @@ Define @var{abbrev} as an abbrev expanding into @var{exp}. ...@@ -88,8 +88,7 @@ Define @var{abbrev} as an abbrev expanding into @var{exp}.
@item M-x define-mode-abbrev @key{RET} @var{abbrev} @key{RET} @var{exp} @key{RET} @item M-x define-mode-abbrev @key{RET} @var{abbrev} @key{RET} @var{exp} @key{RET}
Define @var{abbrev} as a mode-specific abbrev expanding into @var{exp}. Define @var{abbrev} as a mode-specific abbrev expanding into @var{exp}.
@item M-x kill-all-abbrevs @item M-x kill-all-abbrevs
This command discards all abbrev definitions currently in effect, Discard all abbrev definitions, leaving a blank slate.
leaving a blank slate.
@end table @end table
@kindex C-x a g @kindex C-x a g
...@@ -118,13 +117,13 @@ as for @kbd{C-x a g}. ...@@ -118,13 +117,13 @@ as for @kbd{C-x a g}.
@findex inverse-add-global-abbrev @findex inverse-add-global-abbrev
@kindex C-x a i l @kindex C-x a i l
@findex inverse-add-mode-abbrev @findex inverse-add-mode-abbrev
If the text already in the buffer is the abbrev, rather than its If the abbrev text itself is already in the buffer, you can use the
expansion, use command @kbd{C-x a i g} commands @kbd{C-x a i g} (@code{inverse-add-global-abbrev}) and
(@code{inverse-add-global-abbrev}) instead of @kbd{C-x a g}, or use @kbd{C-x a i l} (@code{inverse-add-mode-abbrev}) to define it as an
@kbd{C-x a i l} (@code{inverse-add-mode-abbrev}) instead of @kbd{C-x a abbrev by specify the expansion in the minibuffer. These commands are
l}. These commands are called ``inverse'' because they invert the called ``inverse'' because they invert the meaning of the two text
meaning of the two text strings they use (one from the buffer and one strings they use (one from the buffer and one read with the
read with the minibuffer). minibuffer).
@findex define-mode-abbrev @findex define-mode-abbrev
@findex define-global-abbrev @findex define-global-abbrev
...@@ -137,14 +136,12 @@ It reads two arguments---the abbrev, and its expansion. The command ...@@ -137,14 +136,12 @@ It reads two arguments---the abbrev, and its expansion. The command
When the abbrev has a prior definition, the abbrev definition commands When the abbrev has a prior definition, the abbrev definition commands
ask for confirmation before replacing it. ask for confirmation before replacing it.
To remove an abbrev definition, give a negative argument to the abbrev
definition command: @kbd{C-u - C-x a g} or @kbd{C-u - C-x a l}. The
former removes a global definition, while the latter removes a
mode-specific definition.
@findex kill-all-abbrevs @findex kill-all-abbrevs
@kbd{M-x kill-all-abbrevs} removes all the abbrev definitions there To remove an abbrev definition, give a negative argument to the
are, both global and local. abbrev definition command: @kbd{C-u - C-x a g} or @kbd{C-u - C-x a l}.
The former removes a global definition, while the latter removes a
mode-specific definition. @kbd{M-x kill-all-abbrevs} removes all
abbrev definitions, both global and local.
@node Expanding Abbrevs @node Expanding Abbrevs
@section Controlling Abbrev Expansion @section Controlling Abbrev Expansion
...@@ -179,9 +176,9 @@ Expand some or all abbrevs found in the region. ...@@ -179,9 +176,9 @@ Expand some or all abbrevs found in the region.
@kindex M-' @kindex M-'
@findex abbrev-prefix-mark @findex abbrev-prefix-mark
You may wish to expand an abbrev with a prefix attached; for example, You may wish to expand an abbrev and attach a prefix to the expansion;
if @samp{cnst} expands into @samp{construction}, you might want to use for example, if @samp{cnst} expands into @samp{construction}, you might want
it to enter @samp{reconstruction}. It does not work to type to use it to enter @samp{reconstruction}. It does not work to type
@kbd{recnst}, because that is not necessarily a defined abbrev. What @kbd{recnst}, because that is not necessarily a defined abbrev. What
you can do is use the command @kbd{M-'} (@code{abbrev-prefix-mark}) in you can do is use the command @kbd{M-'} (@code{abbrev-prefix-mark}) in
between the prefix @samp{re} and the abbrev @samp{cnst}. First, insert between the prefix @samp{re} and the abbrev @samp{cnst}. First, insert
...@@ -195,7 +192,7 @@ used. The result is the desired @samp{reconstruction}. ...@@ -195,7 +192,7 @@ used. The result is the desired @samp{reconstruction}.
If you actually want the text of the abbrev in the buffer, rather than If you actually want the text of the abbrev in the buffer, rather than
its expansion, you can accomplish this by inserting the following its expansion, you can accomplish this by inserting the following
punctuation with @kbd{C-q}. Thus, @kbd{foo C-q ,} leaves @samp{foo,} in punctuation with @kbd{C-q}. Thus, @kbd{foo C-q ,} leaves @samp{foo,} in
the buffer. the buffer, not expanding it.
@findex unexpand-abbrev @findex unexpand-abbrev
If you expand an abbrev by mistake, you can undo the expansion and If you expand an abbrev by mistake, you can undo the expansion and
...@@ -234,6 +231,7 @@ Edit a list of abbrevs; you can add, alter or remove definitions. ...@@ -234,6 +231,7 @@ Edit a list of abbrevs; you can add, alter or remove definitions.
The output from @kbd{M-x list-abbrevs} looks like this: The output from @kbd{M-x list-abbrevs} looks like this:
@example @example
@var{various other tables@dots{}}
(lisp-mode-abbrev-table) (lisp-mode-abbrev-table)
"dk" 0 "define-key" "dk" 0 "define-key"
(global-abbrev-table) (global-abbrev-table)
...@@ -322,16 +320,16 @@ variable @code{save-abbrevs} to @code{nil}. ...@@ -322,16 +320,16 @@ variable @code{save-abbrevs} to @code{nil}.
similar to the previous commands but work on text in an Emacs buffer. similar to the previous commands but work on text in an Emacs buffer.
@kbd{M-x insert-abbrevs} inserts text into the current buffer after point, @kbd{M-x insert-abbrevs} inserts text into the current buffer after point,
describing all current abbrev definitions; @kbd{M-x define-abbrevs} parses describing all current abbrev definitions; @kbd{M-x define-abbrevs} parses
the entire current buffer and defines abbrevs accordingly.@refill the entire current buffer and defines abbrevs accordingly.
@node Dynamic Abbrevs @node Dynamic Abbrevs
@section Dynamic Abbrev Expansion @section Dynamic Abbrev Expansion
The abbrev facility described above operates automatically as you insert The abbrev facility described above operates automatically as you
text, but all abbrevs must be defined explicitly. By contrast, insert text, but all abbrevs must be defined explicitly. By contrast,
@dfn{dynamic abbrevs} allow the meanings of abbrevs to be determined @dfn{dynamic abbrevs} allow the meanings of abbreviations to be
automatically from the contents of the buffer, but dynamic abbrev expansion determined automatically from the contents of the buffer, but dynamic
happens only when you request it explicitly. abbrev expansion happens only when you request it explicitly.
@kindex M-/ @kindex M-/
@kindex C-M-/ @kindex C-M-/
...@@ -357,7 +355,7 @@ expansion found looking backward from point. Repeating @kbd{M-/} ...@@ -357,7 +355,7 @@ expansion found looking backward from point. Repeating @kbd{M-/}
searches for an alternative expansion by looking farther back. After searches for an alternative expansion by looking farther back. After
scanning all the text before point, it searches the text after point. scanning all the text before point, it searches the text after point.
The variable @code{dabbrev-limit}, if non-@code{nil}, specifies how far The variable @code{dabbrev-limit}, if non-@code{nil}, specifies how far
in the buffer to search for an expansion. away in the buffer to search for an expansion.
@vindex dabbrev-check-all-buffers @vindex dabbrev-check-all-buffers
After scanning the current buffer, @kbd{M-/} normally searches other After scanning the current buffer, @kbd{M-/} normally searches other
...@@ -372,21 +370,20 @@ expressions, dynamic abbrev expansion skips that buffer. ...@@ -372,21 +370,20 @@ expressions, dynamic abbrev expansion skips that buffer.
A negative argument to @kbd{M-/}, as in @kbd{C-u - M-/}, says to A negative argument to @kbd{M-/}, as in @kbd{C-u - M-/}, says to
search first for expansions after point, then other buffers, and search first for expansions after point, then other buffers, and
consider expansions before point only as a last resort. consider expansions before point only as a last resort. If you repeat
the @kbd{M-/} to look for another expansion, do not specify an
If you repeat the @kbd{M-/} to look for another expansion, do not argument. Repeating @kbd{M-/} cycles through all the expansions after
specify an argument. This tries all the expansions after point and point and then the expansions before point.
then the expansions before point.
After you have expanded a dynamic abbrev, you can copy additional After you have expanded a dynamic abbrev, you can copy additional
words that follow the expansion in its original context. Simply type words that follow the expansion in its original context. Simply type
@kbd{@key{SPC} M-/} for each word you want to copy. The spacing and @kbd{@key{SPC} M-/} for each additional word you want to copy. The
punctuation between words is copied along with the words. spacing and punctuation between words is copied along with the words.
The command @kbd{C-M-/} (@code{dabbrev-completion}) performs The command @kbd{C-M-/} (@code{dabbrev-completion}) performs
completion of a dynamic abbreviation. Instead of trying the possible completion of a dynamic abbrev. Instead of trying the possible
expansions one by one, it finds all of them, then inserts the text that expansions one by one, it finds all of them, then inserts the text
they have in common. If they have nothing in common, @kbd{C-M-/} that they have in common. If they have nothing in common, @kbd{C-M-/}
displays a list of completions, from which you can select a choice in displays a list of completions, from which you can select a choice in
the usual manner. @xref{Completion}. the usual manner. @xref{Completion}.
...@@ -411,24 +408,25 @@ in case. If the value of @code{dabbrev-case-fold-search} is ...@@ -411,24 +408,25 @@ in case. If the value of @code{dabbrev-case-fold-search} is
for expansions. for expansions.
@vindex dabbrev-case-replace @vindex dabbrev-case-replace
Normally, dynamic abbrev expansion preserves the case pattern @emph{of Normally, dynamic abbrev expansion preserves the case pattern
the abbrev you have typed}, by converting the expansion to that case @emph{of the dynamic abbrev you are expanding}, by converting the
pattern. expansion to that case pattern.
@vindex dabbrev-case-fold-search @vindex dabbrev-case-fold-search
The variable @code{dabbrev-case-replace} controls whether to preserve The variable @code{dabbrev-case-replace} controls whether to
the case pattern of the abbrev. If it is @code{t}, the abbrev's case preserve the case pattern of the dynamic abbrev. If it is @code{t},
pattern is preserved in most cases; if it is @code{nil}, the expansion is the dynamic abbrev's case pattern is preserved in most cases; if it is
always copied verbatim. If the value of @code{dabbrev-case-replace} is @code{nil}, the expansion is always copied verbatim. If the value of
@code{case-replace}, which is true by default, then the variable @code{dabbrev-case-replace} is @code{case-replace}, which is true by
@code{case-replace} controls whether to copy the expansion verbatim. default, then the variable @code{case-replace} controls whether to
copy the expansion verbatim.
However, if the expansion contains a complex mixed case pattern, and However, if the expansion contains a complex mixed case pattern, and
the abbrev matches this pattern as far as it goes, then the expansion is the dynamic abbrev matches this pattern as far as it goes, then the
always copied verbatim, regardless of those variables. Thus, for expansion is always copied verbatim, regardless of those variables.
example, if the buffer contains @code{variableWithSillyCasePattern}, and Thus, for example, if the buffer contains
you type @kbd{v a M-/}, it copies the expansion verbatim including its @code{variableWithSillyCasePattern}, and you type @kbd{v a M-/}, it
case pattern. copies the expansion verbatim including its case pattern.
@vindex dabbrev-abbrev-char-regexp @vindex dabbrev-abbrev-char-regexp
The variable @code{dabbrev-abbrev-char-regexp}, if non-@code{nil}, The variable @code{dabbrev-abbrev-char-regexp}, if non-@code{nil},
...@@ -436,16 +434,16 @@ controls which characters are considered part of a word, for dynamic expansion ...@@ -436,16 +434,16 @@ controls which characters are considered part of a word, for dynamic expansion
purposes. The regular expression must match just one character, never purposes. The regular expression must match just one character, never
two or more. The same regular expression also determines which two or more. The same regular expression also determines which
characters are part of an expansion. The value @code{nil} has a special characters are part of an expansion. The value @code{nil} has a special
meaning: abbreviations are made of word characters, but expansions are meaning: dynamic abbrevs are made of word characters, but expansions are
made of word and symbol characters. made of word and symbol characters.
@vindex dabbrev-abbrev-skip-leading-regexp @vindex dabbrev-abbrev-skip-leading-regexp
In shell scripts and makefiles, a variable name is sometimes prefixed In shell scripts and makefiles, a variable name is sometimes prefixed
with @samp{$} and sometimes not. Major modes for this kind of text can with @samp{$} and sometimes not. Major modes for this kind of text can
customize dynamic abbreviation to handle optional prefixes by setting customize dynamic abbrev expansion to handle optional prefixes by setting
the variable @code{dabbrev-abbrev-skip-leading-regexp}. Its value the variable @code{dabbrev-abbrev-skip-leading-regexp}. Its value
should be a regular expression that matches the optional prefix that should be a regular expression that matches the optional prefix that
dynamic abbreviation should ignore. dynamic abbrev expression should ignore.
@ignore @ignore
arch-tag: 638e0079-9540-48ec-9166-414083e16445 arch-tag: 638e0079-9540-48ec-9166-414083e16445
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment