From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hong Xu Newsgroups: gmane.emacs.bugs Subject: bug#37611: [PATCH] Default FILE to the current buffer for list-tags Date: Fri, 4 Oct 2019 17:38:22 -0700 Message-ID: <6014109a-f6ac-f0de-1a46-c0e420e313d5@topbug.net> References: <83v9t554c9.fsf@gnu.org> <831d1916-8c3b-70e2-3a94-3259a911e5e8@topbug.net> <83bluw5mdc.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------581AE9C6C77B98C1B6AF1BAD" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="33892"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: 37611@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 05 02:39:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iGY6K-0008g3-Jh for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Oct 2019 02:39:12 +0200 Original-Received: from localhost ([::1]:53830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGY6I-0002qV-Sy for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Oct 2019 20:39:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56748) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGY6B-0002qP-P6 for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2019 20:39:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGY6A-0001El-Ik for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2019 20:39:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34769) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGY6A-0001Ec-Fd for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2019 20:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iGY6A-00087b-6Z for bug-gnu-emacs@gnu.org; Fri, 04 Oct 2019 20:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Hong Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Oct 2019 00:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37611 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 37611-submit@debbugs.gnu.org id=B37611.157023591331179 (code B ref 37611); Sat, 05 Oct 2019 00:39:02 +0000 Original-Received: (at 37611) by debbugs.gnu.org; 5 Oct 2019 00:38:33 +0000 Original-Received: from localhost ([127.0.0.1]:43590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iGY5h-00086o-9F for submit@debbugs.gnu.org; Fri, 04 Oct 2019 20:38:33 -0400 Original-Received: from sender4-of-o55.zoho.com ([136.143.188.55]:21522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iGY5f-00086g-AT for 37611@debbugs.gnu.org; Fri, 04 Oct 2019 20:38:31 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1570235903; cv=none; d=zoho.com; s=zohoarc; b=DIZ8b3uT9YptNcEi4lAbSg4EfrgXmZE0A+XDE6p4aW66V9Cy0l8DGl/KC8dDMa7herJG38XzO1yLHdk/oX11aSw1Pvp8STBDK8HGKWGKOnIY/OjXl8IerihHgArcVh46SmD4visxxK8ghLFyANAoLfjPaKRdiyP7v7Zcoz1u4Bw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570235903; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=JxJQkqRdxjJt+8stryOwaMrTxrDjDjU4E9BbR9QYtE8=; b=eqXO42tE0o0H2qJUFg/4lO2UkuEeshpzq756aEJFaQunehZUqGKTHYmQ5hlDg0e9NhtVNCMV66H8X9E69p11QzYRt+/3YGYD2M1rbItoUrMJA+ZGas5GUgvkD5srh4YxCnPz2ON8+QfAq/Ase+9U6CONGorKcPqccOnMCfJ3Gko= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=topbug.net; spf=pass smtp.mailfrom=hong@topbug.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1570235903; s=zoho; d=topbug.net; i=hong@topbug.net; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type; l=4435; bh=JxJQkqRdxjJt+8stryOwaMrTxrDjDjU4E9BbR9QYtE8=; b=KTrs6prI0gkSz8idtnPi9IuyZhIZtbo5jm6gl5E+erIoqx9dO0HQalNrZVM9HDA+ sTIidZSu8O/IT9RBlZVvQAruEwuWcIqp6cNUsS1oWfk7D30gu2+vKHttZHgNWirH8t4 tmkPQCBHoK5ckoZMvnANctnxXx0l1deS9ErNCpFg= Original-Received: from [192.168.88.88] (69-215-149-151.lightspeed.sntcca.sbcglobal.net [69.215.149.151]) by mx.zohomail.com with SMTPS id 157023590278347.69453543965062; Fri, 4 Oct 2019 17:38:22 -0700 (PDT) Openpgp: preference=signencrypt In-Reply-To: <83bluw5mdc.fsf@gnu.org> Content-Language: en-US X-Zoho-Virus-Status: 1 X-ZohoMailClient: External 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: 209.51.188.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:168348 Archived-At: This is a multi-part message in MIME format. --------------581AE9C6C77B98C1B6AF1BAD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 10/4/19 12:41 PM, Eli Zaretskii wrote: >> Cc: 37611@debbugs.gnu.org >> From: Hong Xu >> Date: Fri, 4 Oct 2019 12:20:46 -0700 >> >>> Did you try this in the Emacs source tree? We use the TAGS 'include' >>> facility to include various TAGS files in a single master file. This >>> seems to get in the way when you invoke this command from a Lisp file, >>> because list-tags only recognizes one of the C source files as >>> completion candidates. What does this do with your changes? >>> >> >> I tried in the Emacs source tree without problem (I ran universal ctags, "ctags -R -e ." from root of the source tree). How do you generate the TAGS file? Is there any instruction? I can take a look at it. > > I use "make TAGS", of course. > I updated the patch (as attached) so that it now works with the TAGS generated using `make TAGS` and also includes missing updates to docstring and info nodes. --------------581AE9C6C77B98C1B6AF1BAD Content-Type: text/x-patch; name="0001-Default-FILE-to-the-current-buffer-for-list-tags.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Default-FILE-to-the-current-buffer-for-list-tags.patch" >From a806553186635aeb0e7763490e41b0ac68e602c4 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Thu, 3 Oct 2019 16:36:54 -0700 Subject: [PATCH] Default FILE to the current buffer for list-tags * lisp/progmodes/etags.el (list-tags) (tags--get-current-buffer-name-in-tags-file): Default FILE to the current buffer for list-tags. * doc/emacs/maintaining.texi (List Identifiers): Update `list-tags' doc. --- doc/emacs/maintaining.texi | 4 +++- lisp/progmodes/etags.el | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 9a9957069fd6..519667dfbe92 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -2124,7 +2124,9 @@ List Identifiers file. Do not include a directory as part of the file name unless the file name recorded in the tags table includes a directory. This command works only with the etags backend, and requires a tags table -for the project to be available. @xref{Tags Tables}. +for the project to be available. @xref{Tags Tables}. If used +interactively, the default tag is file name of the current buffer if +used interactively. @c Sadly, the new-and-improved Xref feature doesn't provide anything @c close to the described below features of the now-obsoleted diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index a03516100087..5edced5080e2 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -1852,15 +1852,28 @@ tags-complete-tags-table-file (all-completions string (tags-table-files) predicate) (try-completion string (tags-table-files) predicate)))) +(defun tags--get-current-buffer-name-in-tags-file () + "Get the file name that the current buffer corresponds in the tags file." + (let ((tag-dir + (save-excursion + (visit-tags-table-buffer) + (file-name-directory (buffer-file-name))))) + (file-relative-name (buffer-file-name) tag-dir))) + ;;;###autoload (defun list-tags (file &optional _next-match) "Display list of tags in file FILE. -This searches only the first table in the list, and no included tables. -FILE should be as it appeared in the `etags' command, usually without a -directory specification." - (interactive (list (completing-read "List tags in file: " - 'tags-complete-tags-table-file - nil t nil))) +This searches only the first table in the list, and no included +tables. FILE should be as it appeared in the `etags' command, +usually without a directory specification. If called +interactively, FILE defaults to the file name of the current +buffer." + (interactive (list (completing-read + "List tags in file: " + 'tags-complete-tags-table-file + nil t + ;; Default FILE to the current buffer. + (tags--get-current-buffer-name-in-tags-file)))) (with-output-to-temp-buffer "*Tags List*" (princ (substitute-command-keys "Tags in file `")) (tags-with-face 'highlight (princ file)) -- 2.20.1 --------------581AE9C6C77B98C1B6AF1BAD--