Function: byte-compile--wide-docstring-p

byte-compile--wide-docstring-p is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile--wide-docstring-p DOCSTRING COL)

Documentation

Return t if string DOCSTRING is wider than COL.

Ignore all substitute-command-keys substitutions, except for the \\=[command] ones that are assumed to be of length byte-compile--wide-docstring-substitution-len. Also ignore URLs.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile--wide-docstring-p (docstring col)
  "Return t if string DOCSTRING is wider than COL.
Ignore all `substitute-command-keys' substitutions, except for
the `\\\\=[command]' ones that are assumed to be of length
`byte-compile--wide-docstring-substitution-len'.  Also ignore
URLs."
  (string-match
   (format "^.\\{%d,\\}$" (min (1+ col) #xffff)) ; Heed RE_DUP_MAX.
   (replace-regexp-in-string
    (rx (or
         ;; Ignore some URLs.
         (seq "http" (? "s") "://" (* nonl))
         ;; Ignore these `substitute-command-keys' substitutions.
         (seq "\\" (or "="
                       (seq "<" (* (not ">")) ">")
                       (seq "{" (* (not "}")) "}")))
         ;; Ignore the function signature that's stashed at the end of
         ;; the doc string (in some circumstances).
         (seq bol "(" (+ (any word "-/:[]&"))
              ;; One or more arguments.
              (+ " " (or
                      ;; Arguments.
                      (+ (or (syntax symbol)
                             (any word "-/:[]&=()<>.,?^\\#*'\"")))
                      ;; Argument that is a list.
                      (seq "(" (* (not ")")) ")")))
              ")")))
    ""
    ;; Heuristic: We can't reliably do `substitute-command-keys'
    ;; substitutions, since the value of a keymap in general can't be
    ;; known at compile time.  So instead, we assume that these
    ;; substitutions are of some length N.
    (replace-regexp-in-string
     (rx "\\[" (* (not "]")) "]")
     (make-string byte-compile--wide-docstring-substitution-len ?x)
     ;; For literal key sequence substitutions (e.g. "\\`C-h'"), just
     ;; remove the markup as `substitute-command-keys' would.
     (replace-regexp-in-string
      (rx "\\`" (group (* (not "'"))) "'")
      "\\1"
      docstring)))))