* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
Avoid false positive when a variable contains a keybinding (for
example, "C-g"). (Bug#68002)
* test/lisp/emacs-lisp/checkdoc-tests.el
(checkdoc-docstring-avoid-false-positive-ok): New test.
(let ((f nil) (m nil) (start (point))
;; Ignore the "A-" modifier: it is uncommon in practice,
;; and leads to false positives in regexp ranges.
- (re "[^`‘A-Za-z0-9_]\\([CMs]-[a-zA-Z]\\|\\(\\([CMs]-\\)?\
-mouse-[0-3]\\)\\)\\>"))
+ (re (rx (not (any "0-9A-Za-z_`‘-"))
+ (group (or (seq (any "CMs") "-" (any "A-Za-z"))
+ (group (opt (group (any "CMs") "-"))
+ "mouse-" (any "0-3"))))
+ eow)))
;; Find the first key sequence not in a sample
(while (and (not f) (setq m (re-search-forward re e t)))
(setq f (not (checkdoc-in-sample-code-p start e))))
(insert "(defun foo())")
(should-error (checkdoc-defun) :type 'user-error)))
+(ert-deftest checkdoc-docstring-avoid-false-positive-ok ()
+ "Check that Bug#68002 is fixed."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defvar org-element--cache-interrupt-C-g-count 0
+ \"Current number of `org-element--cache-sync' calls.
+See `org-element--cache-interrupt-C-g'.\")")
+ (checkdoc-defun)))
+
(ert-deftest checkdoc-cl-defmethod-ok ()
"Checkdoc should be happy with a simple correct cl-defmethod."
(with-temp-buffer