diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 1106d65f..fad73dfe 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -117,7 +117,7 @@ for quering the message information." :safe 'symbolp :group 'mu4e-compose) -(defvar mu4e-compose-pre-hook nil +(defcustom mu4e-compose-pre-hook nil "Hook run just *before* message composition starts. If the compose-type is either 'reply' or 'forward', the variable `mu4e-compose-parent-message' points to the message replied to / @@ -127,7 +127,9 @@ Note that there is no draft message yet when this hook runs, it is meant for influencing the how mu4e constructs the draft message. If you want to do something with the draft messages after it has been constructed, `mu4e-compose-mode-hook' would be the -place to do that.") +place to do that." + :type 'hook + :group 'mu4e-compose) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -265,6 +267,8 @@ appear on disk." \\{message-mode-map}." (progn (use-local-map mu4e-compose-mode-map) + (set (make-local-variable 'message-signature) + mu4e-compose-signature) (make-local-variable 'message-default-charset) ;; if the default charset is not set, use UTF-8 (unless message-default-charset @@ -360,10 +364,6 @@ tempfile)." (dolist (att includes) (mml-attach-file (plist-get att :file-name) (plist-get att :mime-type)))) - ;; include the message signature (if it's set); but not when editing an - ;; existing message. - (unless (eq compose-type 'edit) - (message-insert-signature)) ;; buffer is not user-modified yet (mu4e~compose-set-friendly-buffer-name compose-type) (set-buffer-modified-p nil) @@ -377,9 +377,8 @@ tempfile)." ;; hide some headers (mu4e~compose-hide-headers) ;; switch on the mode - (run-with-timer 0.01 nil #'(lambda () (mu4e-compose-mode)))) - - + (mu4e-compose-mode)) + (defun mu4e-sent-handler (docid path) "Handler function, called with DOCID and PATH for the just-sent message. For Forwarded ('Passed') and Replied messages, try to set diff --git a/mu4e/mu4e-draft.el b/mu4e/mu4e-draft.el index ff257e5b..a881d91d 100644 --- a/mu4e/mu4e-draft.el +++ b/mu4e/mu4e-draft.el @@ -32,6 +32,7 @@ (require 'mu4e-vars) (require 'mu4e-utils) (require 'mu4e-message) +(require 'message) ;; mail-header-separator ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -43,27 +44,45 @@ :type 'boolean :group 'mu4e-compose) +(defcustom mu4e-compose-cite-function + (or message-cite-function 'message-cite-original-without-signature) + "The function to use to cite message in replies and forwarded +messages. This is the mu4e-specific version of +`message-cite-function'." + :type 'function + :group 'mu4e-compose) + +(defcustom mu4e-compose-signature + (or message-signature "Sent with my mu4e") + "The message signature (i.e. the blob at the bottom of +messages). This is the mu4e-specific version of +`message-signature'." + :type 'sexp + :group 'mu4e-compose) + (defun mu4e~draft-user-agent-construct () "Return the User-Agent string for mu4e. This is either the value of `mu4e-user-agent', or, if not set, a string based on the versions of mu4e and emacs." (format "mu4e %s; emacs %s" mu4e-mu-version emacs-version)) - (defun mu4e~draft-cite-original (msg) "Return a cited version of the original message MSG as a plist. -This function use gnus' `message-cite-function', and as such all -its settings apply." +This function uses gnus' `mu4e-compose-cite-function', and as such +all its settings apply." (with-temp-buffer (when (fboundp 'mu4e-view-message-text) ;; keep bytecompiler happy (insert (mu4e-view-message-text msg)) - ;; this seems to be needed, otherwise existing signatures - ;; won't be stripped (message-yank-original) (goto-char (point-min)) (push-mark (point-max)) - (funcall message-cite-function) + ;; set the the signature separator to 'loose', since in the real world, + ;; many message don't follow the standard... + (let ((message-signature-separator "^-- *$")) + (funcall mu4e-compose-cite-function)) (pop-mark) + (goto-char (point-min)) + (mu4e~fontify-cited) (buffer-string)))) (defun mu4e~draft-header (hdr val) @@ -219,7 +238,7 @@ separator is never written to the message file. Also see 'intangible t 'read-only "Can't touch this" 'rear-nonsticky t - 'font-lock-face 'mu4e-separator-face))) + 'font-lock-face 'mu4e-compose-separator-face))) (widen) ;; search for the first empty line (goto-char (point-min)) @@ -260,9 +279,7 @@ If there is just one recipient of ORIGMSG do nothing." (defun mu4e~draft-message-filename-construct (&optional flagstr) "Construct a randomized name for a message file with flags FLAGSTR. It looks something like -