]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-mua.el
emacs: make citation function customizable.
[notmuch] / emacs / notmuch-mua.el
index ba3ef275ec5ef03f894602499f224cce99130ed1..33f139987e659135cb2aeb29767144455a26429e 100644 (file)
@@ -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 ()
@@ -115,6 +131,14 @@ list."
            (push header message-hidden-headers)))
        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/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))))
+
 (defun notmuch-mua-get-quotable-parts (parts)
   (loop for part in parts
        if (notmuch-match-content-type (plist-get part :content-type) "multipart/alternative")
@@ -151,9 +175,10 @@ list."
 
 (defun notmuch-mua-reply (query-string &optional sender reply-all)
   (let ((args '("reply" "--format=sexp" "--format-version=1"))
+       (process-crypto notmuch-show-process-crypto)
        reply
        original)
-    (when notmuch-show-process-crypto
+    (when process-crypto
       (setq args (append args '("--decrypt"))))
 
     (if reply-all
@@ -211,8 +236,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")
 
@@ -224,7 +250,11 @@ 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)))
+
+    ;; Crypto processing based crypto content of the original message
+    (when process-crypto
+      (notmuch-mua-reply-crypto (plist-get original :body))))
 
   ;; Push mark right before signature, if any.
   (message-goto-signature)
@@ -333,7 +363,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.