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).