[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27772: 25.2; Choosing tags files
From: |
npostavs |
Subject: |
bug#27772: 25.2; Choosing tags files |
Date: |
Mon, 07 Aug 2017 22:55:57 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) |
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).
>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