]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'ediff-before-setup-hook'
authorEli Zaretskii <eliz@gnu.org>
Sat, 5 Jul 2025 08:07:29 +0000 (11:07 +0300)
committerEshel Yaron <me@eshelyaron.com>
Wed, 23 Jul 2025 20:20:15 +0000 (22:20 +0200)
* lisp/vc/ediff-util.el
(ediff-clone-buffer-for-region-comparison): Wrap body in
'save-window-excursion', to make sure original window
configuration is restored after quitting 'ediff-regions-linewise'.
Suggested by Aaron Zeng <azeng@janestreet.com>.  (Bug#78897)

(cherry picked from commit 34dad30e49e4d7768d74f2d32544845a893b0796)

lisp/vc/ediff-util.el

index d80b79ee1c7cdec254cd25113021fa0f79cfa8bb..61e90e52bb4d6913a9c77efae744e5acd0c7164b 100644 (file)
@@ -3220,46 +3220,47 @@ Without an argument, it saves customized diff argument, if available
 
 ;; idea suggested by Hannu Koivisto <azure@iki.fi>
 (defun ediff-clone-buffer-for-region-comparison (buff region-name)
-  (let ((cloned-buff (ediff-make-cloned-buffer buff region-name))
-       (pop-up-windows t)
-       wind
-       other-wind
-       msg-buf)
-    (ediff-with-current-buffer cloned-buff
-      (setq ediff-temp-indirect-buffer t))
-    (pop-to-buffer cloned-buff)
-    (setq wind (ediff-get-visible-buffer-window cloned-buff))
-    (when (window-live-p wind)
-      (select-window wind)
-      (delete-other-windows))
-    (or (mark) (push-mark))
-    (setq mark-active 'ediff-util)
-    (setq-local transient-mark-mode t)
-    (split-window-vertically)
-    (ediff-select-lowest-window)
-    (setq other-wind (selected-window))
-    (with-temp-buffer
-      (erase-buffer)
-      (insert
-       (format "\n   *******  Mark a region in buffer %s (or confirm the existing one)  *******\n"
-              (buffer-name cloned-buff)))
-      (insert
-       (ediff-with-current-buffer buff
-        (format "\n\t      When done, type %s       Use %s to abort\n    "
-                (ediff-format-bindings-of 'exit-recursive-edit)
-                (ediff-format-bindings-of 'abort-recursive-edit))))
-      (goto-char (point-min))
-      (setq msg-buf (current-buffer))
-      (set-window-buffer other-wind msg-buf)
-      (shrink-window-if-larger-than-buffer)
-      (if (window-live-p wind)
-         (select-window wind))
-      (condition-case nil
-         (recursive-edit)
-       (quit
-        (ediff-kill-buffer-carefully cloned-buff)))
-      )
-    cloned-buff))
+  (save-window-excursion
+    (let ((cloned-buff (ediff-make-cloned-buffer buff region-name))
+         (pop-up-windows t)
+         wind
+         other-wind
+         msg-buf)
+      (ediff-with-current-buffer cloned-buff
+                                 (setq ediff-temp-indirect-buffer t))
+      (pop-to-buffer cloned-buff)
+      (setq wind (ediff-get-visible-buffer-window cloned-buff))
+      (when (window-live-p wind)
+        (select-window wind)
+        (delete-other-windows))
+      (or (mark) (push-mark))
+      (setq mark-active 'ediff-util)
+      (setq-local transient-mark-mode t)
+      (split-window-vertically)
+      (ediff-select-lowest-window)
+      (setq other-wind (selected-window))
+      (with-temp-buffer
+        (erase-buffer)
+        (insert
+         (format "\n   *******  Mark a region in buffer %s (or confirm the existing one)  *******\n"
+                (buffer-name cloned-buff)))
+        (insert
+         (ediff-with-current-buffer buff
+                                   (format "\n\t      When done, type %s       Use %s to abort\n    "
+                                           (ediff-format-bindings-of 'exit-recursive-edit)
+                                           (ediff-format-bindings-of 'abort-recursive-edit))))
+        (goto-char (point-min))
+        (setq msg-buf (current-buffer))
+        (set-window-buffer other-wind msg-buf)
+        (shrink-window-if-larger-than-buffer)
+        (if (window-live-p wind)
+           (select-window wind))
+        (condition-case nil
+           (recursive-edit)
+         (quit
+          (ediff-kill-buffer-carefully cloned-buff)))
+        )
+      cloned-buff)))
 
 
 (defun ediff-clone-buffer-for-window-comparison (buff wind region-name)