mirror of https://github.com/djcb/mu.git
mu4e: try a bit harder to find the draft folder
If we can't guess the draft folder when re-editing a message, fallback to the default.
This commit is contained in:
parent
5228e24fbd
commit
ddf4adc30f
|
@ -432,9 +432,10 @@ fields will be the same as in the original."
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-draft-open (compose-type &optional msg)
|
(defun mu4e-draft-open (compose-type &optional msg)
|
||||||
"Open a draft file for a new message (when COMPOSE-TYPE is `reply', `forward' or `new'),
|
"Open a draft file for a new message (when COMPOSE-TYPE is `reply',
|
||||||
open an existing draft (when COMPOSE-TYPE is `edit'), or re-send
|
`forward' or `new'), open an existing draft (when COMPOSE-TYPE
|
||||||
an existing message (when COMPOSE-TYPE is `resend').
|
is `edit'), or re-send an existing message (when COMPOSE-TYPE is
|
||||||
|
`resend').
|
||||||
|
|
||||||
The name of the draft folder is constructed from the
|
The name of the draft folder is constructed from the
|
||||||
concatenation of `mu4e-maildir' and `mu4e-drafts-folder' (the
|
concatenation of `mu4e-maildir' and `mu4e-drafts-folder' (the
|
||||||
|
@ -447,8 +448,9 @@ will be created from either `mu4e~draft-reply-construct', or
|
||||||
(case compose-type
|
(case compose-type
|
||||||
|
|
||||||
(edit
|
(edit
|
||||||
;; case-1: re-editing a draft messages. in this case, we do know the full
|
;; case-1: re-editing a draft messages. in this case, we do know the
|
||||||
;; path, but we cannot really know 'drafts folder'... we make a guess
|
;; full path, but we cannot really know 'drafts folder'... we make a
|
||||||
|
;; guess
|
||||||
(setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path)))
|
(setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path)))
|
||||||
(mu4e~draft-open-file (mu4e-message-field msg :path)))
|
(mu4e~draft-open-file (mu4e-message-field msg :path)))
|
||||||
|
|
||||||
|
@ -461,7 +463,7 @@ will be created from either `mu4e~draft-reply-construct', or
|
||||||
(mu4e~draft-open-file draft-path)))
|
(mu4e~draft-open-file draft-path)))
|
||||||
|
|
||||||
((reply forward new)
|
((reply forward new)
|
||||||
;; case-3: creating a new message; in this case, we can determing
|
;; case-3: creating a new message; in this case, we can determine
|
||||||
;; mu4e-get-drafts-folder
|
;; mu4e-get-drafts-folder
|
||||||
(setq draft-dir (mu4e-get-drafts-folder msg))
|
(setq draft-dir (mu4e-get-drafts-folder msg))
|
||||||
(let ((draft-path (mu4e~draft-determine-path draft-dir))
|
(let ((draft-path (mu4e~draft-determine-path draft-dir))
|
||||||
|
@ -480,8 +482,11 @@ will be created from either `mu4e~draft-reply-construct', or
|
||||||
(message-insert-signature)
|
(message-insert-signature)
|
||||||
(mu4e~fontify-signature))))))
|
(mu4e~fontify-signature))))))
|
||||||
(t (mu4e-error "unsupported compose-type %S" compose-type)))
|
(t (mu4e-error "unsupported compose-type %S" compose-type)))
|
||||||
;; evaluate mu4e~drafts-drafts-folder once, here, and use that value
|
;; if we didn't find a draft folder yet, try some default
|
||||||
;; throughout.
|
(unless draft-dir
|
||||||
|
(setq draft-dir (mu4e-get-drafts-folder msg)))
|
||||||
|
;; evaluate mu4e~drafts-drafts-folder once, here, and use that value
|
||||||
|
;; throughout.
|
||||||
(set (make-local-variable 'mu4e~draft-drafts-folder) draft-dir)
|
(set (make-local-variable 'mu4e~draft-drafts-folder) draft-dir)
|
||||||
(put 'mu4e~draft-drafts-folder 'permanent-local t)
|
(put 'mu4e~draft-drafts-folder 'permanent-local t)
|
||||||
(unless mu4e~draft-drafts-folder
|
(unless mu4e~draft-drafts-folder
|
||||||
|
|
Loading…
Reference in New Issue