unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37611: [PATCH] Default FILE to the current buffer for list-tags
@ 2019-10-04  2:05 Hong Xu
  2019-10-04  7:59 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Hong Xu @ 2019-10-04  2:05 UTC (permalink / raw)
  To: 37611

* 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






^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-07  4:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04  2:05 bug#37611: [PATCH] Default FILE to the current buffer for list-tags Hong Xu
2019-10-04  7:59 ` Eli Zaretskii
2019-10-04 19:20   ` Hong Xu
2019-10-04 19:41     ` Eli Zaretskii
2019-10-05  0:38       ` Hong Xu
2019-10-07  4:03         ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).