[notmuch] [PATCH -V3] notmuch.el: Support for customizing search result display
From: Aneesh Kumar K.V This patch helps in customizing search result display similar to mutt's index_format. The customization is done by defining an alist as below (setq notmuch-search-result-format '(("date" . "%s ") ("authors" . "%-40s ") ("subject" . "%s "))) The supported keywords are date, count, authors, subject. Signed-off-by: Aneesh Kumar K.V --- emacs/notmuch.el | 55 + 1 files changed, 38 insertions(+), 17 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 5b553bb..cc5167f 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -157,6 +157,18 @@ remaining lines into a button.") (defvar notmuch-show-body-read-visible nil) (defvar notmuch-show-citations-visible nil) (defvar notmuch-show-signatures-visible nil) +(defcustom notmuch-search-result-format + '(("date" . "%s") +("count" . "%-7s") +("authors" . "%-40s") +("subject" . "%s")) + "Search result formating. Supported fields are + date, count, authors, subject +ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\) + \(\"subject\" . \"%s\"\)\)\)" +:type '(alist :key-type (string) :value-type (string)) +:group 'notmuch) + (defvar notmuch-show-headers-visible nil) ; XXX: This should be a generic function in emacs somewhere, not here @@ -1314,11 +1326,6 @@ matching this search term are shown if non-nil. " "Notmuch search mode face used to highligh tags." :group 'notmuch) -(defvar notmuch-tag-face-alist nil - "List containing the tag list that need to be highlighed") - -(defvar notmuch-search-font-lock-keywords nil) - ;;;###autoload (defun notmuch-search-mode () "Major mode displaying results of a notmuch search. @@ -1356,17 +1363,7 @@ Complete list of currently available key bindings: (setq truncate-lines t) (setq major-mode 'notmuch-search-mode mode-name "notmuch-search") - (setq buffer-read-only t) - (if (not notmuch-tag-face-alist) - (add-to-list 'notmuch-search-font-lock-keywords (list - "(\\([^)]*\\))$" '(1 'notmuch-tag-face))) -(let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))) - (loop for notmuch-search-tag in notmuch-search-tags - do (add-to-list 'notmuch-search-font-lock-keywords (list - (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$") - `(1 ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist - (set (make-local-variable 'font-lock-defaults) - '(notmuch-search-font-lock-keywords t))) + (setq buffer-read-only t)) (defun notmuch-search-find-thread-id () "Return the thread for the current thread" @@ -1487,6 +1484,30 @@ This function advances the next thread when finished." (if never-found-target-thread (goto-char notmuch-search-target-position))) +(defun insert-tags (tags) + (insert (concat "(" (propertize tags +'font-lock-face 'notmuch-tag-face) ")"))) + +(defun insert-field (field date count authors subject tags) +(if (string-equal field "date") +(insert (format (cdr (assoc field notmuch-search-result-format)) date)) + (if (string-equal field "count") +(insert (format (cdr (assoc field notmuch-search-result-format)) count)) + (if (string-equal field "authors") +(insert (format (cdr (assoc field notmuch-search-result-format)) authors)) + (if (string-equal field "subject") + (insert (format (cdr (assoc field notmuch-search-result-format)) subject)) + (if (string-equal field "tags") + (insert-tags (format "%s" tags))) +) + +(defun notmuch-search-show-result (date count authors subject tags) +(let ((fields) (field)) + (setq fields (mapcar 'car notmuch-search-result-format)) + (loop for field in fields + do (insert-field field date count authors subject tags))) +(insert "\n")) + (defun notmuch-search-process-filter (proc string) "Process and filter the output of \"notmuch search\"" (let ((buffer (process-buffer proc)) @@ -1510,7 +1531,7 @@ This function advances the next thread when finished." (set 'authors (concat (substring authors 0 (- 40 3)) "..."))) (goto-char (point-max)) (let ((beg (point-marker))) - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags)) + (notmuch-search-show-result date count authors subject tags) (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id) (put-text-property beg (point-marker) 'notmuch-search-authors authors) (put-text-property beg (point-marker) 'notmuch-search-subject subject) -- 1.7.0.2.157.gb7e7f
[notmuch] [PATCH -V3 2/2] notmuch.el: Add support for reply-to sender
From: Aneesh Kumar K.V Add key binding to do a reply-to sender. This is mapped to 'R' Signed-off-by: Aneesh Kumar K.V --- emacs/notmuch.el | 24 ++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 5b553bb..9ba1ec1 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -78,7 +78,8 @@ (define-key map "s" 'notmuch-search) (define-key map "m" 'message-mail) (define-key map "f" 'notmuch-show-forward-current) -(define-key map "r" 'notmuch-show-reply) +(define-key map "r" 'notmuch-show-reply-all) +(define-key map "R" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) (define-key map "w" 'notmuch-show-save-attachments) (define-key map "V" 'notmuch-show-view-raw-message) @@ -446,12 +447,31 @@ buffer." (forward-line))) (message-mode)) -(defun notmuch-show-reply () +(defun notmuch-show-reply-all () "Begin composing a reply to the current message in a new buffer." (interactive) (let ((message-id (notmuch-show-get-message-id))) (notmuch-reply message-id))) + +(defun notmuch-recipient-reply (recipient query-string) + (switch-to-buffer (generate-new-buffer "notmuch-draft")) + (call-process notmuch-command nil t nil "reply" + (concat "--recipient=" recipient) query-string) + (message-insert-signature) + (goto-char (point-min)) + (if (re-search-forward "^$" nil t) + (progn + (insert "--text follows this line--") + (forward-line))) + (message-mode)) + +(defun notmuch-show-reply () + "Begin composing a reply to the current message in a new buffer." + (interactive) + (let ((message-id (notmuch-show-get-message-id))) +(notmuch-recipient-reply "sender" message-id))) + (defun notmuch-show-forward-current () "Forward the current message." (interactive) -- 1.7.0.2.157.gb7e7f
[notmuch] [PATCH -V3 1/2] notmuch-reply: Add support for replying only to sender
From: Aneesh Kumar K.V This patch add --recipient=all|sender option Signed-off-by: Aneesh Kumar K.V --- notmuch-client.h |2 + notmuch-reply.c | 55 - 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index c80b39c..26fdb4a 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -70,6 +70,8 @@ #define STRNCMP_LITERAL(var, literal) \ strncmp ((var), (literal), sizeof (literal) - 1) +#define NOTMUCH_REPLY_ALL 0x1 +#define NOTMUCH_REPLY_SENDER_ONLY 0x2 static inline void chomp_newline (char *str) { diff --git a/notmuch-reply.c b/notmuch-reply.c index 6c15536..e8a0820 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -232,20 +232,37 @@ reply_to_header_is_redundant (notmuch_message_t *message) static const char * add_recipients_from_message (GMimeMessage *reply, notmuch_config_t *config, -notmuch_message_t *message) +notmuch_message_t *message, +int reply_options) { -struct { +struct reply_to_map { const char *header; const char *fallback; GMimeRecipientType recipient_type; -} reply_to_map[] = { +} ; +const char *from_addr = NULL; +unsigned int i; +struct reply_to_map *reply_to_map; + +struct reply_to_map reply_to_map_all[] = { { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO }, { "to", NULL, GMIME_RECIPIENT_TYPE_TO }, { "cc", NULL, GMIME_RECIPIENT_TYPE_CC }, - { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC } + { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC }, + { NULL,NULL, 0 } }; -const char *from_addr = NULL; -unsigned int i; + +/* we try from first and then reply-to */ +struct reply_to_map reply_to_map_sender[] = { + { "from", "reply-to", GMIME_RECIPIENT_TYPE_TO }, + { NULL,NULL, 0 } +}; + +if (reply_options == NOTMUCH_REPLY_SENDER_ONLY) { + reply_to_map = reply_to_map_sender; +} else { + reply_to_map = reply_to_map_all; +} /* Some mailing lists munge the Reply-To header despite it being A Bad * Thing, see http://www.unicom.com/pw/reply-to-harmful.html @@ -263,7 +280,7 @@ add_recipients_from_message (GMimeMessage *reply, reply_to_map[0].fallback = NULL; } -for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) { +for (i = 0; reply_to_map[i].header; i++) { const char *addr, *recipients; recipients = notmuch_message_get_header (message, @@ -283,7 +300,7 @@ add_recipients_from_message (GMimeMessage *reply, } static int -notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query) +notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_options) { GMimeMessage *reply; notmuch_messages_t *messages; @@ -311,7 +328,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ subject = talloc_asprintf (ctx, "Re: %s", subject); g_mime_message_set_subject (reply, subject); - from_addr = add_recipients_from_message (reply, config, message); + from_addr = add_recipients_from_message (reply, config, message, reply_options); if (from_addr == NULL) from_addr = notmuch_config_get_user_primary_email (config); @@ -359,7 +376,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ /* This format is currently tuned for a git send-email --notmuch hook */ static int -notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query) +notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_options) { GMimeMessage *reply; notmuch_messages_t *messages; @@ -399,7 +416,7 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q g_mime_object_set_header (GMIME_OBJECT (reply), "References", references); - (void)add_recipients_from_message (reply, config, message); + (void)add_recipients_from_message (reply, config, message, reply_options); g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc", notmuch_config_get_user_primary_email (config)); @@ -423,8 +440,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) notmuch_database_t *notmuch; notmuch_query_t *query; char *opt, *query_string; -int i, ret = 0; -int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query); +int i, ret = 0, reply_to = NOTMUCH_REPLY_ALL; +int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_options); reply_format_func = notmuch_reply_format_default; @@ -443,6 +460,16
[notmuch] Any idea why my emacs doesn't want to accept my notmuch-folder keymap changes?
You have a typo: mot-much-folder-mode-map should be notmuch-folder-mode-map. (s/motmuch/notmuch/) On Wed, 10 Mar 2010 13:19:09 -0700, Mark R Anderson wrote: > I have added several keys to the search and show keymaps in my .emacs > file, but when my hook for notmuch-folder-mode generates warnings. > > I'm not sure exactly when the error happens, it may just be the compile > phase of reading the .emacs file, my ELisp is pretty shaky. > > (add-hook 'notmuch-folder-mode > (define-key motmuch-folder-mode-map "k" 'notmuch-folder-previous) > (define-key notmuch-folder-mode-map "j" 'notmuch-folder-next) > (define-key notmuch-folder-mode-map "F" 'notmuch-folder) > ) > > > emacs *Warnings*: > -- > Warning (initialization): An error occurred while loading > `/home/manderso/.emacs': > > Symbol's value as variable is void: motmuch-folder-mode-map > > To ensure normal operation, you should investigate and remove the > cause of the error in your initialization file. Start Emacs with > the `--debug-init' option to view a complete error backtrace. > -- > > I'm not sure why this one is so different from the other modes, any > suggestions? > > Thanks, > -Mark > > > > ___ > notmuch mailing list > notmuch at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] Any idea why my emacs doesn't want to accept my notmuch-folder keymap changes?
On Wed, 10 Mar 2010 16:01:28 -0600, James Vasile wrote: > You have a typo: mot-much-folder-mode-map should be > notmuch-folder-mode-map. (s/motmuch/notmuch/) Wow, how long can you stare at something and not see the obvious? Thanks, -Mark
Re: [notmuch] Any idea why my emacs doesn't want to accept my notmuch-folder keymap changes?
On Wed, 10 Mar 2010 16:01:28 -0600, James Vasile wrote: > You have a typo: mot-much-folder-mode-map should be > notmuch-folder-mode-map. (s/motmuch/notmuch/) Wow, how long can you stare at something and not see the obvious? Thanks, -Mark ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [notmuch] Any idea why my emacs doesn't want to accept my notmuch-folder keymap changes?
You have a typo: mot-much-folder-mode-map should be notmuch-folder-mode-map. (s/motmuch/notmuch/) On Wed, 10 Mar 2010 13:19:09 -0700, Mark R Anderson wrote: > I have added several keys to the search and show keymaps in my .emacs > file, but when my hook for notmuch-folder-mode generates warnings. > > I'm not sure exactly when the error happens, it may just be the compile > phase of reading the .emacs file, my ELisp is pretty shaky. > > (add-hook 'notmuch-folder-mode > (define-key motmuch-folder-mode-map "k" 'notmuch-folder-previous) > (define-key notmuch-folder-mode-map "j" 'notmuch-folder-next) > (define-key notmuch-folder-mode-map "F" 'notmuch-folder) > ) > > > emacs *Warnings*: > -- > Warning (initialization): An error occurred while loading > `/home/manderso/.emacs': > > Symbol's value as variable is void: motmuch-folder-mode-map > > To ensure normal operation, you should investigate and remove the > cause of the error in your initialization file. Start Emacs with > the `--debug-init' option to view a complete error backtrace. > -- > > I'm not sure why this one is so different from the other modes, any > suggestions? > > Thanks, > -Mark > > > > ___ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] Any idea why my emacs doesn't want to accept my notmuch-folder keymap changes?
I have added several keys to the search and show keymaps in my .emacs file, but when my hook for notmuch-folder-mode generates warnings. I'm not sure exactly when the error happens, it may just be the compile phase of reading the .emacs file, my ELisp is pretty shaky. (add-hook 'notmuch-folder-mode (define-key motmuch-folder-mode-map "k" 'notmuch-folder-previous) (define-key notmuch-folder-mode-map "j" 'notmuch-folder-next) (define-key notmuch-folder-mode-map "F" 'notmuch-folder) ) emacs *Warnings*: -- Warning (initialization): An error occurred while loading `/home/manderso/.emacs': Symbol's value as variable is void: motmuch-folder-mode-map To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace. -- I'm not sure why this one is so different from the other modes, any suggestions? Thanks, -Mark
[notmuch] Any idea why my emacs doesn't want to accept my notmuch-folder keymap changes?
I have added several keys to the search and show keymaps in my .emacs file, but when my hook for notmuch-folder-mode generates warnings. I'm not sure exactly when the error happens, it may just be the compile phase of reading the .emacs file, my ELisp is pretty shaky. (add-hook 'notmuch-folder-mode (define-key motmuch-folder-mode-map "k" 'notmuch-folder-previous) (define-key notmuch-folder-mode-map "j" 'notmuch-folder-next) (define-key notmuch-folder-mode-map "F" 'notmuch-folder) ) emacs *Warnings*: -- Warning (initialization): An error occurred while loading `/home/manderso/.emacs': Symbol's value as variable is void: motmuch-folder-mode-map To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace. -- I'm not sure why this one is so different from the other modes, any suggestions? Thanks, -Mark ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] [PATCH 3/3] notmuch-show.c: prototype tabular output format, with output control
On Wed, 10 Mar 2010 01:25:22 -0800, Carl Worth wrote: > On Tue, 09 Mar 2010 16:19:16 -0400, David Bremner > wrote: > > > > --format=tabular --output=message-id > > Ah, so maybe your "notmuch show --format=tabular" is basically the same > thing I imagined for "notmuch search" (once we teach it to accept a list > of the desired elements to output). There is a third "control axis", namely one piece of output per thread (current "notmuch search" style), or all of the messages ("notmuch show style")
[notmuch] [PATCH 2/2] notmuch-show: add tags to json output
On Tue, 2 Mar 2010 11:52:33 +0100, Sebastian Spaeth wrote: I just updated this patch to reflect the new notmuch_tags_valid/notmuch_tags_to_next(?) syntax. It is commit e7cfd46505e8b1c4124a8fa88ea0fbee286d9360 on git://github.com/spaetz/notmuch-all-feature.git (http://github.com/spaetz/notmuch-all-feature/commit/e7cfd46505e8b1c4124a8fa88ea0fbee286d9360) Sebastian
[notmuch] [PATCH -V3] notmuch.el: Support for customizing search result display
From: Aneesh Kumar K.V This patch helps in customizing search result display similar to mutt's index_format. The customization is done by defining an alist as below (setq notmuch-search-result-format '(("date" . "%s ") ("authors" . "%-40s ") ("subject" . "%s "))) The supported keywords are date, count, authors, subject. Signed-off-by: Aneesh Kumar K.V --- emacs/notmuch.el | 55 + 1 files changed, 38 insertions(+), 17 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 5b553bb..cc5167f 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -157,6 +157,18 @@ remaining lines into a button.") (defvar notmuch-show-body-read-visible nil) (defvar notmuch-show-citations-visible nil) (defvar notmuch-show-signatures-visible nil) +(defcustom notmuch-search-result-format + '(("date" . "%s") +("count" . "%-7s") +("authors" . "%-40s") +("subject" . "%s")) + "Search result formating. Supported fields are + date, count, authors, subject +ex: (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\) + \(\"subject\" . \"%s\"\)\)\)" +:type '(alist :key-type (string) :value-type (string)) +:group 'notmuch) + (defvar notmuch-show-headers-visible nil) ; XXX: This should be a generic function in emacs somewhere, not here @@ -1314,11 +1326,6 @@ matching this search term are shown if non-nil. " "Notmuch search mode face used to highligh tags." :group 'notmuch) -(defvar notmuch-tag-face-alist nil - "List containing the tag list that need to be highlighed") - -(defvar notmuch-search-font-lock-keywords nil) - ;;;###autoload (defun notmuch-search-mode () "Major mode displaying results of a notmuch search. @@ -1356,17 +1363,7 @@ Complete list of currently available key bindings: (setq truncate-lines t) (setq major-mode 'notmuch-search-mode mode-name "notmuch-search") - (setq buffer-read-only t) - (if (not notmuch-tag-face-alist) - (add-to-list 'notmuch-search-font-lock-keywords (list - "(\\([^)]*\\))$" '(1 'notmuch-tag-face))) -(let ((notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))) - (loop for notmuch-search-tag in notmuch-search-tags - do (add-to-list 'notmuch-search-font-lock-keywords (list - (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$") - `(1 ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist - (set (make-local-variable 'font-lock-defaults) - '(notmuch-search-font-lock-keywords t))) + (setq buffer-read-only t)) (defun notmuch-search-find-thread-id () "Return the thread for the current thread" @@ -1487,6 +1484,30 @@ This function advances the next thread when finished." (if never-found-target-thread (goto-char notmuch-search-target-position))) +(defun insert-tags (tags) + (insert (concat "(" (propertize tags +'font-lock-face 'notmuch-tag-face) ")"))) + +(defun insert-field (field date count authors subject tags) +(if (string-equal field "date") +(insert (format (cdr (assoc field notmuch-search-result-format)) date)) + (if (string-equal field "count") +(insert (format (cdr (assoc field notmuch-search-result-format)) count)) + (if (string-equal field "authors") +(insert (format (cdr (assoc field notmuch-search-result-format)) authors)) + (if (string-equal field "subject") + (insert (format (cdr (assoc field notmuch-search-result-format)) subject)) + (if (string-equal field "tags") + (insert-tags (format "%s" tags))) +) + +(defun notmuch-search-show-result (date count authors subject tags) +(let ((fields) (field)) + (setq fields (mapcar 'car notmuch-search-result-format)) + (loop for field in fields + do (insert-field field date count authors subject tags))) +(insert "\n")) + (defun notmuch-search-process-filter (proc string) "Process and filter the output of \"notmuch search\"" (let ((buffer (process-buffer proc)) @@ -1510,7 +1531,7 @@ This function advances the next thread when finished." (set 'authors (concat (substring authors 0 (- 40 3)) "..."))) (goto-char (point-max)) (let ((beg (point-marker))) - (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags)) + (notmuch-search-show-result date count authors subject tags) (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id) (put-text-property beg (point-marker) 'notmuch-search-authors authors) (put-text-property beg (point-marker) 'notmuch-search-subject subject) -- 1.7.0.2.157.gb7e7f ___ notmuch mailing list notmuch@notmuchmail.org http://
[notmuch] [PATCH -V3 1/2] notmuch-reply: Add support for replying only to sender
From: Aneesh Kumar K.V This patch add --recipient=all|sender option Signed-off-by: Aneesh Kumar K.V --- notmuch-client.h |2 + notmuch-reply.c | 55 - 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index c80b39c..26fdb4a 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -70,6 +70,8 @@ #define STRNCMP_LITERAL(var, literal) \ strncmp ((var), (literal), sizeof (literal) - 1) +#define NOTMUCH_REPLY_ALL 0x1 +#define NOTMUCH_REPLY_SENDER_ONLY 0x2 static inline void chomp_newline (char *str) { diff --git a/notmuch-reply.c b/notmuch-reply.c index 6c15536..e8a0820 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -232,20 +232,37 @@ reply_to_header_is_redundant (notmuch_message_t *message) static const char * add_recipients_from_message (GMimeMessage *reply, notmuch_config_t *config, -notmuch_message_t *message) +notmuch_message_t *message, +int reply_options) { -struct { +struct reply_to_map { const char *header; const char *fallback; GMimeRecipientType recipient_type; -} reply_to_map[] = { +} ; +const char *from_addr = NULL; +unsigned int i; +struct reply_to_map *reply_to_map; + +struct reply_to_map reply_to_map_all[] = { { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO }, { "to", NULL, GMIME_RECIPIENT_TYPE_TO }, { "cc", NULL, GMIME_RECIPIENT_TYPE_CC }, - { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC } + { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC }, + { NULL,NULL, 0 } }; -const char *from_addr = NULL; -unsigned int i; + +/* we try from first and then reply-to */ +struct reply_to_map reply_to_map_sender[] = { + { "from", "reply-to", GMIME_RECIPIENT_TYPE_TO }, + { NULL,NULL, 0 } +}; + +if (reply_options == NOTMUCH_REPLY_SENDER_ONLY) { + reply_to_map = reply_to_map_sender; +} else { + reply_to_map = reply_to_map_all; +} /* Some mailing lists munge the Reply-To header despite it being A Bad * Thing, see http://www.unicom.com/pw/reply-to-harmful.html @@ -263,7 +280,7 @@ add_recipients_from_message (GMimeMessage *reply, reply_to_map[0].fallback = NULL; } -for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) { +for (i = 0; reply_to_map[i].header; i++) { const char *addr, *recipients; recipients = notmuch_message_get_header (message, @@ -283,7 +300,7 @@ add_recipients_from_message (GMimeMessage *reply, } static int -notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query) +notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_options) { GMimeMessage *reply; notmuch_messages_t *messages; @@ -311,7 +328,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ subject = talloc_asprintf (ctx, "Re: %s", subject); g_mime_message_set_subject (reply, subject); - from_addr = add_recipients_from_message (reply, config, message); + from_addr = add_recipients_from_message (reply, config, message, reply_options); if (from_addr == NULL) from_addr = notmuch_config_get_user_primary_email (config); @@ -359,7 +376,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ /* This format is currently tuned for a git send-email --notmuch hook */ static int -notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query) +notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_options) { GMimeMessage *reply; notmuch_messages_t *messages; @@ -399,7 +416,7 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q g_mime_object_set_header (GMIME_OBJECT (reply), "References", references); - (void)add_recipients_from_message (reply, config, message); + (void)add_recipients_from_message (reply, config, message, reply_options); g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc", notmuch_config_get_user_primary_email (config)); @@ -423,8 +440,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) notmuch_database_t *notmuch; notmuch_query_t *query; char *opt, *query_string; -int i, ret = 0; -int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query); +int i, ret = 0, reply_to = NOTMUCH_REPLY_ALL; +int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_options); reply_format_func = notmuch_reply_format_default; @@ -4
[notmuch] [PATCH -V3 2/2] notmuch.el: Add support for reply-to sender
From: Aneesh Kumar K.V Add key binding to do a reply-to sender. This is mapped to 'R' Signed-off-by: Aneesh Kumar K.V --- emacs/notmuch.el | 24 ++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 5b553bb..9ba1ec1 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -78,7 +78,8 @@ (define-key map "s" 'notmuch-search) (define-key map "m" 'message-mail) (define-key map "f" 'notmuch-show-forward-current) -(define-key map "r" 'notmuch-show-reply) +(define-key map "r" 'notmuch-show-reply-all) +(define-key map "R" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) (define-key map "w" 'notmuch-show-save-attachments) (define-key map "V" 'notmuch-show-view-raw-message) @@ -446,12 +447,31 @@ buffer." (forward-line))) (message-mode)) -(defun notmuch-show-reply () +(defun notmuch-show-reply-all () "Begin composing a reply to the current message in a new buffer." (interactive) (let ((message-id (notmuch-show-get-message-id))) (notmuch-reply message-id))) + +(defun notmuch-recipient-reply (recipient query-string) + (switch-to-buffer (generate-new-buffer "notmuch-draft")) + (call-process notmuch-command nil t nil "reply" + (concat "--recipient=" recipient) query-string) + (message-insert-signature) + (goto-char (point-min)) + (if (re-search-forward "^$" nil t) + (progn + (insert "--text follows this line--") + (forward-line))) + (message-mode)) + +(defun notmuch-show-reply () + "Begin composing a reply to the current message in a new buffer." + (interactive) + (let ((message-id (notmuch-show-get-message-id))) +(notmuch-recipient-reply "sender" message-id))) + (defun notmuch-show-forward-current () "Forward the current message." (interactive) -- 1.7.0.2.157.gb7e7f ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [notmuch] [PATCH 3/3] notmuch-show.c: prototype tabular output format, with output control
On Wed, 10 Mar 2010 01:25:22 -0800, Carl Worth wrote: > On Tue, 09 Mar 2010 16:19:16 -0400, David Bremner wrote: > > > > --format=tabular --output=message-id > > Ah, so maybe your "notmuch show --format=tabular" is basically the same > thing I imagined for "notmuch search" (once we teach it to accept a list > of the desired elements to output). There is a third "control axis", namely one piece of output per thread (current "notmuch search" style), or all of the messages ("notmuch show style") ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [notmuch] [PATCH 2/2] notmuch-show: add tags to json output
On Tue, 2 Mar 2010 11:52:33 +0100, Sebastian Spaeth wrote: I just updated this patch to reflect the new notmuch_tags_valid/notmuch_tags_to_next(?) syntax. It is commit e7cfd46505e8b1c4124a8fa88ea0fbee286d9360 on git://github.com/spaetz/notmuch-all-feature.git (http://github.com/spaetz/notmuch-all-feature/commit/e7cfd46505e8b1c4124a8fa88ea0fbee286d9360) Sebastian ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [notmuch] [PATCH 3/3] notmuch-show.c: prototype tabular output format, with output control
On Tue, 09 Mar 2010 16:19:16 -0400, David Bremner wrote: > I think some tabular format would be handy because it is very easy to > parse with scripts, and because it is a natural natural way to get > e.g. a list of message-ids. > > --format=tabular --output=message-id Ah, so maybe your "notmuch show --format=tabular" is basically the same thing I imagined for "notmuch search" (once we teach it to accept a list of the desired elements to output). > On the other hand, I'm not yet using this code, so I guess the main > point is to discuss how output control should be implemented, and in > that sense the patch is a demo. I suspect once we start using json > output more, we will definitely want it there. Yes. I think we next need to implement some --output options and then see what we want from there. -Carl pgpDI41dxykd3.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] [PATCH 3/3] notmuch-show.c: prototype tabular output format, with output control
On Tue, 09 Mar 2010 16:19:16 -0400, David Bremner wrote: > I think some tabular format would be handy because it is very easy to > parse with scripts, and because it is a natural natural way to get > e.g. a list of message-ids. > > --format=tabular --output=message-id Ah, so maybe your "notmuch show --format=tabular" is basically the same thing I imagined for "notmuch search" (once we teach it to accept a list of the desired elements to output). > On the other hand, I'm not yet using this code, so I guess the main > point is to discuss how output control should be implemented, and in > that sense the patch is a demo. I suspect once we start using json > output more, we will definitely want it there. Yes. I think we next need to implement some --output options and then see what we want from there. -Carl -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20100310/f6da9462/attachment-0001.pgp>