aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Cassou2023-09-12 08:28:37 +0200
committerStefan Kangas2023-09-13 16:34:45 +0200
commitf045750fa5e94659e96bab85d1d05ddf65a4c557 (patch)
tree06325a9095a0cf20678048d944194033a3ebb05f
parentd436c559a4fa7154802f4c898630266a3ff6efa9 (diff)
downloademacs-f045750fa5e94659e96bab85d1d05ddf65a4c557.tar.gz
emacs-f045750fa5e94659e96bab85d1d05ddf65a4c557.zip
Shorten docstrings generated by cl-defsubst
* lisp/emacs-lisp/cl-macs.el (cl-defsubst): Split the first line of the docstring into 2 lines if the function name is very long. Additionally, remove the word "inlining" in the generated docstring as it is not very useful and increases the likelihood of "docstring wider than 80 characters" errors. (Bug#65790)
-rw-r--r--lisp/emacs-lisp/cl-macs.el9
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el11
2 files changed, 19 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index c8e2610c8b0..dc17f992660 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2931,7 +2931,14 @@ The function's arguments should be treated as immutable.
2931 ,(if (memq '&key args) 2931 ,(if (memq '&key args)
2932 `(&whole cl-whole &cl-quote ,@args) 2932 `(&whole cl-whole &cl-quote ,@args)
2933 (cons '&cl-quote args)) 2933 (cons '&cl-quote args))
2934 ,(format "compiler-macro for inlining `%s'." name) 2934 ;; NB. This will produce incorrect results in some
2935 ;; cases, as our coding conventions says that the first
2936 ;; line must be a full sentence. However, if we don't
2937 ;; word wrap we will have byte-compiler warnings about
2938 ;; overly long docstrings. So we can't have a perfect
2939 ;; result here, and choose to avoid the byte-compiler
2940 ;; warnings.
2941 ,(internal--format-docstring-line "compiler-macro for `%s'." name)
2935 (cl--defsubst-expand 2942 (cl--defsubst-expand
2936 ',argns '(cl-block ,name ,@(cdr (macroexp-parse-body body))) 2943 ',argns '(cl-block ,name ,@(cdr (macroexp-parse-body body)))
2937 nil 2944 nil
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index c0adab75269..102616c9bb7 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -972,6 +972,17 @@ byte-compiled. Run with dynamic binding."
972 (bytecomp--with-warning-test "defvar.*foo.*wider than.*characters" 972 (bytecomp--with-warning-test "defvar.*foo.*wider than.*characters"
973 `(defvar foo t ,bytecomp-tests--docstring))) 973 `(defvar foo t ,bytecomp-tests--docstring)))
974 974
975(ert-deftest bytecomp-warn-wide-docstring/cl-defsubst ()
976 (bytecomp--without-warning-test
977 `(cl-defsubst short-name ()
978 "Do something."))
979 (bytecomp--without-warning-test
980 `(cl-defsubst long-name-with-less-80-characters-but-still-quite-a-bit ()
981 "Do something."))
982 (bytecomp--with-warning-test "wider than.*characters"
983 `(cl-defsubst long-name-with-more-than-80-characters-yes-this-is-a-very-long-name-but-why-not!! ()
984 "Do something.")))
985
975(ert-deftest bytecomp-warn-quoted-condition () 986(ert-deftest bytecomp-warn-quoted-condition ()
976 (bytecomp--with-warning-test 987 (bytecomp--with-warning-test
977 "Warning: `condition-case' condition should not be quoted: 'arith-error" 988 "Warning: `condition-case' condition should not be quoted: 'arith-error"