Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2DEA0431FBD for ; Tue, 2 Mar 2010 04:37:57 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.959 X-Spam-Level: X-Spam-Status: No, score=-1.959 tagged_above=-999 required=5 tests=[AWL=0.640, BAYES_00=-2.599] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wbUBl5-sWkPL for ; Tue, 2 Mar 2010 04:37:56 -0800 (PST) Received: from homiemail-a15.g.dreamhost.com (caiajhbdcagg.dreamhost.com [208.97.132.66]) by olra.theworths.org (Postfix) with ESMTP id 88785431FAE for ; Tue, 2 Mar 2010 04:37:56 -0800 (PST) Received: from localhost.localdomain (mtec-hg-docking-1-dhcp-204.ethz.ch [129.132.133.204]) by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id F114476C065; Tue, 2 Mar 2010 04:37:46 -0800 (PST) From: Sebastian Spaeth To: notmuch@notmuchmail.org Date: Tue, 2 Mar 2010 13:37:42 +0100 Message-Id: <1267533462-15682-1-git-send-email-Sebastian@SSpaeth.de> X-Mailer: git-send-email 1.6.3.3 Subject: [notmuch] [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2010 12:37:57 -0000 Previously, we would output: 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth wrote:' now it is: 'On 2010-02-25, Sebastian Spaeth wrote:' In case we don't find a '<' (as indicator for 'Realname '), we still use the whole from address. Signed-off-by: Sebastian Spaeth --- This probably shows my lack of C skills quite nicely but it does the job for me. notmuch-reply.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index 98f6442..929572f 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ GMimeMessage *reply; notmuch_messages_t *messages; notmuch_message_t *message; - const char *subject, *from_addr = NULL; + const char *subject, *from_addr = NULL, *short_from; const char *in_reply_to, *orig_references, *references; char *reply_headers; + time_t date; + struct tm *datetm; + char *datestr; for (messages = notmuch_query_search_messages (query); notmuch_messages_has_more (messages); @@ -346,10 +349,21 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ g_object_unref (G_OBJECT (reply)); reply = NULL; + date = notmuch_message_get_date(message); + datetm = gmtime( &date ); + datestr = talloc_array(ctx, char, 11); + strftime(datestr, 11, "%Y-%m-%d", datetm); + + /* If from contains '<' (not as first char), + * only use the preceding real name */ + short_from = talloc_strdup(ctx, from_addr); + if (strstr(short_from, "<") > short_from) { + *(strstr(short_from, "<")-1) = 0; + } + printf ("On %s, %s wrote:\n", - notmuch_message_get_header (message, "date"), - notmuch_message_get_header (message, "from")); + datestr, + short_from); show_message_body (notmuch_message_get_filename (message), reply_part); -- 1.6.3.3