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.
This commit is contained in:
parent
61c254cafc
commit
e91f71676c
3 changed files with 27 additions and 1 deletions
|
@ -1674,7 +1674,12 @@ URLs."
|
|||
(replace-regexp-in-string
|
||||
(rx "\\" (or (seq "[" (* (not "]")) "]")))
|
||||
(make-string byte-compile--wide-docstring-substitution-len ?x)
|
||||
docstring))))
|
||||
;; For literal key sequence substitutions (e.g. "\\`C-h'"), just
|
||||
;; remove the markup as `substitute-command-keys' would.
|
||||
(replace-regexp-in-string
|
||||
(rx "\\" (seq "`" (group (* (not "]"))) "'"))
|
||||
"\\1"
|
||||
docstring)))))
|
||||
|
||||
(defcustom byte-compile-docstring-max-column 80
|
||||
"Recommended maximum width of doc string lines.
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
;;; -*- lexical-binding: t -*-
|
||||
(defalias 'foo #'ignore
|
||||
"None of this should be considered too wide.
|
||||
|
||||
; this should be treated as 60 characters - no warning
|
||||
\\[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]
|
||||
|
||||
; 64 * 'x' does not warn
|
||||
\\`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'
|
||||
|
||||
; keymaps are just ignored
|
||||
\\<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}\\{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}
|
||||
|
||||
bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar
|
||||
")
|
|
@ -955,6 +955,10 @@ byte-compiled. Run with dynamic binding."
|
|||
"warn-wide-docstring-ignore-override.el"
|
||||
"defvar .foo-bar. docstring wider than .* characters" 'reverse)
|
||||
|
||||
(bytecomp--define-warning-file-test
|
||||
"warn-wide-docstring-ignore-substitutions.el"
|
||||
"defvar .foo-bar. docstring wider than .* characters" 'reverse)
|
||||
|
||||
(bytecomp--define-warning-file-test
|
||||
"warn-wide-docstring-ignore.el"
|
||||
"defvar .foo-bar. docstring wider than .* characters" 'reverse)
|
||||
|
|
Loading…
Add table
Reference in a new issue