From: Dmitry Gutov Date: Sun, 15 Nov 2015 05:00:45 +0000 (+0200) Subject: Unify the absolutely equal xref-backend-references implementations X-Git-Tag: emacs-25.0.90~789 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a4c6f55b9a222849a1c5d590589b1f8f0627d6f8;p=emacs.git 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. --- diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 2c22483e86f..d6e7f837750 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -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 diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index ae1aa11fbc2..651c824275d 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -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)) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 40f8d23c64a..69a11bb776b 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -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.