emacs-devel
[Top][All Lists]
Advanced

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

Potential bug in the logic of rmail-select-summary


From: Göktuğ Kayaalp
Subject: Potential bug in the logic of rmail-select-summary
Date: Tue, 19 Jan 2021 15:23:02 +0300

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



reply via email to

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