Add origami-toggle-all-nodes

This commit is contained in:
Greg Sexton 2014-11-16 18:09:19 +00:00
parent ec68e37557
commit 7e878a2251
2 changed files with 15 additions and 0 deletions

View File

@ -101,6 +101,11 @@ The following commands are supplied to manipulate folds in the buffer:
<td>Close every fold in the buffer.</td> <td>Close every fold in the buffer.</td>
</tr> </tr>
<tr>
<td>origami-toggle-all-nodes</td>
<td>Toggle open/closed every fold node in the buffer.</td>
</tr>
<tr> <tr>
<td>origami-show-only-node</td> <td>origami-show-only-node</td>
<td>Close everything but the folds necessary to see the point. Very useful for concentrating on an area of code.</td> <td>Close everything but the folds necessary to see the point. Very useful for concentrating on an area of code.</td>

View File

@ -525,6 +525,16 @@ familiar. It's easiest to grasp this just by giving it a go."
(origami-fold-open-set node nil)) (origami-fold-open-set node nil))
tree))))) 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) (defun origami-show-only-node (buffer point)
"Close all fold nodes in BUFFER except for those necessary to "Close all fold nodes in BUFFER except for those necessary to
make POINT visible. Very useful for quickly collapsing everything make POINT visible. Very useful for quickly collapsing everything