diff options
| author | Stefan Kangas | 2025-02-21 17:40:12 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2025-02-21 17:46:50 +0100 |
| commit | 8d4feb214b7eb802fec34269de11d30b9382cd83 (patch) | |
| tree | 3f6bc59ec214c49628d3b9f95e1850552ed6ce07 | |
| parent | e7a35dac2fbe5777df531690c770b99e5f7561bb (diff) | |
| download | emacs-8d4feb214b7eb802fec34269de11d30b9382cd83.tar.gz emacs-8d4feb214b7eb802fec34269de11d30b9382cd83.zip | |
New user option checkdoc-allow-quoting-nil-and-t
* lisp/emacs-lisp/checkdoc.el (checkdoc-allow-quoting-nil-and-t):
New user option that allows turning off the warning for having nil
and t in quotes.
(checkdoc-this-string-valid-engine): Use above new option.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 31 |
2 files changed, 25 insertions, 11 deletions
| @@ -841,6 +841,11 @@ This affects calls to 'warn', 'lwarn', 'display-warning', and | |||
| 841 | 'message-box'. | 841 | 'message-box'. |
| 842 | 842 | ||
| 843 | --- | 843 | --- |
| 844 | *** New user option 'checkdoc-allow-quoting-nil-and-t'. | ||
| 845 | Customizing this option to a non-nil value stops checkdoc from warning | ||
| 846 | for docstrings where symbols 'nil' and 't' are in quotes. | ||
| 847 | |||
| 848 | --- | ||
| 844 | *** The default of 'checkdoc-verb-check-experimental-flag' is now nil. | 849 | *** The default of 'checkdoc-verb-check-experimental-flag' is now nil. |
| 845 | In most cases, having it enabled leads to a large amount of false | 850 | In most cases, having it enabled leads to a large amount of false |
| 846 | positives. | 851 | positives. |
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 3541e3d0a57..95fa3a2027e 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el | |||
| @@ -322,6 +322,14 @@ variable `checkdoc-common-verbs-wrong-voice' if you wish to add your own." | |||
| 322 | Do not set this by hand, use a function like `checkdoc-current-buffer' | 322 | Do not set this by hand, use a function like `checkdoc-current-buffer' |
| 323 | with a universal argument.") | 323 | with a universal argument.") |
| 324 | 324 | ||
| 325 | (defcustom checkdoc-allow-quoting-nil-and-t nil | ||
| 326 | "If non-nil, don't warn when the symbols nil and t are quoted. | ||
| 327 | |||
| 328 | In other words, it allows writing them like this: \\=`nil\\=', \\=`t\\='." | ||
| 329 | :type 'boolean | ||
| 330 | :version "31.1") | ||
| 331 | ;;;###autoload(put 'checkdoc-allow-quoting-nil-and-t 'safe-local-variable #'booleanp) | ||
| 332 | |||
| 325 | (defcustom checkdoc-symbol-words | 333 | (defcustom checkdoc-symbol-words |
| 326 | '("beginning-of-buffer" "beginning-of-line" "byte-code" | 334 | '("beginning-of-buffer" "beginning-of-line" "byte-code" |
| 327 | "byte-compile" "command-line" "end-of-buffer" "end-of-line" | 335 | "byte-compile" "command-line" "end-of-buffer" "end-of-line" |
| @@ -1956,17 +1964,18 @@ Replace with \"%s\"?" original replace) | |||
| 1956 | (length ms))) | 1964 | (length ms))) |
| 1957 | nil))) | 1965 | nil))) |
| 1958 | ;; t and nil case | 1966 | ;; t and nil case |
| 1959 | (save-excursion | 1967 | (unless checkdoc-allow-quoting-nil-and-t |
| 1960 | (if (re-search-forward "\\([`‘]\\(t\\|nil\\)['’]\\)" e t) | 1968 | (save-excursion |
| 1961 | (if (checkdoc-autofix-ask-replace | 1969 | (if (re-search-forward "\\([`‘]\\(t\\|nil\\)['’]\\)" e t) |
| 1962 | (match-beginning 1) (match-end 1) | 1970 | (if (checkdoc-autofix-ask-replace |
| 1963 | (format "%s should not appear in quotes. Remove?" | 1971 | (match-beginning 1) (match-end 1) |
| 1964 | (match-string 2)) | 1972 | (format "%s should not appear in quotes. Remove?" |
| 1965 | (match-string 2) t) | 1973 | (match-string 2)) |
| 1966 | nil | 1974 | (match-string 2) t) |
| 1967 | (checkdoc-create-error | 1975 | nil |
| 1968 | "Symbols t and nil should not appear in single quotes" | 1976 | (checkdoc-create-error |
| 1969 | (match-beginning 1) (match-end 1))))) | 1977 | "Symbols t and nil should not appear in single quotes" |
| 1978 | (match-beginning 1) (match-end 1)))))) | ||
| 1970 | ;; Here is some basic sentence formatting | 1979 | ;; Here is some basic sentence formatting |
| 1971 | (checkdoc-sentencespace-region-engine (point) e) | 1980 | (checkdoc-sentencespace-region-engine (point) e) |
| 1972 | ;; Here are common proper nouns that should always appear capitalized. | 1981 | ;; Here are common proper nouns that should always appear capitalized. |