Subject: bug#21443: 24.5; etags' complete-tag changes the global value of tags-file-name

From: Dmitry Gutov <[email-masked]>
Date: Tue, 24 Nov 2015 00:03:12 +0200

On 09/11/2015 09:57 AM, Eli Zaretskii wrote:

> You can't, currently.  You need to invoke visit-tags-table manually,
> with a prefix argument, before the mini-buffer completion.  This is
> how the code was designed.

Unfortunately, this is also broken: you can C-u M-x visit-tags-table, 
and it will set the local value of tags-file-name, but as soon as you 
M-x find-tag, it changes the global value of tags-file-name as well, to 
the last element in tags-table-list.

Apparently because the lambda in tags-lazy-completion-table calls 
visit-tags-table-buffer at least twice, and the latter function modifies 
tags-file-name, _and_ changes the current buffer (and when called the 
second time, it changes tags-file-name in the tags table buffer, thus 
changing the global value).

And I can't simply wrap most of the second half of 
visit-tags-table-buffer in a with-current-buffer, because some code 
assumes that the buffer does indeed change. Otherwise, the value of 
tags-completion-table-function is nil (tags-completion-table calls it 
after calling visit-tags-table-buffer).

Modifications of tags-file-name are also numerous, so changing a couple 
of setq to setq-local inside visit-tags-table-buffer doesn't do the 
trick either.

At this point I'm leaving this to someone else who's more motivated. But 
we'll likely already migrate to e.g. GNU Global before that happens.