]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-reply.c
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / notmuch-reply.c
index 700f33978a14f1328a95e0dbbcf7c17d7bf7aa01..44297251d02183121685a0cb5bda2cae76cdbea4 100644 (file)
@@ -464,8 +464,8 @@ guess_from_in_received_by (notmuch_database_t *notmuch, const char *received)
  * (last Received: header added) and try to extract from them
  * indications to which email address this message was delivered.
  *
- * The Received: header is special in our get_header function and is
- * always concatenated.
+ * The Received: header is among special ones in our get_header function
+ * and is always concatenated.
  *
  * Return the address that was found, if any, and NULL otherwise.
  */
@@ -499,6 +499,9 @@ guess_from_in_received_headers (notmuch_message_t *message)
  * headers: Envelope-To, X-Original-To, and Delivered-To (searched in
  * that order).
  *
+ * The Delivered-To: header is among special ones in our get_header
+ * function and is always concatenated.
+ *
  * Return the address that was found, if any, and NULL otherwise.
  */
 static const char *
@@ -639,7 +642,9 @@ do_reply (notmuch_database_t *notmuch,
            return 1;
 
        if (count != 1) {
-           fprintf (stderr, "Error: search term did not match precisely one message (matched %u messages).\n", count);
+           fprintf (stderr,
+                    "Error: search term did not match precisely one message (matched %u messages).\n",
+                    count);
            return 1;
        }
 
@@ -658,7 +663,7 @@ do_reply (notmuch_database_t *notmuch,
         notmuch_messages_move_to_next (messages)) {
        message = notmuch_messages_get (messages);
 
-       if (mime_node_open (notmuch, message, &params->crypto, &node))
+       if (mime_node_open (notmuch, message, params->duplicate, &params->crypto, &node))
            return 1;
 
        reply = create_reply_message (notmuch, message,
@@ -678,7 +683,7 @@ do_reply (notmuch_database_t *notmuch,
 
            /* Start the original */
            sp->map_key (sp, "original");
-           format_part_sprinter (notmuch, sp, node, true, false);
+           format_part_sprinter (notmuch, sp, node, params->duplicate, true, false);
 
            /* End */
            sp->end (sp);
@@ -703,17 +708,19 @@ do_reply (notmuch_database_t *notmuch,
 }
 
 int
-notmuch_reply_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[])
+notmuch_reply_command (notmuch_database_t *notmuch, int argc, char *argv[])
 {
     notmuch_query_t *query;
     char *query_string;
     int opt_index;
     notmuch_show_params_t params = {
        .part = -1,
+       .duplicate = 0,
        .crypto = { .decrypt = NOTMUCH_DECRYPT_AUTO },
     };
     int format = FORMAT_DEFAULT;
     int reply_all = true;
+    notmuch_status_t status;
 
     notmuch_opt_desc_t options[] = {
        { .opt_keyword = &format, .name = "format", .keywords =
@@ -733,6 +740,7 @@ notmuch_reply_command (unused(notmuch_config_t *config), notmuch_database_t *not
                                      { "auto", NOTMUCH_DECRYPT_AUTO },
                                      { "true", NOTMUCH_DECRYPT_NOSTASH },
                                      { 0, 0 } } },
+       { .opt_int = &params.duplicate, .name = "duplicate" },
        { .opt_inherit = notmuch_shared_options },
        { }
     };
@@ -741,7 +749,7 @@ notmuch_reply_command (unused(notmuch_config_t *config), notmuch_database_t *not
     if (opt_index < 0)
        return EXIT_FAILURE;
 
-    notmuch_process_shared_options (argv[0]);
+    notmuch_process_shared_options (notmuch, argv[0]);
 
     notmuch_exit_if_unsupported_format ();
 
@@ -756,13 +764,11 @@ notmuch_reply_command (unused(notmuch_config_t *config), notmuch_database_t *not
        return EXIT_FAILURE;
     }
 
-    notmuch_exit_if_unmatched_db_uuid (notmuch);
-
-    query = notmuch_query_create (notmuch, query_string);
-    if (query == NULL) {
-       fprintf (stderr, "Out of memory\n");
+    status = notmuch_query_create_with_syntax (notmuch, query_string,
+                                              shared_option_query_syntax (),
+                                              &query);
+    if (print_status_database ("notmuch reply", notmuch, status))
        return EXIT_FAILURE;
-    }
 
     if (do_reply (notmuch, query, &params, format, reply_all) != 0)
        return EXIT_FAILURE;