summaryrefslogtreecommitdiff
path: root/lisp/progmodes/etags.el
diff options
context:
space:
mode:
authorHong Xu <hong@topbug.net>2019-10-07 06:03:21 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-10-07 06:03:21 +0200
commit273dd6542d96e09f90308187bac341ebaa0c770d (patch)
tree3fa76a9448b93e830ca60b14ea03cb4ad49ced47 /lisp/progmodes/etags.el
parenta5a967b43dd2810635d7a06ea70510c4a8e5c10f (diff)
downloademacs-273dd6542d96e09f90308187bac341ebaa0c770d.tar.gz
Default FILE to the current buffer for list-tags
* doc/emacs/maintaining.texi (List Identifiers): Update `list-tags' doc (bug#37611). * lisp/progmodes/etags.el (list-tags) (tags--get-current-buffer-name-in-tags-file): Default FILE to the current buffer for list-tags.
Diffstat (limited to 'lisp/progmodes/etags.el')
-rw-r--r--lisp/progmodes/etags.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index a0351610008..5edced5080e 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -1852,15 +1852,28 @@ For non-interactive use, superceded by `fileloop-initialize-replace'."
(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))