1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Fill doc strings for ERC modules

* lisp/erc/erc-common.el (erc--fill-module-docstring): Add helper to
fill doc strings.
(erc--assemble-toggle, define-erc-module): Use helper to fill doc
string.
* test/lisp/erc/erc-tests.el (define-minor-mode--global,
define-minor-mode--local): Adjust expected output for generated doc
strings.  (Bug#60935.)
This commit is contained in:
F. Jason Park 2023-01-16 20:18:32 -08:00
parent 9c65ac7365
commit 39d4f32fc9
2 changed files with 33 additions and 15 deletions

View file

@ -136,7 +136,7 @@ instead of a `set' state, which precludes any actual saving."
(defun erc--assemble-toggle (localp name ablsym mode val body)
(let ((arg (make-symbol "arg")))
`(defun ,ablsym ,(if localp `(&optional ,arg) '())
,(concat
,(erc--fill-module-docstring
(if val "Enable" "Disable")
" ERC " (symbol-name name) " mode."
(when localp
@ -250,6 +250,20 @@ Do so by always returning its standard value, namely nil."
(if hasp "from" "to") " `erc-modules'.")))
:action ,(apply-partially #'erc--tick-module-checkbox name))))
(defun erc--fill-module-docstring (&rest strings)
(with-temp-buffer
(emacs-lisp-mode)
(insert "(defun foo ()\n"
(format "%S" (apply #'concat strings))
"\n(ignore))")
(goto-char (point-min))
(forward-line 2)
(let ((emacs-lisp-docstring-fill-column 65)
(sentence-end-double-space t))
(fill-paragraph))
(goto-char (point-min))
(nth 3 (read (current-buffer)))))
(defmacro define-erc-module (name alias doc enable-body disable-body
&optional local-p)
"Define a new minor mode using ERC conventions.
@ -289,11 +303,11 @@ Example:
`(progn
(define-minor-mode
,mode
,(format "Toggle ERC %S mode.
,(erc--fill-module-docstring (format "Toggle ERC %s mode.
With a prefix argument ARG, enable %s if ARG is positive,
and disable it otherwise. If called from Lisp, enable the mode
if ARG is omitted or nil.
%s" name name doc)
\n%s" name name doc))
:global ,(not local-p)
:group (erc--find-group ',name ,(and alias (list 'quote alias)))
,@(unless local-p '(:get #'erc--neuter-custom-variable-state))