Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 50 / 360f20f9a2e519f021c5d58b5d129e5d5e8379
1 Return-Path: <mdroth@linux.vnet.ibm.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 olra.theworths.org (Postfix) with ESMTP id 1EA8D431FD0\r
6         for <notmuch@notmuchmail.org>; Fri, 23 Sep 2011 17:46:54 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 z9qw7pK8MSuL for <notmuch@notmuchmail.org>;\r
16         Fri, 23 Sep 2011 17:46:52 -0700 (PDT)\r
17 Received: from mout.perfora.net (mout.perfora.net [74.208.4.194])\r
18         by olra.theworths.org (Postfix) with ESMTP id D1644431FB6\r
19         for <notmuch@notmuchmail.org>; Fri, 23 Sep 2011 17:46:52 -0700 (PDT)\r
20 Received: from illuin.austin.ibm.com ([32.97.110.59])\r
21         by mrelay.perfora.net (node=mrus2) with ESMTP (Nemesis)\r
22         id 0Mclzd-1QpSWZ39wf-00HiY1; Fri, 23 Sep 2011 20:46:51 -0400\r
23 From: Michael Roth <mdroth@linux.vnet.ibm.com>\r
24 To: notmuch@notmuchmail.org\r
25 Subject: [PATCH] vim plugin: allow customizing of current read+archive+advance\r
26         behavior\r
27 Date: Fri, 23 Sep 2011 19:46:40 -0500\r
28 Message-Id: <1316825200-15711-1-git-send-email-mdroth@linux.vnet.ibm.com>\r
29 X-Mailer: git-send-email 1.7.4.1\r
30 X-Provags-ID: V02:K0:OH16NLnnZKYuQYCguu5kehl83Ent3EOEsJgRnR42irT\r
31         d7A5D95zpwEJLQe5Fm7a8XUbjy53/OWfsbt+ZhuV2i8g2lHrlA\r
32         zHJ2wvltPaWid19Bm7l88pR5LEwBbz3XHSNbO8t1+8+esbnwEI\r
33         1tK00Xj306QFyinCQgmjYaNaoVAMz3at57/ETsWb/CtvPqvqXa\r
34         AsD7gywdlFV+wWPtw2Lnr92P+fI1f87ATz5lFjSr4d+eSym9jP\r
35         62EKQfVkkCPUPRchZuGSRRIh/SqO2R74BvPtkVeMQPDkCTz6wm\r
36         +q25lYeUnVc1ZQVsjuuMbO5OXES5Q41aZryQ7UXfHZ4p2W+8ET\r
37         WLDr9+TJDhZ2+dUEX3pI6WfGH7rVpjgDjaNpMYZnV+cXgDuGNV\r
38         UpJ4YbiEzvI51Gt0nDYT05HCr1mURQXvEc=\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Sat, 24 Sep 2011 00:46:54 -0000\r
52 \r
53 Currently if you navigate through an entire thread using <space> it will\r
54 automatically have it's 'unread' and 'inbox' tags removed.\r
55 \r
56 For many userss archiving is limited to threads that are old and unlikely\r
57 to be referenced again rather than threads that you've simply read or\r
58 glanced through recently, particularly users like me with poor\r
59 long-term memory.\r
60 \r
61 This patch adds g:notmuch_advance_add_tags and\r
62 g:notmuch_advance_remove_tags settings to customize this behavior while\r
63 also adding the option to have tags added to threads that have been read\r
64 in their entirety.\r
65 \r
66 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>\r
67 ---\r
68  vim/plugin/notmuch.vim |   47 ++++++++++++++++++++++++++++++++++++-----------\r
69  1 files changed, 36 insertions(+), 11 deletions(-)\r
70 \r
71 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim\r
72 index 21985c7..5bcd262 100644\r
73 --- a/vim/plugin/notmuch.vim\r
74 +++ b/vim/plugin/notmuch.vim\r
75 @@ -103,6 +103,14 @@ let s:notmuch_compose_headers_defaults = [\r
76          \ 'Subject'\r
77          \ ]\r
78  \r
79 +" defaults for g:notmuch_advance_remove_tags\r
80 +" override with: let g:notmuch_advance_remove_tags = [ ... ]\r
81 +let s:notmuch_advance_remove_tags = [ 'unread', 'inbox' ]\r
82 +\r
83 +" defaults for g:notmuch_advance_add_tags\r
84 +" override with: let g:notmuch_advance_add_tags = [ ... ]\r
85 +let s:notmuch_advance_add_tags = [ ]\r
86 +\r
87  " --- keyboard mapping definitions {{{1\r
88  \r
89  " --- --- bindings for folders mode {{{2\r
90 @@ -160,7 +168,7 @@ let g:notmuch_show_maps = {\r
91          \ 'v':          ':call <SID>NM_show_view_all_mime_parts()<CR>',\r
92          \ '+':          ':call <SID>NM_show_add_tag()<CR>',\r
93          \ '-':          ':call <SID>NM_show_remove_tag()<CR>',\r
94 -        \ '<Space>':    ':call <SID>NM_show_advance_marking_read_and_archiving()<CR>',\r
95 +        \ '<Space>':    ':call <SID>NM_show_advance_and_tag()<CR>',\r
96          \ '\|':         ':call <SID>NM_show_pipe_message()<CR>',\r
97          \\r
98          \ '<S-Tab>':    ':call <SID>NM_show_previous_fold()<CR>',\r
99 @@ -573,10 +581,11 @@ endfunction\r
100  \r
101  " if entire message is not visible scroll down 1/2 page or less to get to the bottom of message\r
102  " otherwise go to next message\r
103 -" any message that is viewed entirely has inbox and unread tags removed\r
104 -function! s:NM_show_advance_marking_read_and_archiving()\r
105 -        let advance_tags = ['unread', 'inbox']\r
106 -\r
107 +" any message that is viewed entirely has g:notmuch_advance_add_tags added and\r
108 +" g:notmuch_advance_remove_tags removed\r
109 +function! s:NM_show_advance_and_tag()\r
110 +        let remove_tags = copy(g:notmuch_advance_remove_tags)\r
111 +        let add_tags = copy(g:notmuch_advance_add_tags)\r
112          let vis_top = line('w0')\r
113          let vis_bot = line('w$')\r
114  \r
115 @@ -585,6 +594,11 @@ function! s:NM_show_advance_marking_read_and_archiving()\r
116                  throw "No top visible message."\r
117          endif\r
118  \r
119 +        let remove_tags_formatted = copy(remove_tags)\r
120 +        call map(remove_tags_formatted, '"-" . v:val')\r
121 +        let add_tags_formatted = copy(add_tags)\r
122 +        call map(add_tags_formatted, '"+" . v:val')\r
123 +\r
124          " if the top message is the last message, just expunge the entire thread and move on\r
125          if msg_top['end'] == line('$')\r
126                  let ids = []\r
127 @@ -593,11 +607,14 @@ function! s:NM_show_advance_marking_read_and_archiving()\r
128                                  call add(ids, msg['id'])\r
129                          endif\r
130                  endfor\r
131 -                let filter = <SID>NM_combine_tags('tag:', advance_tags, 'OR', '()')\r
132 +                let filter = <SID>NM_combine_tags('tag:', remove_tags, 'OR', '()')\r
133                           \ + ['AND']\r
134                           \ + <SID>NM_combine_tags('', ids, 'OR', '()')\r
135 -                call map(advance_tags, '"-" . v:val')\r
136 -                call <SID>NM_tag(filter, advance_tags)\r
137 +                call <SID>NM_tag(filter, remove_tags_formatted)\r
138 +                let filter = <SID>NM_combine_tags('not tag:', add_tags, 'OR', '()')\r
139 +                         \ + ['AND']\r
140 +                         \ + <SID>NM_combine_tags('', ids, 'OR', '()')\r
141 +                call <SID>NM_tag(filter, add_tags_formatted)\r
142                  call <SID>NM_show_next(1, 1)\r
143                  return\r
144          endif\r
145 @@ -614,10 +631,12 @@ function! s:NM_show_advance_marking_read_and_archiving()\r
146                  if has_key(msg_top,'match') && msg_top['match'] != '0'\r
147                          redraw\r
148                          " do this last to hide the latency\r
149 -                        let filter = <SID>NM_combine_tags('tag:', advance_tags, 'OR', '()')\r
150 +                        let filter = <SID>NM_combine_tags('tag:', remove_tags, 'OR', '()')\r
151 +                                 \ + ['AND', msg_top['id']]\r
152 +                        call <SID>NM_tag(filter, remove_tags_formatted)\r
153 +                        let filter = <SID>NM_combine_tags('not tag:', add_tags, 'OR', '()')\r
154                                   \ + ['AND', msg_top['id']]\r
155 -                        call map(advance_tags, '"-" . v:val')\r
156 -                        call <SID>NM_tag(filter, advance_tags)\r
157 +                        call <SID>NM_tag(filter, add_tags_formatted)\r
158                  endif\r
159                  return\r
160          endif\r
161 @@ -1375,6 +1394,12 @@ endif\r
162  if !exists('g:notmuch_compose_headers')\r
163          let g:notmuch_compose_headers = s:notmuch_compose_headers_defaults\r
164  endif\r
165 +if !exists('g:notmuch_advance_remove_tags')\r
166 +        let g:notmuch_advance_remove_tags = s:notmuch_advance_remove_tags\r
167 +endif\r
168 +if !exists('g:notmuch_advance_add_tags')\r
169 +        let g:notmuch_advance_add_tags = s:notmuch_advance_add_tags\r
170 +endif\r
171  \r
172  " --- assign keymaps {{{1\r
173  \r
174 -- \r
175 1.7.4.1\r
176 \r