Thursday, January 28, 2010

Re: Cscope quickfix -- not jump to first error

On Thu, Jan 28, 2010 at 1:19 PM, Sergey Khorev <sergey.khorev@gmail.com> 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

No comments: