From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Willcock Newsgroups: gmane.emacs.bugs Subject: bug#73533: [PATCH] Rewrite speedbar expansion for all descendants Date: Mon, 30 Sep 2024 10:03:18 +0100 Message-ID: <87wmitfr8p.fsf@ice9.digital> References: <87y13blhu1.fsf@ice9.digital> <86a5fr5apb.fsf@gnu.org> <87v7yeeqig.fsf@ice9.digital> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2104"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 73533@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 30 11:04:54 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1svCKr-0000Oc-TO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Sep 2024 11:04:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svCKW-0006Be-Ra; Mon, 30 Sep 2024 05:04:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svCKU-00065B-Au for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 05:04:30 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svCKU-0003YU-1q for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 05:04:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=c9j6lHEM6M8Cdj2l5kENzQJbKHKkw2qso0xQKsV8Qwc=; b=cOo+UaXnS64Gr0qw22efSeS8Vbt0TaYMrtHsWqGOm59aC+xuPRHRN0dui8iPBePVJ4PisKosuUbxrEF4XSoCxh/BnCyMC6LsiPI7RFUnp15Ck6gw6PYpWerH8SoJBAK/de940q3DyWwHsERrlGOqXBApQKQVcQ/pjitXhu3a8uD1YfVnbqDEXmjJQpgi9aZNodmb7p3QKHoF9gvS0Ka1ohNIGxn1yy7d/Nkp4sckILQCPY2I8OrKQrsGidayAbZHYAVAivBO96kL0DUlS7Bm5BCneJR6Y/dhxuubEsz8UjIYE4o2p76uWtY3mt7uSR40BDvo6XreJb2CYaERuLj03w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1svCL0-00070r-Dj for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 05:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Sep 2024 09:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73533 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73533-submit@debbugs.gnu.org id=B73533.172768706126918 (code B ref 73533); Mon, 30 Sep 2024 09:05:02 +0000 Original-Received: (at 73533) by debbugs.gnu.org; 30 Sep 2024 09:04:21 +0000 Original-Received: from localhost ([127.0.0.1]:44701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svCKL-000706-92 for submit@debbugs.gnu.org; Mon, 30 Sep 2024 05:04:21 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:47913) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svCKI-0006zx-Uv for 73533@debbugs.gnu.org; Mon, 30 Sep 2024 05:04:19 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id A39212000E; Mon, 30 Sep 2024 09:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1727687000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c9j6lHEM6M8Cdj2l5kENzQJbKHKkw2qso0xQKsV8Qwc=; b=Vmm3Szg0y8+53fB5joJWmYfOLOaDZYXVI+vY0KVAAaTkeHABiURG1K+QrR+YdnylSTX/+b ZiKIj3F6kqNE1l4ujpTAADMbtkUO2U2UrMNaRhPES1QkEbIVC7hJD1ikQOt7X+EdCEEChi SHE1rqVuXqldzLrm4TOoPI5a+EE6dhGKhip8yi6Ry3HLxeypqIcRr7dPh3uuvzCbUlZIoX HUt/0sHl1KFeAst+08X2Bjgvmmc4ipmiHDBY6EV9k1bI7sDSy7uUQ/8vbsIriIQI+9iV2p Eaizaow5+vsqXMym/mJXZol4QzxzIuEB0KhGW4Vpr8LgmIFbM09351BAqry3Bg== In-Reply-To: <87v7yeeqig.fsf@ice9.digital> (Morgan Willcock's message of "Sun, 29 Sep 2024 10:52:07 +0100") X-GND-Sasl: morgan@ice9.digital X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292697 Archived-At: --=-=-= Content-Type: text/plain Morgan Willcock writes: > The old code with the fix for bug#35014 narrowed each item recursively > with the narrowing around the top level preventing a top-level sibling > being reached. The change that was made in bug#35014 looks like it broke the expansion when the item was already partially expanded, so attached is a modified version of the patch that completely removes the narrowing-per-item approach and also includes more comments. Thanks, Morgan -- Morgan Willcock --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Rewrite-speedbar-expansion-for-all-descendants.patch >From aa17e562b9844a50b8b01777c83830d3c4ead963 Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Sat, 28 Sep 2024 19:11:11 +0100 Subject: [PATCH] Rewrite speedbar expansion for all descendants Rewrite 'speedbar-expand-line-descendants' to avoid getting into an infinite loop by reaching max-lisp-eval-depth. The new method avoids querying and displaying information for every movement, instead using a single message to indicate that expansion is in progress, and so is significantly faster. The narrowing per item introduced by the fix for bug#35014 is removed because it prevented expanded descendant items when the top-level item was already expanded. * lisp/speedbar.el (speedbar-expand-line-descendants): Use simpler line motion and no recursion. Output messages indicating when expansion is in progress and when it is completed. Fix expansion of descendants where the top-level item was already expanded. --- lisp/speedbar.el | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/lisp/speedbar.el b/lisp/speedbar.el index c13c977938b..723a5595854 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -3172,21 +3172,36 @@ speedbar-expand-line-descendants "Expand the line under the cursor and all descendants. Optional argument ARG indicates that any cache should be flushed." (interactive "P") - (save-restriction - (narrow-to-region (line-beginning-position) - (line-beginning-position 2)) - (speedbar-expand-line arg) - ;; 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)))))))) + (dframe-message "Expanding all descendants...") + (save-excursion + (with-restriction + ;; Narrow around the top-level item to ensure that later sibling + ;; items will not be entered. + (line-beginning-position) + (condition-case nil + (save-excursion + (speedbar-restricted-move 1) + ;; Use the line beginning position of the next sibling + ;; item to apply the restriction. + (line-beginning-position)) + ;; This was the last sibling item so just apply the + ;; restriction to the end of the buffer. This fixes the + ;; change applied in bug#35014 which prevented the top-level + ;; item from having its descendants expanded if it was already + ;; expanded. + (error (point-max))) + ;; Expand every line until the end of the restriction is reached. + (while (zerop (progn + ;; Assume that the line will expand and try to + ;; expand it. + (speedbar-expand-line arg) + ;; Moving forwards will be moving into the + ;; expanded lists if one opened, into an already + ;; expanded list if it was already open, to a + ;; sibling, or to the end of restriction. + (forward-line 1)))))) + (dframe-message "Expanding all descendants...done") + (speedbar-position-cursor-on-line)) (defun speedbar-contract-line-descendants () "Expand the line under the cursor and all descendants." -- 2.39.5 --=-=-=--