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 C32706DE022C for ; Mon, 16 Jul 2018 16:27:58 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -5.026 X-Spam-Level: X-Spam-Status: No, score=-5.026 tagged_above=-999 required=5 tests=[AWL=0.005, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-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 pt3MUnzPtYPX for ; Mon, 16 Jul 2018 16:27:57 -0700 (PDT) Received: from eggs.gnu.org (eggs.gnu.org [208.118.235.92]) by arlo.cworth.org (Postfix) with ESMTPS id 36E9D6DE0228 for ; Mon, 16 Jul 2018 16:27:57 -0700 (PDT) Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffCuI-0003FO-0L for notmuch@notmuchmail.org; Mon, 16 Jul 2018 19:27:54 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56494) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffCuH-0003FB-Su for notmuch@notmuchmail.org; Mon, 16 Jul 2018 19:27:53 -0400 Received: from [2607:fea8:3ba0:f85::2] (port=38470 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ffCuH-0000Xo-Iz for notmuch@notmuchmail.org; Mon, 16 Jul 2018 19:27:53 -0400 Resent-To: notmuch@notmuchmail.org Resent-From: Amin Bandali Resent-Date: Mon, 16 Jul 2018 19:27:52 -0400 Resent-Message-ID: <8736wig3rb.fsf@fencepost.gnu.org> From: Amin Bandali To: david@tethera.net Subject: Re: [BUG] Custom headers in `notmuch-message-headers` are broken In-Reply-To: <87tvwd3bx2.fsf@tethera.net> Date: Mon, 16 Jul 2018 17:51:09 -0400 Message-ID: <87muuqsvci.fsf@fencepost.gnu.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Mon, 16 Jul 2018 23:27:58 -0000 I got bitten by this today. I only had a brief look at the format_headers_sprinter function in notmuch-show.c. Would you, David, or anyone else be able to point out if the following makes sense, for generalizing format_headers_sprinter to handle any arbitrary headers? I saw this bit near the bottom of that function: --8<---------------cut here---------------start------------->8--- if (reply) { sp->map_key (sp, "In-reply-to"); sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to")); sp->map_key (sp, "References"); sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References")); } --8<---------------cut here---------------end--------------->8--- So I had a look at GMimeObject's docs on GNOME.org [0], and saw g_mime_object_get_header_list, which returns a GMimeHeaderList* list of headers [1], which seems to be what we're looking for. >From there, we'd walk over 0..(g_mime_header_list_get_count-1) indices and use g_mime_header_list_get_header_at to get each header, and pass it to g_mime_header_get_name to get the name which we'll pass to sp->map_key and also use to get its value from g_mime_object_get_header. Does that make sense? [0]: https://developer.gnome.org/gmime/stable/GMimeObject.html [1]: https://developer.gnome.org/gmime/stable/GMimeHeaderList.html -amin