Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 7c / 6a9dbee4d374b3b30a3350d9e6694c55e8857b
1 Return-Path: <amdragon@mit.edu>\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 13BED429E41\r
6         for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 08:19:29 -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 ZlePl1tjfEBZ for <notmuch@notmuchmail.org>;\r
16         Thu, 24 Oct 2013 08:19:24 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
18         [18.7.68.37])\r
19         by olra.theworths.org (Postfix) with ESMTP id CAE22429E42\r
20         for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 08:19:19 -0700 (PDT)\r
21 X-AuditID: 12074425-b7f1c8e0000009c7-ea-52693a7472ef\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 57.31.02503.47A39625; Thu, 24 Oct 2013 11:19:16 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r9OFJE6a030431; \r
27         Thu, 24 Oct 2013 11:19:15 -0400\r
28 Received: from drake.dyndns.org\r
29         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [216.15.114.40]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9OFJCvY012905\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Thu, 24 Oct 2013 11:19:14 -0400\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1VZMgq-0006dh-Kp; Thu, 24 Oct 2013 11:19:12 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v2 00/11] Fix search tagging races\r
41 Date: Thu, 24 Oct 2013 11:19:00 -0400\r
42 Message-Id: <1382627951-25252-1-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.8.4.rc3\r
44 X-Brightmail-Tracker:\r
45  H4sIAAAAAAAAA+NgFlrDIsWRmVeSWpSXmKPExsUixCmqrVtilRlksPituEXTdGeL1XN5LK7f\r
46         nMnswOyxc9Zddo9b91+zezxbdYs5gDmKyyYlNSezLLVI3y6BK2Pdv27Wgm6Viocv+hgbGNtl\r
47         uxg5OCQETCSaprh2MXICmWISF+6tZ+ti5OIQEtjHKLFscxsjhLORUaK1+T47SJWQwB0mie8f\r
48         ZSEScxkl3hzfwgySYBPQkNi2fzkjiC0iIC2x8+5sVhCbWUBPYsvDzWC2sICRxPwrr8BqWARU\r
49         JdreQwzlFXCQePGsgQ3iDCWJhae2sU5g5F3AyLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10Iv\r
50         N7NELzWldBMjKFDYXVR3ME44pHSIUYCDUYmHt+FTepAQa2JZcWXuIUZJDiYlUd57pplBQnxJ\r
51         +SmVGYnFGfFFpTmpxYcYJTiYlUR4p+kB5XhTEiurUovyYVLSHCxK4ry3OOyDhATSE0tSs1NT\r
52         C1KLYLIyHBxKErz/LIEaBYtS01Mr0jJzShDSTBycIMN5gIbfA6nhLS5IzC3OTIfIn2JUlBLn\r
53         5QXGopAASCKjNA+uFxbJrxjFgV4R5v0A0s4DTAJw3a+ABjMBDZ6yJA1kcEkiQkqqgZF5zqO2\r
54         4u47i3bNO5jxSuH30+OKQcc3nz4YZr557Zu39xzTt7A53lU9K3eL+3nvqf9aGh8K/dhsT7H1\r
55         1qx7z3VzQeeCpvqXPcy8p8oyTnw/LhvdvyPvw/Kd3ilSm+pufhMQzjwf69Qe4Be730GtR8l4\r
56         hdzGU2tSXGoMEmosX9cw/w52WuS/I0qJpTgj0VCLuag4EQBndZoOvwIAAA==\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Thu, 24 Oct 2013 15:19:29 -0000\r
70 \r
71 This is v2 of id:1381185201-25197-1-git-send-email-amdragon@mit.edu.\r
72 It fixes several comments from Mark and Jani.  This has been rebased\r
73 on top of the tag completion changes, so doing * from a large search\r
74 buffer will no longer crash.  Hence, this series depends on the\r
75 (currently pending) series in\r
76 id:1382487721-31776-1-git-send-email-amdragon@mit.edu.\r
77 \r
78 This version does not address what happens when you * on a search\r
79 buffer that's still filling.  With this series, it will apply to all\r
80 messages that have appeared when the user finishes entering tag\r
81 changes.  This isn't ideal, but this seems pretty obscure and I'm not\r
82 sure what the right answer is, so I'm punting it to the future.\r
83 \r
84 Another thing that may be worth changing in a follow-up is what\r
85 messages * applies to.  Currently, * applies *only* to matched\r
86 messages, not all threads in the search, which I think was an accident\r
87 of implementation.  This series retains that behavior, but opens up\r
88 the possibility of applying to all threads instead.  I think that\r
89 would be much more consistent and less surprising behavior.\r
90 \r
91 An approximate diff from v1 is below.  This diff is prior to rebasing,\r
92 since the post-rebase diff is not useful.\r
93 \r
94 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
95 index a4eec14..36937fb 100644\r
96 --- a/emacs/notmuch-tag.el\r
97 +++ b/emacs/notmuch-tag.el\r
98 @@ -242,7 +242,11 @@ from TAGS if present."\r
99            (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))\r
100      (sort result-tags 'string<)))\r
101  \r
102 -(defconst notmuch-tag-argument-limit 1000)\r
103 +(defconst notmuch-tag-argument-limit 1000\r
104 +  "Use batch tagging if the tagging query is longer than this.\r
105 +\r
106 +This limits the length of arguments passed to the notmuch CLI to\r
107 +avoid system argument length limits and performance problems.")\r
108  \r
109  (defun notmuch-tag (query &optional tag-changes)\r
110    "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
111 @@ -276,7 +280,6 @@ notmuch-after-tag-hook will be run."\r
112        ;; Use batch tag mode to avoid argument length limitations\r
113        (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")\r
114                               " -- " query)))\r
115 -       (message "Batch tagging with %s" batch-op)\r
116         (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch")))\r
117      (run-hooks 'notmuch-after-tag-hook))\r
118    ;; in all cases we return tag-changes as a list\r
119 diff --git a/notmuch-client.h b/notmuch-client.h\r
120 index 1b14910..8bc1a2a 100644\r
121 --- a/notmuch-client.h\r
122 +++ b/notmuch-client.h\r
123 @@ -144,7 +144,8 @@ chomp_newline (char *str)\r
124  #define NOTMUCH_FORMAT_MIN 1\r
125  /* The minimum non-deprecated structured output format version.\r
126   * Requests for format versions below this will print a stern warning.\r
127 - * Must be >= NOTMUCH_FORMAT_MIN and < NOTMUCH_FORMAT_CUR.\r
128 + * Must be between NOTMUCH_FORMAT_MIN and NOTMUCH_FORMAT_CUR,\r
129 + * inclusive.\r
130   */\r
131  #define NOTMUCH_FORMAT_MIN_ACTIVE 1\r
132  \r
133 diff --git a/notmuch-search.c b/notmuch-search.c\r
134 index 1d14651..7c973b3 100644\r
135 --- a/notmuch-search.c\r
136 +++ b/notmuch-search.c\r
137 @@ -53,13 +53,13 @@ sanitize_string (const void *ctx, const char *str)\r
138   * NULL. */\r
139  static int\r
140  get_thread_query (notmuch_thread_t *thread,\r
141 -                 char **matched_out, char **unmached_out)\r
142 +                 char **matched_out, char **unmatched_out)\r
143  {\r
144      notmuch_messages_t *messages;\r
145      char *escaped = NULL;\r
146      size_t escaped_len = 0;\r
147  \r
148 -    *matched_out = *unmached_out = NULL;\r
149 +    *matched_out = *unmatched_out = NULL;\r
150  \r
151      for (messages = notmuch_thread_get_messages (thread);\r
152          notmuch_messages_valid (messages);\r
153 @@ -69,17 +69,16 @@ get_thread_query (notmuch_thread_t *thread,\r
154         const char *mid = notmuch_message_get_message_id (message);\r
155         /* Determine which query buffer to extend */\r
156         char **buf = notmuch_message_get_flag (\r
157 -           message, NOTMUCH_MESSAGE_FLAG_MATCH) ? matched_out : unmached_out;\r
158 -       /* Allocate the query buffer is this is the first message */\r
159 -       if (!*buf && (*buf = talloc_strdup (thread, "")) == NULL)\r
160 -           return -1;\r
161 +           message, NOTMUCH_MESSAGE_FLAG_MATCH) ? matched_out : unmatched_out;\r
162         /* Add this message's id: query.  Since "id" is an exclusive\r
163          * prefix, it is implicitly 'or'd together, so we only need to\r
164          * join queries with a space. */\r
165         if (make_boolean_term (thread, "id", mid, &escaped, &escaped_len) < 0)\r
166             return -1;\r
167 -       *buf = talloc_asprintf_append_buffer (\r
168 -           *buf, "%s%s", **buf ? " " : "", escaped);\r
169 +       if (*buf)\r
170 +           *buf = talloc_asprintf_append_buffer (*buf, " %s", escaped);\r
171 +       else\r
172 +           *buf = talloc_strdup (thread, escaped);\r
173         if (!*buf)\r
174             return -1;\r
175      }\r
176 \r
177 \r