diff options
| author | Stefan Kangas | 2021-11-22 08:08:11 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-11-22 12:04:19 +0100 |
| commit | e91f71676c19127dd90efabfc0da36483aa53a82 (patch) | |
| tree | 832dfd92cf35d5f695d9ecb2c47500fa4d9757b0 | |
| parent | 61c254cafc9caa3b52553fa0e7cca8a5086c5cea (diff) | |
| download | emacs-e91f71676c19127dd90efabfc0da36483aa53a82.tar.gz emacs-e91f71676c19127dd90efabfc0da36483aa53a82.zip | |
Avoid false positives about wide docstrings for key sequences
* lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p):
Ignore literal key sequence substitutions.
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-substitutions.el:
New file.
* test/lisp/emacs-lisp/bytecomp-tests.el
("warn-wide-docstring-ignore-substitutions.el"): New test.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 7 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-substitutions.el | 17 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 4 |
3 files changed, 27 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 3338c383171..bd74c79d717 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -1674,7 +1674,12 @@ URLs." | |||
| 1674 | (replace-regexp-in-string | 1674 | (replace-regexp-in-string |
| 1675 | (rx "\\" (or (seq "[" (* (not "]")) "]"))) | 1675 | (rx "\\" (or (seq "[" (* (not "]")) "]"))) |
| 1676 | (make-string byte-compile--wide-docstring-substitution-len ?x) | 1676 | (make-string byte-compile--wide-docstring-substitution-len ?x) |
| 1677 | docstring)))) | 1677 | ;; For literal key sequence substitutions (e.g. "\\`C-h'"), just |
| 1678 | ;; remove the markup as `substitute-command-keys' would. | ||
| 1679 | (replace-regexp-in-string | ||
| 1680 | (rx "\\" (seq "`" (group (* (not "]"))) "'")) | ||
| 1681 | "\\1" | ||
| 1682 | docstring))))) | ||
| 1678 | 1683 | ||
| 1679 | (defcustom byte-compile-docstring-max-column 80 | 1684 | (defcustom byte-compile-docstring-max-column 80 |
| 1680 | "Recommended maximum width of doc string lines. | 1685 | "Recommended maximum width of doc string lines. |
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-substitutions.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-substitutions.el new file mode 100644 index 00000000000..37cfe463bfe --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-substitutions.el | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | ;;; -*- lexical-binding: t -*- | ||
| 2 | (defalias 'foo #'ignore | ||
| 3 | "None of this should be considered too wide. | ||
| 4 | |||
| 5 | ; this should be treated as 60 characters - no warning | ||
| 6 | \\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window]\\[quit-window] | ||
| 7 | |||
| 8 | ; 64 * 'x' does not warn | ||
| 9 | \\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x'\\`x' | ||
| 10 | |||
| 11 | ; keymaps are just ignored | ||
| 12 | \\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map>\\<foo-bar-map> | ||
| 13 | |||
| 14 | \\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map}\\{foo-bar-map} | ||
| 15 | |||
| 16 | bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar | ||
| 17 | ") | ||
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index dbc0aa3db42..816f14a18d5 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -956,6 +956,10 @@ byte-compiled. Run with dynamic binding." | |||
| 956 | "defvar .foo-bar. docstring wider than .* characters" 'reverse) | 956 | "defvar .foo-bar. docstring wider than .* characters" 'reverse) |
| 957 | 957 | ||
| 958 | (bytecomp--define-warning-file-test | 958 | (bytecomp--define-warning-file-test |
| 959 | "warn-wide-docstring-ignore-substitutions.el" | ||
| 960 | "defvar .foo-bar. docstring wider than .* characters" 'reverse) | ||
| 961 | |||
| 962 | (bytecomp--define-warning-file-test | ||
| 959 | "warn-wide-docstring-ignore.el" | 963 | "warn-wide-docstring-ignore.el" |
| 960 | "defvar .foo-bar. docstring wider than .* characters" 'reverse) | 964 | "defvar .foo-bar. docstring wider than .* characters" 'reverse) |
| 961 | 965 | ||