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:
Philipp Stephani 2016-12-30 18:00:54 +01:00
parent 8a165813cb
commit 4bbd5424a2
2 changed files with 44 additions and 28 deletions

View file

@ -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