mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-09 15:50:40 -08:00
xref-find-definitions: Exclude more generic function items.
* lisp/emacs-lisp/cl-generic.el (cl--generic-search-method): Add doc string. (cl--generic-find-defgeneric-regexp): New. (find-function-regexp-alist): Add it. * lisp/emacs-lisp/find-func.el (find-feature-regexp): Move here from elisp-mode.el, change to search for ";;; Code:" (find-alias-regexp): Move here from elisp-mode.el, cleaned up. (find-function-regexp-alist): Add them. * lisp/progmodes/elisp-mode.el: (elisp--xref-format, elisp--xref-format-extra): Change back to defvar due to bug#21237. (elisp--xref-find-definitions): Exclude co-located default methods for generic functions. Also exclude implicitly declared defgeneric. (elisp--xref-find-definitions): Handle C source properly. Exclude minor mode variables defined by 'define-minor-mode'. * test/automated/elisp-mode-tests.el: Declare generic functions, add tests for them. (xref-elisp-test-run): Fix bug. (emacs-test-dir): Improve initial value. (find-defs-defun-defvar-el): Don't expect defvar. (find-defs-feature-el): Match change to find-feature-regexp.
This commit is contained in:
parent
9c13a81a9e
commit
0382fd42c6
4 changed files with 264 additions and 55 deletions
|
|
@ -791,6 +791,8 @@ Can only be used from within the lexical body of a primary or around method."
|
|||
;;; Add support for describe-function
|
||||
|
||||
(defun cl--generic-search-method (met-name)
|
||||
"For `find-function-regexp-alist'. Searches for a cl-defmethod.
|
||||
MET-NAME is a cons (SYMBOL . SPECIALIZERS)."
|
||||
(let ((base-re (concat "(\\(?:cl-\\)?defmethod[ \t]+"
|
||||
(regexp-quote (format "%s" (car met-name)))
|
||||
"\\_>")))
|
||||
|
|
@ -806,11 +808,15 @@ Can only be used from within the lexical body of a primary or around method."
|
|||
nil t)
|
||||
(re-search-forward base-re nil t))))
|
||||
|
||||
;; WORKAROUND: This can't be a defconst due to bug#21237.
|
||||
(defvar cl--generic-find-defgeneric-regexp "(\\(?:cl-\\)?defgeneric[ \t]+%s\\>")
|
||||
|
||||
(with-eval-after-load 'find-func
|
||||
(defvar find-function-regexp-alist)
|
||||
(add-to-list 'find-function-regexp-alist
|
||||
`(cl-defmethod . ,#'cl--generic-search-method)))
|
||||
`(cl-defmethod . ,#'cl--generic-search-method))
|
||||
(add-to-list 'find-function-regexp-alist
|
||||
`(cl-defgeneric . cl--generic-find-defgeneric-regexp)))
|
||||
|
||||
(defun cl--generic-method-info (method)
|
||||
(let* ((specializers (cl--generic-method-specializers method))
|
||||
|
|
|
|||
|
|
@ -100,10 +100,34 @@ Please send improvements and fixes to the maintainer."
|
|||
:group 'find-function
|
||||
:version "22.1")
|
||||
|
||||
(defcustom find-feature-regexp
|
||||
(concat ";;; Code:")
|
||||
"The regexp used by `xref-find-definitions' when searching for a feature definition.
|
||||
Note it must contain a `%s' at the place where `format'
|
||||
should insert the feature name."
|
||||
;; We search for ";;; Code" rather than (feature '%s) because the
|
||||
;; former is near the start of the code, and the latter is very
|
||||
;; uninteresting. If the regexp is not found, just goes to
|
||||
;; (point-min), which is acceptable in this case.
|
||||
:type 'regexp
|
||||
:group 'xref
|
||||
:version "25.0")
|
||||
|
||||
(defcustom find-alias-regexp
|
||||
"(defalias +'%s"
|
||||
"The regexp used by `xref-find-definitions' to search for an alias definition.
|
||||
Note it must contain a `%s' at the place where `format'
|
||||
should insert the feature name."
|
||||
:type 'regexp
|
||||
:group 'xref
|
||||
:version "25.0")
|
||||
|
||||
(defvar find-function-regexp-alist
|
||||
'((nil . find-function-regexp)
|
||||
(defvar . find-variable-regexp)
|
||||
(defface . find-face-regexp))
|
||||
(defface . find-face-regexp)
|
||||
(feature . find-feature-regexp)
|
||||
(defalias . find-alias-regexp))
|
||||
"Alist mapping definition types into regexp variables.
|
||||
Each regexp variable's value should actually be a format string
|
||||
to be used to substitute the desired symbol name into the regexp.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue