From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#27772: 25.2; Choosing tags files Date: Tue, 08 Aug 2017 20:02:10 -0400 Message-ID: <87shh138xp.fsf@users.sourceforge.net> References: <87mv7c40bv.fsf@users.sourceforge.net> <83h8xjtl35.fsf@gnu.org> <871som4vk2.fsf@users.sourceforge.net> <834ltita1s.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1502236884 7518 195.159.176.226 (9 Aug 2017 00:01:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 9 Aug 2017 00:01:24 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 27772@debbugs.gnu.org, daniel.lopez999@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 09 02:01:19 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfER1-0001Uw-G0 for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Aug 2017 02:01:15 +0200 Original-Received: from localhost ([::1]:44993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfER7-0002Fm-Pl for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Aug 2017 20:01:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfEQv-000295-14 for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2017 20:01:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfEQo-000869-TP for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2017 20:01:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43705) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dfEQo-00085g-Iy for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2017 20:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dfEQo-0001wC-Ax for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2017 20:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Aug 2017 00:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27772 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 27772-submit@debbugs.gnu.org id=B27772.15022368426254 (code B ref 27772); Wed, 09 Aug 2017 00:01:02 +0000 Original-Received: (at 27772) by debbugs.gnu.org; 9 Aug 2017 00:00:42 +0000 Original-Received: from localhost ([127.0.0.1]:52386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfEQU-0001cG-1z for submit@debbugs.gnu.org; Tue, 08 Aug 2017 20:00:42 -0400 Original-Received: from mail-io0-f194.google.com ([209.85.223.194]:37388) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfEQS-0001VQ-F8 for 27772@debbugs.gnu.org; Tue, 08 Aug 2017 20:00:40 -0400 Original-Received: by mail-io0-f194.google.com with SMTP id c74so3585015iod.4 for <27772@debbugs.gnu.org>; Tue, 08 Aug 2017 17:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=b+vvfZb8VygcCq8BWtvq/4vKfy/ejy/RQTDx1aFIdN0=; b=Ceezp0Ct/R4h8rTWS7No2zdUmeg+dBVK/f49dIw5mqlOFdMxJhSPRavu1oeNDRRNrE SD4aA9Bt2ff61xpI1bWzAfKnbCa4//AIKuhqYUy3K9e6RieYLYfhm1pAhN/zYPW6sHV/ ohDTGfUCTQltjn2w8DdvCxCcIcAC3guwk0F9vE52csfEPcsOH4pBAvGtFtttq8uiGBWw gyNZ7QTO1iCehJS/xsjrJJ3PYQuYbvCIL/oTq6BC/mRUOsf1g7Tj68Fx70dfGDybquKh CZD7i2Qj3+u5Vpaj14DwZ9yIKtooE07q22splTGNDqJQInJVjt5LoAz1ncw7+JTGHjZP pniQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=b+vvfZb8VygcCq8BWtvq/4vKfy/ejy/RQTDx1aFIdN0=; b=nf5v8xvB8MXIOFYnGVsIxiGN+aE+Lh8e4EOIkJdcNAVACbOYtP8rPZGpo3BY+0Ej7k pjFPaodKzVsuKWCWpNvwqeMGlbswFmtBj7Vcm05wR4RAPGHnzNGqTBTFEqUXmQOAYnYZ 6q43HFMLcctVt9Tyc14dHfgOtJ8nnuqAPt4EoPm9UVIWHtVvpmfCqLA+dqVB3VSvySkc cOUEaFPar58l/+sKkRKnI7ZXwLQz8VBQRprxagkUHuqKfFxAO5MnQ07X5knvCahMwXog ZvkvGdWFytNMBPTJJFF6QnN8ZDUUoudQ4rW4KcMnYuW+N1hwO8KhdFmjpo6Mm0MWIGa7 hfoQ== X-Gm-Message-State: AHYfb5hE5G0sZxM/pWnqPJAHsh5uBkIs8Sg58IikJKoIBvB6DwKIoy+9 Dpi03Y4g+oW3oA== X-Received: by 10.107.24.66 with SMTP id 63mr4876022ioy.111.1502236834815; Tue, 08 Aug 2017 17:00:34 -0700 (PDT) Original-Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id y65sm1393301itb.44.2017.08.08.17.00.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Aug 2017 17:00:33 -0700 (PDT) In-Reply-To: <834ltita1s.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 08 Aug 2017 17:21:19 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135585 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii 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.) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-Respect-buffer-local-value-of-tags-table-list-Bug.patch Content-Description: patch >From 6df75e619d2438483e917b4c3a4c8a50f10db93c Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-=--