emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a011665: Make checkdoc--next-docstring use the doc-string-elt pro


From: Mauro Aranda
Subject: master a011665: Make checkdoc--next-docstring use the doc-string-elt property
Date: Mon, 8 Mar 2021 06:12:45 -0500 (EST)

branch: master
commit a01166562cec3f97e722b627cf5db8ef49338cde
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Mauro Aranda <maurooaranda@gmail.com>

    Make checkdoc--next-docstring use the doc-string-elt property
    
    This follows from a fix for Bug#46918 and a discussion to use
    doc-string-elt:
    https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00232.html
    
    * lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): Check for a
    non-nil doc-string-elt property, instead of hard-coding the
    supported symbols.  Use that property to position point at the
    doc-string.
---
 lisp/emacs-lisp/checkdoc.el | 33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 213ab43..ee2e774 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -931,35 +931,20 @@ don't move point."
                            ;; Don't bug out if the file is empty (or a
                            ;; definition ends prematurely.
                            (end-of-file)))
-    (`(,(or 'defun 'defvar 'defcustom 'defmacro 'defconst 'defsubst 'defadvice
-            'cl-defun 'cl-defgeneric 'cl-defmacro)
+    (`(,(and (pred symbolp) def
+             (let (and doc (guard doc)) (function-get def 'doc-string-elt)))
        ,(pred symbolp)
        ;; Require an initializer, i.e. ignore single-argument `defvar'
        ;; forms, which never have a doc string.
        ,_ . ,_)
      (down-list)
-     ;; Skip over function or macro name, symbol to be defined, and
-     ;; initializer or argument list.
-     (forward-sexp 3)
-     (skip-chars-forward " \n\t")
-     t)
-    (`(,'cl-defmethod
-        ,(pred symbolp)
-        . ,rest)
-     (down-list)
-     (forward-sexp (pcase (car rest)
-                     ;; No qualifier, so skip like we would have skipped in
-                     ;; the first clause of the outer `pcase'.
-                     ((pred listp) 3)
-                     (':extra
-                      ;; Skip the :extra qualifier together with its string 
too.
-                      ;; Skip any additional qualifier.
-                      (if (memq (nth 2 rest) '(:around :before :after))
-                                  6
-                                5))
-                     ;; Skip :before, :after or :around qualifier too.
-                     ((or ':around ':before ':after)
-                      4)))
+     ;; Skip over function or macro name.
+     (forward-sexp 1)
+     ;; And now skip until the docstring.
+     (forward-sexp (1- ; We already skipped the function or macro name.
+                    (cond
+                     ((numberp doc) doc)
+                     ((functionp doc) (funcall doc)))))
      (skip-chars-forward " \n\t")
      t)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]