aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/speedbar.el37
1 files changed, 22 insertions, 15 deletions
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index c13c977938b..38fb641acf7 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -3168,25 +3168,32 @@ With universal argument ARG, flush cached data."
3168 (speedbar-do-function-pointer)) 3168 (speedbar-do-function-pointer))
3169 (error (speedbar-position-cursor-on-line)))) 3169 (error (speedbar-position-cursor-on-line))))
3170 3170
3171(defun speedbar--get-line-indent-level ()
3172 "Return the indentation level of the current line."
3173 (save-excursion
3174 (beginning-of-line)
3175 (if (looking-at "[0-9]+:")
3176 (string-to-number (match-string 0))
3177 0)))
3178
3171(defun speedbar-expand-line-descendants (&optional arg) 3179(defun speedbar-expand-line-descendants (&optional arg)
3172 "Expand the line under the cursor and all descendants. 3180 "Expand the line under the cursor and all descendants.
3173Optional argument ARG indicates that any cache should be flushed." 3181Optional argument ARG indicates that any cache should be flushed."
3174 (interactive "P") 3182 (interactive "P")
3175 (save-restriction 3183 (dframe-message "Expanding all descendants...")
3176 (narrow-to-region (line-beginning-position) 3184 (save-excursion
3177 (line-beginning-position 2)) 3185 (let ((top-depth (speedbar--get-line-indent-level)))
3178 (speedbar-expand-line arg) 3186 ;; Attempt to expand the top-level item.
3179 ;; Now, inside the area expanded here, expand all subnodes of 3187 (speedbar-expand-line arg)
3180 ;; the same descendant type. 3188 ;; Move forwards, either into the newly expanded list, onto an
3181 (save-excursion 3189 ;; already expanded list, onto a sibling item, or to the end of
3182 (speedbar-next 1) ;; Move into the list. 3190 ;; the buffer.
3183 (let ((err nil)) 3191 (while (and (zerop (forward-line 1))
3184 (while (not err) 3192 (not (eobp))
3185 (condition-case nil 3193 (> (speedbar--get-line-indent-level) top-depth)
3186 (progn 3194 (speedbar-expand-line arg)))))
3187 (speedbar-expand-line-descendants arg) 3195 (dframe-message "Expanding all descendants...done")
3188 (speedbar-restricted-next 1)) 3196 (speedbar-position-cursor-on-line))
3189 (error (setq err t))))))))
3190 3197
3191(defun speedbar-contract-line-descendants () 3198(defun speedbar-contract-line-descendants ()
3192 "Expand the line under the cursor and all descendants." 3199 "Expand the line under the cursor and all descendants."