有没有办法从标签表列表中定义的文件中获取所有标签?我已经像这样设置了我的标签文件:
(setq tags-table-list '("~/project/TAGS"))
我试过(tags-completion-table)
了,但它不包含所有标签。
如果您只有一个 TAGS 文件,M-x visit-tags-table
~/project/TAGS
或者(visit-tags-table "~/project/TAGS")
应该将 TAGS 表加载到缓冲区中,这意味着 Emacs 可以像使用它一样访问它,M-x tags-search
.
如果您在项目中添加了多个 TAGS 文件或拥有多个项目,(setq tags-table-list '("~/project1/TAGS" "~/Project2/TAGS" ...))
并且(visit-tags-table-buffer t)
每次调用时都应该访问下一个表,直到列表末尾。
编辑:
(defvar buffer-in-string)
(defvar string-list)
(defun write-buffer-to-string ()
(interactive)
(setq buffer-in-string (buffer-substring (point-min) (point-max)))
(kill-buffer) ;; If the buffer is big, it makes sense to kill it,
;; since its contents are copied into the string anyway
(setq string-list (split-string buffer-in-string " "))
)
那应该将缓冲区变成一个字符串。应该有更优雅的方式,但目前,这是我用我非常有限的 elisp 流畅度所能写的最多的。
函数tags-completion-table
为您提供了一个完成表以供使用。从文档字符串:
Build 'tags-completion-table' on demand.
The tags included in the completion table are those in the current
tags table and its (recursively) included tags tables.
并tags-lazy-completion-table
给你一个补全功能来使用。它使用tags-completion-table
.