summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Nicolas Petton2021-02-28 21:32:54 +0100
committerGravatar Nicolas Petton2021-02-28 21:32:54 +0100
commitb909ccd800a2f92f078823034c9ce57aad218553 (patch)
tree81cbfa48dd22aa9fb3a5b4c9da64eab197239139
parent71dad15b6dc9e32298dabdb5f301a6c228414254 (diff)
downloadnroam-b909ccd800a2f92f078823034c9ce57aad218553.tar.gz
nroam-b909ccd800a2f92f078823034c9ce57aad218553.zip
Insert sections when turning the mode on if the buffer file exists.
* nroam.el (nroam-mode): Conditionally insert sections when turning enabling `nroam-mode'. (nroam--maybe-insert-immediately): New function.
-rw-r--r--nroam.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/nroam.el b/nroam.el
index 329111c..711aded 100644
--- a/nroam.el
+++ b/nroam.el
@@ -99,11 +99,16 @@ Make the region inserted by BODY read-only, and marked with
(nroam--init-work-buffer)
(add-hook 'before-save-hook #'nroam--prune nil t)
(add-hook 'after-save-hook #'nroam--update-maybe nil t)
- (nroam-update))
+ (nroam--maybe-insert-immediately))
(remove-hook 'before-save-hook #'nroam--prune t)
(remove-hook 'after-save-hook #'nroam--update-maybe t)
(nroam--prune)))
+(defun nroam--maybe-insert-immediately ()
+ "Insert nroam sections iff the buffer file exists."
+ (when (file-exists-p buffer-file-name)
+ (nroam-update)))
+
;;;###autoload
(defun nroam-ctrl-c-ctrl-c ()
"Update the sections for the current buffer, or fallback to `org-ctrl-c-ctrl-c'."