aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim
diff options
context:
space:
mode:
authorGravatar Bart Trojanowski <bart@jukie.net>2009-11-22 00:29:57 -0500
committerGravatar Bart Trojanowski <bart@jukie.net>2009-11-25 00:48:54 -0500
commit0210f960f10db27ea2556d61340bca24302baf56 (patch)
treefbd4ccf614a624cdfdf8cd8ee7f6beb107d2a4dc /vim
parent251ec73587e92f386c9d24bc781bad38a70e3afb (diff)
vim: have ? show details of what's under cursor in search/show views
Diffstat (limited to 'vim')
-rw-r--r--vim/README2
-rw-r--r--vim/plugin/notmuch.vim36
2 files changed, 34 insertions, 4 deletions
diff --git a/vim/README b/vim/README
index 91fc7a34..ff0828ff 100644
--- a/vim/README
+++ b/vim/README
@@ -36,6 +36,7 @@ Buffer types:
+ - add tag(s) to selected message
- - remove tag(s) from selected message
= - refresh display
+ ? - reveal the thread ID of what's under cursor
^] - search using word under cursor
[notmuch-show]
@@ -49,5 +50,6 @@ Buffer types:
h - toggle folding of extra header lines
s - toggle folding of signatures
q - return to search display
+ ? - reveal the message and thread IDs of what's under cursor
^] - search using word under cursor
diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 15252d2d..e13ea9f7 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -104,6 +104,7 @@ let g:notmuch_search_maps = {
\ '+': ':call <SID>NM_search_add_tags([])<CR>',
\ '-': ':call <SID>NM_search_remove_tags([])<CR>',
\ '=': ':call <SID>NM_search_refresh_view()<CR>',
+ \ '?': ':echo <SID>NM_search_thread_id()<CR>',
\ }
" --- --- bindings for show screen {{{2
@@ -129,6 +130,7 @@ let g:notmuch_show_maps = {
\
\ 'r': ':call <SID>NM_show_reply()<CR>',
\ 'm': ':call <SID>NM_new_mail()<CR>',
+ \ '?': ':echo <SID>NM_show_thread_id() . '' '' . <SID>NM_show_message_id()<CR>',
\ }
@@ -226,7 +228,7 @@ endfunction
" --- --- search screen action functions {{{2
function! s:NM_search_show_thread()
- let id = <SID>NM_search_find_thread_id()
+ let id = <SID>NM_search_thread_id()
if id != ''
call <SID>NM_cmd_show([id])
endif
@@ -324,7 +326,7 @@ endfunction
" --- --- search screen helper functions {{{2
-function! s:NM_search_find_thread_id()
+function! s:NM_search_thread_id()
if !exists('b:nm_raw_lines')
echoe 'no b:nm_raw_lines'
return ''
@@ -363,6 +365,7 @@ function! s:NM_cmd_show(words)
setlocal bufhidden=hide
call <SID>NM_newBuffer('show', join(info['disp'], "\n"))
setlocal bufhidden=delete
+ let b:nm_words = a:words
let b:nm_raw_info = info
let b:nm_prev_bufnr = prev_bufnr
@@ -475,7 +478,32 @@ function! s:NM_show_pipe_message()
echo 'not implemented'
endfunction
-" --- --- search screen helper functions {{{2
+" --- --- show screen helper functions {{{2
+
+function! s:NM_show_thread_id()
+ if !exists('b:nm_words')
+ echoe 'no b:nm_words'
+ return ''
+ endif
+ return b:nm_words[0]
+endfunction
+
+function! s:NM_show_message_id()
+ if !exists('b:nm_raw_info')
+ echoe 'no b:nm_raw_info'
+ return ''
+ endif
+ let info = b:nm_raw_info
+ let lnum = line('.')
+ for msg in info['msgs']
+ if lnum < msg['start']
+ continue
+ endif
+
+ return msg['id']
+ endfor
+ return ''
+endfunction
function! s:NM_show_fold_toggle(key, type, fold)
let info = b:nm_raw_info
@@ -766,7 +794,7 @@ function! s:NM_search_expand(arg)
endfunction
function! s:NM_add_remove_tags(prefix, tags)
- let id = <SID>NM_search_find_thread_id()
+ let id = <SID>NM_search_thread_id()
if id == ''
echoe 'Eeek! I couldn''t find the thead id!'
endif