aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHong Xu2019-10-07 06:03:21 +0200
committerLars Ingebrigtsen2019-10-07 06:03:21 +0200
commit273dd6542d96e09f90308187bac341ebaa0c770d (patch)
tree3fa76a9448b93e830ca60b14ea03cb4ad49ced47
parenta5a967b43dd2810635d7a06ea70510c4a8e5c10f (diff)
downloademacs-273dd6542d96e09f90308187bac341ebaa0c770d.tar.gz
emacs-273dd6542d96e09f90308187bac341ebaa0c770d.zip
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.
-rw-r--r--doc/emacs/maintaining.texi4
-rw-r--r--lisp/progmodes/etags.el25
2 files changed, 22 insertions, 7 deletions
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 9a9957069fd..519667dfbe9 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -2124,7 +2124,9 @@ the selected tags table, and displays a list of tags defined in that
2124file. Do not include a directory as part of the file name unless the 2124file. Do not include a directory as part of the file name unless the
2125file name recorded in the tags table includes a directory. This 2125file name recorded in the tags table includes a directory. This
2126command works only with the etags backend, and requires a tags table 2126command works only with the etags backend, and requires a tags table
2127for the project to be available. @xref{Tags Tables}. 2127for the project to be available. @xref{Tags Tables}. If used
2128interactively, the default tag is file name of the current buffer if
2129used interactively.
2128 2130
2129@c Sadly, the new-and-improved Xref feature doesn't provide anything 2131@c Sadly, the new-and-improved Xref feature doesn't provide anything
2130@c close to the described below features of the now-obsoleted 2132@c close to the described below features of the now-obsoleted
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'."
1852 (all-completions string (tags-table-files) predicate) 1852 (all-completions string (tags-table-files) predicate)
1853 (try-completion string (tags-table-files) predicate)))) 1853 (try-completion string (tags-table-files) predicate))))
1854 1854
1855(defun tags--get-current-buffer-name-in-tags-file ()
1856 "Get the file name that the current buffer corresponds in the tags file."
1857 (let ((tag-dir
1858 (save-excursion
1859 (visit-tags-table-buffer)
1860 (file-name-directory (buffer-file-name)))))
1861 (file-relative-name (buffer-file-name) tag-dir)))
1862
1855;;;###autoload 1863;;;###autoload
1856(defun list-tags (file &optional _next-match) 1864(defun list-tags (file &optional _next-match)
1857 "Display list of tags in file FILE. 1865 "Display list of tags in file FILE.
1858This searches only the first table in the list, and no included tables. 1866This searches only the first table in the list, and no included
1859FILE should be as it appeared in the `etags' command, usually without a 1867tables. FILE should be as it appeared in the `etags' command,
1860directory specification." 1868usually without a directory specification. If called
1861 (interactive (list (completing-read "List tags in file: " 1869interactively, FILE defaults to the file name of the current
1862 'tags-complete-tags-table-file 1870buffer."
1863 nil t nil))) 1871 (interactive (list (completing-read
1872 "List tags in file: "
1873 'tags-complete-tags-table-file
1874 nil t
1875 ;; Default FILE to the current buffer.
1876 (tags--get-current-buffer-name-in-tags-file))))
1864 (with-output-to-temp-buffer "*Tags List*" 1877 (with-output-to-temp-buffer "*Tags List*"
1865 (princ (substitute-command-keys "Tags in file `")) 1878 (princ (substitute-command-keys "Tags in file `"))
1866 (tags-with-face 'highlight (princ file)) 1879 (tags-with-face 'highlight (princ file))