all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andrea Monaco <andrea.monaco@autistici.org>,
	Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Summary by thread in rmail
Date: Mon, 10 Oct 2022 10:15:43 +0300	[thread overview]
Message-ID: <83bkqki1y8.fsf@gnu.org> (raw)
In-Reply-To: <87o7uq6ihu.fsf@autistici.org> (message from Andrea Monaco on Wed, 05 Oct 2022 23:57:49 +0200)

> From: Andrea Monaco <andrea.monaco@autistici.org>
> Date: Wed, 05 Oct 2022 23:57:49 +0200
> 
> I had some code ready.  This only looks at the Subject field.  You can
> invoke it with rmail-thread-summary and it creates a buffer called
> e.g. RMAIL-thread-summary that is independent of RMAIL-summary.  There's
> still no code to update the summary after getting new mail.  It's basic,
> but it works.

Thanks.  Please see some comments below.

Richard, I'd appreciate your review as well.

> --- /dev/null
> +++ b/lisp/mail/rmailthread.el

Please add this to rmailsum.el, instead of making a new file.

> +(defun rmail-get-create-thread-summary-buffer ()
> +  "Return the Rmail thread summary buffer.
> +If necessary, it is created and undo is disabled."
> +  (if (and rmail-thread-summary-buffer (buffer-name rmail-thread-summary-buffer))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We nowadays have the buffer-live-p function to make such tests.

> +    (let ((buff (generate-new-buffer (concat (buffer-name) "-thread-summary"))))

I think "-summary-by-thread" is a better name.  "Thread-summary" hints
that it is a summary of a single thread, which is not the case here.

> +(defun rmail-new-thread-summary (desc redo function &rest args)
> +  "Create a summary of selected messages by thread."

The "selected" part here is misleading, I think.  The truth is, the
messages can be "selected" by the FUNCTION argument, but what kind of
FUNCTION can make sense for this summary?  And in any case, if we keep
the FUNCTION arg, the doc string should explain how messages are
"selected" for the summary.

> +    (with-current-buffer rmail-buffer
> +      (setq rmail-thread-summary-buffer (rmail-new-thread-summary-1 desc redo function args)
> +	    ;; r-s-b is buffer-local.

What is "r-s-b" here?  Please don't use abbreviated symbol names, they
make reading the code harder.

> +      ;; This is how rmail makes the summary buffer reappear.
> +      ;; We do this here to make the window the proper size.
> +      ;(rmail-select-summary nil)
> +					;(set-buffer sumbuf))

Is this commented-out code necessary?

> +    ;(rmail-summary-goto-msg mesg t t)
> +    ;(rmail-summary-construct-io-menu)

And this?

> +			  (if thread
> +			      (setcdr thread
> +				      (cons (cons msgnum (rmail-get-summary msgnum)) (cdr thread)))
> +			    (progn
> +			      (let* ((newthread (list subject (cons msgnum (rmail-get-summary msgnum))))
> +				     (newcell (cons newthread cell)))
> +				(setq cell newcell)
> +				(puthash subject newcell rmail-thread-hash-table)
> +				(setq ordered-threads (cons newthread ordered-threads)))))

Is progn really necessary here?

> +				(setq ordered-threads (cons newthread ordered-threads)))))

Maybe using 'push' here will make the code more concise and readable?

> +			  (setq msgnum (1+ msgnum))
> +			  (if (and (not (zerop msgnum))
> +				   (zerop (% msgnum 10)))
> +			      (message "Computing thread summary lines... %d"
> +				       msgnum))))))

"Computing by-thread summary lines... %d" is a better message, I
think.

> +	      (while thread-message
> +		(let* ((suml (cdar thread-message))
> +		       (newsuml (concat (substring suml 0 42) "  " (substring suml 42))))

Why are you truncating the subject at the 42nd character? and why is
42 hard-coded?

This:

> +	(setq-local minor-mode-alist (list (list t (concat ": " description))))

together with this:

> +  (rmail-new-thread-summary "All" '(rmail-thread-summary) nil))

Will AFAIU display "RMAIL Summary: All" in the mode line.  However, I
think the mode line should in this case show something like this
instead:

  RMAIL Summary: By-Thread

Thanks again for working on this.



  parent reply	other threads:[~2022-10-10  7:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 21:57 [PATCH] Summary by thread in rmail Andrea Monaco
2022-10-06  6:02 ` Eli Zaretskii
2022-10-06  7:21   ` Andrea Monaco
2022-10-06  7:29     ` tomas
2022-10-06 19:19       ` Emanuel Berg
2022-10-06 10:20     ` Eli Zaretskii
2022-10-06 10:55       ` Andrea Monaco
2022-10-06 14:18         ` Eli Zaretskii
2022-10-06 19:23         ` Emanuel Berg
2022-10-06 19:25         ` Emanuel Berg
2022-10-10  7:15 ` Eli Zaretskii [this message]
2022-11-15 19:07   ` [PATCH] Add command rmail-summary-by-thread (was: Summary by thread in rmail) Andrea Monaco
2022-11-17  4:34     ` Richard Stallman
2022-11-17 13:54     ` Eli Zaretskii
2022-12-09 20:22       ` [PATCH] Make rmail-summary-by-thread faster Andrea Monaco
2022-12-18 10:25         ` Eli Zaretskii

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bkqki1y8.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=andrea.monaco@autistici.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.