From 2081e1268ad57dfb94171d1a99e8f13126fbdaa5 Mon Sep 17 00:00:00 2001 From: "Charl P. Botha" Date: Thu, 13 Aug 2020 05:18:06 +0200 Subject: [PATCH] (feat): add org-roam-enable-headline-linking (#1030) When disabled, Org-roam will not attempt to cache headlines, and will not create IDs. Co-authored-by: Jethro Kuan --- org-roam-db.el | 11 +++++++---- org-roam.el | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/org-roam-db.el b/org-roam-db.el index 0d16d97..2dd247d 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -39,6 +39,7 @@ (require 'org-roam-macs) (defvar org-roam-directory) +(defvar org-roam-enable-headline-linking) (defvar org-roam-verbose) (defvar org-roam-file-name) @@ -472,7 +473,8 @@ connections, nil is returned." (org-roam-db--update-tags) (org-roam-db--update-titles) (org-roam-db--update-refs) - (org-roam-db--update-headlines) + (when org-roam-enable-headline-linking + (org-roam-db--update-headlines)) (org-roam-db--update-links))) (org-roam-buffer--update-maybe :redisplay t))))) @@ -511,9 +513,10 @@ If FORCE, force a rebuild of the cache from scratch." :values $v1] (vector file contents-hash (list :atime atime :mtime mtime))) (setq file-count (1+ file-count)) - (when-let ((headlines (org-roam--extract-headlines file))) - (when (org-roam-db--insert-headlines headlines) - (setq headline-count (1+ headline-count))))) + (when org-roam-enable-headline-linking + (when-let ((headlines (org-roam--extract-headlines file))) + (when (org-roam-db--insert-headlines headlines) + (setq headline-count (1+ headline-count)))))) (file-error (setq org-roam-files (remove file org-roam-files)) (org-roam-db--clear-file file) diff --git a/org-roam.el b/org-roam.el index d255b7a..bc26a96 100644 --- a/org-roam.el +++ b/org-roam.el @@ -244,6 +244,11 @@ space-delimited strings. (symbol))) :group 'org-roam) +(defcustom org-roam-enable-headline-linking t + "Enable linking to headlines, which includes automatic :ID: creation and scanning of :ID:s for org-roam database." + :type 'boolean + :group 'org-roam) + (defcustom org-roam-verbose t "Echo messages that are not errors." :type 'boolean @@ -1589,7 +1594,8 @@ M-x info for more information at Org-roam > Installation > Post-Installation Tas (advice-add 'rename-file :after #'org-roam--rename-file-advice) (advice-add 'delete-file :before #'org-roam--delete-file-advice) (when (fboundp 'org-link-set-parameters) - (org-link-set-parameters "file" :face 'org-roam--file-link-face :store #'org-roam-store-link) + (when org-roam-enable-headline-linking + (org-link-set-parameters "file" :face 'org-roam--file-link-face :store #'org-roam-store-link)) (org-link-set-parameters "id" :face 'org-roam--id-link-face)) (org-roam-db-build-cache)) (t