emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 179499c: Respect buffer-local value of tags-table-l


From: Noam Postavsky
Subject: [Emacs-diffs] master 179499c: Respect buffer-local value of tags-table-list (Bug#27772)
Date: Thu, 10 Aug 2017 21:43:57 -0400 (EDT)

branch: master
commit 179499cde921a28c82400b1674520da245b93bb9
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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 8d635cb..222dea1 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -599,12 +599,13 @@ Returns t if it visits a tags table, or nil if there are 
no more in the list."
                ;; 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 eec8a02..0153f32 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 @@
     (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 @@
     (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 @@
   (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))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]