]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix recently introduced bug in checkdoc
authorStefan Kangas <stefan@marxist.se>
Fri, 24 Sep 2021 21:00:57 +0000 (23:00 +0200)
committerStefan Kangas <stefan@marxist.se>
Fri, 24 Sep 2021 21:00:57 +0000 (23:00 +0200)
* lisp/emacs-lisp/checkdoc.el (checkdoc-in-abbreviation-p): Fix
recently introduced bug where some abbreviations weren't recognized.
* test/lisp/emacs-lisp/checkdoc-tests.el
(checkdoc-tests-in-abbrevation-p/basic-case): Extend test.

lisp/emacs-lisp/checkdoc.el
test/lisp/emacs-lisp/checkdoc-tests.el

index df93d3924178ed0b72aad055635021b6bde0e2b3..0862e66ac5d5cee97b6dcbd6604a5762409ec9f0 100644 (file)
@@ -2105,14 +2105,15 @@ Examples of recognized abbreviations: \"e.g.\", \"i.e.\", \"cf.\"."
   (save-excursion
     (goto-char begin)
     (condition-case nil
-        (let ((single-letter t))
+        (let (single-letter)
           (forward-word -1)
           ;; Skip over all dots backwards, as `forward-word' will only
           ;; go one dot at a time in a string like "e.g.".
           (while (save-excursion (forward-char -1)
                                  (looking-at (rx ".")))
-            (setq single-letter nil)
             (forward-word -1))
+          (when (= (point) (1- begin))
+            (setq single-letter t))
           ;; Piece of an abbreviation.
           (looking-at
            (if single-letter
index 13b6d134e5c16bacfeb56d93c3e6ce00073e9cca..d452024b8ff8ff852378d8cd55a8b2f2b1e6706e 100644 (file)
@@ -131,7 +131,10 @@ See the comments in Bug#24998."
     (checkdoc-in-abbreviation-p (point))))
 
 (ert-deftest checkdoc-tests-in-abbrevation-p/basic-case ()
-  (should (checkdoc-tests--abbrev-test "foo bar e.g. baz" "e.g")))
+  (should (checkdoc-tests--abbrev-test "foo bar e.g. baz" "e.g"))
+  (should (checkdoc-tests--abbrev-test "behavior/errors etc. that" "etc"))
+  (should (checkdoc-tests--abbrev-test "foo vs. bar" "vs"))
+  (should (checkdoc-tests--abbrev-test "spy a.k.a. spy" "a.k.a")))
 
 (ert-deftest checkdoc-tests-in-abbrevation-p/with-parens ()
   (should (checkdoc-tests--abbrev-test "foo bar (e.g. baz)" "e.g")))