Function: help-fns-function-name

help-fns-function-name is an autoloaded and byte-compiled function defined in help-fns.el.gz.

Signature

(help-fns-function-name FUNCTION)

Documentation

Return a short buttonized string representing FUNCTION.

The string is propertized with a button; clicking on that provides further details about FUNCTION. FUNCTION can be a function, a built-in, a keyboard macro, or a compile function. This function is intended to be used to display various callable symbols in buffers in a way that allows the user to find out more details about the symbols.

Probably introduced at or before Emacs version 30.1.

Source Code

;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
;;;###autoload
(defun help-fns-function-name (function)
  "Return a short buttonized string representing FUNCTION.
The string is propertized with a button; clicking on that
provides further details about FUNCTION.
FUNCTION can be a function, a built-in, a keyboard macro,
or a compile function.
This function is intended to be used to display various
callable symbols in buffers in a way that allows the user
to find out more details about the symbols."
  ;; FIXME: For kmacros, should we print the key-sequence?
  (cond
   ((symbolp function)
    (let ((name (if (eq (intern-soft (symbol-name function)) function)
                    (symbol-name function)
                  (concat "#:" (symbol-name function)))))
      (if (not (fboundp function))
          name
        (make-text-button name nil
                          'type 'help-function
                          'help-args (list function)))))
   ((gethash function help-fns--function-names))
   ((subrp function)
    (let ((name (subr-name function)))
      ;; FIXME: For native-elisp-functions, should we use `help-function'
      ;; or `disassemble'?
      (format "#<%s %s>"
              (cl-type-of function)
              (make-text-button name nil
                                'type 'help-function
                                ;; Let's hope the subr hasn't been redefined!
                                'help-args (list (intern name))))))
   (t
    (let ((type (or (oclosure-type function)
                    (if (consp function)
                        (car function) (cl-type-of function))))
          (hash (sxhash-eq function))
          ;; Use 3 digits minimum.
          (mask #xfff)
          name)
      (while
          (let* ((hex (format (concat "%0"
                                      (number-to-string (1+ (/ (logb mask) 4)))
                                      "X")
                              (logand mask hash)))
                 ;; FIXME: For kmacros, we don't want to `disassemble'!
                 (button (buttonize
                          hex #'help-fns--display-function function
                          ;; FIXME: Shouldn't `buttonize' add
                          ;; the "mouse-2, RET:" prefix?
                          "mouse-2, RET: Display the function's body")))
            (setq name (format "#<%s %s>" type button))
            (and (< mask (abs hash))    ; We can add more digits.
                 (gethash name help-fns--function-numbers)))
        ;; Add a digit.
        (setq mask (+ (ash mask 4) #x0f)))
      (puthash name function help-fns--function-numbers)
      (puthash function name help-fns--function-names)
      name))))