From: "Göktuğ Kayaalp" <self@gkayaalp.com>
To: martin rudalics <rudalics@gmx.at>
Cc: eliz@gnu.org, emacs-devel@gnu.org
Subject: Re: Potential bug in the logic of rmail-select-summary
Date: Wed, 20 Jan 2021 17:09:44 +0300 [thread overview]
Message-ID: <87zh13wvh3.fsf@gkayaalp.com> (raw)
In-Reply-To: <27bf2070-6c72-afb9-dbc8-c1855470123b@gmx.at> (message from martin rudalics on Tue, 19 Jan 2021 20:04:33 +0100)
On 2021-01-19 20:04 +01, martin rudalics <rudalics@gmx.at> wrote:
> >> AFAIU rmail-pop-to-buffer could use some form of display-buffer-* to
> >> avoid going through display-buffer-alist.
> An overriding action? That's much too severe.
> > Yes, but I'm not sure we should prevent users from customizing the
> > way Rmail buffers are displayed.
> Rmail is free to do what it wants in this regard. But
>
> (".*" . (display-buffer-same-window))
>
> is a much too strong customization IMO. It conflates 'pop-to-buffer'
> with its standard "pop to a window other than the selected one even if
> the buffer is already displayed in the selected window" behavior with
> 'switch-to-buffer'. Don't do that - it may miss too many cases.
Martin and Eli, thanks for your help and sorry for this non-issue. I
had this problem for more than a couple years now, and I was having some
problems with some Magit commands too, should’ve figured it out by now.
But also, it seems to me that how Rmail uses (rmail-)pop-to-buffer is
somewhat problematic regardless because Rmail uses it as part of its
logic sometimes and apparently that results in multiple calls to that
function per command. I tested some configs and appended the results
below, tho I’m again not sure if it’s expected behaviour or some bug.
Best,
-gk.
Appendix: Testing various configs with rmail-summary and display-buffer-alist.
This config in emacs -Q results in a vertical split, both windows
displaying the summary buffer, after hitting ‘h’ in an Rmail buffer:
(setq
display-buffer-alist
'(((lambda (b _) (eq (with-current-buffer b major-mode) 'rmail-summary-mode))
.
(display-buffer-below-selected))))
When I instead try this one:
(setq
display-buffer-alist
'(((lambda (b _) (eq (with-current-buffer b major-mode) 'rmail-summary-mode))
.
(display-buffer-at-bottom . ((inhibit-same-window . t))))))
(with or without the alist, summary buffer replaces the Rmail buffer. A
more sophisticated config which is what I’d actually like to have
behaves a bit more weirdly:
(setq
display-buffer-alist
'(((lambda (b _) (eq (with-current-buffer b major-mode) 'rmail-summary-mode))
.
(gk-display-buffer-for-rmail))))
(defun gk-display-buffer-for-rmail (buffer _)
(if (= (length (window-list)) 1)
(display-buffer-in-direction buffer '((direction . left)))
;; If there are 1+ windows, use the top quarter of selected
;; window.
(split-window-vertically (/ (window-height) 4))
(switch-to-buffer buffer)))
if I have a vertical split, this happens:
[ some buffer ][ rmail ] -> [ some buffer ][ rmail-summary ]
[ rmail-summary ]
[ rmail ]
instead of expected
[ some buffer ][ rmail ] -> [ some buffer ][ rmail-summary ]
[ rmail ]
and if rmail window was the only window, I get
[ rmail-summary ][ rmail-summary ]
This is apparently because rmail-summary (and rmail-quit, too) end up
calling rmail-pop-to-buffer multiple times, somehow. I verified that
with calling toggle-debug-on-entry on the function: with rmail-summary I
need to hit ‘c’ in the debugger 4 times for the command to complete.
I tried the following more elaborate setup:
(require 'cl-lib)
(setq
display-buffer-alist
'(((lambda (b _) (eq (with-current-buffer b major-mode) 'rmail-summary-mode))
.
(gk-display-buffer-for-rmail))))
(defun gk-display-buffer-for-rmail (buffer _)
;; If the summary buffer is displayed, just go to it
(if-let* ((sumw (car (cl-remove-if
#'null
(mapcar (lambda (w)
(and (eq 'rmail-summary-mode
(buffer-local-value 'major-mode (window-buffer w)))
w))
(window-list))))))
(select-window sumw)
;; Otherwise, if frame has only 1 window...
(if (= (length (window-list)) 1)
;; (a) ...split it in two, otherwise...
(split-window-horizontally (/ (window-width) 2))
;; (b) ...create a 1/4 split above the selected window, ...
(split-window-vertically (/ (window-height) 4)))
;; ...eventually, display ‘buffer’.
(switch-to-buffer buffer)))
This helps with the multiple summary windows problem, but while (b) case
works as expected, (a) results in a single window displaying the summary
buffer, which is weird. I thought what rmail-pop-to-buffer does has
some effect here, but the following works fine:
(let (split-width-threshold)
(split-window-horizontally (/ (window-width) 2)))
next prev parent reply other threads:[~2021-01-20 14:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 12:23 Potential bug in the logic of rmail-select-summary Göktuğ Kayaalp
2021-01-19 14:50 ` Eli Zaretskii
2021-01-19 17:14 ` Göktuğ Kayaalp
2021-01-19 18:33 ` Eli Zaretskii
2021-01-19 19:04 ` martin rudalics
2021-01-20 14:09 ` Göktuğ Kayaalp [this message]
2021-01-20 16:51 ` martin rudalics
2021-01-27 23:23 ` Göktuğ Kayaalp
2021-01-28 9:42 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zh13wvh3.fsf@gkayaalp.com \
--to=self@gkayaalp.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).