diff options
| author | Hong Xu | 2019-10-07 06:03:21 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-07 06:03:21 +0200 |
| commit | 273dd6542d96e09f90308187bac341ebaa0c770d (patch) | |
| tree | 3fa76a9448b93e830ca60b14ea03cb4ad49ced47 | |
| parent | a5a967b43dd2810635d7a06ea70510c4a8e5c10f (diff) | |
| download | emacs-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.texi | 4 | ||||
| -rw-r--r-- | 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 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 | |||
| 2124 | file. Do not include a directory as part of the file name unless the | 2124 | file. Do not include a directory as part of the file name unless the |
| 2125 | file name recorded in the tags table includes a directory. This | 2125 | file name recorded in the tags table includes a directory. This |
| 2126 | command works only with the etags backend, and requires a tags table | 2126 | command works only with the etags backend, and requires a tags table |
| 2127 | for the project to be available. @xref{Tags Tables}. | 2127 | for the project to be available. @xref{Tags Tables}. If used |
| 2128 | interactively, the default tag is file name of the current buffer if | ||
| 2129 | used 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. |
| 1858 | This searches only the first table in the list, and no included tables. | 1866 | This searches only the first table in the list, and no included |
| 1859 | FILE should be as it appeared in the `etags' command, usually without a | 1867 | tables. FILE should be as it appeared in the `etags' command, |
| 1860 | directory specification." | 1868 | usually without a directory specification. If called |
| 1861 | (interactive (list (completing-read "List tags in file: " | 1869 | interactively, FILE defaults to the file name of the current |
| 1862 | 'tags-complete-tags-table-file | 1870 | buffer." |
| 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)) |