- for (messages = notmuch_query_search_messages (query, 0, -1);
- notmuch_messages_has_more (messages);
- notmuch_messages_advance (messages))
+ if (argc && strcmp (argv[0], "--") == 0){
+ argc--;
+ argv++;
+ }
+
+ if (argc) {
+ query_str = query_string_from_args (notmuch, argc, argv);
+ if (query_str == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ return 1;
+ }
+ }
+
+ query = notmuch_query_create (notmuch, query_str);
+ if (query == NULL) {
+ fprintf (stderr, "Out of memory\n");
+ return 1;
+ }
+ notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
+
+ for (messages = notmuch_query_search_messages (query);
+ notmuch_messages_valid (messages);
+ notmuch_messages_move_to_next (messages))