unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* rmail-total-messages has two different values, one is wrong
@ 2022-10-26 21:26 Andrea Monaco
  2022-10-27 17:04 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Monaco @ 2022-10-26 21:26 UTC (permalink / raw)
  To: emacs-devel


When I evaluate these forms, I get two different values:

  (with-current-buffer "RMAIL"
    rmail-total-messages) -> 4805

  (with-current-buffer "RMAIL-summary"
    rmail-total-messages) -> 4457


The first one is correct and in fact the summary has 4805 lines.  The
second one is wrong.  Why?  This caused me some delay while working on a
patch.  I conjecture that the second binding is not updated when new
mail is loaded.



Andrea Monaco



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

* Re: rmail-total-messages has two different values, one is wrong
  2022-10-26 21:26 rmail-total-messages has two different values, one is wrong Andrea Monaco
@ 2022-10-27 17:04 ` Eli Zaretskii
  2023-06-18 12:51   ` Andrea Monaco
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-10-27 17:04 UTC (permalink / raw)
  To: Andrea Monaco; +Cc: emacs-devel

> From: Andrea Monaco <andrea.monaco@autistici.org>
> Date: Wed, 26 Oct 2022 23:26:42 +0200
> 
> 
> When I evaluate these forms, I get two different values:
> 
>   (with-current-buffer "RMAIL"
>     rmail-total-messages) -> 4805
> 
>   (with-current-buffer "RMAIL-summary"
>     rmail-total-messages) -> 4457
> 
> 
> The first one is correct and in fact the summary has 4805 lines.  The
> second one is wrong.  Why?  This caused me some delay while working on a
> patch.  I conjecture that the second binding is not updated when new
> mail is loaded.

It is supposed to happen inside rmail-select-summary, which is called
from rmail-get-new-mail-1.  Can you step through it and see why it
doesn't update the count?



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

* Re: rmail-total-messages has two different values, one is wrong
  2022-10-27 17:04 ` Eli Zaretskii
@ 2023-06-18 12:51   ` Andrea Monaco
  2023-06-24 12:30     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Monaco @ 2023-06-18 12:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


I think the problem is in rmail-count-new-messages.  The function runs
in the main buffer, so this assignment


    (setq rmail-total-messages
	  (+ rmail-total-messages total-messages))


should be duplicated for the summary buffer (maybe the same goes for
other assignments in that function, I don't know).

But this bug is not nasty, so we could just document the current
behavior.  What do you think?



Andrea Monaco



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

* Re: rmail-total-messages has two different values, one is wrong
  2023-06-18 12:51   ` Andrea Monaco
@ 2023-06-24 12:30     ` Eli Zaretskii
  2023-07-01  8:35       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2023-06-24 12:30 UTC (permalink / raw)
  To: Andrea Monaco; +Cc: emacs-devel

> From: Andrea Monaco <andrea.monaco@autistici.org>
> Cc: emacs-devel@gnu.org
> Date: Sun, 18 Jun 2023 14:51:15 +0200
> 
> 
> I think the problem is in rmail-count-new-messages.  The function runs
> in the main buffer, so this assignment
> 
> 
>     (setq rmail-total-messages
> 	  (+ rmail-total-messages total-messages))
> 
> 
> should be duplicated for the summary buffer (maybe the same goes for
> other assignments in that function, I don't know).
> 
> But this bug is not nasty, so we could just document the current
> behavior.  What do you think?

I think it's a bug: the value in the summary buffer should tell how
many messages are shown in the summary.

Does the patch below give good results?  Please try it both with
"normal" summaries and with various filtering alternatives.

diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 21dec2b..e3a6c16 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -742,13 +742,14 @@ rmail-new-summary-1
 	  (setq rmail-summary-buffer nil)))
     (save-excursion
       (let ((rbuf (current-buffer))
-	    (total rmail-total-messages))
+	    (total 0))
 	(set-buffer sumbuf)
 	;; Set up the summary buffer's contents.
 	(let ((buffer-read-only nil))
 	  (erase-buffer)
 	  (while summary-msgs
 	    (princ (cdr (car summary-msgs)) sumbuf)
+            (setq total (1+ total))
 	    (setq summary-msgs (cdr summary-msgs)))
 	  (goto-char (point-min)))
 	;; Set up the rest of its state and local variables.



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

* Re: rmail-total-messages has two different values, one is wrong
  2023-06-24 12:30     ` Eli Zaretskii
@ 2023-07-01  8:35       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2023-07-01  8:35 UTC (permalink / raw)
  To: andrea.monaco; +Cc: emacs-devel

> Date: Sat, 24 Jun 2023 15:30:07 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > From: Andrea Monaco <andrea.monaco@autistici.org>
> > Cc: emacs-devel@gnu.org
> > Date: Sun, 18 Jun 2023 14:51:15 +0200
> > 
> > 
> > I think the problem is in rmail-count-new-messages.  The function runs
> > in the main buffer, so this assignment
> > 
> > 
> >     (setq rmail-total-messages
> > 	  (+ rmail-total-messages total-messages))
> > 
> > 
> > should be duplicated for the summary buffer (maybe the same goes for
> > other assignments in that function, I don't know).
> > 
> > But this bug is not nasty, so we could just document the current
> > behavior.  What do you think?
> 
> I think it's a bug: the value in the summary buffer should tell how
> many messages are shown in the summary.
> 
> Does the patch below give good results?  Please try it both with
> "normal" summaries and with various filtering alternatives.

No further comments, so I've now installed the change on the master
branch.



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

end of thread, other threads:[~2023-07-01  8:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 21:26 rmail-total-messages has two different values, one is wrong Andrea Monaco
2022-10-27 17:04 ` Eli Zaretskii
2023-06-18 12:51   ` Andrea Monaco
2023-06-24 12:30     ` Eli Zaretskii
2023-07-01  8:35       ` Eli Zaretskii

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