diff --git a/README.md b/README.md
index bd058af..f5752fe 100644
--- a/README.md
+++ b/README.md
@@ -101,6 +101,11 @@ The following commands are supplied to manipulate folds in the buffer:
Close every fold in the buffer. |
+
+ origami-toggle-all-nodes |
+ Toggle open/closed every fold node in the buffer. |
+
+
origami-show-only-node |
Close everything but the folds necessary to see the point. Very useful for concentrating on an area of code. |
diff --git a/origami.el b/origami.el
index 1722ae8..3072c8d 100644
--- a/origami.el
+++ b/origami.el
@@ -525,6 +525,16 @@ familiar. It's easiest to grasp this just by giving it a go."
(origami-fold-open-set node nil))
tree)))))
+(defun origami-toggle-all-nodes (buffer)
+ "Toggle all fold nodes in the buffer recursively open or
+recursively closed."
+ (interactive (list (current-buffer)))
+ (-when-let (tree (origami-get-fold-tree buffer))
+ ;; use the first child as root is always open
+ (if (-> tree origami-fold-children car origami-fold-open?)
+ (origami-close-all-nodes buffer)
+ (origami-open-all-nodes buffer))))
+
(defun origami-show-only-node (buffer point)
"Close all fold nodes in BUFFER except for those necessary to
make POINT visible. Very useful for quickly collapsing everything