Quantcast

Re: Cscope quickfix -- not jump to first error

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Aarto Matti
On Jun 25 2008, 6:59 pm, Hari <[hidden email]> wrote:
> Hello All,
>
> Is there a way to prevent the cscope quickfix window from jumping to the
> first error. I have searched in the forums and someone suggested that this
> must be a request to the dev team...wonder if there was ever taken on a wish
> list?
>
> Thanks for your responses....
>
> -Hari

I want to disable jump too! How can I do that?

--
Aarto

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Tony Mechelynck
On 26/01/10 16:09, Aarto Matti wrote:

> On Jun 25 2008, 6:59 pm, Hari <[hidden email]
> <mailto:[hidden email]>> wrote:
>  > Hello All,
>  >
>  > Is there a way to prevent the cscope quickfix window from jumping to the
>  > first error. I have searched in the forums and someone suggested that
> this
>  > must be a request to the dev team...wonder if there was ever taken on
> a wish
>  > list?
>  >
>  > Thanks for your responses....
>  >
>  > -Hari
>
> I want to disable jump too! How can I do that?
>
> --
> Aarto
>
> --
> You received this message from the "vim_use" maillist.
> For more information, visit http://www.vim.org/maillist.php

AFAIK, with :cscope you can't (unless of course you leave
'cscopequickfix' empty so cscope never uses the quickfix mechanism, but
I suppose that that's not what you want). This is unlike most other
quickfix commands, such as :make and :grep with bang, and :vimgrep with
the j flag after the pattern. (IIUC, :helpgrep also always jumps to the
first match, but in a help window; however for :helpgrep I suppose there
is little use for "not" seeing the context above and below the match --
you're hoping there will be some help to read.)

I also don't notice this capability in the todo.txt helpfile. For the
"official" wish list, see

        :help sponsor
        :help sponsor-faq


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
249. You've forgotten what the outside looks like.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Sergey Khorev
In reply to this post by Aarto Matti
>> Is there a way to prevent the cscope quickfix window from jumping to the
>> first error.

Something like this should do the trick:

*** ../vim-hg/src/ex_cmds.h Mon Jan 11 16:07:46 2010
--- src/ex_cmds.h Thu Jan 28 13:58:34 2010
***************
*** 278,284 ****
  EX(CMD_crewind, "crewind", ex_cc,
  RANGE|NOTADR|COUNT|TRLBAR|BANG),
  EX(CMD_cscope, "cscope", do_cscope,
! EXTRA|NOTRLCOM|XFILE),
  EX(CMD_cstag, "cstag", do_cstag,
  BANG|TRLBAR|WORD1),
  EX(CMD_cunmap, "cunmap", ex_unmap,
--- 278,284 ----
  EX(CMD_crewind, "crewind", ex_cc,
  RANGE|NOTADR|COUNT|TRLBAR|BANG),
  EX(CMD_cscope, "cscope", do_cscope,
! BANG|EXTRA|NOTRLCOM|XFILE),
  EX(CMD_cstag, "cstag", do_cstag,
  BANG|TRLBAR|WORD1),
  EX(CMD_cunmap, "cunmap", ex_unmap,
*** ../vim-hg/src/if_cscope.c Tue Jan 19 18:23:47 2010
--- src/if_cscope.c Thu Jan 28 13:56:37 2010
***************
*** 1265,1271 ****
      */
     qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
  ?  wp->w_llist_ref : wp->w_llist;
! qf_jump(qi, 0, 0, forceit);
     }
  }
  mch_remove(tmp);
--- 1265,1272 ----
      */
     qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
  ?  wp->w_llist_ref : wp->w_llist;
! if (!forceit)
!    qf_jump(qi, 0, 0, forceit);
     }
  }
  mch_remove(tmp);
*** ../vim-hg/runtime/doc/if_cscop.txt Mon Jan 11 16:07:20 2010
--- runtime/doc/if_cscop.txt Thu Jan 28 14:15:25 2010
***************
*** 264,269 ****
--- 264,271 ----
  seems to be useful: >
  :set cscopequickfix=s-,c-,d-,i-,t-,e-
  <
+ If cscope was executed with !, Vim will not jump to the first error in
+ the quickfix window.
  *cscopetag* *cst*
  If 'cscopetag' set, the commands ":tag" and CTRL-] as well as "vim -t" will
  always use |:cstag| instead of the default :tag behavior.  Effectively, by

--
Sergey Khorev
http://sites.google.com/site/khorser
Can anybody think of a good tagline I can steal?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Aarto Matti
On Thu, Jan 28, 2010 at 1:19 PM, Sergey Khorev <[hidden email]> wrote:
>> Is there a way to prevent the cscope quickfix window from jumping to the
>> first error.

Something like this should do the trick:

*** ../vim-hg/src/ex_cmds.h     Mon Jan 11 16:07:46 2010
--- src/ex_cmds.h       Thu Jan 28 13:58:34 2010
***************
*** 278,284 ****
 EX(CMD_crewind,               "crewind",      ex_cc,
                       RANGE|NOTADR|COUNT|TRLBAR|BANG),
 EX(CMD_cscope,                "cscope",       do_cscope,
!                       EXTRA|NOTRLCOM|XFILE),
 EX(CMD_cstag,         "cstag",        do_cstag,
                       BANG|TRLBAR|WORD1),
 EX(CMD_cunmap,                "cunmap",       ex_unmap,
--- 278,284 ----
 EX(CMD_crewind,               "crewind",      ex_cc,
                       RANGE|NOTADR|COUNT|TRLBAR|BANG),
 EX(CMD_cscope,                "cscope",       do_cscope,
!                       BANG|EXTRA|NOTRLCOM|XFILE),
 EX(CMD_cstag,         "cstag",        do_cstag,
                       BANG|TRLBAR|WORD1),
 EX(CMD_cunmap,                "cunmap",       ex_unmap,
*** ../vim-hg/src/if_cscope.c   Tue Jan 19 18:23:47 2010
--- src/if_cscope.c     Thu Jan 28 13:56:37 2010
***************
*** 1265,1271 ****
                    */
                   qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
                       ?  wp->w_llist_ref : wp->w_llist;
!               qf_jump(qi, 0, 0, forceit);
           }
       }
       mch_remove(tmp);
--- 1265,1272 ----
                    */
                   qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
                       ?  wp->w_llist_ref : wp->w_llist;
!               if (!forceit)
!                   qf_jump(qi, 0, 0, forceit);
           }
       }
       mch_remove(tmp);
*** ../vim-hg/runtime/doc/if_cscop.txt  Mon Jan 11 16:07:20 2010
--- runtime/doc/if_cscop.txt    Thu Jan 28 14:15:25 2010
***************
*** 264,269 ****
--- 264,271 ----
 seems to be useful: >
       :set cscopequickfix=s-,c-,d-,i-,t-,e-
 <
+ If cscope was executed with !, Vim will not jump to the first error in
+ the quickfix window.
                                                       *cscopetag* *cst*
 If 'cscopetag' set, the commands ":tag" and CTRL-] as well as "vim -t" will
 always use |:cstag| instead of the default :tag behavior.  Effectively, by

--
Sergey Khorev
http://sites.google.com/site/khorser
Can anybody think of a good tagline I can steal?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
 

Thanks, Sergey. That worked!

--
Aarto

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Aarto Matti
In reply to this post by Sergey Khorev
On Thu, Jan 28, 2010 at 1:19 PM, Sergey Khorev <[hidden email]> wrote:
>> Is there a way to prevent the cscope quickfix window from jumping to the
>> first error.

Something like this should do the trick:

*** ../vim-hg/src/ex_cmds.h     Mon Jan 11 16:07:46 2010
--- src/ex_cmds.h       Thu Jan 28 13:58:34 2010
***************
*** 278,284 ****
 EX(CMD_crewind,               "crewind",      ex_cc,
                       RANGE|NOTADR|COUNT|TRLBAR|BANG),
 EX(CMD_cscope,                "cscope",       do_cscope,
!                       EXTRA|NOTRLCOM|XFILE),
 EX(CMD_cstag,         "cstag",        do_cstag,
                       BANG|TRLBAR|WORD1),
 EX(CMD_cunmap,                "cunmap",       ex_unmap,
--- 278,284 ----
 EX(CMD_crewind,               "crewind",      ex_cc,
                       RANGE|NOTADR|COUNT|TRLBAR|BANG),
 EX(CMD_cscope,                "cscope",       do_cscope,
!                       BANG|EXTRA|NOTRLCOM|XFILE),
 EX(CMD_cstag,         "cstag",        do_cstag,
                       BANG|TRLBAR|WORD1),
 EX(CMD_cunmap,                "cunmap",       ex_unmap,
*** ../vim-hg/src/if_cscope.c   Tue Jan 19 18:23:47 2010
--- src/if_cscope.c     Thu Jan 28 13:56:37 2010
***************
*** 1265,1271 ****
                    */
                   qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
                       ?  wp->w_llist_ref : wp->w_llist;
!               qf_jump(qi, 0, 0, forceit);
           }
       }
       mch_remove(tmp);
--- 1265,1272 ----
                    */
                   qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
                       ?  wp->w_llist_ref : wp->w_llist;
!               if (!forceit)
!                   qf_jump(qi, 0, 0, forceit);
           }
       }
       mch_remove(tmp);
*** ../vim-hg/runtime/doc/if_cscop.txt  Mon Jan 11 16:07:20 2010
--- runtime/doc/if_cscop.txt    Thu Jan 28 14:15:25 2010
***************
*** 264,269 ****
--- 264,271 ----
 seems to be useful: >
       :set cscopequickfix=s-,c-,d-,i-,t-,e-
 <
+ If cscope was executed with !, Vim will not jump to the first error in
+ the quickfix window.
                                                       *cscopetag* *cst*
 If 'cscopetag' set, the commands ":tag" and CTRL-] as well as "vim -t" will
 always use |:cstag| instead of the default :tag behavior.  Effectively, by

--
Sergey Khorev
http://sites.google.com/site/khorser
Can anybody think of a good tagline I can steal?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php


There's also a dirty fix to open quickfix window after search, I'm not sure of it's quality since I'm a noob, but I hope Bram will consider fixing that one too.

--- a/src/if_cscope.c    2010-01-28 17:47:53.000000000 +0200
+++ b/src/if_cscope.c    2010-01-28 17:46:45.000000000 +0200
@@ -1267,6 +1267,12 @@ cs_find_common(opt, pat, forceit, verbos
             ?  wp->w_llist_ref : wp->w_llist;
             if (!forceit)
                 qf_jump(qi, 0, 0, forceit);
+            exarg_T *eap;
+            eap = (exarg_T *)alloc_clear((unsigned)sizeof(exarg_T));
+            eap->cmdidx = CMD_copen;
+            eap->addr_count = 0;
+            ex_copen(eap);
+            vim_free(eap);
         }
     }
     mch_remove(tmp);

Should be applied after Sergey's patch. Thanks to Sergey for giving me a right direction.

--
Aarto


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Ben Fritz


On Jan 28, 9:58 am, Aarto Matti <[hidden email]> wrote:
>
> There's also a dirty fix to open quickfix window after search, I'm not sure
> of it's quality since I'm a noob, but I hope Bram will consider fixing that
> one too.
>
>
> Should be applied after Sergey's patch. Thanks to Sergey for giving me a
> right direction.
>

This would make cscope behave unlike any other quickfix command. I
think it would be better accomplished through vimscript.

For example, it could be just as simple as using a command-line
abbreviation like this:

:cabbrev cscope cscope find <C-R><C-W> | botright copen<C-Left><C-
Left><C-Left><C-Left>

Which will, when you type "cscope" on the command line, automatically
fill in most of the search (including the word under the cursor) for
you, all you need to do is enter the type of cscope query you wish to
run.

You may be interested in the following wiki pages to enhance this or
inspire other ways of accomplishing what you want:

http://vim.wikia.com/wiki/Find_in_files_within_Vim
http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Bram Moolenaar
In reply to this post by Sergey Khorev

Sergey Khorev wrote:

> >> Is there a way to prevent the cscope quickfix window from jumping to the
> >> first error.
>
> Something like this should do the trick:

[...]

> *** ../vim-hg/runtime/doc/if_cscop.txt Mon Jan 11 16:07:20 2010
> --- runtime/doc/if_cscop.txt Thu Jan 28 14:15:25 2010
> ***************
> *** 264,269 ****
> --- 264,271 ----
>   seems to be useful: >
>   :set cscopequickfix=s-,c-,d-,i-,t-,e-
>   <
> + If cscope was executed with !, Vim will not jump to the first error in
> + the quickfix window.
>   *cscopetag* *cst*
>   If 'cscopetag' set, the commands ":tag" and CTRL-] as well as "vim -t" will
>   always use |:cstag| instead of the default :tag behavior.  Effectively, by

This is incompatible with the behavior of :cstag where the bang means to
abandon a changed file.

The solution should probably be to have something else than "find" after
":cscope".


--
You're as much use as a condom machine at the Vatican.
                  -- Rimmer to Holly in Red Dwarf 'Queeg'

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Ben Fritz


On Jan 28, 2:15 pm, Bram Moolenaar <[hidden email]> wrote:
>
> This is incompatible with the behavior of :cstag where the bang means to
> abandon a changed file.
>
> The solution should probably be to have something else than "find" after
> ":cscope".
>

Instead of a ! on the command, how about incorporating it into
'cscopequickfix'? For example, the following could be made a valid
setting:

:set cscopequickfix=s-!,c-,d!-,t+!,e-

Which would:
* populate quickfix for C symbol searches, but not jump to the first
result
* populate quickfix for function call searches, and jump to the first
result
* populate quickfix for called function searches, but not jump to the
first result
* add to the quickfix for textual searches, but not jump to the first
result
* populate the quickfix for grep searches, and jump to the first
result

Putting it here makes at least some sense, would be easier to use (no
need to update mappings or anything, just an option), and won't break
backwards compatibility because without the ! in the options, the
string acts just as before.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Sergey Khorev
> Instead of a ! on the command, how about incorporating it into
> 'cscopequickfix'? For example, the following could be made a valid
> setting:

Agreed, that should make more sense.

--
Sergey Khorev
http://sites.google.com/site/khorser
Can anybody think of a good tagline I can steal?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Aarto Matti


On Fri, Jan 29, 2010 at 7:33 AM, Sergey Khorev <[hidden email]> wrote:
> Instead of a ! on the command, how about incorporating it into
> 'cscopequickfix'? For example, the following could be made a valid
> setting:

Agreed, that should make more sense.


I'm agree as well, extending 'cscopequickfix' is a better way.

--
Aarto

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Sergey Khorev
In reply to this post by Bram Moolenaar
> The solution should probably be to have something else than "find" after
> ":cscope".

Ok, attached is another try which extends csqf option as suggested by Ben.

--
Sergey Khorev
http://sites.google.com/site/khorser
Can anybody think of a good tagline I can steal?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cscope quickfix -- not jump to first error

Sergey Khorev
Apologies, I've forgotten to attach the patch

>> The solution should probably be to have something else than "find" after
>> ":cscope".
>
> Ok, attached is another try which extends csqf option as suggested by Ben.



--
Sergey Khorev
http://sites.google.com/site/khorser
Can anybody think of a good tagline I can steal?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

if_cscope_bang.patch (5K) Download Attachment
Loading...