X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-mua.el;h=57465b205a60a7875a66fdbd39874ca56f2e376c;hp=bf6253fc4669638da27b934063deb0fe035c75f9;hb=e26d99dc7b02f33299c281f97a13deaef802bc7a;hpb=30a0ed197efae461912138fb4e5f70849124fee3 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index bf6253fc..57465b20 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -50,7 +50,7 @@ window/frame that will be destroyed when the buffer is killed. You may want to customize `message-kill-buffer-on-exit' accordingly." (when (< emacs-major-version 24) - " Due to a known bug in Emacs 23, you should not set + " Due to a known bug in Emacs 23, you should not set this to `new-window' if `message-kill-buffer-on-exit' is disabled: this would result in an incorrect behavior.")) :group 'notmuch-send @@ -75,6 +75,22 @@ list." :type '(repeat string) :group 'notmuch-send) +(defgroup notmuch-reply nil + "Replying to messages in notmuch" + :group 'notmuch) + +(defcustom notmuch-mua-cite-function 'message-cite-original + "*Function for citing an original message. +Predefined functions include `message-cite-original' and +`message-cite-original-without-signature'. +Note that these functions use `mail-citation-hook' if that is non-nil." + :type '(radio (function-item message-cite-original) + (function-item message-cite-original-without-signature) + (function-item sc-cite-original) + (function :tag "Other")) + :link '(custom-manual "(message)Insertion Variables") + :group 'notmuch-reply) + ;; (defun notmuch-mua-get-switch-function () @@ -102,7 +118,10 @@ list." (defun notmuch-mua-user-agent-notmuch () "Generate a `User-Agent:' string suitable for notmuch." - (concat "Notmuch/" (notmuch-version) " (http://notmuchmail.org)")) + (let ((notmuch-version (if (string= notmuch-emacs-version "unknown") + (notmuch-cli-version) + notmuch-emacs-version))) + (concat "Notmuch/" notmuch-version " (http://notmuchmail.org)"))) (defun notmuch-mua-user-agent-emacs () "Generate a `User-Agent:' string suitable for notmuch." @@ -116,10 +135,9 @@ list." notmuch-mua-hidden-headers)) (defun notmuch-mua-reply-crypto (parts) + "Add mml sign-encrypt flag if any part of original message is encrypted." (loop for part in parts - if (notmuch-match-content-type (plist-get part :content-type) "multipart/signed") - do (mml-secure-message-sign) - else if (notmuch-match-content-type (plist-get part :content-type) "multipart/encrypted") + if (notmuch-match-content-type (plist-get part :content-type) "multipart/encrypted") do (mml-secure-message-sign-encrypt) else if (notmuch-match-content-type (plist-get part :content-type) "multipart/*") do (notmuch-mua-reply-crypto (plist-get part :content)))) @@ -221,8 +239,9 @@ list." (date (plist-get original-headers :Date)) (start (point))) - ;; message-cite-original constructs a citation line based on the From and Date - ;; headers of the original message, which are assumed to be in the buffer. + ;; notmuch-mua-cite-function constructs a citation line based + ;; on the From and Date headers of the original message, which + ;; are assumed to be in the buffer. (insert "From: " from "\n") (insert "Date: " date "\n\n") @@ -234,9 +253,9 @@ list." (set-mark (point)) (goto-char start) ;; Quote the original message according to the user's configured style. - (message-cite-original))) + (funcall notmuch-mua-cite-function))) - ;; Sign and/or encrypt replies to signed and/or encrypted messages. + ;; Crypto processing based crypto content of the original message (when process-crypto (notmuch-mua-reply-crypto (plist-get original :body)))) @@ -249,6 +268,12 @@ list." (message-goto-body) (set-buffer-modified-p nil)) +(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]" + "Notmuch message composition mode. Mostly like `message-mode'") + +(define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit) +(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send) + (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args) "Invoke the notmuch mail composition window. @@ -265,6 +290,8 @@ OTHER-ARGS are passed through to `message-mail'." (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers)) (apply #'message-mail to subject other-headers other-args) + (notmuch-message-mode) + (notmuch-fcc-header-setup) (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) @@ -347,7 +374,8 @@ the From: address first." (message-forward-make-body cur) ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. - (message-hide-headers))) + (message-hide-headers) + (set-buffer-modified-p nil))) (defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all) "Compose a reply to the message identified by QUERY-STRING. @@ -377,7 +405,13 @@ will be addressed to all recipients of the source message." (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") - (message-send-and-exit arg)) + (let ((message-fcc-handler-function #'notmuch-fcc-handler)) + (message-send-and-exit arg))) + +(defun notmuch-mua-send (&optional arg) + (interactive "P") + (let ((message-fcc-handler-function #'notmuch-fcc-handler)) + (message-send arg))) (defun notmuch-mua-kill-buffer () (interactive)