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