[PATCH] Improve moving between messages in a thread

2014-10-06 Thread Ian Main
Ian Main wrote:
> This patch adds 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
> ---
>  vim/notmuch.vim | 24 ++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 331e930..95e5c4b 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,23 @@ 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("")
> + VIM::command("normal #{m.start + scrolloff}zt")
> + $curwin.cursor = r + scrolloff, c
> + vim_puts("moving to #{m.start + scrolloff}")

Woops, forgot to remove the vim_puts debugging.

Ian


[PATCH] Improve moving between messages in a thread

2014-10-06 Thread Ian Main
This patch adds 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
---
 vim/notmuch.vim | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..95e5c4b 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,23 @@ 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("")
+   VIM::command("normal #{m.start + scrolloff}zt")
+   $curwin.cursor = r + scrolloff, c
+   vim_puts("moving to #{m.start + scrolloff}")
+   end
+EOF
+endfunction
+
 function! s:show_next_msg()
 ruby << EOF
r, c = $curwin.cursor
@@ -121,8 +139,10 @@ 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("")
+   VIM::command("normal #{m.start + scrolloff}zt")
+   $curwin.cursor = r + scrolloff, c
+   vim_puts("moving to #{m.start + scrolloff}")
end
 EOF
 endfunction
-- 
1.9.3



[PATCH] Improve moving between messages in a thread

2014-10-06 Thread Ian Main
This patch adds 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
---
 vim/notmuch.vim | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..95e5c4b 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()',
+   \ 'S-Tab':'show_prev_msg()',
\ 'Tab':  'show_next_msg()',
\ 'c':  'compose()',
\ }
@@ -113,6 +114,23 @@ 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
+   vim_puts(moving to #{m.start + scrolloff})
+   end
+EOF
+endfunction
+
 function! s:show_next_msg()
 ruby  EOF
r, c = $curwin.cursor
@@ -121,8 +139,10 @@ 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
+   vim_puts(moving to #{m.start + scrolloff})
end
 EOF
 endfunction
-- 
1.9.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


RE: [PATCH] Improve moving between messages in a thread

2014-10-06 Thread Ian Main
Ian Main wrote:
 This patch adds 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
 ---
  vim/notmuch.vim | 24 ++--
  1 file changed, 22 insertions(+), 2 deletions(-)
 
 diff --git a/vim/notmuch.vim b/vim/notmuch.vim
 index 331e930..95e5c4b 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()',
 + \ 'S-Tab':'show_prev_msg()',
   \ 'Tab':  'show_next_msg()',
   \ 'c':  'compose()',
   \ }
 @@ -113,6 +114,23 @@ 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
 + vim_puts(moving to #{m.start + scrolloff})

Woops, forgot to remove the vim_puts debugging.

Ian
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch