mirror of https://github.com/djcb/mu.git
* mu4e: when replying to messages written by self, keep the same to:/cc:
This commit is contained in:
parent
b17f26537b
commit
5ecbb40557
|
@ -119,7 +119,9 @@ form (NAME . EMAIL)."
|
||||||
"Create a list of address for the To: in a new message, based on
|
"Create a list of address for the To: in a new message, based on
|
||||||
the original message ORIGMSG. If the Reply-To address is set, use
|
the original message ORIGMSG. If the Reply-To address is set, use
|
||||||
that, otherwise use the From address. Note, whatever was in the To:
|
that, otherwise use the From address. Note, whatever was in the To:
|
||||||
field before, goes to the Cc:-list (if we're doing a reply-to-all)."
|
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
|
(let ((reply-to
|
||||||
(or (plist-get origmsg :reply-to) (plist-get origmsg :from))))
|
(or (plist-get origmsg :reply-to) (plist-get origmsg :from))))
|
||||||
(delete-duplicates reply-to :test #'mu4e~draft-address-cell-equal)
|
(delete-duplicates reply-to :test #'mu4e~draft-address-cell-equal)
|
||||||
|
@ -275,35 +277,45 @@ You can append flags."
|
||||||
"String to prefix replies with.")
|
"String to prefix replies with.")
|
||||||
|
|
||||||
(defun mu4e~draft-reply-construct (origmsg)
|
(defun mu4e~draft-reply-construct (origmsg)
|
||||||
"Create a draft message as a reply to original message ORIGMSG."
|
"Create a draft message as a reply to original message
|
||||||
(let* ((recipnum
|
ORIGMSG. Replying-to-self is a special; in that case, the To and Cc
|
||||||
(+ (length (mu4e~draft-create-to-lst origmsg))
|
fields will be the same as in the original."
|
||||||
(length (mu4e~draft-create-cc-lst origmsg t))))
|
(let* ((reply-to-self (mu4e-message-contact-field-matches-me msg :from))
|
||||||
(reply-all (mu4e~draft-user-wants-reply-all origmsg))
|
(recipnum
|
||||||
|
(+ (length (mu4e~draft-create-to-lst origmsg))
|
||||||
|
(length (mu4e~draft-create-cc-lst origmsg t))))
|
||||||
|
;; reply-to-self implies reply-all
|
||||||
|
(reply-all (or reply-to-self (mu4e~draft-user-wants-reply-all origmsg)))
|
||||||
(old-msgid (plist-get origmsg :message-id))
|
(old-msgid (plist-get origmsg :message-id))
|
||||||
(subject
|
(subject
|
||||||
(concat mu4e~draft-reply-prefix
|
(concat mu4e~draft-reply-prefix
|
||||||
(message-strip-subject-re (or (plist-get origmsg :subject) "")))))
|
(message-strip-subject-re (or (plist-get origmsg :subject) "")))))
|
||||||
(concat
|
(concat
|
||||||
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
|
(mu4e~draft-header "From" (or (mu4e~draft-from-construct) ""))
|
||||||
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
|
(mu4e~draft-header "Reply-To" mu4e-compose-reply-to-address)
|
||||||
;; 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))))
|
|
||||||
|
|
||||||
(mu4e~draft-header "Subject" subject)
|
(if reply-to-self
|
||||||
(mu4e~draft-header "References"
|
;; When we're replying to ourselves, simply keep the same headers.
|
||||||
(mu4e~draft-references-construct origmsg))
|
(concat
|
||||||
(mu4e~draft-common-construct)
|
(mu4e~draft-header "To" (mu4e-message-field :to origmsg))
|
||||||
(when old-msgid
|
(mu4e~draft-header "Cc" (mu4e-message-field :cc origmsg)))
|
||||||
(mu4e~draft-header "In-reply-to" (format "<%s>" old-msgid)))
|
|
||||||
"\n\n"
|
;; if there's no-one in To, copy the CC-list
|
||||||
(mu4e~draft-cite-original origmsg))))
|
(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)))))
|
||||||
|
(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: "
|
(defconst mu4e~draft-forward-prefix "Fwd: "
|
||||||
"String to prefix replies with.")
|
"String to prefix replies with.")
|
||||||
|
|
|
@ -215,14 +215,25 @@ match."
|
||||||
(and email (string-match rx email)))))
|
(and email (string-match rx email)))))
|
||||||
(mu4e-message-field msg cfield))))
|
(mu4e-message-field msg cfield))))
|
||||||
|
|
||||||
|
(defun mu4e-message-contact-field-matches-me (msg cfield)
|
||||||
|
"Checks whether any of the of the contacts in field
|
||||||
|
CFIELD (either :to, :from, :cc or :bcc) of msg MSG matches *me*,
|
||||||
|
that is, any of the e-mail address in
|
||||||
|
`mu4e-user-mail-address-list'. Returns the contact cell that
|
||||||
|
matched, or nil."
|
||||||
|
(find-if
|
||||||
|
(lambda (cc-cell)
|
||||||
|
(member-if
|
||||||
|
(lambda (addr)
|
||||||
|
(string= (downcase addr) (downcase (cdr cc-cell))))
|
||||||
|
mu4e-user-mail-address-list))
|
||||||
|
(mu4e-message-field msg cfield)))
|
||||||
|
|
||||||
(defsubst mu4e-message-part-field (msgpart field)
|
(defsubst mu4e-message-part-field (msgpart field)
|
||||||
"Get some field in a message part; a part would look something like:
|
"Get some field in a message part; a part would look something like:
|
||||||
(:index 2 :name \"photo.jpg\" :mime-type \"image/jpeg\" :size 147331)."
|
(:index 2 :name \"photo.jpg\" :mime-type \"image/jpeg\" :size 147331)."
|
||||||
(plist-get msgpart field))
|
(plist-get msgpart field))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; backward compatibility ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; backward compatibility ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(defalias 'mu4e-msg-field 'mu4e-message-field)
|
(defalias 'mu4e-msg-field 'mu4e-message-field)
|
||||||
(defalias 'mu4e-body-text 'mu4e-message-body-text) ;; backward compatibility
|
(defalias 'mu4e-body-text 'mu4e-message-body-text) ;; backward compatibility
|
||||||
|
|
Loading…
Reference in New Issue