1

I'm trying to find a way to add a clickable link in org-mode that opens another local file and scrolls to a specific property id.

It's easier to explain with an example:

$ 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

Unfortunately, I can't change the structure of another-file.org. I can only reference using a property id.

Just renaming "Question :drill:" would have been much easier but it is duplicated many times and as I said it is not available for updates.


Update:

With "CUSTOM_ID" property it seems to be working

*** 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]]

But is there any way to make it with with default :ID: property?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91

1 Answers1

1

Try setting org-link-search-must-match-exact-headline to nil. That makes the third type of link above [[file:path/to/another-file.org::d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]] do a fuzzy text search, whereas the other values (t and the default query-to-create) are biased towards headlines when the target file is an Org mode file.

Here's the doc string of 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.

BTW, I found it by reading the External Links section of the manual: look for text search and the accompanying footnote.

NickD
  • 5,937
  • 1
  • 21
  • 38