From: Ian Main Date: Mon, 20 Oct 2014 18:01:51 +0000 (+1700) Subject: [PATCH v3] VIM: Improve moving between messages in a thread X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=46ae85251740b982a5a5f13270838c64596fc361;p=notmuch-archives.git [PATCH v3] VIM: Improve moving between messages in a thread --- diff --git a/9b/f08ca94b626027ec1d44958765c9ea21ebee49 b/9b/f08ca94b626027ec1d44958765c9ea21ebee49 new file mode 100644 index 000000000..49b75fa1f --- /dev/null +++ b/9b/f08ca94b626027ec1d44958765c9ea21ebee49 @@ -0,0 +1,112 @@ +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 2F9DC431FAF + for ; Mon, 20 Oct 2014 11:02:02 -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 cpEVfOfZ-+g8 for ; + Mon, 20 Oct 2014 11:01:56 -0700 (PDT) +Received: from cmta12.telus.net (cmta12.telus.net [209.171.16.85]) + by olra.theworths.org (Postfix) with ESMTP id 977C9431FAE + for ; Mon, 20 Oct 2014 11:01:56 -0700 (PDT) +Received: from ovo.mains.priv ([207.102.88.62]) by cmta12.telus.net with TELUS + id 5W1u1p00l1LiWEf01W1udJ; Mon, 20 Oct 2014 12:01:56 -0600 +X-Authority-Analysis: v=2.0 cv=f5eW8pOM c=1 sm=2 + a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8 + a=Ev2wUXwO5xFQ6vl1vPYA:9 a=EcQDfIwDZEqJA1f7rVUV8Q==:117 +X-Telus-Outbound-IP: 207.102.88.62 +From: Ian Main +To: notmuch@notmuchmail.org +Subject: [PATCH v3] VIM: Improve moving between messages in a thread +Date: Mon, 20 Oct 2014 11:01:51 -0700 +Message-Id: <1413828111-2879-1-git-send-email-imain@stemwinder.org> +X-Mailer: git-send-email 1.9.3 +In-Reply-To: <1412618116-27586-1-git-send-email-imain@stemwinder.org> +References: <1412618116-27586-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, 20 Oct 2014 18:02:02 -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 +--- + +Remove spurious vim_puts. + + vim/notmuch.vim | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +diff --git a/vim/notmuch.vim b/vim/notmuch.vim +index 331e930..bd007b1 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,21 @@ 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 ++ 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 +137,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 +