Вопрос

I hashtag notes that I take with Emacs while I read books, articles, etc - humanities, mostly. I would like to know if Emacs can automatically build a list of hashtags that I enter (in a separate file, probably)? Also, can Emacs - reading from this hypothetical list - offer an incremental (or tab) autocompletion when I start to type the hashtag. I need this feature in order to have a consistent tagging.

Thanx!

Это было полезно?

Решение

You can use the Exuberant ctags to generate the TAGS file. For instance, if your notes are in Org mode, you can do this:

(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")

Now you can use org-ctags-find-tag-interactive to search the tags which claims to have autocompletion:

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

but I prefer Helm completion, so I just do M-x helm-etags-select. You can also ignore the org-ctags and build the TAGS yourself:

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

(or create a convenience emacs function that does that for you).

Другие советы

An alternative: You can bookmark such notes. And if you use Bookmark+ then you can tag bookmarks.

You can use as many tags as you like for a bookmark, and the tags can be any strings (they can even have associated Lisp values). Bookmarks (tagged or not) are not visible in the bookmarked text, by default. But (with Bookmark+) you can have them be highlighted in various ways.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top