mirror of
https://github.com/djcb/mu.git
synced 2024-06-25 07:28:02 +02:00
* mu4e-send.el: make sure messages are saved before moving them from draft -->
sent (or elsewhere)
This commit is contained in:
parent
25801c7c51
commit
ad0c315c02
|
@ -293,7 +293,9 @@ use the new docid. Returns the full path to the new message."
|
||||||
(let ((message-hidden-headers
|
(let ((message-hidden-headers
|
||||||
`("^References:" "^Face:" "^X-Face:" "^X-Draft-From:"
|
`("^References:" "^Face:" "^X-Face:" "^X-Draft-From:"
|
||||||
"^User-agent:")))
|
"^User-agent:")))
|
||||||
(message-hide-headers))
|
(use-local-map mu4e-edit-mode-map)
|
||||||
|
|
||||||
|
(message-hide-headers)
|
||||||
|
|
||||||
(make-local-variable 'after-save-hook)
|
(make-local-variable 'after-save-hook)
|
||||||
|
|
||||||
|
@ -309,7 +311,12 @@ use the new docid. Returns the full path to the new message."
|
||||||
|
|
||||||
;; register the function; this function will be called when the '(:sent...)'
|
;; register the function; this function will be called when the '(:sent...)'
|
||||||
;; message is received (see mu4e-proc.el) with parameters docid and path
|
;; message is received (see mu4e-proc.el) with parameters docid and path
|
||||||
(setq mu4e-proc-sent-func 'mu4e-sent-handler))
|
(setq mu4e-proc-sent-func 'mu4e-sent-handler)
|
||||||
|
|
||||||
|
;; set the default directory to the user's home dir; this is probably more
|
||||||
|
;; useful e.g. when finding an attachment file the directory the current
|
||||||
|
;; mail files lives in...
|
||||||
|
(setq default-directory (expand-file-name "~/"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,21 +378,29 @@ using Gnus' `message-mode'."
|
||||||
(defun mu4e-sent-handler (docid path)
|
(defun mu4e-sent-handler (docid path)
|
||||||
"Handler function, called with DOCID and PATH for the just-sent
|
"Handler function, called with DOCID and PATH for the just-sent
|
||||||
message."
|
message."
|
||||||
|
(with-current-buffer (find-file-noselect path)
|
||||||
|
;; make sure this buffer is saved
|
||||||
|
(save-buffer)
|
||||||
|
(message "Mail sent")
|
||||||
;; for Forward ('Passed') and Replied messages, try to set the appropriate
|
;; for Forward ('Passed') and Replied messages, try to set the appropriate
|
||||||
;; flag at the message forwarded or replied-to
|
;; flag at the message forwarded or replied-to
|
||||||
(mu4e-send-set-parent-flag docid path)
|
(mu4e-send-set-parent-flag docid path)
|
||||||
;; handle the draft -- should it be moved to the send folder, or elsewhere?
|
;; handle the draft -- should it be moved to the send folder, or elsewhere?
|
||||||
(mu4e-send-save-copy-maybe docid path))
|
(mu4e-send-save-copy-maybe docid path)
|
||||||
|
;; now, get rid of the buffer
|
||||||
|
(kill-buffer)))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-send-save-copy-maybe (docid path)
|
(defun mu4e-send-save-copy-maybe (docid path)
|
||||||
"Handler function, called with DOCID and PATH for the just-sent
|
"Handler function, called with DOCID and PATH for the just-sent
|
||||||
message."
|
message, which will move it to the sent-folder or elsewhere,
|
||||||
|
depending on the value of `mu4e-sent-messages-behavior'.
|
||||||
|
|
||||||
|
Function assumes that it's executed in the context of the message
|
||||||
|
buffer."
|
||||||
;; first, what to do with the draft message in PATH?
|
;; first, what to do with the draft message in PATH?
|
||||||
(with-current-buffer (find-file-noselect path)
|
|
||||||
(if (eq mu4e-sent-messages-behavior 'delete)
|
(if (eq mu4e-sent-messages-behavior 'delete)
|
||||||
(progn
|
(progn
|
||||||
(save-buffer)
|
|
||||||
(mu4e-proc-remove-msg docid)) ;; remove it
|
(mu4e-proc-remove-msg docid)) ;; remove it
|
||||||
;; otherwise,
|
;; otherwise,
|
||||||
(progn ;; prepare the message for saving
|
(progn ;; prepare the message for saving
|
||||||
|
@ -396,10 +411,11 @@ message."
|
||||||
(replace-match "")
|
(replace-match "")
|
||||||
(error "cannot find mail-header-separator"))
|
(error "cannot find mail-header-separator"))
|
||||||
(save-buffer)
|
(save-buffer)
|
||||||
|
(message nil)
|
||||||
;; ok, all seems well, well move the message to the sent-folder
|
;; ok, all seems well, well move the message to the sent-folder
|
||||||
(if (eq mu4e-sent-messages-behavior 'trash)
|
(if (eq mu4e-sent-messages-behavior 'trash)
|
||||||
(mu4e-proc-move-msg docid mu4e-trash-folder "+T-D+S")
|
(mu4e-proc-move-msg docid mu4e-trash-folder "+T-D+S")
|
||||||
(mu4e-proc-move-msg docid mu4e-sent-folder "-T-D+S")))))))
|
(mu4e-proc-move-msg docid mu4e-sent-folder "-T-D+S"))))))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-send-set-parent-flag (docid path)
|
(defun mu4e-send-set-parent-flag (docid path)
|
||||||
|
@ -415,8 +431,11 @@ corresponding with the /last/ message-id in the references header.
|
||||||
Now, if the message has been determined to be either a forwarded
|
Now, if the message has been determined to be either a forwarded
|
||||||
message or a reply, we instruct the server to update that message
|
message or a reply, we instruct the server to update that message
|
||||||
with resp. the 'P' (passed) flag for a forwarded message, or the
|
with resp. the 'P' (passed) flag for a forwarded message, or the
|
||||||
'R' flag for a replied message."
|
'R' flag for a replied message.
|
||||||
(with-current-buffer (find-file-noselect path)
|
|
||||||
|
Function assumes that it's executed in the context of the message
|
||||||
|
buffer.
|
||||||
|
"
|
||||||
(let ((in-reply-to (message-fetch-field "in-reply-to"))
|
(let ((in-reply-to (message-fetch-field "in-reply-to"))
|
||||||
(forwarded-from)
|
(forwarded-from)
|
||||||
(references (message-fetch-field "references")))
|
(references (message-fetch-field "references")))
|
||||||
|
@ -434,6 +453,6 @@ with resp. the 'P' (passed) flag for a forwarded message, or the
|
||||||
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
|
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
|
||||||
(mu4e-proc-flag (match-string 1 in-reply-to) "+R"))
|
(mu4e-proc-flag (match-string 1 in-reply-to) "+R"))
|
||||||
(when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
|
(when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
|
||||||
(mu4e-proc-flag (match-string 1 forwarded-from) "+P")))))
|
(mu4e-proc-flag (match-string 1 forwarded-from) "+P"))))
|
||||||
|
|
||||||
(provide 'mu4e-send)
|
(provide 'mu4e-send)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user