(feat): add org-roam-prefer-id-links to select linking method (#1238)

This commit is contained in:
Jethro Kuan
2020-11-07 15:06:12 +08:00
committed by GitHub
parent 4d423a916e
commit 440461a90b
2 changed files with 8 additions and 1 deletions

View File

@ -5,6 +5,7 @@
### Features ### Features
- [#1183](https://github.com/org-roam/org-roam/pull/1183) add interactive functions for managing aliases and tags in Org-roam file, namely `org-roam-alias-add`, `org-roam-alias-delete`, `org-roam-tag-add`, and `org-roam-tag-delete`. - [#1183](https://github.com/org-roam/org-roam/pull/1183) add interactive functions for managing aliases and tags in Org-roam file, namely `org-roam-alias-add`, `org-roam-alias-delete`, `org-roam-tag-add`, and `org-roam-tag-delete`.
- [#1238](https://github.com/org-roam/org-roam/pull/1238) add `org-roam-prefer-id-links` variable to select linking method
### Bugfixes ### Bugfixes

View File

@ -147,6 +147,11 @@ Formatter may be a function that takes title as its only argument."
(function :tag "Custom function")) (function :tag "Custom function"))
:group 'org-roam) :group 'org-roam)
(defcustom org-roam-prefer-id-links t
"If non-nil, use ID for linking instead where available."
:type 'boolean
:group 'org-roam)
(defcustom org-roam-list-files-commands (defcustom org-roam-list-files-commands
(if (member system-type '(windows-nt ms-dos cygwin)) (if (member system-type '(windows-nt ms-dos cygwin))
nil nil
@ -806,7 +811,8 @@ backlinks."
TYPE defaults to \"file\". TYPE defaults to \"file\".
Here, we also check if there is an ID for the file." Here, we also check if there is an ID for the file."
(setq type (or type "file")) (setq type (or type "file"))
(when-let ((id (and (string-equal type "file") (when-let ((id (and org-roam-prefer-id-links
(string-equal type "file")
(caar (org-roam-db-query [:select [id] :from ids (caar (org-roam-db-query [:select [id] :from ids
:where (= file $s1) :where (= file $s1)
:and (= level 0) :and (= level 0)