branch: elpa/magit
commit 1762e7f3d96a66286e253c0648a24ac989a955e3
Author: X4lldux <x4ll...@vectron.io>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    magit-section-show-level: Support acting on selected sections
---
 lisp/magit-section.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 6a9828f48e..a68b728506 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -1076,8 +1076,10 @@ SECTION's body (and heading) obviously cannot be 
visible."
 
 (defun magit-section-show-level (level)
   "Show surrounding sections up to LEVEL.
-Likewise hide sections at higher levels.  If LEVEL is negative, show all
-sections up to the absolute value of that, not just surrounding sections."
+Likewise hide sections at higher levels.  If the region selects multiple
+sibling sections, act on all marked trees.  If LEVEL is negative, show
+all sections up to the absolute value of that, not just surrounding
+sections."
   (if (< level 0)
       (let ((s (magit-current-section)))
         (setq level (- level))
@@ -1085,13 +1087,15 @@ sections up to the absolute value of that, not just 
surrounding sections."
           (setq s (oref s parent))
           (goto-char (oref s start)))
         (magit-section-show-children magit-root-section (1- level)))
-    (cl-do* ((s (magit-current-section)
-                (oref s parent))
-             (i (1- (length (magit-section-ident s)))
-                (cl-decf i)))
-        ((cond ((< i level) (magit-section-show-children s (- level i 1)) t)
-               ((= i level) (magit-section-hide s) t))
-         (magit-section-goto s)))))
+    (dolist (section (or (magit-region-sections)
+                         (list (magit-current-section))))
+      (cl-do* ((s section
+                  (oref s parent))
+               (i (1- (length (magit-section-ident s)))
+                  (cl-decf i)))
+          ((cond ((< i level) (magit-section-show-children s (- level i 1)) t)
+                 ((= i level) (magit-section-hide s) t))
+           (magit-section-goto s))))))
 
 (defun magit-section-show-level-1 ()
   "Show surrounding sections on first level."

Reply via email to