Karsten Hopp 81c285
To: vim-dev@vim.org
Karsten Hopp 81c285
Subject: Patch 7.2.156
Karsten Hopp 81c285
Fcc: outbox
Karsten Hopp 81c285
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 81c285
Mime-Version: 1.0
Karsten Hopp 81c285
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 81c285
Content-Transfer-Encoding: 8bit
Karsten Hopp 81c285
------------
Karsten Hopp 81c285
Karsten Hopp 81c285
Patch 7.2.156 (after 7.2.143)
Karsten Hopp 81c285
Problem:    No completion for :scscope and :lcscope commands.
Karsten Hopp 81c285
Solution:   Implement the completion. (Dominique Pelle)
Karsten Hopp 81c285
Files:	    src/if_cscope.c, src/ex_docmd.c, src/proto/if_cscope.pro
Karsten Hopp 81c285
Karsten Hopp 81c285
Karsten Hopp 81c285
*** ../vim-7.2.155/src/if_cscope.c	Wed Mar 18 14:30:46 2009
Karsten Hopp 81c285
--- src/if_cscope.c	Wed Apr 22 11:57:49 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 98,103 ****
Karsten Hopp 81c285
--- 98,104 ----
Karsten Hopp 81c285
  static enum
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      EXP_CSCOPE_SUBCMD,	/* expand ":cscope" sub-commands */
Karsten Hopp 81c285
+     EXP_SCSCOPE_SUBCMD,	/* expand ":scscope" sub-commands */
Karsten Hopp 81c285
      EXP_CSCOPE_FIND,	/* expand ":cscope find" arguments */
Karsten Hopp 81c285
      EXP_CSCOPE_KILL	/* expand ":cscope kill" arguments */
Karsten Hopp 81c285
  } expand_what;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 112,123 ****
Karsten Hopp 81c285
--- 113,135 ----
Karsten Hopp 81c285
      expand_T	*xp;
Karsten Hopp 81c285
      int		idx;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
+     int		current_idx;
Karsten Hopp 81c285
+     int		i;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      switch (expand_what)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
      case EXP_CSCOPE_SUBCMD:
Karsten Hopp 81c285
  	/* Complete with sub-commands of ":cscope":
Karsten Hopp 81c285
  	 * add, find, help, kill, reset, show */
Karsten Hopp 81c285
  	return (char_u *)cs_cmds[idx].name;
Karsten Hopp 81c285
+     case EXP_SCSCOPE_SUBCMD:
Karsten Hopp 81c285
+ 	/* Complete with sub-commands of ":scscope": same sub-commands as
Karsten Hopp 81c285
+ 	 * ":cscope" but skip commands which don't support split windows */
Karsten Hopp 81c285
+ 	for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++)
Karsten Hopp 81c285
+ 	    if (cs_cmds[i].cansplit)
Karsten Hopp 81c285
+ 		if (current_idx++ == idx)
Karsten Hopp 81c285
+ 		    break;
Karsten Hopp 81c285
+ 	return (char_u *)cs_cmds[i].name;
Karsten Hopp 81c285
      case EXP_CSCOPE_FIND:
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    const char *query_type[] =
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 133,147 ****
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      case EXP_CSCOPE_KILL:
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
- 	    int			i;
Karsten Hopp 81c285
- 	    int			current_idx = 0;
Karsten Hopp 81c285
  	    static char_u	connection[2];
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* ":cscope kill" accepts connection numbers or partial names of
Karsten Hopp 81c285
  	     * the pathname of the cscope database as argument.  Only complete
Karsten Hopp 81c285
  	     * with connection numbers. -1 can also be used to kill all
Karsten Hopp 81c285
  	     * connections. */
Karsten Hopp 81c285
! 	    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		if (csinfo[i].fname == NULL)
Karsten Hopp 81c285
  		    continue;
Karsten Hopp 81c285
--- 145,157 ----
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      case EXP_CSCOPE_KILL:
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    static char_u	connection[2];
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* ":cscope kill" accepts connection numbers or partial names of
Karsten Hopp 81c285
  	     * the pathname of the cscope database as argument.  Only complete
Karsten Hopp 81c285
  	     * with connection numbers. -1 can also be used to kill all
Karsten Hopp 81c285
  	     * connections. */
Karsten Hopp 81c285
! 	    for (i = 0, current_idx = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		if (csinfo[i].fname == NULL)
Karsten Hopp 81c285
  		    continue;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 165,180 ****
Karsten Hopp 81c285
   * Handle command line completion for :cscope command.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
! set_context_in_cscope_cmd(xp, arg)
Karsten Hopp 81c285
      expand_T	*xp;
Karsten Hopp 81c285
      char_u	*arg;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      char_u	*p;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* Default: expand subcommands */
Karsten Hopp 81c285
      xp->xp_context = EXPAND_CSCOPE;
Karsten Hopp 81c285
-     expand_what = EXP_CSCOPE_SUBCMD;
Karsten Hopp 81c285
      xp->xp_pattern = arg;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* (part of) subcommand already typed */
Karsten Hopp 81c285
      if (*arg != NUL)
Karsten Hopp 81c285
--- 175,192 ----
Karsten Hopp 81c285
   * Handle command line completion for :cscope command.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
! set_context_in_cscope_cmd(xp, arg, cmdidx)
Karsten Hopp 81c285
      expand_T	*xp;
Karsten Hopp 81c285
      char_u	*arg;
Karsten Hopp 81c285
+     cmdidx_T	cmdidx;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      char_u	*p;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* Default: expand subcommands */
Karsten Hopp 81c285
      xp->xp_context = EXPAND_CSCOPE;
Karsten Hopp 81c285
      xp->xp_pattern = arg;
Karsten Hopp 81c285
+     expand_what = (cmdidx == CMD_scscope)
Karsten Hopp 81c285
+ 			? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* (part of) subcommand already typed */
Karsten Hopp 81c285
      if (*arg != NUL)
Karsten Hopp 81c285
*** ../vim-7.2.155/src/ex_docmd.c	Wed Apr 22 14:42:26 2009
Karsten Hopp 81c285
--- src/ex_docmd.c	Wed Apr 22 11:57:49 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3690,3696 ****
Karsten Hopp 81c285
  	    break;
Karsten Hopp 81c285
  #ifdef FEAT_CSCOPE
Karsten Hopp 81c285
  	case CMD_cscope:
Karsten Hopp 81c285
! 	    set_context_in_cscope_cmd(xp, arg);
Karsten Hopp 81c285
  	    break;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #ifdef FEAT_LISTCMDS
Karsten Hopp 81c285
--- 3690,3698 ----
Karsten Hopp 81c285
  	    break;
Karsten Hopp 81c285
  #ifdef FEAT_CSCOPE
Karsten Hopp 81c285
  	case CMD_cscope:
Karsten Hopp 81c285
! 	case CMD_lcscope:
Karsten Hopp 81c285
! 	case CMD_scscope:
Karsten Hopp 81c285
! 	    set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
Karsten Hopp 81c285
  	    break;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #ifdef FEAT_LISTCMDS
Karsten Hopp 81c285
*** ../vim-7.2.155/src/proto/if_cscope.pro	Wed Mar 18 12:50:58 2009
Karsten Hopp 81c285
--- src/proto/if_cscope.pro	Wed Apr 22 11:57:49 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1,6 ****
Karsten Hopp 81c285
  /* if_cscope.c */
Karsten Hopp 81c285
  char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 81c285
! void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg));
Karsten Hopp 81c285
  void do_cscope __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  void do_scscope __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  void do_cstag __ARGS((exarg_T *eap));
Karsten Hopp 81c285
--- 1,6 ----
Karsten Hopp 81c285
  /* if_cscope.c */
Karsten Hopp 81c285
  char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 81c285
! void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg, cmdidx_T cmdidx));
Karsten Hopp 81c285
  void do_cscope __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  void do_scscope __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  void do_cstag __ARGS((exarg_T *eap));
Karsten Hopp 81c285
*** ../vim-7.2.155/src/version.c	Wed Apr 22 16:07:57 2009
Karsten Hopp 81c285
--- src/version.c	Wed Apr 22 16:21:43 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 678,679 ****
Karsten Hopp 81c285
--- 678,681 ----
Karsten Hopp 81c285
  {   /* Add new patch number below this line */
Karsten Hopp 81c285
+ /**/
Karsten Hopp 81c285
+     156,
Karsten Hopp 81c285
  /**/
Karsten Hopp 81c285
Karsten Hopp 81c285
-- 
Karsten Hopp 81c285
ARTHUR:  Shut up!  Will you shut up!
Karsten Hopp 81c285
DENNIS:  Ah, now we see the violence inherent in the system.
Karsten Hopp 81c285
ARTHUR:  Shut up!
Karsten Hopp 81c285
DENNIS:  Oh!  Come and see the violence inherent in the system!
Karsten Hopp 81c285
         HELP! HELP!  I'm being repressed!
Karsten Hopp 81c285
                                  The Quest for the Holy Grail (Monty Python)
Karsten Hopp 81c285
Karsten Hopp 81c285
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 81c285
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 81c285
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 81c285
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///