[PATCH] Improve moving between messages in a thread
authorIan Main <imain@stemwinder.org>
Mon, 6 Oct 2014 07:12:17 +0000 (00:12 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:04 +0000 (10:05 -0800)
d0/1fb0929149c019aa239dd73da0ac1dac6f2803 [new file with mode: 0644]

diff --git a/d0/1fb0929149c019aa239dd73da0ac1dac6f2803 b/d0/1fb0929149c019aa239dd73da0ac1dac6f2803
new file mode 100644 (file)
index 0000000..0207bec
--- /dev/null
@@ -0,0 +1,110 @@
+Return-Path: <imain@stemwinder.org>\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 1845B431FB6\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Oct 2014 00:12:31 -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 RoBf3Vig8n3G for <notmuch@notmuchmail.org>;\r
+       Mon,  6 Oct 2014 00:12:27 -0700 (PDT)\r
+Received: from cmta2.telus.net (cmta2.telus.net [209.171.16.75])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5E7CF431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Oct 2014 00:12:27 -0700 (PDT)\r
+Received: from ovo.mains.priv ([207.102.88.62]) by cmta2.telus.net with TELUS\r
+       id zjCR1o00G1LiWEf01jCRqh; Mon, 06 Oct 2014 01:12:26 -0600\r
+X-Authority-Analysis: v=2.0 cv=ErcMW1gA c=1 sm=2\r
+       a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8\r
+       a=luRVYIaq7LDw4LXNCHgA:9 a=EcQDfIwDZEqJA1f7rVUV8Q==:117\r
+X-Telus-Outbound-IP: 207.102.88.62\r
+From: Ian Main <imain@stemwinder.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] Improve moving between messages in a thread\r
+Date: Mon,  6 Oct 2014 00:12:17 -0700\r
+Message-Id: <1412579537-7921-1-git-send-email-imain@stemwinder.org>\r
+X-Mailer: git-send-email 1.9.3\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: Mon, 06 Oct 2014 07:12:31 -0000\r
+\r
+This patch adds a few changes to moving between threads:\r
+\r
+- It supports 'scrolloff' so that if you have this set it will move the\r
+  buffer and cursor so the next/prev email starts at the top of the\r
+  screen.\r
+- It adds the ability to use shift-tab to go to the previous msg in\r
+  the thread.\r
+\r
+    Ian\r
+---\r
+ vim/notmuch.vim | 24 ++++++++++++++++++++++--\r
+ 1 file changed, 22 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+index 331e930..95e5c4b 100644\r
+--- a/vim/notmuch.vim\r
++++ b/vim/notmuch.vim\r
+@@ -39,6 +39,7 @@ let g:notmuch_show_maps = {\r
+       \ 'p':          'show_save_patches()',\r
+       \ 'r':          'show_reply()',\r
+       \ '?':          'show_info()',\r
++      \ '<S-Tab>':    'show_prev_msg()',\r
+       \ '<Tab>':      'show_next_msg()',\r
+       \ 'c':          'compose()',\r
+       \ }\r
+@@ -113,6 +114,23 @@ EOF\r
+       call s:kill_this_buffer()\r
+ endfunction\r
\r
++function! s:show_prev_msg()\r
++ruby << EOF\r
++      r, c = $curwin.cursor\r
++      n = $curbuf.line_number\r
++      i = $messages.index { |m| n >= m.start && n <= m.end }\r
++      m = $messages[i - 1] if i > 0\r
++      vim_puts ("messages index is #{i} and m is #{m}")\r
++      if m\r
++              r = m.body_start + 1\r
++              scrolloff = VIM::evaluate("&scrolloff")\r
++              VIM::command("normal #{m.start + scrolloff}zt")\r
++              $curwin.cursor = r + scrolloff, c\r
++              vim_puts("moving to #{m.start + scrolloff}")\r
++      end\r
++EOF\r
++endfunction\r
++\r
+ function! s:show_next_msg()\r
+ ruby << EOF\r
+       r, c = $curwin.cursor\r
+@@ -121,8 +139,10 @@ ruby << EOF\r
+       m = $messages[i + 1]\r
+       if m\r
+               r = m.body_start + 1\r
+-              VIM::command("normal #{m.start}zt")\r
+-              $curwin.cursor = r, c\r
++              scrolloff = VIM::evaluate("&scrolloff")\r
++              VIM::command("normal #{m.start + scrolloff}zt")\r
++              $curwin.cursor = r + scrolloff, c\r
++              vim_puts("moving to #{m.start + scrolloff}")\r
+       end\r
+ EOF\r
+ endfunction\r
+-- \r
+1.9.3\r
+\r