]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/etags.el
Add mode local overrides to xref-find-definitions
[gnu-emacs] / lisp / progmodes / etags.el
index bf57770a3dd0e2e9d34cdf9801e97d5ca9a890c7..23f9370767961a2dc3568e78641083e138e74e08 100644 (file)
@@ -1754,7 +1754,7 @@ if the file was newly read in, the value is the filename."
         (with-current-buffer buffer
           (revert-buffer t t)))
     (if (not (and new novisit))
-       (find-file next novisit)
+       (find-file next)
       ;; Like find-file, but avoids random warning messages.
       (switch-to-buffer (get-buffer-create " *next-file*"))
       (kill-all-local-variables)
@@ -1772,7 +1772,7 @@ if the file was newly read in, the value is the filename."
                "No \\[tags-search] or \\[tags-query-replace] in progress"))
   "Form for `tags-loop-continue' to eval to scan one file.
 If it returns non-nil, this file needs processing by evalling
-\`tags-loop-operate'.  Otherwise, move on to the next file.")
+`tags-loop-operate'.  Otherwise, move on to the next file.")
 
 (defun tags-loop-eval (form)
   "Evaluate FORM and return its result.
@@ -1846,7 +1846,9 @@ nil, we exit; otherwise we scan the next file."
 
          ;; Now operate on the file.
          ;; If value is non-nil, continue to scan the next file.
-         (tags-loop-eval tags-loop-operate))
+          (save-restriction
+            (widen)
+            (tags-loop-eval tags-loop-operate)))
       (setq file-finished t))
     (and messaged
         (null tags-loop-operate)
@@ -2087,18 +2089,15 @@ for \\[find-tag] (which see)."
 (defun etags-xref-find (action id)
   (pcase action
     (`definitions (etags--xref-find-definitions id))
-    (`references
-     (etags--xref-find-matches id #'xref-collect-references))
-    (`matches
-     (etags--xref-find-matches id #'xref-collect-matches))
+    (`references  (etags--xref-find-references id))
     (`apropos (etags--xref-find-definitions id t))))
 
-(defun etags--xref-find-matches (input fun)
-  (let ((dirs (if tags-table-list
-                  (mapcar #'file-name-directory tags-table-list)
-                ;; If no tags files are loaded, prompt for the dir.
-                (list (read-directory-name "In directory: " nil nil t)))))
-    (cl-mapcan (lambda (dir) (funcall fun input dir)) dirs)))
+(defun etags--xref-find-references (symbol)
+  ;; TODO: Merge together with the Elisp impl.
+  (cl-mapcan
+   (lambda (dir)
+     (xref-collect-references symbol dir))
+   (project-search-path (project-current))))
 
 (defun etags--xref-find-definitions (pattern &optional regexp?)
   ;; This emulates the behaviour of `find-tag-in-order' but instead of
@@ -2154,6 +2153,9 @@ for \\[find-tag] (which see)."
   (with-slots (tag-info) l
     (nth 1 tag-info)))
 
+(defun etags-search-path ()
+  (mapcar #'file-name-directory tags-table-list))
+
 \f
 (provide 'etags)