From: Sean Whitton Date: Mon, 28 Apr 2025 12:45:44 +0000 (+0800) Subject: log-edit-diff-function leaves the diff-mode buffer's window selected X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ccc12ffdf1c8fd35dc347d7d764480504c7488d3;p=emacs.git log-edit-diff-function leaves the diff-mode buffer's window selected This reverts the following two changesets: Author: Sean Whitton AuthorDate: Tue Oct 29 09:40:02 2024 +0800 Fix window selection after log-edit-show-diff Author: Sean Whitton AuthorDate: Tue Apr 8 20:36:42 2025 +0800 Fix window selection after log-edit-show-diff, again This also replaces the following changeset: Author: Sean Whitton AuthorDate: Tue Oct 29 12:52:20 2024 +0800 * lisp/vc/log-edit.el (log-edit-diff-function): Document. * lisp/vc/log-edit.el (log-edit-diff-function): Document that the function *should* leave the window selected when it returns. (log-edit-diff-fileset): * lisp/vc/vc.el (vc-modify-change-comment): Don't use save-selected-window (bug#77946). (vc-diff-patch-string): Call pop-to-buffer, not display-buffer (bug#77946). (cherry picked from commit d44c87ceb6dc7e85ccfecf47f52f8495e34c1d0b) --- diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index 19cf1a5ae3d..508b4e41d68 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -250,8 +250,8 @@ when this variable is set to nil.") (lambda () (error "Diff functionality has not been set up")) "Function to display an appropriate `diff-mode' buffer for the change. Called by the `log-edit-show-diff' command. -Should not leave the `diff-mode' buffer's window selected; that is, the -Log Edit buffer's window should be selected when the function returns.") +The function should display the buffer in a window and leave that window +selected when it returns, probably by calling `pop-to-buffer'.") (defvar log-edit-listfun nil) (defvar log-edit-parent-buffer nil) @@ -857,8 +857,7 @@ comment history, see `log-edit-comment-ring', and hides `log-edit-files-buf'." (defun log-edit-diff-fileset () "Display diffs for the files to be committed." (interactive) - (save-selected-window - (vc-diff nil nil (list log-edit-vc-backend vc-log-fileset)))) + (vc-diff nil nil (list log-edit-vc-backend vc-log-fileset))) (defun log-edit-show-diff () "Show the diff for the files to be committed." diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index bd25e94c391..67ac17c5e4a 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2061,7 +2061,7 @@ in the output buffer." (setq-local revert-buffer-function (lambda (_ _) (vc-diff-patch-string patch-string))) (setq-local vc-patch-string patch-string) - (display-buffer (current-buffer)) + (pop-to-buffer (current-buffer)) (vc-run-delayed (vc-diff-finish (current-buffer) nil)))) (defun vc-diff-internal (async vc-fileset rev1 rev2 &optional verbose buffer) @@ -2639,9 +2639,8 @@ the variable `vc-BACKEND-header'." (prevrev (vc-call-backend backend 'previous-revision rootdir rev))) - (save-selected-window - (vc-diff-internal nil (list backend (list rootdir)) - prevrev rev))))))) + (vc-diff-internal nil (list backend (list rootdir)) + prevrev rev)))))) ;;;###autoload (defun vc-merge ()