unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
@ 2023-11-13 22:38 Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-14 14:17 ` Eli Zaretskii
  2023-11-14 19:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 7+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-13 22:38 UTC (permalink / raw)
  To: 67153, rms, gerd, monnier

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

Tags: patch

This patch adds 5 docstrings to abbrev.el where there were none before.
This now completes all docstrings in this Lisp file.

The patch is a documentation patch based on emacs-29.
Please let me know if this is ready to install or if changes are needed.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Add-5-docstrings-to-abbrev.el.patch --]
[-- Type: text/patch, Size: 3470 bytes --]

From fbe88f6dd4717ae07883dfdf8e87053008293753 Mon Sep 17 00:00:00 2001
From: Jeremy Bryant <jb@jeremybryant.net>
Date: Mon, 13 Nov 2023 22:24:36 +0000
Subject: [PATCH 2/2] Add 5 docstrings to abbrev.el

* lisp/abbrev.el (prepare-abbrev-list-buffer)
(add-abbrev)
(inverse-add-abbrev)
(abbrev--describe)
(abbrev--possibly-save): Add docstrings.
---
 lisp/abbrev.el | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index e1311dbc83b..70c79c1380f 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -122,6 +122,10 @@ abbrev-table-name
     found))
 
 (defun prepare-abbrev-list-buffer (&optional local)
+  "Return *Abbrevs* buffer for the caller to select or display.
+
+LOCAL is a flag, if non-nil display only local abbrevs.
+"
   (let ((local-table local-abbrev-table))
     (with-current-buffer (get-buffer-create "*Abbrevs*")
       (erase-buffer)
@@ -333,6 +337,22 @@ add-global-abbrev
   (add-abbrev global-abbrev-table "Global" arg))
 
 (defun add-abbrev (table type arg)
+  "Define an abbrev in abbrev TABLE whose expansion is last word before point.
+If there's an active region, use that as the expansion.
+
+ARG says how many words before point to use for the expansion;
+zero means the entire region is the expansion.
+
+A negative ARG means to undefine the specified abbrev.
+
+TYPE of abbrev includes \"Global\", \"Mode\".
+
+This command reads the abbreviation from the minibuffer.
+
+See `add-global-abbrev', `add-mode-abbrev' for caller examples.
+See `inverse-add-abbrev' for the opposite task.
+
+Don't use this function in a Lisp program; use `define-abbrev' instead."
   (let ((exp
          (cond
           ((or (and (null arg) (use-region-p))
@@ -393,6 +413,18 @@ inverse-add-global-abbrev
   (inverse-add-abbrev global-abbrev-table "Global" n))
 
 (defun inverse-add-abbrev (table type arg)
+  "Define the word before point as as an abbrev in TABLE.
+
+ARG means use the ARG-th word before point as the
+abbreviation.  Negative ARG means use the ARG-th word after point.
+
+This command reads the expansion from the minibuffer, defines the
+abbrev, and then expands the abbreviation in the current buffer.
+
+TYPE of abbrev can be \"Global\", \"Mode\".
+
+See `inverse-add-global-n', `inverse-add-mode-abbrev' for caller examples.
+See also `add-abbrev', which performs the opposite task."
   (let (name exp start end)
     (save-excursion
       (forward-word (1+ (- arg)))
@@ -406,7 +438,7 @@ inverse-add-abbrev
 			   nil nil nil t))
     (when (or (not (abbrev-expansion name table))
 	      (y-or-n-p (format "%s expands into \"%s\"; redefine? "
-				name (abbrev-expansion name table))))
+                                name (abbrev-expansion name table))))
       (define-abbrev table (downcase name) exp)
       (save-excursion
 	(goto-char end)
@@ -1102,6 +1134,8 @@ abbrev--write
   (insert ")\n"))
 
 (defun abbrev--describe (sym)
+  "Describe abbrev SYM.
+Used to generate a table by `insert-abbrev-table-description'."
   (when (symbol-value sym)
     (prin1 (symbol-name sym))
     (if (null (abbrev-get sym :system))
@@ -1243,6 +1277,8 @@ edit-abbrevs-mode
   (setq font-lock-multiline nil))
 
 (defun abbrev--possibly-save (query &optional arg)
+  "Hook function for use by `save-some-buffer-functions'.
+Associated meaning for QUERY and ARG."
   ;; Query mode.
   (if (eq query 'query)
       (and save-abbrevs abbrevs-changed)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
  2023-11-13 22:38 bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-14 14:17 ` Eli Zaretskii
  2023-11-14 19:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-11-14 14:17 UTC (permalink / raw)
  To: Jeremy Bryant; +Cc: 67153, gerd, rms, monnier

> Date: Mon, 13 Nov 2023 22:38:39 +0000
> From:  Jeremy Bryant via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> This patch adds 5 docstrings to abbrev.el where there were none before.
> This now completes all docstrings in this Lisp file.
> 
> The patch is a documentation patch based on emacs-29.
> Please let me know if this is ready to install or if changes are needed.

Thanks, see a few comments below.

>  (defun prepare-abbrev-list-buffer (&optional local)
> +  "Return *Abbrevs* buffer for the caller to select or display.
> +
> +LOCAL is a flag, if non-nil display only local abbrevs.
> +"

That newline before the closing quote is redundant,

>  (defun add-abbrev (table type arg)
> +  "Define an abbrev in abbrev TABLE whose expansion is last word before point.

The first sentence of a doc string should preferably mention the
mandatory arguments (TYPE and ARG).  If the result is too long to fit
on a single line, consider saying only the main part there, and then
describing the details in the following lines.

> +TYPE of abbrev includes \"Global\", \"Mode\".

"Includes"? are there other types?

>  (defun inverse-add-abbrev (table type arg)
> +  "Define the word before point as as an abbrev in TABLE.
                                   ^^^^^
Typo.

> +ARG means use the ARG-th word before point as the
> +abbreviation.  Negative ARG means use the ARG-th word after point.
> +
> +This command reads the expansion from the minibuffer, defines the
> +abbrev, and then expands the abbreviation in the current buffer.
> +
> +TYPE of abbrev can be \"Global\", \"Mode\".
> +
> +See `inverse-add-global-n', `inverse-add-mode-abbrev' for caller examples.
> +See also `add-abbrev', which performs the opposite task."

Same comments here.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
  2023-11-13 22:38 bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-14 14:17 ` Eli Zaretskii
@ 2023-11-14 19:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-15 23:24   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-14 19:23 UTC (permalink / raw)
  To: Jeremy Bryant; +Cc: gerd, 67153, rms

> This patch adds 5 docstrings to abbrev.el where there were none before.

Thanks.  See some comments below.


        Stefan


>  (defun prepare-abbrev-list-buffer (&optional local)
> +  "Return *Abbrevs* buffer for the caller to select or display.

A few points:

- I don't think the docstring should document to the name of the buffer.
- Docstrings should usually say what the function does rather than what
  the callers are expected to do with the result.
- To me, the above description makes it sound like the function does
  little more than `(get-buffer "*Abbrevs*")`.
  IOW, it should say that it fills the buffer with "some" representation
  of "some" abbrevs.

> +LOCAL is a flag, if non-nil display only local abbrevs.
> +"

We don't like our docstrings to end with a newline.

> +A negative ARG means to undefine the specified abbrev.
[...]
> +This command reads the abbreviation from the minibuffer.

We should say this before referring to it via "the specified abbrev".

> +TYPE of abbrev includes \"Global\", \"Mode\".

Here you made the same mistake of documenting what the callers do rather
than what the function does.

> +See `add-global-abbrev', `add-mode-abbrev' for caller examples.

We usually don't include this in docstrings.
We have `xref` and `grep` for those kinds of things.

>  (defun abbrev--describe (sym)
> +  "Describe abbrev SYM.
> +Used to generate a table by `insert-abbrev-table-description'."

Similarly here I wouldn't mention the caller.  Instead I'd try and
explain what kind of description is generated and where it's placed
(at point in the current buffer?  As a return values? ...).

>  (defun abbrev--possibly-save (query &optional arg)
> +  "Hook function for use by `save-some-buffer-functions'.
> +Associated meaning for QUERY and ARG."

Hook functions are one of the exceptions where it's often OK to refer to
how it's used in the docstring, like you do here (e.g. so we don't have
to repeat what `query` and `arg` are for).
But it should also say what it actually does.


        Stefan






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
  2023-11-14 19:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-15 23:24   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-16  6:47     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-15 23:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: gerd, 67153, rms

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Add-5-docstrings-to-abbrev.el.patch --]
[-- Type: text/x-diff, Size: 3535 bytes --]

From 2e7f167ae4c6cac02d530a1c9d529c3240eb4187 Mon Sep 17 00:00:00 2001
From: Jeremy Bryant <jb@jeremybryant.net>
Date: Wed, 15 Nov 2023 23:15:46 +0000
Subject: [PATCH] Add 5 docstrings to abbrev.el

* lisp/abbrev.el (prepare-abbrev-list-buffer)
(add-abbrev)
(inverse-add-abbrev)
(abbrev--describe)
(abbrev--possibly-save): Add docstrings.
---
 lisp/abbrev.el | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index e1311dbc83b..6f62e088d64 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -122,6 +122,9 @@ abbrev-table-name
     found))
 
 (defun prepare-abbrev-list-buffer (&optional local)
+  "Return buffer listing abbreviations and expansions for each abbrev table.
+
+LOCAL is a flag, if non-nil display only local abbrevs."
   (let ((local-table local-abbrev-table))
     (with-current-buffer (get-buffer-create "*Abbrevs*")
       (erase-buffer)
@@ -333,6 +336,21 @@ add-global-abbrev
   (add-abbrev global-abbrev-table "Global" arg))
 
 (defun add-abbrev (table type arg)
+  "Define abbrev in TABLE, whose expansion is ARG words before point.
+This command reads the abbreviation from the minibuffer, with prompt TYPE.
+
+ARG of zero means the entire region is the expansion.
+If there's an active region, use that as the expansion.
+
+A negative ARG means to undefine the specified abbrev.
+
+TYPE is an arbitrary string used to prompt user for the kind of
+abbrev, such as \"Global\", \"Mode\".  (This has no influence on the
+choice of the actual TABLE).
+
+See `inverse-add-abbrev' for the opposite task.
+
+Don't use this function in a Lisp program; use `define-abbrev' instead."
   (let ((exp
          (cond
           ((or (and (null arg) (use-region-p))
@@ -353,7 +371,7 @@ add-abbrev
     (if (or (null exp)
 	    (not (abbrev-expansion name table))
 	    (y-or-n-p (format "%s expands into \"%s\"; redefine? "
-			      name (abbrev-expansion name table))))
+                              name (abbrev-expansion name table))))
 	(define-abbrev table (downcase name) exp))))
 
 (defun inverse-add-mode-abbrev (n)
@@ -393,6 +411,18 @@ inverse-add-global-abbrev
   (inverse-add-abbrev global-abbrev-table "Global" n))
 
 (defun inverse-add-abbrev (table type arg)
+  "Define the word before point as an abbrev in TABLE.
+This command reads the expansion from the minibuffer, using prompt TYPE,
+defines the abbrev, and then expands the abbreviation in the current buffer.
+
+ARG means use the ARG-th word before point as the abbreviation.
+Negative ARG means use the ARG-th word after point.
+
+TYPE is an arbitrary string used to prompt user for the kind of
+abbrev, such as \"Global\", \"Mode\".  (This has no influence on the
+choice of the actual TABLE).
+
+See also `add-abbrev', which performs the opposite task."
   (let (name exp start end)
     (save-excursion
       (forward-word (1+ (- arg)))
@@ -1102,6 +1132,8 @@ abbrev--write
   (insert ")\n"))
 
 (defun abbrev--describe (sym)
+  "Describe abbrev SYM.
+Print on `standard-output' the abbrev, count of use, expansion."
   (when (symbol-value sym)
     (prin1 (symbol-name sym))
     (if (null (abbrev-get sym :system))
@@ -1243,6 +1275,8 @@ edit-abbrevs-mode
   (setq font-lock-multiline nil))
 
 (defun abbrev--possibly-save (query &optional arg)
+  "Maybe save abbrevs: Hook function for use by `save-some-buffer-functions'.
+Associated meaning for QUERY and ARG."
   ;; Query mode.
   (if (eq query 'query)
       (and save-abbrevs abbrevs-changed)
-- 
2.40.1


[-- Attachment #2: Type: text/plain, Size: 2783 bytes --]


Attached is a revised patch addressing comments of Eli and Stefan.

Further clarifications below:-


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>  (defun prepare-abbrev-list-buffer (&optional local)
>> +  "Return *Abbrevs* buffer for the caller to select or display.
>
> A few points:
>
> - I don't think the docstring should document to the name of the buffer.
> - Docstrings should usually say what the function does rather than what
>   the callers are expected to do with the result.

Initially, I had simply lifted the text from the file ChangeLog.1
1985-12-13  Richard M. Stallman  (rms@prep)
        * abbrev.el (prepare-abbrev-list-buffer, list-abbrevs,
	edit-abbrevs):
        Some cleanups.  prepare-... now does all the work and
	returns the buffer for the caller to select or display.


But I have now rewritten.


> - To me, the above description makes it sound like the function does
>   little more than `(get-buffer "*Abbrevs*")`.
>   IOW, it should say that it fills the buffer with "some" representation
>   of "some" abbrevs.
>
>> +LOCAL is a flag, if non-nil display only local abbrevs.
>> +"
>
> We don't like our docstrings to end with a newline.

Fixed.

>
>> +A negative ARG means to undefine the specified abbrev.
> [...]
>> +This command reads the abbreviation from the minibuffer.
>
> We should say this before referring to it via "the specified abbrev".

Fixed in both add-abbrev and inverse-add-abbrev.
I initially adapted the docstring from surrounding callers like
add-global-abbrev, but have now rewritten.

>
>> +TYPE of abbrev includes \"Global\", \"Mode\".
>
> Here you made the same mistake of documenting what the callers do rather
> than what the function does.

Fixed, rewritten, it turns out the ARG string is purely descriptive.

>
>> +See `add-global-abbrev', `add-mode-abbrev' for caller examples.
>
> We usually don't include this in docstrings.
> We have `xref` and `grep` for those kinds of things.

Fixed

>>  (defun abbrev--describe (sym)
>> +  "Describe abbrev SYM.
>> +Used to generate a table by `insert-abbrev-table-description'."
>
> Similarly here I wouldn't mention the caller.  Instead I'd try and
> explain what kind of description is generated and where it's placed
> (at point in the current buffer?  As a return values? ...).

Fixed with this detail after examining the code.
>
>>  (defun abbrev--possibly-save (query &optional arg)
>> +  "Hook function for use by `save-some-buffer-functions'.
>> +Associated meaning for QUERY and ARG."
>
> Hook functions are one of the exceptions where it's often OK to refer to
> how it's used in the docstring, like you do here (e.g. so we don't have
> to repeat what `query` and `arg` are for).
> But it should also say what it actually does.

Fixed.

>
>
>         Stefan


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
  2023-11-15 23:24   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-16  6:47     ` Eli Zaretskii
  2023-11-16 23:48       ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-11-16  6:47 UTC (permalink / raw)
  To: Jeremy Bryant; +Cc: 67153, monnier

> Cc: gerd@gnu.org, 67153@debbugs.gnu.org, rms@gnu.org
> Date: Wed, 15 Nov 2023 23:24:48 +0000
> From:  Jeremy Bryant via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
>  (defun prepare-abbrev-list-buffer (&optional local)
> +  "Return buffer listing abbreviations and expansions for each abbrev table.
> +
> +LOCAL is a flag, if non-nil display only local abbrevs."

Our style for expressing what you say in the last sentence is

  If LOCAL is non-nil, include in the buffer only the local abbrevs.

("Display" is not appropriate here, since this function doesn't
display the buffer.)

>  (defun add-abbrev (table type arg)
> +  "Define abbrev in TABLE, whose expansion is ARG words before point.
> +This command reads the abbreviation from the minibuffer, with prompt TYPE.
        ^^^^^^^
This is not a command.

> +ARG of zero means the entire region is the expansion.
> +If there's an active region, use that as the expansion.

Is the second sentence conditioned on the first, i.e., does the
function use the active region only when ARG is zero?  If so, the
second sentence should be removed.  If use of the active region is NOT
conditioned on ARG, I would reword the above:

  If there's an active region, use the region as the expansion.
  ARG of zero means the region is the expansion, even if it is
  inactive.

>  (defun inverse-add-abbrev (table type arg)
> +  "Define the word before point as an abbrev in TABLE.
> +This command reads the expansion from the minibuffer, using prompt TYPE,
> +defines the abbrev, and then expands the abbreviation in the current buffer.
> +
> +ARG means use the ARG-th word before point as the abbreviation.
> +Negative ARG means use the ARG-th word after point.
> +
> +TYPE is an arbitrary string used to prompt user for the kind of
> +abbrev, such as \"Global\", \"Mode\".  (This has no influence on the
> +choice of the actual TABLE).
> +
> +See also `add-abbrev', which performs the opposite task."

Same comments here.

>  (defun abbrev--possibly-save (query &optional arg)
> +  "Maybe save abbrevs: Hook function for use by `save-some-buffer-functions'.

I'd say here just

  Hook function for use by `save-some-buffer-functions'.

and add the "Maybe save" bit as a separate second sentence.

> +Associated meaning for QUERY and ARG."

I couldn't parse this sentence.

Thanks.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
  2023-11-16  6:47     ` Eli Zaretskii
@ 2023-11-16 23:48       ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-17  8:17         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-16 23:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 67153, monnier

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Add-5-docstrings-to-abbrev.el.patch --]
[-- Type: text/x-diff, Size: 3638 bytes --]

From a8a1b01cab209d73dabf34fe7fcebe9075bc3ca0 Mon Sep 17 00:00:00 2001
From: Jeremy Bryant <jb@jeremybryant.net>
Date: Wed, 15 Nov 2023 23:15:46 +0000
Subject: [PATCH] Add 5 docstrings to abbrev.el

* lisp/abbrev.el (prepare-abbrev-list-buffer)
(add-abbrev)
(inverse-add-abbrev)
(abbrev--describe)
(abbrev--possibly-save): Add docstrings.
---
 lisp/abbrev.el | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index e1311dbc83b..6269fd50adf 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -122,6 +122,9 @@ abbrev-table-name
     found))
 
 (defun prepare-abbrev-list-buffer (&optional local)
+  "Return buffer listing abbreviations and expansions for each abbrev table.
+
+If LOCAL is non-nil, include in the buffer only the local abbrevs."
   (let ((local-table local-abbrev-table))
     (with-current-buffer (get-buffer-create "*Abbrevs*")
       (erase-buffer)
@@ -333,6 +336,20 @@ add-global-abbrev
   (add-abbrev global-abbrev-table "Global" arg))
 
 (defun add-abbrev (table type arg)
+  "Define abbrev in TABLE, whose expansion is ARG words before point.
+Read the abbreviation from the minibuffer, with prompt TYPE.
+
+ARG of zero means the entire region is the expansion.
+
+A negative ARG means to undefine the specified abbrev.
+
+TYPE is an arbitrary string used to prompt user for the kind of
+abbrev, such as \"Global\", \"Mode\".  (This has no influence on the
+choice of the actual TABLE).
+
+See `inverse-add-abbrev' for the opposite task.
+
+Don't use this function in a Lisp program; use `define-abbrev' instead."
   (let ((exp
          (cond
           ((or (and (null arg) (use-region-p))
@@ -353,7 +370,7 @@ add-abbrev
     (if (or (null exp)
 	    (not (abbrev-expansion name table))
 	    (y-or-n-p (format "%s expands into \"%s\"; redefine? "
-			      name (abbrev-expansion name table))))
+                              name (abbrev-expansion name table))))
 	(define-abbrev table (downcase name) exp))))
 
 (defun inverse-add-mode-abbrev (n)
@@ -393,6 +410,19 @@ inverse-add-global-abbrev
   (inverse-add-abbrev global-abbrev-table "Global" n))
 
 (defun inverse-add-abbrev (table type arg)
+  "Define the word before point as an abbrev in TABLE.
+Read the expansion from the minibuffer, using prompt TYPE, define
+the abbrev, and then expand the abbreviation in the current
+buffer.
+
+ARG means use the ARG-th word before point as the abbreviation.
+Negative ARG means use the ARG-th word after point.
+
+TYPE is an arbitrary string used to prompt user for the kind of
+abbrev, such as \"Global\", \"Mode\".  (This has no influence on the
+choice of the actual TABLE).
+
+See also `add-abbrev', which performs the opposite task."
   (let (name exp start end)
     (save-excursion
       (forward-word (1+ (- arg)))
@@ -1102,6 +1132,8 @@ abbrev--write
   (insert ")\n"))
 
 (defun abbrev--describe (sym)
+  "Describe abbrev SYM.
+Print on `standard-output' the abbrev, count of use, expansion."
   (when (symbol-value sym)
     (prin1 (symbol-name sym))
     (if (null (abbrev-get sym :system))
@@ -1243,11 +1275,12 @@ edit-abbrevs-mode
   (setq font-lock-multiline nil))
 
 (defun abbrev--possibly-save (query &optional arg)
+  "Hook function for use by `save-some-buffer-functions'.
+
+Maybe save abbrevs, and record whether we either saved them or asked to."
   ;; Query mode.
   (if (eq query 'query)
       (and save-abbrevs abbrevs-changed)
-    ;; Maybe save abbrevs, and record whether we either saved them or
-    ;; asked to.
     (and save-abbrevs
          abbrevs-changed
          (prog1
-- 
2.40.1


[-- Attachment #2: Type: text/plain, Size: 3149 bytes --]


Thank you for your patience in explaining what is required.
New patch attached, with comments below.


Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: gerd@gnu.org, 67153@debbugs.gnu.org, rms@gnu.org
>> Date: Wed, 15 Nov 2023 23:24:48 +0000
>> From:  Jeremy Bryant via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>>  (defun prepare-abbrev-list-buffer (&optional local)
>> +  "Return buffer listing abbreviations and expansions for each abbrev table.
>> +
>> +LOCAL is a flag, if non-nil display only local abbrevs."
>
> Our style for expressing what you say in the last sentence is
>
>   If LOCAL is non-nil, include in the buffer only the local abbrevs.
>
> ("Display" is not appropriate here, since this function doesn't
> display the buffer.)

Noted, fixed

>
>>  (defun add-abbrev (table type arg)
>> +  "Define abbrev in TABLE, whose expansion is ARG words before point.
>> +This command reads the abbreviation from the minibuffer, with prompt TYPE.
>         ^^^^^^^
> This is not a command.

Reworded
>
>> +ARG of zero means the entire region is the expansion.
>> +If there's an active region, use that as the expansion.
>
> Is the second sentence conditioned on the first, i.e., does the
> function use the active region only when ARG is zero?  If so, the
> second sentence should be removed.  If use of the active region is NOT
> conditioned on ARG, I would reword the above:
>
>   If there's an active region, use the region as the expansion.
>   ARG of zero means the region is the expansion, even if it is
>   inactive.
>

Fixed by removing sentence
>>  (defun inverse-add-abbrev (table type arg)
>> +  "Define the word before point as an abbrev in TABLE.
>> +This command reads the expansion from the minibuffer, using prompt TYPE,
>> +defines the abbrev, and then expands the abbreviation in the current buffer.
>> +
>> +ARG means use the ARG-th word before point as the abbreviation.
>> +Negative ARG means use the ARG-th word after point.
>> +
>> +TYPE is an arbitrary string used to prompt user for the kind of
>> +abbrev, such as \"Global\", \"Mode\".  (This has no influence on the
>> +choice of the actual TABLE).
>> +
>> +See also `add-abbrev', which performs the opposite task."
>
> Same comments here.

Reworded; region comment N/A.
>
>>  (defun abbrev--possibly-save (query &optional arg)
>> +  "Maybe save abbrevs: Hook function for use by `save-some-buffer-functions'.
>
> I'd say here just
>
>   Hook function for use by `save-some-buffer-functions'.
>
> and add the "Maybe save" bit as a separate second sentence.

Reworded by moving comment.

>
>> +Associated meaning for QUERY and ARG."
>
> I couldn't parse this sentence.
>
> Thanks.

Initially I read Stefan's suggestion

"
Hook functions are one of the exceptions where it's often OK to refer to
how it's used in the docstring, like you do here (e.g. so we don't have
to repeat what `query` and `arg` are for).
But it should also say what it actually does.
"

and left this as guide to arguments, but have now removed arguments
entirely.

Please let me know if this is good to install or any other changes needed.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el
  2023-11-16 23:48       ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-17  8:17         ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-11-17  8:17 UTC (permalink / raw)
  To: Jeremy Bryant; +Cc: 67153-done, monnier

> From: Jeremy Bryant <jb@jeremybryant.net>
> Cc: monnier@iro.umontreal.ca, 67153@debbugs.gnu.org
> Date: Thu, 16 Nov 2023 23:48:04 +0000
> 
> Thank you for your patience in explaining what is required.
> New patch attached, with comments below.

Thanks, installed on the emacs-29 branch, and closing the bug.

Please note my minor changes in the log message, and try to follow
these conventions in the future.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-17  8:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 22:38 bug#67153: [PATCH 2/2] Add 5 docstrings to abbrev.el Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-14 14:17 ` Eli Zaretskii
2023-11-14 19:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-15 23:24   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-16  6:47     ` Eli Zaretskii
2023-11-16 23:48       ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-17  8:17         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).