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 MATCHER-FACTORY)

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 matcher-factory)
  "Expand macros in BUF to search for the definition of SYMBOL of TYPE."
  (with-current-buffer buf
    (when-let* ((expected-symbol-p
                 (cond ((null type)
                        (lambda (form)
                          ;; 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)
                        (lambda (form)
                          ;; Variables generated by macros ultimately
                          ;; expand to `defvar'.
                          (and (eq (car-safe form) 'defvar)
                               (eq (car-safe (cdr form)) symbol))))
                       (matcher-factory
                        (funcall matcher-factory symbol)))))
      (catch 'found
        (save-excursion
          (goto-char (point-min))
          (condition-case nil
              (while t
                (when (find-function--any-subform-p
                       (find-function--try-macroexpand
                        (read (current-buffer)))
                       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)))))))