GNU bug report logs - #37611
[PATCH] Default FILE to the current buffer for list-tags

Previous Next

Package: emacs;

Reported by: Hong Xu <hong <at> topbug.net>

Date: Fri, 4 Oct 2019 02:06:03 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37611 in the body.
You can then email your comments to 37611 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37611; Package emacs. (Fri, 04 Oct 2019 02:06:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Hong Xu <hong <at> topbug.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 04 Oct 2019 02:06:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Hong Xu <hong <at> topbug.net>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: [PATCH] Default FILE to the current buffer for list-tags
Date: Thu, 3 Oct 2019 19:05:08 -0700
* lisp/progmodes/etags.el (list-tags)
(tags--get-current-buffer-name-in-tags-file): Default FILE to the
current buffer for list-tags.
---
 lisp/progmodes/etags.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index a03516100087..23acffcac299 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -1852,15 +1852,27 @@ 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)))))
+    (when (string-prefix-p tag-dir (buffer-file-name))
+      (substring (buffer-file-name) (length tag-dir) nil))))
+
 ;;;###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)))
+  (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.18.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37611; Package emacs. (Fri, 04 Oct 2019 08:00:05 GMT) Full text and rfc822 format available.

Message #8 received at 37611 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Hong Xu <hong <at> topbug.net>
Cc: 37611 <at> debbugs.gnu.org
Subject: Re: bug#37611: [PATCH] Default FILE to the current buffer for
 list-tags
Date: Fri, 04 Oct 2019 10:59:02 +0300
> From: Hong Xu <hong <at> topbug.net>
> Date: Thu, 3 Oct 2019 19:05:08 -0700
> 
> * lisp/progmodes/etags.el (list-tags)
> (tags--get-current-buffer-name-in-tags-file): Default FILE to the
> current buffer for list-tags.
> ---
>   lisp/progmodes/etags.el | 18 +++++++++++++++---
>   1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
> index a03516100087..23acffcac299 100644
> --- a/lisp/progmodes/etags.el
> +++ b/lisp/progmodes/etags.el
> @@ -1852,15 +1852,27 @@ 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."

Thanks.  The doc string of list-tags needs an update as result of
this, and also its documentation in the user manual.

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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37611; Package emacs. (Fri, 04 Oct 2019 19:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 37611 <at> debbugs.gnu.org (full text, mbox):

From: Hong Xu <hong <at> topbug.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 37611 <at> debbugs.gnu.org
Subject: Re: bug#37611: [PATCH] Default FILE to the current buffer for
 list-tags
Date: Fri, 4 Oct 2019 12:20:46 -0700
On 10/4/19 12:59 AM, Eli Zaretskii wrote:
> Thanks.  The doc string of list-tags needs an update as result of
> this, and also its documentation in the user manual.

I will update the doc.

> 
> 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.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37611; Package emacs. (Fri, 04 Oct 2019 19:43:02 GMT) Full text and rfc822 format available.

Message #14 received at 37611 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Hong Xu <hong <at> topbug.net>
Cc: 37611 <at> debbugs.gnu.org
Subject: Re: bug#37611: [PATCH] Default FILE to the current buffer for
 list-tags
Date: Fri, 04 Oct 2019 22:41:51 +0300
> Cc: 37611 <at> debbugs.gnu.org
> From: Hong Xu <hong <at> topbug.net>
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37611; Package emacs. (Sat, 05 Oct 2019 00:39:02 GMT) Full text and rfc822 format available.

Message #17 received at 37611 <at> debbugs.gnu.org (full text, mbox):

From: Hong Xu <hong <at> topbug.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 37611 <at> debbugs.gnu.org
Subject: Re: bug#37611: [PATCH] Default FILE to the current buffer for
 list-tags
Date: Fri, 4 Oct 2019 17:38:22 -0700
[Message part 1 (text/plain, inline)]
On 10/4/19 12:41 PM, Eli Zaretskii wrote:
>> Cc: 37611 <at> debbugs.gnu.org
>> From: Hong Xu <hong <at> topbug.net>
>> 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.
[0001-Default-FILE-to-the-current-buffer-for-list-tags.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37611; Package emacs. (Mon, 07 Oct 2019 04:05:02 GMT) Full text and rfc822 format available.

Message #20 received at 37611 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Hong Xu <hong <at> topbug.net>
Cc: 37611 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#37611: [PATCH] Default FILE to the current buffer for
 list-tags
Date: Mon, 07 Oct 2019 06:03:59 +0200
Hong Xu <hong <at> topbug.net> writes:

> 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.

Looks good to me, so I've now applied it to Emacs 27.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Oct 2019 04:05:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 37611 <at> debbugs.gnu.org and Hong Xu <hong <at> topbug.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Oct 2019 04:05:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 04 Nov 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 222 days ago.

Previous Next


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