Function: eldoc--format-doc-buffer

eldoc--format-doc-buffer is a byte-compiled function defined in eldoc.el.gz.

Signature

(eldoc--format-doc-buffer DOCS)

Documentation

Ensure DOCS are displayed in an *eldoc* buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/eldoc.el.gz
(defun eldoc--format-doc-buffer (docs)
  "Ensure DOCS are displayed in an *eldoc* buffer."
  (with-current-buffer (if (buffer-live-p eldoc--doc-buffer)
                           eldoc--doc-buffer
                         (setq eldoc--doc-buffer
                               (get-buffer-create " *eldoc*")))
    (unless (eq docs eldoc--doc-buffer-docs)
      (setq-local eldoc--doc-buffer-docs docs)
      (let ((inhibit-read-only t)
            (things-reported-on))
        (erase-buffer) (setq buffer-read-only t)
        (setq-local nobreak-char-display nil)
        (local-set-key "q" 'quit-window)
        (cl-loop for (docs . rest) on docs
                 for (this-doc . plist) = docs
                 for thing = (plist-get plist :thing)
                 when thing do
                 (cl-pushnew thing things-reported-on)
                 (setq this-doc
                       (concat
                        (propertize (format "%s" thing)
                                    'face (plist-get plist :face))
                        ": "
                        this-doc))
                 do (insert this-doc)
                 when rest do (insert "\n")
                 finally (goto-char (point-min)))
        ;; Rename the buffer, taking into account whether it was
        ;; hidden or not
        (rename-buffer (format "%s*eldoc%s*"
                               (if (string-match "^ " (buffer-name)) " " "")
                               (if things-reported-on
                                   (format " for %s"
                                           (mapconcat
                                            (lambda (s) (format "%s" s))
                                            things-reported-on
                                            ", "))
                                 ""))))))
  eldoc--doc-buffer)