[PATCH 4/4] emacs: Allow the user to choose the "From" address when replying to a message.

Thomas Jost schnouki at schnouki.net
Wed May 25 06:22:40 PDT 2011


---
 emacs/notmuch-mua.el  |    9 ++++++++-
 emacs/notmuch-show.el |    6 ++++++
 emacs/notmuch.el      |    7 +++++++
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 7c08a6e..d04e69c 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -69,7 +69,7 @@ list."
 	    (push header message-hidden-headers)))
 	notmuch-mua-hidden-headers))
 
-(defun notmuch-mua-reply (query-string)
+(defun notmuch-mua-reply (query-string &optional sender)
   (let (headers
 	body
 	(args '("reply")))
@@ -90,6 +90,9 @@ list."
 	      (setq headers (mail-header-extract)))))
       (forward-line 1)
       (setq body (buffer-substring (point) (point-max))))
+    ;; If sender is non-nil, set the From: header to its value.
+    (when sender
+      (mail-header-set 'from sender headers))
     (let
 	;; Overlay the composition window on that being used to read
 	;; the original message.
@@ -190,6 +193,10 @@ name and addresses configured in the notmuch configuration file."
 	 (user-mail-address (cadr address-components)))
     (notmuch-mua-forward-message)))
 
+(defun notmuch-mua-reply-prompt-for-sender (query-string)
+  (interactive)
+  (notmuch-mua-reply query-string (notmuch-mua-prompt-for-sender)))
+
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
   (message-send-and-exit arg))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 50b20b2..2c69e96 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -852,6 +852,7 @@ function is used. "
 	(define-key map "f" 'notmuch-show-forward-message)
 	(define-key map "F" 'notmuch-show-forward-message-prompt-for-sender)
 	(define-key map "r" 'notmuch-show-reply)
+	(define-key map "R" 'notmuch-show-reply-prompt-for-sender)
 	(define-key map "|" 'notmuch-show-pipe-message)
 	(define-key map "w" 'notmuch-show-save-attachments)
 	(define-key map "V" 'notmuch-show-view-raw-message)
@@ -1160,6 +1161,11 @@ any effects from previous calls to
   (interactive)
   (notmuch-mua-reply (notmuch-show-get-message-id)))
 
+(defun notmuch-show-reply-prompt-for-sender ()
+  "Reply to the current message, prompting for the From: address first."
+  (interactive)
+  (notmuch-mua-reply-prompt-for-sender (notmuch-show-get-message-id)))
+
 (defun notmuch-show-forward-message ()
   "Forward the current message."
   (interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1791d84..153dc74 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -204,6 +204,7 @@ For a mouse binding, return nil."
     (define-key map "p" 'notmuch-search-previous-thread)
     (define-key map "n" 'notmuch-search-next-thread)
     (define-key map "r" 'notmuch-search-reply-to-thread)
+    (define-key map "R" 'notmuch-search-reply-to-thread-prompt-for-sender)
     (define-key map "m" 'notmuch-mua-new-mail)
     (define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender)
     (define-key map "s" 'notmuch-search)
@@ -449,6 +450,12 @@ Complete list of currently available key bindings:
   (let ((message-id (notmuch-search-find-thread-id)))
     (notmuch-mua-reply message-id)))
 
+(defun notmuch-search-reply-to-thread-prompt-for-sender ()
+  "Begin composing a reply to the entire current thread in a new buffer, prompting for the From: address first."
+  (interactive)
+  (let ((message-id (notmuch-search-find-thread-id)))
+    (notmuch-mua-reply-prompt-for-sender message-id)))
+
 (defun notmuch-call-notmuch-process (&rest args)
   "Synchronously invoke \"notmuch\" with the given list of arguments.
 
-- 
1.7.5.1



More information about the notmuch mailing list