unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Potential bug in the logic of rmail-select-summary
@ 2021-01-19 12:23 Göktuğ Kayaalp
  2021-01-19 14:50 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Göktuğ Kayaalp @ 2021-01-19 12:23 UTC (permalink / raw)
  To: Emacs devel

Hello,

When both an Rmail buffer and it’s summary buffer are displayed
simultaneously, when something triggers rmail-show-message when
navigating inside the Rmail buffer, the Rmail buffer is replaced with
the summary buffer.  E.g., assume we have an mbox called ‘current’, and
‘X’ is the active cursor:

1. window setup: [ current-summary ] [ current X ]
2. hit ‘n’, i.e. rmail-next-undeleted-message
3. resulting window setup: [ current-summary ] [ current-summary X ]

This is not the case when ‘current’ is the sole buffer, when I navigate
messages the window keeps on displaying ‘current’ as expected.

rmail-next-undeleted-message calls rmail-show-message which triggers
rmail-select-summary, which has the following logic in it:

- if rmail-summary-displayed
  - rmail-pop-to-buffer rmail-summary-buffer ...
- else
  - with-current-buffer rmail-summary-buffer ...

Which IMHO is the opposite of what needs to happen.  If the summary
buffer is already displayed, why pop to it again?

When I flip the then and else clauses around like below, it behaves like
I expect it to.  Tho I’m not sure if the original behaviour is actually
wrong or not.  Am I not understanding what it’s supposed to do, or is
this a bug?

One caveat of my little ‘fix’ is the point is not updated in the summary
buffer, which results in the annoying behaviour where when I switch to
the summary buffer highlighted msg is not the one in the rmail buffer
but the last one I moved to in the summary buffer.

FWIW the exact thing I want to do in terms of usage is to just see the
rmail buffer and the associated summary buffer simultaneously.


Best,

        -Göktuğ.


(defmacro rmail-select-summary (&rest body)
  `(let ((total rmail-total-messages))
     (if (rmail-summary-displayed)
         (with-current-buffer rmail-summary-buffer
	   (let ((rmail-total-messages total))
	     ,@body))
       (let ((window (selected-window)))
	 (save-excursion
	   (unwind-protect
	       (progn
		 (rmail-pop-to-buffer rmail-summary-buffer)
		 ;; rmail-total-messages is a buffer-local var
		 ;; in the rmail buffer.
		 ;; This way we make it available for the body
		 ;; even tho the rmail buffer is not current.
		 (let ((rmail-total-messages total))
		   ,@body))
	     (select-window window)))))
     (rmail-maybe-display-summary)))

-- 
İ. Göktuğ Kayaalp / @cadadr / <https://www.gkayaalp.com/>
pgp:   024C 30DD 597D 142B 49AC 40EB 465C D949 B101 2427



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

end of thread, other threads:[~2021-01-28  9:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-01-20 16:51           ` martin rudalics
2021-01-27 23:23             ` Göktuğ Kayaalp
2021-01-28  9:42               ` martin rudalics

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).