Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use a simpler link syntax in org-mode?

I'd like to have links with the syntax [[foo bar]] go to files with the name foo bar.org. This would make using org-mode much more like using a personal local wiki.

Is this possible without breaking existing link functionality? I'd also ideally still be able to export to html, etc. with standard org-mode tools.

The best I've been able to do is something like: (setq org-link-abbrev-alist '(("o" . "file:%s.org")))

This lets me use the syntax [[o:foo bar]], but that is more verbose, and looks distractingly ugly inline. For example: The quick brown o:fox jumps over the o:lazy_dog. And [[o:foo bar][foo bar]] is even more verbose to type and edit (though it reads fine in org mode).

like image 370
avv Avatar asked Nov 02 '22 07:11

avv


1 Answers

I don't have a ready made solution and am not a programmer, but this part is self-documenting in org.el, you can write a dedicated link search function. I cite:

"List of functions to execute a file search triggered by a link.

Functions added to this hook must accept a single argument, the search string that was part of the file link, the part after the double colon. The function must first check if it would like to handle this search, for example by checking the `major-mode' or the file extension. If it decides not to handle this search, it should just return nil to give other functions a chance. If it does handle the search, it must return a non-nil value to keep other functions from trying.

Each function can access the current prefix argument through the variable `current-prefix-arg'. Note that a single prefix is used to force opening a link in Emacs, so it may be good to only use a numeric or double prefix to guide the search function.

In case this is needed, a function in this hook can also restore the window configuration before `org-open-at-point' was called using:

(set-window-configuration org-window-config-before-follow-link)")

See also Hyperlinks :: Custom Searches @ gnu.org

like image 121
TNT Avatar answered Nov 28 '22 23:11

TNT