From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: 27772@debbugs.gnu.org, daniel.lopez999@gmail.com
Subject: bug#27772: 25.2; Choosing tags files
Date: Tue, 08 Aug 2017 20:02:10 -0400 [thread overview]
Message-ID: <87shh138xp.fsf@users.sourceforge.net> (raw)
In-Reply-To: <834ltita1s.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 08 Aug 2017 17:21:19 +0300")
[-- 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
next prev parent reply other threads:[~2017-08-09 0:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shh138xp.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=27772@debbugs.gnu.org \
--cc=daniel.lopez999@gmail.com \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.