]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-reply.c
emacs: use define-derived-mode for defining modes.
[notmuch] / notmuch-reply.c
index 7c1c80959ed6cee221479353bbb84345a6875055..49513732e620d4867d1676878bd06d6124fb0062 100644 (file)
@@ -14,7 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
  *
  * Authors: Carl Worth <cworth@cworth.org>
  *         Keith Packard <keithp@keithp.com>
@@ -80,7 +80,8 @@ format_part_reply (mime_node_t *node)
            show_text_part_content (node->part, stream_stdout, NOTMUCH_SHOW_TEXT_PART_REPLY);
            g_object_unref(stream_stdout);
        } else if (disposition &&
-                  strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) {
+                  strcasecmp (g_mime_content_disposition_get_disposition (disposition),
+                              GMIME_DISPOSITION_ATTACHMENT) == 0) {
            const char *filename = g_mime_part_get_filename (GMIME_PART (node->part));
            printf ("Attachment: %s (%s)\n", filename,
                    g_mime_content_type_to_string (content_type));
@@ -323,7 +324,7 @@ add_recipients_from_message (GMimeMessage *reply,
     unsigned int n = 0;
 
     /* Some mailing lists munge the Reply-To header despite it being A Bad
-     * Thing, see http://www.unicom.com/pw/reply-to-harmful.html
+     * Thing, see http://marc.merlins.org/netrants/reply-to-harmful.html
      *
      * The munging is easy to detect, because it results in a
      * redundant reply-to header, (with an address that already exists
@@ -331,7 +332,7 @@ add_recipients_from_message (GMimeMessage *reply,
      * field and use the From header. This ensures the original sender
      * will get the reply even if not subscribed to the list. Note
      * that the address in the Reply-To header will always appear in
-     * the reply.
+     * the reply if reply_all is true.
      */
     if (reply_to_header_is_redundant (message)) {
        reply_to_map[0].header = "from";
@@ -606,8 +607,13 @@ notmuch_reply_format_default(void *ctx,
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     mime_node_t *root;
+    notmuch_status_t status;
 
-    for (messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch reply", query, status))
+       return 1;
+
+    for (;
         notmuch_messages_valid (messages);
         notmuch_messages_move_to_next (messages))
     {
@@ -650,13 +656,22 @@ notmuch_reply_format_sprinter(void *ctx,
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     mime_node_t *node;
+    unsigned count;
+    notmuch_status_t status;
+
+    status = notmuch_query_count_messages_st (query, &count);
+    if (print_status_query ("notmuch reply", query, status))
+       return 1;
 
-    if (notmuch_query_count_messages (query) != 1) {
-       fprintf (stderr, "Error: search term did not match precisely one message.\n");
+    if (count != 1) {
+       fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count);
        return 1;
     }
 
-    messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch reply", query, status))
+       return 1;
+
     message = notmuch_messages_get (messages);
     if (mime_node_open (ctx, message, &(params->crypto), &node) != NOTMUCH_STATUS_SUCCESS)
        return 1;
@@ -698,8 +713,13 @@ notmuch_reply_format_headers_only(void *ctx,
     notmuch_message_t *message;
     const char *in_reply_to, *orig_references, *references;
     char *reply_headers;
+    notmuch_status_t status;
 
-    for (messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch reply", query, status))
+       return 1;
+
+    for (;
         notmuch_messages_valid (messages);
         notmuch_messages_move_to_next (messages))
     {
@@ -769,7 +789,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
        .part = -1,
        .crypto = {
            .verify = FALSE,
-           .decrypt = FALSE
+           .decrypt = FALSE,
+           .gpgpath = NULL
        }
     };
     int format = FORMAT_DEFAULT;
@@ -789,6 +810,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
                                  { "sender", FALSE },
                                  { 0, 0 } } },
        { NOTMUCH_OPT_BOOLEAN, &params.crypto.decrypt, "decrypt", 'd', 0 },
+       { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },
        { 0, 0, 0, 0, 0 }
     };
 
@@ -796,6 +818,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
     if (opt_index < 0)
        return EXIT_FAILURE;
 
+    notmuch_process_shared_options (argv[0]);
+
     if (format == FORMAT_HEADERS_ONLY) {
        reply_format_func = notmuch_reply_format_headers_only;
     } else if (format == FORMAT_JSON) {
@@ -821,10 +845,14 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
        return EXIT_FAILURE;
     }
 
+    params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config);
+
     if (notmuch_database_open (notmuch_config_get_database_path (config),
                               NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))
        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");