From b02e92996093ffd6db404db796e16e1511a7c431 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 21 Apr 2013 12:40:57 +0300 Subject: [PATCH] * mu4e-compose: allow mu4e-sent-message-behavior to be a function (thanks to egh) --- mu4e/mu4e-compose.el | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index ecc982f0..089dcf7d 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -99,8 +99,19 @@ This is one of the symbols: Note, when using GMail/IMAP, you should set this to either `trash' or `delete', since GMail already takes care of keeping -copies in the sent folder." - :type '(choice (const :tag "move message to mu4e-sent-folder" sent) +copies in the sent folder. + +Alternatively, `mu4e-sent-messages-behavior' can be a function +which takes no arguments, and which should return on of the mentioned symbols, +for example: + + (setq mu4e-sent-messages-behavior (lambda () + (if (string= (message-sendmail-envelope-from) \"foo@example.com\") + 'delete 'sent))) + +The various `message-' functions from `message-mode' are available +for quering the message information." + :type '(choice (const :tag "move message to mu4e-sent-folder" sent) (const :tag "move message to mu4e-trash-folder" trash) (const :tag "delete message" delete)) :safe 'symbolp @@ -147,8 +158,12 @@ Messages are captured with `mu4e-action-capture-message'." (defun mu4e~compose-setup-fcc-maybe () "Maybe setup Fcc, based on `mu4e-sent-messages-behavior'. If needed, set the Fcc header, and register the handler function." - (let* ((mdir - (case mu4e-sent-messages-behavior + (let* ((sent-behavior + (if (functionp mu4e-sent-messages-behavior) + (funcall mu4e-sent-messages-behavior) + mu4e-sent-messages-behavior)) + (mdir + (case sent-behavior (delete nil) (trash (mu4e-get-trash-folder mu4e-compose-parent-message)) (sent (mu4e-get-sent-folder mu4e-compose-parent-message)) @@ -251,7 +266,8 @@ appear on disk." (mu4e~compose-setup-completion)) (define-key mu4e-compose-mode-map (kbd "C-S-u") 'mu4e-update-mail-and-index) - + (define-key mu4e-compose-mode-map (kbd "C-c C-u") 'mu4e-update-mail-and-index) + ;; setup the fcc-stuff, if needed (add-hook 'message-send-hook (defun mu4e~compose-save-before-sending ()