Function: easy-mmode--mode-docstring

easy-mmode--mode-docstring is a byte-compiled function defined in easy-mmode.el.gz.

Signature

(easy-mmode--mode-docstring DOC MODE-PRETTY-NAME KEYMAP-SYM GETTER)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/easy-mmode.el.gz
(defun easy-mmode--mode-docstring (doc mode-pretty-name keymap-sym
                                       getter)
  (let ((doc (or doc (format "Toggle %s on or off.

\\{%s}" mode-pretty-name keymap-sym))))
    (if (string-match-p "\\bARG\\b" doc)
        doc
      (let* ((fill-prefix nil)
             (docs-fc (bound-and-true-p emacs-lisp-docstring-fill-column))
             (fill-column (if (integerp docs-fc) docs-fc 65))
             (argdoc (format easy-mmode--arg-docstring mode-pretty-name
                             ;; Avoid having quotes turn into pretty quotes.
                             (string-replace "'" "\\\\='"
                                             (format "%S" getter))))
             (filled (if (fboundp 'fill-region)
                         (with-temp-buffer
                           (insert argdoc)
                           (fill-region (point-min) (point-max) 'left t)
                           (buffer-string))
                       argdoc)))
        (replace-regexp-in-string "\\(\n\n\\|\\'\\)\\(.\\|\n\\)*\\'"
                                  (concat filled "\\1")
                                  doc nil nil 1)))))