From 0210f960f10db27ea2556d61340bca24302baf56 Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Sun, 22 Nov 2009 00:29:57 -0500 Subject: [PATCH] vim: have ? show details of what's under cursor in search/show views --- vim/README | 2 ++ vim/plugin/notmuch.vim | 36 ++++++++++++++++++++++++++++++++---- 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 NM_search_add_tags([])', \ '-': ':call NM_search_remove_tags([])', \ '=': ':call NM_search_refresh_view()', + \ '?': ':echo NM_search_thread_id()', \ } " --- --- bindings for show screen {{{2 @@ -129,6 +130,7 @@ let g:notmuch_show_maps = { \ \ 'r': ':call NM_show_reply()', \ 'm': ':call NM_new_mail()', + \ '?': ':echo NM_show_thread_id() . '' '' . NM_show_message_id()', \ } @@ -226,7 +228,7 @@ endfunction " --- --- search screen action functions {{{2 function! s:NM_search_show_thread() - let id = NM_search_find_thread_id() + let id = NM_search_thread_id() if id != '' call 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 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 = NM_search_find_thread_id() + let id = NM_search_thread_id() if id == '' echoe 'Eeek! I couldn''t find the thead id!' endif -- 2.26.2