all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#20206: 25.0.50; [PATCH] keep diff-mode's window visible when we visit sources from diff-mode
@ 2015-03-26 18:25 Dima Kogan
  2015-03-26 18:41 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Dima Kogan @ 2015-03-26 18:25 UTC (permalink / raw)
  To: 20206

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

When looking at a patch in diff-mode, one can visit the sources being
patched with several functions, for instance (diff-goto-source). This
patch makes sure that the source buffer does not cover up the diff-mode
buffer in its window, but uses any other window instead.

This really is a continuation of bug 20034 (and 17675 and 19901). I feel
like the earlier display-buffer implementation had a nicer default in
this regard. Should we keep adding this patch wherever a user operation
on a buffer can cause a different buffer to be displayed, or should
display-buffer defaults be changed to make the "don't steal user's
focus" behavior the default?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-keep-diff-mode-s-window-visible-when-we-visit-source.patch --]
[-- Type: text/x-diff, Size: 2784 bytes --]

From fa88533777a500784cb5def1733aa182c6bd4135 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Thu, 26 Mar 2015 11:21:06 -0700
Subject: [PATCH] keep diff-mode's window visible when we visit sources from
 diff-mode

When looking at a patch in diff-mode, one can visit the sources being
patched with several functions, for instance (diff-goto-source).  This
patch makes sure that the source buffer does not cover up the
diff-mode buffer in its window, but uses any other window instead
---
 lisp/vc/diff-mode.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index a9614e9..15cdae9 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1318,7 +1318,7 @@ See `after-change-functions' for the meaning of BEG, END and LEN."
   ;; Select a window that displays the current buffer so that point
   ;; movements are reflected in that window.  Otherwise, the user might
   ;; never see the hunk corresponding to the source she's jumping to.
-  (pop-to-buffer (current-buffer))
+  (pop-to-buffer (current-buffer) '(display-buffer-use-some-window (inhibit-same-window . t)))
   (if reset (goto-char (point-min)))
   (diff-hunk-next arg)
   (diff-goto-source))
@@ -1801,7 +1801,7 @@ With a prefix argument, REVERSE the hunk."
 	(delete-region (car pos) (cdr pos))
 	(insert (car new)))
       ;; Display BUF in a window
-      (set-window-point (display-buffer buf) (+ (car pos) (cdr new)))
+      (set-window-point (display-buffer buf '(display-buffer-use-some-window (inhibit-same-window . t))) (+ (car pos) (cdr new)))
       (diff-hunk-status-msg line-offset (diff-xor switched reverse) nil)
       (when diff-advance-after-apply-hunk
 	(diff-hunk-next))))))
@@ -1813,7 +1813,7 @@ With a prefix argument, try to REVERSE the hunk."
   (interactive "P")
   (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched)
                (diff-find-source-location nil reverse)))
-    (set-window-point (display-buffer buf) (+ (car pos) (cdr src)))
+    (set-window-point (display-buffer buf '(display-buffer-use-some-window (inhibit-same-window . t))) (+ (car pos) (cdr src)))
     (diff-hunk-status-msg line-offset (diff-xor reverse switched) t)))
 
 
@@ -1843,7 +1843,7 @@ then `diff-jump-to-old-file' is also set, for the next invocations."
   (let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))
     (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched)
                  (diff-find-source-location other-file rev)))
-      (pop-to-buffer buf)
+      (pop-to-buffer buf '(display-buffer-use-some-window (inhibit-same-window . t)))
       (goto-char (+ (car pos) (cdr src)))
       (diff-hunk-status-msg line-offset (diff-xor rev switched) t))))
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread
* Re: Re: Change in list-buffers behavior in 24.4
@ 2015-04-13 12:14 martin rudalics
  2015-04-13 14:34 ` bug#20206: 25.0.50; [PATCH] keep diff-mode's window visible when we visit sources from diff-mode Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: martin rudalics @ 2015-04-13 12:14 UTC (permalink / raw)
  To: mrsam; +Cc: help-gnu-emacs

 > The change in behavior is when there are already two buffers being shown, with different files. So, with two files, a and b:
 >
 >
 > $ emacs -Q a b
 >
 > I get just "b" displayed.
 >
 > ^X^B^Xo, cursor down, Enter.
 >
 > I get the "b" file in the top window, "a" file in the bottom window, with the cursor in the "a" file's window.
 >
 >
 > ^X^B
 >
 > The buffer window now replaces the "a" file, where the cursor was, and the cursor now winds up in the buffer list window. That's the different behavior than what I'm used to.
 >
 >
 > Now, if instead of doing ^X^B at this point, I press ^Xo, moving the cursor back to the "b" file's window, then ^X^B still opens the list buffer in the "a" file's window (also).
 >
 >
 > So, maybe the change in behavior is that list-buffers' window is "sticky", and it tries to open the buffer window in the same window it was previously shown in, apparently. If that window is showing another file buffer, even if the cursor is still in that file buffer the buffer list window still gets opened there, replacing the buffer the cursor was in.
 >
 >
 > So, depending on window history, ^X^B ends up either opening the buffer list window in some other window, than the one the cursor is currently in, or the same window where the cursor is. I'm pretty sure that in earlier versions of emacs, ^X^B never opened the list buffer in the same window the cursor was, at the time the list-buffers command was executed.
 >
 >
 > And that's where my muscle memory is failing me now. I'm used to having multiple windows open; and with the cursor in one of them, ^X^B opening the buffer in some other window, and then typing ^Xo to jump into the buffer list window. Now, depending on where the buffer-list window was previously shown, it will now open in the same window with the cursor, and I realize belatedly, after I already jumped somewhere else with ^Xo.

Your explanation is correct.  The behavior is intended as a feature but
inherently breaks the behavior of `pop-to-buffer', especially when used
interactively.  I intend to fix this soonish for Emacs 25 and also post
a simple workaround you can use for Emacs 24.4.

Kindly add your observations to this thread

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20206

so we can discuss the solution there.

And please use our conventional notation for key bindings.  That is,
write C-x C-b C-x o instead of ^X^B^Xo and RET instead of ENTER.

Thanks, martin



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-06-25 18:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-26 18:25 bug#20206: 25.0.50; [PATCH] keep diff-mode's window visible when we visit sources from diff-mode Dima Kogan
2015-03-26 18:41 ` Eli Zaretskii
2015-03-26 18:58 ` martin rudalics
2015-03-28  6:01   ` Dima Kogan
2015-03-28  9:58     ` martin rudalics
2015-03-28 21:44       ` Dima Kogan
2015-03-29 18:00         ` martin rudalics
2015-03-29 20:06           ` Dima Kogan
2015-03-30  8:37             ` martin rudalics
2015-03-28 21:53   ` Dima Kogan
2015-03-29 18:01     ` martin rudalics
2015-03-29 19:48       ` Dima Kogan
2015-03-30  8:37         ` martin rudalics
2019-06-25 17:33 ` Lars Ingebrigtsen
2019-06-25 18:10   ` Dima Kogan
  -- strict thread matches above, loose matches on Subject: below --
2015-04-13 12:14 Re: Change in list-buffers behavior in 24.4 martin rudalics
2015-04-13 14:34 ` bug#20206: 25.0.50; [PATCH] keep diff-mode's window visible when we visit sources from diff-mode Eli Zaretskii
2015-04-14 15:51   ` martin rudalics

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.