(feat): support file-level IDs (#1163)

Additionally cache IDs at outline-level 0, now that property drawers are supported in Org 9.4.

Update org-roam--format-link to prefer ID links wherever possible. That is, when a file has an ID, use an id link instead of file link.
This commit is contained in:
Jethro Kuan
2020-10-05 16:57:54 +08:00
committed by GitHub
parent 6759bee56b
commit d973e8f6e0
7 changed files with 89 additions and 95 deletions

View File

@ -41,7 +41,7 @@
(defvar org-roam-directory)
(declare-function org-roam--find-file "org-roam")
(declare-function org-roam-find-file "org-roam")
(declare-function org-roam-format-link "org-roam")
(defcustom org-roam-link-auto-replace t
"When non-nil, replace Org-roam's roam links with file or id links whenever possible."
@ -236,9 +236,7 @@ DESC is the link description."
(unless (org-in-regexp org-link-bracket-re 1)
(user-error "No link at point"))
(replace-match "")
(when (string-equal link-type "file")
(setq loc (org-roam-link-get-path loc)))
(insert (org-roam-link-make-string (concat link-type ":" loc) desc)))))
(insert (org-roam-format-link loc desc link-type)))))
(defun org-roam-link-replace-all ()
"Replace all roam links in the current buffer."