From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 886FE6DE39F9 for ; Sat, 13 Aug 2016 04:39:30 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.573 X-Spam-Level: X-Spam-Status: No, score=-0.573 tagged_above=-999 required=5 tests=[AWL=0.147, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NQTTjdzCLUrp for ; Sat, 13 Aug 2016 04:39:22 -0700 (PDT) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 4CEDE6DE38D1 for ; Sat, 13 Aug 2016 04:39:11 -0700 (PDT) Received: by mail-wm0-f65.google.com with SMTP id i5so2016665wmg.2 for ; Sat, 13 Aug 2016 04:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=fbeShvw4M66SrxkIEgtBhkFxVPPUGacbY8QcRCVt1P8=; b=D40EZr4nheHCp+XA042QJMLrpm/bjnHXiZh+5QgkIjxYZQ/CAUVRujJltzHoqNrUVM +5hlNASWdIDDb/2k7cUX8loo8pdugb7odH5jiKRXyXhzAFWkVWlsUbtNtDjiCVg5mpyg Lem6er+u6xqNWfFLl+PUnbQ7iiVu0Z0ebw+3GDNf8NfmTgvw+gvg0mfFSQ1kuOHntxqU VdGYg6+Vkm12DMNJ6kBwrpvbWKMdhNSPohMHim5F85UOnMtntr2O2qeQFRIzknLTRFrI D7pbcIYllFfWncyjeA3vCO4yrfW6E6YnOvGgEYc0kl3dySnoTvuwBtLlLQk6joNnfqGk vgAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=fbeShvw4M66SrxkIEgtBhkFxVPPUGacbY8QcRCVt1P8=; b=B6OxzOgwdAfP93kCON8Ou8rrzwLWK5KEV1C/MoK435NCOEw5vjZ0bgITaXA5A30gAZ 9TrzRjB+FaCyH2MiqRVkEhdnzwBNatVYnC7AN81G4nmGC/jGtyHQ+r7TeTSyppbWR4Sg zfj9/wCCA1eyfndA1oA0vYUl/Y1D/fzIUjbDUb/hP4E3FksxBlfcd5fSsnBc9/9Iq9tA CryhQe21cCtnx8t6KRW8kq+Skxs9BkGz56W8mO7CRO1brHrIWo7pL4VJiLOSdpvYXsYB TXlSn09cHAKg/lsNLGAsg8zWGwwnUAzxx3w8inZV7M9+9kL65lchUcaCY5XSycBeBUiu v+HA== X-Gm-Message-State: AEkooutgaTA8K7L2TDA5IDumZ20jXLQCulLVJZaCBfJQD4JlGLu03L+6JbuwZMfc+Qw34Q== X-Received: by 10.194.135.205 with SMTP id pu13mr24239190wjb.37.1471088349934; Sat, 13 Aug 2016 04:39:09 -0700 (PDT) Received: from localhost (mobile-access-bcee63-250.dhcp.inet.fi. [188.238.99.250]) by smtp.gmail.com with ESMTPSA id p1sm11776270wjd.37.2016.08.13.04.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Aug 2016 04:39:09 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Cc: Daniel Kahn Gillmor , jani@nikula.org Subject: [PATCH v2 05/14] cli/reply: reorganize create_reply_message() Date: Sat, 13 Aug 2016 14:37:29 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 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: Sat, 13 Aug 2016 11:39:30 -0000 Again, in preparation for later unification, reorganize create_reply_message() to be more similar to the open coded version in the headers-only format reply code. Due to "pretty" header ordering, there should be no change in output. There should be no functional changes. --- notmuch-reply.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index 4b97ffa4f096..eb07405591fd 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -532,12 +532,20 @@ create_reply_message(void *ctx, return NULL; } - subject = notmuch_message_get_header (message, "subject"); - if (subject) { - if (strncasecmp (subject, "Re:", 3)) - subject = talloc_asprintf (ctx, "Re: %s", subject); - g_mime_message_set_subject (reply, subject); - } + in_reply_to = talloc_asprintf (ctx, "<%s>", + notmuch_message_get_message_id (message)); + + g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to); + + orig_references = notmuch_message_get_header (message, "references"); + if (!orig_references) + /* Treat errors like missing References headers. */ + orig_references = ""; + references = talloc_asprintf (ctx, "%s%s%s", + *orig_references ? orig_references : "", + *orig_references ? " " : "", + in_reply_to); + g_mime_object_set_header (GMIME_OBJECT (reply), "References", references); from_addr = add_recipients_from_message (reply, config, message, reply_all); @@ -572,25 +580,14 @@ create_reply_message(void *ctx, from_addr = talloc_asprintf (ctx, "%s <%s>", notmuch_config_get_user_name (config), from_addr); - g_mime_object_set_header (GMIME_OBJECT (reply), - "From", from_addr); - - in_reply_to = talloc_asprintf (ctx, "<%s>", - notmuch_message_get_message_id (message)); - - g_mime_object_set_header (GMIME_OBJECT (reply), - "In-Reply-To", in_reply_to); + g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr); - orig_references = notmuch_message_get_header (message, "references"); - if (!orig_references) - /* Treat errors like missing References headers. */ - orig_references = ""; - references = talloc_asprintf (ctx, "%s%s%s", - *orig_references ? orig_references : "", - *orig_references ? " " : "", - in_reply_to); - g_mime_object_set_header (GMIME_OBJECT (reply), - "References", references); + subject = notmuch_message_get_header (message, "subject"); + if (subject) { + if (strncasecmp (subject, "Re:", 3)) + subject = talloc_asprintf (ctx, "Re: %s", subject); + g_mime_message_set_subject (reply, subject); + } return reply; } -- 2.1.4