GNU bug report logs - #27772
25.2; Choosing tags files

Previous Next

Package: emacs;

Reported by: Daniel Lopez <daniel.lopez999 <at> gmail.com>

Date: Thu, 20 Jul 2017 13:51:02 UTC

Severity: minor

Tags: fixed, patch

Found in version 25.2

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


Message #10 received at control <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Daniel Lopez <daniel.lopez999 <at> gmail.com>
Cc: 27772 <at> debbugs.gnu.org
Subject: Re: bug#27772: 25.2; Choosing tags files
Date: Sun, 06 Aug 2017 21:45:56 -0400
[Message part 1 (text/plain, inline)]
tags 27772 + patch
severity 27772 minor
quit

Daniel Lopez <daniel.lopez999 <at> gmail.com> writes:

> mkdir foo_files
> cd foo_files
> echo "const int foo_const = 1;" > foo.h
> ctags -e foo.h

Hmm...

    $ ctags -e foo.h 
    ctags: invalid option -- 'e'
        Try 'ctags --help' for a complete list of options.
    $ ctags --version
    ctags (GNU Emacs 25.2.50)
    Copyright (C) 2017 Free Software Foundation, Inc.
    This program is distributed under the terms in ETAGS.README

Using 'etags foo.h' I can reproduce your results.

> I made some incomplete investigations into visit-tags-table-buffer
> where this seems to be implemented - I saw that at one point it seems
> to explicitly look up the local value of tags-file name:
>
>   ;; First, try a local variable.
>   (cdr (assq 'tags-file-name (buffer-local-variables)))
>
> Inspired by that I tried changing the part below where it seems to get
> the value of tags-table-list:
>
>   ;; Fifth, use the user variable giving the table list.
>   ;; Find the first element of the list that actually exists.
>   (let ((list tags-table-list)
>
> to go explicitly via the (buffer-local-variables) alist as well:
>
>   (let ((list (or (cdr (assq 'tags-table-list
> (buffer-local-variables))) tags-table-list))
>
> but it didn't seem to change the outcome of the above test case at
> all.

The problem is that the buffer gets changed by the time we reach there.
The following patch seems to fix it (no need to explicitly use
`buffer-local-variables' since normal variable access will check the
buffer-local value first.  I think the use of `buffer-local-variables'
above is meant to ignore the global value of `tags-file-name').

[v1-0001-Respect-buffer-local-value-of-tags-table-list-Bug.patch (text/x-diff, inline)]
From 884e23043dc263126341f297953d89ce28d7dd9a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 6 Aug 2017 21:35:04 -0400
Subject: [PATCH v1] Respect buffer-local value of tags-table-list (Bug#27772)

* lisp/progmodes/etags.el (visit-tags-table-buffer): Save the current
around the `tags-table-including' calls so as to get buffer local
variables from the right buffer later.
---
 lisp/progmodes/etags.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 8d635cb6d4..222dea1a2a 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -599,12 +599,13 @@ (defun visit-tags-table-buffer (&optional cont cbuf)
 		;; be frobnicated, and CONT will be set non-nil so we don't
 		;; do it below.
 		(and buffer-file-name
-		     (or
-		      ;; First check only tables already in buffers.
-		      (tags-table-including buffer-file-name t)
-		      ;; Since that didn't find any, now do the
-		      ;; expensive version: reading new files.
-		      (tags-table-including buffer-file-name nil)))
+                     (save-current-buffer
+                       (or
+                        ;; First check only tables already in buffers.
+                        (tags-table-including buffer-file-name t)
+                        ;; Since that didn't find any, now do the
+                        ;; expensive version: reading new files.
+                        (tags-table-including buffer-file-name nil))))
 		;; Fourth, use the user variable tags-file-name, if it is
 		;; not already in the current list.
 		(and tags-file-name
-- 
2.11.1


This bug report was last modified 8 years ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.