Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / e7 / 9b65404bedbe2cb2f0562590fd91890b36626a
1 Return-Path: <tomi.ollila@iki.fi>\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 3A6D16DE020B\r
6  for <notmuch@notmuchmail.org>; Thu,  6 Aug 2015 12:09:14 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 1.25\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.25 tagged_above=-999 required=5 tests=[AWL=-0.146, \r
12  SPF_NEUTRAL=0.652, URIBL_SBL=0.644, URIBL_SBL_A=0.1]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id HGFhDf0E5kW0 for <notmuch@notmuchmail.org>;\r
17  Thu,  6 Aug 2015 12:09:12 -0700 (PDT)\r
18 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
19  by arlo.cworth.org (Postfix) with ESMTP id 7EBA56DE00DE\r
20  for <notmuch@notmuchmail.org>; Thu,  6 Aug 2015 12:09:10 -0700 (PDT)\r
21 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
22  by guru.guru-group.fi (Postfix) with ESMTP id 7DA60100046;\r
23  Thu,  6 Aug 2015 22:08:56 +0300 (EEST)\r
24 From: Tomi Ollila <tomi.ollila@iki.fi>\r
25 To: David Bremner <david@tethera.net>,\r
26  Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
27 Subject: Re: [PATCH 2/2] emacs: make modifications to message Fcc vars\r
28  buffer-local\r
29 In-Reply-To: <1438718659-11522-2-git-send-email-david@tethera.net>\r
30 References: <87fv4093sl.fsf@maritornes.cs.unb.ca>\r
31  <1438718659-11522-1-git-send-email-david@tethera.net>\r
32  <1438718659-11522-2-git-send-email-david@tethera.net>\r
33 User-Agent: Notmuch/0.20.2+54~g0bf3ee6 (http://notmuchmail.org) Emacs/24.3.1\r
34  (x86_64-unknown-linux-gnu)\r
35 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
36  $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
37  !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
38 Date: Thu, 06 Aug 2015 22:08:56 +0300\r
39 Message-ID: <m2twscdyk7.fsf@guru.guru-group.fi>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.18\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46  <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Thu, 06 Aug 2015 19:09:14 -0000\r
55 \r
56 On Tue, Aug 04 2015, David Bremner <david@tethera.net> wrote:\r
57 \r
58 > Previously we globally modified these variables, which tended to cause\r
59 > problems for people using message-mode, but not notmuch-mua-mail, to\r
60 > send mail.\r
61 >\r
62 > User visible changes:\r
63 >\r
64 > - calling notmuch-fcc-header-setup is no longer optional. OTOH, it\r
65 >   seems to do the right thing if notmuch-fcc-dirs is set to nil.\r
66 >\r
67 > - the Fcc header is visible during message composition\r
68 >\r
69 > - the name in the mode line is changed, and (sadface) no longer\r
70 >   matches the menu label.\r
71 >\r
72 > - Previously notmuch-mua-send-and-exit was never called.  Either we\r
73 >   misunderstood define-mail-user-agent, or it had a bug.  So there was\r
74 >   no difference if the user called message-send-and-exit directly. Now\r
75 >   there will be.\r
76 >\r
77 > - user bindings to C-c C-s and C-c C-s in message-mode-map are\r
78 >   overridden. The user can override them in notmuch-message-mode-map,\r
79 >   but then they're on their own for Fcc handling.\r
80 \r
81 This looks pretty good to me -- one of the above is `C-c C-c` and\r
82 capitalization could be consistent in the commit message.\r
83 \r
84 One thing come to my mind: would it be possible to use buffer-local\r
85 variable message-fcc-handler-function in notmuch-message-mode buffers so\r
86 that such wrapper functions defined below would not be needed. i.e.\r
87 \r
88   (make-local-variable 'message-fcc-handler-function)\r
89   (setq message-fcc-handler-function #'notmuch-fcc-handler)\r
90 \r
91 (or not? :D)\r
92 \r
93 one more thing (extra newline) inline below\r
94  \r
95 Tomi\r
96 \r
97 > ---\r
98 >  emacs/notmuch-maildir-fcc.el | 23 +++++++++--------------\r
99 >  emacs/notmuch-mua.el         | 15 +++++++++++++--\r
100 >  test/test-lib.sh             |  4 ++--\r
101 >  3 files changed, 24 insertions(+), 18 deletions(-)\r
102 >\r
103 > diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
104 > index 07eedba..c2f2f4c 100644\r
105 > --- a/emacs/notmuch-maildir-fcc.el\r
106 > +++ b/emacs/notmuch-maildir-fcc.el\r
107 > @@ -59,23 +59,19 @@ yet when sending a mail."\r
108 >   :require 'notmuch-fcc-initialization\r
109 >   :group 'notmuch-send)\r
110 >  \r
111 > -(defun notmuch-fcc-initialization ()\r
112 > -  "If notmuch-fcc-directories is set,\r
113 > -   hook them into the message-fcc-handler-function"\r
114 > -    ;; Set up the message-fcc-handler to move mails to the maildir in Fcc\r
115 > -    ;; The parameter is set to mark messages as "seen"\r
116 > -    (setq message-fcc-handler-function\r
117 > -          (lambda (destdir)\r
118 > -         (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))\r
119 > -    ;; add a hook to actually insert the Fcc header when sending\r
120 > -    (add-hook 'message-header-setup-hook 'notmuch-fcc-header-setup))\r
121 > +(defun notmuch-fcc-handler (destdir)\r
122 > +  "Write buffer to `destdir', marking it as sent\r
123 > +\r
124 > +Intended to be dynamically bound to `message-fcc-handler-function'"\r
125 > +    (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))\r
126 >  \r
127 >  (defun notmuch-fcc-header-setup ()\r
128 >    "Add an Fcc header to the current message buffer.\r
129 >  \r
130 > -Can be added to `message-send-hook' and will set the Fcc header\r
131 > -based on the values of `notmuch-fcc-dirs'. An existing Fcc header\r
132 > -will NOT be removed or replaced."\r
133 > +Sets the Fcc header based on the values of `notmuch-fcc-dirs'.\r
134 > +\r
135 > +Originally intended to be use a hook function, but now called directly\r
136 > +by notmuch-mua-mail"\r
137 >  \r
138 >    (let ((subdir\r
139 >        (cond\r
140 > @@ -213,6 +209,5 @@ return t if successful, and nil otherwise."\r
141 >         (delete-file (concat destdir "/tmp/" msg-id))))\r
142 >        t)))\r
143 >  \r
144 > -(notmuch-fcc-initialization)\r
145 >  (provide 'notmuch-maildir-fcc)\r
146 >  \r
147 > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
148 > index 1018321..803459a 100644\r
149 > --- a/emacs/notmuch-mua.el\r
150 > +++ b/emacs/notmuch-mua.el\r
151 > @@ -268,9 +268,13 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
152 >    (message-goto-body)\r
153 >    (set-buffer-modified-p nil))\r
154 >  \r
155 > -(define-derived-mode notmuch-message-mode message-mode "Notmuch Message"\r
156 > +(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"\r
157 >    "Notmuch message composition mode. Mostly like `message-mode'")\r
158 >  \r
159 > +(define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)\r
160 > +(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)\r
161 > +\r
162 > +\r
163 \r
164 2 empty lines above -- nowhere else in notmuch-mua.el is such a thing.\r
165 \r
166 >  (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)\r
167 >    "Invoke the notmuch mail composition window.\r
168 >  \r
169 > @@ -288,6 +292,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
170 >  \r
171 >    (apply #'message-mail to subject other-headers other-args)\r
172 >    (notmuch-message-mode)\r
173 > +  (notmuch-fcc-header-setup)\r
174 >    (message-sort-headers)\r
175 >    (message-hide-headers)\r
176 >    (set-buffer-modified-p nil)\r
177 > @@ -401,7 +406,13 @@ will be addressed to all recipients of the source message."\r
178 >  \r
179 >  (defun notmuch-mua-send-and-exit (&optional arg)\r
180 >    (interactive "P")\r
181 > -  (message-send-and-exit arg))\r
182 > +  (let ((message-fcc-handler-function #'notmuch-fcc-handler))\r
183 > +    (message-send-and-exit arg)))\r
184 > +\r
185 > +(defun notmuch-mua-send (&optional arg)\r
186 > +  (interactive "P")\r
187 > +  (let ((message-fcc-handler-function #'notmuch-fcc-handler))\r
188 > +    (message-send arg)))\r
189 >  \r
190 >  (defun notmuch-mua-kill-buffer ()\r
191 >    (interactive)\r
192 > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
193 > index db3b6aa..eeb5487 100644\r
194 > --- a/test/test-lib.sh\r
195 > +++ b/test/test-lib.sh\r
196 > @@ -487,7 +487,7 @@ emacs_deliver_message ()\r
197 >          (message-goto-body)\r
198 >          (insert \"${body}\")\r
199 >          $@\r
200 > -        (message-send-and-exit))"\r
201 > +        (notmuch-mua-send-and-exit))"\r
202 >  \r
203 >      # In case message was sent properly, client waits for confirmation\r
204 >      # before exiting and resuming control here; therefore making sure\r
205 > @@ -522,7 +522,7 @@ emacs_fcc_message ()\r
206 >          (message-goto-body)\r
207 >          (insert \"${body}\")\r
208 >          $@\r
209 > -        (message-send-and-exit))" || return 1\r
210 > +        (notmuch-mua-send-and-exit))" || return 1\r
211 >      notmuch new >/dev/null\r
212 >  }\r
213 >  \r
214 > -- \r
215 > 2.1.4\r