From 0f08711a7f42dd43179e566fa87b00afaf6410bb Mon Sep 17 00:00:00 2001 From: Greg Sexton Date: Sat, 19 Apr 2014 15:08:46 +0100 Subject: [PATCH] Implement toggle --- origami.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/origami.el b/origami.el index b244b22..ab234a5 100644 --- a/origami.el +++ b/origami.el @@ -414,7 +414,18 @@ otherwise fetch cached tree." (origami-delete-overlay-from-fold-tree-fn buffer) (origami-change-overlay-from-fold-node-fn buffer))))) -(defun origami-toggle-node (buffer point)) +(defun origami-toggle-node (buffer point) + (interactive (list (current-buffer) (point))) + (let ((tree (origami-get-fold-tree buffer))) + (-when-let (path (origami-fold-find-path-containing tree point)) + (debug-msg "open path: %s" path) + (origami-fold-diff tree (origami-store-cached-tree buffer + (origami-fold-open-set + path + (not (origami-fold-open-p (-last-item path))))) + (origami-create-overlay-from-fold-tree-fn buffer) + (origami-delete-overlay-from-fold-tree-fn buffer) + (origami-change-overlay-from-fold-node-fn buffer))))) (defun origami-reset (buffer) ;; TODO: provide this to the user in case we get screwed up, maybe