* Re: Notmuch Ruby bindings
2010-11-08 18:02 ` Carl Worth
@ 2010-11-08 19:21 ` Andreas Amann
2010-11-10 3:44 ` Rob Browning
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Amann @ 2010-11-08 19:21 UTC (permalink / raw)
To: notmuch
[-- Attachment #1: Type: text/plain, Size: 363 bytes --]
On Mon, 08 Nov 2010 10:02:31 -0800, Carl Worth <cworth@cworth.org> wrote:
> Now, where was that patch adding a "reply to sender only" binding...
>
After a number of embarrassing mails I use the attached patch, which
changes the default behaviour of "r" to "reply to sender only". Usual
reply to everybody is "R". Maybe you prefer reversed binding?
Andreas
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-reply-to-sender-only-functionality.patch --]
[-- Type: text/x-patch, Size: 5731 bytes --]
Add reply to sender only functionality
This changes the default keybinding "r" in notmuch emacs interface to
mean "reply to sender only". This is an adapted version of a patch by
Michal Sojka.
---
emacs/notmuch-mua.el | 2 +-
emacs/notmuch-show.el | 10 ++++++++--
emacs/notmuch.el | 12 ++++++++++--
notmuch-reply.c | 9 +++++++--
notmuch.1 | 6 ++++++
notmuch.c | 3 +++
6 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index dc7b386..2cf846e 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -75,7 +75,7 @@ list."
;; really only that the headers come first followed by a blank
;; line and then the body.
(with-temp-buffer
- (call-process notmuch-command nil t nil "reply" query-string)
+ (apply 'call-process (append (list notmuch-command nil t nil "reply") query-string))
(goto-char (point-min))
(if (re-search-forward "^$" nil t)
(save-excursion
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 98a2fbc..b634b8d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -563,7 +563,8 @@ function is used. "
(define-key map "s" 'notmuch-search)
(define-key map "m" 'notmuch-mua-mail)
(define-key map "f" 'notmuch-show-forward-message)
- (define-key map "r" 'notmuch-show-reply)
+ (define-key map "R" 'notmuch-show-reply)
+ (define-key map "r" 'notmuch-show-reply-to-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)
@@ -870,7 +871,12 @@ any effects from previous calls to
(defun notmuch-show-reply ()
"Reply to the current message."
(interactive)
- (notmuch-mua-reply (notmuch-show-get-message-id)))
+ (notmuch-mua-reply (list (notmuch-show-get-message-id))))
+
+(defun notmuch-show-reply-to-sender ()
+ "Reply to the current message (only to the sender)."
+ (interactive)
+ (notmuch-mua-reply (list "--sender-only" (notmuch-show-get-message-id))))
(defun notmuch-show-forward-message ()
"Forward the current message."
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2a87ab9..8897d09 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -203,7 +203,8 @@ For a mouse binding, return nil."
(define-key map ">" 'notmuch-search-last-thread)
(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)
+ (define-key map "r" 'notmuch-search-reply-to-thread-sender)
(define-key map "m" 'notmuch-mua-mail)
(define-key map "s" 'notmuch-search)
(define-key map "o" 'notmuch-search-toggle-order)
@@ -427,7 +428,14 @@ Complete list of currently available key bindings:
"Begin composing a reply to the entire current thread in a new buffer."
(interactive)
(let ((message-id (notmuch-search-find-thread-id)))
- (notmuch-mua-reply message-id)))
+ (notmuch-mua-reply (list message-id))))
+
+(defun notmuch-search-reply-to-thread-sender ()
+ "Begin composing a reply to the sender only of the current thread in a new buffer."
+ (interactive)
+ (let ((message-id (notmuch-search-find-thread-id)))
+ (notmuch-mua-reply (list "--sender-only" message-id))))
+
(defun notmuch-call-notmuch-process (&rest args)
"Synchronously invoke \"notmuch\" with the given list of arguments.
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 23d04b8..886157a 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -24,6 +24,8 @@
#include "gmime-filter-reply.h"
#include "gmime-filter-headers.h"
+static notmuch_bool_t sender_only = FALSE;
+
static void
reply_part_content (GMimeObject *part)
{
@@ -272,6 +274,7 @@ add_recipients_from_message (GMimeMessage *reply,
};
const char *from_addr = NULL;
unsigned int i;
+ unsigned int max;
/* Some mailing lists munge the Reply-To header despite it being A Bad
* Thing, see http://www.unicom.com/pw/reply-to-harmful.html
@@ -288,8 +291,8 @@ add_recipients_from_message (GMimeMessage *reply,
reply_to_map[0].header = "from";
reply_to_map[0].fallback = NULL;
}
-
- for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
+ max = sender_only ? 1 : ARRAY_SIZE (reply_to_map);
+ for (i = 0; i < max; i++) {
const char *addr, *recipients;
recipients = notmuch_message_get_header (message,
@@ -595,6 +598,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
fprintf (stderr, "Invalid value for --format: %s\n", opt);
return 1;
}
+ } else if (STRNCMP_LITERAL (argv[i], "--sender-only") == 0) {
+ sender_only = TRUE;
} else {
fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
return 1;
diff --git a/notmuch.1 b/notmuch.1
index 2c33749..6bd5dc0 100644
--- a/notmuch.1
+++ b/notmuch.1
@@ -353,6 +353,12 @@ Includes subject and quoted message body.
.BR headers\-only
Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
.RE
+.TP 4
+.B \-\-sender\-only
+
+Only setup the To: header as described above, not the additional Cc
+headers.
+.RE
See the
.B "SEARCH SYNTAX"
diff --git a/notmuch.c b/notmuch.c
index 030e494..1780dbe 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -297,6 +297,9 @@ command_t commands[] = {
"\t\t\tOnly produces In-Reply-To, References, To\n"
"\t\t\tCc, and Bcc headers.\n"
"\n"
+ "\t\t--sender-only\n"
+ "\t\t\tReply only to sender.\n"
+ "\n"
"\tSee \"notmuch help search-terms\" for details of the search\n"
"\tterms syntax." },
{ "tag", notmuch_tag_command,
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread