From unknown Thu Aug 14 21:47:34 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78897 <78897@debbugs.gnu.org> To: bug#78897 <78897@debbugs.gnu.org> Subject: Status: Ediff 2.81.6; Window restoration with ediff-before-setup-hook doesn't work for ediff-regions-linewise Reply-To: bug#78897 <78897@debbugs.gnu.org> Date: Fri, 15 Aug 2025 04:47:34 +0000 retitle 78897 Ediff 2.81.6; Window restoration with ediff-before-setup-hook= doesn't work for ediff-regions-linewise reassign 78897 emacs submitter 78897 Aaron Zeng severity 78897 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 25 16:41:10 2025 Received: (at submit) by debbugs.gnu.org; 25 Jun 2025 20:41:10 +0000 Received: from localhost ([127.0.0.1]:39650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uUWvc-0002xf-9f for submit@debbugs.gnu.org; Wed, 25 Jun 2025 16:41:10 -0400 Received: from lists.gnu.org ([2001:470:142::17]:60262) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uUWvY-0002vl-W1 for submit@debbugs.gnu.org; Wed, 25 Jun 2025 16:41:06 -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 1uUWvT-000062-L4 for bug-gnu-emacs@gnu.org; Wed, 25 Jun 2025 16:40:59 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uUWvP-0003h9-1o for bug-gnu-emacs@gnu.org; Wed, 25 Jun 2025 16:40:58 -0400 From: Aaron Zeng To: kifer@cs.stonybrook.edu, bug-gnu-emacs@gnu.org Subject: Ediff 2.81.6; Window restoration with ediff-before-setup-hook doesn't work for ediff-regions-linewise Date: Wed, 25 Jun 2025 16:40:51 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1750884051; bh=hAw/9hqxlcjbsf0S11G6FaKeLeqFZm1MFgB9p6Ct4WU=; h=From:To:Cc:Subject:Date; b=k9wMyoP+3pSEFyKmyZOCsqGM+mJdseTf5mWzdRMK6TTjnWCcJHmMbrKeCGc4wd8Hl Bf8fEQm1MuRzs72mZnKgpgVRTTdm6DByWa7MVSzkeTSOWxh6U26SDWTOdNILUcZuXZ 6GVc7pWOBzBwp5DY0KKhlvXgHRWlNIXqEW5wWobGENNxzUjfmdgjyU0Bm4R/itITM1 X4Dc14x8smnJQakBNJfpwaTNHnjK/SNhNoPTX2oTFV/1K8j89V21jg9NXXTCytjwAj I2I+holrk7UyJbrGGVVfmBsEMKDOd8TlJd6n8XbXV0wZXT6kx3U//6uuKdGcBkryRc SEfiDSXKy2OFg== Received-SPF: pass client-ip=64.215.233.18; envelope-from=azeng@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: app-emacs-dev@janestreet.com 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.1 (/) ediff-before-setup-hook's docstring suggests using it to save and restore the window configuration prior to invoking an Ediff command. Users at my site have an equivalent to the following hooks: (defvar my-saved-window-configuration nil) (add-hook 'ediff-before-setup-hook (lambda () (setq my-saved-window-configuration (current-window-configuration)))) (add-hook 'ediff-quit-hook (lambda () (set-window-configuration my-saved-window-configuration) (setq my-saved-window-configuration nil))) This works fine for most Ediff commands but does not work correctly with ediff-regions-linewise and ediff-regions-wordwise. You can reproduce the behavior from emacs -Q: 1. emacs -Q 2. Evaluate the above snippet 3. M-x ediff-regions-linewise (select an arbitrary pair of buffers and regions like selecting *scratch* twice) 4. Press q After quitting, the original window configuration is not restored. In particular, the window is split vertically with a short window below the selected taller one. I believe this is because those commands use ediff-clone-buffer-for-region-comparison to prompt for regions as diff input, and that involves adjusting the window configuration a few times. The following patch seems to fix the behavior (edited to remove the indentation diff for brevity): diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el index a2c9b6f50ec..16878cf779f 100644 --- a/lisp/vc/ediff-util.el +++ b/lisp/vc/ediff-util.el @@ -3247,6 +3247,7 @@ ediff-save-buffer ;; idea suggested by Hannu Koivisto (defun ediff-clone-buffer-for-region-comparison (buff region-name) + (save-window-excursion (let ((cloned-buff (ediff-make-cloned-buffer buff region-name)) (pop-up-windows t) wind @@ -3285,7 +3286,7 @@ ediff-clone-buffer-for-region-comparison (quit (ediff-kill-buffer-carefully cloned-buff))) ) - cloned-buff)) + cloned-buff))) (defun ediff-clone-buffer-for-window-comparison (buff wind region-name) The generated output below reflects my site's actual default config, but the reproduction steps above work with Emacs's defaults. Emacs : GNU Emacs 30.1.90 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2025-06-25 Package: Ediff 2.81.6 current state: ============== (setq ediff-diff-program "diff" ediff-diff-options "" ediff-diff3-program "diff3" ediff-diff3-options "" ediff-patch-program "patch" ediff-patch-options "-f" ediff-shell "sh" ediff-use-faces t ediff-auto-refine 'on ediff-highlighting-style 'face ediff-buffer-A nil ediff-buffer-B nil ediff-control-buffer nil ediff-forward-word-function 'ediff-forward-word ediff-control-frame nil ediff-control-frame-parameters '((name . "Ediff") (minibuffer) (user-position . t) (vertical-scroll-bars) (menu-bar-lines . 0) (tool-bar-lines . 0) (left-fringe . 0) (right-fringe . 0) (auto-lower) (auto-raise . t) (visibility) (width . 1) (height . 1) (fullscreen) (top . 4321) (left . 3841)) ediff-control-frame-position-function 'ediff-make-frame-position ediff-prefer-iconified-control-frame nil ediff-window-setup-function 'ediff-setup-windows-plain ediff-split-window-function 'split-window-horizontally ediff-job-name nil ediff-word-mode nil ediff-buffer-name " *ediff-message*" window-system 'x ) From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 05 04:09:20 2025 Received: (at 78897-done) by debbugs.gnu.org; 5 Jul 2025 08:09:21 +0000 Received: from localhost ([127.0.0.1]:39475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uXxxY-0007RJ-8v for submit@debbugs.gnu.org; Sat, 05 Jul 2025 04:09:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57828) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uXxxV-0007QD-DF for 78897-done@debbugs.gnu.org; Sat, 05 Jul 2025 04:09:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uXxxP-0007F9-G3; Sat, 05 Jul 2025 04:09:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9bQFrJvMewHXYw7w0MLf2P1QjfXguiNI0RNLUyosOmk=; b=ZrKGU5dRSOFW suT6HaV+qZKbhW2+4yD0otHAsSjlMDOHn0FXJZAh3FIxtC0cv4M+eP4Jz8CEdmx8bLyZelF2u9bSP WLv8z7XhZRxQ426FZxjx2RUHxDFV4ZBxRjTXzgxpww/6UorpuKAM/VKl1Z2YK/Rz7WiK7gafkH++N mwvH7R/b+cAtRXlMWtVOVsJWhJf4ZjQ9AcY7vJakAhvTzeXVUbysWiHNLzq9KF1+9cwpAwZbdhUvg X1OJhdgrdCt6BBrCg+GA1BSjamHPAyNIshwC+ZNbMIDp5U4GF6LPWoOUEtEv3GfQcje4egDmkcaMu yNwR03IjLRvi2jEH5L5VRQ==; Date: Sat, 05 Jul 2025 11:09:03 +0300 Message-Id: <86ldp3vz34.fsf@gnu.org> From: Eli Zaretskii To: Aaron Zeng In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#78897: Ediff 2.81.6; Window restoration with ediff-before-setup-hook doesn't work for ediff-regions-linewise References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78897-done Cc: kifer@cs.stonybrook.edu, app-emacs-dev@janestreet.com, 78897-done@debbugs.gnu.org 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: -3.3 (---) > Cc: app-emacs-dev@janestreet.com > Date: Wed, 25 Jun 2025 16:40:51 -0400 > From: Aaron Zeng via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > ediff-before-setup-hook's docstring suggests using it to save and > restore the window configuration prior to invoking an Ediff command. > Users at my site have an equivalent to the following hooks: > > (defvar my-saved-window-configuration nil) > (add-hook 'ediff-before-setup-hook > (lambda () > (setq my-saved-window-configuration (current-window-configuration)))) > (add-hook 'ediff-quit-hook > (lambda () > (set-window-configuration my-saved-window-configuration) > (setq my-saved-window-configuration nil))) > > This works fine for most Ediff commands but does not work correctly > with ediff-regions-linewise and ediff-regions-wordwise. You can > reproduce the behavior from emacs -Q: > > 1. emacs -Q > 2. Evaluate the above snippet > 3. M-x ediff-regions-linewise (select an arbitrary pair of buffers and > regions like selecting *scratch* twice) > 4. Press q > > After quitting, the original window configuration is not restored. In > particular, the window is split vertically with a short window below > the selected taller one. > > I believe this is because those commands use > ediff-clone-buffer-for-region-comparison to prompt for regions as diff > input, and that involves adjusting the window configuration a few > times. The following patch seems to fix the behavior (edited to > remove the indentation diff for brevity): Thanks, I've now installed this on the master branch, and I'm therefore closing this bug. From unknown Thu Aug 14 21:47:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 02 Aug 2025 11:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator