diff options
| author | Eli Zaretskii | 2020-09-27 08:57:17 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-09-27 08:57:17 +0300 |
| commit | c37370a7a0f329d13cf00a06e446514be09a7bab (patch) | |
| tree | 57b3ac3274ae1df4372020b25f1d1f7f7ca4ce81 | |
| parent | 768676f74f093e75e2d7e04e18e1fd1836d1e7e9 (diff) | |
| download | emacs-c37370a7a0f329d13cf00a06e446514be09a7bab.tar.gz emacs-c37370a7a0f329d13cf00a06e446514be09a7bab.zip | |
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'.
| -rw-r--r-- | doc/emacs/abbrevs.texi | 39 | ||||
| -rw-r--r-- | doc/emacs/emacs.texi | 1 | ||||
| -rw-r--r-- | etc/NEWS | 10 | ||||
| -rw-r--r-- | lisp/abbrev.el | 27 |
4 files changed, 41 insertions, 36 deletions
diff --git a/doc/emacs/abbrevs.texi b/doc/emacs/abbrevs.texi index 0dda977833f..e3766aae9e8 100644 --- a/doc/emacs/abbrevs.texi +++ b/doc/emacs/abbrevs.texi | |||
| @@ -28,7 +28,7 @@ Automatic Typing}. | |||
| 28 | * Abbrev Concepts:: Fundamentals of defined abbrevs. | 28 | * Abbrev Concepts:: Fundamentals of defined abbrevs. |
| 29 | * Defining Abbrevs:: Defining an abbrev, so it will expand when typed. | 29 | * Defining Abbrevs:: Defining an abbrev, so it will expand when typed. |
| 30 | * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. | 30 | * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. |
| 31 | * Abbrevs Suggestions:: Get suggestions about defined abbrevs. | 31 | * Abbrevs Suggestions:: Get automatic suggestions about defined abbrevs. |
| 32 | * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs. | 32 | * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs. |
| 33 | * Saving Abbrevs:: Saving the entire list of abbrevs for another session. | 33 | * Saving Abbrevs:: Saving the entire list of abbrevs for another session. |
| 34 | * Dynamic Abbrevs:: Abbreviations for words already in the buffer. | 34 | * Dynamic Abbrevs:: Abbreviations for words already in the buffer. |
| @@ -224,34 +224,35 @@ changing this function you can make arbitrary changes to | |||
| 224 | the abbrev expansion. @xref{Abbrev Expansion,,, elisp, The Emacs Lisp | 224 | the abbrev expansion. @xref{Abbrev Expansion,,, elisp, The Emacs Lisp |
| 225 | Reference Manual}. | 225 | Reference Manual}. |
| 226 | 226 | ||
| 227 | @node Abbrev Suggestions | 227 | @node Abbrevs Suggestions |
| 228 | @section Abbrev Suggestions | 228 | @section Abbrevs Suggestions |
| 229 | 229 | ||
| 230 | You can get abbrev suggestions when you manually type text for which | 230 | You can get abbrev suggestions when you manually type text for which |
| 231 | there is currently an active defined abbrev. For example, if there is | 231 | there is currently an active defined abbrev. For example, if there is |
| 232 | an abbrev @samp{foo} with the expansion @samp{find outer otter}, and | 232 | an abbrev @samp{foo} with the expansion @samp{find outer otter}, and |
| 233 | you manually type @samp{find outer otter}, the abbrev suggestion | 233 | you manually type @samp{find outer otter}, Emacs can notice this and |
| 234 | feature will notice this and show a hint in the echo area when you | 234 | show a hint in the echo area when you have stopped typing. |
| 235 | have stopped typing. | ||
| 236 | 235 | ||
| 237 | @vindex abbrev-suggest | 236 | @vindex abbrev-suggest |
| 238 | Enable the abbrev suggestion feature by setting | 237 | To enable the abbrev suggestion feature, customize the option |
| 239 | @code{abbrev-suggest} to @code{t}. | 238 | @code{abbrev-suggest} to a non-@code{nil} value. |
| 240 | 239 | ||
| 241 | @vindex abbrev-suggest-hint-threshold | 240 | @vindex abbrev-suggest-hint-threshold |
| 242 | Controls when to suggest an abbrev to the user. The variable | 241 | The variable @code{abbrev-suggest-hint-threshold} controls when to |
| 243 | defines the number of characters that the user must save in order to | 242 | suggest an abbrev to the user. This variable defines the minimum |
| 244 | get a suggestion. For example, if the user types @samp{foo bar} | 243 | savings (in terms of the number of characters the user will not have |
| 245 | (seven characters) and there is an abbrev @samp{fubar} defined (five | 244 | to type) required for Emacs to suggest using an abbrev. For example, |
| 246 | characters), the user will not get any suggestion unless the threshold | 245 | if the user types @samp{foo bar} (seven characters) and there is an |
| 247 | is set to the number 2 or lower. With the default value 3, the user | 246 | abbrev @samp{fubar} defined (five characters), the user will not get |
| 248 | would not get any suggestion, because the savings in using the abbrev | 247 | any suggestion unless the threshold is set to the number 2 or lower. |
| 249 | are not above the threshold. If you always want to get abbrev | 248 | With the default value 3, the user would not get any suggestion in |
| 250 | suggestions, set this variable to 0. | 249 | this example, because the savings in using the abbrev are below |
| 250 | the threshold. If you always want to get abbrev suggestions, set this | ||
| 251 | variable's value to zero. | ||
| 251 | 252 | ||
| 252 | @findex abbrev-suggest-show-report | 253 | @findex abbrev-suggest-show-report |
| 253 | The command @code{abbrev-suggest-show-report} can be used to show a | 254 | The command @code{abbrev-suggest-show-report} displays a buffer with |
| 254 | buffer with all abbrev suggestions from the current editing session. | 255 | all the abbrev suggestions shown during the current editing session. |
| 255 | This can be useful if you get several abbrev suggestions and don't | 256 | This can be useful if you get several abbrev suggestions and don't |
| 256 | remember them all. | 257 | remember them all. |
| 257 | 258 | ||
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index 6aed7bd92a5..566229b2f32 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi | |||
| @@ -908,6 +908,7 @@ Abbrevs | |||
| 908 | * Abbrev Concepts:: Fundamentals of defined abbrevs. | 908 | * Abbrev Concepts:: Fundamentals of defined abbrevs. |
| 909 | * Defining Abbrevs:: Defining an abbrev, so it will expand when typed. | 909 | * Defining Abbrevs:: Defining an abbrev, so it will expand when typed. |
| 910 | * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. | 910 | * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. |
| 911 | * Abbrevs Suggestions:: Get automatic suggestions about defined abbrevs. | ||
| 911 | * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs. | 912 | * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs. |
| 912 | * Saving Abbrevs:: Saving the entire list of abbrevs for another session. | 913 | * Saving Abbrevs:: Saving the entire list of abbrevs for another session. |
| 913 | * Dynamic Abbrevs:: Abbreviations for words already in the buffer. | 914 | * Dynamic Abbrevs:: Abbreviations for words already in the buffer. |
| @@ -1274,12 +1274,12 @@ of conditionals. | |||
| 1274 | ** Abbrev mode | 1274 | ** Abbrev mode |
| 1275 | 1275 | ||
| 1276 | +++ | 1276 | +++ |
| 1277 | *** Abbrev can now suggest pre-existing abbrevs based on typed text. | 1277 | *** Emacs can now suggest to use an abbrev based on text you type. |
| 1278 | A new user option, 'abbrev-suggest', enables the new abbrev suggestion | 1278 | A new user option, 'abbrev-suggest', enables the new abbrev suggestion |
| 1279 | feature. When enabled, if a user manually type a piece of text that | 1279 | feature. When enabled, if a user manually types a piece of text that |
| 1280 | could have been written by using an abbrev, a hint will be displayed | 1280 | could have saved enough typing by using an abbrev, a hint will be |
| 1281 | in the echo area, mentioning the abbrev that could have been used | 1281 | displayed in the echo area, mentioning the abbrev that could have been |
| 1282 | instead. | 1282 | used instead. |
| 1283 | 1283 | ||
| 1284 | 1284 | ||
| 1285 | * New Modes and Packages in Emacs 28.1 | 1285 | * New Modes and Packages in Emacs 28.1 |
diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 75cc43941f4..dc52a220125 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el | |||
| @@ -825,22 +825,23 @@ see `define-abbrev' for details." | |||
| 825 | Takes no argument and should return the abbrev symbol if expansion took place.") | 825 | Takes no argument and should return the abbrev symbol if expansion took place.") |
| 826 | 826 | ||
| 827 | (defcustom abbrev-suggest nil | 827 | (defcustom abbrev-suggest nil |
| 828 | "Non-nil means suggest abbrevs to the user. | 828 | "Non-nil means suggest using abbrevs to save typing. |
| 829 | By enabling this option, if abbrev mode is enabled and if the | 829 | When abbrev mode is active and this option is non-nil, Emacs will |
| 830 | user has typed some text that exists as an abbrev, suggest to the | 830 | suggest in the echo area to use an existing abbrev if doing so |
| 831 | user to use the abbrev by displaying a message in the echo area." | 831 | will save enough typing. See `abbrev-suggest-hint-threshold' for |
| 832 | the definition of \"enough typing\"." | ||
| 832 | :type 'boolean | 833 | :type 'boolean |
| 833 | :version "28.1") | 834 | :version "28.1") |
| 834 | 835 | ||
| 835 | (defcustom abbrev-suggest-hint-threshold 3 | 836 | (defcustom abbrev-suggest-hint-threshold 3 |
| 836 | "Threshold for when to inform the user that there is an abbrev. | 837 | "Threshold for when to suggest to use an abbrev to save typing. |
| 837 | The threshold is the number of characters that differ between the | 838 | The threshold is the amount of typing, in terms of the number of |
| 838 | length of the abbrev and the length of the expansion. The | 839 | characters, that would be saved by using the abbrev. The |
| 839 | thinking is that if the expansion is only one or a few characters | 840 | thinking is that if the expansion is only a few characters |
| 840 | longer than the abbrev, the benefit of informing the user is not | 841 | longer than the abbrev, the benefit of informing the user is not |
| 841 | that big. If you always want to be informed, set this value to | 842 | significant. If you always want to be informed about existing |
| 842 | `0' or less. This setting only applies if `abbrev-suggest' is | 843 | abbrevs for the text you type, set this value to zero or less. |
| 843 | non-nil." | 844 | This setting only applies if `abbrev-suggest' is non-nil." |
| 844 | :type 'number | 845 | :type 'number |
| 845 | :version "28.1") | 846 | :version "28.1") |
| 846 | 847 | ||
| @@ -945,7 +946,9 @@ typed." | |||
| 945 | total)) | 946 | total)) |
| 946 | 947 | ||
| 947 | (defun abbrev-suggest-show-report () | 948 | (defun abbrev-suggest-show-report () |
| 948 | "Show the user a report of abbrevs he could have used." | 949 | "Show a buffer with the list of abbrevs you could have used. |
| 950 | This shows the abbrevs you've \"missed\" because you typed the | ||
| 951 | full text instead of the abbrevs that expand into that text." | ||
| 949 | (interactive) | 952 | (interactive) |
| 950 | (let ((totals (abbrev--suggest-get-totals)) | 953 | (let ((totals (abbrev--suggest-get-totals)) |
| 951 | (buf (get-buffer-create "*abbrev-suggest*"))) | 954 | (buf (get-buffer-create "*abbrev-suggest*"))) |