unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH]: 0001-Include-tags-in-notmuch-show-format-json.patch
@ 2010-03-08 13:08 Fernando Herrera
  2010-03-08 13:16 ` Jameson Rollins
  0 siblings, 1 reply; 3+ messages in thread
From: Fernando Herrera @ 2010-03-08 13:08 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 832 bytes --]

Hi all!

First a quick presentation of myself as described in the mailing list
subscription message: I am an old mutt user who loved its quick and
clean interface. During the last years I have been trapped into gmail
because of its great search capabilities and ubiquous web interface.
Now with notmuch I got better search capabilities, and I only needed a
web interface, so I started writing one for myself:

   http://github.com/fherrera/notmuch-web

Now the patch :)

The attached patch includes tags as headers in the  "notmuch show
--format=json ..." output. The text output already shows tags in the
one-line header, and I needed them to show specific tags for each
message in the thread view of the webmail (if not included in the show
output, I would need to do a web request per message to know its
tags).


Thanks!

Salu2

[-- Attachment #2: 0001-Include-tags-in-notmuch-show-format-json.patch --]
[-- Type: text/x-patch, Size: 1622 bytes --]

From 856a959360ade598d270af1ce7284b1c569589e1 Mon Sep 17 00:00:00 2001
From: Fernando Herrera <fherrera@onirica.com>
Date: Sun, 7 Mar 2010 16:17:33 +0100
Subject: [PATCH] Include tags in "notmuch show --format=json ..."

---
 notmuch-show.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 1a1d601..9920a4c 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -168,23 +168,33 @@ format_headers_text (const void *ctx, notmuch_message_t *message)
 static void
 format_headers_json (const void *ctx, notmuch_message_t *message)
 {
+    notmuch_tags_t *tags;
     const char *headers[] = {
 	"Subject", "From", "To", "Cc", "Bcc", "Date"
     };
     const char *name, *value;
     unsigned int i;
-    int first_header = 1;
+    int first_tag = 1;
     void *ctx_quote = talloc_new (ctx);
 
+    printf ("%s: [", json_quote_str (ctx_quote, "tags"));
+    for (tags = notmuch_message_get_tags (message);
+         notmuch_tags_has_more (tags);
+         notmuch_tags_advance (tags))
+    {
+	if (!first_tag)
+            fputs (", ", stdout);
+        printf ("%s", json_quote_str (ctx_quote, notmuch_tags_get (tags)));
+        first_tag = 0;
+    }
+    printf ("]");
+
     for (i = 0; i < ARRAY_SIZE (headers); i++) {
 	name = headers[i];
 	value = notmuch_message_get_header (message, name);
 	if (value)
 	{
-	    if (!first_header)
-		fputs (", ", stdout);
-	    first_header = 0;
-
+            fputs (", ", stdout);
 	    printf ("%s: %s",
 		    json_quote_str (ctx_quote, name),
 		    json_quote_str (ctx_quote, value));
-- 
1.6.6.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-08 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-08 13:08 [PATCH]: 0001-Include-tags-in-notmuch-show-format-json.patch Fernando Herrera
2010-03-08 13:16 ` Jameson Rollins
2010-03-08 14:38   ` Sebastian Spaeth

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).