Monday, October 31, 2011

Re: detect QuickFix window list or LocationList

Thanks to upper two guys hints. empty(getloclist(0)) is more simple.

Andy Wokula, which one is for QuickFix like getloclist(0), I can not find it even I use many times
Tab.

=> On [2011-10-31 13:50:49 +0100]:
Andy Wokula Said:
> Am 31.10.2011 12:14, schrieb stardiviner:
> >I want to bind key Alt-n/p to next/previous LocationList or next/previous QuickFix list.
> >So I need to detect which List in current buffer. then bind Alt-n/p to them.
> >like this.
> > if (detect Location or QuickFix)
> > map<A-n> :cnext<CR>
> > map<A-n> :cprevious<CR>
> > elseif
> > map<A-n> :lnext<CR>
> > map<A-n> :lprevious<CR>
> > endif
>
> You could check for
> empty(getloclist(0))
>
>
> " Second approach: always do :lnext and if that fails, try :cnext
>
> nnoremap <A-n> :NextError<CR>
> nnoremap <A-p> :PrevError<CR>
>
> com! -bar NextError call s:GoForError("next")
> com! -bar PrevError call s:GoForError("previous")
>
> func! s:GoForError(partcmd)
> try
> try
> exec "l". a:partcmd
> catch /:E776:/
> " No location list
> exec "c". a:partcmd
> endtry
> catch
> echohl ErrorMsg
> echomsg matchstr(v:exception, ':\zs.*')
> echohl None
> endtry
> endfunc
>
> --
> Andy
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

--
stardiviner GPG: 5D9F64D8 Twitter: @numbchild
http://stardiviner.dyndns-blog.com/author.html

No comments: