Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 27 / d2e0f4fe0d4112ff8cb2ffa8ab3ed669a3530a
1 Return-Path: <markwalters1009@gmail.com>\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 arlo.cworth.org (Postfix) with ESMTP id 848C06DE0319\r
6  for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 16:03:18 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.335\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.335 tagged_above=-999 required=5 tests=[AWL=0.235,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id 0DZc6Jm-rST1 for <notmuch@notmuchmail.org>;\r
19  Fri, 10 Jun 2016 16:03:10 -0700 (PDT)\r
20 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
21  [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 7EDBF6DE00DF for\r
22  <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 16:03:05 -0700 (PDT)\r
23 Received: by mail-wm0-f65.google.com with SMTP id n184so1713859wmn.1\r
24  for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 16:03:05 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27  bh=IndlDcsn9t+LchHWSRIMysZ6P5+h3eusanbeUDDJETU=;\r
28  b=WRzaZUkb6hIMvZ8TmgIQen70et+FxJ9A3ajToNCnsyWPlg/5zziV62JqrdfaDg4b/2\r
29  wm7XEmIzQBkImozpB9wzBXIUNbLcHxsKOL39Z8qGFHji6ymBhHcSPFCsYTQgkF/LEfxr\r
30  l/8/Y1FhSLrShVWaEBwLSpT6fmcxHVFErzZBta/neJb10zNJiTaR+I0YLVUoW94+gMFm\r
31  BSk5KTH76EzKhu5xSVNnufJbZQdhoxwTF3p50SyDmkwInwVRDkRXOOZnanf99qVHayc7\r
32  D0P4rESxwCMfv7oPN3SLw5Otg37CuZ5VX3VjfBTtQ/hSX57LARlzhHuxFs1lqCgSuEIq\r
33  ZAoQ==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=IndlDcsn9t+LchHWSRIMysZ6P5+h3eusanbeUDDJETU=;\r
39  b=OkRXeiAQp5b1Nx76TOdhzUn+iVWdheGYImw4CgjdWMe/pLccFHewPcjvkYxhBEiLik\r
40  yxaVNiNjz9xF4E+ttb4dFC2Qi3KiD6K7879BSrGoUSIN+LEXlKFBSTeEldwzoNExOJI5\r
41  BSGB+d8DPYRQ++3s/n58FIvndWlmECB1KgrzSDvFND8tsBBOb63IIf3z4WZ49NHBkE3B\r
42  cAv7BfifOZKhLzrGNfDYvdgNKT4y0vnKOSie02jQqUeU6atej74u5ysOr+UqUymjLNZB\r
43  s/XR5ENc0ehlQve6Go8nnfn6c8xFY+obPln06lMHX7fWhMpI7OusPFIOax1hbZKja7uz\r
44  mqig==\r
45 X-Gm-Message-State:\r
46  ALyK8tIVz1j7mEJu97Su1Lh3juS5h9m6JlJRVLS0xqH2qm0Qn1B4ffLDExJgUAijrErrjg==\r
47 X-Received: by 10.194.192.193 with SMTP id hi1mr4081178wjc.4.1465599784031;\r
48  Fri, 10 Jun 2016 16:03:04 -0700 (PDT)\r
49 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
50  by smtp.gmail.com with ESMTPSA id 124sm1266181wml.12.2016.06.10.16.03.03\r
51  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
52  Fri, 10 Jun 2016 16:03:03 -0700 (PDT)\r
53 From: Mark Walters <markwalters1009@gmail.com>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH 2/6] emacs: maildir-fcc: prepare for use of notmuch insert\r
56 Date: Sat, 11 Jun 2016 00:02:48 +0100\r
57 Message-Id: <1465599772-10297-3-git-send-email-markwalters1009@gmail.com>\r
58 X-Mailer: git-send-email 2.1.4\r
59 In-Reply-To: <1465599772-10297-1-git-send-email-markwalters1009@gmail.com>\r
60 References: <1465599772-10297-1-git-send-email-markwalters1009@gmail.com>\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.20\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65  <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
67  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
72  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Fri, 10 Jun 2016 23:03:18 -0000\r
74 \r
75 We move some code around in preparation for the use of notmuch\r
76 insert. In particular, we move the check for a valid maildir for the\r
77 fcc to when the message is sent rather than when the fcc header is\r
78 inserted. The main motivation is consistency with the insert version\r
79 (coming later) where we cannot check the validity until send.\r
80 \r
81 We allow the user some chance to correct the header; the choice here\r
82 is intended to be consistent with the insert version to come.\r
83 ---\r
84  emacs/notmuch-maildir-fcc.el | 69 ++++++++++++++++++++++++++++----------------\r
85  1 file changed, 44 insertions(+), 25 deletions(-)\r
86 \r
87 diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
88 index bbf6132..835258f 100644\r
89 --- a/emacs/notmuch-maildir-fcc.el\r
90 +++ b/emacs/notmuch-maildir-fcc.el\r
91 @@ -65,11 +65,9 @@ yet when sending a mail."\r
92   :require 'notmuch-fcc-initialization\r
93   :group 'notmuch-send)\r
94  \r
95 -(defun notmuch-fcc-handler (destdir)\r
96 -  "Write buffer to `destdir', marking it as sent\r
97  \r
98 -Intended to be dynamically bound to `message-fcc-handler-function'"\r
99 -    (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))\r
100 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
101 +;; Functions which set up the fcc header in the message buffer.\r
102  \r
103  (defun notmuch-fcc-header-setup ()\r
104    "Add an Fcc header to the current message buffer.\r
105 @@ -110,27 +108,25 @@ by notmuch-mua-mail"\r
106            (error "Invalid `notmuch-fcc-dirs' setting (neither string nor list)")))))\r
107  \r
108      (when subdir\r
109 -      (message-add-header\r
110 -       (concat "Fcc: "\r
111 -              (file-truename\r
112 -               ;; If the resulting directory is not an absolute path,\r
113 -               ;; prepend the standard notmuch database path.\r
114 -               (if (= (elt subdir 0) ?/)\r
115 -                   subdir\r
116 -                 (concat (notmuch-database-path) "/" subdir)))))\r
117 -      \r
118 -      ;; finally test if fcc points to a valid maildir\r
119 -      (let ((fcc-header (message-field-value "Fcc")))\r
120 -       (unless (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)\r
121 -         (cond ((not (file-writable-p fcc-header))\r
122 -                (error (format "No permission to create %s, which does not exist"\r
123 -                               fcc-header)))\r
124 -               ((y-or-n-p (format "%s is not a maildir. Create it? "\r
125 -                                  fcc-header))\r
126 -                (notmuch-maildir-fcc-create-maildir fcc-header))\r
127 -               (t\r
128 -                (error "Message not sent"))))))))\r
129\r
130 +      (notmuch-maildir-add-file-style-fcc-header subdir))))\r
131 +\r
132 +(defun notmuch-maildir-add-file-style-fcc-header (subdir)\r
133 +  (message-add-header\r
134 +   (concat "Fcc: "\r
135 +          (file-truename\r
136 +           ;; If the resulting directory is not an absolute path,\r
137 +           ;; prepend the standard notmuch database path.\r
138 +           (if (= (elt subdir 0) ?/)\r
139 +               subdir\r
140 +             (concat (notmuch-database-path) "/" subdir))))))\r
141 +\r
142 +(defun notmuch-fcc-handler (fcc-header)\r
143 +  "Store message with file fcc."\r
144 +  (notmuch-maildir-fcc-file-fcc fcc-header))\r
145 +\r
146 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
147 +;; Functions for saving a message using file fcc.\r
148 +\r
149  (defun notmuch-maildir-fcc-host-fixer (hostname)\r
150    (replace-regexp-in-string "/\\|:"\r
151                             (lambda (s)\r
152 @@ -192,6 +188,29 @@ if successful, nil if not."\r
153     (concat destdir "/tmp/" msg-id)\r
154     (concat destdir "/cur/" msg-id ":2," (when mark-seen "S"))))\r
155  \r
156 +(defun notmuch-maildir-fcc-file-fcc (fcc-header)\r
157 +  "Write the message to the file specified by FCC-HEADER.\r
158 +\r
159 +It offers the user a chance to correct the header, or filesystem,\r
160 +if needed."\r
161 +  (if (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)\r
162 +      (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header 't)\r
163 +    ;; The fcc-header is not a valid maildir see if the user wants to\r
164 +    ;; fix it in some way.\r
165 +    (let* ((prompt (format "Fcc %s is not a maildir: (r)etry, (c)reate folder, (i)gnore, or  (e)dit the header? "\r
166 +                          fcc-header))\r
167 +           (response (read-char-choice prompt '(?r ?c ?i ?e))))\r
168 +        (case response\r
169 +              (?r (notmuch-maildir-fcc-file-fcc fcc-header))\r
170 +              (?c (if (file-writable-p fcc-header)\r
171 +                      (notmuch-maildir-fcc-create-maildir fcc-header)\r
172 +                    (message "No permission to create %s." fcc-header)\r
173 +                    (sit-for 2))\r
174 +                  (notmuch-maildir-fcc-file-fcc fcc-header))\r
175 +              (?i 't)\r
176 +              (?e (notmuch-maildir-fcc-file-fcc\r
177 +                   (read-from-minibuffer "Fcc header: " fcc-header)))))))\r
178 +\r
179  (defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir &optional mark-seen)\r
180    "Writes the current buffer to maildir destdir. If mark-seen is\r
181  non-nil, it will write it to cur/, and mark it as read. It should\r
182 -- \r
183 2.1.4\r
184 \r