Function: elisp-eldoc-funcall-with-docstring

elisp-eldoc-funcall-with-docstring is a byte-compiled function defined in elisp-mode.el.gz.

Signature

(elisp-eldoc-funcall-with-docstring CALLBACK &rest IGNORED)

Documentation

Document function call at point by calling CALLBACK.

Intended for eldoc-documentation-functions (which see). Compared to elisp-eldoc-funcall, this also includes the current function doc string, doc string length depends on elisp-eldoc-funcall-with-docstring-length.

Probably introduced at or before Emacs version 31.1.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/elisp-mode.el.gz
(defun elisp-eldoc-funcall-with-docstring (callback &rest _ignored)
  "Document function call at point by calling CALLBACK.
Intended for `eldoc-documentation-functions' (which see).
Compared to `elisp-eldoc-funcall', this also includes the
current function doc string, doc string length depends on
`elisp-eldoc-funcall-with-docstring-length'."
  (when-let* ((sym-info (elisp--fnsym-in-current-sexp))
              (fn-sym (car sym-info))
              ((fboundp fn-sym))
              (fn-doc (or (cdr (help-split-fundoc
                                (condition-case nil (documentation fn-sym t)
                                  (invalid-function nil))
                                fn-sym))
                          "Undocumented."))
              (more (- (length fn-doc) elisp-eldoc-docstring-length-limit))
              (doc (concat
                      (propertize
                       (string-limit fn-doc elisp-eldoc-docstring-length-limit)
                       'face 'font-lock-doc-face)
                      (when (> more 0)
                        (format "[%sc more]" more)))))
    (funcall callback
               (concat (apply #'elisp-get-fnsym-args-string sym-info)
                       ;; Ensure not display the docstring in the
                       ;; mode-line.
                       (when (not (minibufferp))
                         (concat
                          "\n"
                          (pcase elisp-eldoc-funcall-with-docstring-length
                            ('full doc)
                            ('short
                             (save-match-data
                               (when (string-match "\\." doc)
                                 (concat "\n" (substring doc 0 (match-end 0))))))))))
               :thing fn-sym
               :face (if (functionp fn-sym)
                         'font-lock-function-name-face
                       'font-lock-keyword-face))))