From 7775fc202307b58f175c25a0c1f500353a2afb5c Mon Sep 17 00:00:00 2001 From: Greg Sexton Date: Mon, 4 Aug 2014 22:01:00 +0100 Subject: [PATCH] Implement origami-forward-toggle-node --- origami.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/origami.el b/origami.el index 3dff54f..e9cff08 100644 --- a/origami.el +++ b/origami.el @@ -562,6 +562,26 @@ as to ensure seeing where POINT is." node (not (origami-fold-open-p (-last-item path)))))))))) +(defun origami-forward-toggle-node (buffer point) + (interactive (list (current-buffer) (point))) + (let (end) + (with-current-buffer buffer + (save-excursion + (goto-char point) + (setq end (line-end-position)))) + (-when-let (tree (origami-get-fold-tree buffer)) + (-when-let (path (origami-fold-find-path-containing tree point)) + (let ((forward-node (-first (lambda (node) + (and (>= (origami-fold-beg node) point) + (<= (origami-fold-beg node) end))) + (origami-fold-children (-last-item path))))) + (let ((path (if forward-node (append path (list forward-node)) path))) + (origami-apply-new-tree buffer tree (origami-fold-assoc + path (lambda (node) + (origami-fold-open-set + node (not (origami-fold-open-p + (-last-item path))))))))))))) + (defun origami-open-all-nodes (buffer) (interactive (list (current-buffer))) (-when-let (tree (origami-get-fold-tree buffer))