Subject: Re: bug#37063: 26.2.90; Problems with recent CL support in checkdoc

From: [email-masked]
Date: Mon, 30 Sep 2019 12:52:36 -0400

>From c97b08a1d6df46f674a18ab83ae86dc6a5ad3aa0 Mon Sep 17 00:00:00 2001
From: dickmao <none>
Date: Mon, 30 Sep 2019 10:04:49 -0400
Subject: [PATCH] ; checkdoc identifying formal args

* lisp/emacs-lisp/checkdoc.el (checkdoc-defun-info):
* test/lisp/emacs-lisp/checkdoc-tests.el: (Bug#37063)
---
 lisp/emacs-lisp/checkdoc.el            |  5 ++---
 test/lisp/emacs-lisp/checkdoc-tests.el | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 51fb75da69..6c40bdf632 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -1952,11 +1952,10 @@ checkdoc-defun-info
 	;; new obarray.
 	(if (not (listp lst)) (setq lst nil))
 	(unless is-advice
-          ;; lst here can be something like ((foo bar) baz) from
+          ;; (car lst) can be something like ((foo bar) baz) from
           ;; cl-lib methods; flatten it:
-          (setq lst (flatten-tree lst))
 	  (while lst
-	    (setq ret (cons (symbol-name (car lst)) ret)
+	    (setq ret (cons (symbol-name (car (flatten-tree (car lst)))) ret)
 		  lst (cdr lst)))))
       (nreverse ret))))
 
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el b/test/lisp/emacs-lisp/checkdoc-tests.el
index 1cefc4c366..b3cc943ac0 100644
--- a/test/lisp/emacs-lisp/checkdoc-tests.el
+++ b/test/lisp/emacs-lisp/checkdoc-tests.el
@@ -50,4 +50,20 @@ checkdoc-tests--next-docstring
     (should (looking-at-p "\"baz\")"))
     (should-not (checkdoc-next-docstring))))
 
+(ert-deftest checkdoc-tests--cl-defun ()
+  "Identify formal arguments from arbitary lisp code."
+  (with-temp-buffer
+    (let ((checkdoc-autofix-flag 'never))
+      (emacs-lisp-mode)
+      (insert "(cl-defun foo(&key bar &aux (baz (baz bar))) \"BAR BAZ.\")")
+      (should-not (checkdoc-defun)))))
+
+(ert-deftest checkdoc-tests--cl-defmethod ()
+  "Identify formal arguments from object types."
+  (with-temp-buffer
+    (let ((checkdoc-autofix-flag 'never))
+      (emacs-lisp-mode)
+      (insert "(cl-defmethod foo((a list)) \"Return A.\")")
+      (should-not (checkdoc-defun)))))
+
 ;;; checkdoc-tests.el ends here
-- 
2.23.0