Emacs主题标签(#tagsLikeThisOne)自动完成

时间:2013-11-14 15:31:55

标签: emacs autocomplete hashtag

我标签指出,当我阅读书籍,文章等时,我会使用Emacs - 人文学科。我想知道Emacs是否可以自动构建我输入的主题标签列表(可能在单独的文件中)?此外,当我开始输入主题标签时,Emacs(从这个假设列表中读取)可以提供增量(或标签)自动完成功能。我需要此功能才能获得一致的标记。

感谢名单!

2 个答案:

答案 0 :(得分:0)

另一种选择:你可以书签这样的笔记。如果您使用Bookmark+,则可以tag bookmarks

您可以为书签使用任意数量的标签,标签可以是任何字符串(它们甚至可以具有关联的Lisp值)。默认情况下,书签(标记或不标记)在书签文本中不可见。但是(使用Bookmark +)您可以通过各种方式突出显示它们。

答案 1 :(得分:0)

您可以使用Exuberant ctags生成TAGS文件。例如,如果您的笔记处于组织模式,则可以执行以下操作:

(require 'org-ctags)
(setq org-ctags-path-to-ctags "/path/to/ctags")

;; Regular expression for the hashtags.
;; Nnote that this would remove the existing definition and effectively disable 
;; the standard use of org-ctags which is to tag <<links>>. If you want to preserve old
;; behavior you need to combine the two regexes.
(setq org-ctags-tag-regexp "/(#[^+]+)/\\1/d,definition/")

(org-ctags-create-tags "directory")

现在,您可以使用org-ctags-find-tag-interactive搜索声称具有自动完成功能的代码:

(add-hook 'org-mode-hook
    (lambda ()
      (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive)))

但我更喜欢Helm完成,所以我只做M-x helm-etags-select。您也可以忽略org-ctags并自己构建TAGS:

 ctags --langdef=orgmode --langmap=orgmode:.org
       --regex-orgmode="/(#[^+]+)/\1/d,definition/"
       -f /your/path/TAGS -e -R /your/path/*.org

(或创建一个方便的emacs功能,为您做到这一点)。