[PATCH 3/3] emacs: mua: allow the user to widen the reply
Mark Walters
markwalters1009 at gmail.com
Sat May 11 13:15:44 PDT 2013
Emacs message mode already has a widen reply option C-c C-f w (which
obviously doesn't work when used via notmuch). This uses the new
reply-all-recipients output to add a function to make it work in this case.
---
emacs/notmuch-mua.el | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 24eebff..1f28287 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -74,6 +74,12 @@ list."
:type '(repeat string)
:group 'notmuch-send)
+;; This is used to store the reply all headers to allow the reply to
+;; be `widened' in the mail compose window.
+(defvar notmuch-mua-reply-all-recipients nil)
+(make-variable-buffer-local 'notmuch-mua-reply-all-recipients)
+(put 'notmuch-mua-reply-all-recipients 'permanent-local t)
+
;;
(defun notmuch-mua-get-switch-function ()
@@ -145,6 +151,14 @@ list."
(funcall original-func header references)
(unless (bolp) (insert "\n")))
+(defun notmuch-mua-widen-reply ()
+ (interactive)
+ (let ((reply-all-headers notmuch-mua-reply-all-recipients))
+ (message-replace-header "To" (plist-get reply-all-headers :To))
+ (message-replace-header "Cc" (plist-get reply-all-headers :Cc))
+ (message-replace-header "Bcc" (plist-get reply-all-headers :Bcc))
+ (message-sort-headers)))
+
(defun notmuch-mua-reply (query-string &optional sender reply-all)
(let ((args '("reply" "--format=json" "--format-version=1"))
reply
@@ -165,7 +179,8 @@ list."
;; Extract the headers of both the reply and the original message.
(let* ((original-headers (plist-get original :headers))
- (reply-headers (plist-get reply :reply-headers)))
+ (reply-headers (plist-get reply :reply-headers))
+ (reply-all-recipients (plist-get reply :reply-all-recipients)))
;; If sender is non-nil, set the From: header to its value.
(when sender
@@ -191,6 +206,11 @@ list."
(notmuch-headers-plist-to-alist reply-headers)
nil (notmuch-mua-get-switch-function))))
+ ;; Store the JSON for use by the mail compose window for header
+ ;; toggling etc.
+ (setq notmuch-mua-reply-all-recipients reply-all-recipients)
+ (local-set-key "\C-c\C-fw" 'notmuch-mua-widen-reply)
+
;; Insert the message body - but put it in front of the signature
;; if one is present
(goto-char (point-max))
--
1.7.9.1
More information about the notmuch
mailing list