From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Kieran Barry Newsgroups: gmane.emacs.bugs Subject: bug#35014: speedbar-expand-line-descendants opens non-descendant tree entries Date: Tue, 26 Mar 2019 20:55:51 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a13e340585058c3d" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="172947"; mail-complaints-to="usenet@blaine.gmane.org" To: 35014@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 26 23:25:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8uVV-000ip0-ON for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Mar 2019 23:25:23 +0100 Original-Received: from localhost ([127.0.0.1]:38708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8uVP-0000SB-Lm for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Mar 2019 18:25:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8uV9-0008Pm-SA for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 18:25:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8uRL-0000Ic-Ar for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 18:21:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h8uRL-0000IW-6o for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 18:21:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h8uRL-0001g4-2Z for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 18:21:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kieran Barry Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Mar 2019 22:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35014 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15536388376379 (code B ref -1); Tue, 26 Mar 2019 22:21:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Mar 2019 22:20:37 +0000 Original-Received: from localhost ([127.0.0.1]:60661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h8uQu-0001ej-Hj for submit@debbugs.gnu.org; Tue, 26 Mar 2019 18:20:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40923) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h8t7J-0007uT-5l for submit@debbugs.gnu.org; Tue, 26 Mar 2019 16:56:17 -0400 Original-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 ) id 1h8t7D-0000C7-Rd for submit@debbugs.gnu.org; Tue, 26 Mar 2019 16:56:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8t7C-0004cT-9n for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 16:56:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8t7A-00009G-Jt for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 16:56:10 -0400 Original-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 ) id 1h8t78-000059-MM for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2019 16:56:08 -0400 Original-Received: by mail-ua1-x935.google.com with SMTP id 46so1091996uan.8 for ; 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) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Tue, 26 Mar 2019 18:20:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156841 Archived-At: --000000000000a13e340585058c3d Content-Type: text/plain; charset="UTF-8" Patch to fix. Changelog: 2019-03-26 Kieran Barry * 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 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 > > > [ > > ("[" 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 --000000000000a13e340585058c3d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Patch to fix.
=

Changelog:
2019-03-26=C2=A0 Kieran Barry= =C2=A0 <kieranb@....com>
<= /span>* lisp/speedbar.el: speedbar-expand-line-descendants fixed to only ex= pand descendants of current node.

diff --git= a/lisp/speedbar.el b/lisp/speedbar.el
index 399ef4557b..81ab8d23= 06 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el=
@@ -3271,6 +3271,18 @@ With universal argument ARG, flush cached= data."
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (speedbar-do-function-po= inter))
=C2=A0 =C2=A0 =C2=A0(error (speedbar-position-cursor-on-l= ine))))
=C2=A0
+(defun speedbar--get-entry-depth ()
+=C2=A0 =C2=A0 "Extract the depth parameter from speedbar line.=
+Returns depth as a string.
+Raises error when line do= esn't match speedbar format."
+=C2=A0 (interactive)
+=C2=A0 (save-match-data
+=C2=A0 =C2=A0 (save-excursion
+=C2=A0 =C2=A0 =C2=A0 (beginning-of-line)
+=C2=A0 =C2=A0 = =C2=A0 (if (looking-at "\\([0-9]+\\):")
+=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (match-string-no-properties 1)
+=C2=A0 =C2= =A0 =C2=A0 =C2=A0 (user-error "Incorrect format for speedbar entry&quo= t;)))))
+
=C2=A0(defun speedbar-expand-line-descendants= (&optional arg)
=C2=A0 =C2=A0"Expand the line under the= cursor and all descendants.
=C2=A0Optional argument ARG indicate= s that any cache should be flushed."
@@ -3279,15 +3291,29 @@= Optional argument ARG indicates that any cache should be flushed."
=C2=A0 =C2=A0;; Now, inside the area expanded here, expand all subn= odes of
=C2=A0 =C2=A0;; the same descendant type.
=C2= =A0 =C2=A0(save-excursion
-=C2=A0 =C2=A0 (speedbar-next 1) ;; Mov= e into the list.
-=C2=A0 =C2=A0 (let ((err nil))
-=C2= =A0 =C2=A0 =C2=A0 (while (not err)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(c= ondition-case nil
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(prog= n
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(speedbar-expa= nd-line-descendants arg)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(speedbar-restricted-next 1))
-=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(error (setq err t))))))
-=C2=A0 )
+=C2=A0 = =C2=A0 (let ((starting-depth (speedbar--get-entry-depth)))
+=C2= =A0 =C2=A0 =C2=A0 (speedbar-next 1) ;; Move into the list.
+=C2= =A0 =C2=A0 =C2=A0 ;; Expand all descendants of the "next entry" p= rovided they are at
+=C2=A0 =C2=A0 =C2=A0 ;; depth greater than t= he initial entry.
+=C2=A0 =C2=A0 =C2=A0 (speedbar--expand-line-de= scendants-impl starting-depth)
+=C2=A0 )))
+
= +(defun speedbar--expand-line-descendants-impl (calling-depth &optional= arg)
+=C2=A0 "Expand the line under the cursor and all desc= endants recursively.
+Finish if the line to be expanded is not at= the same depth as CALLING-DEPTH.
+Optional argument ARG indicate= s that any cache should be flushed."
+=C2=A0 (interactive &q= uot;P")
+=C2=A0 (let ((current-depth (speedbar--get-entry-de= pth)))
+=C2=A0 =C2=A0 (unless (equal current-depth calling-depth)=
+=C2=A0 =C2=A0 =C2=A0 (speedbar-expand-line arg)
+=C2= =A0 =C2=A0 =C2=A0 (speedbar-next 1)
+=C2=A0 =C2=A0 =C2=A0 (let ((= err nil))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (not err)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (condition-case nil
+=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn
+=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (speedbar--expand-line-descendant= s-impl calling-depth)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (speedbar-restricted-next 1))
+=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 (error (setq err t))))))))
=C2=A0
=C2=A0(defun speedbar-contract-line-descendants ()
=C2=A0 =C2=A0= "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-de= scendants incorrectly recursively expands all nodes below the current node.=

Expected behaviour:
Should only recursi= vely expand descendants of the current node.

Steps= to reproduce:
emacs -Q ~
M-x speedbar
<fo= cus to speedbar>
<cursor over a directory that is not the l= ast in list>
[

("[" is boun= d to `speedbar-expand-line-descendants')

Found in:=C2=A0GNU Emacs 26.1

--
Kieran Barry --=C2=A0kier= anb@google.com
EU Direc= tive 2003/58/EC compliance:
Google Ireland Ltd., Gordon House, Barrow Street, Dublin 4 Ireland<= /div>
Registered in Dublin, Ireland with= # 368047


--
Kieran Barry --=C2=A0kieranb@google.com
EU Directive 2003/58/EC compliance:
Google Ireland Ltd., Gordon Hous= e, Barrow Street, Dublin 4 Ireland
Registered in Dublin, Ireland with # 368047
--000000000000a13e340585058c3d--