From 71dad15b6dc9e32298dabdb5f301a6c228414254 Mon Sep 17 00:00:00 2001 From: Nicolas Petton Date: Sun, 28 Feb 2021 21:28:03 +0100 Subject: * nroam.el (nroam--insert): Extract `nroam--set-sections-visibility'. --- nroam.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/nroam.el b/nroam.el index 944290d..329111c 100644 --- a/nroam.el +++ b/nroam.el @@ -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." -- cgit v1.2.3-54-g00ecf