Subject: bug#23164: 25.1.50; xref-find-definitions with local tags-file-name fails

From: Dmitry Gutov <[email-masked]>
Date: Thu, 7 Apr 2016 06:15:19 +0300

On 04/05/2016 12:24 AM, Johan Claesson wrote:

> It also occur with other simple TAGS files that do not include other
> TAGS files.  And the TAGS file i was using when observing the problem
> the first time was this kind of simple TAGS file.

Right, thank you.

Apparently, the long-standing way to make it work is to call 
visit-tags-table with non-nil second argument, instead of just using 
setq-local. So, this seems to work correctly:

(fundamental-mode)
(visit-tags-table "~/examples/ruby/TAGS" t)
(xref-find-definitions "a")

It performs more work in advance, though, and I'm not sure what's the 
big picture with keeping variables like tags-table-list global anyway.

Here's a patch you can try that makes etags--xref-find-definitions work 
with your original scenario, but I'm not 100% sure it's good code. The 
proper solution to setting tags-file-name locally probably looks different.

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index a2a0df2..856d26b 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2111,6 +2111,7 @@ etags--xref-find-definitions
                                 tags-case-fold-search
                               case-fold-search)))
      (save-excursion
+      (visit-tags-table-buffer) ; Workaround for bug#23164
        (while (visit-tags-table-buffer (not first-time))
          (setq first-time nil)
          (dolist (order-fun (cond (regexp? find-tag-regexp-tag-order)