From e0a27cba79ad8e2713775c4216943138a2d70267 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 7 Dec 2020 09:49:13 +0100 Subject: [PATCH 2/3] Avoid wide doc strings in define-minor-mode * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Avoid producing long documentation strings. --- lisp/emacs-lisp/easy-mmode.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 261f2508af..60ea435e8a 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -115,6 +115,16 @@ easy-mmode--mode-docstring (concat filled "\\1") doc nil nil 1))))) +(defun easy-mmode--fill-string (str) + "Fill string STR to `fill-column' to avoid generating wide docstrings." + (if (< (length str) fill-column) + str + (let ((fst (substring str 0 fill-column)) + (lst (substring str fill-column))) + (if (string-match ".*\\( \\(.+\\)\\)$" fst) + (setq fst (replace-match "\n\\2" nil nil fst 1))) + (concat fst lst)))) + ;;;###autoload (defalias 'easy-mmode-define-minor-mode 'define-minor-mode) ;;;###autoload @@ -278,8 +288,11 @@ define-minor-mode ((not globalp) `(progn :autoload-end - (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled. -Use the command `%s' to change this variable." pretty-name mode)) + (defvar ,mode ,init-value + ,(concat (format "Non-nil if %s is enabled.\n" pretty-name) + (easy-mmode--fill-string + (format "Use the command `%s' to change this variable." + mode)))) (make-variable-buffer-local ',mode))) (t (let ((base-doc-string -- 2.29.2