Function: elisp--xref-filter-definitions

elisp--xref-filter-definitions is a byte-compiled function defined in elisp-mode.el.gz.

Signature

(elisp--xref-filter-definitions DEFINITIONS NAMESPACE SYMBOL)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/elisp-mode.el.gz
(defun elisp--xref-filter-definitions (definitions namespace symbol)
  (if (eq namespace 'any)
      (if (memq symbol minor-mode-list)
          ;; The symbol is a minor mode. These should be defined by
          ;; "define-minor-mode", which means the variable and the
          ;; function are declared in the same place. So we return only
          ;; the function, arbitrarily.
          ;;
          ;; There is an exception, when the variable is defined in C
          ;; code, as for abbrev-mode.
          (cl-loop for d in definitions
                   for loc = (xref-item-location d)
                   for file = (xref-elisp-location-file loc)
                   when (or (not (eq (xref-elisp-location-type loc) 'defvar))
                            (null file)
                            (string-prefix-p "src/" file))
                   collect d)
        definitions)
    (let ((expected-types
           (pcase-exhaustive namespace
             ('function '( nil defalias define-type
                           cl-defgeneric cl-defmethod))
             ('variable '(defvar))
             ('face '(defface))
             ('feature '(feature)))))
      (cl-loop for d in definitions
               when (memq
                     (xref-elisp-location-type (xref-item-location d))
                     expected-types)
               collect d))))