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 A7666431FB6 for ; Mon, 6 Oct 2014 10:55:29 -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 RpeyiyoK+nQI for ; Mon, 6 Oct 2014 10:55:24 -0700 (PDT) Received: from cmta13.telus.net (cmta13.telus.net [209.171.16.86]) by olra.theworths.org (Postfix) with ESMTP id 17959431FAE for ; Mon, 6 Oct 2014 10:55:24 -0700 (PDT) Received: from ovo.mains.priv ([207.102.88.62]) by cmta13.telus.net with TELUS id ztvP1o0071LiWEf01tvP9v; Mon, 06 Oct 2014 11:55:23 -0600 X-Authority-Analysis: v=2.0 cv=OrmRPVDt c=1 sm=2 a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8 a=S3gQTLpqa8hfpVGigeQA:9 a=EcQDfIwDZEqJA1f7rVUV8Q==:117 X-Telus-Outbound-IP: 207.102.88.62 From: Ian Main To: notmuch@notmuchmail.org Subject: [PATCH] VIM: Improve moving between messages in a thread Date: Mon, 6 Oct 2014 10:55:16 -0700 Message-Id: <1412618116-27586-1-git-send-email-imain@stemwinder.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1412579537-7921-1-git-send-email-imain@stemwinder.org> References: <1412579537-7921-1-git-send-email-imain@stemwinder.org> 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: Mon, 06 Oct 2014 17:55:29 -0000 Add a few changes to moving between threads: - It supports 'scrolloff' so that if you have this set it will move the buffer and cursor so the next/prev email starts at the top of the screen. - It adds the ability to use shift-tab to go to the previous msg in the thread. Ian --- This update fixes the commit message and removes vim_puts debugging. vim/notmuch.vim | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 331e930..2124a8e 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -39,6 +39,7 @@ let g:notmuch_show_maps = { \ 'p': 'show_save_patches()', \ 'r': 'show_reply()', \ '?': 'show_info()', + \ '': 'show_prev_msg()', \ '': 'show_next_msg()', \ 'c': 'compose()', \ } @@ -113,6 +114,22 @@ EOF call s:kill_this_buffer() endfunction +function! s:show_prev_msg() +ruby << EOF + r, c = $curwin.cursor + n = $curbuf.line_number + i = $messages.index { |m| n >= m.start && n <= m.end } + m = $messages[i - 1] if i > 0 + vim_puts ("messages index is #{i} and m is #{m}") + if m + r = m.body_start + 1 + scrolloff = VIM::evaluate("&scrolloff") + VIM::command("normal #{m.start + scrolloff}zt") + $curwin.cursor = r + scrolloff, c + end +EOF +endfunction + function! s:show_next_msg() ruby << EOF r, c = $curwin.cursor @@ -121,8 +138,9 @@ ruby << EOF m = $messages[i + 1] if m r = m.body_start + 1 - VIM::command("normal #{m.start}zt") - $curwin.cursor = r, c + scrolloff = VIM::evaluate("&scrolloff") + VIM::command("normal #{m.start + scrolloff}zt") + $curwin.cursor = r + scrolloff, c end EOF endfunction -- 1.9.3