From: Kyle Meyer <firstname.lastname@example.org>
To: Xinglu Chen <email@example.com>
Subject: Re: [RFC PATCH v2] gnus: Add piem-gnus-mid-to-thread
Date: Wed, 20 Jan 2021 21:45:39 -0500 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
Xinglu Chen writes:
> Inserts a string of the whole thread in mbox format.
> Changes from v1
> - Add safety check for major mode and message id before trying to generate
> the mbox file
> - Escape "^From" in the body to prevent ambiguity
I played around with this a bit, and all series seemed to get applied
without issues. I think interface-wise it'd be a bit nicer if we could
do this work behind the scenes without the user seeing any changes in
the layout/rendering of Gnus buffers, but I'm not sure that's really
> diff --git a/piem-gnus.el b/piem-gnus.el
> index 5f10be8..828ce1f 100644
> --- a/piem-gnus.el
> +++ b/piem-gnus.el
> @@ -55,8 +55,38 @@
> (match-string 1 mid)
> -;; If there is an easy way to generate an mbox for a thread in Gnus, a
> -;; function for `piem-mid-to-thread-functions' should be defined.
> +(defun piem-gnus-mid-to-thread (mid)
> + (when (and (derived-mode-p 'gnus-summary-mode)
> + (string-equal (substring
> + (mail-header-id (gnus-summary-article-header))
> + 1 -1) ; Remove "<" and ">"
> + mid))
Great, thanks for adding those guards.
> + (save-excursion
> + ;; Cursor has to be at the root of the thread
> + (gnus-summary-refer-parent-article most-positive-fixnum)
> + (let ((articles (gnus-summary-articles-in-thread))
> + message
I'm going to s/message/&s/ on apply. It's a cosmetic nit, but I'll trip
over this whenever I need to revisit this code if I don't make that
> + ;; Just show raw message
> + (gnus-have-all-headers t)
> + gnus-article-prepare-hook
> + gnus-article-decode-hook
> + gnus-display-mime-function
> + gnus-break-pages)
When compiling, this gives the following warnings:
In toplevel form:
piem-gnus.el:58:1:Warning: Unused lexical variable
piem-gnus.el:58:1:Warning: Unused lexical variable ‘gnus-article-decode-hook’
piem-gnus.el:58:1:Warning: Unused lexical variable ‘gnus-article-prepare-hook’
I'll silence those by adding
> + (mapc (lambda (article)
> + (gnus-summary-display-article article)
> + (push (format
> + "From mboxrd@z Thu Jan 1 00:00:00 1970\n%s\n"
> + (replace-regexp-in-string ; From-munge
> + "^From "
> + "^>From "
There's a spurious "^" making it into the replacement. Also this
doesn't handle mboxrd's ">From " escaping. I'll squash the following
diff --git a/piem-gnus.el b/piem-gnus.el
index 4293049..d81c086 100644
@@ -77,8 +77,8 @@ (defun piem-gnus-mid-to-thread (mid)
"From mboxrd@z Thu Jan 1 00:00:00 1970\n%s\n"
(replace-regexp-in-string ; From-munge
- "^From "
- "^>From "
+ "^>*From "
> + (with-current-buffer gnus-article-buffer
> + (buffer-substring-no-properties
> + (point-min)
> + (point-max)))))
> + message))
> + articles)
> + (lambda ()
> + (insert (apply #'concat (nreverse message))))))))
Mostly just thinking aloud: this could be rewritten without concat by
using (dolist ... (insert ...)), and it might eventually be worth
considering building the mbox up in a temporary buffer rather than as a
list of strings. But I think it's fine as is.
Also, I've replaced the tabs with spaces. Sorry for not having set
indent-tabs-mode for the project. I've now done that in 9d60b3e.
next prev parent reply other threads:[~2021-01-21 2:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 10:34 [RFC PATCH] gnus: Add piem-gnus-mid-to-thread Xinglu Chen
2021-01-19 4:17 ` Kyle Meyer
2021-01-19 8:32 ` yoctocell
2021-01-19 23:41 ` Kyle Meyer
2021-01-20 7:27 ` Xinglu Chen
2021-01-20 8:56 ` [RFC PATCH v2] " Xinglu Chen
2021-01-21 2:45 ` Kyle Meyer [this message]
2021-01-21 8:36 ` Xinglu Chen
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:
List information: https://git.kyleam.com/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).