Karsten Hopp 748f1e
To: vim_dev@googlegroups.com
Karsten Hopp 748f1e
Subject: Patch 7.3.1261
Karsten Hopp 748f1e
Fcc: outbox
Karsten Hopp 748f1e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 748f1e
Mime-Version: 1.0
Karsten Hopp 748f1e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 748f1e
Content-Transfer-Encoding: 8bit
Karsten Hopp 748f1e
------------
Karsten Hopp 748f1e
Karsten Hopp 748f1e
Patch 7.3.1261 (after patch 7.3.1179)
Karsten Hopp 748f1e
Problem:    A buffer-local language mapping from a keymap stops a global
Karsten Hopp 748f1e
	    insert mode mapping from working. (Ron Aaron)
Karsten Hopp 748f1e
Solution:   Do not wait for more characters to be typed only when the mapping
Karsten Hopp 748f1e
	    was defined with <nowait>.
Karsten Hopp 748f1e
Files:	    runtime/doc/map.txt, src/eval.c, src/getchar.c,
Karsten Hopp 748f1e
	    src/testdir/test75.in, src/testdir/test75.ok
Karsten Hopp 748f1e
Karsten Hopp 748f1e
Karsten Hopp 748f1e
*** ../vim-7.3.1260/runtime/doc/map.txt	2013-06-12 21:00:18.000000000 +0200
Karsten Hopp 748f1e
--- runtime/doc/map.txt	2013-06-29 13:55:01.000000000 +0200
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 159,167 ****
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  1.2 SPECIAL ARGUMENTS					*:map-arguments*
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
! "<buffer>", "<silent>", "<special>", "<script>", "<expr>" and "<unique>" can
Karsten Hopp 748f1e
! be used in any order.  They must appear right after the command, before any
Karsten Hopp 748f1e
! other arguments.
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  				*:map-local* *:map-<buffer>* *E224* *E225*
Karsten Hopp 748f1e
  If the first argument to one of these commands is "<buffer>" the mapping will
Karsten Hopp 748f1e
--- 159,167 ----
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  1.2 SPECIAL ARGUMENTS					*:map-arguments*
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
! "<buffer>", "<nowait>", "<silent>", "<special>", "<script>", "<expr>" and
Karsten Hopp 748f1e
! "<unique>" can be used in any order.  They must appear right after the
Karsten Hopp 748f1e
! command, before any other arguments.
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  				*:map-local* *:map-<buffer>* *E224* *E225*
Karsten Hopp 748f1e
  If the first argument to one of these commands is "<buffer>" the mapping will
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 169,175 ****
Karsten Hopp 748f1e
  	:map <buffer>  ,w  /[.,;]<CR>
Karsten Hopp 748f1e
  Then you can map ",w" to something else in another buffer: >
Karsten Hopp 748f1e
  	:map <buffer>  ,w  /[#&!]<CR>
Karsten Hopp 748f1e
! The local buffer mappings are used before the global ones.
Karsten Hopp 748f1e
  The "<buffer>" argument can also be used to clear mappings: >
Karsten Hopp 748f1e
  	:unmap <buffer> ,w
Karsten Hopp 748f1e
  	:mapclear <buffer>
Karsten Hopp 748f1e
--- 169,177 ----
Karsten Hopp 748f1e
  	:map <buffer>  ,w  /[.,;]<CR>
Karsten Hopp 748f1e
  Then you can map ",w" to something else in another buffer: >
Karsten Hopp 748f1e
  	:map <buffer>  ,w  /[#&!]<CR>
Karsten Hopp 748f1e
! The local buffer mappings are used before the global ones.  See <nowait> below
Karsten Hopp 748f1e
! to make a short local mapping not taking effect when a longer global one
Karsten Hopp 748f1e
! exists.
Karsten Hopp 748f1e
  The "<buffer>" argument can also be used to clear mappings: >
Karsten Hopp 748f1e
  	:unmap <buffer> ,w
Karsten Hopp 748f1e
  	:mapclear <buffer>
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 177,182 ****
Karsten Hopp 748f1e
--- 179,192 ----
Karsten Hopp 748f1e
  unloaded.  Just like local option values.
Karsten Hopp 748f1e
  Also see |map-precedence|.
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
+ 						*:map-<nowait>* *:map-nowait*
Karsten Hopp 748f1e
+ When defining a buffer-local mapping for "," there may be a global mapping
Karsten Hopp 748f1e
+ that starts with ",".  Then you need to type another character for Vim to know
Karsten Hopp 748f1e
+ whether to use the "," mapping or the longer one.  To avoid this add the
Karsten Hopp 748f1e
+ <nowait> argument.  Then the mapping will be used when it matches, Vim does
Karsten Hopp 748f1e
+ not wait for more characters to be typed.  However, if the characters were
Karsten Hopp 748f1e
+ already type they are used.
Karsten Hopp 748f1e
+ 
Karsten Hopp 748f1e
  						*:map-<silent>* *:map-silent*
Karsten Hopp 748f1e
  To define a mapping which will not be echoed on the command line, add
Karsten Hopp 748f1e
  "<silent>" as the first argument.  Example: >
Karsten Hopp 748f1e
*** ../vim-7.3.1260/src/eval.c	2013-06-24 22:17:27.000000000 +0200
Karsten Hopp 748f1e
--- src/eval.c	2013-06-29 13:32:35.000000000 +0200
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 13735,13740 ****
Karsten Hopp 748f1e
--- 13735,13741 ----
Karsten Hopp 748f1e
  	dict_add_nr_str(dict, "silent",  mp->m_silent  ? 1L : 0L, NULL);
Karsten Hopp 748f1e
  	dict_add_nr_str(dict, "sid",     (long)mp->m_script_ID, NULL);
Karsten Hopp 748f1e
  	dict_add_nr_str(dict, "buffer",  (long)buffer_local, NULL);
Karsten Hopp 748f1e
+ 	dict_add_nr_str(dict, "nowait",  mp->m_nowait  ? 1L : 0L, NULL);
Karsten Hopp 748f1e
  	dict_add_nr_str(dict, "mode",    0L, mapmode);
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  	vim_free(lhs);
Karsten Hopp 748f1e
*** ../vim-7.3.1260/src/getchar.c	2013-06-12 21:00:18.000000000 +0200
Karsten Hopp 748f1e
--- src/getchar.c	2013-06-29 13:43:27.000000000 +0200
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 1924,1930 ****
Karsten Hopp 748f1e
      mapblock_T	*mp;
Karsten Hopp 748f1e
  #ifdef FEAT_LOCALMAP
Karsten Hopp 748f1e
      mapblock_T	*mp2;
Karsten Hopp 748f1e
-     int		expecting_global_mappings;
Karsten Hopp 748f1e
  #endif
Karsten Hopp 748f1e
      mapblock_T	*mp_match;
Karsten Hopp 748f1e
      int		mp_match_len = 0;
Karsten Hopp 748f1e
--- 1924,1929 ----
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 2106,2114 ****
Karsten Hopp 748f1e
  			/* First try buffer-local mappings. */
Karsten Hopp 748f1e
  			mp = curbuf->b_maphash[MAP_HASH(local_State, c1)];
Karsten Hopp 748f1e
  			mp2 = maphash[MAP_HASH(local_State, c1)];
Karsten Hopp 748f1e
- 			expecting_global_mappings = (mp && mp2);
Karsten Hopp 748f1e
  			if (mp == NULL)
Karsten Hopp 748f1e
  			{
Karsten Hopp 748f1e
  			    mp = mp2;
Karsten Hopp 748f1e
  			    mp2 = NULL;
Karsten Hopp 748f1e
  			}
Karsten Hopp 748f1e
--- 2105,2113 ----
Karsten Hopp 748f1e
  			/* First try buffer-local mappings. */
Karsten Hopp 748f1e
  			mp = curbuf->b_maphash[MAP_HASH(local_State, c1)];
Karsten Hopp 748f1e
  			mp2 = maphash[MAP_HASH(local_State, c1)];
Karsten Hopp 748f1e
  			if (mp == NULL)
Karsten Hopp 748f1e
  			{
Karsten Hopp 748f1e
+ 			    /* There are no buffer-local mappings. */
Karsten Hopp 748f1e
  			    mp = mp2;
Karsten Hopp 748f1e
  			    mp2 = NULL;
Karsten Hopp 748f1e
  			}
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 2130,2145 ****
Karsten Hopp 748f1e
  #endif
Karsten Hopp 748f1e
  				(mp = mp->m_next))
Karsten Hopp 748f1e
  			{
Karsten Hopp 748f1e
- #ifdef FEAT_LOCALMAP
Karsten Hopp 748f1e
- 			    if (expecting_global_mappings && mp2 == NULL)
Karsten Hopp 748f1e
- 			    {
Karsten Hopp 748f1e
- 				/* This is the first global mapping. If we've
Karsten Hopp 748f1e
- 				 * got a complete buffer-local match, use it. */
Karsten Hopp 748f1e
- 				if (mp_match)
Karsten Hopp 748f1e
- 				    break;
Karsten Hopp 748f1e
- 				expecting_global_mappings = FALSE;
Karsten Hopp 748f1e
- 			    }
Karsten Hopp 748f1e
- #endif
Karsten Hopp 748f1e
  			    /*
Karsten Hopp 748f1e
  			     * Only consider an entry if the first character
Karsten Hopp 748f1e
  			     * matches and it is for the current state.
Karsten Hopp 748f1e
--- 2129,2134 ----
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 2215,2221 ****
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  				    if (keylen > typebuf.tb_len)
Karsten Hopp 748f1e
  				    {
Karsten Hopp 748f1e
! 					if (!timedout)
Karsten Hopp 748f1e
  					{
Karsten Hopp 748f1e
  					    /* break at a partly match */
Karsten Hopp 748f1e
  					    keylen = KEYLEN_PART_MAP;
Karsten Hopp 748f1e
--- 2204,2211 ----
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  				    if (keylen > typebuf.tb_len)
Karsten Hopp 748f1e
  				    {
Karsten Hopp 748f1e
! 					if (!timedout && !(mp_match != NULL
Karsten Hopp 748f1e
! 						       && mp_match->m_nowait))
Karsten Hopp 748f1e
  					{
Karsten Hopp 748f1e
  					    /* break at a partly match */
Karsten Hopp 748f1e
  					    keylen = KEYLEN_PART_MAP;
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 3207,3212 ****
Karsten Hopp 748f1e
--- 3197,3203 ----
Karsten Hopp 748f1e
      mapblock_T	**abbr_table;
Karsten Hopp 748f1e
      mapblock_T	**map_table;
Karsten Hopp 748f1e
      int		unique = FALSE;
Karsten Hopp 748f1e
+     int		nowait = FALSE;
Karsten Hopp 748f1e
      int		silent = FALSE;
Karsten Hopp 748f1e
      int		special = FALSE;
Karsten Hopp 748f1e
  #ifdef FEAT_EVAL
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 3225,3231 ****
Karsten Hopp 748f1e
      else
Karsten Hopp 748f1e
  	noremap = REMAP_YES;
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
!     /* Accept <buffer>, <silent>, <expr> <script> and <unique> in any order. */
Karsten Hopp 748f1e
      for (;;)
Karsten Hopp 748f1e
      {
Karsten Hopp 748f1e
  #ifdef FEAT_LOCALMAP
Karsten Hopp 748f1e
--- 3216,3223 ----
Karsten Hopp 748f1e
      else
Karsten Hopp 748f1e
  	noremap = REMAP_YES;
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
!     /* Accept <buffer>, <nowait>, <silent>, <expr> <script> and <unique> in
Karsten Hopp 748f1e
!      * any order. */
Karsten Hopp 748f1e
      for (;;)
Karsten Hopp 748f1e
      {
Karsten Hopp 748f1e
  #ifdef FEAT_LOCALMAP
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 3242,3247 ****
Karsten Hopp 748f1e
--- 3234,3249 ----
Karsten Hopp 748f1e
  #endif
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
  	/*
Karsten Hopp 748f1e
+ 	 * Check for "<nowait>": don't wait for more characters.
Karsten Hopp 748f1e
+ 	 */
Karsten Hopp 748f1e
+ 	if (STRNCMP(keys, "<nowait>", 8) == 0)
Karsten Hopp 748f1e
+ 	{
Karsten Hopp 748f1e
+ 	    keys = skipwhite(keys + 8);
Karsten Hopp 748f1e
+ 	    nowait = TRUE;
Karsten Hopp 748f1e
+ 	    continue;
Karsten Hopp 748f1e
+ 	}
Karsten Hopp 748f1e
+ 
Karsten Hopp 748f1e
+ 	/*
Karsten Hopp 748f1e
  	 * Check for "<silent>": don't echo commands.
Karsten Hopp 748f1e
  	 */
Karsten Hopp 748f1e
  	if (STRNCMP(keys, "<silent>", 8) == 0)
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 3607,3612 ****
Karsten Hopp 748f1e
--- 3609,3615 ----
Karsten Hopp 748f1e
  				vim_free(mp->m_orig_str);
Karsten Hopp 748f1e
  				mp->m_orig_str = vim_strsave(orig_rhs);
Karsten Hopp 748f1e
  				mp->m_noremap = noremap;
Karsten Hopp 748f1e
+ 				mp->m_nowait = nowait;
Karsten Hopp 748f1e
  				mp->m_silent = silent;
Karsten Hopp 748f1e
  				mp->m_mode = mode;
Karsten Hopp 748f1e
  #ifdef FEAT_EVAL
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 3695,3700 ****
Karsten Hopp 748f1e
--- 3698,3704 ----
Karsten Hopp 748f1e
      }
Karsten Hopp 748f1e
      mp->m_keylen = (int)STRLEN(mp->m_keys);
Karsten Hopp 748f1e
      mp->m_noremap = noremap;
Karsten Hopp 748f1e
+     mp->m_nowait = nowait;
Karsten Hopp 748f1e
      mp->m_silent = silent;
Karsten Hopp 748f1e
      mp->m_mode = mode;
Karsten Hopp 748f1e
  #ifdef FEAT_EVAL
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 4173,4178 ****
Karsten Hopp 748f1e
--- 4177,4187 ----
Karsten Hopp 748f1e
  		arg = skipwhite(arg + 8);
Karsten Hopp 748f1e
  		continue;
Karsten Hopp 748f1e
  	    }
Karsten Hopp 748f1e
+ 	    if (STRNCMP(arg, "<nowait>", 8) == 0)
Karsten Hopp 748f1e
+ 	    {
Karsten Hopp 748f1e
+ 		arg = skipwhite(arg + 8);
Karsten Hopp 748f1e
+ 		continue;
Karsten Hopp 748f1e
+ 	    }
Karsten Hopp 748f1e
  	    if (STRNCMP(arg, "<silent>", 8) == 0)
Karsten Hopp 748f1e
  	    {
Karsten Hopp 748f1e
  		arg = skipwhite(arg + 8);
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 4229,4235 ****
Karsten Hopp 748f1e
      {
Karsten Hopp 748f1e
  	count = 0;
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
! 	for (i = 0; i < 5; ++i)
Karsten Hopp 748f1e
  	{
Karsten Hopp 748f1e
  	    if (i == 0)
Karsten Hopp 748f1e
  		p = (char_u *)"<silent>";
Karsten Hopp 748f1e
--- 4238,4244 ----
Karsten Hopp 748f1e
      {
Karsten Hopp 748f1e
  	count = 0;
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
! 	for (i = 0; i < 6; ++i)
Karsten Hopp 748f1e
  	{
Karsten Hopp 748f1e
  	    if (i == 0)
Karsten Hopp 748f1e
  		p = (char_u *)"<silent>";
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 4245,4250 ****
Karsten Hopp 748f1e
--- 4254,4261 ----
Karsten Hopp 748f1e
  	    else if (i == 4 && !expand_buffer)
Karsten Hopp 748f1e
  		p = (char_u *)"<buffer>";
Karsten Hopp 748f1e
  #endif
Karsten Hopp 748f1e
+ 	    else if (i == 5)
Karsten Hopp 748f1e
+ 		p = (char_u *)"<nowait>";
Karsten Hopp 748f1e
  	    else
Karsten Hopp 748f1e
  		continue;
Karsten Hopp 748f1e
  
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 4857,4862 ****
Karsten Hopp 748f1e
--- 4868,4875 ----
Karsten Hopp 748f1e
  			return FAIL;
Karsten Hopp 748f1e
  		    if (buf != NULL && fputs(" <buffer>", fd) < 0)
Karsten Hopp 748f1e
  			return FAIL;
Karsten Hopp 748f1e
+ 		    if (mp->m_nowait && fputs(" <nowait>", fd) < 0)
Karsten Hopp 748f1e
+ 			return FAIL;
Karsten Hopp 748f1e
  		    if (mp->m_silent && fputs(" <silent>", fd) < 0)
Karsten Hopp 748f1e
  			return FAIL;
Karsten Hopp 748f1e
  #ifdef FEAT_EVAL
Karsten Hopp 748f1e
*** ../vim-7.3.1260/src/testdir/test75.in	2011-08-19 22:28:58.000000000 +0200
Karsten Hopp 748f1e
--- src/testdir/test75.in	2013-06-29 13:48:42.000000000 +0200
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 9,14 ****
Karsten Hopp 748f1e
--- 9,16 ----
Karsten Hopp 748f1e
  :call append('$', maparg('foo<C-V>'))
Karsten Hopp 748f1e
  :call append('$', string(maparg('foo<C-V>', '', 0, 1)))
Karsten Hopp 748f1e
  :call append('$', string(maparg('bar', '', 0, 1)))
Karsten Hopp 748f1e
+ :map <buffer> <nowait> foo bar
Karsten Hopp 748f1e
+ :call append('$', string(maparg('foo', '', 0, 1)))
Karsten Hopp 748f1e
  :"
Karsten Hopp 748f1e
  :map abc x<char-114>x
Karsten Hopp 748f1e
  :call append('$', maparg('abc'))
Karsten Hopp 748f1e
*** ../vim-7.3.1260/src/testdir/test75.ok	2011-08-19 22:28:58.000000000 +0200
Karsten Hopp 748f1e
--- src/testdir/test75.ok	2013-06-29 13:50:08.000000000 +0200
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 1,5 ****
Karsten Hopp 748f1e
  is<F4>foo
Karsten Hopp 748f1e
! {'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
Karsten Hopp 748f1e
! {'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
Karsten Hopp 748f1e
  xrx
Karsten Hopp 748f1e
  yRy
Karsten Hopp 748f1e
--- 1,6 ----
Karsten Hopp 748f1e
  is<F4>foo
Karsten Hopp 748f1e
! {'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
Karsten Hopp 748f1e
! {'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
Karsten Hopp 748f1e
! {'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1}
Karsten Hopp 748f1e
  xrx
Karsten Hopp 748f1e
  yRy
Karsten Hopp 748f1e
*** ../vim-7.3.1260/src/version.c	2013-06-29 12:58:27.000000000 +0200
Karsten Hopp 748f1e
--- src/version.c	2013-06-29 13:25:13.000000000 +0200
Karsten Hopp 748f1e
***************
Karsten Hopp 748f1e
*** 730,731 ****
Karsten Hopp 748f1e
--- 730,733 ----
Karsten Hopp 748f1e
  {   /* Add new patch number below this line */
Karsten Hopp 748f1e
+ /**/
Karsten Hopp 748f1e
+     1261,
Karsten Hopp 748f1e
  /**/
Karsten Hopp 748f1e
Karsten Hopp 748f1e
-- 
Karsten Hopp 748f1e
GUARD #2:  It could be carried by an African swallow!
Karsten Hopp 748f1e
GUARD #1:  Oh, yeah, an African swallow maybe, but not a European swallow,
Karsten Hopp 748f1e
           that's my point.
Karsten Hopp 748f1e
GUARD #2:  Oh, yeah, I agree with that...
Karsten Hopp 748f1e
                                  The Quest for the Holy Grail (Monty Python)
Karsten Hopp 748f1e
Karsten Hopp 748f1e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 748f1e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 748f1e
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 748f1e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///