Re: [PATCH] doc: Allow rst2man.py as an alternative to rst2man
[notmuch-archives.git] / fc / 46f6ca502c3e74e0b68c104096775306726455
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 B6133421161\r
6         for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 08:19:38 -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 tXz8pfWyvPed for <notmuch@notmuchmail.org>;\r
16         Thu, 24 Oct 2013 08:19:33 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\r
19         by olra.theworths.org (Postfix) with ESMTP id 07496429E48\r
20         for <notmuch@notmuchmail.org>; Thu, 24 Oct 2013 08:19:22 -0700 (PDT)\r
21 X-AuditID: 12074424-b7f528e0000009aa-23-52693a7a95f6\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id C1.25.02474.A7A39625; Thu, 24 Oct 2013 11:19:22 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r9OFJF9H011798; \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 r9OFJCqk012919\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-0006dz-Qd; 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 07/11] emacs: Use notmuch tag --batch for large tag queries\r
41 Date: Thu, 24 Oct 2013 11:19:07 -0400\r
42 Message-Id: <1382627951-25252-8-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.8.4.rc3\r
44 In-Reply-To: <1382627951-25252-1-git-send-email-amdragon@mit.edu>\r
45 References: <1382627951-25252-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixG6noltllRlksPSIkkXTdGeL1XN5LK7f\r
48         nMnswOyxc9Zddo9b91+zezxbdYs5gDmKyyYlNSezLLVI3y6BK+PT+WVsBT9kKs4s6mZtYOyV\r
49         6GLk5JAQMJHYMeEjM4QtJnHh3nq2LkYuDiGBfYwS6x/vhnI2MkrM2nKFHcK5wySxccZcqMxc\r
50         RonDvVsZQfrZBDQktu1fDmaLCEhL7Lw7mxXEZhaIljhyeQYbiC0s4Cfxq2M1O4jNIqAq0XRy\r
51         J1icV8BBYkLbCUaIO5QkFp7aBtbLKeAo8fP1NbC4EFDNr99nWCYw8i9gZFjFKJuSW6Wbm5iZ\r
52         U5yarFucnJiXl1qka66Xm1mil5pSuokRHFwuKjsYmw8pHWIU4GBU4uHV+JAeJMSaWFZcmXuI\r
53         UZKDSUmU955pZpAQX1J+SmVGYnFGfFFpTmrxIUYJDmYlEd5pekA53pTEyqrUonyYlDQHi5I4\r
54         7y0O+yAhgfTEktTs1NSC1CKYrAwHh5IEb6clUKNgUWp6akVaZk4JQpqJgxNkOA/Q8HsgNbzF\r
55         BYm5xZnpEPlTjIpS4rzzQBICIImM0jy4Xlj0v2IUB3pFmHcTSBUPMHHAdb8CGswENHjKkjSQ\r
56         wSWJCCmpBsa6bV/Lyg/510RU1Wkbyq6aKWB07Nb2E2eN7eRvSRT/Yl63ZdE9vv1cPLvsfymx\r
57         eT7uKar9+HjK8ehVKX71EycEfEm9pf0iQ6Npd9zKEw2vbwiwFX3q2P1x1R5upqeqKn3+nJGC\r
58         8zbtbuV/u/lI6XMBNb7A8pTYX83CwidEvtben/Cs5K5D7F0lluKMREMt5qLiRACIqFfS2QIA        AA==\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Thu, 24 Oct 2013 15:19:39 -0000\r
72 \r
73 (Unfortunately, it's difficult to first demonstrate this problem with\r
74 a known-broken test because modern Linux kernels have argument length\r
75 limits in the megabytes, which makes Emacs really slow!)\r
76 ---\r
77  emacs/notmuch-lib.el |  8 ++++++++\r
78  emacs/notmuch-tag.el | 15 +++++++++++++--\r
79  test/emacs           |  8 ++++++++\r
80  3 files changed, 29 insertions(+), 2 deletions(-)\r
81 \r
82 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
83 index 22156f1..348112b 100644\r
84 --- a/emacs/notmuch-lib.el\r
85 +++ b/emacs/notmuch-lib.el\r
86 @@ -261,6 +261,14 @@ user-friendly queries."\r
87    "Return a query that matches the message with id ID."\r
88    (concat "id:" (notmuch-escape-boolean-term id)))\r
89  \r
90 +(defun notmuch-hex-encode (str)\r
91 +  "Hex-encode STR (e.g., as used by batch tagging).\r
92 +\r
93 +This replaces spaces, percents, and double quotes in STR with\r
94 +%NN where NN is the hexadecimal value of the character."\r
95 +  (replace-regexp-in-string\r
96 +   "[ %\"]" (lambda (match) (format "%%%02x" (aref match 0))) str))\r
97 +\r
98  ;;\r
99  \r
100  (defun notmuch-common-do-stash (text)\r
101 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
102 index 7b21006..cbb935c 100644\r
103 --- a/emacs/notmuch-tag.el\r
104 +++ b/emacs/notmuch-tag.el\r
105 @@ -252,6 +252,12 @@ from TAGS if present."\r
106            (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))\r
107      (sort result-tags 'string<)))\r
108  \r
109 +(defconst notmuch-tag-argument-limit 1000\r
110 +  "Use batch tagging if the tagging query is longer than this.\r
111 +\r
112 +This limits the length of arguments passed to the notmuch CLI to\r
113 +avoid system argument length limits and performance problems.")\r
114 +\r
115  (defun notmuch-tag (query tag-changes)\r
116    "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
117  \r
118 @@ -270,8 +276,13 @@ notmuch-after-tag-hook will be run."\r
119         tag-changes)\r
120    (unless (null tag-changes)\r
121      (run-hooks 'notmuch-before-tag-hook)\r
122 -    (apply 'notmuch-call-notmuch-process "tag"\r
123 -          (append tag-changes (list "--" query)))\r
124 +    (if (<= (length query) notmuch-tag-argument-limit)\r
125 +       (apply 'notmuch-call-notmuch-process "tag"\r
126 +              (append tag-changes (list "--" query)))\r
127 +      ;; Use batch tag mode to avoid argument length limitations\r
128 +      (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")\r
129 +                             " -- " query)))\r
130 +       (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch")))\r
131      (run-hooks 'notmuch-after-tag-hook)))\r
132  \r
133  (defun notmuch-tag-change-list (tags &optional reverse)\r
134 diff --git a/test/emacs b/test/emacs\r
135 index 05295af..5fbee12 100755\r
136 --- a/test/emacs\r
137 +++ b/test/emacs\r
138 @@ -122,6 +122,14 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")\r
139  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
140  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"\r
141  \r
142 +test_begin_subtest "Add tag (large query)"\r
143 +# We use a long query to force us into batch mode and use a funny tag\r
144 +# that requires escaping for batch tagging.\r
145 +test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (make-string notmuch-tag-argument-limit ?x)) (list \"+tag-from-%-large-query\"))"\r
146 +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
147 +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-%-large-query unread)"\r
148 +notmuch tag -tag-from-%-large-query $os_x_darwin_thread\r
149 +\r
150  test_begin_subtest "notmuch-show: add single tag to single message"\r
151  test_emacs "(notmuch-show \"$os_x_darwin_thread\")\r
152             (execute-kbd-macro \"+tag-from-show-view\")"\r
153 -- \r
154 1.8.4.rc3\r
155 \r