mu4e: Fix indentation

This commit is contained in:
Jonas Bernoulli
2020-02-11 12:00:46 +01:00
parent be1ba1ce68
commit 6790c0d015
18 changed files with 3284 additions and 3285 deletions

View File

@ -56,9 +56,9 @@ This is the mu4e-specific version of
\(i.e. the blob at the bottom of messages). This is the
mu4e-specific version of `message-signature'."
:type '(choice string
(const :tag "None" nil)
(const :tag "Contents of signature file" t)
function sexp)
(const :tag "None" nil)
(const :tag "Contents of signature file" t)
function sexp)
:risky t
:group 'mu4e-compose)
@ -68,7 +68,7 @@ mu4e-specific version of `message-signature'."
:group 'mu4e-compose)
(make-obsolete-variable 'mu4e-compose-auto-include-date
"This is done unconditionally now" "1.3.5")
"This is done unconditionally now" "1.3.5")
(defcustom mu4e-compose-in-new-frame nil
"Whether to compose messages in a new frame."
@ -95,7 +95,7 @@ its settings apply."
;; set the the signature separator to 'loose', since in the real world,
;; many message don't follow the standard...
(let ((message-signature-separator "^-- *$")
(message-signature-insert-empty-line t))
(message-signature-insert-empty-line t))
(funcall mu4e-compose-cite-function))
(pop-mark)
(goto-char (point-min))
@ -107,8 +107,8 @@ If VAL is nil, return nil."
;; note: the propertize here is currently useless, since gnus sets its own
;; later.
(when val (format "%s: %s\n"
(propertize hdr 'face 'mu4e-header-key-face)
(propertize val 'face 'mu4e-header-value-face))))
(propertize hdr 'face 'mu4e-header-key-face)
(propertize val 'face 'mu4e-header-value-face))))
(defconst mu4e~max-reference-num 21
"Specifies the maximum number of References:.
@ -119,7 +119,7 @@ As suggested by `message-shorten-references'.")
Beginning with CUTth
one. Code borrowed from `message-shorten-1'."
(setcdr (nthcdr (- cut 2) list)
(nthcdr (+ (- cut 2) surplus 1) list)))
(nthcdr (+ (- cut 2) surplus 1) list)))
(defun mu4e~draft-references-construct (msg)
"Construct the value of the References: header based on MSG.
@ -129,15 +129,15 @@ that :references includes the old in-reply-to as well) and the
message-id. If the message-id is empty, returns the old
References. If both are empty, return nil."
(let* ( ;; these are the ones from the message being replied to / forwarded
(refs (mu4e-message-field msg :references))
(msgid (mu4e-message-field msg :message-id))
;; now, append in
(refs (if (and msgid (not (string= msgid "")))
(append refs (list msgid)) refs))
;; no doubles
(refs (cl-delete-duplicates refs :test #'equal))
(refnum (length refs))
(cut 2))
(refs (mu4e-message-field msg :references))
(msgid (mu4e-message-field msg :message-id))
;; now, append in
(refs (if (and msgid (not (string= msgid "")))
(append refs (list msgid)) refs))
;; no doubles
(refs (cl-delete-duplicates refs :test #'equal))
(refnum (length refs))
(cut 2))
;; remove some refs when there are too many
(when (> refnum mu4e~max-reference-num)
(let ((surplus (- refnum mu4e~max-reference-num)))
@ -154,13 +154,13 @@ This is specified as a comma-separated list of e-mail addresses.
If LST is nil, returns nil."
(when lst
(mapconcat
(lambda (addrcell)
(let ((name (car addrcell))
(email (cdr addrcell)))
(if name
(format "%s <%s>" (mu4e~rfc822-quoteit name) email)
(format "%s" email))))
lst ", ")))
(lambda (addrcell)
(let ((name (car addrcell))
(email (cdr addrcell)))
(if name
(format "%s <%s>" (mu4e~rfc822-quoteit name) email)
(format "%s" email))))
lst ", ")))
(defun mu4e~draft-address-cell-equal (cell1 cell2)
"Return t if CELL1 and CELL2 have the same e-mail address.
@ -168,8 +168,8 @@ The comparison is done case-insensitively. If the cells done
match return nil. CELL1 and CELL2 are cons cells of the
form (NAME . EMAIL)."
(string=
(downcase (or (cdr cell1) ""))
(downcase (or (cdr cell2) ""))))
(downcase (or (cdr cell1) ""))
(downcase (or (cdr cell2) ""))))
(defun mu4e~draft-create-to-lst (origmsg)
@ -180,16 +180,16 @@ whatever was in the To: field before, goes to the Cc:-list (if
we're doing a reply-to-all). Special case: if we were the sender
of the original, we simple copy the list form the original."
(let ((reply-to
(or (plist-get origmsg :reply-to) (plist-get origmsg :from))))
(or (plist-get origmsg :reply-to) (plist-get origmsg :from))))
(cl-delete-duplicates reply-to :test #'mu4e~draft-address-cell-equal)
(if mu4e-compose-dont-reply-to-self
(cl-delete-if
(lambda (to-cell)
(cl-member-if
(cl-delete-if
(lambda (to-cell)
(cl-member-if
(lambda (addr)
(string= (downcase addr) (downcase (cdr to-cell))))
(mu4e-personal-addresses)))
reply-to)
reply-to)
reply-to)))
@ -198,24 +198,24 @@ of the original, we simple copy the list form the original."
I.e. return all the addresses in ADDRS not matching
`mu4e-compose-reply-ignore-address'."
(cond
((null mu4e-compose-reply-ignore-address)
addrs)
((functionp mu4e-compose-reply-ignore-address)
((null mu4e-compose-reply-ignore-address)
addrs)
((functionp mu4e-compose-reply-ignore-address)
(cl-remove-if
(lambda (elt)
(funcall mu4e-compose-reply-ignore-address (cdr elt)))
addrs))
(t
;; regexp or list of regexps
(let* ((regexp mu4e-compose-reply-ignore-address)
(regexp (if (listp regexp)
(mapconcat (lambda (elt) (concat "\\(" elt "\\)"))
regexp "\\|")
regexp)))
(cl-remove-if
(lambda (elt)
(funcall mu4e-compose-reply-ignore-address (cdr elt)))
addrs))
(t
;; regexp or list of regexps
(let* ((regexp mu4e-compose-reply-ignore-address)
(regexp (if (listp regexp)
(mapconcat (lambda (elt) (concat "\\(" elt "\\)"))
regexp "\\|")
regexp)))
(cl-remove-if
(lambda (elt)
(string-match regexp (cdr elt)))
addrs)))))
(lambda (elt)
(string-match regexp (cdr elt)))
addrs)))))
(defun mu4e~draft-create-cc-lst (origmsg &optional reply-all include-from)
"Create a list of address for the Cc: in a new message.
@ -223,37 +223,37 @@ This is based on the original message ORIGMSG, and whether it's a
REPLY-ALL."
(when reply-all
(let* ((cc-lst ;; get the cc-field from the original, remove dups
(cl-delete-duplicates
(append
(plist-get origmsg :to)
(plist-get origmsg :cc)
(when include-from(plist-get origmsg :from))
(plist-get origmsg :list-post))
:test #'mu4e~draft-address-cell-equal))
;; now we have the basic list, but we must remove
;; addresses also in the To: list
(cc-lst
(cl-delete-if
(lambda (cc-cell)
(cl-find-if
(lambda (to-cell)
(mu4e~draft-address-cell-equal cc-cell to-cell))
(mu4e~draft-create-to-lst origmsg)))
cc-lst))
;; remove ignored addresses
(cc-lst (mu4e~strip-ignored-addresses cc-lst))
;; finally, we need to remove ourselves from the cc-list
;; unless mu4e-compose-keep-self-cc is non-nil
(cc-lst
(if (or mu4e-compose-keep-self-cc (null user-mail-address))
(cl-delete-duplicates
(append
(plist-get origmsg :to)
(plist-get origmsg :cc)
(when include-from(plist-get origmsg :from))
(plist-get origmsg :list-post))
:test #'mu4e~draft-address-cell-equal))
;; now we have the basic list, but we must remove
;; addresses also in the To: list
(cc-lst
(cl-delete-if
(lambda (cc-cell)
(cl-find-if
(lambda (to-cell)
(mu4e~draft-address-cell-equal cc-cell to-cell))
(mu4e~draft-create-to-lst origmsg)))
cc-lst))
;; remove ignored addresses
(cc-lst (mu4e~strip-ignored-addresses cc-lst))
;; finally, we need to remove ourselves from the cc-list
;; unless mu4e-compose-keep-self-cc is non-nil
(cc-lst
(if (or mu4e-compose-keep-self-cc (null user-mail-address))
cc-lst
(cl-delete-if
(lambda (cc-cell)
(cl-member-if
(lambda (addr)
(string= (downcase addr) (downcase (cdr cc-cell))))
(mu4e-personal-addresses)))
cc-lst))))
(cl-delete-if
(lambda (cc-cell)
(cl-member-if
(lambda (addr)
(string= (downcase addr) (downcase (cdr cc-cell))))
(mu4e-personal-addresses)))
cc-lst))))
cc-lst)))
(defun mu4e~draft-recipients-construct (field origmsg &optional reply-all include-from)
@ -262,13 +262,13 @@ REPLY-ALL."
and (optionally) REPLY-ALL which indicates this is a reply-to-all
message. Return nil if there are no recipients for the particular field."
(mu4e~draft-recipients-list-to-string
(cl-case field
(:to
(mu4e~draft-create-to-lst origmsg))
(:cc
(mu4e~draft-create-cc-lst origmsg reply-all include-from))
(otherwise
(mu4e-error "Unsupported field")))))
(cl-case field
(:to
(mu4e~draft-create-to-lst origmsg))
(:cc
(mu4e~draft-create-cc-lst origmsg reply-all include-from))
(otherwise
(mu4e-error "Unsupported field")))))
;;; RFC2822 handling of phrases in mail-addresses
;;; The optional display-name contains a phrase, it sits before the angle-addr
@ -284,14 +284,14 @@ The reverse of the RFC atext definition is then tested.
If it matches, nil is returned, if not, it is an 'rfc822-atom, which
is returned."
(cond
((= (length ph) 0) 'rfc822-empty)
((= (aref ph 0) ?\")
(if (string-match "\"\\([^\"\\\n]\\|\\\\.\\|\\\\\n\\)*\"" ph)
((= (length ph) 0) 'rfc822-empty)
((= (aref ph 0) ?\")
(if (string-match "\"\\([^\"\\\n]\\|\\\\.\\|\\\\\n\\)*\"" ph)
'rfc822-quoted-string
'rfc822-containing-quote)) ; starts with quote, but doesn't end with one
((string-match-p "[\"]" ph) 'rfc822-containing-quote)
((string-match-p "[\000-\037()\*<>@,;:\\\.]+" ph) nil)
(t 'rfc822-atom)))
'rfc822-containing-quote)) ; starts with quote, but doesn't end with one
((string-match-p "[\"]" ph) 'rfc822-containing-quote)
((string-match-p "[\000-\037()\*<>@,;:\\\.]+" ph) nil)
(t 'rfc822-atom)))
(defun mu4e~rfc822-quoteit (ph)
"Quote an RFC822 phrase PH only if necessary.
@ -299,12 +299,12 @@ Atoms and quoted strings don't need quotes. The rest do. In
case a phrase contains a quote, it will be escaped."
(let ((type (mu4e~rfc822-phrase-type ph)))
(cond
((eq type 'rfc822-atom) ph)
((eq type 'rfc822-quoted-string) ph)
((eq type 'rfc822-containing-quote)
(format "\"%s\""
(replace-regexp-in-string "\"" "\\\\\"" ph)))
(t (format "\"%s\"" ph)))))
((eq type 'rfc822-atom) ph)
((eq type 'rfc822-quoted-string) ph)
((eq type 'rfc822-containing-quote)
(format "\"%s\""
(replace-regexp-in-string "\"" "\\\\\"" ph)))
(t (format "\"%s\"" ph)))))
(defun mu4e~draft-from-construct ()
@ -313,7 +313,7 @@ This is based on the variable `user-full-name' and
`user-mail-address'; if the latter is nil, function returns nil."
(when user-mail-address
(if user-full-name
(format "%s <%s>" (mu4e~rfc822-quoteit user-full-name) user-mail-address)
(format "%s <%s>" (mu4e~rfc822-quoteit user-full-name) user-mail-address)
(format "%s" user-mail-address))))
@ -333,23 +333,23 @@ separator is never written to the message file. Also see
;; make sure there's not one already
(mu4e~draft-remove-mail-header-separator)
(let ((sepa (propertize mail-header-separator
'intangible t
;; don't make this read-only, message-mode
;; seems to require it being writable in some cases
;;'read-only "Can't touch this"
'rear-nonsticky t
'font-lock-face 'mu4e-compose-separator-face)))
'intangible t
;; don't make this read-only, message-mode
;; seems to require it being writable in some cases
;;'read-only "Can't touch this"
'rear-nonsticky t
'font-lock-face 'mu4e-compose-separator-face)))
(widen)
;; search for the first empty line
(goto-char (point-min))
(if (search-forward-regexp "^$" nil t)
(progn
(replace-match sepa)
;; `message-narrow-to-headers` searches for a
;; `mail-header-separator` followed by a new line. Therefore, we
;; must insert a newline if on the last line of the buffer.
(when (= (point) (point-max))
(insert "\n")))
(progn
(replace-match sepa)
;; `message-narrow-to-headers` searches for a
;; `mail-header-separator` followed by a new line. Therefore, we
;; must insert a newline if on the last line of the buffer.
(when (= (point) (point-max))
(insert "\n")))
(progn ;; no empty line? then prepend one
(goto-char (point-max))
(insert "\n" sepa))))))
@ -372,15 +372,15 @@ never hits the disk. Also see
"Ask user whether she wants to reply to *all* recipients.
If there is just one recipient of ORIGMSG do nothing."
(let* ((recipnum
(+ (length (mu4e~draft-create-to-lst origmsg))
(+ (length (mu4e~draft-create-to-lst origmsg))
(length (mu4e~draft-create-cc-lst origmsg t))))
(response
(if (< recipnum 2)
(response
(if (< recipnum 2)
'all ;; with less than 2 recipients, we can reply to 'all'
(mu4e-read-option
"Reply to "
`( (,(format "all %d recipients" recipnum) . all)
("sender only" . sender-only))))))
(mu4e-read-option
"Reply to "
`( (,(format "all %d recipients" recipnum) . all)
("sender only" . sender-only))))))
(eq response 'all)))
(defun mu4e~draft-message-filename-construct (&optional flagstr)
@ -389,25 +389,25 @@ It looks something like
<time>-<random>.<hostname>:2,
You can append flags."
(let* ((sysname (if (fboundp 'system-name)
(system-name)
(system-name)
(with-no-warnings system-name)))
(sysname (if (string= sysname "") "localhost" sysname))
(hostname (downcase
(save-match-data
(substring sysname
(string-match "^[^.]+" sysname)
(match-end 0))))))
(sysname (if (string= sysname "") "localhost" sysname))
(hostname (downcase
(save-match-data
(substring sysname
(string-match "^[^.]+" sysname)
(match-end 0))))))
(format "%s.%04x%04x%04x%04x.%s:2,%s"
(format-time-string "%s" (current-time))
(random 65535) (random 65535) (random 65535) (random 65535)
hostname (or flagstr ""))))
(format-time-string "%s" (current-time))
(random 65535) (random 65535) (random 65535) (random 65535)
hostname (or flagstr ""))))
(defun mu4e~draft-common-construct ()
"Construct the common headers for each message."
(concat
(when mu4e-user-agent-string
(mu4e~draft-header "User-agent" mu4e-user-agent-string))
(mu4e~draft-header "Date" (message-make-date))))
(when mu4e-user-agent-string
(mu4e~draft-header "User-agent" mu4e-user-agent-string))
(mu4e~draft-header "Date" (message-make-date))))
(defconst mu4e~draft-reply-prefix "Re: "
"String to prefix replies with.")
@ -415,81 +415,81 @@ You can append flags."
(defun mu4e~draft-reply-construct-recipients (origmsg)
"Determine the to/cc recipients for a reply message."
(let* ((reply-to-self (mu4e-message-contact-field-matches-me origmsg :from))
;; reply-to-self implies reply-all
(reply-all (or reply-to-self
(eq mu4e-compose-reply-recipients 'all)
(and (not (eq mu4e-compose-reply-recipients 'sender))
(mu4e~draft-reply-all-p origmsg)))))
;; reply-to-self implies reply-all
(reply-all (or reply-to-self
(eq mu4e-compose-reply-recipients 'all)
(and (not (eq mu4e-compose-reply-recipients 'sender))
(mu4e~draft-reply-all-p origmsg)))))
(concat
(if reply-to-self
;; When we're replying to ourselves, simply keep the same headers.
(concat
(if reply-to-self
;; When we're replying to ourselves, simply keep the same headers.
(concat
(mu4e~draft-header "To" (mu4e~draft-recipients-list-to-string
(mu4e-message-field origmsg :to)))
(mu4e-message-field origmsg :to)))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-list-to-string
(mu4e-message-field origmsg :cc))))
(mu4e-message-field origmsg :cc))))
;; if there's no-one in To, copy the CC-list
(if (zerop (length (mu4e~draft-create-to-lst origmsg)))
(mu4e~draft-header "To" (mu4e~draft-recipients-construct
;; if there's no-one in To, copy the CC-list
(if (zerop (length (mu4e~draft-create-to-lst origmsg)))
(mu4e~draft-header "To" (mu4e~draft-recipients-construct
:cc origmsg reply-all))
;; otherwise...
(concat
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg reply-all))))))))
;; otherwise...
(concat
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg reply-all))))))))
(defun mu4e~draft-reply-construct-recipients-list (origmsg)
"Determine the to/cc recipients for a reply message to a
mailing-list."
(let* ( ;; reply-to-self implies reply-all
(list-post (plist-get origmsg :list-post))
(from (plist-get origmsg :from))
(recipnum
(+ (length (mu4e~draft-create-to-lst origmsg))
(length (mu4e~draft-create-cc-lst origmsg t t))))
(reply-type
(mu4e-read-option
"Reply to mailing-list "
`( (,(format "all %d recipient(s)" recipnum) . all)
(,(format "list-only (%s)" (cdar list-post)) . list-only)
(,(format "sender-only (%s)" (cdar from)) . sender-only)))))
(list-post (plist-get origmsg :list-post))
(from (plist-get origmsg :from))
(recipnum
(+ (length (mu4e~draft-create-to-lst origmsg))
(length (mu4e~draft-create-cc-lst origmsg t t))))
(reply-type
(mu4e-read-option
"Reply to mailing-list "
`( (,(format "all %d recipient(s)" recipnum) . all)
(,(format "list-only (%s)" (cdar list-post)) . list-only)
(,(format "sender-only (%s)" (cdar from)) . sender-only)))))
(cl-case reply-type
(all
(concat
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg t t))))
(concat
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg t t))))
(list-only
(mu4e~draft-header "To"
(mu4e~draft-recipients-list-to-string list-post)))
(mu4e~draft-header "To"
(mu4e~draft-recipients-list-to-string list-post)))
(sender-only
(mu4e~draft-header "To"
(mu4e~draft-recipients-list-to-string from))))))
(mu4e~draft-header "To"
(mu4e~draft-recipients-list-to-string from))))))
(defun mu4e~draft-reply-construct (origmsg)
"Create a draft message as a reply to ORIGMSG.
Replying-to-self is special; in that case, the To and Cc fields
will be the same as in the original."
(let* ((old-msgid (plist-get origmsg :message-id))
(subject (concat mu4e~draft-reply-prefix
(message-strip-subject-re
(or (plist-get origmsg :subject) ""))))
(list-post (plist-get origmsg :list-post)))
(subject (concat mu4e~draft-reply-prefix
(message-strip-subject-re
(or (plist-get origmsg :subject) ""))))
(list-post (plist-get origmsg :list-post)))
(concat
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
(if list-post ;; mailing-lists are a bit special.
(mu4e~draft-reply-construct-recipients-list origmsg)
(mu4e~draft-reply-construct-recipients origmsg))
(if list-post ;; mailing-lists are a bit special.
(mu4e~draft-reply-construct-recipients-list origmsg)
(mu4e~draft-reply-construct-recipients origmsg))
(mu4e~draft-header "Subject" subject)
(mu4e~draft-header "References"
(mu4e~draft-references-construct origmsg))
(mu4e~draft-common-construct)
(when old-msgid
(mu4e~draft-header "In-reply-to" (format "<%s>" old-msgid)))
"\n\n"
(mu4e~draft-cite-original origmsg))))
(mu4e~draft-header "Subject" subject)
(mu4e~draft-header "References"
(mu4e~draft-references-construct origmsg))
(mu4e~draft-common-construct)
(when old-msgid
(mu4e~draft-header "In-reply-to" (format "<%s>" old-msgid)))
"\n\n"
(mu4e~draft-cite-original origmsg))))
(defconst mu4e~draft-forward-prefix "Fwd: "
"String to prefix replies with.")
@ -497,34 +497,34 @@ will be the same as in the original."
(defun mu4e~draft-forward-construct (origmsg)
"Create a draft forward message for original message ORIGMSG."
(let ((subject
(or (plist-get origmsg :subject) "")))
(or (plist-get origmsg :subject) "")))
(concat
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
(mu4e~draft-header "To" "")
(mu4e~draft-common-construct)
(mu4e~draft-header "References"
(mu4e~draft-references-construct origmsg))
(mu4e~draft-header "Subject"
(concat
;; if there's no Fwd: yet, prepend it
(if (string-match "^Fwd:" subject)
""
mu4e~draft-forward-prefix)
subject))
(unless mu4e-compose-forward-as-attachment
(concat
"\n\n"
(mu4e~draft-cite-original origmsg))))))
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
(mu4e~draft-header "To" "")
(mu4e~draft-common-construct)
(mu4e~draft-header "References"
(mu4e~draft-references-construct origmsg))
(mu4e~draft-header "Subject"
(concat
;; if there's no Fwd: yet, prepend it
(if (string-match "^Fwd:" subject)
""
mu4e~draft-forward-prefix)
subject))
(unless mu4e-compose-forward-as-attachment
(concat
"\n\n"
(mu4e~draft-cite-original origmsg))))))
(defun mu4e~draft-newmsg-construct ()
"Create a new message."
(concat
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
(mu4e~draft-header "To" "")
(mu4e~draft-header "Subject" "")
(mu4e~draft-common-construct)))
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
(mu4e~draft-header "To" "")
(mu4e~draft-header "Subject" "")
(mu4e~draft-common-construct)))
(defvar mu4e~draft-drafts-folder nil
"The drafts-folder for this compose buffer.
@ -533,13 +533,13 @@ This is based on `mu4e-drafts-folder', which is evaluated once.")
(defun mu4e~draft-open-file (path)
"Open the the draft file at PATH."
(if mu4e-compose-in-new-frame
(find-file-other-frame path)
(find-file-other-frame path)
(find-file path)))
(defun mu4e~draft-determine-path (draft-dir)
"Determines the path for a new draft file in DRAFT-DIR."
(format "%s/%s/cur/%s"
(mu4e-root-maildir) draft-dir (mu4e~draft-message-filename-construct "DS")))
(mu4e-root-maildir) draft-dir (mu4e~draft-message-filename-construct "DS")))
(defun mu4e-draft-open (compose-type &optional msg)
@ -558,39 +558,39 @@ will be created from either `mu4e~draft-reply-construct', or
(cl-case compose-type
(edit
;; case-1: re-editing a draft messages. in this case, we do know the
;; full path, but we cannot really know 'drafts folder'... we make a
;; guess
(setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path)))
(mu4e~draft-open-file (mu4e-message-field msg :path)))
;; case-1: re-editing a draft messages. in this case, we do know the
;; full path, but we cannot really know 'drafts folder'... we make a
;; guess
(setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path)))
(mu4e~draft-open-file (mu4e-message-field msg :path)))
(resend
;; case-2: copy some exisisting message to a draft message, then edit
;; that.
(setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path)))
(let ((draft-path (mu4e~draft-determine-path draft-dir)))
(copy-file (mu4e-message-field msg :path) draft-path)
(mu4e~draft-open-file draft-path)))
;; case-2: copy some exisisting message to a draft message, then edit
;; that.
(setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path)))
(let ((draft-path (mu4e~draft-determine-path draft-dir)))
(copy-file (mu4e-message-field msg :path) draft-path)
(mu4e~draft-open-file draft-path)))
((reply forward new)
;; case-3: creating a new message; in this case, we can determine
;; mu4e-get-drafts-folder
(setq draft-dir (mu4e-get-drafts-folder msg))
(let ((draft-path (mu4e~draft-determine-path draft-dir))
(initial-contents
(cl-case compose-type
(reply (mu4e~draft-reply-construct msg))
(forward (mu4e~draft-forward-construct msg))
(new (mu4e~draft-newmsg-construct)))))
(mu4e~draft-open-file draft-path)
(insert initial-contents)
(newline)
;; include the message signature (if it's set)
(if (and mu4e-compose-signature-auto-include mu4e-compose-signature)
(let ((message-signature mu4e-compose-signature))
(save-excursion
(message-insert-signature)
(mu4e~fontify-signature))))))
;; case-3: creating a new message; in this case, we can determine
;; mu4e-get-drafts-folder
(setq draft-dir (mu4e-get-drafts-folder msg))
(let ((draft-path (mu4e~draft-determine-path draft-dir))
(initial-contents
(cl-case compose-type
(reply (mu4e~draft-reply-construct msg))
(forward (mu4e~draft-forward-construct msg))
(new (mu4e~draft-newmsg-construct)))))
(mu4e~draft-open-file draft-path)
(insert initial-contents)
(newline)
;; include the message signature (if it's set)
(if (and mu4e-compose-signature-auto-include mu4e-compose-signature)
(let ((message-signature mu4e-compose-signature))
(save-excursion
(message-insert-signature)
(mu4e~fontify-signature))))))
(t (mu4e-error "Unsupported compose-type %S" compose-type)))
;; if we didn't find a draft folder yet, try some default
(unless draft-dir