diff options
author | Philipp Stephani <phst@google.com> | 2016-12-30 18:00:54 +0100 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2016-12-31 17:30:46 +0100 |
commit | 4bbd5424a2290ab4bd88c0af602b7aa7d53a407e (patch) | |
tree | c6928916fdb29df58d509e519953adc1fe21f6a3 /test/lisp/emacs-lisp | |
parent | 8a165813cb9321a8979ac6d98530f5e4392fb879 (diff) | |
download | emacs-4bbd5424a2290ab4bd88c0af602b7aa7d53a407e.tar.gz emacs-4bbd5424a2290ab4bd88c0af602b7aa7d53a407e.tar.bz2 emacs-4bbd5424a2290ab4bd88c0af602b7aa7d53a407e.zip |
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.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/checkdoc-tests.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el b/test/lisp/emacs-lisp/checkdoc-tests.el index 18b5a499e08..02db88c17e2 100644 --- a/test/lisp/emacs-lisp/checkdoc-tests.el +++ b/test/lisp/emacs-lisp/checkdoc-tests.el @@ -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 |