[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32790: 27.0.50; point jumps unexpectedly after delete-window

From: Juri Linkov
Subject: bug#32790: 27.0.50; point jumps unexpectedly after delete-window
Date: Sun, 18 Nov 2018 00:18:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> Whereas I meant mostly switch-to-buffer as a command bound to 'C-x b',
>> non-interactive calls of 'switch-to-buffer' have the same problem, and
>> maybe some of them could be replaced with 'pop-to-buffer-same-window'
>> without side effects.  One example is 'C-h C-n' (view-emacs-news) that
>> uses switch-to-buffer, and can't be forced into another window.
>> I solved this general problem for myself with such advice:
>> (advice-add 'switch-to-buffer :around
>>              (lambda (orig-fun &rest args)
>>                (let ((buffer (apply orig-fun args))
>>                      (window (selected-window)))
>>                  (switch-to-prev-buffer window)
>>                  (pop-to-buffer-same-window buffer))))
>> Then 'S-M-right C-h C-n' shows it in the right window.
> I don't grok it yet.  What's the 'switch-to-prev-buffer' call for?

switch-to-buffer switches the buffer in the selected window.
switch-to-prev-buffer undoes this, and displays the same buffer
in another window instead.

>> Do you think it's possible to add a corresponding customizable option
>> that would provide the same behavior?
> I would have to understand the "behavior" first.  One approach would
> be to move the user-error and 'switch-to-buffer-preserve-window-point'
> handling into the interactive specification handling and for the rest
> do what 'pop-to-buffer-same-window' does.

Or maybe to add a new option that will allow switch-to-buffer
to use pop-to-buffer-same-window.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]