diff options
author | Nicolas Petton | 2021-02-28 21:32:54 +0100 |
---|---|---|
committer | Nicolas Petton | 2021-02-28 21:32:54 +0100 |
commit | b909ccd800a2f92f078823034c9ce57aad218553 (patch) | |
tree | 81cbfa48dd22aa9fb3a5b4c9da64eab197239139 /nroam.el | |
parent | 71dad15b6dc9e32298dabdb5f301a6c228414254 (diff) | |
download | nroam-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.
Diffstat (limited to 'nroam.el')
-rw-r--r-- | nroam.el | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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'." |