From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 29 17:06:57 2025 Received: (at submit) by debbugs.gnu.org; 29 Mar 2025 21:06:57 +0000 Received: from localhost ([127.0.0.1]:33213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tydOL-0000bs-0u for submit@debbugs.gnu.org; Sat, 29 Mar 2025 17:06:57 -0400 Received: from lists.gnu.org ([2001:470:142::17]:48004) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tydOH-0000bT-P4 for submit@debbugs.gnu.org; Sat, 29 Mar 2025 17:06:55 -0400 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 1tydOB-0003lN-Fn for bug-gnu-emacs@gnu.org; Sat, 29 Mar 2025 17:06:47 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tydO9-0008NZ-GZ for bug-gnu-emacs@gnu.org; Sat, 29 Mar 2025 17:06:47 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-ac2bb7ca40bso653661666b.3 for ; Sat, 29 Mar 2025 14:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743282403; x=1743887203; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=5OmPEAGF5FAZF2gqT7yvlQtV3bHMLWwm8+xF/qCiOmQ=; b=lz2x2nUcQHLfsizV3YxsavJGV9dqEQ68gijFtm43b/hApALDNcweSYFA9D0XDGCpWq Nvu16I/8pkuhvtsSgK+J1E1slfANg43YD2Cs3oaIvG3MVuEdiYA+KIJNoUa1fcopS7Y1 RDgZKy+lbIqUyokcILcfOOpSbK5sA45MDMUq8V6O1jLez5zYXtlddbyqQsqk1YiTKDyk wH2dk+FZCQTkzczHiLRE/agcU0fYJcPBtXzeaxpzDCsMeGnjrrsa18VvgAH9NF/m6DoC SxR1ABDoBT+6O6maHHBPFLv6/qMgGBVyU3fAz0wmN59K1/064LLVUJk1uhnEOUaKzIP1 dzMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743282403; x=1743887203; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5OmPEAGF5FAZF2gqT7yvlQtV3bHMLWwm8+xF/qCiOmQ=; b=ElBqrO4NwEGBpXX9XqRamkVUbYDuuKVkBavk4PF0rh3Lxy5nwuRVhqwAzBbyUQve+s I9IGhoUio+kSukHy95Fg2dqyU3ugkvX8YbUBieHAwYFcSLOeockgBruFW2d+YAcE5YOG VIZg/xSJAzLCsgyTpN/dzTPawmddcgUYlP1mAMX+Iun6vOxD0yqbkH+qZXbxbC5K3U2I 4u4+PqajTAOswS2aQelr7f1y3sVraPhh5SCpm6OYhEHg5b1QY062ZAfRkTU4zjea+sLi BxEcScXvaws/JWQvHdiMhSbC8kArbRe5FgpkNqNalHGnfmqMHolL2iUu5JHZGfHuDpeb 5EUg== X-Gm-Message-State: AOJu0Yz5T+SmcF0zJQguXwHACy1sxNWFk5ZTZmY56ZeZ6Dy7uWDnBIXc +JjYoD2EPAMNLsGzaxJhUBXXc8kvhpobcB7/ZLu2Tb1eHCDc9yDE/p9M2gA+ X-Gm-Gg: ASbGncsJ8SPWOY7dp+OziP2j4Hj8dJNuB3hqNvpyW04sK43Cw3Kb/8t1jWjAIO6Xvsg 6rThsySbAcABg2CK117N6UgO3mpCVRCJWbS8qWpKxWx4hlXbJoTE8++mydV6FLnymK/i49iPmA0 GJWltaKtLiYNC7huCBNiiEykko92+DTAGP7jgU7Bmnv3nU9DHR6c8UAeJLOna1Z8XxnA66Ig8eO o9N/k/fCqhmBPfbOvY3dU27Tr2I9Q4v3Fx+P16/habyvVX6LSQmMC2ERjnpQSZCUUmLDsSmIUN+ vks4HmOi9Ov7rWUmMweJrnyz2wGi9sdDiq/ZRSH5RdGZs4l8Iam1uE8j21neLrJlI331JL7+5of 18knasXdeDg== X-Google-Smtp-Source: AGHT+IHssCiNAyN8Rvvk618sYNNhhrsiz9Mu+eZRowHYQVsJsKyri5QexSH+BAtHybRxpAI+0f0C2g== X-Received: by 2002:a17:906:6a0b:b0:ac3:8aa0:9d70 with SMTP id a640c23a62f3a-ac738c6efc4mr282064466b.51.1743282402641; Sat, 29 Mar 2025 14:06:42 -0700 (PDT) Received: from localhost (0x573d6713.static.cust.fastspeed.dk. [87.61.103.19]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac71961f8b7sm382387066b.121.2025.03.29.14.06.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Mar 2025 14:06:42 -0700 (PDT) From: "Paul D. Nelson" To: bug-gnu-emacs@gnu.org Subject: [PATCH] Improve foldout-exit-fold behavior with negative argument Date: Sat, 29 Mar 2025 22:06:40 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=ultrono@gmail.com; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain The foldout-* commands, available in outline-minor-mode, give a way to zoom in and out of "folds", which are subtrees defined by the outline structure. To follow along with this email, start by doing foldout-zoom-subtree (C-c @ C-z) on a subtree (e.g., an elisp defun). By default, foldout-exit-fold (C-c @ C-x) exits one fold, hides the text that was in that fold (outline-hide-subtree), moves point to the heading, and recenters. When invoked with a negative prefix argument like C-- C-c @ C-x, the command instead (1) exits one fold without hiding the text, (2) moves point to the bottom of the fold, and (3) recenters. I think that better behavior would be to skip steps (2) and (3), so that the point stays put and the window view does not change. [Step (2) seems incidental rather than by design, so "skip" really means "counter".] Advantages of omitting (2) are: - We don't lose our place when zooming out. - If we zoom in and zoom out (C-c @ C-z, C-- C-c @ C-x), then point doesn't move. - Consistency with other outline/foldout commands that preserve "point being on a heading". Regarding (3), recentering helps us reorient when hiding an exited fold, but is disruptive when the text remains visible. We retain the flexibility to imitate the old behavior using M-> and C-l. The change could be guarded by a defcustom, but it seems to me like a clear improvement. I'd be happy to learn if I missed some scenario where it is not. Any feedback would be welcome. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Improve-foldout-exit-fold-with-negative-arg.patch >From a384ca50aeb65c976df6e536d54f96acf1d143d2 Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Sat, 29 Mar 2025 19:07:13 +0100 Subject: [PATCH] Improve foldout-exit-fold with negative arg * lisp/foldout.el (foldout-exit-fold): When called with a negative prefix argument (so that the exited fold is not hidden), preserve the position of point and do not recenter. --- etc/NEWS | 5 +++++ lisp/foldout.el | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1bd2fd6d486..7a3419ee59a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1367,6 +1367,11 @@ string instead of preprending it and 'tmm-mid-prompt' to said entry. ** Foldout +*** Improved behavior of 'foldout-exit-fold' with negative prefix argument. +When 'foldout-exit-fold' is called with a negative argument (so that the +exited fold remains visible), the position of point and window view are +preserved. + --- *** New command 'foldout-widen-to-current-fold'. This command widens the view to the current fold level when in a fold, diff --git a/lisp/foldout.el b/lisp/foldout.el index fcc5e294561..748f56c0c9c 100644 --- a/lisp/foldout.el +++ b/lisp/foldout.el @@ -290,10 +290,10 @@ foldout-exit-fold "Return to the ARG'th enclosing fold view. With ARG = 0 exit all folds. Normally causes exited folds to be hidden, but with ARG < 0, -ARG folds are -exited and text is left visible." +exited, text is left visible, and point position is preserved." (interactive "p") (let ((hide-fold t) start-marker end-marker - beginning-of-heading end-of-subtree) + beginning-of-heading end-of-subtree (original-point (point))) ;; check there are some folds to leave (if (null foldout-fold-list) @@ -369,7 +369,10 @@ foldout-exit-fold (if end-marker (1- (marker-position end-marker)) (point-max))))) - (recenter) + + (if hide-fold + (recenter) + (goto-char original-point)) ;; update the mode line (foldout-update-mode-line))) -- 2.39.3 (Apple Git-145) --=-=-=--