0

我正在尝试找到一种在 org-mode 中添加可点击链接的方法,该链接会打开另一个本地文件并滚动到特定的属性 ID。

用一个例子更容易解释:

$ cat file1.org
* org links that I've tried and they don't work properly

[[file:path/to/another-file.org::#d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
[[file:path/to/another-file.org:id:d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
[[file:path/to/another-file.org::d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
[[file:path/to/another-file.org::id:d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
$ cat another-file.org

* Top category

** Category X

*** Question :drill:
    :PROPERTIES:
    :ID:       d89ba6bd-7c9a-4559-9965-7a6541f1a7c5
    :END:

Content of d89ba6bd-7c9a-4559-9965-7a6541f1a7c5 entry

*** Question :drill:
    :PROPERTIES:
    :ID:       some-other-property-uuid
    :END:

Content of some-other-property-uuid entry

不幸的是,我无法更改 another-file.org 的结构。我只能使用属性 ID 进行引用。

只是重命名“问题:drill:”会容易得多,但它会重复很多次,正如我所说的那样,它不可用于更新。


更新:

使用“CUSTOM_ID”属性,它似乎正在工作

*** Question :drill:
    :PROPERTIES:
    :CUSTOM_ID:       d89ba6bd-7c9a-4559-9965-7a6541f1a7c5
    :END:

Content of d89ba6bd-7c9a-4559-9965-7a6541f1a7c5 entry
[[file:path/to/another-file.org::#d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]

但是有什么方法可以使用默认:ID:属性来实现吗?

4

1 回答 1

1

尝试设置org-link-search-must-match-exact-headlinenil. 这使得上面的第三种类型的链接[[file:path/to/another-file.org::d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]进行模糊文本搜索,而当目标文件是 Org 模式文件时,其他值(t和默认值query-to-create)偏向于标题。

这是 doc 字符串org-link-search-must-match-exact-headline

org-link-search-must-match-exact-headline is a variable defined in ‘ol.el’.
Its value is nil
Original value was ‘query-to-create’

  This variable is safe as a file local variable if its value
  satisfies the predicate ‘symbolp’.
  You can customize this variable.
  This variable was introduced, or its default value was changed, in
  version 24.1 of Emacs.

Documentation:
Non-nil means internal fuzzy links can only match headlines.

When nil, the a fuzzy link may point to a target or a named
construct in the document.  When set to the special value
‘query-to-create’, offer to create a new headline when none
matched.

Spaces and statistics cookies are ignored during heading searches.

顺便说一句,我通过阅读手册的外部链接部分找到了它:查找text search和随附的脚注。

于 2020-11-12T17:30:10.847 回答