unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27772: 25.2; Choosing tags files
@ 2017-07-20 13:49 Daniel Lopez
  2017-08-07  1:45 ` npostavs
       [not found] ` <handler.27772.C.15024158873392.notifdonectrl.0@debbugs.gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Lopez @ 2017-07-20 13:49 UTC (permalink / raw)
  To: 27772

Having problems while trying to choose multiple tags tables, via 
tags-table-list, to apply to a specific buffer only by setting that 
variable in a buffer-local way:

Test case:

Prepare a couple of directories each with with a TAGS file:

### Bash code start ###

mkdir /tmp/emacs_tags_test
cd /tmp/emacs_tags_test

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

mkdir bar_files
cd bar_files
echo "const int bar_const = 1;" > bar.h
ctags -e bar.h
cd ..

### Bash code end ###

Start emacs -Q and run the following to open a new file and set 
tags-table-list buffer-locally to reference both TAGS files:

### Elisp start ###

(progn
   (find-file "/tmp/emacs_tags_test/main.cpp")  ;;(this is a new file)

   (setq-local tags-table-list
       '("/tmp/emacs_tags_test/foo_files/TAGS"
         "/tmp/emacs_tags_test/bar_files/TAGS"))
)

### Elisp end ###

Do M-x xref-find-definitions. I get the prompt "Find definitions of:". I 
hit TAB hoping to get a list giving the choices of "foo_const" and 
"bar_const", but instead am prompted:

Visit tags table (default TAGS): /tmp/emacs_tags_test/bar_files/

I press Enter reluctantly to accept the default. I'm returned to the
"Find definitions of:" prompt, and "bar_const" is the sole completion
(no "foo_const" which I also wanted).

An aside: The global value of tags-file-name has now been set to
  "/tmp/emacs_tags_test/bar_files/TAGS"
and the global value of tags-table-list has now been set to
  ("/tmp/emacs_tags_test/bar_files/TAGS")
while the local value of tags-table-list is unchanged from what I set it to:
  ("/tmp/emacs_tags_test/foo_files/TAGS" 
"/tmp/emacs_tags_test/bar_files/TAGS")

If I do another M-x xref-find-definitions now, I still get "bar_const"
as the sole completion (instead of the choice of two I wanted).

(End test case)


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 rest of that function seems a bit too complicated for me to delve 
into right now (and I admit I've worked around this for myself, for now, 
by setting before-advice on visit-tags-table-buffer to set the global 
value of tags-table-list to what I want every time).

Daniel

---



In GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.10)
  of 2017-04-22 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.11903000
Configured using:
  'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
  --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
  'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
  -fstack-protector-strong' CPPFLAGS=-D_FORTIFY_SOURCE=2
  LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
   value of $LANG: en_GB.UTF-8
   locale-coding-system: utf-8-unix

Major mode: C++/l

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t


electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t
   abbrev-mode: t

Recent messages:
("/tmp/emacs_tags_test/foo_files/TAGS" 
"/tmp/emacs_tags_test/bar_files/TAGS")
Making tags completion table for /tmp/emacs_tags_test/bar_files/TAGS...
Starting a new list of tags tables
Making tags completion table for /tmp/emacs_tags_test/bar_files/TAGS...done
Quit
Type C-x 1 to delete the help window.
Making completion list...

Quit
completing-read-default: Command attempted to use minibuffer while in 
minibuffer

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils pp help-fns
thingatpt etags xref cl-seq project ring eieio byte-opt bytecomp
byte-compile cconv eieio-core cl-macs gv cl-extra help-mode cc-mode
cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs cl-loaddefs pcase cl-lib time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 116530 3695)
  (symbols 48 23070 0)
  (miscs 40 53 111)
  (strings 32 23520 5093)
  (string-bytes 1 794931)
  (vectors 16 16526)
  (vector-slots 8 487720 4910)
  (floats 8 230 253)
  (intervals 56 297 7)
  (buffers 976 23))





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27772: 25.2; Choosing tags files
  2017-07-20 13:49 bug#27772: 25.2; Choosing tags files Daniel Lopez
@ 2017-08-07  1:45 ` npostavs
  2017-08-07 16:10   ` Eli Zaretskii
       [not found] ` <handler.27772.C.15024158873392.notifdonectrl.0@debbugs.gnu.org>
  1 sibling, 1 reply; 8+ messages in thread
From: npostavs @ 2017-08-07  1:45 UTC (permalink / raw)
  To: Daniel Lopez; +Cc: 27772

[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]

tags 27772 + patch
severity 27772 minor
quit

Daniel Lopez <daniel.lopez999@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').


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1668 bytes --]

From 884e23043dc263126341f297953d89ce28d7dd9a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27772: 25.2; Choosing tags files
  2017-08-07  1:45 ` npostavs
@ 2017-08-07 16:10   ` Eli Zaretskii
  2017-08-08  2:55     ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-08-07 16:10 UTC (permalink / raw)
  To: npostavs; +Cc: daniel.lopez999, 27772

> From: npostavs@users.sourceforge.net
> Date: Sun, 06 Aug 2017 21:45:56 -0400
> Cc: 27772@debbugs.gnu.org
> 
> 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.

Seems reasonable, thanks.

> * lisp/progmodes/etags.el (visit-tags-table-buffer): Save the current
                                                                ^^^^^^^
You meant "current buffer", I presume.

Do etags-tests.el still pass after this change?  If so, would it be
possible to add a test for this bug?

Other than that, LGTM.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27772: 25.2; Choosing tags files
  2017-08-07 16:10   ` Eli Zaretskii
@ 2017-08-08  2:55     ` npostavs
  2017-08-08 14:21       ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-08-08  2:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27772, daniel.lopez999

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> * lisp/progmodes/etags.el (visit-tags-table-buffer): Save the current
>                                                                 ^^^^^^^
> You meant "current buffer", I presume.

Whoops, yes.

> Do etags-tests.el still pass after this change?

Yep, all 2 of them.

> If so, would it be possible to add a test for this bug?

Okay, the following basically works.  Although without the patch, the
test doesn't fail cleanly, it rather gets stuck waiting for input (the
TAGS table filename).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4547 bytes --]

From e3d3edfedf81543612367aee9a5aa53600d3c5c8 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 6 Aug 2017 21:35:04 -0400
Subject: [PATCH v2] Respect buffer-local value of tags-table-list (Bug#27772)

* lisp/progmodes/etags.el (visit-tags-table-buffer): Save the current
buffer around the `tags-table-including' calls so as to get buffer
local variables from the right buffer later.
* test/lisp/progmodes/etags-tests.el (etags-visit-tags-table-buffer):
New test.
* test/lisp/progmodes/etags-tests.el (etags-tests--test-dir): New
constant.
(etags-bug-158, etags-bug-23164): Use it so that when running the test
interactively, setting EMACS_TEST_DIRECTORY is not needed.
---
 lisp/progmodes/etags.el            | 13 +++++++------
 test/lisp/progmodes/etags-tests.el | 27 +++++++++++++++++++++------
 2 files changed, 28 insertions(+), 12 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 @@ visit-tags-table-buffer
 		;; 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
diff --git a/test/lisp/progmodes/etags-tests.el b/test/lisp/progmodes/etags-tests.el
index eec8a02f1b..950c853c09 100644
--- a/test/lisp/progmodes/etags-tests.el
+++ b/test/lisp/progmodes/etags-tests.el
@@ -26,6 +26,11 @@
 
 (defvar his-masters-voice t)
 
+(defconst etags-tests--test-dir
+  (or (getenv "EMACS_TEST_DIRECTORY")
+      (expand-file-name "../../.."
+                        (or load-file-name buffer-file-name))))
+
 (defun y-or-n-p (_prompt)
   "Replacement for `y-or-n-p' that returns what we tell it to."
   his-masters-voice)
@@ -38,8 +43,7 @@ y-or-n-p
     (set-buffer buf-with-global-tags)
     (setq default-directory (expand-file-name "."))
     (visit-tags-table
-     (expand-file-name "manual/etags/ETAGS.good_1"
-                       (getenv "EMACS_TEST_DIRECTORY")))
+     (expand-file-name "manual/etags/ETAGS.good_1" etags-tests--test-dir))
     ;; Check that tags in ETAGS.good_1 are recognized.
     (setq xref-buf (xref-find-definitions "LL_Task_Procedure_Access/t"))
     (should (bufferp xref-buf))
@@ -55,8 +59,7 @@ y-or-n-p
     (setq default-directory (expand-file-name "."))
     (let (his-masters-voice)
       (visit-tags-table
-       (expand-file-name "manual/etags/ETAGS.good_3"
-                         (getenv "EMACS_TEST_DIRECTORY"))
+       (expand-file-name "manual/etags/ETAGS.good_3" etags-tests--test-dir)
        t))
     ;; Check that tags in ETAGS.good_1 are recognized.
     (setq xref-buf (xref-find-definitions "LL_Task_Procedure_Access/t"))
@@ -84,8 +87,20 @@ y-or-n-p
   (set-buffer (get-buffer-create "*foobar*"))
   (fundamental-mode)
   (visit-tags-table
-   (expand-file-name "manual/etags/ETAGS.good_3"
-                     (getenv "EMACS_TEST_DIRECTORY"))
+   (expand-file-name "manual/etags/ETAGS.good_3" etags-tests--test-dir)
    t)
   (should (equal (should-error (xref-find-definitions "foobar123"))
                  '(user-error "No definitions found for: foobar123"))))
+
+(ert-deftest etags-buffer-local-tags-table-list ()
+  "Test that a buffer-local value of `tags-table-list' is used."
+  (let ((file (make-temp-file "etag-test-tmpfile")))
+    (set-buffer (find-file-noselect file))
+    (fundamental-mode)
+    (setq-local tags-table-list
+                (list (expand-file-name "manual/etags/ETAGS.good_3"
+                                        etags-tests--test-dir)))
+    (let ((tag-tables tags-table-list)
+          (tags-file-name nil))
+      (should (visit-tags-table-buffer))
+      (should (equal tags-file-name (car tag-tables))))))
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27772: 25.2; Choosing tags files
  2017-08-08  2:55     ` npostavs
@ 2017-08-08 14:21       ` Eli Zaretskii
  2017-08-09  0:02         ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-08-08 14:21 UTC (permalink / raw)
  To: npostavs; +Cc: 27772, daniel.lopez999

> From: npostavs@users.sourceforge.net
> Cc: 27772@debbugs.gnu.org,  daniel.lopez999@gmail.com
> Date: Mon, 07 Aug 2017 22:55:57 -0400
> 
> > If so, would it be possible to add a test for this bug?
> 
> Okay, the following basically works.  Although without the patch, the
> test doesn't fail cleanly, it rather gets stuck waiting for input (the
> TAGS table filename).

Would it be possible to work around that by replacing some function
(like we already do in this test)?  If not, please push, and thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27772: 25.2; Choosing tags files
  2017-08-08 14:21       ` Eli Zaretskii
@ 2017-08-09  0:02         ` npostavs
  2017-08-11  1:46           ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-08-09  0:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27772, daniel.lopez999

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: npostavs@users.sourceforge.net
>> Cc: 27772@debbugs.gnu.org,  daniel.lopez999@gmail.com
>> Date: Mon, 07 Aug 2017 22:55:57 -0400
>> 
>> > If so, would it be possible to add a test for this bug?
>> 
>> Okay, the following basically works.  Although without the patch, the
>> test doesn't fail cleanly, it rather gets stuck waiting for input (the
>> TAGS table filename).
>
> Would it be possible to work around that by replacing some function
> (like we already do in this test)?  If not, please push, and thanks.

Oh yeah, that's easy (why didn't I do that right away?  Must have been
tired or something.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4778 bytes --]

From 6df75e619d2438483e917b4c3a4c8a50f10db93c Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 6 Aug 2017 21:35:04 -0400
Subject: [PATCH v3] Respect buffer-local value of tags-table-list (Bug#27772)

* lisp/progmodes/etags.el (visit-tags-table-buffer): Save the current
buffer around the `tags-table-including' calls so as to get buffer
local variables from the right buffer later.
* test/lisp/progmodes/etags-tests.el (etags-visit-tags-table-buffer):
New test.
* test/lisp/progmodes/etags-tests.el (etags-tests--test-dir): New
constant.
(etags-bug-158, etags-bug-23164): Use it so that when running the test
interactively, setting EMACS_TEST_DIRECTORY is not needed.
---
 lisp/progmodes/etags.el            | 13 +++++++------
 test/lisp/progmodes/etags-tests.el | 31 +++++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 12 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 @@ visit-tags-table-buffer
 		;; 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
diff --git a/test/lisp/progmodes/etags-tests.el b/test/lisp/progmodes/etags-tests.el
index eec8a02f1b..0153f327ba 100644
--- a/test/lisp/progmodes/etags-tests.el
+++ b/test/lisp/progmodes/etags-tests.el
@@ -23,9 +23,15 @@
 
 (require 'ert)
 (require 'etags)
+(eval-when-compile (require 'cl-lib))
 
 (defvar his-masters-voice t)
 
+(defconst etags-tests--test-dir
+  (or (getenv "EMACS_TEST_DIRECTORY")
+      (expand-file-name "../../.."
+                        (or load-file-name buffer-file-name))))
+
 (defun y-or-n-p (_prompt)
   "Replacement for `y-or-n-p' that returns what we tell it to."
   his-masters-voice)
@@ -38,8 +44,7 @@ y-or-n-p
     (set-buffer buf-with-global-tags)
     (setq default-directory (expand-file-name "."))
     (visit-tags-table
-     (expand-file-name "manual/etags/ETAGS.good_1"
-                       (getenv "EMACS_TEST_DIRECTORY")))
+     (expand-file-name "manual/etags/ETAGS.good_1" etags-tests--test-dir))
     ;; Check that tags in ETAGS.good_1 are recognized.
     (setq xref-buf (xref-find-definitions "LL_Task_Procedure_Access/t"))
     (should (bufferp xref-buf))
@@ -55,8 +60,7 @@ y-or-n-p
     (setq default-directory (expand-file-name "."))
     (let (his-masters-voice)
       (visit-tags-table
-       (expand-file-name "manual/etags/ETAGS.good_3"
-                         (getenv "EMACS_TEST_DIRECTORY"))
+       (expand-file-name "manual/etags/ETAGS.good_3" etags-tests--test-dir)
        t))
     ;; Check that tags in ETAGS.good_1 are recognized.
     (setq xref-buf (xref-find-definitions "LL_Task_Procedure_Access/t"))
@@ -84,8 +88,23 @@ y-or-n-p
   (set-buffer (get-buffer-create "*foobar*"))
   (fundamental-mode)
   (visit-tags-table
-   (expand-file-name "manual/etags/ETAGS.good_3"
-                     (getenv "EMACS_TEST_DIRECTORY"))
+   (expand-file-name "manual/etags/ETAGS.good_3" etags-tests--test-dir)
    t)
   (should (equal (should-error (xref-find-definitions "foobar123"))
                  '(user-error "No definitions found for: foobar123"))))
+
+(ert-deftest etags-buffer-local-tags-table-list ()
+  "Test that a buffer-local value of `tags-table-list' is used."
+  (let ((file (make-temp-file "etag-test-tmpfile")))
+    (set-buffer (find-file-noselect file))
+    (fundamental-mode)
+    (setq-local tags-table-list
+                (list (expand-file-name "manual/etags/ETAGS.good_3"
+                                        etags-tests--test-dir)))
+    (cl-letf ((tag-tables tags-table-list)
+              (tags-file-name nil)
+              ((symbol-function 'read-file-name)
+               (lambda (&rest _)
+                 (error "We should not prompt the user"))))
+      (should (visit-tags-table-buffer))
+      (should (equal tags-file-name (car tag-tables))))))
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27772: 25.2; Choosing tags files
  2017-08-09  0:02         ` npostavs
@ 2017-08-11  1:46           ` npostavs
  0 siblings, 0 replies; 8+ messages in thread
From: npostavs @ 2017-08-11  1:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27772, daniel.lopez999

tags 27772 fixed
close 27772 26.1
quit

npostavs@users.sourceforge.net writes:

>>> Okay, the following basically works.  Although without the patch, the
>>> test doesn't fail cleanly, it rather gets stuck waiting for input (the
>>> TAGS table filename).
>>
>> Would it be possible to work around that by replacing some function
>> (like we already do in this test)?  If not, please push, and thanks.
>
> Oh yeah, that's easy (why didn't I do that right away?  Must have been
> tired or something.)

Pushed to master.

[1: 179499cde9]: 2017-08-10 21:30:37 -0400
  Respect buffer-local value of tags-table-list (Bug#27772)
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=179499cde921a28c82400b1674520da245b93bb9





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27772: acknowledged by developer (Re: bug#27772: 25.2; Choosing tags files)
       [not found] ` <handler.27772.C.15024158873392.notifdonectrl.0@debbugs.gnu.org>
@ 2017-08-11  3:46   ` Daniel Lopez
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Lopez @ 2017-08-11  3:46 UTC (permalink / raw)
  To: 27772

On 11/08/17 02:45, GNU bug Tracking System wrote:
> This is an automatic notification regarding your bug report
> #27772: 25.2; Choosing tags files,
> which was filed against the emacs package.
> 
> Thank you for your report, which has now been closed.
> You can view the full report at
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27772
> 
> If you require further information, please followup to 27772@debbugs.gnu.org.
> 
> debbugs.gnu.org maintainers
> (administrator, GNU bugs database)
> 
> 

Thanks for seeing to this, guys - I had a quick try with the modified 
visit-tags-table-buffer in my running Emacs, and it seems to fix my 
original problem.

Daniel





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-08-11  3:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-20 13:49 bug#27772: 25.2; Choosing tags files Daniel Lopez
2017-08-07  1:45 ` npostavs
2017-08-07 16:10   ` Eli Zaretskii
2017-08-08  2:55     ` npostavs
2017-08-08 14:21       ` Eli Zaretskii
2017-08-09  0:02         ` npostavs
2017-08-11  1:46           ` npostavs
     [not found] ` <handler.27772.C.15024158873392.notifdonectrl.0@debbugs.gnu.org>
2017-08-11  3:46   ` bug#27772: acknowledged by developer (Re: bug#27772: 25.2; Choosing tags files) Daniel Lopez

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).