File 6.3.023 of Package kvim

To: vim-dev@vim.org
Subject: Patch 6.3.023
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 6.3.023
Problem:    When the "to" part of a mapping starts with its "from" part,
	    abbreviations for the same characters is not possible.  For
	    example, when <Space> is mapped to something that starts with a
	    space, typing <Space> does not expand abbreviations.
Solution:   Only disable expanding abbreviations when a mapping is not
	    remapped, don't disable it when the RHS of a mapping starts with
	    the LHS.
Files:	    src/getchar.c, src/vim.h


*** ../vim-6.3.022/src/getchar.c	Wed Jun  9 14:56:25 2004
--- src/getchar.c	Sat Sep  4 18:16:26 2004
***************
*** 100,105 ****
--- 100,106 ----
  #define RM_YES		0	/* tb_noremap: remap */
  #define RM_NONE		1	/* tb_noremap: don't remap */
  #define RM_SCRIPT	2	/* tb_noremap: remap local script mappings */
+ #define RM_ABBR		4	/* tb_noremap: don't remap, do abbrev. */
  
  /* typebuf.tb_buf has three parts: room in front (for result of mappings), the
   * middle for typeahead and room for new characters (which needs to be 3 *
***************
*** 896,901 ****
--- 897,904 ----
   *
   * If noremap is REMAP_YES, new string can be mapped again.
   * If noremap is REMAP_NONE, new string cannot be mapped again.
+  * If noremap is REMAP_SKIP, fist char of new string cannot be mapped again,
+  * but abbreviations are allowed.
   * If noremap is REMAP_SCRIPT, new string cannot be mapped again, except for
   *			script-local mappings.
   * If noremap is > 0, that many characters of the new string cannot be mapped.
***************
*** 993,998 ****
--- 996,1003 ----
      /* If noremap == REMAP_SCRIPT: do remap script-local mappings. */
      if (noremap == REMAP_SCRIPT)
  	val = RM_SCRIPT;
+     else if (noremap == REMAP_SKIP)
+ 	val = RM_ABBR;
      else
  	val = RM_NONE;
  
***************
*** 1004,1010 ****
       * If noremap  > 0: "noremap" characters are not remappable, the rest
       *			mappable
       */
!     if (noremap < 0)
  	nrm = addlen;
      else
  	nrm = noremap;
--- 1009,1017 ----
       * If noremap  > 0: "noremap" characters are not remappable, the rest
       *			mappable
       */
!     if (noremap == REMAP_SKIP)
! 	nrm = 1;
!     else if (noremap < 0)
  	nrm = addlen;
      else
  	nrm = noremap;
***************
*** 1856,1863 ****
  			    && (no_zero_mapping == 0 || c1 != '0')
  			    && (typebuf.tb_maplen == 0
  				|| (p_remap
! 				    && typebuf.tb_noremap[typebuf.tb_off]
! 								  != RM_NONE))
  			    && !(p_paste && (State & (INSERT + CMDLINE)))
  			    && !(State == HITRETURN && (c1 == CAR || c1 == ' '))
  			    && State != ASKMORE
--- 1863,1870 ----
  			    && (no_zero_mapping == 0 || c1 != '0')
  			    && (typebuf.tb_maplen == 0
  				|| (p_remap
! 				    && (typebuf.tb_noremap[typebuf.tb_off]
! 						    & (RM_NONE|RM_ABBR)) == 0))
  			    && !(p_paste && (State & (INSERT + CMDLINE)))
  			    && !(State == HITRETURN && (c1 == CAR || c1 == ' '))
  			    && State != ASKMORE
***************
*** 1973,1979 ****
  				     * remapped, skip the entry.
  				     */
  				    for (n = mlen; --n >= 0; )
! 					if (*s++ == RM_NONE)
  					    break;
  				    if (n >= 0)
  					continue;
--- 1980,1986 ----
  				     * remapped, skip the entry.
  				     */
  				    for (n = mlen; --n >= 0; )
! 					if (*s++ & (RM_NONE|RM_ABBR))
  					    break;
  				    if (n >= 0)
  					continue;
***************
*** 2132,2138 ****
  							 + typebuf.tb_off, 1);
  				    }
  				    KeyNoremap = (typebuf.tb_noremap[
! 						typebuf.tb_off] != REMAP_YES);
  				    del_typebuf(1, 0);
  				}
  				break;	    /* got character, break for loop */
--- 2139,2146 ----
  							 + typebuf.tb_off, 1);
  				    }
  				    KeyNoremap = (typebuf.tb_noremap[
! 						   typebuf.tb_off]
! 						       & (RM_NONE|RM_SCRIPT));
  				    del_typebuf(1, 0);
  				}
  				break;	    /* got character, break for loop */
***************
*** 2233,2239 ****
  			/*
  			 * Insert the 'to' part in the typebuf.tb_buf.
  			 * If 'from' field is the same as the start of the
! 			 * 'to' field, don't remap the first character.
  			 * If m_noremap is set, don't remap the whole 'to'
  			 * part.
  			 */
--- 2241,2248 ----
  			/*
  			 * Insert the 'to' part in the typebuf.tb_buf.
  			 * If 'from' field is the same as the start of the
! 			 * 'to' field, don't remap the first character (but do
! 			 * allow abbreviations).
  			 * If m_noremap is set, don't remap the whole 'to'
  			 * part.
  			 */
***************
*** 2241,2248 ****
  				mp->m_noremap != REMAP_YES
  					    ? mp->m_noremap
  					    : STRNCMP(mp->m_str, mp->m_keys,
! 							       (size_t)keylen)
! 							      ? REMAP_YES : 1,
  				0, TRUE, cmd_silent || mp->m_silent) == FAIL)
  			{
  			    c = -1;
--- 2250,2257 ----
  				mp->m_noremap != REMAP_YES
  					    ? mp->m_noremap
  					    : STRNCMP(mp->m_str, mp->m_keys,
! 							  (size_t)keylen) != 0
! 						     ? REMAP_YES : REMAP_SKIP,
  				0, TRUE, cmd_silent || mp->m_silent) == FAIL)
  			{
  			    c = -1;
*** ../vim-6.3.022/src/vim.h	Wed Jun  9 14:56:26 2004
--- src/vim.h	Sat Sep  4 18:17:00 2004
***************
*** 726,731 ****
--- 726,732 ----
  #define REMAP_YES	0	/* allow remapping */
  #define REMAP_NONE	-1	/* no remapping */
  #define REMAP_SCRIPT	-2	/* remap script-local mappings only */
+ #define REMAP_SKIP	-3	/* no remapping for first char */
  
  /* Values for mch_call_shell() second argument */
  #define SHELL_FILTER	1	/* filtering text */
*** ../vim-6.3.022/src/version.c	Sat Sep  4 16:28:02 2004
--- src/version.c	Sat Sep  4 18:20:40 2004
***************
*** 643,644 ****
--- 643,646 ----
  {   /* Add new patch number below this line */
+ /**/
+     23,
  /**/

-- 
TALL KNIGHT: We shall say Ni! again to you if you do not appease us.
ARTHUR:      All right!  What do you want?
TALL KNIGHT: We want ... a shrubbery!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
openSUSE Build Service is sponsored by