Unify the absolutely equal xref-backend-references implementations

* lisp/progmodes/elisp-mode.el (xref-backend-references):
Remove.

* lisp/progmodes/etags.el (xref-backend-references):
Remove.

* lisp/progmodes/xref.el (xref-backend-references):
Define the default implementation.
This commit is contained in:
Dmitry Gutov 2015-11-15 07:00:45 +02:00
parent 1a3c4541c3
commit a4c6f55b9a
3 changed files with 12 additions and 23 deletions

View file

@ -795,18 +795,6 @@ non-nil result supercedes the xrefs produced by
xrefs))
(declare-function project-library-roots "project")
(declare-function project-roots "project")
(declare-function project-current "project")
(cl-defmethod xref-backend-references ((_backend (eql elisp)) symbol)
"Find all references to SYMBOL (a string) in the current project."
(cl-mapcan
(lambda (dir)
(xref-collect-references symbol dir))
(let ((pr (project-current t)))
(append
(project-roots pr)
(project-library-roots pr)))))
(cl-defmethod xref-backend-apropos ((_backend (eql elisp)) regexp)
(apply #'nconc

View file

@ -2089,15 +2089,6 @@ for \\[find-tag] (which see)."
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
(tags-lazy-completion-table))
(cl-defmethod xref-backend-references ((_backend (eql etags)) symbol)
(cl-mapcan
(lambda (dir)
(xref-collect-references symbol dir))
(let ((pr (project-current t)))
(append
(project-roots pr)
(project-library-roots pr)))))
(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol)
(etags--xref-find-definitions symbol))

View file

@ -231,10 +231,20 @@ IDENTIFIER can be any string returned by
To create an xref object, call `xref-make'.")
(cl-defgeneric xref-backend-references (backend identifier)
(cl-defgeneric xref-backend-references (_backend identifier)
"Find references of IDENTIFIER.
The result must be a list of xref objects. If no references can
be found, return nil.")
be found, return nil.
The default implementation performs a Grep symbol-search inside
the current project."
(cl-mapcan
(lambda (dir)
(xref-collect-references identifier dir))
(let ((pr (project-current t)))
(append
(project-roots pr)
(project-library-roots pr)))))
(cl-defgeneric xref-backend-apropos (backend pattern)
"Find all symbols that match PATTERN.