Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 27 / 9410ca9eeffcc074234090a40519a54e1d0a61
1 Return-Path: <Sebastian@SSpaeth.de>\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 106064196F2\r
6         for <notmuch@notmuchmail.org>; Mon, 26 Apr 2010 01:23:26 -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: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\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 7VzZQIAoeLkH for <notmuch@notmuchmail.org>;\r
16         Mon, 26 Apr 2010 01:23:24 -0700 (PDT)\r
17 Received: from homiemail-a15.g.dreamhost.com (caiajhbdcbbj.dreamhost.com\r
18         [208.97.132.119])\r
19         by olra.theworths.org (Postfix) with ESMTP id A1F8A4196F0\r
20         for <notmuch@notmuchmail.org>; Mon, 26 Apr 2010 01:23:24 -0700 (PDT)\r
21 Received: from localhost.localdomain (mtec-hg-docking-1-dhcp-204.ethz.ch\r
22         [129.132.133.204]) (Authenticated sender: sebastian@sspaeth.de)\r
23         by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 7FDF776C065; \r
24         Mon, 26 Apr 2010 01:23:23 -0700 (PDT)\r
25 From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
26 To: Notmuch developer list <notmuch@notmuchmail.org>\r
27 Subject: [PATCH v3 2/4] Integrate notmuch-maildir-fcc into notmuch\r
28 Date: Mon, 26 Apr 2010 10:23:16 +0200\r
29 Message-Id: <1272270198-28357-2-git-send-email-Sebastian@SSpaeth.de>\r
30 X-Mailer: git-send-email 1.7.0.4\r
31 In-Reply-To: <m3bpd8tpjk.fsf@x200.gr8dns.org>\r
32 References: <m3bpd8tpjk.fsf@x200.gr8dns.org>\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.13\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37         <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
39         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Mon, 26 Apr 2010 08:23:26 -0000\r
46 \r
47 Require notmuch-maildir-fcc and also install it.\r
48 Rename all jkr/* functions to notmuch-maildir-fcc-*\r
49 \r
50 Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
51 ---\r
52  emacs/Makefile.local         |    1 +\r
53  emacs/notmuch-maildir-fcc.el |   42 ++++++++++++++++++++++--------------------\r
54  emacs/notmuch.el             |    1 +\r
55  3 files changed, 24 insertions(+), 20 deletions(-)\r
56 \r
57 diff --git a/emacs/Makefile.local b/emacs/Makefile.local\r
58 index 7537c3d..e446f97 100644\r
59 --- a/emacs/Makefile.local\r
60 +++ b/emacs/Makefile.local\r
61 @@ -9,6 +9,7 @@ emacs_sources := \\r
62         $(dir)/notmuch-wash.el \\r
63         $(dir)/notmuch-hello.el \\r
64         $(dir)/notmuch-mua.el \\r
65 +       $(dir)/notmuch-maildir-fcc.el \\r
66         $(dir)/notmuch-address.el\r
67  \r
68  emacs_images := \\r
69 diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
70 index 979428e..2117f54 100644\r
71 --- a/emacs/notmuch-maildir-fcc.el\r
72 +++ b/emacs/notmuch-maildir-fcc.el\r
73 @@ -28,18 +28,18 @@\r
74  ;;\r
75  ;;     (setq message-fcc-handler-function\r
76  ;;          '(lambda (destdir)\r
77 -;;          (jkr/maildir-write-buffer-to-maildir destdir t)))\r
78 +;;          (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))\r
79  ;;\r
80  ;; if you want Fcc'd messages to be marked as new:\r
81  ;;\r
82  ;;     (setq message-fcc-handler-function\r
83  ;;          '(lambda (destdir)\r
84 -;;          (jkr/maildir-write-buffer-to-maildir destdir nil)))\r
85 +;;          (notmuch-maildir-fcc-write-buffer-to-maildir destdir nil)))\r
86  \r
87  \r
88 -(defvar jkr/maildir-count 0)\r
89 +(defvar notmuch-maildir-fcc-count 0)\r
90  \r
91 -(defun jkr/maildir-host-fixer (hostname)\r
92 +(defun notmuch-maildir-fcc-host-fixer (hostname)\r
93    (replace-regexp-in-string "/\\|:"\r
94                             '(lambda (s)\r
95                                  (cond ((string-equal s "/") "\\057")\r
96 @@ -49,31 +49,31 @@\r
97                             t\r
98                             t))\r
99  \r
100 -(defun jkr/maildir-make-uniq-maildir-id ()\r
101 +(defun notmuch-maildir-fcc-make-uniq-maildir-id ()\r
102     (let* ((ct (current-time))\r
103           (timeid (+ (* (car ct) 65536) (cadr ct)))\r
104           (microseconds (caddr ct))\r
105 -         (hostname (jkr/maildir-host-fixer system-name)))\r
106 -     (setq jkr/maildir-count (+ jkr/maildir-count 1))\r
107 +         (hostname (notmuch-maildir-fcc-host-fixer system-name)))\r
108 +     (setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1))\r
109       (format "%d.%d_%d_%d.%s"\r
110              timeid\r
111              (emacs-pid)\r
112              microseconds\r
113 -            jkr/maildir-count\r
114 +            notmuch-maildir-fcc-count\r
115              hostname)))\r
116  \r
117 -(defun jkr/maildir-dir-is-maildir-p (dir)\r
118 +(defun notmuch-maildir-fcc-dir-is-maildir-p (dir)\r
119    (and (file-exists-p (concat dir "/cur/"))\r
120         (file-exists-p (concat dir "/new/"))\r
121         (file-exists-p (concat dir "/tmp/"))))\r
122  \r
123 -(defun jkr/maildir-save-buffer-to-tmp (destdir)\r
124 +(defun notmuch-maildir-fcc-save-buffer-to-tmp (destdir)\r
125    "Returns the msg id of the message written to the temp directory\r
126  if successful, nil if not."\r
127 -  (let ((msg-id (jkr/maildir-make-uniq-maildir-id)))\r
128 +  (let ((msg-id (notmuch-maildir-fcc-make-uniq-maildir-id)))\r
129      (while (file-exists-p (concat destdir "/tmp/" msg-id))\r
130 -      (setq msg-id (jkr/maildir-make-uniq-maildir-id)))\r
131 -    (cond ((jkr/maildir-dir-is-maildir-p destdir)\r
132 +      (setq msg-id (notmuch-maildir-fcc-make-uniq-maildir-id)))\r
133 +    (cond ((notmuch-maildir-fcc-dir-is-maildir-p destdir)\r
134            (write-file (concat destdir "/tmp/" msg-id))\r
135            msg-id)\r
136           (t\r
137 @@ -81,17 +81,17 @@ if successful, nil if not."\r
138                      destdir))\r
139            nil))))\r
140  \r
141 -(defun jkr/maildir-move-tmp-to-new (destdir msg-id)\r
142 +(defun notmuch-maildir-fcc-move-tmp-to-new (destdir msg-id)\r
143    (add-name-to-file\r
144     (concat destdir "/tmp/" msg-id)\r
145     (concat destdir "/new/" msg-id ":2,")))\r
146  \r
147 -(defun jkr/maildir-move-tmp-to-cur (destdir msg-id &optional mark-seen)\r
148 +(defun notmuch-maildir-fcc-move-tmp-to-cur (destdir msg-id &optional mark-seen)\r
149    (add-name-to-file\r
150     (concat destdir "/tmp/" msg-id)\r
151     (concat destdir "/cur/" msg-id ":2," (when mark-seen "S"))))\r
152  \r
153 -(defun jkr/maildir-write-buffer-to-maildir (destdir &optional mark-seen)\r
154 +(defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir &optional mark-seen)\r
155    "Writes the current buffer to maildir destdir. If mark-seen is\r
156  non-nil, it will write it to cur/, and mark it as read. It should\r
157  return t if successful, and nil otherwise."\r
158 @@ -99,17 +99,19 @@ return t if successful, and nil otherwise."\r
159      (with-temp-buffer\r
160        (insert-buffer orig-buffer)\r
161        (catch 'link-error\r
162 -       (let ((msg-id (jkr/maildir-save-buffer-to-tmp destdir)))\r
163 +       (let ((msg-id (notmuch-maildir-fcc-save-buffer-to-tmp destdir)))\r
164           (when msg-id\r
165             (cond (mark-seen\r
166                    (condition-case err\r
167 -                      (jkr/maildir-move-tmp-to-cur destdir msg-id t)\r
168 +                      (notmuch-maildir-fcc-move-tmp-to-cur destdir msg-id t)\r
169                      (file-already-exists\r
170                       (throw 'link-error nil))))\r
171                   (t\r
172                    (condition-case err\r
173 -                      (jkr/maildir-move-tmp-to-new destdir msg-id)\r
174 +                      (notmuch-maildir-fcc-move-tmp-to-new destdir msg-id)\r
175                      (file-already-exists\r
176                       (throw 'link-error nil))))))\r
177           (delete-file (concat destdir "/tmp/" msg-id))))\r
178 -      t)))\r
179 \ No newline at end of file\r
180 +      t)))\r
181 +\r
182 +(provide 'notmuch-maildir-fcc)\r
183 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
184 index 378c004..127af2c 100644\r
185 --- a/emacs/notmuch.el\r
186 +++ b/emacs/notmuch.el\r
187 @@ -54,6 +54,7 @@\r
188  (require 'notmuch-lib)\r
189  (require 'notmuch-show)\r
190  (require 'notmuch-mua)\r
191 +(require 'notmuch-maildir-fcc)\r
192  \r
193  (defcustom notmuch-search-result-format\r
194    `(("date" . "%s ")\r
195 -- \r
196 1.7.0.4\r
197 \r