[RFC PATCH v3 01/11] cli: add --headers_only option to notmuch-show.c

Mark Walters markwalters1009 at gmail.com
Sun Feb 12 17:20:05 PST 2012


This option just outputs the headers of a message
(i.e. it omits the bodies).

This is used by notmuch-pick.el (although not needed) because it gives a
speed-up of at least a factor of a two; moreover it reduces the memory
usage in emacs hugely.
---
 notmuch-client.h |    1 +
 notmuch-show.c   |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 60828aa..0da2d8d 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -101,6 +101,7 @@ typedef struct notmuch_show_params {
     notmuch_bool_t entire_thread;
     notmuch_bool_t raw;
     int part;
+    int headers_only;
 #ifdef GMIME_ATLEAST_26
     GMimeCryptoContext* cryptoctx;
 #else
diff --git a/notmuch-show.c b/notmuch-show.c
index d930f94..9d73685 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -841,7 +841,7 @@ show_message (void *ctx,
 	fputs (format->body_start, stdout);
     }
 
-    if (format->part_content)
+    if (format->part_content && !params->headers_only)
 	show_message_body (message, format, params);
 
     if (params->part <= 0) {
@@ -1034,6 +1034,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     notmuch_show_params_t params = { .part = -1 };
     int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
     notmuch_bool_t verify = FALSE;
+    notmuch_bool_t headers_only = FALSE;
 
     notmuch_opt_desc_t options[] = {
 	{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -1046,6 +1047,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 	{ NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },
 	{ NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },
 	{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
+	{ NOTMUCH_OPT_BOOLEAN, &headers_only, "headers-only", 'h', 0 },
 	{ 0, 0, 0, 0, 0 }
     };
 
@@ -1055,6 +1057,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 	return 1;
     }
 
+    params.headers_only = headers_only;
+
     if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
 	/* if part was requested and format was not specified, use format=raw */
 	if (params.part >= 0)
-- 
1.7.2.3



More information about the notmuch mailing list