[Top][All Lists]

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

Re: nnimap-split-download-body removed?

From: Bodertz
Subject: Re: nnimap-split-download-body removed?
Date: Wed, 02 Dec 2020 00:18:32 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux)

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

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

(setq nnimap-split-download-body-default nil)

(defun scratch/test-split ()
  (current-buffer) ;; => " *nntpd*"
        (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))
                (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)
          ;; 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)

reply via email to

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