Re: [WIP PATCH] emacs: query: completion for from: in searches
[notmuch-archives.git] / c0 / fd5cd3bb0a0fb0212df42801e07c576d89bc9e
1 Return-Path: <pieter@praet.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id B5C48429E25\r
6         for <notmuch@notmuchmail.org>; Sun, 10 Jul 2011 07:11:53 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 9cCeYYwX5Y7T for <notmuch@notmuchmail.org>;\r
16         Sun, 10 Jul 2011 07:11:53 -0700 (PDT)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  9AB99431FB6    for <notmuch@notmuchmail.org>; Sun, 10 Jul 2011 07:11:52 -0700\r
21  (PDT)\r
22 Received: by wwj40 with SMTP id 40so1490275wwj.2\r
23         for <notmuch@notmuchmail.org>; Sun, 10 Jul 2011 07:11:51 -0700 (PDT)\r
24 Received: by 10.216.202.9 with SMTP id c9mr2288319weo.14.1310307111071;\r
25         Sun, 10 Jul 2011 07:11:51 -0700 (PDT)\r
26 Received: from localhost ([109.131.150.231])\r
27         by mx.google.com with ESMTPS id z22sm6414076weq.2.2011.07.10.07.11.48\r
28         (version=TLSv1/SSLv3 cipher=OTHER);\r
29         Sun, 10 Jul 2011 07:11:49 -0700 (PDT)\r
30 From: Pieter Praet <pieter@praet.org>\r
31 To: Austin Clements <amdragon@MIT.EDU>\r
32 Subject: [PATCH] emacs: bad regexp @ `notmuch-search-process-filter'\r
33 Date: Sun, 10 Jul 2011 16:11:39 +0200\r
34 Message-Id: <1310307099-25197-1-git-send-email-pieter@praet.org>\r
35 X-Mailer: git-send-email 1.7.5.4\r
36 In-Reply-To: <20110705214234.GA15360@mit.edu>\r
37 References: <20110705214234.GA15360@mit.edu>\r
38 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Sun, 10 Jul 2011 14:11:53 -0000\r
52 \r
53 Ok, I've got everything pretty much ready to go, minus the crux:\r
54 the regexp @ `notmuch-search-process-filter' :)\r
55 \r
56 My misguided attempt seems to work perfectly fine with `re-builder' on a\r
57 large sample of my mail store, but in the actual search buffer and tests,\r
58 the Message-Ids appear to get cut off at some arbitrary point.\r
59 \r
60 This patch introduces the following changes (on top of Austin's 2nd patch):\r
61 - notmuch-search.c: to prevent a slew of failing tests obscuring\r
62   interesting failures, only output Message-Ids when supplied with the\r
63   `--output=summary-ids' option.\r
64 - emacs/notmuch.el: add property `msgids' to every result in search buffer\r
65 \r
66 After applying it, two tests fail, at different places, even though they\r
67 output the exact same results (albeit with a different sort order) :\r
68 - Basic notmuch-search view in emacs\r
69 - Navigation of notmuch-hello to search results\r
70 \r
71 Could someone please provide my ignorant @$$ with a regexp that works?\r
72 \r
73 Peace\r
74 \r
75 Signed-off-by: Pieter Praet <pieter@praet.org>\r
76 ---\r
77  emacs/notmuch.el |    5 ++++-\r
78  notmuch-search.c |    6 +++++-\r
79  2 files changed, 9 insertions(+), 2 deletions(-)\r
80 \r
81 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
82 index f11ec24..501c1a2 100644\r
83 --- a/emacs/notmuch.el\r
84 +++ b/emacs/notmuch.el\r
85 @@ -801,13 +801,14 @@ non-authors is found, assume that all of the authors match."\r
86               (while more\r
87                 (while (and (< line (length string)) (= (elt string line) ?\n))\r
88                   (setq line (1+ line)))\r
89 -               (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)\r
90 +               (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\)) \\(.*\\)$" string line)\r
91                     (let* ((thread-id (match-string 1 string))\r
92                            (date (match-string 2 string))\r
93                            (count (match-string 3 string))\r
94                            (authors (match-string 4 string))\r
95                            (subject (match-string 5 string))\r
96                            (tags (match-string 6 string))\r
97 +                          (msgids (match-string 7 string))\r
98                            (tag-list (if tags (save-match-data (split-string tags)))))\r
99                       (goto-char (point-max))\r
100                       (if (/= (match-beginning 1) line)\r
101 @@ -816,6 +817,7 @@ non-authors is found, assume that all of the authors match."\r
102                         (notmuch-search-show-result date count authors subject tags)\r
103                         (notmuch-search-color-line beg (point-marker) tag-list)\r
104                         (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)\r
105 +                       (put-text-property beg (point-marker) 'notmuch-search-msgids msgids)\r
106                         (put-text-property beg (point-marker) 'notmuch-search-authors authors)\r
107                         (put-text-property beg (point-marker) 'notmuch-search-subject subject)\r
108                         (if (string= thread-id notmuch-search-target-thread)\r
109 @@ -913,6 +915,7 @@ The optional parameters are used as follows:\r
110         (let ((proc (start-process\r
111                      "notmuch-search" buffer\r
112                      notmuch-command "search"\r
113 +                    "--output=summary-ids"\r
114                      (if oldest-first\r
115                          "--sort=oldest-first"\r
116                        "--sort=newest-first")\r
117 diff --git a/notmuch-search.c b/notmuch-search.c\r
118 index 2288eb7..b3af88b 100644\r
119 --- a/notmuch-search.c\r
120 +++ b/notmuch-search.c\r
121 @@ -22,6 +22,7 @@\r
122  \r
123  typedef enum {\r
124      OUTPUT_SUMMARY,\r
125 +    OUTPUT_SUMMARY_IDS,\r
126      OUTPUT_THREADS,\r
127      OUTPUT_MESSAGES,\r
128      OUTPUT_FILES,\r
129 @@ -274,7 +275,7 @@ do_search_threads (const search_format_t *format,\r
130  \r
131             fputs (format->tag_end, stdout);\r
132  \r
133 -           if (format == &format_text) {\r
134 +           if (format == &format_text && output == OUTPUT_SUMMARY_IDS) {\r
135                 notmuch_messages_t *toplevel;\r
136                 const char *first;\r
137  \r
138 @@ -462,6 +463,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
139             opt = argv[i] + sizeof ("--output=") - 1;\r
140             if (strcmp (opt, "summary") == 0) {\r
141                 output = OUTPUT_SUMMARY;\r
142 +           } else if (strcmp (opt, "summary-ids") == 0) {\r
143 +               output = OUTPUT_SUMMARY_IDS;\r
144             } else if (strcmp (opt, "threads") == 0) {\r
145                 output = OUTPUT_THREADS;\r
146             } else if (strcmp (opt, "messages") == 0) {\r
147 @@ -513,6 +516,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
148      switch (output) {\r
149      default:\r
150      case OUTPUT_SUMMARY:\r
151 +    case OUTPUT_SUMMARY_IDS:\r
152      case OUTPUT_THREADS:\r
153         ret = do_search_threads (format, query, sort, output);\r
154         break;\r
155 -- \r
156 1.7.5.4\r
157 \r