1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-03 02:31:03 -08:00

Improve documentation of the 'abbrev-suggest' feature

* lisp/abbrev.el (abbrev-suggest, abbrev-suggest-hint-threshold)
(abbrev-suggest-show-report): Improve wording of the doc strings.

* doc/emacs/abbrevs.texi (Abbrevs Suggestions): Fix the typo in
the node name.  Improve wording.
* doc/emacs/emacs.texi (Top): Add the new node in the @detailmenu
section.

* etc/NEWS: Improve wording of the NEWS entry for
'abbrev-suggest'.
This commit is contained in:
Eli Zaretskii 2020-09-27 08:57:17 +03:00
parent 768676f74f
commit c37370a7a0
4 changed files with 41 additions and 36 deletions

View file

@ -28,7 +28,7 @@ Automatic Typing}.
* Abbrev Concepts:: Fundamentals of defined abbrevs. * Abbrev Concepts:: Fundamentals of defined abbrevs.
* Defining Abbrevs:: Defining an abbrev, so it will expand when typed. * Defining Abbrevs:: Defining an abbrev, so it will expand when typed.
* Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion.
* Abbrevs Suggestions:: Get suggestions about defined abbrevs. * Abbrevs Suggestions:: Get automatic suggestions about defined abbrevs.
* Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs. * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs.
* Saving Abbrevs:: Saving the entire list of abbrevs for another session. * Saving Abbrevs:: Saving the entire list of abbrevs for another session.
* Dynamic Abbrevs:: Abbreviations for words already in the buffer. * Dynamic Abbrevs:: Abbreviations for words already in the buffer.
@ -224,34 +224,35 @@ changing this function you can make arbitrary changes to
the abbrev expansion. @xref{Abbrev Expansion,,, elisp, The Emacs Lisp the abbrev expansion. @xref{Abbrev Expansion,,, elisp, The Emacs Lisp
Reference Manual}. Reference Manual}.
@node Abbrev Suggestions @node Abbrevs Suggestions
@section Abbrev Suggestions @section Abbrevs Suggestions
You can get abbrev suggestions when you manually type text for which You can get abbrev suggestions when you manually type text for which
there is currently an active defined abbrev. For example, if there is there is currently an active defined abbrev. For example, if there is
an abbrev @samp{foo} with the expansion @samp{find outer otter}, and an abbrev @samp{foo} with the expansion @samp{find outer otter}, and
you manually type @samp{find outer otter}, the abbrev suggestion you manually type @samp{find outer otter}, Emacs can notice this and
feature will notice this and show a hint in the echo area when you show a hint in the echo area when you have stopped typing.
have stopped typing.
@vindex abbrev-suggest @vindex abbrev-suggest
Enable the abbrev suggestion feature by setting To enable the abbrev suggestion feature, customize the option
@code{abbrev-suggest} to @code{t}. @code{abbrev-suggest} to a non-@code{nil} value.
@vindex abbrev-suggest-hint-threshold @vindex abbrev-suggest-hint-threshold
Controls when to suggest an abbrev to the user. The variable The variable @code{abbrev-suggest-hint-threshold} controls when to
defines the number of characters that the user must save in order to suggest an abbrev to the user. This variable defines the minimum
get a suggestion. For example, if the user types @samp{foo bar} savings (in terms of the number of characters the user will not have
(seven characters) and there is an abbrev @samp{fubar} defined (five to type) required for Emacs to suggest using an abbrev. For example,
characters), the user will not get any suggestion unless the threshold if the user types @samp{foo bar} (seven characters) and there is an
is set to the number 2 or lower. With the default value 3, the user abbrev @samp{fubar} defined (five characters), the user will not get
would not get any suggestion, because the savings in using the abbrev any suggestion unless the threshold is set to the number 2 or lower.
are not above the threshold. If you always want to get abbrev With the default value 3, the user would not get any suggestion in
suggestions, set this variable to 0. this example, because the savings in using the abbrev are below
the threshold. If you always want to get abbrev suggestions, set this
variable's value to zero.
@findex abbrev-suggest-show-report @findex abbrev-suggest-show-report
The command @code{abbrev-suggest-show-report} can be used to show a The command @code{abbrev-suggest-show-report} displays a buffer with
buffer with all abbrev suggestions from the current editing session. all the abbrev suggestions shown during the current editing session.
This can be useful if you get several abbrev suggestions and don't This can be useful if you get several abbrev suggestions and don't
remember them all. remember them all.

View file

@ -908,6 +908,7 @@ Abbrevs
* Abbrev Concepts:: Fundamentals of defined abbrevs. * Abbrev Concepts:: Fundamentals of defined abbrevs.
* Defining Abbrevs:: Defining an abbrev, so it will expand when typed. * Defining Abbrevs:: Defining an abbrev, so it will expand when typed.
* Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion.
* Abbrevs Suggestions:: Get automatic suggestions about defined abbrevs.
* Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs. * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs.
* Saving Abbrevs:: Saving the entire list of abbrevs for another session. * Saving Abbrevs:: Saving the entire list of abbrevs for another session.
* Dynamic Abbrevs:: Abbreviations for words already in the buffer. * Dynamic Abbrevs:: Abbreviations for words already in the buffer.

View file

@ -1274,12 +1274,12 @@ of conditionals.
** Abbrev mode ** Abbrev mode
+++ +++
*** Abbrev can now suggest pre-existing abbrevs based on typed text. *** Emacs can now suggest to use an abbrev based on text you type.
A new user option, 'abbrev-suggest', enables the new abbrev suggestion A new user option, 'abbrev-suggest', enables the new abbrev suggestion
feature. When enabled, if a user manually type a piece of text that feature. When enabled, if a user manually types a piece of text that
could have been written by using an abbrev, a hint will be displayed could have saved enough typing by using an abbrev, a hint will be
in the echo area, mentioning the abbrev that could have been used displayed in the echo area, mentioning the abbrev that could have been
instead. used instead.
* New Modes and Packages in Emacs 28.1 * New Modes and Packages in Emacs 28.1

View file

@ -825,22 +825,23 @@ see `define-abbrev' for details."
Takes no argument and should return the abbrev symbol if expansion took place.") Takes no argument and should return the abbrev symbol if expansion took place.")
(defcustom abbrev-suggest nil (defcustom abbrev-suggest nil
"Non-nil means suggest abbrevs to the user. "Non-nil means suggest using abbrevs to save typing.
By enabling this option, if abbrev mode is enabled and if the When abbrev mode is active and this option is non-nil, Emacs will
user has typed some text that exists as an abbrev, suggest to the suggest in the echo area to use an existing abbrev if doing so
user to use the abbrev by displaying a message in the echo area." will save enough typing. See `abbrev-suggest-hint-threshold' for
the definition of \"enough typing\"."
:type 'boolean :type 'boolean
:version "28.1") :version "28.1")
(defcustom abbrev-suggest-hint-threshold 3 (defcustom abbrev-suggest-hint-threshold 3
"Threshold for when to inform the user that there is an abbrev. "Threshold for when to suggest to use an abbrev to save typing.
The threshold is the number of characters that differ between the The threshold is the amount of typing, in terms of the number of
length of the abbrev and the length of the expansion. The characters, that would be saved by using the abbrev. The
thinking is that if the expansion is only one or a few characters thinking is that if the expansion is only a few characters
longer than the abbrev, the benefit of informing the user is not longer than the abbrev, the benefit of informing the user is not
that big. If you always want to be informed, set this value to significant. If you always want to be informed about existing
`0' or less. This setting only applies if `abbrev-suggest' is abbrevs for the text you type, set this value to zero or less.
non-nil." This setting only applies if `abbrev-suggest' is non-nil."
:type 'number :type 'number
:version "28.1") :version "28.1")
@ -945,7 +946,9 @@ typed."
total)) total))
(defun abbrev-suggest-show-report () (defun abbrev-suggest-show-report ()
"Show the user a report of abbrevs he could have used." "Show a buffer with the list of abbrevs you could have used.
This shows the abbrevs you've \"missed\" because you typed the
full text instead of the abbrevs that expand into that text."
(interactive) (interactive)
(let ((totals (abbrev--suggest-get-totals)) (let ((totals (abbrev--suggest-get-totals))
(buf (get-buffer-create "*abbrev-suggest*"))) (buf (get-buffer-create "*abbrev-suggest*")))