[PATCH] vim plugin: allow customizing of current read+archive+advance behavior
authorMichael Roth <mdroth@linux.vnet.ibm.com>
Sat, 24 Sep 2011 00:46:40 +0000 (19:46 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:28 +0000 (09:39 -0800)
50/360f20f9a2e519f021c5d58b5d129e5d5e8379 [new file with mode: 0644]

diff --git a/50/360f20f9a2e519f021c5d58b5d129e5d5e8379 b/50/360f20f9a2e519f021c5d58b5d129e5d5e8379
new file mode 100644 (file)
index 0000000..7245f05
--- /dev/null
@@ -0,0 +1,176 @@
+Return-Path: <mdroth@linux.vnet.ibm.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1EA8D431FD0\r
+       for <notmuch@notmuchmail.org>; Fri, 23 Sep 2011 17:46:54 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id z9qw7pK8MSuL for <notmuch@notmuchmail.org>;\r
+       Fri, 23 Sep 2011 17:46:52 -0700 (PDT)\r
+Received: from mout.perfora.net (mout.perfora.net [74.208.4.194])\r
+       by olra.theworths.org (Postfix) with ESMTP id D1644431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 23 Sep 2011 17:46:52 -0700 (PDT)\r
+Received: from illuin.austin.ibm.com ([32.97.110.59])\r
+       by mrelay.perfora.net (node=mrus2) with ESMTP (Nemesis)\r
+       id 0Mclzd-1QpSWZ39wf-00HiY1; Fri, 23 Sep 2011 20:46:51 -0400\r
+From: Michael Roth <mdroth@linux.vnet.ibm.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] vim plugin: allow customizing of current read+archive+advance\r
+       behavior\r
+Date: Fri, 23 Sep 2011 19:46:40 -0500\r
+Message-Id: <1316825200-15711-1-git-send-email-mdroth@linux.vnet.ibm.com>\r
+X-Mailer: git-send-email 1.7.4.1\r
+X-Provags-ID: V02:K0:OH16NLnnZKYuQYCguu5kehl83Ent3EOEsJgRnR42irT\r
+       d7A5D95zpwEJLQe5Fm7a8XUbjy53/OWfsbt+ZhuV2i8g2lHrlA\r
+       zHJ2wvltPaWid19Bm7l88pR5LEwBbz3XHSNbO8t1+8+esbnwEI\r
+       1tK00Xj306QFyinCQgmjYaNaoVAMz3at57/ETsWb/CtvPqvqXa\r
+       AsD7gywdlFV+wWPtw2Lnr92P+fI1f87ATz5lFjSr4d+eSym9jP\r
+       62EKQfVkkCPUPRchZuGSRRIh/SqO2R74BvPtkVeMQPDkCTz6wm\r
+       +q25lYeUnVc1ZQVsjuuMbO5OXES5Q41aZryQ7UXfHZ4p2W+8ET\r
+       WLDr9+TJDhZ2+dUEX3pI6WfGH7rVpjgDjaNpMYZnV+cXgDuGNV\r
+       UpJ4YbiEzvI51Gt0nDYT05HCr1mURQXvEc=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 24 Sep 2011 00:46:54 -0000\r
+\r
+Currently if you navigate through an entire thread using <space> it will\r
+automatically have it's 'unread' and 'inbox' tags removed.\r
+\r
+For many userss archiving is limited to threads that are old and unlikely\r
+to be referenced again rather than threads that you've simply read or\r
+glanced through recently, particularly users like me with poor\r
+long-term memory.\r
+\r
+This patch adds g:notmuch_advance_add_tags and\r
+g:notmuch_advance_remove_tags settings to customize this behavior while\r
+also adding the option to have tags added to threads that have been read\r
+in their entirety.\r
+\r
+Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>\r
+---\r
+ vim/plugin/notmuch.vim |   47 ++++++++++++++++++++++++++++++++++++-----------\r
+ 1 files changed, 36 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim\r
+index 21985c7..5bcd262 100644\r
+--- a/vim/plugin/notmuch.vim\r
++++ b/vim/plugin/notmuch.vim\r
+@@ -103,6 +103,14 @@ let s:notmuch_compose_headers_defaults = [\r
+         \ 'Subject'\r
+         \ ]\r
\r
++" defaults for g:notmuch_advance_remove_tags\r
++" override with: let g:notmuch_advance_remove_tags = [ ... ]\r
++let s:notmuch_advance_remove_tags = [ 'unread', 'inbox' ]\r
++\r
++" defaults for g:notmuch_advance_add_tags\r
++" override with: let g:notmuch_advance_add_tags = [ ... ]\r
++let s:notmuch_advance_add_tags = [ ]\r
++\r
+ " --- keyboard mapping definitions {{{1\r
\r
+ " --- --- bindings for folders mode {{{2\r
+@@ -160,7 +168,7 @@ let g:notmuch_show_maps = {\r
+         \ 'v':          ':call <SID>NM_show_view_all_mime_parts()<CR>',\r
+         \ '+':          ':call <SID>NM_show_add_tag()<CR>',\r
+         \ '-':          ':call <SID>NM_show_remove_tag()<CR>',\r
+-        \ '<Space>':    ':call <SID>NM_show_advance_marking_read_and_archiving()<CR>',\r
++        \ '<Space>':    ':call <SID>NM_show_advance_and_tag()<CR>',\r
+         \ '\|':         ':call <SID>NM_show_pipe_message()<CR>',\r
+         \\r
+         \ '<S-Tab>':    ':call <SID>NM_show_previous_fold()<CR>',\r
+@@ -573,10 +581,11 @@ endfunction\r
\r
+ " if entire message is not visible scroll down 1/2 page or less to get to the bottom of message\r
+ " otherwise go to next message\r
+-" any message that is viewed entirely has inbox and unread tags removed\r
+-function! s:NM_show_advance_marking_read_and_archiving()\r
+-        let advance_tags = ['unread', 'inbox']\r
+-\r
++" any message that is viewed entirely has g:notmuch_advance_add_tags added and\r
++" g:notmuch_advance_remove_tags removed\r
++function! s:NM_show_advance_and_tag()\r
++        let remove_tags = copy(g:notmuch_advance_remove_tags)\r
++        let add_tags = copy(g:notmuch_advance_add_tags)\r
+         let vis_top = line('w0')\r
+         let vis_bot = line('w$')\r
\r
+@@ -585,6 +594,11 @@ function! s:NM_show_advance_marking_read_and_archiving()\r
+                 throw "No top visible message."\r
+         endif\r
\r
++        let remove_tags_formatted = copy(remove_tags)\r
++        call map(remove_tags_formatted, '"-" . v:val')\r
++        let add_tags_formatted = copy(add_tags)\r
++        call map(add_tags_formatted, '"+" . v:val')\r
++\r
+         " if the top message is the last message, just expunge the entire thread and move on\r
+         if msg_top['end'] == line('$')\r
+                 let ids = []\r
+@@ -593,11 +607,14 @@ function! s:NM_show_advance_marking_read_and_archiving()\r
+                                 call add(ids, msg['id'])\r
+                         endif\r
+                 endfor\r
+-                let filter = <SID>NM_combine_tags('tag:', advance_tags, 'OR', '()')\r
++                let filter = <SID>NM_combine_tags('tag:', remove_tags, 'OR', '()')\r
+                          \ + ['AND']\r
+                          \ + <SID>NM_combine_tags('', ids, 'OR', '()')\r
+-                call map(advance_tags, '"-" . v:val')\r
+-                call <SID>NM_tag(filter, advance_tags)\r
++                call <SID>NM_tag(filter, remove_tags_formatted)\r
++                let filter = <SID>NM_combine_tags('not tag:', add_tags, 'OR', '()')\r
++                         \ + ['AND']\r
++                         \ + <SID>NM_combine_tags('', ids, 'OR', '()')\r
++                call <SID>NM_tag(filter, add_tags_formatted)\r
+                 call <SID>NM_show_next(1, 1)\r
+                 return\r
+         endif\r
+@@ -614,10 +631,12 @@ function! s:NM_show_advance_marking_read_and_archiving()\r
+                 if has_key(msg_top,'match') && msg_top['match'] != '0'\r
+                         redraw\r
+                         " do this last to hide the latency\r
+-                        let filter = <SID>NM_combine_tags('tag:', advance_tags, 'OR', '()')\r
++                        let filter = <SID>NM_combine_tags('tag:', remove_tags, 'OR', '()')\r
++                                 \ + ['AND', msg_top['id']]\r
++                        call <SID>NM_tag(filter, remove_tags_formatted)\r
++                        let filter = <SID>NM_combine_tags('not tag:', add_tags, 'OR', '()')\r
+                                  \ + ['AND', msg_top['id']]\r
+-                        call map(advance_tags, '"-" . v:val')\r
+-                        call <SID>NM_tag(filter, advance_tags)\r
++                        call <SID>NM_tag(filter, add_tags_formatted)\r
+                 endif\r
+                 return\r
+         endif\r
+@@ -1375,6 +1394,12 @@ endif\r
+ if !exists('g:notmuch_compose_headers')\r
+         let g:notmuch_compose_headers = s:notmuch_compose_headers_defaults\r
+ endif\r
++if !exists('g:notmuch_advance_remove_tags')\r
++        let g:notmuch_advance_remove_tags = s:notmuch_advance_remove_tags\r
++endif\r
++if !exists('g:notmuch_advance_add_tags')\r
++        let g:notmuch_advance_add_tags = s:notmuch_advance_add_tags\r
++endif\r
\r
+ " --- assign keymaps {{{1\r
\r
+-- \r
+1.7.4.1\r
+\r