Function: find-function--search-by-expanding-macros

find-function--search-by-expanding-macros is a byte-compiled function defined in find-func.el.gz.

Signature

(find-function--search-by-expanding-macros BUF SYMBOL TYPE)

Documentation

Expand macros in BUF to search for the definition of SYMBOL of TYPE.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/find-func.el.gz
(defun find-function--search-by-expanding-macros (buf symbol type)
  "Expand macros in BUF to search for the definition of SYMBOL of TYPE."
  (catch 'found
    (with-current-buffer buf
      (save-excursion
        (goto-char (point-min))
        (condition-case nil
            (while t
              (let ((form (read (current-buffer)))
                    (expected-symbol-p
                      (lambda (form)
                        (cond
                         ((null type)
                          ;; Check if a given form is a `defalias' to
                          ;; SYM, the function name we are searching
                          ;; for.  All functions in Emacs Lisp
                          ;; ultimately expand to a `defalias' form
                          ;; after several steps of macroexpansion.
                          (and (eq (car-safe form) 'defalias)
                               (equal (car-safe (cdr form))
                                      `(quote ,symbol))))
                         ((eq type 'defvar)
                          ;; Variables generated by macros ultimately
                          ;; expand to `defvar'.
                          (and (eq (car-safe form) 'defvar)
                               (eq (car-safe (cdr form)) symbol)))
                         (t nil)))))
                (when (find-function--any-subform-p
                       (find-function--try-macroexpand form)
                       expected-symbol-p)
                  ;; We want to return the location at the beginning
                  ;; of the macro, so move back one sexp.
                  (throw 'found (progn (backward-sexp) (point))))))
          (end-of-file nil))))))