]> git.eshelyaron.com Git - emacs.git/commitdiff
Improved docstring single quote warning
authorMattias Engdegård <mattiase@acm.org>
Wed, 18 Jan 2023 17:41:39 +0000 (18:41 +0100)
committerMattias Engdegård <mattiase@acm.org>
Wed, 18 Jan 2023 17:50:23 +0000 (18:50 +0100)
* lisp/emacs-lisp/bytecomp.el (byte-compile-docstring-style-warn):
More robust regexp.  More explicit warning message.

lisp/emacs-lisp/bytecomp.el

index fb4b73b1c144432c73d2379cab01cd3da0624d82..aa9521e5a65422db6e2d47bcc8c55f729d099212 100644 (file)
@@ -1772,10 +1772,16 @@ It is too wide if it has any lines longer than the largest of
            kind name col))
         ;; There's a "naked" ' character before a symbol/list, so it
         ;; should probably be quoted with \=.
-        (when (string-match-p "\\( [\"#]\\|[ \t]\\|^\\)'[a-z(]" docs)
+        (when (string-match-p (rx (| (in " \t") bol)
+                                  (? (in "\"#"))
+                                  "'"
+                                  (in "A-Za-z" "("))
+                              docs)
           (byte-compile-warn-x
-           name "%s%sdocstring has wrong usage of unescaped single quotes (use \\= or different quoting)"
-           kind name))
+           name
+           (concat "%s%sdocstring has wrong usage of unescaped single quotes"
+                   " (use \\=%c or different quoting such as %c...%c)")
+           kind name ?' ?` ?'))
         ;; There's a "Unicode quote" in the string -- it should probably
         ;; be an ASCII one instead.
         (when (byte-compile-warning-enabled-p 'docstrings-non-ascii-quotes)