Karsten Hopp 7f399b
To: vim_dev@googlegroups.com
Karsten Hopp 7f399b
Subject: Patch 7.3.867
Karsten Hopp 7f399b
Fcc: outbox
Karsten Hopp 7f399b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 7f399b
Mime-Version: 1.0
Karsten Hopp 7f399b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 7f399b
Content-Transfer-Encoding: 8bit
Karsten Hopp 7f399b
------------
Karsten Hopp 7f399b
Karsten Hopp 7f399b
Patch 7.3.867
Karsten Hopp 7f399b
Problem:    Matchparen does not update match when using auto-indenting.
Karsten Hopp 7f399b
	    (Marc Aldorasi)
Karsten Hopp 7f399b
Solution:   Add the TextChanged and TextChangedI autocommand events.
Karsten Hopp 7f399b
Files:	    runtime/plugin/matchparen.vim, src/main.c, src/edit.c,
Karsten Hopp 7f399b
	    src/globals.h, src/vim.h, src/fileio.c, src/proto/fileio.pro,
Karsten Hopp 7f399b
	    runtime/doc/autocmd.txt
Karsten Hopp 7f399b
Karsten Hopp 7f399b
Karsten Hopp 7f399b
*** ../vim-7.3.866/runtime/plugin/matchparen.vim	2010-08-15 21:57:19.000000000 +0200
Karsten Hopp 7f399b
--- runtime/plugin/matchparen.vim	2013-03-19 13:16:46.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 1,6 ****
Karsten Hopp 7f399b
  " Vim plugin for showing matching parens
Karsten Hopp 7f399b
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
Karsten Hopp 7f399b
! " Last Change: 2008 Sep 03
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
  " Exit quickly when:
Karsten Hopp 7f399b
  " - this plugin was already loaded (or disabled)
Karsten Hopp 7f399b
--- 1,6 ----
Karsten Hopp 7f399b
  " Vim plugin for showing matching parens
Karsten Hopp 7f399b
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
Karsten Hopp 7f399b
! " Last Change: 2013 Mar 19
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
  " Exit quickly when:
Karsten Hopp 7f399b
  " - this plugin was already loaded (or disabled)
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 14,19 ****
Karsten Hopp 7f399b
--- 14,22 ----
Karsten Hopp 7f399b
  augroup matchparen
Karsten Hopp 7f399b
    " Replace all matchparen autocommands
Karsten Hopp 7f399b
    autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
Karsten Hopp 7f399b
+   if exists('##TextChanged')
Karsten Hopp 7f399b
+     autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair()
Karsten Hopp 7f399b
+   endif
Karsten Hopp 7f399b
  augroup END
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
  " Skip the rest if it was already done.
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 82,89 ****
Karsten Hopp 7f399b
    endif
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
    " When not in a string or comment ignore matches inside them.
Karsten Hopp 7f399b
    let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
Karsten Hopp 7f399b
! 	\ '=~?  "string\\|character\\|singlequote\\|comment"'
Karsten Hopp 7f399b
    execute 'if' s_skip '| let s_skip = 0 | endif'
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
    " Limit the search to lines visible in the window.
Karsten Hopp 7f399b
--- 85,93 ----
Karsten Hopp 7f399b
    endif
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
    " When not in a string or comment ignore matches inside them.
Karsten Hopp 7f399b
+   " We match "escape" for special items, such as lispEscapeSpecial.
Karsten Hopp 7f399b
    let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
Karsten Hopp 7f399b
! 	\ '=~?  "string\\|character\\|singlequote\\|escape\\|comment"'
Karsten Hopp 7f399b
    execute 'if' s_skip '| let s_skip = 0 | endif'
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
    " Limit the search to lines visible in the window.
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/main.c	2013-03-13 20:23:17.000000000 +0100
Karsten Hopp 7f399b
--- src/main.c	2013-03-19 13:00:34.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 1168,1173 ****
Karsten Hopp 7f399b
--- 1168,1186 ----
Karsten Hopp 7f399b
  	    }
Karsten Hopp 7f399b
  #endif
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
+ #ifdef FEAT_AUTOCMD
Karsten Hopp 7f399b
+ 	    /* Trigger TextChanged if b_changedtick differs. */
Karsten Hopp 7f399b
+ 	    if (!finish_op && has_textchanged()
Karsten Hopp 7f399b
+ 		    && last_changedtick != curbuf->b_changedtick)
Karsten Hopp 7f399b
+ 	    {
Karsten Hopp 7f399b
+ 		if (last_changedtick_buf == curbuf)
Karsten Hopp 7f399b
+ 		    apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL,
Karsten Hopp 7f399b
+ 							       FALSE, curbuf);
Karsten Hopp 7f399b
+ 		last_changedtick_buf = curbuf;
Karsten Hopp 7f399b
+ 		last_changedtick = curbuf->b_changedtick;
Karsten Hopp 7f399b
+ 	    }
Karsten Hopp 7f399b
+ #endif
Karsten Hopp 7f399b
+ 
Karsten Hopp 7f399b
  #if defined(FEAT_DIFF) && defined(FEAT_SCROLLBIND)
Karsten Hopp 7f399b
  	    /* Scroll-binding for diff mode may have been postponed until
Karsten Hopp 7f399b
  	     * here.  Avoids doing it for every change. */
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/edit.c	2013-03-07 19:38:49.000000000 +0100
Karsten Hopp 7f399b
--- src/edit.c	2013-03-19 13:08:46.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 1593,1598 ****
Karsten Hopp 7f399b
--- 1593,1613 ----
Karsten Hopp 7f399b
  	    last_cursormoved = curwin->w_cursor;
Karsten Hopp 7f399b
  	}
Karsten Hopp 7f399b
  #endif
Karsten Hopp 7f399b
+ #ifdef FEAT_AUTOCMD
Karsten Hopp 7f399b
+ 	/* Trigger TextChangedI if b_changedtick differs. */
Karsten Hopp 7f399b
+ 	if (!ready && has_textchangedI()
Karsten Hopp 7f399b
+ 		&& last_changedtick != curbuf->b_changedtick
Karsten Hopp 7f399b
+ # ifdef FEAT_INS_EXPAND
Karsten Hopp 7f399b
+ 		&& !pum_visible()
Karsten Hopp 7f399b
+ # endif
Karsten Hopp 7f399b
+ 		)
Karsten Hopp 7f399b
+ 	{
Karsten Hopp 7f399b
+ 	    if (last_changedtick_buf == curbuf)
Karsten Hopp 7f399b
+ 		apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
Karsten Hopp 7f399b
+ 	    last_changedtick_buf = curbuf;
Karsten Hopp 7f399b
+ 	    last_changedtick = curbuf->b_changedtick;
Karsten Hopp 7f399b
+ 	}
Karsten Hopp 7f399b
+ #endif
Karsten Hopp 7f399b
  	if (must_redraw)
Karsten Hopp 7f399b
  	    update_screen(0);
Karsten Hopp 7f399b
  	else if (clear_cmdline || redraw_cmdline)
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/globals.h	2013-02-26 14:56:24.000000000 +0100
Karsten Hopp 7f399b
--- src/globals.h	2013-03-19 13:11:35.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 1057,1067 ****
Karsten Hopp 7f399b
  EXTERN int	autocmd_bufnr INIT(= 0);     /* fnum for <abuf> on cmdline */
Karsten Hopp 7f399b
  EXTERN char_u	*autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
Karsten Hopp 7f399b
  EXTERN int	did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
Karsten Hopp 7f399b
! EXTERN pos_T	last_cursormoved	    /* for CursorMoved event */
Karsten Hopp 7f399b
  # ifdef DO_INIT
Karsten Hopp 7f399b
  			= INIT_POS_T(0, 0, 0)
Karsten Hopp 7f399b
  # endif
Karsten Hopp 7f399b
  			;
Karsten Hopp 7f399b
  #endif
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
  #ifdef FEAT_WINDOWS
Karsten Hopp 7f399b
--- 1057,1069 ----
Karsten Hopp 7f399b
  EXTERN int	autocmd_bufnr INIT(= 0);     /* fnum for <abuf> on cmdline */
Karsten Hopp 7f399b
  EXTERN char_u	*autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
Karsten Hopp 7f399b
  EXTERN int	did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
Karsten Hopp 7f399b
! EXTERN pos_T	last_cursormoved	      /* for CursorMoved event */
Karsten Hopp 7f399b
  # ifdef DO_INIT
Karsten Hopp 7f399b
  			= INIT_POS_T(0, 0, 0)
Karsten Hopp 7f399b
  # endif
Karsten Hopp 7f399b
  			;
Karsten Hopp 7f399b
+ EXTERN int	last_changedtick INIT(= 0);   /* for TextChanged event */
Karsten Hopp 7f399b
+ EXTERN buf_T	*last_changedtick_buf INIT(= NULL);
Karsten Hopp 7f399b
  #endif
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
  #ifdef FEAT_WINDOWS
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/vim.h	2013-02-26 14:56:24.000000000 +0100
Karsten Hopp 7f399b
--- src/vim.h	2013-03-19 13:07:00.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 1300,1305 ****
Karsten Hopp 7f399b
--- 1300,1307 ----
Karsten Hopp 7f399b
      EVENT_TABENTER,		/* after entering a tab page */
Karsten Hopp 7f399b
      EVENT_SHELLCMDPOST,		/* after ":!cmd" */
Karsten Hopp 7f399b
      EVENT_SHELLFILTERPOST,	/* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
Karsten Hopp 7f399b
+     EVENT_TEXTCHANGED,		/* text was modified */
Karsten Hopp 7f399b
+     EVENT_TEXTCHANGEDI,		/* text was modified in Insert mode*/
Karsten Hopp 7f399b
      NUM_EVENTS			/* MUST be the last one */
Karsten Hopp 7f399b
  };
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/fileio.c	2013-01-30 14:13:52.000000000 +0100
Karsten Hopp 7f399b
--- src/fileio.c	2013-03-19 13:08:31.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 7713,7718 ****
Karsten Hopp 7f399b
--- 7713,7720 ----
Karsten Hopp 7f399b
      {"TabLeave",	EVENT_TABLEAVE},
Karsten Hopp 7f399b
      {"TermChanged",	EVENT_TERMCHANGED},
Karsten Hopp 7f399b
      {"TermResponse",	EVENT_TERMRESPONSE},
Karsten Hopp 7f399b
+     {"TextChanged",	EVENT_TEXTCHANGED},
Karsten Hopp 7f399b
+     {"TextChangedI",	EVENT_TEXTCHANGEDI},
Karsten Hopp 7f399b
      {"User",		EVENT_USER},
Karsten Hopp 7f399b
      {"VimEnter",	EVENT_VIMENTER},
Karsten Hopp 7f399b
      {"VimLeave",	EVENT_VIMLEAVE},
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 9138,9143 ****
Karsten Hopp 7f399b
--- 9140,9163 ----
Karsten Hopp 7f399b
  }
Karsten Hopp 7f399b
  
Karsten Hopp 7f399b
  /*
Karsten Hopp 7f399b
+  * Return TRUE when there is a TextChanged autocommand defined.
Karsten Hopp 7f399b
+  */
Karsten Hopp 7f399b
+     int
Karsten Hopp 7f399b
+ has_textchanged()
Karsten Hopp 7f399b
+ {
Karsten Hopp 7f399b
+     return (first_autopat[(int)EVENT_TEXTCHANGED] != NULL);
Karsten Hopp 7f399b
+ }
Karsten Hopp 7f399b
+ 
Karsten Hopp 7f399b
+ /*
Karsten Hopp 7f399b
+  * Return TRUE when there is a TextChangedI autocommand defined.
Karsten Hopp 7f399b
+  */
Karsten Hopp 7f399b
+     int
Karsten Hopp 7f399b
+ has_textchangedI()
Karsten Hopp 7f399b
+ {
Karsten Hopp 7f399b
+     return (first_autopat[(int)EVENT_TEXTCHANGEDI] != NULL);
Karsten Hopp 7f399b
+ }
Karsten Hopp 7f399b
+ 
Karsten Hopp 7f399b
+ /*
Karsten Hopp 7f399b
   * Return TRUE when there is an InsertCharPre autocommand defined.
Karsten Hopp 7f399b
   */
Karsten Hopp 7f399b
      int
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/proto/fileio.pro	2012-12-05 19:13:11.000000000 +0100
Karsten Hopp 7f399b
--- src/proto/fileio.pro	2013-03-19 13:10:13.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 44,49 ****
Karsten Hopp 7f399b
--- 44,51 ----
Karsten Hopp 7f399b
  int trigger_cursorhold __ARGS((void));
Karsten Hopp 7f399b
  int has_cursormoved __ARGS((void));
Karsten Hopp 7f399b
  int has_cursormovedI __ARGS((void));
Karsten Hopp 7f399b
+ int has_textchanged __ARGS((void));
Karsten Hopp 7f399b
+ int has_textchangedI __ARGS((void));
Karsten Hopp 7f399b
  int has_insertcharpre __ARGS((void));
Karsten Hopp 7f399b
  void block_autocmds __ARGS((void));
Karsten Hopp 7f399b
  void unblock_autocmds __ARGS((void));
Karsten Hopp 7f399b
*** ../vim-7.3.866/runtime/doc/autocmd.txt	2012-03-07 20:13:44.000000000 +0100
Karsten Hopp 7f399b
--- runtime/doc/autocmd.txt	2013-03-19 13:22:37.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 805,817 ****
Karsten Hopp 7f399b
  TermResponse			After the response to |t_RV| is received from
Karsten Hopp 7f399b
  				the terminal.  The value of |v:termresponse|
Karsten Hopp 7f399b
  				can be used to do things depending on the
Karsten Hopp 7f399b
! 				terminal version.
Karsten Hopp 7f399b
  							*User*
Karsten Hopp 7f399b
  User				Never executed automatically.  To be used for
Karsten Hopp 7f399b
  				autocommands that are only executed with
Karsten Hopp 7f399b
  				":doautocmd".
Karsten Hopp 7f399b
  							*UserGettingBored*
Karsten Hopp 7f399b
! UserGettingBored		When the user hits CTRL-C.  Just kidding! :-)
Karsten Hopp 7f399b
  							*VimEnter*
Karsten Hopp 7f399b
  VimEnter			After doing all the startup stuff, including
Karsten Hopp 7f399b
  				loading .vimrc files, executing the "-c cmd"
Karsten Hopp 7f399b
--- 828,858 ----
Karsten Hopp 7f399b
  TermResponse			After the response to |t_RV| is received from
Karsten Hopp 7f399b
  				the terminal.  The value of |v:termresponse|
Karsten Hopp 7f399b
  				can be used to do things depending on the
Karsten Hopp 7f399b
! 				terminal version.  Note that this event may be
Karsten Hopp 7f399b
! 				triggered halfway executing another event,
Karsten Hopp 7f399b
! 				especially if file I/O, a shell command or
Karsten Hopp 7f399b
! 				anything else that takes time is involved.
Karsten Hopp 7f399b
! 							*TextChanged*
Karsten Hopp 7f399b
! TextChanged			After a change was made to the text in the
Karsten Hopp 7f399b
! 				current buffer in Normal mode.  That is when
Karsten Hopp 7f399b
! 				|b:changedtick| has changed.
Karsten Hopp 7f399b
! 				Not triggered when there is typeahead or when
Karsten Hopp 7f399b
! 				an operator is pending.
Karsten Hopp 7f399b
! 				Careful: This is triggered very often, don't
Karsten Hopp 7f399b
! 				do anything that the user does not expect or
Karsten Hopp 7f399b
! 				that is slow.
Karsten Hopp 7f399b
! 							*TextChangedI*
Karsten Hopp 7f399b
! TextChangedI			After a change was made to the text in the
Karsten Hopp 7f399b
! 				current buffer in Insert mode.
Karsten Hopp 7f399b
! 				Not triggered when the popup menu is visible.
Karsten Hopp 7f399b
! 				Otherwise the same as TextChanged.
Karsten Hopp 7f399b
  							*User*
Karsten Hopp 7f399b
  User				Never executed automatically.  To be used for
Karsten Hopp 7f399b
  				autocommands that are only executed with
Karsten Hopp 7f399b
  				":doautocmd".
Karsten Hopp 7f399b
  							*UserGettingBored*
Karsten Hopp 7f399b
! UserGettingBored		When the user presses the same key 42 times.
Karsten Hopp 7f399b
! 				Just kidding! :-)
Karsten Hopp 7f399b
  							*VimEnter*
Karsten Hopp 7f399b
  VimEnter			After doing all the startup stuff, including
Karsten Hopp 7f399b
  				loading .vimrc files, executing the "-c cmd"
Karsten Hopp 7f399b
*** ../vim-7.3.866/src/version.c	2013-03-19 12:35:33.000000000 +0100
Karsten Hopp 7f399b
--- src/version.c	2013-03-19 13:29:58.000000000 +0100
Karsten Hopp 7f399b
***************
Karsten Hopp 7f399b
*** 730,731 ****
Karsten Hopp 7f399b
--- 730,733 ----
Karsten Hopp 7f399b
  {   /* Add new patch number below this line */
Karsten Hopp 7f399b
+ /**/
Karsten Hopp 7f399b
+     867,
Karsten Hopp 7f399b
  /**/
Karsten Hopp 7f399b
Karsten Hopp 7f399b
-- 
Karsten Hopp 7f399b
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 7f399b
73. You give your dog used motherboards instead of bones
Karsten Hopp 7f399b
Karsten Hopp 7f399b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 7f399b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 7f399b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 7f399b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///