Function: describe-symbol

describe-symbol is an autoloaded, interactive and byte-compiled function defined in help-fns.el.gz.

Signature

(describe-symbol SYMBOL &optional BUFFER FRAME)

Documentation

Display the full documentation of SYMBOL.

Will show the info of SYMBOL as a function, variable, and/or face. Optional arguments BUFFER and FRAME specify for which buffer and frame to show the information about SYMBOL; they default to the current buffer and the selected frame, respectively.

View in manual

Probably introduced at or before Emacs version 25.1.

Key Bindings

Aliases

help-xref-interned (obsolete since 25.1)

Source Code

;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
;;;###autoload
(defun describe-symbol (symbol &optional buffer frame)
  "Display the full documentation of SYMBOL.
Will show the info of SYMBOL as a function, variable, and/or face.
Optional arguments BUFFER and FRAME specify for which buffer and
frame to show the information about SYMBOL; they default to the
current buffer and the selected frame, respectively."
  (interactive
   (let* ((v-or-f (symbol-at-point))
          (found (if v-or-f (cl-some (lambda (x) (funcall (nth 1 x) v-or-f))
                                     describe-symbol-backends)))
          (v-or-f (if found v-or-f (function-called-at-point)))
          (found (or found v-or-f))
          (enable-recursive-minibuffers t)
          (val (completing-read (format-prompt "Describe symbol"
                                               (and found v-or-f))
				#'help--symbol-completion-table
				(lambda (vv)
                                  (cl-some (lambda (x) (funcall (nth 1 x) vv))
                                           describe-symbol-backends))
				t nil nil
				(if found (symbol-name v-or-f)))))
     (list (if (equal val "")
	       (or v-or-f "") (intern val)))))
  (let ((help-buffer-under-preparation t))
    (if (not (symbolp symbol))
        (user-error "You didn't specify a function or variable"))
    (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
    (unless (frame-live-p frame) (setq frame (selected-frame)))
    (with-current-buffer (help-buffer)
      ;; Push the previous item on the stack before clobbering the output buffer.
      (help-setup-xref nil nil)
      (let* ((docs
              (nreverse
               (delq nil
                     (mapcar (pcase-lambda (`(,name ,testfn ,descfn))
                               (when (funcall testfn symbol)
                                 ;; Don't record the current entry in the stack.
                                 (setq help-xref-stack-item nil)
                                 (let ((help-xref-stack nil)
                                       (help-xref-forward-stack nil))
                                   (funcall descfn symbol buffer frame))
                                 (cons name (buffer-string))))
                             describe-symbol-backends))))
             (single (null (cdr docs))))
        (while (cdr docs)
          (goto-char (point-min))
          (let ((inhibit-read-only t)
                (name (caar docs))        ;Name of doc currently at BOB.
                (doc (cdr (cadr docs))))  ;Doc to add at BOB.
            (when doc
              (insert doc)
              (delete-region (point)
                             (progn (skip-chars-backward " \t\n") (point)))
              (insert "\n\n" (make-separator-line) "\n")
              (when name
                (insert (symbol-name symbol)
                        " is also a " name "." "\n\n"))))
          (setq docs (cdr docs)))
        (unless single
          ;; Don't record the `describe-variable' item in the stack.
          (setq help-xref-stack-item nil)
          (help-setup-xref (list #'describe-symbol symbol) nil))
        (goto-char (point-max))
        (help-xref--navigation-buttons)
        (goto-char (point-min))))))