Function: find-function-library

find-function-library is a byte-compiled function defined in find-func.el.gz.

Signature

(find-function-library FUNCTION &optional LISP-ONLY VERBOSE)

Documentation

Return the pair (ORIG-FUNCTION . LIBRARY) for FUNCTION.

ORIG-FUNCTION is the original name, after resolving aliases. LIBRARY is an absolute file name, a relative file name inside the C sources directory, or a name of an autoloaded feature.

If ORIG-FUNCTION is a built-in function and LISP-ONLY is non-nil, signal an error.

If VERBOSE is non-nil, and FUNCTION is an alias, display a message about the whole chain of aliases.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/find-func.el.gz
(defun find-function-library (function &optional lisp-only verbose)
  "Return the pair (ORIG-FUNCTION . LIBRARY) for FUNCTION.

ORIG-FUNCTION is the original name, after resolving aliases.
LIBRARY is an absolute file name, a relative
file name inside the C sources directory, or a name of an
autoloaded feature.

If ORIG-FUNCTION is a built-in function and LISP-ONLY is non-nil,
signal an error.

If VERBOSE is non-nil, and FUNCTION is an alias, display a
message about the whole chain of aliases."
  (let ((def (when (symbolp function)
               (or (fboundp function)
                   (signal 'void-function (list function)))
               (find-function-advised-original function)))
        aliases)
    ;; FIXME for completeness, it might be nice to print something like:
    ;; foo (which is advised), which is an alias for bar (which is advised).
    (while (and def (symbolp def))
      (or (eq def function)
          (not verbose)
          (setq aliases (if aliases
                            (concat aliases
                                    (format-message
                                     ", which is an alias for `%s'"
                                     (symbol-name def)))
                          (format-message "`%s' is an alias for `%s'"
                                          function (symbol-name def)))))
      (setq function (find-function-advised-original function)
            def (find-function-advised-original function)))
    (if aliases
        (message "%s" aliases))
    (cons function
          (cond
           ((autoloadp def) (nth 1 def))
           ((subr-primitive-p def)
            (if lisp-only
                (error "%s is a built-in function" function))
            (help-C-file-name def 'subr))
           ((symbol-file function 'defun))))))