Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d0 / 1fb0929149c019aa239dd73da0ac1dac6f2803
1 Return-Path: <imain@stemwinder.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 1845B431FB6\r
6         for <notmuch@notmuchmail.org>; Mon,  6 Oct 2014 00:12:31 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id RoBf3Vig8n3G for <notmuch@notmuchmail.org>;\r
16         Mon,  6 Oct 2014 00:12:27 -0700 (PDT)\r
17 Received: from cmta2.telus.net (cmta2.telus.net [209.171.16.75])\r
18         by olra.theworths.org (Postfix) with ESMTP id 5E7CF431FAE\r
19         for <notmuch@notmuchmail.org>; Mon,  6 Oct 2014 00:12:27 -0700 (PDT)\r
20 Received: from ovo.mains.priv ([207.102.88.62]) by cmta2.telus.net with TELUS\r
21         id zjCR1o00G1LiWEf01jCRqh; Mon, 06 Oct 2014 01:12:26 -0600\r
22 X-Authority-Analysis: v=2.0 cv=ErcMW1gA c=1 sm=2\r
23         a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=tsa3CZZnAAAA:8\r
24         a=luRVYIaq7LDw4LXNCHgA:9 a=EcQDfIwDZEqJA1f7rVUV8Q==:117\r
25 X-Telus-Outbound-IP: 207.102.88.62\r
26 From: Ian Main <imain@stemwinder.org>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [PATCH] Improve moving between messages in a thread\r
29 Date: Mon,  6 Oct 2014 00:12:17 -0700\r
30 Message-Id: <1412579537-7921-1-git-send-email-imain@stemwinder.org>\r
31 X-Mailer: git-send-email 1.9.3\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Mon, 06 Oct 2014 07:12:31 -0000\r
45 \r
46 This patch adds a few changes to moving between threads:\r
47 \r
48 - It supports 'scrolloff' so that if you have this set it will move the\r
49   buffer and cursor so the next/prev email starts at the top of the\r
50   screen.\r
51 - It adds the ability to use shift-tab to go to the previous msg in\r
52   the thread.\r
53 \r
54     Ian\r
55 ---\r
56  vim/notmuch.vim | 24 ++++++++++++++++++++++--\r
57  1 file changed, 22 insertions(+), 2 deletions(-)\r
58 \r
59 diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
60 index 331e930..95e5c4b 100644\r
61 --- a/vim/notmuch.vim\r
62 +++ b/vim/notmuch.vim\r
63 @@ -39,6 +39,7 @@ let g:notmuch_show_maps = {\r
64         \ 'p':          'show_save_patches()',\r
65         \ 'r':          'show_reply()',\r
66         \ '?':          'show_info()',\r
67 +       \ '<S-Tab>':    'show_prev_msg()',\r
68         \ '<Tab>':      'show_next_msg()',\r
69         \ 'c':          'compose()',\r
70         \ }\r
71 @@ -113,6 +114,23 @@ EOF\r
72         call s:kill_this_buffer()\r
73  endfunction\r
74  \r
75 +function! s:show_prev_msg()\r
76 +ruby << EOF\r
77 +       r, c = $curwin.cursor\r
78 +       n = $curbuf.line_number\r
79 +       i = $messages.index { |m| n >= m.start && n <= m.end }\r
80 +       m = $messages[i - 1] if i > 0\r
81 +       vim_puts ("messages index is #{i} and m is #{m}")\r
82 +       if m\r
83 +               r = m.body_start + 1\r
84 +               scrolloff = VIM::evaluate("&scrolloff")\r
85 +               VIM::command("normal #{m.start + scrolloff}zt")\r
86 +               $curwin.cursor = r + scrolloff, c\r
87 +               vim_puts("moving to #{m.start + scrolloff}")\r
88 +       end\r
89 +EOF\r
90 +endfunction\r
91 +\r
92  function! s:show_next_msg()\r
93  ruby << EOF\r
94         r, c = $curwin.cursor\r
95 @@ -121,8 +139,10 @@ ruby << EOF\r
96         m = $messages[i + 1]\r
97         if m\r
98                 r = m.body_start + 1\r
99 -               VIM::command("normal #{m.start}zt")\r
100 -               $curwin.cursor = r, c\r
101 +               scrolloff = VIM::evaluate("&scrolloff")\r
102 +               VIM::command("normal #{m.start + scrolloff}zt")\r
103 +               $curwin.cursor = r + scrolloff, c\r
104 +               vim_puts("moving to #{m.start + scrolloff}")\r
105         end\r
106  EOF\r
107  endfunction\r
108 -- \r
109 1.9.3\r
110 \r