Karsten Hopp a7ea2b
To: vim_dev@googlegroups.com
Karsten Hopp a7ea2b
Subject: Patch 7.3.091
Karsten Hopp a7ea2b
Fcc: outbox
Karsten Hopp a7ea2b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp a7ea2b
Mime-Version: 1.0
Karsten Hopp a7ea2b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp a7ea2b
Content-Transfer-Encoding: 8bit
Karsten Hopp a7ea2b
------------
Karsten Hopp a7ea2b
Karsten Hopp a7ea2b
Patch 7.3.091
Karsten Hopp a7ea2b
Problem:    "vim -w foo" writes special key codes for removed escape
Karsten Hopp a7ea2b
	    sequences. (Josh Triplett)
Karsten Hopp a7ea2b
Solution:   Don't write K_IGNORE codes.
Karsten Hopp a7ea2b
Files:	    src/getchar.c, src/misc1.c, src/term.c, src/vim.h
Karsten Hopp a7ea2b
Karsten Hopp a7ea2b
Karsten Hopp a7ea2b
*** ../vim-7.3.090/src/getchar.c	2010-10-27 17:39:00.000000000 +0200
Karsten Hopp a7ea2b
--- src/getchar.c	2010-12-30 12:16:36.000000000 +0100
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 1506,1514 ****
Karsten Hopp a7ea2b
      }
Karsten Hopp a7ea2b
  }
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
- #define KL_PART_KEY -1		/* keylen value for incomplete key-code */
Karsten Hopp a7ea2b
- #define KL_PART_MAP -2		/* keylen value for incomplete mapping */
Karsten Hopp a7ea2b
- 
Karsten Hopp a7ea2b
  /*
Karsten Hopp a7ea2b
   * Get the next input character.
Karsten Hopp a7ea2b
   * Can return a special key or a multi-byte character.
Karsten Hopp a7ea2b
--- 1506,1511 ----
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2171,2177 ****
Karsten Hopp a7ea2b
  					if (!timedout)
Karsten Hopp a7ea2b
  					{
Karsten Hopp a7ea2b
  					    /* break at a partly match */
Karsten Hopp a7ea2b
! 					    keylen = KL_PART_MAP;
Karsten Hopp a7ea2b
  					    break;
Karsten Hopp a7ea2b
  					}
Karsten Hopp a7ea2b
  				    }
Karsten Hopp a7ea2b
--- 2168,2174 ----
Karsten Hopp a7ea2b
  					if (!timedout)
Karsten Hopp a7ea2b
  					{
Karsten Hopp a7ea2b
  					    /* break at a partly match */
Karsten Hopp a7ea2b
! 					    keylen = KEYLEN_PART_MAP;
Karsten Hopp a7ea2b
  					    break;
Karsten Hopp a7ea2b
  					}
Karsten Hopp a7ea2b
  				    }
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2192,2198 ****
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  			/* If no partly match found, use the longest full
Karsten Hopp a7ea2b
  			 * match. */
Karsten Hopp a7ea2b
! 			if (keylen != KL_PART_MAP)
Karsten Hopp a7ea2b
  			{
Karsten Hopp a7ea2b
  			    mp = mp_match;
Karsten Hopp a7ea2b
  			    keylen = mp_match_len;
Karsten Hopp a7ea2b
--- 2189,2195 ----
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  			/* If no partly match found, use the longest full
Karsten Hopp a7ea2b
  			 * match. */
Karsten Hopp a7ea2b
! 			if (keylen != KEYLEN_PART_MAP)
Karsten Hopp a7ea2b
  			{
Karsten Hopp a7ea2b
  			    mp = mp_match;
Karsten Hopp a7ea2b
  			    keylen = mp_match_len;
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2230,2236 ****
Karsten Hopp a7ea2b
  			}
Karsten Hopp a7ea2b
  			/* Need more chars for partly match. */
Karsten Hopp a7ea2b
  			if (mlen == typebuf.tb_len)
Karsten Hopp a7ea2b
! 			    keylen = KL_PART_KEY;
Karsten Hopp a7ea2b
  			else if (max_mlen < mlen)
Karsten Hopp a7ea2b
  			    /* no match, may have to check for termcode at
Karsten Hopp a7ea2b
  			     * next character */
Karsten Hopp a7ea2b
--- 2227,2233 ----
Karsten Hopp a7ea2b
  			}
Karsten Hopp a7ea2b
  			/* Need more chars for partly match. */
Karsten Hopp a7ea2b
  			if (mlen == typebuf.tb_len)
Karsten Hopp a7ea2b
! 			    keylen = KEYLEN_PART_KEY;
Karsten Hopp a7ea2b
  			else if (max_mlen < mlen)
Karsten Hopp a7ea2b
  			    /* no match, may have to check for termcode at
Karsten Hopp a7ea2b
  			     * next character */
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2238,2244 ****
Karsten Hopp a7ea2b
  		    }
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  		    if ((mp == NULL || max_mlen >= mp_match_len)
Karsten Hopp a7ea2b
! 						     && keylen != KL_PART_MAP)
Karsten Hopp a7ea2b
  		    {
Karsten Hopp a7ea2b
  			int	save_keylen = keylen;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
--- 2235,2241 ----
Karsten Hopp a7ea2b
  		    }
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  		    if ((mp == NULL || max_mlen >= mp_match_len)
Karsten Hopp a7ea2b
! 						 && keylen != KEYLEN_PART_MAP)
Karsten Hopp a7ea2b
  		    {
Karsten Hopp a7ea2b
  			int	save_keylen = keylen;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2264,2271 ****
Karsten Hopp a7ea2b
  			    /* If no termcode matched but 'pastetoggle'
Karsten Hopp a7ea2b
  			     * matched partially it's like an incomplete key
Karsten Hopp a7ea2b
  			     * sequence. */
Karsten Hopp a7ea2b
! 			    if (keylen == 0 && save_keylen == KL_PART_KEY)
Karsten Hopp a7ea2b
! 				keylen = KL_PART_KEY;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  			    /*
Karsten Hopp a7ea2b
  			     * When getting a partial match, but the last
Karsten Hopp a7ea2b
--- 2261,2268 ----
Karsten Hopp a7ea2b
  			    /* If no termcode matched but 'pastetoggle'
Karsten Hopp a7ea2b
  			     * matched partially it's like an incomplete key
Karsten Hopp a7ea2b
  			     * sequence. */
Karsten Hopp a7ea2b
! 			    if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
Karsten Hopp a7ea2b
! 				keylen = KEYLEN_PART_KEY;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  			    /*
Karsten Hopp a7ea2b
  			     * When getting a partial match, but the last
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2302,2308 ****
Karsten Hopp a7ea2b
  				    continue;
Karsten Hopp a7ea2b
  				}
Karsten Hopp a7ea2b
  				if (*s == NUL)	    /* need more characters */
Karsten Hopp a7ea2b
! 				    keylen = KL_PART_KEY;
Karsten Hopp a7ea2b
  			    }
Karsten Hopp a7ea2b
  			    if (keylen >= 0)
Karsten Hopp a7ea2b
  #endif
Karsten Hopp a7ea2b
--- 2299,2305 ----
Karsten Hopp a7ea2b
  				    continue;
Karsten Hopp a7ea2b
  				}
Karsten Hopp a7ea2b
  				if (*s == NUL)	    /* need more characters */
Karsten Hopp a7ea2b
! 				    keylen = KEYLEN_PART_KEY;
Karsten Hopp a7ea2b
  			    }
Karsten Hopp a7ea2b
  			    if (keylen >= 0)
Karsten Hopp a7ea2b
  #endif
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2339,2345 ****
Karsten Hopp a7ea2b
  			if (keylen > 0)	    /* full matching terminal code */
Karsten Hopp a7ea2b
  			{
Karsten Hopp a7ea2b
  #if defined(FEAT_GUI) && defined(FEAT_MENU)
Karsten Hopp a7ea2b
! 			    if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
Karsten Hopp a7ea2b
  					 && typebuf.tb_buf[typebuf.tb_off + 1]
Karsten Hopp a7ea2b
  								   == KS_MENU)
Karsten Hopp a7ea2b
  			    {
Karsten Hopp a7ea2b
--- 2336,2343 ----
Karsten Hopp a7ea2b
  			if (keylen > 0)	    /* full matching terminal code */
Karsten Hopp a7ea2b
  			{
Karsten Hopp a7ea2b
  #if defined(FEAT_GUI) && defined(FEAT_MENU)
Karsten Hopp a7ea2b
! 			    if (typebuf.tb_len >= 2
Karsten Hopp a7ea2b
! 				&& typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
Karsten Hopp a7ea2b
  					 && typebuf.tb_buf[typebuf.tb_off + 1]
Karsten Hopp a7ea2b
  								   == KS_MENU)
Karsten Hopp a7ea2b
  			    {
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2381,2387 ****
Karsten Hopp a7ea2b
  			/* Partial match: get some more characters.  When a
Karsten Hopp a7ea2b
  			 * matching mapping was found use that one. */
Karsten Hopp a7ea2b
  			if (mp == NULL || keylen < 0)
Karsten Hopp a7ea2b
! 			    keylen = KL_PART_KEY;
Karsten Hopp a7ea2b
  			else
Karsten Hopp a7ea2b
  			    keylen = mp_match_len;
Karsten Hopp a7ea2b
  		    }
Karsten Hopp a7ea2b
--- 2379,2385 ----
Karsten Hopp a7ea2b
  			/* Partial match: get some more characters.  When a
Karsten Hopp a7ea2b
  			 * matching mapping was found use that one. */
Karsten Hopp a7ea2b
  			if (mp == NULL || keylen < 0)
Karsten Hopp a7ea2b
! 			    keylen = KEYLEN_PART_KEY;
Karsten Hopp a7ea2b
  			else
Karsten Hopp a7ea2b
  			    keylen = mp_match_len;
Karsten Hopp a7ea2b
  		    }
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2553,2559 ****
Karsten Hopp a7ea2b
  #endif
Karsten Hopp a7ea2b
  			&& typebuf.tb_maplen == 0
Karsten Hopp a7ea2b
  			&& (State & INSERT)
Karsten Hopp a7ea2b
! 			&& (p_timeout || (keylen == KL_PART_KEY && p_ttimeout))
Karsten Hopp a7ea2b
  			&& (c = inchar(typebuf.tb_buf + typebuf.tb_off
Karsten Hopp a7ea2b
  						     + typebuf.tb_len, 3, 25L,
Karsten Hopp a7ea2b
  						 typebuf.tb_change_cnt)) == 0)
Karsten Hopp a7ea2b
--- 2551,2558 ----
Karsten Hopp a7ea2b
  #endif
Karsten Hopp a7ea2b
  			&& typebuf.tb_maplen == 0
Karsten Hopp a7ea2b
  			&& (State & INSERT)
Karsten Hopp a7ea2b
! 			&& (p_timeout
Karsten Hopp a7ea2b
! 			    || (keylen == KEYLEN_PART_KEY && p_ttimeout))
Karsten Hopp a7ea2b
  			&& (c = inchar(typebuf.tb_buf + typebuf.tb_off
Karsten Hopp a7ea2b
  						     + typebuf.tb_len, 3, 25L,
Karsten Hopp a7ea2b
  						 typebuf.tb_change_cnt)) == 0)
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2783,2791 ****
Karsten Hopp a7ea2b
  			    ? 0
Karsten Hopp a7ea2b
  			    : ((typebuf.tb_len == 0
Karsten Hopp a7ea2b
  				    || !(p_timeout || (p_ttimeout
Karsten Hopp a7ea2b
! 						   && keylen == KL_PART_KEY)))
Karsten Hopp a7ea2b
  				    ? -1L
Karsten Hopp a7ea2b
! 				    : ((keylen == KL_PART_KEY && p_ttm >= 0)
Karsten Hopp a7ea2b
  					    ? p_ttm
Karsten Hopp a7ea2b
  					    : p_tm)), typebuf.tb_change_cnt);
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
--- 2782,2790 ----
Karsten Hopp a7ea2b
  			    ? 0
Karsten Hopp a7ea2b
  			    : ((typebuf.tb_len == 0
Karsten Hopp a7ea2b
  				    || !(p_timeout || (p_ttimeout
Karsten Hopp a7ea2b
! 					       && keylen == KEYLEN_PART_KEY)))
Karsten Hopp a7ea2b
  				    ? -1L
Karsten Hopp a7ea2b
! 				    : ((keylen == KEYLEN_PART_KEY && p_ttm >= 0)
Karsten Hopp a7ea2b
  					    ? p_ttm
Karsten Hopp a7ea2b
  					    : p_tm)), typebuf.tb_change_cnt);
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
*** ../vim-7.3.090/src/misc1.c	2010-12-02 16:01:23.000000000 +0100
Karsten Hopp a7ea2b
--- src/misc1.c	2010-12-30 12:28:59.000000000 +0100
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 3114,3123 ****
Karsten Hopp a7ea2b
  	       && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
Karsten Hopp a7ea2b
  	    continue;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
! 	/* found a termcode: adjust length */
Karsten Hopp a7ea2b
! 	if (n > 0)
Karsten Hopp a7ea2b
  	    len = n;
Karsten Hopp a7ea2b
! 	if (len == 0)	    /* nothing typed yet */
Karsten Hopp a7ea2b
  	    continue;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  	/* Handle modifier and/or special key code. */
Karsten Hopp a7ea2b
--- 3114,3124 ----
Karsten Hopp a7ea2b
  	       && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
Karsten Hopp a7ea2b
  	    continue;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
! 	if (n == KEYLEN_REMOVED)  /* key code removed */
Karsten Hopp a7ea2b
! 	    continue;
Karsten Hopp a7ea2b
! 	if (n > 0)		/* found a termcode: adjust length */
Karsten Hopp a7ea2b
  	    len = n;
Karsten Hopp a7ea2b
! 	if (len == 0)		/* nothing typed yet */
Karsten Hopp a7ea2b
  	    continue;
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
  	/* Handle modifier and/or special key code. */
Karsten Hopp a7ea2b
*** ../vim-7.3.090/src/term.c	2010-08-15 21:57:32.000000000 +0200
Karsten Hopp a7ea2b
--- src/term.c	2010-12-30 12:14:48.000000000 +0100
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 3828,3833 ****
Karsten Hopp a7ea2b
--- 3831,3837 ----
Karsten Hopp a7ea2b
   * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off
Karsten Hopp a7ea2b
   * + max_offset].
Karsten Hopp a7ea2b
   * Return 0 for no match, -1 for partial match, > 0 for full match.
Karsten Hopp a7ea2b
+  * Return KEYLEN_REMOVED when a key code was deleted.
Karsten Hopp a7ea2b
   * With a match, the match is removed, the replacement code is inserted in
Karsten Hopp a7ea2b
   * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
Karsten Hopp a7ea2b
   * returned.
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 3845,3850 ****
Karsten Hopp a7ea2b
--- 3849,3855 ----
Karsten Hopp a7ea2b
      int		slen = 0;	/* init for GCC */
Karsten Hopp a7ea2b
      int		modslen;
Karsten Hopp a7ea2b
      int		len;
Karsten Hopp a7ea2b
+     int		retval = 0;
Karsten Hopp a7ea2b
      int		offset;
Karsten Hopp a7ea2b
      char_u	key_name[2];
Karsten Hopp a7ea2b
      int		modifiers;
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 4940,4945 ****
Karsten Hopp a7ea2b
--- 4945,4957 ----
Karsten Hopp a7ea2b
  #endif
Karsten Hopp a7ea2b
  		string[new_slen++] = key_name[1];
Karsten Hopp a7ea2b
  	}
Karsten Hopp a7ea2b
+ 	else if (new_slen == 0 && key_name[0] == KS_EXTRA
Karsten Hopp a7ea2b
+ 						  && key_name[1] == KE_IGNORE)
Karsten Hopp a7ea2b
+ 	{
Karsten Hopp a7ea2b
+ 	    /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED
Karsten Hopp a7ea2b
+ 	     * to indicate what happened. */
Karsten Hopp a7ea2b
+ 	    retval = KEYLEN_REMOVED;
Karsten Hopp a7ea2b
+ 	}
Karsten Hopp a7ea2b
  	else
Karsten Hopp a7ea2b
  	{
Karsten Hopp a7ea2b
  	    string[new_slen++] = K_SPECIAL;
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 4976,4982 ****
Karsten Hopp a7ea2b
  						   (size_t)(buflen - offset));
Karsten Hopp a7ea2b
  	    mch_memmove(buf + offset, string, (size_t)new_slen);
Karsten Hopp a7ea2b
  	}
Karsten Hopp a7ea2b
! 	return (len + extra + offset);
Karsten Hopp a7ea2b
      }
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
      return 0;			    /* no match found */
Karsten Hopp a7ea2b
--- 4988,4994 ----
Karsten Hopp a7ea2b
  						   (size_t)(buflen - offset));
Karsten Hopp a7ea2b
  	    mch_memmove(buf + offset, string, (size_t)new_slen);
Karsten Hopp a7ea2b
  	}
Karsten Hopp a7ea2b
! 	return retval == 0 ? (len + extra + offset) : retval;
Karsten Hopp a7ea2b
      }
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
      return 0;			    /* no match found */
Karsten Hopp a7ea2b
*** ../vim-7.3.090/src/vim.h	2010-12-17 20:23:56.000000000 +0100
Karsten Hopp a7ea2b
--- src/vim.h	2010-12-30 12:06:45.000000000 +0100
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 2211,2214 ****
Karsten Hopp a7ea2b
--- 2211,2218 ----
Karsten Hopp a7ea2b
  #define MSCR_LEFT	-1
Karsten Hopp a7ea2b
  #define MSCR_RIGHT	-2
Karsten Hopp a7ea2b
  
Karsten Hopp a7ea2b
+ #define KEYLEN_PART_KEY -1	/* keylen value for incomplete key-code */
Karsten Hopp a7ea2b
+ #define KEYLEN_PART_MAP -2	/* keylen value for incomplete mapping */
Karsten Hopp a7ea2b
+ #define KEYLEN_REMOVED  9999	/* keylen value for removed sequence */
Karsten Hopp a7ea2b
+ 
Karsten Hopp a7ea2b
  #endif /* VIM__H */
Karsten Hopp a7ea2b
*** ../vim-7.3.090/src/version.c	2010-12-30 11:41:05.000000000 +0100
Karsten Hopp a7ea2b
--- src/version.c	2010-12-30 12:24:56.000000000 +0100
Karsten Hopp a7ea2b
***************
Karsten Hopp a7ea2b
*** 716,717 ****
Karsten Hopp a7ea2b
--- 716,719 ----
Karsten Hopp a7ea2b
  {   /* Add new patch number below this line */
Karsten Hopp a7ea2b
+ /**/
Karsten Hopp a7ea2b
+     91,
Karsten Hopp a7ea2b
  /**/
Karsten Hopp a7ea2b
Karsten Hopp a7ea2b
-- 
Karsten Hopp a7ea2b
hundred-and-one symptoms of being an internet addict:
Karsten Hopp a7ea2b
56. You leave the modem speaker on after connecting because you think it
Karsten Hopp a7ea2b
    sounds like the ocean wind...the perfect soundtrack for "surfing the net".
Karsten Hopp a7ea2b
Karsten Hopp a7ea2b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp a7ea2b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp a7ea2b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp a7ea2b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///