From: Austin Clements <amdragon@MIT.EDU>
To: Sime Ramov <sramov@pobox.com>
Cc: notmuch@notmuchmail.org
Subject: Re: notmuch-reply date format
Date: Tue, 15 Jul 2014 10:14:07 -0400 [thread overview]
Message-ID: <20140715141407.GF4660@mit.edu> (raw)
In-Reply-To: <702358554056882337.enqueue@ouroboros.ramov.inet>
Quoth Sime Ramov on Jul 15 at 9:35 am:
> Hello,
>
> * Austin Clements <amdragon@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
next prev parent reply other threads:[~2014-07-15 14:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 12:28 notmuch-reply date format Sime Ramov
2014-07-14 13:04 ` Austin Clements
2014-07-14 13:25 ` Sime Ramov
2014-07-15 7:35 ` Sime Ramov
2014-07-15 14:14 ` Austin Clements [this message]
2014-07-15 16:59 ` Sime Ramov
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=20140715141407.GF4660@mit.edu \
--to=amdragon@mit.edu \
--cc=notmuch@notmuchmail.org \
--cc=sramov@pobox.com \
/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).