[PATCH] Fix format_headers_sprinter to return all headers
Jani Nikula
jani at nikula.org
Sat Nov 9 11:19:47 PST 2019
On Sat, 09 Nov 2019, Johan Parin <johanparin at gmail.com> wrote:
> Modify format_headers_sprinter so that it returns all headers in the
> sexp, instead of a fixed set of headers.
I have to deal with plenty of long threads that already take a very long
time to open in notmuch-emacs. How's this going to impact the emacs
interface performance? For example the patch mail I'm replying to has
more header content than body content. There are tons of headers that I
can't imagine being useful to anyone.
I'm wondering if the right thing to do would be to make it possible to
specify which additional headers to include in notmuch-show output. This
would be based on notmuch-message-headers. We already have options to
include/exclude body content and html parts for much the same
reasons. (Though the command-line arguments for those are incoherent at
best.)
It is, of course, much more work than the patch at hand.
BR,
Jani.
>
> This is required in order for the elisp variable
>`notmuch-message-headers' to work.
>
> See this bug report:
>
> https://notmuchmail.org/pipermail/notmuch/2017/026069.html
> ---
> notmuch-show.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 21792a57..9652ed09 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -205,6 +205,15 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
> char *recipients_string;
> const char *reply_to_string;
> void *local = talloc_new (sp);
> + GMimeHeaderList *header_list;
> + GMimeHeader *header;
> + int header_count;
> + /* Headers requiring some special treatment in formatting */
> + const char* special_headers[] = {"Subject", "From", "To", "Cc", "Bcc",
> + "Reply-To", "In-reply-to", "References",
> + "Date"};
> + const int special_header_count = sizeof(special_headers) / sizeof(char *);
> + bool special;
>
> sp->begin_map (sp);
>
> @@ -255,6 +264,24 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
> sp->string (sp, g_mime_message_get_date_string (sp, message));
> }
>
> + header_list = g_mime_object_get_header_list (GMIME_OBJECT(message));
> + header_count = g_mime_header_list_get_count(header_list);
> +
> + for (int i = 0; i < header_count; i++) {
> + header = g_mime_header_list_get_header_at(header_list, i);
> + special = false;
> + for (int k = 0; k < special_header_count; k++)
> + if (!STRNCMP_LITERAL(g_mime_header_get_name(header),
> + special_headers[k])) {
> + special = true;
> + break;
> + }
> + if (special)
> + continue;
> + sp->map_key (sp, g_mime_header_get_name(header));
> + sp->string (sp, g_mime_header_get_value(header));
> + }
> +
> sp->end (sp);
> talloc_free (local);
> }
> --
> 2.21.0 (Apple Git-122)
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list