diff options
author | Nicolas Petton | 2021-02-24 17:03:31 +0100 |
---|---|---|
committer | Nicolas Petton | 2021-02-24 17:03:31 +0100 |
commit | e6ecd9f5f687415bfc3e6336127d22a01ebcccc2 (patch) | |
tree | d41b172d50cb75af34eaea5347d171eba63a3146 | |
parent | 34e21d6880c7c6fe1eed86ecd7cfc303c3338ad5 (diff) | |
download | nroam-e6ecd9f5f687415bfc3e6336127d22a01ebcccc2.tar.gz nroam-e6ecd9f5f687415bfc3e6336127d22a01ebcccc2.zip |
Advice org-capture to remove nroam sections when capturing
Nroam sections need to be pruned as they are in read-only, otherwise
`org-capture' will fail to insert the capture template.
-rw-r--r-- | nroam.el | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -37,10 +37,23 @@ (require 'org-roam) (require 'org-roam-buffer) (require 'org-element) +(require 'org-capture) (require 'seq) (require 'subr-x) (require 'bookmark) +(defun nroam--handle-org-capture (&rest _) + "Setup the `org-capture' buffer. + +Nroam sections need to be pruned as they are in read-only, +otherwise `org-capture' will fail to insert the capture +template." + (when-let ((buf (org-capture-get :buffer))) + (with-current-buffer buf + (nroam--prune)))) + +(advice-add 'org-capture-place-template :before #'nroam--handle-org-capture) + (defcustom nroam-sections '(nroam-backlinks-section) "List of functions to be called to insert sections in nroam buffers." @@ -119,8 +132,8 @@ Make the region inserted by BODY read-only, and marked with (defun nroam-backlinks-section () "Insert org-roam backlinks for the current buffer." - (when-let* ((backlinks (nroam--get-backlinks)) - (groups (seq-reverse (nroam--group-backlinks backlinks)))) + (let* ((backlinks (nroam--get-backlinks)) + (groups (seq-reverse (nroam--group-backlinks backlinks)))) (nroam--ensure-empty-line) (nroam--insert-backlinks-heading (seq-length backlinks)) (seq-do #'nroam--insert-backlink-group groups) |