From: Alex Branham Date: Fri, 16 Aug 2019 21:00:31 +0000 (-0700) Subject: Make checkdoc check cl-lib function docstrings X-Git-Tag: emacs-27.0.90~1594 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=496bab789d55ff20f150dd7a7d1d9bb837fb4534;p=emacs.git Make checkdoc check cl-lib function docstrings * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): Remove calls to delete-region to avoid deleting final " (bug#26328). * lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring) (checkdoc-defun-info): Include cl-defun, cl-defgeneric, cl-defmethod. (checkdoc-this-string-valid-engine): Add cl-lib supported keywords. (checkdoc-defun-info): Ensure function parameters are a "flat" list (bug#37034). --- diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 3c699750215..8a88c5756f1 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -933,7 +933,8 @@ 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) + (`(,(or 'defun 'defvar 'defcustom 'defmacro 'defconst 'defsubst 'defadvice + 'cl-defun 'cl-defgeneric 'cl-defmethod 'cl-defmacro) ,(pred symbolp) ;; Require an initializer, i.e. ignore single-argument `defvar' ;; forms, which never have a doc string. @@ -1675,7 +1676,10 @@ function,command,variable,option or symbol." ms1)))))) (last-pos 0) (found 1) (order (and (nth 3 fp) (car (nth 3 fp)))) - (nocheck (append '("&optional" "&rest") (nth 3 fp))) + (nocheck (append '("&optional" "&rest" "&key" "&aux" + "&context" "&environment" "&whole" + "&body" "&allow-other-keys") + (nth 3 fp))) (inopts nil)) (while (and args found (> found last-pos)) (if (or (member (car args) nocheck) @@ -1880,7 +1884,8 @@ the token checkdoc-order: exists, and TOKEN is a symbol read from the comment." (save-excursion (beginning-of-defun) - (let ((defun (looking-at "(def\\(un\\|macro\\|subst\\|advice\\)")) + (let ((defun (looking-at + "(\\(?:cl-\\)?def\\(un\\|macro\\|subst\\|advice\\|generic\\|method\\)")) (is-advice (looking-at "(defadvice")) (lst nil) (ret nil) @@ -1946,7 +1951,10 @@ from the comment." ;; This is because read will intern nil if it doesn't into the ;; new obarray. (if (not (listp lst)) (setq lst nil)) - (if is-advice nil + (unless is-advice + ;; lst here 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) lst (cdr lst)))))