* bug#35013: speedbar-expand-line-descendants opens non-descendant tree entries
@ 2019-03-26 20:28 Kieran Barry
2019-03-26 20:55 ` bug#35014: " Kieran Barry
0 siblings, 1 reply; 3+ messages in thread
From: Kieran Barry @ 2019-03-26 20:28 UTC (permalink / raw)
To: 35013
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
Current behaviour:
speedbar-expand-line-descendants incorrectly recursively expands all nodes
below the current node.
Expected behaviour:
Should only recursively expand descendants of the current node.
Steps to reproduce:
emacs -Q ~
M-x speedbar
<focus to speedbar>
<cursor over a directory that is not the last in list>
[
("[" is bound to `speedbar-expand-line-descendants')
Found in: GNU Emacs 26.1
--
Kieran Barry -- kieranb@google.com
EU Directive 2003/58/EC compliance:
Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland
Registered in Dublin, Ireland with # 368047
[-- Attachment #2: Type: text/html, Size: 1218 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#35014: speedbar-expand-line-descendants opens non-descendant tree entries
2019-03-26 20:28 bug#35013: speedbar-expand-line-descendants opens non-descendant tree entries Kieran Barry
@ 2019-03-26 20:55 ` Kieran Barry
2020-08-19 10:46 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Kieran Barry @ 2019-03-26 20:55 UTC (permalink / raw)
To: 35014
[-- Attachment #1: Type: text/plain, Size: 3583 bytes --]
Patch to fix.
Changelog:
2019-03-26 Kieran Barry <kieranb@....com>
* lisp/speedbar.el: speedbar-expand-line-descendants fixed to only expand
descendants of current node.
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 399ef4557b..81ab8d2306 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -3271,6 +3271,18 @@ With universal argument ARG, flush cached data."
(speedbar-do-function-pointer))
(error (speedbar-position-cursor-on-line))))
+(defun speedbar--get-entry-depth ()
+ "Extract the depth parameter from speedbar line.
+Returns depth as a string.
+Raises error when line doesn't match speedbar format."
+ (interactive)
+ (save-match-data
+ (save-excursion
+ (beginning-of-line)
+ (if (looking-at "\\([0-9]+\\):")
+ (match-string-no-properties 1)
+ (user-error "Incorrect format for speedbar entry")))))
+
(defun speedbar-expand-line-descendants (&optional arg)
"Expand the line under the cursor and all descendants.
Optional argument ARG indicates that any cache should be flushed."
@@ -3279,15 +3291,29 @@ Optional argument ARG indicates that any cache
should be flushed."
;; Now, inside the area expanded here, expand all subnodes of
;; the same descendant type.
(save-excursion
- (speedbar-next 1) ;; Move into the list.
- (let ((err nil))
- (while (not err)
- (condition-case nil
- (progn
- (speedbar-expand-line-descendants arg)
- (speedbar-restricted-next 1))
- (error (setq err t))))))
- )
+ (let ((starting-depth (speedbar--get-entry-depth)))
+ (speedbar-next 1) ;; Move into the list.
+ ;; Expand all descendants of the "next entry" provided they are at
+ ;; depth greater than the initial entry.
+ (speedbar--expand-line-descendants-impl starting-depth)
+ )))
+
+(defun speedbar--expand-line-descendants-impl (calling-depth &optional arg)
+ "Expand the line under the cursor and all descendants recursively.
+Finish if the line to be expanded is not at the same depth as
CALLING-DEPTH.
+Optional argument ARG indicates that any cache should be flushed."
+ (interactive "P")
+ (let ((current-depth (speedbar--get-entry-depth)))
+ (unless (equal current-depth calling-depth)
+ (speedbar-expand-line arg)
+ (speedbar-next 1)
+ (let ((err nil))
+ (while (not err)
+ (condition-case nil
+ (progn
+ (speedbar--expand-line-descendants-impl calling-depth)
+ (speedbar-restricted-next 1))
+ (error (setq err t))))))))
(defun speedbar-contract-line-descendants ()
"Expand the line under the cursor and all descendants."
On Tue, Mar 26, 2019 at 8:28 PM Kieran Barry <kieranb@google.com> wrote:
> Current behaviour:
> speedbar-expand-line-descendants incorrectly recursively expands all nodes
> below the current node.
>
> Expected behaviour:
> Should only recursively expand descendants of the current node.
>
> Steps to reproduce:
> emacs -Q ~
> M-x speedbar
> <focus to speedbar>
> <cursor over a directory that is not the last in list>
> [
>
> ("[" is bound to `speedbar-expand-line-descendants')
>
> Found in: GNU Emacs 26.1
>
> --
> Kieran Barry -- kieranb@google.com
> EU Directive 2003/58/EC compliance:
> Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland
> Registered in Dublin, Ireland with # 368047
>
--
Kieran Barry -- kieranb@google.com
EU Directive 2003/58/EC compliance:
Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland
Registered in Dublin, Ireland with # 368047
[-- Attachment #2: Type: text/html, Size: 5894 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#35014: speedbar-expand-line-descendants opens non-descendant tree entries
2019-03-26 20:55 ` bug#35014: " Kieran Barry
@ 2020-08-19 10:46 ` Lars Ingebrigtsen
0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-19 10:46 UTC (permalink / raw)
To: Kieran Barry; +Cc: 35013, 35014
Kieran Barry <kieranb@google.com> writes:
> Patch to fix.
>
> Changelog:
> 2019-03-26 Kieran Barry <kieranb@....com>
> * lisp/speedbar.el: speedbar-expand-line-descendants fixed to only expand
> descendants of current node.
Thanks for the patch.
I had a look at the speedbar code (I don't normally use the mode
myself), and there seemed like a much simpler fix -- just narrow to the
current line before starting to expand. I tried that, and it seems to
work for me, so I've pushed that fix to Emacs 28 instead.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-19 10:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-26 20:28 bug#35013: speedbar-expand-line-descendants opens non-descendant tree entries Kieran Barry
2019-03-26 20:55 ` bug#35014: " Kieran Barry
2020-08-19 10:46 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.