unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/3] emacs: mua: allow the user to widen the reply
Date: Sat, 11 May 2013 21:15:44 +0100	[thread overview]
Message-ID: <1368303344-13713-4-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1368303344-13713-1-git-send-email-markwalters1009@gmail.com>

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

  parent reply	other threads:[~2013-05-11 20:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-11 20:15 [PATCH 0/3] Allow widen reply Mark Walters
2013-05-11 20:15 ` [PATCH 1/3] cli: show: separate out the printing of recipient headers Mark Walters
2013-05-11 20:15 ` [PATCH 2/3] cli: reply: additionally output reply-to-all headers to allow widen reply Mark Walters
2013-05-11 20:15 ` Mark Walters [this message]
2013-05-12 20:53 ` [PATCH 0/3] Allow " Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368303344-13713-4-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).