Karsten Hopp 6ee35f
To: vim-dev@vim.org
Karsten Hopp 6ee35f
Subject: Patch 7.2.353
Karsten Hopp 6ee35f
Fcc: outbox
Karsten Hopp 6ee35f
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6ee35f
Mime-Version: 1.0
Karsten Hopp 6ee35f
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 6ee35f
Content-Transfer-Encoding: 8bit
Karsten Hopp 6ee35f
------------
Karsten Hopp 6ee35f
Karsten Hopp 6ee35f
Patch 7.2.353
Karsten Hopp 6ee35f
Problem:    No command line completion for ":profile".
Karsten Hopp 6ee35f
Solution:   Complete the subcommand and file name.
Karsten Hopp 6ee35f
Files:	    src/ex_docmd.c, src/ex_cmds2.c, src/ex_getln.c,
Karsten Hopp 6ee35f
	    src/proto/ex_cmds2.pro, src/vim.h
Karsten Hopp 6ee35f
Karsten Hopp 6ee35f
Karsten Hopp 6ee35f
*** ../vim-7.2.352/src/ex_docmd.c	2009-11-03 12:38:50.000000000 +0100
Karsten Hopp 6ee35f
--- src/ex_docmd.c	2010-02-03 14:40:14.000000000 +0100
Karsten Hopp 6ee35f
***************
Karsten Hopp 6ee35f
*** 3804,3809 ****
Karsten Hopp 6ee35f
--- 3804,3814 ----
Karsten Hopp 6ee35f
  		xp->xp_context = EXPAND_NOTHING;
Karsten Hopp 6ee35f
  	    break;
Karsten Hopp 6ee35f
  #endif
Karsten Hopp 6ee35f
+ #if defined(FEAT_PROFILE)
Karsten Hopp 6ee35f
+ 	case CMD_profile:
Karsten Hopp 6ee35f
+ 	    set_context_in_profile_cmd(xp, arg);
Karsten Hopp 6ee35f
+ 	    break;
Karsten Hopp 6ee35f
+ #endif
Karsten Hopp 6ee35f
  
Karsten Hopp 6ee35f
  #endif /* FEAT_CMDL_COMPL */
Karsten Hopp 6ee35f
  
Karsten Hopp 6ee35f
*** ../vim-7.2.352/src/ex_cmds2.c	2010-01-20 21:41:40.000000000 +0100
Karsten Hopp 6ee35f
--- src/ex_cmds2.c	2010-02-03 14:50:08.000000000 +0100
Karsten Hopp 6ee35f
***************
Karsten Hopp 6ee35f
*** 1115,1120 ****
Karsten Hopp 6ee35f
--- 1115,1193 ----
Karsten Hopp 6ee35f
      }
Karsten Hopp 6ee35f
  }
Karsten Hopp 6ee35f
  
Karsten Hopp 6ee35f
+ /* Command line expansion for :profile. */
Karsten Hopp 6ee35f
+ static enum
Karsten Hopp 6ee35f
+ {
Karsten Hopp 6ee35f
+     PEXP_SUBCMD,	/* expand :profile sub-commands */
Karsten Hopp 6ee35f
+     PEXP_FUNC,		/* expand :profile func {funcname} */
Karsten Hopp 6ee35f
+ } pexpand_what;
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+ static char *pexpand_cmds[] = {
Karsten Hopp 6ee35f
+ 			"start",
Karsten Hopp 6ee35f
+ #define PROFCMD_START	0
Karsten Hopp 6ee35f
+ 			"pause",
Karsten Hopp 6ee35f
+ #define PROFCMD_PAUSE	1
Karsten Hopp 6ee35f
+ 			"continue",
Karsten Hopp 6ee35f
+ #define PROFCMD_CONTINUE 2
Karsten Hopp 6ee35f
+ 			"func",
Karsten Hopp 6ee35f
+ #define PROFCMD_FUNC	3
Karsten Hopp 6ee35f
+ 			"file",
Karsten Hopp 6ee35f
+ #define PROFCMD_FILE	4
Karsten Hopp 6ee35f
+ 			NULL
Karsten Hopp 6ee35f
+ #define PROFCMD_LAST	5
Karsten Hopp 6ee35f
+ };
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+ /*
Karsten Hopp 6ee35f
+  * Function given to ExpandGeneric() to obtain the profile command
Karsten Hopp 6ee35f
+  * specific expansion.
Karsten Hopp 6ee35f
+  */
Karsten Hopp 6ee35f
+     char_u *
Karsten Hopp 6ee35f
+ get_profile_name(xp, idx)
Karsten Hopp 6ee35f
+     expand_T	*xp UNUSED;
Karsten Hopp 6ee35f
+     int		idx;
Karsten Hopp 6ee35f
+ {
Karsten Hopp 6ee35f
+     switch (pexpand_what)
Karsten Hopp 6ee35f
+     {
Karsten Hopp 6ee35f
+     case PEXP_SUBCMD:
Karsten Hopp 6ee35f
+ 	return (char_u *)pexpand_cmds[idx];
Karsten Hopp 6ee35f
+     /* case PEXP_FUNC: TODO */
Karsten Hopp 6ee35f
+     default:
Karsten Hopp 6ee35f
+ 	return NULL;
Karsten Hopp 6ee35f
+     }
Karsten Hopp 6ee35f
+ }
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+ /*
Karsten Hopp 6ee35f
+  * Handle command line completion for :profile command.
Karsten Hopp 6ee35f
+  */
Karsten Hopp 6ee35f
+     void
Karsten Hopp 6ee35f
+ set_context_in_profile_cmd(xp, arg)
Karsten Hopp 6ee35f
+     expand_T	*xp;
Karsten Hopp 6ee35f
+     char_u	*arg;
Karsten Hopp 6ee35f
+ {
Karsten Hopp 6ee35f
+     char_u	*end_subcmd;
Karsten Hopp 6ee35f
+     int		len;
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+     /* Default: expand subcommands. */
Karsten Hopp 6ee35f
+     xp->xp_context = EXPAND_PROFILE;
Karsten Hopp 6ee35f
+     pexpand_what = PEXP_SUBCMD;
Karsten Hopp 6ee35f
+     xp->xp_pattern = arg;
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+     end_subcmd = skiptowhite(arg);
Karsten Hopp 6ee35f
+     if (*end_subcmd == NUL)
Karsten Hopp 6ee35f
+ 	return;
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+     len = end_subcmd - arg;
Karsten Hopp 6ee35f
+     if (len == 5 && STRNCMP(arg, "start", 5) == 0)
Karsten Hopp 6ee35f
+     {
Karsten Hopp 6ee35f
+ 	xp->xp_context = EXPAND_FILES;
Karsten Hopp 6ee35f
+ 	xp->xp_pattern = skipwhite(end_subcmd);
Karsten Hopp 6ee35f
+ 	return;
Karsten Hopp 6ee35f
+     }
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
+     /* TODO: expand function names after "func" */
Karsten Hopp 6ee35f
+     xp->xp_context = EXPAND_NOTHING;
Karsten Hopp 6ee35f
+ }
Karsten Hopp 6ee35f
+ 
Karsten Hopp 6ee35f
  /*
Karsten Hopp 6ee35f
   * Dump the profiling info.
Karsten Hopp 6ee35f
   */
Karsten Hopp 6ee35f
*** ../vim-7.2.352/src/ex_getln.c	2010-01-19 14:59:14.000000000 +0100
Karsten Hopp 6ee35f
--- src/ex_getln.c	2010-02-03 14:38:43.000000000 +0100
Karsten Hopp 6ee35f
***************
Karsten Hopp 6ee35f
*** 4522,4527 ****
Karsten Hopp 6ee35f
--- 4522,4530 ----
Karsten Hopp 6ee35f
  #ifdef FEAT_SIGNS
Karsten Hopp 6ee35f
  	    {EXPAND_SIGN, get_sign_name, TRUE},
Karsten Hopp 6ee35f
  #endif
Karsten Hopp 6ee35f
+ #ifdef FEAT_PROFILE
Karsten Hopp 6ee35f
+ 	    {EXPAND_PROFILE, get_profile_name, TRUE},
Karsten Hopp 6ee35f
+ #endif
Karsten Hopp 6ee35f
  #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
Karsten Hopp 6ee35f
  	&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
Karsten Hopp 6ee35f
  	    {EXPAND_LANGUAGE, get_lang_arg, TRUE},
Karsten Hopp 6ee35f
*** ../vim-7.2.352/src/proto/ex_cmds2.pro	2008-01-06 20:07:25.000000000 +0100
Karsten Hopp 6ee35f
--- src/proto/ex_cmds2.pro	2010-02-03 14:43:12.000000000 +0100
Karsten Hopp 6ee35f
***************
Karsten Hopp 6ee35f
*** 24,29 ****
Karsten Hopp 6ee35f
--- 24,31 ----
Karsten Hopp 6ee35f
  int profile_equal __ARGS((proftime_T *tm1, proftime_T *tm2));
Karsten Hopp 6ee35f
  int profile_cmp __ARGS((proftime_T *tm1, proftime_T *tm2));
Karsten Hopp 6ee35f
  void ex_profile __ARGS((exarg_T *eap));
Karsten Hopp 6ee35f
+ char_u *get_profile_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 6ee35f
+ void set_context_in_profile_cmd __ARGS((expand_T *xp, char_u *arg));
Karsten Hopp 6ee35f
  void profile_dump __ARGS((void));
Karsten Hopp 6ee35f
  void script_prof_save __ARGS((proftime_T *tm));
Karsten Hopp 6ee35f
  void script_prof_restore __ARGS((proftime_T *tm));
Karsten Hopp 6ee35f
*** ../vim-7.2.352/src/vim.h	2009-06-16 11:08:13.000000000 +0200
Karsten Hopp 6ee35f
--- src/vim.h	2010-02-03 14:40:42.000000000 +0100
Karsten Hopp 6ee35f
***************
Karsten Hopp 6ee35f
*** 718,723 ****
Karsten Hopp 6ee35f
--- 718,724 ----
Karsten Hopp 6ee35f
  #define EXPAND_SHELLCMD		32
Karsten Hopp 6ee35f
  #define EXPAND_CSCOPE		33
Karsten Hopp 6ee35f
  #define EXPAND_SIGN		34
Karsten Hopp 6ee35f
+ #define EXPAND_PROFILE		35
Karsten Hopp 6ee35f
  
Karsten Hopp 6ee35f
  /* Values for exmode_active (0 is no exmode) */
Karsten Hopp 6ee35f
  #define EXMODE_NORMAL		1
Karsten Hopp 6ee35f
*** ../vim-7.2.352/src/version.c	2010-02-03 12:23:16.000000000 +0100
Karsten Hopp 6ee35f
--- src/version.c	2010-02-03 15:07:26.000000000 +0100
Karsten Hopp 6ee35f
***************
Karsten Hopp 6ee35f
*** 683,684 ****
Karsten Hopp 6ee35f
--- 683,686 ----
Karsten Hopp 6ee35f
  {   /* Add new patch number below this line */
Karsten Hopp 6ee35f
+ /**/
Karsten Hopp 6ee35f
+     353,
Karsten Hopp 6ee35f
  /**/
Karsten Hopp 6ee35f
Karsten Hopp 6ee35f
-- 
Karsten Hopp 6ee35f
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 6ee35f
188. You purchase a laptop so you can surf while sitting on the can.
Karsten Hopp 6ee35f
Karsten Hopp 6ee35f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6ee35f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6ee35f
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 6ee35f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///