unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* date_relative in notmuch-search
@ 2011-07-14 22:22 Patrick Totzke
  2011-07-15 15:58 ` Jameson Graef Rollins
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Totzke @ 2011-07-14 22:22 UTC (permalink / raw)
  To: notmuch

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

Hi,

I wodered why "notmuch search --format=json" doesn't provide the "date_relative" field for
results, as the show command does.

I'm not expert on notmuch internals but I got it working like this:

diff --git a/notmuch-search.c b/notmuch-search.c
index faccaf7..b1adc03 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -176,12 +176,14 @@ format_thread_json (const void *ctx,
 
     printf ("\"thread\": %s,\n"
            "\"timestamp\": %ld,\n"
+           "\"date_relative\": \"%s\",\n"
            "\"matched\": %d,\n"
            "\"total\": %d,\n"
            "\"authors\": %s,\n"
            "\"subject\": %s,\n",
            json_quote_str (ctx_quote, thread_id),
            date,
+           notmuch_time_relative_date (ctx, date),

I'm unsure it it's better to use json_quote_str here but you tell me :)
Best,
/p

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: date_relative in notmuch-search
  2011-07-14 22:22 date_relative in notmuch-search Patrick Totzke
@ 2011-07-15 15:58 ` Jameson Graef Rollins
  2011-07-15 21:04   ` Patrick Totzke
  0 siblings, 1 reply; 7+ messages in thread
From: Jameson Graef Rollins @ 2011-07-15 15:58 UTC (permalink / raw)
  To: Patrick Totzke, notmuch

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

On Thu, 14 Jul 2011 23:22:58 +0100, Patrick Totzke <patricktotzke@googlemail.com> wrote:
> I wodered why "notmuch search --format=json" doesn't provide the "date_relative" field for
> results, as the show command does.
> 
> I'm not expert on notmuch internals but I got it working like this:

Hi, Patrick.  I think this is a very reasonable patch.  However, there
are a couple of things you need to do to get this patch accepted.

First of all, you should send the patch to the list in a format that
will allow it to be applied directly to a git repo.  In particular, it
needs to include a good commit log message.  Look at using git send-mail
to send it to the list, which will format it correctly.

Also, I'm quite sure this patch will require a couple of changes to the
test suite.  You should submit a patch that changes the test suite to
reflect the desired changes *first*, followed by the patch that fixes
the issue.

Thanks!

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: date_relative in notmuch-search
  2011-07-15 15:58 ` Jameson Graef Rollins
@ 2011-07-15 21:04   ` Patrick Totzke
  2011-07-18 19:07     ` Jameson Graef Rollins
  2011-07-23  9:54     ` [PATCH 1/2] test: date_relative in notmuch search json output pazz
  0 siblings, 2 replies; 7+ messages in thread
From: Patrick Totzke @ 2011-07-15 21:04 UTC (permalink / raw)
  To: Jameson Graef Rollins; +Cc: Patrick Totzke, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1501 bytes --]

Hi Jason,

Thanks for the tip with git send-mail. I didn't really intend to
get this "patch" accepted. It was more that I feel bad asking for 
features all the time and as I'm not so comfortable with hacking
on the notmuch code I thought I'd ask if one could implement it like this.
Anyhow, attached you'll find a patch for the test and another for
the proposed change. Feel free to discard it :)
Best,
/p

On Fri, Jul 15, 2011 at 08:58:45AM -0700, Jameson Graef Rollins wrote:
> On Thu, 14 Jul 2011 23:22:58 +0100, Patrick Totzke <patricktotzke@googlemail.com> wrote:
> > I wodered why "notmuch search --format=json" doesn't provide the "date_relative" field for
> > results, as the show command does.
> > 
> > I'm not expert on notmuch internals but I got it working like this:
> 
> Hi, Patrick.  I think this is a very reasonable patch.  However, there
> are a couple of things you need to do to get this patch accepted.
> 
> First of all, you should send the patch to the list in a format that
> will allow it to be applied directly to a git repo.  In particular, it
> needs to include a good commit log message.  Look at using git send-mail
> to send it to the list, which will format it correctly.
> 
> Also, I'm quite sure this patch will require a couple of changes to the
> test suite.  You should submit a patch that changes the test suite to
> reflect the desired changes *first*, followed by the patch that fixes
> the issue.
> 
> Thanks!
> 
> jamie.



[-- Attachment #1.2: 0001-test-date_relative-in-notmuch-search-json-output.patch --]
[-- Type: text/x-diff, Size: 1264 bytes --]

From 9a0260e36e36af94bed695e713bbc1be0a069fce Mon Sep 17 00:00:00 2001
From: pazz <patricktotzke@gmail.com>
Date: Fri, 15 Jul 2011 21:36:54 +0100
Subject: [PATCH 1/2] test: date_relative in notmuch search json output

expect the date_relative field for thread entries
in notmuch search's json output
---
 test/json |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/test/json b/test/json
index 5a2544c..d54bf25 100755
--- a/test/json
+++ b/test/json
@@ -12,6 +12,7 @@ add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00
 output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)
 test_expect_equal "$output" "[{\"thread\": \"XXX\",
 \"timestamp\": 946728000,
+\"date_relative\": \"2000-01-01\",
 \"matched\": 1,
 \"total\": 1,
 \"authors\": \"Notmuch Test Suite\",
@@ -28,6 +29,7 @@ add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Ja
 output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_search_sanitize)
 test_expect_equal "$output" "[{\"thread\": \"XXX\",
 \"timestamp\": 946728000,
+\"date_relative\": \"2000-01-01\",
 \"matched\": 1,
 \"total\": 1,
 \"authors\": \"Notmuch Test Suite\",
-- 
1.7.4.1


[-- Attachment #1.3: 0002-json-date_relative-for-threads.patch --]
[-- Type: text/x-diff, Size: 974 bytes --]

From 1a796b09eb4c6171ddaf5f847df56d1a0181cb7c Mon Sep 17 00:00:00 2001
From: pazz <patricktotzke@gmail.com>
Date: Fri, 15 Jul 2011 21:41:02 +0100
Subject: [PATCH 2/2] json: date_relative for threads

include the date_relative field in the
json formated output of notmuch search
---
 notmuch-search.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index faccaf7..b1adc03 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -176,12 +176,14 @@ format_thread_json (const void *ctx,
 
     printf ("\"thread\": %s,\n"
 	    "\"timestamp\": %ld,\n"
+	    "\"date_relative\": \"%s\",\n"
 	    "\"matched\": %d,\n"
 	    "\"total\": %d,\n"
 	    "\"authors\": %s,\n"
 	    "\"subject\": %s,\n",
 	    json_quote_str (ctx_quote, thread_id),
 	    date,
+	    notmuch_time_relative_date (ctx, date),
 	    matched,
 	    total,
 	    json_quote_str (ctx_quote, authors),
-- 
1.7.4.1


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: date_relative in notmuch-search
  2011-07-15 21:04   ` Patrick Totzke
@ 2011-07-18 19:07     ` Jameson Graef Rollins
  2011-07-23  9:54     ` [PATCH 1/2] test: date_relative in notmuch search json output pazz
  1 sibling, 0 replies; 7+ messages in thread
From: Jameson Graef Rollins @ 2011-07-18 19:07 UTC (permalink / raw)
  To: Patrick Totzke; +Cc: notmuch

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

On Fri, 15 Jul 2011 22:04:59 +0100, Patrick Totzke <patricktotzke@googlemail.com> wrote:
> Thanks for the tip with git send-mail.

Hi, Patrick.  You might have noticed my response to Felix a little while
ago.  The git format-patch command outputs an email that is meant to be
sent directly to the list, not as an attachment on another message.  The
git send-email command should actually handle sending the mails
(assuming you have a working sendmail-like MTA on your machine.  I would
recommend using git send-email to send patches to the list.

Try resending these two patches as their own emails.

> I didn't really intend to get this "patch" accepted. It was more that
> I feel bad asking for features all the time and as I'm not so
> comfortable with hacking on the notmuch code I thought I'd ask if one
> could implement it like this.  Anyhow, attached you'll find a patch
> for the test and another for the proposed change. Feel free to discard
> it :)

But this is exactly how features get added!  If you want a feature added
to notmuch, send in a patch for it.  Otherwise you'll have to just wait
until someone else submits a patch to do the same thing, which may or
may not ever happen.  It's a community-run project, developed by those
that use the program (which includes you!).  Since you've already done
the work to figure out what needed to be changed, all you need to do now
is follow the procedure I've outlined to publish the patch to the list,
and eventually, hopefully, Carl will get around to pulling it in to the
notmuch master repo.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* [PATCH 1/2] test: date_relative in notmuch search json output
  2011-07-15 21:04   ` Patrick Totzke
  2011-07-18 19:07     ` Jameson Graef Rollins
@ 2011-07-23  9:54     ` pazz
  2011-07-23  9:54       ` [PATCH 2/2] json: date_relative for threads pazz
  2011-12-08  1:29       ` [PATCH 1/2] test: date_relative in notmuch search json output David Bremner
  1 sibling, 2 replies; 7+ messages in thread
From: pazz @ 2011-07-23  9:54 UTC (permalink / raw)
  To: notmuch

expect the date_relative field for thread entries
in notmuch search's json output
---
 test/json |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/test/json b/test/json
index 5a2544c..d54bf25 100755
--- a/test/json
+++ b/test/json
@@ -12,6 +12,7 @@ add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00
 output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)
 test_expect_equal "$output" "[{\"thread\": \"XXX\",
 \"timestamp\": 946728000,
+\"date_relative\": \"2000-01-01\",
 \"matched\": 1,
 \"total\": 1,
 \"authors\": \"Notmuch Test Suite\",
@@ -28,6 +29,7 @@ add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Ja
 output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_search_sanitize)
 test_expect_equal "$output" "[{\"thread\": \"XXX\",
 \"timestamp\": 946728000,
+\"date_relative\": \"2000-01-01\",
 \"matched\": 1,
 \"total\": 1,
 \"authors\": \"Notmuch Test Suite\",
-- 
1.7.4.1

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

* [PATCH 2/2] json: date_relative for threads
  2011-07-23  9:54     ` [PATCH 1/2] test: date_relative in notmuch search json output pazz
@ 2011-07-23  9:54       ` pazz
  2011-12-08  1:29       ` [PATCH 1/2] test: date_relative in notmuch search json output David Bremner
  1 sibling, 0 replies; 7+ messages in thread
From: pazz @ 2011-07-23  9:54 UTC (permalink / raw)
  To: notmuch

include the date_relative field in the
json formated output of notmuch search
---
 notmuch-search.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index faccaf7..b1adc03 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -176,12 +176,14 @@ format_thread_json (const void *ctx,
 
     printf ("\"thread\": %s,\n"
 	    "\"timestamp\": %ld,\n"
+	    "\"date_relative\": \"%s\",\n"
 	    "\"matched\": %d,\n"
 	    "\"total\": %d,\n"
 	    "\"authors\": %s,\n"
 	    "\"subject\": %s,\n",
 	    json_quote_str (ctx_quote, thread_id),
 	    date,
+	    notmuch_time_relative_date (ctx, date),
 	    matched,
 	    total,
 	    json_quote_str (ctx_quote, authors),
-- 
1.7.4.1

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

* Re: [PATCH 1/2] test: date_relative in notmuch search json output
  2011-07-23  9:54     ` [PATCH 1/2] test: date_relative in notmuch search json output pazz
  2011-07-23  9:54       ` [PATCH 2/2] json: date_relative for threads pazz
@ 2011-12-08  1:29       ` David Bremner
  1 sibling, 0 replies; 7+ messages in thread
From: David Bremner @ 2011-12-08  1:29 UTC (permalink / raw)
  To: pazz, notmuch

On Sat, 23 Jul 2011 10:54:03 +0100, pazz <patricktotzke@googlemail.com> wrote:
> expect the date_relative field for thread entries
> in notmuch search's json output
> ---

I pushed an amended version of this one (explaining why the date won't
change in the future), and the next patch as well.

d

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

end of thread, other threads:[~2011-12-08  1:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-14 22:22 date_relative in notmuch-search Patrick Totzke
2011-07-15 15:58 ` Jameson Graef Rollins
2011-07-15 21:04   ` Patrick Totzke
2011-07-18 19:07     ` Jameson Graef Rollins
2011-07-23  9:54     ` [PATCH 1/2] test: date_relative in notmuch search json output pazz
2011-07-23  9:54       ` [PATCH 2/2] json: date_relative for threads pazz
2011-12-08  1:29       ` [PATCH 1/2] test: date_relative in notmuch search json output David Bremner

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