mirror of
https://github.com/chrisbarrett/nursery
synced 2025-08-19 13:43:32 -05:00
Offer option to update dblocks silently
This commit is contained in:
@@ -166,6 +166,11 @@ their blocks updated automatically."
|
|||||||
:type '(choice (const nil)
|
:type '(choice (const nil)
|
||||||
(repeat :tag "Tag" (string))))
|
(repeat :tag "Tag" (string))))
|
||||||
|
|
||||||
|
(defcustom org-roam-dblocks-autoupdate-silently-p t
|
||||||
|
"Whether to suppress messages during the dblock update process."
|
||||||
|
:group 'org-roam-dblocks
|
||||||
|
:type 'boolean)
|
||||||
|
|
||||||
(defconst org-roam-dblocks-names '("notes" "backlinks"))
|
(defconst org-roam-dblocks-names '("notes" "backlinks"))
|
||||||
|
|
||||||
|
|
||||||
@@ -476,13 +481,14 @@ and old content."
|
|||||||
(append org-file-tags (org-get-tags)))))
|
(append org-file-tags (org-get-tags)))))
|
||||||
|
|
||||||
(defun org-roam-dblocks--update-blocks ()
|
(defun org-roam-dblocks--update-blocks ()
|
||||||
(org-map-dblocks
|
(let ((message-log-max (if org-roam-dblocks-autoupdate-silently-p nil message-log-max)))
|
||||||
(lambda ()
|
(org-map-dblocks
|
||||||
(when (org-roam-dblocks--update-block-at-point-p)
|
(lambda ()
|
||||||
(pcase (org-element-at-point)
|
(when (org-roam-dblocks--update-block-at-point-p)
|
||||||
(`(dynamic-block ,plist)
|
(pcase (org-element-at-point)
|
||||||
(when (member (plist-get plist :block-name) org-roam-dblocks-names)
|
(`(dynamic-block ,plist)
|
||||||
(org-update-dblock))))))))
|
(when (member (plist-get plist :block-name) org-roam-dblocks-names)
|
||||||
|
(org-update-dblock)))))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -494,7 +500,8 @@ and old content."
|
|||||||
(org-roam-dblocks-autoupdate-mode
|
(org-roam-dblocks-autoupdate-mode
|
||||||
(org-roam-dblocks--update-blocks)
|
(org-roam-dblocks--update-blocks)
|
||||||
(when (and (buffer-file-name) (buffer-modified-p))
|
(when (and (buffer-file-name) (buffer-modified-p))
|
||||||
(save-buffer))
|
(let ((message-log-max (if org-roam-dblocks-autoupdate-silently-p nil message-log-max)))
|
||||||
|
(save-buffer)))
|
||||||
(add-hook 'before-save-hook #'org-roam-dblocks--update-blocks nil t))
|
(add-hook 'before-save-hook #'org-roam-dblocks--update-blocks nil t))
|
||||||
(t
|
(t
|
||||||
(remove-hook 'before-save-hook #'org-roam-dblocks--update-blocks))))
|
(remove-hook 'before-save-hook #'org-roam-dblocks--update-blocks))))
|
||||||
|
Reference in New Issue
Block a user