Rodolf,

Thanks for the feedback! Here's a fixed version:

    (org-link-set-parameters
     "id"
     :complete
     (lambda (&optional _prefix)
       (unless org-id-locations (org-id-locations-load))
       (when-let* ((id (org-id-get-with-outline-path-completion
                        '((nil . (:maxlevel . 10))
                          (org-id-files . (:maxlevel . 10))))))
         (concat "id:" id)))
     :insert-description
     (lambda (link desc)
       (or (org-string-nw-p desc)
           (when-let* ((loc (org-id-find (string-remove-prefix "id:" link))))
             (org-with-file-buffer (car loc)
               (org-with-wide-buffer
                (goto-char (cdr loc))
                (org-link-display-format
                 (org-get-heading t t t t))))))))

> (1) With exactly one file in `org-id-files'...

Fixed by adding (nil . (:maxlevel . 10)) to the targets. Now:

1. Headlines in the current file show up as headlines only (no file
name).
2. Headlines in other files show up as "Headline (file-name.org)".
3. Headlines in the current file always show up, even org-id-files is
empty.

> (2) One of the completions I see is "notes.org/"...

This should be fixed by the same change (bare file names no longer show
up as possible link targets). The alternative would be to make it
possible to link to files by ID (fixing the description logic) but
that's not something I generally want to do anyways.

> (3) When my `notes.org' file is narrowed to a subtree with `C-x n s', ID

Fixed by widening the buffer first.

Reply via email to