cscope quickfix scan

109 views
Skip to first unread message

sinbad

unread,
May 9, 2011, 6:43:38 AM5/9/11
to vim_use
i am using cscope quickfix. from the quickfix
results i want to browse thru the entries whose
filename or file path matches a specific pattern.
how can i achieve this.

thanks

sinbad

unread,
May 10, 2011, 12:26:41 AM5/10/11
to vim_use
any thoughts ?

Gary Johnson

unread,
May 10, 2011, 1:30:40 AM5/10/11
to vim_use
On 2011-05-09, sinbad wrote:

> On May 9, 3:43�pm, sinbad wrote:
> > i am using cscope quickfix. from the quickfix
> > results i want to browse thru the entries whose
> > filename or file path matches a specific pattern.
> > how can i achieve this.

Doing that requires editing the quickfix list. Refer to the thread
you started April 27, "quickfix window's manual fix", for possible
solutions.

The only other way I can think of to do this is to set your
'grepprg' to "cscope" plus a few cscope options, piped into grep to
select those results matching your filename pattern.

I used to execute cscope searches using :grep and the performance
was pretty good.

> any thoughts ?

Those are my thoughts, but I don't have a canned solution for you.

Regards,
Gary

Ben Schmidt

unread,
May 10, 2011, 6:31:28 AM5/10/11
to vim...@googlegroups.com, sinbad

Do you want to eliminate non-matching entries from the list, or just not
switch to them?

Ben.

sinbad

unread,
May 10, 2011, 9:42:36 AM5/10/11
to vim_use

On May 10, 3:31 pm, Ben Schmidt <mail_ben_schm...@yahoo.com.au> wrote:
> On 10/05/11 2:26 PM, sinbad wrote:
>
> > On May 9, 3:43 pm, sinbad<sinbad.sin...@gmail.com>  wrote:
> >> i am using cscope quickfix. from the quickfix
> >> results i want to browse thru the entries whose
> >> filename or file path matches a specific pattern
> >> how can i achieve this.
>
> Do you want to eliminate non-matching entries from the list, or just not
> switch to them?
>
> Ben.

just not switching to them will work for me too. i'm aware that there
are functions like getqflist() to
manipulate on the quickfix results. but i'm not too sure if i can
update that list. i thought there might
be some easier solutions that folks might aware of.

Christian Brabandt

unread,
May 10, 2011, 10:27:58 AM5/10/11
to vim...@googlegroups.com
On Tue, May 10, 2011 3:42 pm, sinbad wrote:
> just not switching to them will work for me too. i'm aware that there
> are functions like getqflist() to
> manipulate on the quickfix results. but i'm not too sure if i can
> update that list. i thought there might
> be some easier solutions that folks might aware of.

There was a message here, that mentioned a plugin that allows you
to modify the quickfix list:
http://groups.google.com/group/vim_use/msg/d622507cbf73a697

So you might want to try this plugin.

regards,
Christian

Ben Fritz

unread,
May 10, 2011, 11:28:58 AM5/10/11
to vim_use
If you are willing to browse using the quickfix window rather
than :cnext and :cprev and the like, it's easy to simply fold away
everything you're not interested in:

http://vim.wikia.com/wiki/Fold_regular_expression

Ben Schmidt

unread,
May 10, 2011, 8:41:58 PM5/10/11
to vim...@googlegroups.com, sinbad
>>> On May 9, 3:43 pm, sinbad<sinbad.sin...@gmail.com> wrote:
>>>> i am using cscope quickfix. from the quickfix
>>>> results i want to browse thru the entries whose
>>>> filename or file path matches a specific pattern
>>>> how can i achieve this.
>>
>> Do you want to eliminate non-matching entries from the list, or just not
>> switch to them?
>
> just not switching to them will work for me too. i'm aware that there
> are functions like getqflist() to
> manipulate on the quickfix results. but i'm not too sure if i can
> update that list. i thought there might
> be some easier solutions that folks might aware of.

There was a recent thread where somebody wanted to jump between just
errors, or warnings, or info messages in qf, but the OP seems to have
gone AWOL. However, in that thread, I was thinking something along these
lines would work:

command! -nargs=1 QFNextRegex call QFNextRegex(<f-args>)
command! QFNextError call QFNextRegex('error:')
function! QFNextRegex(regex)
" Gather info about the window state
let l:winnr = winnr()
let l:winrest = winrestcmd()
let l:lastwin = winnr('$')
" Use the error window to find the current error number
copen
let l:errnum = line('.') - 1
" Restore the window state
if l:lastwin != winnr('$')
cclose
endif
exec l:winnr . "wincmd w"
exe l:winrest
" Get the quickfix list
let l:qf = getqflist()
" Find and go to the next matching item in the list
let l:len = len(l:qf)
let l:errnum += 1
while l:errnum < l:len
if l:qf[l:errnum]['text'] =~ a:regex
exe "cc " . (l:errnum + 1)
return
endif
let l:errnum += 1
endwhile
" Give error if not found (hardcoded to English error message)
echoerr "E553: No more items"
endfunction

:QFNextError
:QFNextRegex \<mykeyword\>

I leave it as an exercise to produce the 'previous' version and/or
modify it to truly check the error type rather than just matching the
text and/or add commands for patterns useful to you. :-)

Ben.

Reply all
Reply to author
Forward
0 new messages