diff options
author | Nicolas Petton | 2021-02-28 21:28:03 +0100 |
---|---|---|
committer | Nicolas Petton | 2021-02-28 21:28:03 +0100 |
commit | 71dad15b6dc9e32298dabdb5f301a6c228414254 (patch) | |
tree | 4afc0c38dddcac23cead7d0f96d288e1f54876ed /nroam.el | |
parent | 90a0ba1599c4738821b3c583cf8d3144f3241df5 (diff) | |
download | nroam-71dad15b6dc9e32298dabdb5f301a6c228414254.tar.gz nroam-71dad15b6dc9e32298dabdb5f301a6c228414254.zip |
* nroam.el (nroam--insert): Extract `nroam--set-sections-visibility'.
Diffstat (limited to 'nroam.el')
-rw-r--r-- | nroam.el | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -185,18 +185,21 @@ Make the region inserted by BODY read-only, and marked with (defun nroam--insert () "Insert nroam sections in the current buffer." - (let ((point (point-max))) - (with-buffer-modified-unmodified - (save-excursion - (goto-char point) - (unless (bobp) - (nroam--ensure-empty-line)) - (with-nroam-markers - (nroam--do-separated-by-newlines #'funcall nroam-sections)) - (when (nroam--sections-inserted-p) - (save-restriction - (narrow-to-region point (point-max)) - (org-set-startup-visibility))))))) + (with-buffer-modified-unmodified + (save-excursion + (goto-char (point-max)) + (unless (bobp) + (nroam--ensure-empty-line)) + (with-nroam-markers + (nroam--do-separated-by-newlines #'funcall nroam-sections)) + (nroam--set-sections-visibility)))) + +(defun nroam--set-sections-visibility () + "Set nroam section visibility according to `org-set-startup-visibility'." + (when (nroam--sections-inserted-p) + (save-restriction + (narrow-to-region nroam-start-marker nroam-end-marker) + (org-set-startup-visibility)))) (defun nroam--get-backlinks () "Return a list of backlinks for the current buffer." |