notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hi,

* Austin Clements  [2014-07-15 16:14 +0200]:
> Close. For whatever reason, localtime takes a pointer to a time_t,
> not a time_t (even though time_t is just a number). You'll need
> something like
>
> [...]

Thank you *so much*, everything is in order now! Finally a nice
attribution line :)


notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hello,

* Austin Clements  [Mon, 14 Jul 2014 09:04:31 -0400]:
> Assuming the CLI is the right place for you to change this, you
> probably want to call notmuch_message_get_date, then localtime, then
> strftime.

Tried to get this working to no avail. Not a programmer obviously :) I
cobbled this together from various online sources:

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7c1c809..16cf19c 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)
 int i;

 if (node->envelope_file) {
-   printf ("On %s, %s wrote:\n",
-   notmuch_message_get_header (node->envelope_file, "date"),
-   notmuch_message_get_header (node->envelope_file, "from"));
+   struct tm *info;
+   char dbuf[30];
+
+   info = localtime(notmuch_message_get_date(node->envelope_file));
+
+   strftime(dbuf, sizeof(dbuf), "%F %R %z", info);
+   printf ("* %s [%s]:\n",
+   notmuch_message_get_header(node->envelope_file, "from"), dbuf);
+
 } else if (GMIME_IS_MESSAGE (node->part)) {
GMimeMessage *message = GMIME_MESSAGE (node->part);
InternetAddressList *recipients;

When compiling I get this warning:

notmuch-reply.c: In function 'format_part_reply':
notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer 
from integer without a cast

And a core dump when notmuch reply is invoked on a message. Am I even
close? :) Thanks


Re: notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hello,

* Austin Clements amdra...@mit.edu [Mon, 14 Jul 2014 09:04:31 -0400]:
 Assuming the CLI is the right place for you to change this, you
 probably want to call notmuch_message_get_date, then localtime, then
 strftime.

Tried to get this working to no avail. Not a programmer obviously :) I
cobbled this together from various online sources:

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7c1c809..16cf19c 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)
 int i;
 
 if (node-envelope_file) {
-   printf (On %s, %s wrote:\n,
-   notmuch_message_get_header (node-envelope_file, date),
-   notmuch_message_get_header (node-envelope_file, from));
+   struct tm *info;
+   char dbuf[30];
+
+   info = localtime(notmuch_message_get_date(node-envelope_file));
+
+   strftime(dbuf, sizeof(dbuf), %F %R %z, info);
+   printf (* %s [%s]:\n,
+   notmuch_message_get_header(node-envelope_file, from), dbuf);
+
 } else if (GMIME_IS_MESSAGE (node-part)) {
GMimeMessage *message = GMIME_MESSAGE (node-part);
InternetAddressList *recipients;

When compiling I get this warning:

notmuch-reply.c: In function 'format_part_reply':
notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer 
from integer without a cast

And a core dump when notmuch reply is invoked on a message. Am I even
close? :) Thanks
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: notmuch-reply date format

2014-07-15 Thread Austin Clements
Quoth Sime Ramov on Jul 15 at  9:35 am:
 Hello,
 
 * Austin Clements amdra...@mit.edu [Mon, 14 Jul 2014 09:04:31 -0400]:
  Assuming the CLI is the right place for you to change this, you
  probably want to call notmuch_message_get_date, then localtime, then
  strftime.
 
 Tried to get this working to no avail. Not a programmer obviously :) I
 cobbled this together from various online sources:
 
 diff --git a/notmuch-reply.c b/notmuch-reply.c
 index 7c1c809..16cf19c 100644
 --- a/notmuch-reply.c
 +++ b/notmuch-reply.c
 @@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)
  int i;
  
  if (node-envelope_file) {
 - printf (On %s, %s wrote:\n,
 - notmuch_message_get_header (node-envelope_file, date),
 - notmuch_message_get_header (node-envelope_file, from));
 + struct tm *info;
 + char dbuf[30];
 +
 + info = localtime(notmuch_message_get_date(node-envelope_file));

Close.  For whatever reason, localtime takes a pointer to a time_t,
not a time_t (even though time_t is just a number).  You'll need
something like

time_t date;

date = notmuch_message_get_date(node-envelope_file);
info = localtime(date);

 +
 + strftime(dbuf, sizeof(dbuf), %F %R %z, info);
 + printf (* %s [%s]:\n,
 + notmuch_message_get_header(node-envelope_file, from), dbuf);
 +
  } else if (GMIME_IS_MESSAGE (node-part)) {
   GMimeMessage *message = GMIME_MESSAGE (node-part);
   InternetAddressList *recipients;
 
 When compiling I get this warning:
 
 notmuch-reply.c: In function 'format_part_reply':
 notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer 
 from integer without a cast

Ah, C.  I'm sure they meant for that number that looks nothing like a
pointer to actually be a pointer that could corrupt memory, disclose
private information, or crash the program.  I'll just convert it for
them real quick...

 And a core dump when notmuch reply is invoked on a message. Am I even
 close? :) Thanks
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hi,

* Austin Clements amdra...@mit.edu [2014-07-15 16:14 +0200]:
 Close. For whatever reason, localtime takes a pointer to a time_t,
 not a time_t (even though time_t is just a number). You'll need
 something like

 [...]

Thank you *so much*, everything is in order now! Finally a nice
attribution line :)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


notmuch-reply date format

2014-07-14 Thread Sime Ramov
* Austin Clements  [Mon, 14 Jul 2014 09:04:31 -0400]:
> First, are you sure this is the right place to modify reply
> attribution? The Emacs frontend builds its own reply template. I'm not
> sure what the other frontends do.

I'm not using any frontends, only CLI.

> Assuming the CLI is the right place for you to change this, you
> probably want to call notmuch_message_get_date, then localtime, then
> strftime. The call to notmuch_message_get_header returns the literal
> text from the message's Date: header, while notmuch_message_get_date
> returns the parsed Date: header as a time_t.

Thanks, will try.


notmuch-reply date format

2014-07-14 Thread Sime Ramov
Hello,

I would like to customize the attribution string in the reply templates.
Something like this, with ISO date:

* Full Name  [2014-07-14 12:30 +0200]:

After the following trivial edit:

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7c1c809..eaf1eed 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,9 +44,9 @@ format_part_reply (mime_node_t *node)
 int i;
 if (node->envelope_file) {
-   printf ("On %s, %s wrote:\n",
-   notmuch_message_get_header (node->envelope_file, "date"),
-   notmuch_message_get_header (node->envelope_file, "from"));
+   printf ("* %s [%s]:\n",
+   notmuch_message_get_header (node->envelope_file, "from"),
+   notmuch_message_get_header (node->envelope_file, "date"));
 } else if (GMIME_IS_MESSAGE (node->part)) {
GMimeMessage *message = GMIME_MESSAGE (node->part);
InternetAddressList *recipients;

The (partial) result is this:

* Full Name  [Mon, 14 Jul 2014 12:30:36 +0200]:

Where would be the best place to `strftime` date? I snooped around in
lib/ source but haven't gotten far. Any ideas? Is it a Xapian thing?


notmuch-reply date format

2014-07-14 Thread Austin Clements
Quoth Sime Ramov on Jul 14 at  2:28 pm:
> Hello,
> 
> I would like to customize the attribution string in the reply templates.
> Something like this, with ISO date:
> 
> * Full Name  [2014-07-14 12:30 +0200]:
> 
> After the following trivial edit:
> 
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 7c1c809..eaf1eed 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -44,9 +44,9 @@ format_part_reply (mime_node_t *node)
>  int i;
>  if (node->envelope_file) {
> -   printf ("On %s, %s wrote:\n",
> -   notmuch_message_get_header (node->envelope_file, "date"),
> -   notmuch_message_get_header (node->envelope_file, "from"));
> +   printf ("* %s [%s]:\n",
> +   notmuch_message_get_header (node->envelope_file, "from"),
> +   notmuch_message_get_header (node->envelope_file, "date"));
>  } else if (GMIME_IS_MESSAGE (node->part)) {
> GMimeMessage *message = GMIME_MESSAGE (node->part);
> InternetAddressList *recipients;
> 
> The (partial) result is this:
> 
> * Full Name  [Mon, 14 Jul 2014 12:30:36 +0200]:
> 
> Where would be the best place to `strftime` date? I snooped around in
> lib/ source but haven't gotten far. Any ideas? Is it a Xapian thing?

Hi Sime.

First, are you sure this is the right place to modify reply
attribution?  The Emacs frontend builds its own reply template.  I'm
not sure what the other frontends do.

Assuming the CLI is the right place for you to change this, you
probably want to call notmuch_message_get_date, then localtime, then
strftime.  The call to notmuch_message_get_header returns the literal
text from the message's Date: header, while notmuch_message_get_date
returns the parsed Date: header as a time_t.


notmuch-reply date format

2014-07-14 Thread Sime Ramov
Hello,

I would like to customize the attribution string in the reply templates.
Something like this, with ISO date:

* Full Name m...@example.net [2014-07-14 12:30 +0200]:

After the following trivial edit:

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7c1c809..eaf1eed 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,9 +44,9 @@ format_part_reply (mime_node_t *node)
 int i;
 if (node-envelope_file) {
-   printf (On %s, %s wrote:\n,
-   notmuch_message_get_header (node-envelope_file, date),
-   notmuch_message_get_header (node-envelope_file, from));
+   printf (* %s [%s]:\n,
+   notmuch_message_get_header (node-envelope_file, from),
+   notmuch_message_get_header (node-envelope_file, date));
 } else if (GMIME_IS_MESSAGE (node-part)) {
GMimeMessage *message = GMIME_MESSAGE (node-part);
InternetAddressList *recipients;

The (partial) result is this:

* Full Name m...@example.net [Mon, 14 Jul 2014 12:30:36 +0200]:

Where would be the best place to `strftime` date? I snooped around in
lib/ source but haven't gotten far. Any ideas? Is it a Xapian thing?
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: notmuch-reply date format

2014-07-14 Thread Austin Clements
Quoth Sime Ramov on Jul 14 at  2:28 pm:
 Hello,
 
 I would like to customize the attribution string in the reply templates.
 Something like this, with ISO date:
 
 * Full Name m...@example.net [2014-07-14 12:30 +0200]:
 
 After the following trivial edit:
 
 diff --git a/notmuch-reply.c b/notmuch-reply.c
 index 7c1c809..eaf1eed 100644
 --- a/notmuch-reply.c
 +++ b/notmuch-reply.c
 @@ -44,9 +44,9 @@ format_part_reply (mime_node_t *node)
  int i;
  if (node-envelope_file) {
 -   printf (On %s, %s wrote:\n,
 -   notmuch_message_get_header (node-envelope_file, date),
 -   notmuch_message_get_header (node-envelope_file, from));
 +   printf (* %s [%s]:\n,
 +   notmuch_message_get_header (node-envelope_file, from),
 +   notmuch_message_get_header (node-envelope_file, date));
  } else if (GMIME_IS_MESSAGE (node-part)) {
 GMimeMessage *message = GMIME_MESSAGE (node-part);
 InternetAddressList *recipients;
 
 The (partial) result is this:
 
 * Full Name m...@example.net [Mon, 14 Jul 2014 12:30:36 +0200]:
 
 Where would be the best place to `strftime` date? I snooped around in
 lib/ source but haven't gotten far. Any ideas? Is it a Xapian thing?

Hi Sime.

First, are you sure this is the right place to modify reply
attribution?  The Emacs frontend builds its own reply template.  I'm
not sure what the other frontends do.

Assuming the CLI is the right place for you to change this, you
probably want to call notmuch_message_get_date, then localtime, then
strftime.  The call to notmuch_message_get_header returns the literal
text from the message's Date: header, while notmuch_message_get_date
returns the parsed Date: header as a time_t.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch