checkdoc: 'y-or-n-p' no longer needs space

* lisp/emacs-lisp/checkdoc.el (checkdoc-message-text-engine):
Change 'y-or-n-p' check to accept prompt ending with both "? " or "?",
that is, it no longer needs the space.  (Bug#50621)
(checkdoc--fix-y-or-n-p): New helper function.
* test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-tests-fix-y-or-n-p)
(checkdoc-tests-fix-y-or-n-p/no-change)
(checkdoc-tests-fix-y-or-n-p/with-space): New tests.
This commit is contained in:
Stefan Kangas 2021-09-16 19:13:56 +02:00
parent 174430e351
commit b6bff3ba79
2 changed files with 62 additions and 50 deletions

View file

@ -146,4 +146,34 @@ See the comments in Bug#24998."
(re-search-forward "e.g")
(should (checkdoc-in-abbreviation-p (point)))))
(ert-deftest checkdoc-tests-fix-y-or-n-p ()
(with-temp-buffer
(emacs-lisp-mode)
(let ((standard-output (current-buffer))
(checkdoc-autofix-flag 'automatic))
(prin1 '(y-or-n-p "foo")) ; "foo"
(goto-char (length "(y-or-n-p "))
(checkdoc--fix-y-or-n-p)
(should (equal (buffer-string) "(y-or-n-p \"foo?\")")))))
(ert-deftest checkdoc-tests-fix-y-or-n-p/no-change ()
(with-temp-buffer
(emacs-lisp-mode)
(let ((standard-output (current-buffer))
(checkdoc-autofix-flag 'automatic))
(prin1 '(y-or-n-p "foo?")) ; "foo?"
(goto-char (length "(y-or-n-p "))
(checkdoc--fix-y-or-n-p)
(should (equal (buffer-string) "(y-or-n-p \"foo?\")")))))
(ert-deftest checkdoc-tests-fix-y-or-n-p/with-space ()
(with-temp-buffer
(emacs-lisp-mode)
(let ((standard-output (current-buffer))
(checkdoc-autofix-flag 'automatic))
(prin1 '(y-or-n-p "foo? ")) ; "foo? "
(goto-char (length "(y-or-n-p "))
(checkdoc--fix-y-or-n-p)
(should (equal (buffer-string) "(y-or-n-p \"foo? \")")))))
;;; checkdoc-tests.el ends here