mu4e: mark compose buffers as non-modified later

To avoid marking user-unchanged buffers as modified.
This commit is contained in:
djcb
2018-12-12 21:35:46 +02:00
parent ff4280d687
commit 9352219dcf

View File

@ -26,7 +26,6 @@
;; In this file, various functions to compose/send messages, piggybacking on ;; In this file, various functions to compose/send messages, piggybacking on
;; gnus' message mode ;; gnus' message mode
;; Magic / Rupe Goldberg ;; Magic / Rupe Goldberg
;; 1) When we reply/forward a message, we get it from the backend, ie: ;; 1) When we reply/forward a message, we get it from the backend, ie:
@ -35,7 +34,6 @@
;; backend responds with: ;; backend responds with:
;; (:compose reply :original ( .... <original message> )) ;; (:compose reply :original ( .... <original message> ))
;; 2) When we compose a message, message and headers are separated by ;; 2) When we compose a message, message and headers are separated by
;; `mail-header-separator', ie. '--text follows this line--. We use ;; `mail-header-separator', ie. '--text follows this line--. We use
;; before-save-hook and after-save-hook to remove/re-add this special line, so ;; before-save-hook and after-save-hook to remove/re-add this special line, so
@ -86,7 +84,6 @@
(require 'mu4e-draft) (require 'mu4e-draft)
(require 'mu4e-context) (require 'mu4e-context)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Composing / Sending messages ;; Composing / Sending messages
(defgroup mu4e-compose nil (defgroup mu4e-compose nil
@ -120,7 +117,6 @@ for querying the message information."
(const :tag "delete message" delete)) (const :tag "delete message" delete))
:group 'mu4e-compose) :group 'mu4e-compose)
(defcustom mu4e-compose-context-policy 'ask (defcustom mu4e-compose-context-policy 'ask
"Policy for determining the context when composing a new message. "Policy for determining the context when composing a new message.
@ -145,7 +141,6 @@ Also see `mu4e-context-policy'."
:safe 'symbolp :safe 'symbolp
:group 'mu4e-compose)) :group 'mu4e-compose))
(defcustom mu4e-compose-crypto-reply-encrypted-policy 'sign-and-encrypt (defcustom mu4e-compose-crypto-reply-encrypted-policy 'sign-and-encrypt
"Policy for signing/encrypting replies to encrypted messages. "Policy for signing/encrypting replies to encrypted messages.
We have the following choices: We have the following choices:
@ -188,7 +183,6 @@ We have the following choices:
'mu4e-compose-crypto-reply-encrypted-policy' should be used instead" 'mu4e-compose-crypto-reply-encrypted-policy' should be used instead"
"2017-09-02") "2017-09-02")
(defcustom mu4e-compose-format-flowed nil (defcustom mu4e-compose-format-flowed nil
"Whether to compose messages to be sent as format=flowed (or "Whether to compose messages to be sent as format=flowed (or
with long lines if `use-hard-newlines' is set to nil). The with long lines if `use-hard-newlines' is set to nil). The
@ -219,7 +213,6 @@ place to do that."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-compose-attach-message (msg) (defun mu4e-compose-attach-message (msg)
"Insert message MSG as an attachment." "Insert message MSG as an attachment."
(let ((path (plist-get msg :path))) (let ((path (plist-get msg :path)))
@ -241,7 +234,6 @@ Messages are captured with `mu4e-action-capture-message'."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 'fcc' refers to saving a copy of a sent message to a certain folder. that's ;; 'fcc' refers to saving a copy of a sent message to a certain folder. that's
;; what these 'Sent mail' folders are for! ;; what these 'Sent mail' folders are for!
;; ;;
@ -539,7 +531,6 @@ buffers; lets remap its faces so it uses the ones for mu4e."
(defconst mu4e~compose-buffer-max-name-length 30 (defconst mu4e~compose-buffer-max-name-length 30
"Maximum length of the mu4e-send-buffer-name.") "Maximum length of the mu4e-send-buffer-name.")
(defun mu4e~compose-set-friendly-buffer-name (&optional compose-type) (defun mu4e~compose-set-friendly-buffer-name (&optional compose-type)
"Set some user-friendly buffer name based on the compose type." "Set some user-friendly buffer name based on the compose type."
(let* ((subj (message-field-value "subject")) (let* ((subj (message-field-value "subject"))
@ -573,7 +564,6 @@ we can decide what we want to do."
(message "Do nothing"))) (message "Do nothing")))
) )
(defun* mu4e~compose-handler (compose-type &optional original-msg includes) (defun* mu4e~compose-handler (compose-type &optional original-msg includes)
"Create a new draft message, or open an existing one. "Create a new draft message, or open an existing one.
@ -627,11 +617,10 @@ tempfile)."
(dolist (att includes) (dolist (att includes)
(mml-attach-file (mml-attach-file
(plist-get att :file-name) (plist-get att :mime-type))))) (plist-get att :file-name) (plist-get att :mime-type)))))
;; buffer is not user-modified yet
(mu4e~compose-set-friendly-buffer-name compose-type)
(set-buffer-modified-p nil)
;; now jump to some useful positions, and start writing that mail!
(mu4e~compose-set-friendly-buffer-name compose-type)
;; now jump to some useful positions, and start writing that mail!
(if (member compose-type '(new forward)) (if (member compose-type '(new forward))
(message-goto-to) (message-goto-to)
;; otherwise, it depends... ;; otherwise, it depends...
@ -660,7 +649,10 @@ tempfile)."
;; make sure to close the frame when we're done with the message these are ;; make sure to close the frame when we're done with the message these are
;; all buffer-local; ;; all buffer-local;
(push 'delete-frame message-exit-actions) (push 'delete-frame message-exit-actions)
(push 'delete-frame message-postpone-actions))) (push 'delete-frame message-postpone-actions))
;; buffer is not user-modified yet
(set-buffer-modified-p nil))
(defun mu4e~switch-back-to-mu4e-buffer () (defun mu4e~switch-back-to-mu4e-buffer ()
"Try to go back to some previous buffer, in the order view->headers->main." "Try to go back to some previous buffer, in the order view->headers->main."