GNU bug report logs - #43086
[PATCH] Allow tags backend to not query for TAGS file

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: "Philip K." <philipk@HIDDEN>; Keywords: patch; dated Fri, 28 Aug 2020 12:51:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 43086 <at> debbugs.gnu.org:


Received: (at 43086) by debbugs.gnu.org; 5 Sep 2020 00:45:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 04 20:45:27 2020
Received: from localhost ([127.0.0.1]:41128 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kEMKd-0006Ym-EP
	for submit <at> debbugs.gnu.org; Fri, 04 Sep 2020 20:45:27 -0400
Received: from mail-lj1-f193.google.com ([209.85.208.193]:44576)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1kEMKb-0006SE-PX
 for 43086 <at> debbugs.gnu.org; Fri, 04 Sep 2020 20:45:26 -0400
Received: by mail-lj1-f193.google.com with SMTP id b19so9915835lji.11
 for <43086 <at> debbugs.gnu.org>; Fri, 04 Sep 2020 17:45:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=IluDPIU6rKGmhoN7sPWtYnIfhxG5v4LWAP9u3p8/FNM=;
 b=p8oOZyBjQhkCK9CnzwzrS+TzpEAKupodGNkqsOYb7HFfN7bt7KxU/EG4Pxr3KAAqS9
 5gEWh0WDMGmmBl6JJthd9LZXvbkGv4TA2fX3eJKwDMrBrLvS61F5rZpQVP6kCtqiI2ld
 dExc+9bJUDmyYKkzJM48hhIu+H1a369rbgVtWHIyrc3krNcFQC9V6JvZNf8C80zYWiHl
 SNQyV9qtryqOeyMHphylU9n9ePEp72RaOtPzRgp/BIRDGpIOksOwo4zln1WCzMRw9kx9
 goBsuoSL1zt6oIFsFUCkFNsKs6xVpldkfpGEpsVucoZTK/YorSNBrKSYFzX8k6PCjHB4
 Q/Tw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=IluDPIU6rKGmhoN7sPWtYnIfhxG5v4LWAP9u3p8/FNM=;
 b=oCwIK2jIV0d45xoIJFvDwdSGMkXbUwU+AtmPNGGOZyOw1LSBvZik6f+tnKWH7f7A7G
 OfFuyqMFO5qVuh6bJ0bWMUq9cNucUBmEmZlhICDHHuseGEaH9+jrWvOKUKMUIPq1nT8R
 H1lo/MEeJrfK0AL9cumUD4p8/8+2xS+Jdg8KjQcQbiSYFbePkYygQ+ayw1bYVPadwnYt
 3t80r03EMeuq2KMtqesD17AQ03UGFOTgV58Wd5D5p3unFaYLU5ENIRTHgLwKFnk8fqt5
 hV6VVe53+qehW2chb1J2XbppC9/Kxp2x9QpU1S9SBWzgOjfAEvh+2gggzy7AgaOTAWlf
 QWsA==
X-Gm-Message-State: AOAM531nsH3X00qgEGk0UQtgAd5NlGgKPtbfowSnA9RECpi8gLvEc3F4
 K49Pn/TAyFQ1L2gLNMVmaHprZ9uRmR0=
X-Google-Smtp-Source: ABdhPJzSm5Qyn4F6imKS2WiD+3r5m5QTXqqPV3niP7vB/L0lGETiDK2EE3lwvd9oeOavorsv2QKinQ==
X-Received: by 2002:a2e:2241:: with SMTP id i62mr5428791lji.265.1599266719378; 
 Fri, 04 Sep 2020 17:45:19 -0700 (PDT)
Received: from [192.168.0.104] ([94.229.108.16])
 by smtp.googlemail.com with ESMTPSA id x20sm1531628ljc.38.2020.09.04.17.45.18
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 04 Sep 2020 17:45:18 -0700 (PDT)
Subject: Re: bug#43086: [PATCH] Allow tags backend to not query for TAGS file
To: "Philip K." <philipk@HIDDEN>, 43086 <at> debbugs.gnu.org
References: <87k0xjue75.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <cfd9096b-6787-236e-7780-df2aa63a94d3@HIDDEN>
Date: Sat, 5 Sep 2020 03:45:17 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <87k0xjue75.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 3.7 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Hi! On 28.08.2020 15:50, Philip K. wrote: > the xref backend
 for etags can be annoying at times, especially in > combination with other
 backends. This patch should improve the > situation, by allowing the user
 to configure how and when the et [...] 
 Content analysis details:   (3.7 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (raaahh[at]gmail.com)
 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
 mail domains are different
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
 [94.229.108.16 listed in zen.spamhaus.org]
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [209.85.208.193 listed in wl.mailspike.net]
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [209.85.208.193 listed in list.dnswl.org]
 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
 EnvelopeFrom freemail headers are different
 -0.1 NICE_REPLY_A           Looks like a legit reply (A)
X-Debbugs-Envelope-To: 43086
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.7 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Hi! On 28.08.2020 15:50, Philip K. wrote: > the xref backend
    for etags can be annoying at times, especially in > combination with other
    backends. This patch should improve the > situation, by allowing the user
    to configure how and when the et [...] 
 
 Content analysis details:   (2.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
                             [209.85.208.193 listed in wl.mailspike.net]
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [209.85.208.193 listed in list.dnswl.org]
  3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
                             [94.229.108.16 listed in zen.spamhaus.org]
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (dgutov[at]yandex.ru)
  0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
                             mail domains are different
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager
  0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
                             EnvelopeFrom freemail headers are
                             different
 -0.1 NICE_REPLY_A           Looks like a legit reply (A)

Hi!

On 28.08.2020 15:50, Philip K. wrote:

> the xref backend for etags can be annoying at times, especially in
> combination with other backends. This patch should improve the
> situation, by allowing the user to configure how and when the etags
> backend is activated. The new user option etags-query-file would allow
> the backend to never query a TAGS file, or conditionally, depending on
> the existence of a TAGS file (in which case it can also be automatically
> loaded).

This is a interesting patch, but it calls for some discussion:

- The possible values all look pretty clever, but there are a lot of 
them! Do we expect them all to be in demand? Ideally, I'd only leave 2-3 
of them, to reduce the number of workflows we need to care about. The 
rest could probably be set up in individual user configurations in 
find-file-hook (like Projectile does).

- The variable name implies it affects how etags.el works globally, but 
the actual effect seems limited to the xref backend function. We should 
either rename it to something like etags-xref-query-file, or consider 
having it affect tags-completion-at-point-function as well. Maybe 
find-tag too. But given that tags-completion-at-point-function has for a 
long time behaved in the "never query" fashion, perhaps the easiest and 
most backward-compatible option is the former.

- One current persistent annoyance is that currently 
xref-find-references doesn't work well in many files where the xref 
backend is the default one (etags) when ido-mode or icomplete-mode are 
enabled because it prompts for the tags file to do identifier 
completion. I wonder if the "no query" option will help with this, too.

> I could imagine this might be extended to allow an auto-generate option,
> but that feature seems out of scope of this patch, and probably would
> require some interoperation with project.el.

Indeed. Actually, I have an old, WIP patch for tag file auto-generation 
which, yes, uses project.el. I can post it again if you're curious.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#43086; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 Aug 2020 12:50:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 28 08:50:51 2020
Received: from localhost ([127.0.0.1]:45468 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kBdqF-0004Uo-AP
	for submit <at> debbugs.gnu.org; Fri, 28 Aug 2020 08:50:51 -0400
Received: from lists.gnu.org ([209.51.188.17]:41920)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1kBdqB-0004Uc-IR
 for submit <at> debbugs.gnu.org; Fri, 28 Aug 2020 08:50:50 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42080)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philipk@HIDDEN>)
 id 1kBdqB-0006dG-6b
 for bug-gnu-emacs@HIDDEN; Fri, 28 Aug 2020 08:50:47 -0400
Received: from mout02.posteo.de ([185.67.36.66]:41395)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philipk@HIDDEN>)
 id 1kBdq7-00070u-PH
 for bug-gnu-emacs@HIDDEN; Fri, 28 Aug 2020 08:50:46 -0400
Received: from submission (posteo.de [89.146.220.130]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 770582400FE
 for <bug-gnu-emacs@HIDDEN>; Fri, 28 Aug 2020 14:50:40 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1598619040; bh=Uq73Ld46Rn2qmkaodImXFtCkzzSX2oK61+unup3UqvY=;
 h=From:To:Subject:Date:From;
 b=MqoNx1fb4Djm5f4K7WhqaG/kgy/bBDYWOa95maTzcYpndQVFdiKOSuXawZdTL3v72
 HiTLQQpTJMenPX8x0vGm7ERsg/oH+RdEkVf4uWCKyqgqRtY9ow/6F5O1v5qFObCppl
 5HO8rLNT3u/fF0RWlRajZieCjcNtD7XrFnGRacQCrxOhahksJFKZKJKReDW4SOhYAv
 TjRFQgQYmaTlOGQrVKcxV24FjJSfhscPjytU3NtQbCvtdWiwCtzu2jUHxF63MQMcD5
 QYCpzOBDFP5s97W0w7Tzivz+FB9DsktHB9yDSdlqSefxWNCNwuOyiazPzzviKVa5U5
 Ns7o2mSyC325g==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4BdKFq66fqz6tmZ
 for <bug-gnu-emacs@HIDDEN>; Fri, 28 Aug 2020 14:50:39 +0200 (CEST)
From: "Philip K." <philipk@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Allow tags backend to not query for TAGS file
Date: Fri, 28 Aug 2020 14:50:38 +0200
Message-ID: <87k0xjue75.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@HIDDEN;
 helo=mout02.posteo.de
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/28 08:27:43
X-ACL-Warn: Detected OS   = Linux 3.11 and newer
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain


Hi,

the xref backend for etags can be annoying at times, especially in
combination with other backends. This patch should improve the
situation, by allowing the user to configure how and when the etags
backend is activated. The new user option etags-query-file would allow
the backend to never query a TAGS file, or conditionally, depending on
the existence of a TAGS file (in which case it can also be automatically
loaded).

I could imagine this might be extended to allow an auto-generate option,
but that feature seems out of scope of this patch, and probably would
require some interoperation with project.el.

-- 
	Philip K.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Allow-tags-backend-to-not-query-for-TAGS-file.patch

From 6b141be5123d4cf37d743a9a12818442333658ed Mon Sep 17 00:00:00 2001
From: Philip K <philipk@HIDDEN>
Date: Fri, 28 Aug 2020 14:20:56 +0200
Subject: [PATCH] Allow tags backend to not query for TAGS file

* lisp/progmodes/etags.el (etags-query-file): Add variable
(etags--xref-backend): Respect etags-query-file
---
 lisp/progmodes/etags.el | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 2c5c36504a..60b162f19e 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2069,8 +2069,39 @@ etags-xref-find-definitions-tag-order
 If you want `xref-find-definitions' to find the tagged files by their
 file name, add `tag-partial-file-name-match-p' to the list value.")
 
+(defcustom etags-query-file t
+  "Specify how and when to query TAGS file.
+If t, always query if no tags file has been loaded.
+If `check', only query if a TAGS file exists.
+If `check-and-set', automatically set TAGS file if exists, and don't
+query otherwise.
+If `set-or-check', set TAGS file if exists, or query user if not.
+If nil, a new table can be loaded using `visit-tags-table'."
+  :type '(choice (const :tag "Always query" t)
+                 (const :tag "Never query" nil)
+                 (const :tag "Query if exists" check)
+                 (const :tag "Set if exists" check-and-set)
+                 (const :tag "Query if not exists" set-or-check))
+  :version "28.1")
+
 ;;;###autoload
-(defun etags--xref-backend () 'etags)
+(defun etags--xref-backend ()
+  (and (cond ((or (null etags-query-file)
+                  tags-table-computed-list))
+             ((eq etags-query-file 'check)
+              (locate-dominating-file default-directory "TAGS"))
+             ((eq etags-query-file 'check-and-set)
+              (let ((dir (locate-dominating-file default-directory "TAGS")))
+                (when dir
+                  (visit-tags-table dir)
+                  t)))
+             ((eq etags-query-file 'set-or-check)
+              (let ((dir (locate-dominating-file default-directory "TAGS")))
+                (when dir
+                  (visit-tags-table dir))
+                t))
+             (etags-query-file))
+       'etags))
 
 (cl-defmethod xref-backend-identifier-at-point ((_backend (eql etags)))
   (find-tag--default))
-- 
2.26.2


--=-=-=--




Acknowledgement sent to "Philip K." <philipk@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#43086; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 5 Sep 2020 01:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.