简体   繁体   English

如何在组织模式中使用更简单的链接语法?

[英]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 .我希望使用语法[[foo bar]]转到名称为foo bar.org文件。 This would make using org-mode much more like using a personal local wiki.这将使使用 org-mode 更像是使用个人本地 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.理想情况下,我还可以使用标准的组织模式工具导出到 html 等。

The best I've been able to do is something like: (setq org-link-abbrev-alist '(("o" . "file:%s.org")))我能做的最好的是: (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.这让我可以使用语法[[o:foo bar]] ,但这更冗长,而且看起来令人分心的内联丑陋。 For example: The quick brown o:fox jumps over the o:lazy_dog .例如: 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). [[o:foo bar][foo bar]]在输入和编辑时更加冗长(尽管它在 org 模式下读起来很好)。

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.我没有现成的解决方案,也不是程序员,但这部分在org.el是自我记录的,您可以编写专用的链接搜索功能。 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.如果它决定不处理这个搜索,它应该只返回 nil 给其他函数一个机会。 If it does handle the search, it must return a non-nil value to keep other functions from trying.如果它确实处​​理了搜索,它必须返回一个非 nil 值以防止其他函数尝试。

Each function can access the current prefix argument through the variable `current-prefix-arg'.每个函数都可以通过变量“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.请注意,在 Emacs 中使用单个前缀来强制打开链接,因此最好仅使用数字或双前缀来引导搜索功能。

In case this is needed, a function in this hook can also restore the window configuration before `org-open-at-point' was called using:如果需要,此钩子中的函数还可以使用以下命令在调用 `org-open-at-point' 之前恢复窗口配置:

(set-window-configuration org-window-config-before-follow-link)") (设置窗口配置 org-window-config-before-follow-link)")

See also Hyperlinks :: Custom Searches @ gnu.org另请参阅超链接 :: 自定义搜索 @ gnu.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM