mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
Modify our local copy of message-do-fcc
Since we also need to use this code for the draft handling we split message-do-fcc into convenient sub-chunks (functions or macros as appropriate).
This commit is contained in:
parent
aa1e8352de
commit
cf59859b20
1 changed files with 38 additions and 25 deletions
|
@ -124,40 +124,53 @@ by notmuch-mua-mail"
|
||||||
;; Functions for saving a message either using notmuch insert or file
|
;; Functions for saving a message either using notmuch insert or file
|
||||||
;; fcc. First functions common to the two cases.
|
;; fcc. First functions common to the two cases.
|
||||||
|
|
||||||
|
(defmacro with-temporary-notmuch-message-buffer (&rest body)
|
||||||
|
"Set-up a temporary copy of the current message-mode buffer."
|
||||||
|
`(let ((case-fold-search t)
|
||||||
|
(buf (current-buffer))
|
||||||
|
(mml-externalize-attachments message-fcc-externalize-attachments))
|
||||||
|
(with-current-buffer (get-buffer-create " *message temp*")
|
||||||
|
(erase-buffer)
|
||||||
|
(insert-buffer-substring buf)
|
||||||
|
,@body)))
|
||||||
|
|
||||||
|
(defun notmuch-maildir-setup-message-for-saving ()
|
||||||
|
"Setup message for saving. Should be called on a temporary copy.
|
||||||
|
|
||||||
|
This is taken from the function message-do-fcc."
|
||||||
|
(message-encode-message-body)
|
||||||
|
(save-restriction
|
||||||
|
(message-narrow-to-headers)
|
||||||
|
(let ((mail-parse-charset message-default-charset))
|
||||||
|
(mail-encode-encoded-word-buffer)))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(when (re-search-forward
|
||||||
|
(concat "^" (regexp-quote mail-header-separator) "$")
|
||||||
|
nil t)
|
||||||
|
(replace-match "" t t )))
|
||||||
|
|
||||||
(defun notmuch-maildir-message-do-fcc ()
|
(defun notmuch-maildir-message-do-fcc ()
|
||||||
"Process Fcc headers in the current buffer.
|
"Process Fcc headers in the current buffer.
|
||||||
|
|
||||||
This is a rearranged version of message mode's message-do-fcc."
|
This is a rearranged version of message mode's message-do-fcc."
|
||||||
(let ((case-fold-search t)
|
(let (list file)
|
||||||
(buf (current-buffer))
|
|
||||||
list file
|
|
||||||
(mml-externalize-attachments message-fcc-externalize-attachments))
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(message-narrow-to-headers)
|
(message-narrow-to-headers)
|
||||||
(setq file (message-fetch-field "fcc" t)))
|
(setq file (message-fetch-field "fcc" t)))
|
||||||
(when file
|
(when file
|
||||||
(set-buffer (get-buffer-create " *message temp*"))
|
(with-temporary-notmuch-message-buffer
|
||||||
(erase-buffer)
|
(save-restriction
|
||||||
(insert-buffer-substring buf)
|
(message-narrow-to-headers)
|
||||||
(message-encode-message-body)
|
(while (setq file (message-fetch-field "fcc" t))
|
||||||
(save-restriction
|
(push file list)
|
||||||
(message-narrow-to-headers)
|
(message-remove-header "fcc" nil t)))
|
||||||
(while (setq file (message-fetch-field "fcc" t))
|
(notmuch-maildir-setup-message-for-saving)
|
||||||
(push file list)
|
;; Process FCC operations.
|
||||||
(message-remove-header "fcc" nil t))
|
(while list
|
||||||
(let ((mail-parse-charset message-default-charset))
|
(setq file (pop list))
|
||||||
(mail-encode-encoded-word-buffer)))
|
(notmuch-fcc-handler file))
|
||||||
(goto-char (point-min))
|
(kill-buffer (current-buffer)))))))
|
||||||
(when (re-search-forward
|
|
||||||
(concat "^" (regexp-quote mail-header-separator) "$")
|
|
||||||
nil t)
|
|
||||||
(replace-match "" t t ))
|
|
||||||
;; Process FCC operations.
|
|
||||||
(while list
|
|
||||||
(setq file (pop list))
|
|
||||||
(notmuch-fcc-handler file))
|
|
||||||
(kill-buffer (current-buffer))))))
|
|
||||||
|
|
||||||
(defun notmuch-fcc-handler (fcc-header)
|
(defun notmuch-fcc-handler (fcc-header)
|
||||||
"Store message with file fcc."
|
"Store message with file fcc."
|
||||||
|
|
Loading…
Reference in a new issue