From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: info-gnus-english@gnu.org
Subject: Re: nnimap-split-download-body removed?
Date: Wed, 02 Dec 2020 12:34:04 -0800 [thread overview]
Message-ID: <87eek8uev7.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87wny0wu9j.fsf@gmail.com>
Bodertz <bodertz@gmail.com> writes:
>> I'm not sure how big of a rewrite this would require. First fetching
>> headers only wouldn't be hard, but then we'd need to somehow partially
>> fake a run of the splitting process in order to know which messages
>> needed more. How do you indicate in your splits that the body should
>> be examined?
>
> I guess an additional splitting character could be introduced (maybe @).
> And instead of splitting then and there it would push the article number
> onto some list, and then after all the normal non-body-splitting
> happens, if that list is non-nil, `nnimap-fetch-inbox' would download
> the bodies for those messages and run the split again. But I don't
> really know.
>
> Going back to what I said earlier about just having the function in the
> `(: function)' split download the body, it seems like that is possible.
> Because it's in the split rule, it only deals with one message at a
> time, so it is inefficient in that sense. In my case, I expect
> on-demand downloading of the occasional message body to be more
> efficient than downloading the body of every message and not using most
> of them, but maybe I'm mistaken.
TBH I don't think it's very likely we'll do a major rewrite to
accommodate this case. Particularly if body-scanning is only likely to
happen for a smaller subset of messages, I'd just do it the way you're
doing it below.
> Anyway, the code is messy, and not quite right (it doesn't clean up the
> `^M's for example), but it does seem to work in the sense that I can
> search for strings in the body and split based on that. I don't know
> which if any of these save-(excursion|restriction|match-data) forms are
> required.
>
>
> (setq nnimap-split-download-body-default nil)
>
> (defun scratch/test-split ()
> (current-buffer) ;; => " *nntpd*"
> (save-excursion
> (save-restriction
> (save-match-data
> (goto-char (point-min))
> (re-search-forward (rx "X-nnimap-article: "
> (group (+ digit))))
> (let* ((article (match-string 1))
> (command (format "UID FETCH %s (UID BODY.PEEK[])" article))
> (full-message
> (with-current-buffer (nnimap-buffer)
> (let ((message-start (point-max)))
> (nnimap-send-command command)
> (buffer-substring message-start (point))))))
> ;; Clear the original message (with only headers)
> (delete-region (point-min)
> (point-max))
> ;; Insert the full message
> (insert full-message)
> ;; Finally split based on message body
> (goto-char (point-min))
> (if (search-forward "Test Gnus Splitting" nil t)
> "mail.bodertz.test"
> "mail.bodertz"))))))
You might try putting the `full-message' text in a temp buffer and
running `nnimap-transform-split-mail' on it first, that might clear up
some of the oddities of the body text itself. I would keep both the
`save-restriction' and `save-match-data'. Otherwise looks like this will
do what you want!
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
prev parent reply other threads:[~2020-12-02 20:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 15:03 Bodertz
2020-11-30 17:10 ` Eric Abrahamsen
2020-12-01 0:15 ` Bodertz
2020-12-01 1:51 ` Eric Abrahamsen
2020-12-01 3:04 ` Bodertz
2020-12-01 3:35 ` Eric Abrahamsen
2020-12-01 8:46 ` Bodertz
2020-12-01 18:26 ` Eric Abrahamsen
2020-12-02 7:18 ` Bodertz
2020-12-02 20:34 ` Eric Abrahamsen [this message]
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=87eek8uev7.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=info-gnus-english@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.
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 NNTP newsgroup(s).