Ok, I've got everything pretty much ready to go, minus the crux: the regexp @ `notmuch-search-process-filter' :) My misguided attempt seems to work perfectly fine with `re-builder' on a large sample of my mail store, but in the actual search buffer and tests, the Message-Ids appear to get cut off at some arbitrary point. This patch introduces the following changes (on top of Austin's 2nd patch): - notmuch-search.c: to prevent a slew of failing tests obscuring interesting failures, only output Message-Ids when supplied with the `--output=summary-ids' option. - emacs/notmuch.el: add property `msgids' to every result in search buffer After applying it, two tests fail, at different places, even though they output the exact same results (albeit with a different sort order) : - Basic notmuch-search view in emacs - Navigation of notmuch-hello to search results Could someone please provide my ignorant @$$ with a regexp that works? Peace Signed-off-by: Pieter Praet <pieter@praet.org> --- emacs/notmuch.el | 5 ++++- notmuch-search.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index f11ec24..501c1a2 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -801,13 +801,14 @@ non-authors is found, assume that all of the authors match." (while more (while (and (< line (length string)) (= (elt string line) ?\n)) (setq line (1+ line))) - (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line) + (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\)) \\(.*\\)$" string line) (let* ((thread-id (match-string 1 string)) (date (match-string 2 string)) (count (match-string 3 string)) (authors (match-string 4 string)) (subject (match-string 5 string)) (tags (match-string 6 string)) + (msgids (match-string 7 string)) (tag-list (if tags (save-match-data (split-string tags))))) (goto-char (point-max)) (if (/= (match-beginning 1) line) @@ -816,6 +817,7 @@ non-authors is found, assume that all of the authors match." (notmuch-search-show-result date count authors subject tags) (notmuch-search-color-line beg (point-marker) tag-list) (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id) + (put-text-property beg (point-marker) 'notmuch-search-msgids msgids) (put-text-property beg (point-marker) 'notmuch-search-authors authors) (put-text-property beg (point-marker) 'notmuch-search-subject subject) (if (string= thread-id notmuch-search-target-thread) @@ -913,6 +915,7 @@ The optional parameters are used as follows: (let ((proc (start-process "notmuch-search" buffer notmuch-command "search" + "--output=summary-ids" (if oldest-first "--sort=oldest-first" "--sort=newest-first") diff --git a/notmuch-search.c b/notmuch-search.c index 2288eb7..b3af88b 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -22,6 +22,7 @@ typedef enum { OUTPUT_SUMMARY, + OUTPUT_SUMMARY_IDS, OUTPUT_THREADS, OUTPUT_MESSAGES, OUTPUT_FILES, @@ -274,7 +275,7 @@ do_search_threads (const search_format_t *format, fputs (format->tag_end, stdout); - if (format == &format_text) { + if (format == &format_text && output == OUTPUT_SUMMARY_IDS) { notmuch_messages_t *toplevel; const char *first; @@ -462,6 +463,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) opt = argv[i] + sizeof ("--output=") - 1; if (strcmp (opt, "summary") == 0) { output = OUTPUT_SUMMARY; + } else if (strcmp (opt, "summary-ids") == 0) { + output = OUTPUT_SUMMARY_IDS; } else if (strcmp (opt, "threads") == 0) { output = OUTPUT_THREADS; } else if (strcmp (opt, "messages") == 0) { @@ -513,6 +516,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) switch (output) { default: case OUTPUT_SUMMARY: + case OUTPUT_SUMMARY_IDS: case OUTPUT_THREADS: ret = do_search_threads (format, query, sort, output); break; -- 1.7.5.4