Checkdoc: use syntax functions instead of regex
In checkdoc.el, get rid of the error-prone regex to find definition forms, and use existing syntax-based navigation functions instead. This fixes a corner case with one-argument `defvar' forms. * lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): New function. (checkdoc-next-docstring, checkdoc-defun): Use it. * test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-tests--next-docstring): Add unit test.
This commit is contained in:
parent
8a165813cb
commit
4bbd5424a2
2 changed files with 44 additions and 28 deletions
|
@ -37,4 +37,17 @@
|
|||
(insert "(defun foo())")
|
||||
(should-error (checkdoc-defun) :type 'user-error)))
|
||||
|
||||
(ert-deftest checkdoc-tests--next-docstring ()
|
||||
"Checks that the one-argument form of `defvar' works.
|
||||
See the comments in Bug#24998."
|
||||
(with-temp-buffer
|
||||
(emacs-lisp-mode)
|
||||
(insert "(defvar foo)
|
||||
\(defvar foo bar \"baz\")
|
||||
\(require 'foo)")
|
||||
(goto-char (point-min))
|
||||
(should (checkdoc-next-docstring))
|
||||
(should (looking-at-p "\"baz\")"))
|
||||
(should-not (checkdoc-next-docstring))))
|
||||
|
||||
;;; checkdoc-tests.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue