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