Re: notmuch-reply date format

Subject: Re: notmuch-reply date format

Date: Mon, 14 Jul 2014 09:04:31 -0400

To: Sime Ramov

Cc: notmuch@notmuchmail.org

From: 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 <me@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 <me@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.

Thread: