Karsten Hopp 7d8cb7
To: vim-dev@vim.org
Karsten Hopp 7d8cb7
Subject: Patch 7.2.143
Karsten Hopp 7d8cb7
Fcc: outbox
Karsten Hopp 7d8cb7
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 7d8cb7
Mime-Version: 1.0
Karsten Hopp 7d8cb7
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 7d8cb7
Content-Transfer-Encoding: 8bit
Karsten Hopp 7d8cb7
------------
Karsten Hopp 7d8cb7
Karsten Hopp 7d8cb7
Patch 7.2.143
Karsten Hopp 7d8cb7
Problem:    No command line completion for ":cscope" command.
Karsten Hopp 7d8cb7
Solution:   Add the completion for ":cscope". (Dominique Pelle)
Karsten Hopp 7d8cb7
Files:	    src/ex_docmd.c, src/ex_getln.c, src/if_cscope.c,
Karsten Hopp 7d8cb7
	    src/proto/if_cscope.pro, src/vim.h
Karsten Hopp 7d8cb7
Karsten Hopp 7d8cb7
Karsten Hopp 7d8cb7
*** ../vim-7.2.142/src/ex_docmd.c	Wed Mar 11 15:36:01 2009
Karsten Hopp 7d8cb7
--- src/ex_docmd.c	Wed Mar 11 15:45:04 2009
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 3683,3688 ****
Karsten Hopp 7d8cb7
--- 3683,3693 ----
Karsten Hopp 7d8cb7
  	case CMD_highlight:
Karsten Hopp 7d8cb7
  	    set_context_in_highlight_cmd(xp, arg);
Karsten Hopp 7d8cb7
  	    break;
Karsten Hopp 7d8cb7
+ #ifdef FEAT_CSCOPE
Karsten Hopp 7d8cb7
+ 	case CMD_cscope:
Karsten Hopp 7d8cb7
+ 	    set_context_in_cscope_cmd(xp, arg);
Karsten Hopp 7d8cb7
+ 	    break;
Karsten Hopp 7d8cb7
+ #endif
Karsten Hopp 7d8cb7
  #ifdef FEAT_LISTCMDS
Karsten Hopp 7d8cb7
  	case CMD_bdelete:
Karsten Hopp 7d8cb7
  	case CMD_bwipeout:
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 5187,5192 ****
Karsten Hopp 7d8cb7
--- 5192,5200 ----
Karsten Hopp 7d8cb7
      {EXPAND_AUGROUP, "augroup"},
Karsten Hopp 7d8cb7
      {EXPAND_BUFFERS, "buffer"},
Karsten Hopp 7d8cb7
      {EXPAND_COMMANDS, "command"},
Karsten Hopp 7d8cb7
+ #if defined(FEAT_CSCOPE)
Karsten Hopp 7d8cb7
+     {EXPAND_CSCOPE, "cscope"},
Karsten Hopp 7d8cb7
+ #endif
Karsten Hopp 7d8cb7
  #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
Karsten Hopp 7d8cb7
      {EXPAND_USER_DEFINED, "custom"},
Karsten Hopp 7d8cb7
      {EXPAND_USER_LIST, "customlist"},
Karsten Hopp 7d8cb7
*** ../vim-7.2.142/src/ex_getln.c	Thu Mar  5 03:13:51 2009
Karsten Hopp 7d8cb7
--- src/ex_getln.c	Wed Mar 11 15:45:04 2009
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 4518,4523 ****
Karsten Hopp 7d8cb7
--- 4518,4526 ----
Karsten Hopp 7d8cb7
  	    {EXPAND_EVENTS, get_event_name, TRUE},
Karsten Hopp 7d8cb7
  	    {EXPAND_AUGROUP, get_augroup_name, TRUE},
Karsten Hopp 7d8cb7
  #endif
Karsten Hopp 7d8cb7
+ #ifdef FEAT_CSCOPE
Karsten Hopp 7d8cb7
+ 	    {EXPAND_CSCOPE, get_cscope_name, TRUE},
Karsten Hopp 7d8cb7
+ #endif
Karsten Hopp 7d8cb7
  #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
Karsten Hopp 7d8cb7
  	&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
Karsten Hopp 7d8cb7
  	    {EXPAND_LANGUAGE, get_lang_arg, TRUE},
Karsten Hopp 7d8cb7
*** ../vim-7.2.142/src/if_cscope.c	Wed Jan 28 16:03:51 2009
Karsten Hopp 7d8cb7
--- src/if_cscope.c	Wed Mar 11 15:56:07 2009
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 93,104 ****
Karsten Hopp 7d8cb7
      (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
Karsten Hopp 7d8cb7
  }
Karsten Hopp 7d8cb7
  
Karsten Hopp 7d8cb7
  /*
Karsten Hopp 7d8cb7
   * PRIVATE: do_cscope_general
Karsten Hopp 7d8cb7
   *
Karsten Hopp 7d8cb7
!  * find the command, print help if invalid, and the then call the
Karsten Hopp 7d8cb7
!  * corresponding command function,
Karsten Hopp 7d8cb7
!  * called from do_cscope and do_scscope
Karsten Hopp 7d8cb7
   */
Karsten Hopp 7d8cb7
      static void
Karsten Hopp 7d8cb7
  do_cscope_general(eap, make_split)
Karsten Hopp 7d8cb7
--- 93,209 ----
Karsten Hopp 7d8cb7
      (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
Karsten Hopp 7d8cb7
  }
Karsten Hopp 7d8cb7
  
Karsten Hopp 7d8cb7
+ #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+ static enum
Karsten Hopp 7d8cb7
+ {
Karsten Hopp 7d8cb7
+     EXP_CSCOPE_SUBCMD,	/* expand ":cscope" sub-commands */
Karsten Hopp 7d8cb7
+     EXP_CSCOPE_FIND,	/* expand ":cscope find" arguments */
Karsten Hopp 7d8cb7
+     EXP_CSCOPE_KILL	/* expand ":cscope kill" arguments */
Karsten Hopp 7d8cb7
+ } expand_what;
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+ /*
Karsten Hopp 7d8cb7
+  * Function given to ExpandGeneric() to obtain the cscope command
Karsten Hopp 7d8cb7
+  * expansion.
Karsten Hopp 7d8cb7
+  */
Karsten Hopp 7d8cb7
+ /*ARGSUSED*/
Karsten Hopp 7d8cb7
+     char_u *
Karsten Hopp 7d8cb7
+ get_cscope_name(xp, idx)
Karsten Hopp 7d8cb7
+     expand_T	*xp;
Karsten Hopp 7d8cb7
+     int		idx;
Karsten Hopp 7d8cb7
+ {
Karsten Hopp 7d8cb7
+     switch (expand_what)
Karsten Hopp 7d8cb7
+     {
Karsten Hopp 7d8cb7
+     case EXP_CSCOPE_SUBCMD:
Karsten Hopp 7d8cb7
+ 	/* Complete with sub-commands of ":cscope":
Karsten Hopp 7d8cb7
+ 	 * add, find, help, kill, reset, show */
Karsten Hopp 7d8cb7
+ 	return (char_u *)cs_cmds[idx].name;
Karsten Hopp 7d8cb7
+     case EXP_CSCOPE_FIND:
Karsten Hopp 7d8cb7
+ 	{
Karsten Hopp 7d8cb7
+ 	    const char *query_type[] =
Karsten Hopp 7d8cb7
+ 	    {
Karsten Hopp 7d8cb7
+ 		"c", "d", "e", "f", "g", "i", "s", "t", NULL
Karsten Hopp 7d8cb7
+ 	    };
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+ 	    /* Complete with query type of ":cscope find {query_type}".
Karsten Hopp 7d8cb7
+ 	     * {query_type} can be letters (c, d, ... t) or numbers (0, 1,
Karsten Hopp 7d8cb7
+ 	     * ..., 8) but only complete with letters, since numbers are
Karsten Hopp 7d8cb7
+ 	     * redundant. */
Karsten Hopp 7d8cb7
+ 	    return (char_u *)query_type[idx];
Karsten Hopp 7d8cb7
+ 	}
Karsten Hopp 7d8cb7
+     case EXP_CSCOPE_KILL:
Karsten Hopp 7d8cb7
+ 	{
Karsten Hopp 7d8cb7
+ 	    int			i;
Karsten Hopp 7d8cb7
+ 	    int			current_idx = 0;
Karsten Hopp 7d8cb7
+ 	    static char_u	connection[2];
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+ 	    /* ":cscope kill" accepts connection numbers or partial names of
Karsten Hopp 7d8cb7
+ 	     * the pathname of the cscope database as argument.  Only complete
Karsten Hopp 7d8cb7
+ 	     * with connection numbers. -1 can also be used to kill all
Karsten Hopp 7d8cb7
+ 	     * connections. */
Karsten Hopp 7d8cb7
+ 	    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 7d8cb7
+ 	    {
Karsten Hopp 7d8cb7
+ 		if (csinfo[i].fname == NULL)
Karsten Hopp 7d8cb7
+ 		    continue;
Karsten Hopp 7d8cb7
+ 		if (current_idx++ == idx)
Karsten Hopp 7d8cb7
+ 		{
Karsten Hopp 7d8cb7
+ 		    /* Connection number fits in one character since
Karsten Hopp 7d8cb7
+ 		     * CSCOPE_MAX_CONNECTIONS is < 10 */
Karsten Hopp 7d8cb7
+ 		    connection[0] = i + '0';
Karsten Hopp 7d8cb7
+ 		    connection[1] = NUL;
Karsten Hopp 7d8cb7
+ 		    return connection;
Karsten Hopp 7d8cb7
+ 		}
Karsten Hopp 7d8cb7
+ 	    }
Karsten Hopp 7d8cb7
+ 	    return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
Karsten Hopp 7d8cb7
+ 	}
Karsten Hopp 7d8cb7
+     default:
Karsten Hopp 7d8cb7
+ 	return NULL;
Karsten Hopp 7d8cb7
+     }
Karsten Hopp 7d8cb7
+ }
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+ /*
Karsten Hopp 7d8cb7
+  * Handle command line completion for :cscope command.
Karsten Hopp 7d8cb7
+  */
Karsten Hopp 7d8cb7
+     void
Karsten Hopp 7d8cb7
+ set_context_in_cscope_cmd(xp, arg)
Karsten Hopp 7d8cb7
+     expand_T	*xp;
Karsten Hopp 7d8cb7
+     char_u	*arg;
Karsten Hopp 7d8cb7
+ {
Karsten Hopp 7d8cb7
+     char_u	*p;
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+     /* Default: expand subcommands */
Karsten Hopp 7d8cb7
+     xp->xp_context = EXPAND_CSCOPE;
Karsten Hopp 7d8cb7
+     expand_what = EXP_CSCOPE_SUBCMD;
Karsten Hopp 7d8cb7
+     xp->xp_pattern = arg;
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+     /* (part of) subcommand already typed */
Karsten Hopp 7d8cb7
+     if (*arg != NUL)
Karsten Hopp 7d8cb7
+     {
Karsten Hopp 7d8cb7
+ 	p = skiptowhite(arg);
Karsten Hopp 7d8cb7
+ 	if (*p != NUL)		    /* past first word */
Karsten Hopp 7d8cb7
+ 	{
Karsten Hopp 7d8cb7
+ 	    xp->xp_pattern = skipwhite(p);
Karsten Hopp 7d8cb7
+ 	    if (*skiptowhite(xp->xp_pattern) != NUL)
Karsten Hopp 7d8cb7
+ 		xp->xp_context = EXPAND_NOTHING;
Karsten Hopp 7d8cb7
+ 	    else if (STRNICMP(arg, "add", p - arg) == 0)
Karsten Hopp 7d8cb7
+ 		xp->xp_context = EXPAND_FILES;
Karsten Hopp 7d8cb7
+ 	    else if (STRNICMP(arg, "kill", p - arg) == 0)
Karsten Hopp 7d8cb7
+ 		expand_what = EXP_CSCOPE_KILL;
Karsten Hopp 7d8cb7
+ 	    else if (STRNICMP(arg, "find", p - arg) == 0)
Karsten Hopp 7d8cb7
+ 		expand_what = EXP_CSCOPE_FIND;
Karsten Hopp 7d8cb7
+ 	    else
Karsten Hopp 7d8cb7
+ 		xp->xp_context = EXPAND_NOTHING;
Karsten Hopp 7d8cb7
+ 	}
Karsten Hopp 7d8cb7
+     }
Karsten Hopp 7d8cb7
+ }
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
+ #endif /* FEAT_CMDL_COMPL */
Karsten Hopp 7d8cb7
+ 
Karsten Hopp 7d8cb7
  /*
Karsten Hopp 7d8cb7
   * PRIVATE: do_cscope_general
Karsten Hopp 7d8cb7
   *
Karsten Hopp 7d8cb7
!  * Find the command, print help if invalid, and then call the corresponding
Karsten Hopp 7d8cb7
!  * command function.
Karsten Hopp 7d8cb7
   */
Karsten Hopp 7d8cb7
      static void
Karsten Hopp 7d8cb7
  do_cscope_general(eap, make_split)
Karsten Hopp 7d8cb7
*** ../vim-7.2.142/src/proto/if_cscope.pro	Thu Sep  6 17:38:21 2007
Karsten Hopp 7d8cb7
--- src/proto/if_cscope.pro	Wed Mar 11 15:57:03 2009
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 1,4 ****
Karsten Hopp 7d8cb7
--- 1,6 ----
Karsten Hopp 7d8cb7
  /* if_cscope.c */
Karsten Hopp 7d8cb7
+ char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 7d8cb7
+ void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg));
Karsten Hopp 7d8cb7
  void do_cscope __ARGS((exarg_T *eap));
Karsten Hopp 7d8cb7
  void do_scscope __ARGS((exarg_T *eap));
Karsten Hopp 7d8cb7
  void do_cstag __ARGS((exarg_T *eap));
Karsten Hopp 7d8cb7
*** ../vim-7.2.142/src/vim.h	Sun Feb 22 02:36:36 2009
Karsten Hopp 7d8cb7
--- src/vim.h	Wed Mar 11 15:45:04 2009
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 708,713 ****
Karsten Hopp 7d8cb7
--- 708,714 ----
Karsten Hopp 7d8cb7
  #define EXPAND_USER_DEFINED	30
Karsten Hopp 7d8cb7
  #define EXPAND_USER_LIST	31
Karsten Hopp 7d8cb7
  #define EXPAND_SHELLCMD		32
Karsten Hopp 7d8cb7
+ #define EXPAND_CSCOPE		33
Karsten Hopp 7d8cb7
  
Karsten Hopp 7d8cb7
  /* Values for exmode_active (0 is no exmode) */
Karsten Hopp 7d8cb7
  #define EXMODE_NORMAL		1
Karsten Hopp 7d8cb7
*** ../vim-7.2.142/src/version.c	Wed Mar 18 12:20:35 2009
Karsten Hopp 7d8cb7
--- src/version.c	Wed Mar 18 12:48:08 2009
Karsten Hopp 7d8cb7
***************
Karsten Hopp 7d8cb7
*** 678,679 ****
Karsten Hopp 7d8cb7
--- 678,681 ----
Karsten Hopp 7d8cb7
  {   /* Add new patch number below this line */
Karsten Hopp 7d8cb7
+ /**/
Karsten Hopp 7d8cb7
+     143,
Karsten Hopp 7d8cb7
  /**/
Karsten Hopp 7d8cb7
Karsten Hopp 7d8cb7
-- 
Karsten Hopp 7d8cb7
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 7d8cb7
234. You started college as a chemistry major, and walk out four years
Karsten Hopp 7d8cb7
     later as an Internet provider.
Karsten Hopp 7d8cb7
Karsten Hopp 7d8cb7
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 7d8cb7
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 7d8cb7
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 7d8cb7
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///