So I'm trying to make an "autolinks mode" to emulate the functionality of notetaking software like Tomboy Notes or notes.vim, which automatically linkifies any text that happens to be the title of a note. But I'm totally new to Emacs and to Elisp. This is what I have so far (it's like the first elisp I've ever written, be gentle):
;; Set directory of files to search for *.org files (setq autolinks-mode-dir "~/Dropbox/Org/") ;; Get all .org files in this directory. (setq autolinks-mode-files (directory-files autolinks-mode-dir t "[.]org\\'")) ;; Convert it to a list of just the filenames, without paths. (setq autolinks-mode-files-bare (mapcar 'file-name-nondirectory autolinks-mode-files)) ;; Strip extensions (setq autolinks-mode-topics (mapcar 'file-name-sans-extension autolinks-mode-files-bare))
So far, so good. Now I I have a list of topics, and a list of corresponding files. For example, the topic "James" corresponds to an org file at "/path/to/notes/James.org". Now I want to manually update org's list of links for a particular buffer with this list of topics, so that, when I turn on this mode, it highlights any instance of the word "James" in an org buffer and makes it a link to
/path/to/notes/James.org. Same with a multi-word org file, like "Henry James", which would point to
/path/to/notes/Henry James.org. Note that I'm not trying to replace all instances of
<James> or something, just trying to get those text snippets to behave as links.
I've been browsing through org.el, and I saw this variable:
(defvar org-link-re-with-space nil "Matches a link with spaces, optional angular brackets around it.")
Which in my system has all kinds of stuff in it, probably due to org-ref and other things:
So it seems Org has the functionality to be able to highlight plain text as a link. I just don't know the best way to do it. I think I can append my list of link words to
org-link-re-with-space, maybe? But then how do I set their targets? Any help would be much appreciated.