GNU bug report logs - #35014
speedbar-expand-line-descendants opens non-descendant tree entries

Previous Next

Package: emacs;

Reported by: Kieran Barry <kieranb <at> google.com>

Date: Tue, 26 Mar 2019 22:21:02 UTC

Severity: normal

Tags: fixed, patch

Merged with 35013

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35014 in the body.
You can then email your comments to 35014 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35014; Package emacs. (Tue, 26 Mar 2019 22:21:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kieran Barry <kieranb <at> google.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 26 Mar 2019 22:21:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kieran Barry <kieranb <at> google.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: speedbar-expand-line-descendants opens non-descendant tree entries
Date: Tue, 26 Mar 2019 20:55:51 +0000
[Message part 1 (text/plain, inline)]
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 <at> 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 <at> 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 <at> google.com
EU Directive 2003/58/EC compliance:
Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland
Registered in Dublin, Ireland with # 368047
[Message part 2 (text/html, inline)]

Merged 35013 35014. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 27 Mar 2019 09:04:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 18 Aug 2020 16:51:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35014; Package emacs. (Wed, 19 Aug 2020 10:47:02 GMT) Full text and rfc822 format available.

Message #12 received at 35014 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kieran Barry <kieranb <at> google.com>
Cc: 35013 <at> debbugs.gnu.org, 35014 <at> debbugs.gnu.org
Subject: Re: bug#35014: speedbar-expand-line-descendants opens
 non-descendant tree entries
Date: Wed, 19 Aug 2020 12:46:17 +0200
Kieran Barry <kieranb <at> 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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Aug 2020 10:47:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 35013 <at> debbugs.gnu.org and Kieran Barry <kieranb <at> google.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Aug 2020 10:47:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 16 Sep 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 228 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.