From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#67687: Feature request: automatic tags management Date: Tue, 2 Jan 2024 03:40:05 +0200 Message-ID: <28e6ee3f-d09b-4350-a01a-29fd268ce8ce@gutov.dev> References: <58D84A29-9A63-45BA-AD8B-B476CDC931A1@gmail.com> <812729c8-726f-d60e-2603-2d8e588929fd@gutov.dev> <835y0sgg12.fsf@gnu.org> <979cf9e0-4d08-4c39-b5c8-11b0bb8801b4@gutov.dev> <83v88e3moc.fsf@gnu.org> <835y0e2ui8.fsf@gnu.org> <95132856-65b0-4812-a124-52e0da674330@gutov.dev> <8334vi2mwo.fsf@gnu.org> <801f2f8a-a39b-493f-a24f-0613a3c7ca57@gutov.dev> <83ttnx1clj.fsf@gnu.org> <2198a45c-e94b-47d6-9815-125d8f505f18@gutov.dev> <83il4d0zhh.fsf@gnu.org> <7361089b-a473-4770-9637-db5855e07aee@gutov.dev> <83frzh0x8b.fsf@gnu.org> <285175f0-24f1-46c5-8559-8d52b1b30b76@gutov.dev> <83edf026vk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15189"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 67687@debbugs.gnu.org, eskinjp@gmail.com, michael.albinus@gmx.de, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 02 02:41:57 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rKTn2-0003iB-JO for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jan 2024 02:41:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKTmE-0008No-GE; Mon, 01 Jan 2024 20:41:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKTmC-0008NR-3A for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2024 20:41:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKTm8-0005T1-8B for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2024 20:41:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rKTm9-0005F1-Tp for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2024 20:41:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Jan 2024 01:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67687 X-GNU-PR-Package: emacs Original-Received: via spool by 67687-submit@debbugs.gnu.org id=B67687.170415961820080 (code B ref 67687); Tue, 02 Jan 2024 01:41:01 +0000 Original-Received: (at 67687) by debbugs.gnu.org; 2 Jan 2024 01:40:18 +0000 Original-Received: from localhost ([127.0.0.1]:49066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rKTlS-0005Do-7C for submit@debbugs.gnu.org; Mon, 01 Jan 2024 20:40:18 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:48939) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rKTlP-0005DY-O8 for 67687@debbugs.gnu.org; Mon, 01 Jan 2024 20:40:16 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 78F9F5C0144; Mon, 1 Jan 2024 20:40:08 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 01 Jan 2024 20:40:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1704159608; x=1704246008; bh=3vW/FsGGa1iOMA4bzPgCmUAV7HAiTEa8CU9C2Vk+VzQ=; b= A6e49/jbJAsk5xA5wlzmRgq8MQ8H0ljTQ1vVEiN36BnShZxzqHbsK662w21GRico CvDCeTovtsbFVl8SeqtNkJf2krmN7aN5VweoMhYawtDCWwrvcsznGyac5uBSMq3M ouvlLc5NUVyPyH4sGN4LlepWgrmuT5fqbn2/+q5i1t8nvHxQh/0wZL7SOG7fsEtN pUztT6Jwp+OByRX+4DJlhMVfHK5sSMFdx6NeHrtdhEnnZ0QBApUv5DYM33mJrivF PEnnjbZNlVPK/Owjszezm1+SEI/lAp6naH9DIViiRBhpWl6/3iYmJVqRdgEj4P4t yKwNPwpgaXg1fI1NR4DHaA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1704159608; x= 1704246008; bh=3vW/FsGGa1iOMA4bzPgCmUAV7HAiTEa8CU9C2Vk+VzQ=; b=z OJBvsiF8HyxIgx8Smh6Ar6HV+NbVrDG42JIKBvPk65Q2tDJ2Oemb73x4sgpIsxZK Jm44Bk+ftXNID2ENm7PUb3J3cZaGYa9mLsKG91oqXNuaznj8f8+Z5F+RY+Tmt3KS Owkc5Roiv3tOZmWC2iEniCtIgXIEVaEWtGfSJYETX5HXSxtPnaTcndoh95wZuvkn Jkfh0Zvd1Dul1ALe6hrd2xCh8O94xAGCD6/o2Pe21ZkV132TJHOAOvYqqbsvPiQs x+SovUtrCN4kmGQ7HLSiwQS0Bzvm+Hv+75WEWEAPVbit2j10Giwb6IhIeE6JRmgr U1woTkY+CAIK6ShcGTYZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeguddgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedu jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Jan 2024 20:40:06 -0500 (EST) Content-Language: en-US In-Reply-To: <83edf026vk.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277205 Archived-At: On 01/01/2024 21:25, Eli Zaretskii wrote: >> Date: Mon, 1 Jan 2024 20:48:37 +0200 >> Cc: stefankangas@gmail.com, eskinjp@gmail.com, 67687@debbugs.gnu.org, >> michael.albinus@gmx.de >> From: Dmitry Gutov >> >> On 01/01/2024 19:39, Eli Zaretskii wrote: >>>> Date: Mon, 1 Jan 2024 19:23:28 +0200 >>>> Cc: stefankangas@gmail.com, eskinjp@gmail.com, 67687@debbugs.gnu.org, >>>> michael.albinus@gmx.de >>>> From: Dmitry Gutov >>>> >>>> On 01/01/2024 18:50, Eli Zaretskii wrote: >>>>>> +The exception is made when the user has already selected a tags >>>>>> +table manually (for example, using \\[visit-tags-table]). Then >>>>>> +this mode doesn't do anything. Reset the visited tags tables >>>>>> +using \\[tags-reset-tags-tables]." >>>>> >>>>> The above is only true for the project whose TAGS was manually >>>>> visited, right? IOW, it's not that once the use invokes >>>>> visit-tags-table once, this mode will be effectively disabled for the >>>>> entire session, right? >>>> >>>> No, it's the latter. It's off for the whole session, just like a visited >>>> TAGS file is active for the whole session (not limited to any specific >>>> project). >>> >>> OK, then please tweak my suggested text to explain the situation >>> correctly instead. >> >> How about this? >> >> If you select a tags table manually (for example, using >> \\[visit-tags-table]), then this mode will be effectively >> disabled for the entire session. Use \\[tags-reset-tags-tables] >> to countermand the effect of a previous \\[visit-tags-table]. > > SGTM, thanks. All right. I think I'll wait a days or two for any more comments and then install the feature. >> (defun project-visit-tags () >> (let* ((pr (project-current)) >> (tags-file (and pr >> (expand-file-name "TAGS" (project-root pr))))) >> (and tags-file >> (file-exists-p tags-file) >> (visit-tags-table tags-file t)))) >> >> (add-hook 'find-file-hook #'project-visit-tags) > > This could work, but IMO it would be more elegant to avoid use of > find-file-hook, and instead have some data structure that maps > projects or directories to tags table files. Looking into it, the variable default-tags-table-function seemed like it could work for this purpose, with settings like this: (defun my/project-default-tags-table () (let* ((pr (project-current)) (tags-file (and pr (expand-file-name "TAGS" (project-root pr))))) (and tags-file (file-exists-p tags-file) tags-file))) (setq tags-table-list '("~/vc/emacs-master/") ; List with all your projects default-tags-table-function #'my/project-default-tags-table) But alas it only changes which table is used first for finding a definition (before all others are tried), and all completions are collected from all completion tables in a global variable (tags-completion-table). So there is more work to be done to support simultaneously loaded independent tags tables. The new user option could look like this one, but it would also be used for the case of CONT=t, and tags-completion-table would need to be set buffer-locally in tags table buffers. Note that etags-regen-mode switches between the tables automatically already, so this would be orthogonal functionality at best. Though hopefully compatible, and something that'd help avoid rescanning the completions table when switching between projects.