]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.c
notmuch show: Trim down header list.
[notmuch] / notmuch.c
index 66b615b2285605cd712852e3eb2060365028d43d..4ac5531ae42a14c8216e3977cfc7dc8a495fbb29 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -806,7 +806,16 @@ show_command (unused (int argc), unused (char *argv[]))
     notmuch_query_t *query = NULL;
     notmuch_message_results_t *messages;
     notmuch_message_t *message;
+    const char *filename;
+    FILE *file;
     int ret = 0;
+    int c;
+
+    const char *headers[] = {
+       "Subject", "From", "To", "Cc", "Bcc", "Date"
+    };
+    const char *name, *value;
+    unsigned int i;
 
     if (argc != 1) {
        fprintf (stderr, "Error: \"notmuch show\" requires exactly one thread-ID argument.\n");
@@ -844,9 +853,30 @@ show_command (unused (int argc), unused (char *argv[]))
 
        printf ("%%header{\n");
 
-       printf ("%s", notmuch_message_get_all_headers (message));
+       for (i = 0; i < ARRAY_SIZE (headers); i++) {
+           name = headers[i];
+           value = notmuch_message_get_header (message, name);
+           if (value)
+               printf ("%s: %s\n", name, value);
+       }
 
        printf ("%%header}\n");
+
+       filename = notmuch_message_get_filename (message);
+
+       file = fopen (filename, "r");
+       if (file) {
+           size_t header_size = notmuch_message_get_header_size (message);
+           fseek (file, header_size + 1, SEEK_SET);
+           while (1) {
+               c = fgetc (file);
+               if (c == EOF)
+                   break;
+               putchar (c);
+           }
+       }
+       fclose (file);
+
        printf ("%%message}\n");
 
        notmuch_message_destroy (message);
@@ -1206,7 +1236,6 @@ command_t commands[] = {
       "\t\tmarks around any parenthesized expression)." },
     { "show", show_command,
       "<thread-id>\n\n"
-      "\t\tNote: The \"notmuch show\" command is not implemented yet.\n\n"
       "\t\tShow the thread with the given thread ID (see 'search').",
       "\t\tThread ID values are given as the first column in the\n"
       "\t\toutput of the \"notmuch search\" command. These are the\n"