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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Kieran Barry <kieranb@HIDDEN>; merged with #35013; dated Tue, 26 Mar 2019 22:21:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Merged 35013 35014. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Mar 2019 22:20:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 26 18:20:37 2019
Received: from localhost ([127.0.0.1]:60661 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1h8uQu-0001ej-Hj
	for submit <at> debbugs.gnu.org; Tue, 26 Mar 2019 18:20:37 -0400
Received: from eggs.gnu.org ([209.51.188.92]:40923)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kieranb@HIDDEN>) id 1h8t7J-0007uT-5l
 for submit <at> debbugs.gnu.org; Tue, 26 Mar 2019 16:56:17 -0400
Received: from lists.gnu.org ([209.51.188.17]:60769)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <kieranb@HIDDEN>) id 1h8t7D-0000C7-Rd
 for submit <at> debbugs.gnu.org; Tue, 26 Mar 2019 16:56:11 -0400
Received: from eggs.gnu.org ([209.51.188.92]:55288)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <kieranb@HIDDEN>) id 1h8t7C-0004cT-9n
 for bug-gnu-emacs@HIDDEN; Tue, 26 Mar 2019 16:56:11 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <kieranb@HIDDEN>) id 1h8t7A-00009G-Jt
 for bug-gnu-emacs@HIDDEN; Tue, 26 Mar 2019 16:56:10 -0400
Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]:41190)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <kieranb@HIDDEN>) id 1h8t78-000059-MM
 for bug-gnu-emacs@HIDDEN; Tue, 26 Mar 2019 16:56:08 -0400
Received: by mail-ua1-x935.google.com with SMTP id 46so1091996uan.8
 for <bug-gnu-emacs@HIDDEN>; Tue, 26 Mar 2019 13:56:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
 bh=bNVFTksvf2uSzeIXY8kU4nj5K2o+5s6QEYmBtXpDrwI=;
 b=UAupiadSInRDSSeIDgrs28Q74iJqfyV/QIG5U3U4hCuMFfOlznpPBiQlzmPx6SxOkM
 o/VCLrYL34q9CMCcCrsMT3dXzLmRntafGeFhX2nonpHAe9cQQ6TsqKxSO/8qhLKBfWmT
 ijgqctLImI6V2qbzbe02tL8P1312a4640SddU1ACiEwmYMncQh4aMNcCQ8b01Y49Wjbk
 8vKxkSSHba13t/LQ8jh/ztl/UefuvpuMxXTP2JGaCpLjbwntauT14Kkj6H8jl/icsOZU
 qLOnfaSZ85Jvn3F5VBryv9haNmy4g0Bvb+zcHTN+Iw+k7T+I1E03hub65eKEzttno2+x
 zoIA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to;
 bh=bNVFTksvf2uSzeIXY8kU4nj5K2o+5s6QEYmBtXpDrwI=;
 b=Z0zEBaMmDCQCAGupuZRSowWCIppIof767CnVNfEcqhzseZfOxjuQmzHhFf4dLezwrm
 uZBbpaU0ig2mLszbxc0bexJZDZvKopD4NhZCbXLtudNVOI8DoKJ8POs0ilZ1BMxRvaHf
 HPPIh1qK0ahPGIRm8BAgRejgDRv05Qi767DXDwqws3oOB5yzPk4iXWwJojoqpP7FoNj+
 JNM5xCfiLiZ49v87mT46admrXq6+eqwiJe//UMYEPXftjWYgjpNGPQd0P8b2RvBznwRT
 h74LhDCY0N0s87Uv4T1vN2OCpmEZBuYXlcwzXmKY/XtxeKVw28T1TI5ndp/p7CBePNkB
 BNXw==
X-Gm-Message-State: APjAAAUngvRb0jTLTTQ3NKzBgWepKytOKB+hGApumVakv2gnsFPb2DhW
 btzZy36jhNE77z725mq8kqYudxR8r9wwlN9k5AKtY1EzMPI=
X-Google-Smtp-Source: APXvYqyaEmsIhP7Z4nFlCWdzaFgtM2VtRNrQ8kTAkFXSrD41hPb4IJ2TgNDDOzv2Z03FTStyscqbqx5juA/siF1/1ck=
X-Received: by 2002:ab0:14ce:: with SMTP id f14mr18236760uae.50.1553633764223; 
 Tue, 26 Mar 2019 13:56:04 -0700 (PDT)
MIME-Version: 1.0
References: <CAE_L=tC+MTRhyJAUjL7BfbFvJh-t9JhKb4j1zAVbh43VuGENvg@HIDDEN>
In-Reply-To: <CAE_L=tC+MTRhyJAUjL7BfbFvJh-t9JhKb4j1zAVbh43VuGENvg@HIDDEN>
From: Kieran Barry <kieranb@HIDDEN>
Date: Tue, 26 Mar 2019 20:55:51 +0000
Message-ID: <CAE_L=tDNx9AZ_U=vHZg=ButF0ZGcrbdBBTtvf9rLb356GVPy7w@HIDDEN>
Subject: Re: speedbar-expand-line-descendants opens non-descendant tree entries
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000a13e340585058c3d"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::935
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 26 Mar 2019 18:20:35 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--000000000000a13e340585058c3d
Content-Type: text/plain; charset="UTF-8"

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@HIDDEN> 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@HIDDEN
> 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@HIDDEN
EU Directive 2003/58/EC compliance:
Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland
Registered in Dublin, Ireland with # 368047

--000000000000a13e340585058c3d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div>Patch to fix.</div>=
<div><br></div><div>Changelog:</div><div><div>2019-03-26=C2=A0 Kieran Barry=
=C2=A0 &lt;kieranb@....com&gt;</div><div><span style=3D"white-space:pre">	<=
/span>* lisp/speedbar.el: speedbar-expand-line-descendants fixed to only ex=
pand descendants of current node.</div></div><div><br></div><div>diff --git=
 a/lisp/speedbar.el b/lisp/speedbar.el</div><div>index 399ef4557b..81ab8d23=
06 100644</div><div>--- a/lisp/speedbar.el</div><div>+++ b/lisp/speedbar.el=
</div><div>@@ -3271,6 +3271,18 @@ With universal argument ARG, flush cached=
 data.&quot;</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (speedbar-do-function-po=
inter))</div><div>=C2=A0 =C2=A0 =C2=A0(error (speedbar-position-cursor-on-l=
ine))))</div><div>=C2=A0</div><div>+(defun speedbar--get-entry-depth ()</di=
v><div>+=C2=A0 =C2=A0 &quot;Extract the depth parameter from speedbar line.=
</div><div>+Returns depth as a string.</div><div>+Raises error when line do=
esn&#39;t match speedbar format.&quot;</div><div>+=C2=A0 (interactive)</div=
><div>+=C2=A0 (save-match-data</div><div>+=C2=A0 =C2=A0 (save-excursion</di=
v><div>+=C2=A0 =C2=A0 =C2=A0 (beginning-of-line)</div><div>+=C2=A0 =C2=A0 =
=C2=A0 (if (looking-at &quot;\\([0-9]+\\):&quot;)</div><div>+=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 (match-string-no-properties 1)</div><div>+=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 (user-error &quot;Incorrect format for speedbar entry&quo=
t;)))))</div><div>+</div><div>=C2=A0(defun speedbar-expand-line-descendants=
 (&amp;optional arg)</div><div>=C2=A0 =C2=A0&quot;Expand the line under the=
 cursor and all descendants.</div><div>=C2=A0Optional argument ARG indicate=
s that any cache should be flushed.&quot;</div><div>@@ -3279,15 +3291,29 @@=
 Optional argument ARG indicates that any cache should be flushed.&quot;</d=
iv><div>=C2=A0 =C2=A0;; Now, inside the area expanded here, expand all subn=
odes of</div><div>=C2=A0 =C2=A0;; the same descendant type.</div><div>=C2=
=A0 =C2=A0(save-excursion</div><div>-=C2=A0 =C2=A0 (speedbar-next 1) ;; Mov=
e into the list.</div><div>-=C2=A0 =C2=A0 (let ((err nil))</div><div>-=C2=
=A0 =C2=A0 =C2=A0 (while (not err)</div><div>-=C2=A0 =C2=A0 =C2=A0 =C2=A0(c=
ondition-case nil</div><div>-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(prog=
n</div><div>-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(speedbar-expa=
nd-line-descendants arg)</div><div>-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0(speedbar-restricted-next 1))</div><div>-=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0(error (setq err t))))))</div><div>-=C2=A0 )</div><div>+=C2=A0 =
=C2=A0 (let ((starting-depth (speedbar--get-entry-depth)))</div><div>+=C2=
=A0 =C2=A0 =C2=A0 (speedbar-next 1) ;; Move into the list.</div><div>+=C2=
=A0 =C2=A0 =C2=A0 ;; Expand all descendants of the &quot;next entry&quot; p=
rovided they are at</div><div>+=C2=A0 =C2=A0 =C2=A0 ;; depth greater than t=
he initial entry.</div><div>+=C2=A0 =C2=A0 =C2=A0 (speedbar--expand-line-de=
scendants-impl starting-depth)</div><div>+=C2=A0 )))</div><div>+</div><div>=
+(defun speedbar--expand-line-descendants-impl (calling-depth &amp;optional=
 arg)</div><div>+=C2=A0 &quot;Expand the line under the cursor and all desc=
endants recursively.</div><div>+Finish if the line to be expanded is not at=
 the same depth as CALLING-DEPTH.</div><div>+Optional argument ARG indicate=
s that any cache should be flushed.&quot;</div><div>+=C2=A0 (interactive &q=
uot;P&quot;)</div><div>+=C2=A0 (let ((current-depth (speedbar--get-entry-de=
pth)))</div><div>+=C2=A0 =C2=A0 (unless (equal current-depth calling-depth)=
</div><div>+=C2=A0 =C2=A0 =C2=A0 (speedbar-expand-line arg)</div><div>+=C2=
=A0 =C2=A0 =C2=A0 (speedbar-next 1)</div><div>+=C2=A0 =C2=A0 =C2=A0 (let ((=
err nil))</div><div>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (not err)</div><div=
>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (condition-case nil</div><div>+=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn</div><div>+=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (speedbar--expand-line-descendant=
s-impl calling-depth)</div><div>+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 (speedbar-restricted-next 1))</div><div>+=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 (error (setq err t))))))))</div><div>=C2=A0</div><div=
>=C2=A0(defun speedbar-contract-line-descendants ()</div><div>=C2=A0 =C2=A0=
&quot;Expand the line under the cursor and all descendants.&quot;</div><div=
><br></div></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr=
" class=3D"gmail_attr">On Tue, Mar 26, 2019 at 8:28 PM Kieran Barry &lt;<a =
href=3D"mailto:kieranb@HIDDEN">kieranb@HIDDEN</a>&gt; wrote:<br></d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bord=
er-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div =
dir=3D"ltr"><div dir=3D"ltr">Current behaviour:<div>speedbar-expand-line-de=
scendants incorrectly recursively expands all nodes below the current node.=
</div><div><br></div><div>Expected behaviour:</div><div>Should only recursi=
vely expand descendants of the current node.</div><div><br></div><div>Steps=
 to reproduce:</div><div>emacs -Q ~</div><div>M-x speedbar</div><div>&lt;fo=
cus to speedbar&gt;</div><div>&lt;cursor over a directory that is not the l=
ast in list&gt;</div><div>[</div><div><br></div><div>(&quot;[&quot; is boun=
d to `speedbar-expand-line-descendants&#39;)<br clear=3D"all"><div><br></di=
v><div>Found in:=C2=A0GNU Emacs 26.1</div><div><br></div>-- <br><div dir=3D=
"ltr" class=3D"gmail-m_-3919270559352147741gmail_signature"><div dir=3D"ltr=
"><div><span style=3D"font-size:13px">Kieran Barry --=C2=A0<a href=3D"mailt=
o:kieranb@HIDDEN" style=3D"color:rgb(17,85,204)" target=3D"_blank">kier=
anb@HIDDEN</a></span></div><div><span style=3D"font-size:13px">EU Direc=
tive 2003/58/EC compliance:</span></div><div><span style=3D"font-size:13px"=
>Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland</span><=
/div><div><span style=3D"font-size:13px">Registered in Dublin, Ireland with=
 # 368047</span></div></div></div></div></div></div></div>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature"><div dir=3D"ltr"><div><span style=3D"font-size:1=
3px">Kieran Barry --=C2=A0<a href=3D"mailto:kieranb@HIDDEN" style=3D"co=
lor:rgb(17,85,204)" target=3D"_blank">kieranb@HIDDEN</a></span></div><d=
iv><span style=3D"font-size:13px">EU Directive 2003/58/EC compliance:</span=
></div><div><span style=3D"font-size:13px">Google Ireland Ltd., Gordon Hous=
e, Barrow Street, Dublin 4 Ireland</span></div><div><span style=3D"font-siz=
e:13px">Registered in Dublin, Ireland with # 368047</span></div></div></div=
>

--000000000000a13e340585058c3d--




Acknowledgement sent to Kieran Barry <kieranb@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#35014; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 27 Mar 2019 09:15:02 UTC

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