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