[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] emacs-26 b1aaa72: Improve documentation of Xref

From: Dmitry Gutov
Subject: Re: [Emacs-diffs] emacs-26 b1aaa72: Improve documentation of Xref
Date: Tue, 13 Mar 2018 01:45:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Thunderbird/59.0

On 3/13/18 12:43 AM, Stefan Monnier wrote:

Maybe xref could have an ad-hoc hack which does:
- if there's no match
- and there's a tags table installed.
- and there's a match in the tags table.
- then kindly suggest to the user to activate xref-etags-mode

Is that going to be a temporary measure? If so, when do we phase it out?

Anyway, here's a patch that somebody could test out:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 5a9a7a925a..bdb1503c2e 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -828,10 +828,19 @@ xref--read-identifier
 ;;; Commands

+(defvar xref--warned-about-xref-etags-mode nil)
 (defun xref--find-xrefs (input kind arg display-action)
-  (let ((xrefs (funcall (intern (format "xref-backend-%s" kind))
-                        (xref-find-backend)
-                        arg)))
+  (let* ((fun (intern (format "xref-backend-%s" kind)))
+         (xrefs (funcall fun (xref-find-backend) arg)))
+    (unless (or xrefs
+                xref--warned-about-xref-etags-mode)
+      (when (and tags-file-name
+                 (funcall fun 'etags arg))
+        (setq xref--warned-about-xref-etags-mode t)
+ (user-error (concat "No %s found for: %s; did you mean to use etags?"
+                            " If so, turn on xref-etags-mode")
+                    (symbol-name kind) input)))
     (unless xrefs
       (user-error "No %s found for: %s" (symbol-name kind) input))
     (xref--show-xrefs xrefs display-action)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]