Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

autodetect toggling key in qbuf

  • Loading branch information...
commit 3809f241a985fd7e668a2a2157b713b7ed1285ac 1 parent bf59a5c
@ap authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 plugin/vimscripts/qbuf.vim
View
14 plugin/vimscripts/qbuf.vim
@@ -15,10 +15,23 @@ function s:run()
let l:cmdheight = &cmdheight
+ let l:toggle = ''
let l:bang = ''
let l:cursel = -1
let l:refresh = 1
+ " figure out what key the user has mapped this to
+ if hasmapto(':QBuf<CR>', 'n')
+ redir => l:nmap
+ silent nmap
+ redir END
+ let l:mappings = split(l:nmap, "\n")
+ let l:line = l:mappings[match(l:mappings, ':QBuf\>')]
+ let l:key = matchstr(l:line[3:], '[^ ]\+')
+ let l:toggle = eval('"'.escape(l:key, '"<').'"')
+ unlet l:nmap
+ endif
+
try | while 1
" SCAN ===============================================================
@@ -130,6 +143,7 @@ function s:run()
if l:key == "\<Up>" | let l:key = 'k'
elseif l:key == "\<Down>" | let l:key = 'j'
elseif l:key == "\<Esc>" | let l:key = 'q'
+ elseif l:key == l:toggle | let l:key = 'q'
end
let l:selbuf = l:buffers[l:cursel]['num']
Please sign in to comment.
Something went wrong with that request. Please try again.