jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.414

3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.414
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.414
3ef2ca
Problem:    Cannot define a command only when it's used.
3ef2ca
Solution:   Add the CmdUndefined autocommand event. (partly by Yasuhiro
3ef2ca
	    Matsumoto)
3ef2ca
Files:	    runtime/doc/autocmd.txt, src/ex_docmd.c, src/fileio.c,
3ef2ca
	    src/proto/fileio.pro
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.413/runtime/doc/autocmd.txt	2013-11-28 18:53:47.000000000 +0100
3ef2ca
--- runtime/doc/autocmd.txt	2014-08-22 20:10:24.026988365 +0200
3ef2ca
***************
3ef2ca
*** 278,283 ****
3ef2ca
--- 278,284 ----
3ef2ca
  |ShellCmdPost|		after executing a shell command
3ef2ca
  |ShellFilterPost|	after filtering with a shell command
3ef2ca
  
3ef2ca
+ |CmdUndefined|		a user command is used but it isn't defined
3ef2ca
  |FuncUndefined|		a user function is used but it isn't defined
3ef2ca
  |SpellFileMissing|	a spell file is used but it can't be found
3ef2ca
  |SourcePre|		before sourcing a Vim script
3ef2ca
***************
3ef2ca
*** 462,467 ****
3ef2ca
--- 466,481 ----
3ef2ca
  							*BufWritePost*
3ef2ca
  BufWritePost			After writing the whole buffer to a file
3ef2ca
  				(should undo the commands for BufWritePre).
3ef2ca
+ 							*CmdUndefined*
3ef2ca
+ CmdUndefined			When a user command is used but it isn't
3ef2ca
+ 				defined.  Useful for defining a command only
3ef2ca
+ 				when it's used.  The pattern is matched
3ef2ca
+ 				against the command name.  Both <amatch> and
3ef2ca
+ 				<afile> are set to the name of the command.
3ef2ca
+ 				NOTE: Autocompletion won't work until the
3ef2ca
+ 				command is defined.  An alternative is to
3ef2ca
+ 				always define the user command and have it
3ef2ca
+ 				invoke an autoloaded function.  See |autoload|.
3ef2ca
  							*CmdwinEnter*
3ef2ca
  CmdwinEnter			After entering the command-line window.
3ef2ca
  				Useful for setting options specifically for
3ef2ca
***************
3ef2ca
*** 663,668 ****
3ef2ca
--- 681,688 ----
3ef2ca
  				when it's used.  The pattern is matched
3ef2ca
  				against the function name.  Both <amatch> and
3ef2ca
  				<afile> are set to the name of the function.
3ef2ca
+ 				NOTE: When writing Vim scripts a better
3ef2ca
+ 				alternative is to use an autoloaded function.
3ef2ca
  				See |autoload-functions|.
3ef2ca
  							*GUIEnter*
3ef2ca
  GUIEnter			After starting the GUI successfully, and after
3ef2ca
*** ../vim-7.4.413/src/ex_docmd.c	2014-08-10 13:34:59.056785459 +0200
3ef2ca
--- src/ex_docmd.c	2014-08-22 20:23:43.426959373 +0200
3ef2ca
***************
3ef2ca
*** 2143,2148 ****
3ef2ca
--- 2143,2168 ----
3ef2ca
      /* Find the command and let "p" point to after it. */
3ef2ca
      p = find_command(&ea, NULL);
3ef2ca
  
3ef2ca
+ #ifdef FEAT_AUTOCMD
3ef2ca
+     /* If this looks like an undefined user command and there are CmdUndefined
3ef2ca
+      * autocommands defined, trigger the matching autocommands. */
3ef2ca
+     if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip
3ef2ca
+ 	    && ASCII_ISUPPER(*ea.cmd)
3ef2ca
+ 	    && has_cmdundefined())
3ef2ca
+     {
3ef2ca
+ 	char_u *p = ea.cmd;
3ef2ca
+ 	int ret;
3ef2ca
+ 
3ef2ca
+ 	while (ASCII_ISALNUM(*p))
3ef2ca
+ 	    ++p;
3ef2ca
+ 	p = vim_strnsave(ea.cmd, p - ea.cmd);
3ef2ca
+ 	ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
3ef2ca
+ 	vim_free(p);
3ef2ca
+ 	if (ret && !aborting())
3ef2ca
+ 	    p = find_command(&ea, NULL);
3ef2ca
+     }
3ef2ca
+ #endif
3ef2ca
+ 
3ef2ca
  #ifdef FEAT_USR_CMDS
3ef2ca
      if (p == NULL)
3ef2ca
      {
3ef2ca
*** ../vim-7.4.413/src/fileio.c	2014-08-13 21:58:24.820885492 +0200
3ef2ca
--- src/fileio.c	2014-08-22 20:25:26.826955623 +0200
3ef2ca
***************
3ef2ca
*** 7641,7646 ****
3ef2ca
--- 7641,7647 ----
3ef2ca
      {"BufWriteCmd",	EVENT_BUFWRITECMD},
3ef2ca
      {"CmdwinEnter",	EVENT_CMDWINENTER},
3ef2ca
      {"CmdwinLeave",	EVENT_CMDWINLEAVE},
3ef2ca
+     {"CmdUndefined",	EVENT_CMDUNDEFINED},
3ef2ca
      {"ColorScheme",	EVENT_COLORSCHEME},
3ef2ca
      {"CompleteDone",	EVENT_COMPLETEDONE},
3ef2ca
      {"CursorHold",	EVENT_CURSORHOLD},
3ef2ca
***************
3ef2ca
*** 9159,9164 ****
3ef2ca
--- 9160,9183 ----
3ef2ca
      return (first_autopat[(int)EVENT_INSERTCHARPRE] != NULL);
3ef2ca
  }
3ef2ca
  
3ef2ca
+ /*
3ef2ca
+  * Return TRUE when there is an CmdUndefined autocommand defined.
3ef2ca
+  */
3ef2ca
+     int
3ef2ca
+ has_cmdundefined()
3ef2ca
+ {
3ef2ca
+     return (first_autopat[(int)EVENT_CMDUNDEFINED] != NULL);
3ef2ca
+ }
3ef2ca
+ 
3ef2ca
+ /*
3ef2ca
+  * Return TRUE when there is an FuncUndefined autocommand defined.
3ef2ca
+  */
3ef2ca
+     int
3ef2ca
+ has_funcundefined()
3ef2ca
+ {
3ef2ca
+     return (first_autopat[(int)EVENT_FUNCUNDEFINED] != NULL);
3ef2ca
+ }
3ef2ca
+ 
3ef2ca
      static int
3ef2ca
  apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
3ef2ca
      event_T	event;
3ef2ca
*** ../vim-7.4.413/src/proto/fileio.pro	2014-08-10 13:34:59.060785459 +0200
3ef2ca
--- src/proto/fileio.pro	2014-08-22 20:25:38.862955186 +0200
3ef2ca
***************
3ef2ca
*** 47,52 ****
3ef2ca
--- 47,54 ----
3ef2ca
  int has_textchanged __ARGS((void));
3ef2ca
  int has_textchangedI __ARGS((void));
3ef2ca
  int has_insertcharpre __ARGS((void));
3ef2ca
+ int has_cmdundefined __ARGS((void));
3ef2ca
+ int has_funcundefined __ARGS((void));
3ef2ca
  void block_autocmds __ARGS((void));
3ef2ca
  void unblock_autocmds __ARGS((void));
3ef2ca
  int is_autocmd_blocked __ARGS((void));
3ef2ca
*** ../vim-7.4.413/src/version.c	2014-08-22 18:44:30.307175276 +0200
3ef2ca
--- src/version.c	2014-08-22 20:55:31.406890176 +0200
3ef2ca
***************
3ef2ca
*** 743,744 ****
3ef2ca
--- 743,746 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     414,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
hundred-and-one symptoms of being an internet addict:
3ef2ca
44. Your friends no longer send you e-mail...they just log on to your IRC
3ef2ca
    channel.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///