unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Fernando Herrera <fherrera@onirica.com>
To: notmuch@notmuchmail.org
Subject: [PATCH]: 0001-Include-tags-in-notmuch-show-format-json.patch
Date: Mon, 8 Mar 2010 14:08:54 +0100	[thread overview]
Message-ID: <121988a31003080508w313aee57g8d1b3dd048bbe375@mail.gmail.com> (raw)

[-- 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


             reply	other threads:[~2010-03-08 13:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-08 13:08 Fernando Herrera [this message]
2010-03-08 13:16 ` [PATCH]: 0001-Include-tags-in-notmuch-show-format-json.patch Jameson Rollins
2010-03-08 14:38   ` Sebastian Spaeth

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=121988a31003080508w313aee57g8d1b3dd048bbe375@mail.gmail.com \
    --to=fherrera@onirica.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).