home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.1261 < prev    next >
Encoding:
Internet Message Format  |  2013-06-28  |  9.9 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.1261
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.1261 (after patch 7.3.1179)
  11. Problem:    A buffer-local language mapping from a keymap stops a global
  12.         insert mode mapping from working. (Ron Aaron)
  13. Solution:   Do not wait for more characters to be typed only when the mapping
  14.         was defined with <nowait>.
  15. Files:        runtime/doc/map.txt, src/eval.c, src/getchar.c,
  16.         src/testdir/test75.in, src/testdir/test75.ok
  17.  
  18.  
  19. *** ../vim-7.3.1260/runtime/doc/map.txt    2013-06-12 21:00:18.000000000 +0200
  20. --- runtime/doc/map.txt    2013-06-29 13:55:01.000000000 +0200
  21. ***************
  22. *** 159,167 ****
  23.   
  24.   1.2 SPECIAL ARGUMENTS                    *:map-arguments*
  25.   
  26. ! "<buffer>", "<silent>", "<special>", "<script>", "<expr>" and "<unique>" can
  27. ! be used in any order.  They must appear right after the command, before any
  28. ! other arguments.
  29.   
  30.                   *:map-local* *:map-<buffer>* *E224* *E225*
  31.   If the first argument to one of these commands is "<buffer>" the mapping will
  32. --- 159,167 ----
  33.   
  34.   1.2 SPECIAL ARGUMENTS                    *:map-arguments*
  35.   
  36. ! "<buffer>", "<nowait>", "<silent>", "<special>", "<script>", "<expr>" and
  37. ! "<unique>" can be used in any order.  They must appear right after the
  38. ! command, before any other arguments.
  39.   
  40.                   *:map-local* *:map-<buffer>* *E224* *E225*
  41.   If the first argument to one of these commands is "<buffer>" the mapping will
  42. ***************
  43. *** 169,175 ****
  44.       :map <buffer>  ,w  /[.,;]<CR>
  45.   Then you can map ",w" to something else in another buffer: >
  46.       :map <buffer>  ,w  /[#&!]<CR>
  47. ! The local buffer mappings are used before the global ones.
  48.   The "<buffer>" argument can also be used to clear mappings: >
  49.       :unmap <buffer> ,w
  50.       :mapclear <buffer>
  51. --- 169,177 ----
  52.       :map <buffer>  ,w  /[.,;]<CR>
  53.   Then you can map ",w" to something else in another buffer: >
  54.       :map <buffer>  ,w  /[#&!]<CR>
  55. ! The local buffer mappings are used before the global ones.  See <nowait> below
  56. ! to make a short local mapping not taking effect when a longer global one
  57. ! exists.
  58.   The "<buffer>" argument can also be used to clear mappings: >
  59.       :unmap <buffer> ,w
  60.       :mapclear <buffer>
  61. ***************
  62. *** 177,182 ****
  63. --- 179,192 ----
  64.   unloaded.  Just like local option values.
  65.   Also see |map-precedence|.
  66.   
  67. +                         *:map-<nowait>* *:map-nowait*
  68. + When defining a buffer-local mapping for "," there may be a global mapping
  69. + that starts with ",".  Then you need to type another character for Vim to know
  70. + whether to use the "," mapping or the longer one.  To avoid this add the
  71. + <nowait> argument.  Then the mapping will be used when it matches, Vim does
  72. + not wait for more characters to be typed.  However, if the characters were
  73. + already type they are used.
  74.                           *:map-<silent>* *:map-silent*
  75.   To define a mapping which will not be echoed on the command line, add
  76.   "<silent>" as the first argument.  Example: >
  77. *** ../vim-7.3.1260/src/eval.c    2013-06-24 22:17:27.000000000 +0200
  78. --- src/eval.c    2013-06-29 13:32:35.000000000 +0200
  79. ***************
  80. *** 13735,13740 ****
  81. --- 13735,13741 ----
  82.       dict_add_nr_str(dict, "silent",  mp->m_silent  ? 1L : 0L, NULL);
  83.       dict_add_nr_str(dict, "sid",     (long)mp->m_script_ID, NULL);
  84.       dict_add_nr_str(dict, "buffer",  (long)buffer_local, NULL);
  85. +     dict_add_nr_str(dict, "nowait",  mp->m_nowait  ? 1L : 0L, NULL);
  86.       dict_add_nr_str(dict, "mode",    0L, mapmode);
  87.   
  88.       vim_free(lhs);
  89. *** ../vim-7.3.1260/src/getchar.c    2013-06-12 21:00:18.000000000 +0200
  90. --- src/getchar.c    2013-06-29 13:43:27.000000000 +0200
  91. ***************
  92. *** 1924,1930 ****
  93.       mapblock_T    *mp;
  94.   #ifdef FEAT_LOCALMAP
  95.       mapblock_T    *mp2;
  96. -     int        expecting_global_mappings;
  97.   #endif
  98.       mapblock_T    *mp_match;
  99.       int        mp_match_len = 0;
  100. --- 1924,1929 ----
  101. ***************
  102. *** 2106,2114 ****
  103.               /* First try buffer-local mappings. */
  104.               mp = curbuf->b_maphash[MAP_HASH(local_State, c1)];
  105.               mp2 = maphash[MAP_HASH(local_State, c1)];
  106. -             expecting_global_mappings = (mp && mp2);
  107.               if (mp == NULL)
  108.               {
  109.                   mp = mp2;
  110.                   mp2 = NULL;
  111.               }
  112. --- 2105,2113 ----
  113.               /* First try buffer-local mappings. */
  114.               mp = curbuf->b_maphash[MAP_HASH(local_State, c1)];
  115.               mp2 = maphash[MAP_HASH(local_State, c1)];
  116.               if (mp == NULL)
  117.               {
  118. +                 /* There are no buffer-local mappings. */
  119.                   mp = mp2;
  120.                   mp2 = NULL;
  121.               }
  122. ***************
  123. *** 2130,2145 ****
  124.   #endif
  125.                   (mp = mp->m_next))
  126.               {
  127. - #ifdef FEAT_LOCALMAP
  128. -                 if (expecting_global_mappings && mp2 == NULL)
  129. -                 {
  130. -                 /* This is the first global mapping. If we've
  131. -                  * got a complete buffer-local match, use it. */
  132. -                 if (mp_match)
  133. -                     break;
  134. -                 expecting_global_mappings = FALSE;
  135. -                 }
  136. - #endif
  137.                   /*
  138.                    * Only consider an entry if the first character
  139.                    * matches and it is for the current state.
  140. --- 2129,2134 ----
  141. ***************
  142. *** 2215,2221 ****
  143.   
  144.                       if (keylen > typebuf.tb_len)
  145.                       {
  146. !                     if (!timedout)
  147.                       {
  148.                           /* break at a partly match */
  149.                           keylen = KEYLEN_PART_MAP;
  150. --- 2204,2211 ----
  151.   
  152.                       if (keylen > typebuf.tb_len)
  153.                       {
  154. !                     if (!timedout && !(mp_match != NULL
  155. !                                && mp_match->m_nowait))
  156.                       {
  157.                           /* break at a partly match */
  158.                           keylen = KEYLEN_PART_MAP;
  159. ***************
  160. *** 3207,3212 ****
  161. --- 3197,3203 ----
  162.       mapblock_T    **abbr_table;
  163.       mapblock_T    **map_table;
  164.       int        unique = FALSE;
  165. +     int        nowait = FALSE;
  166.       int        silent = FALSE;
  167.       int        special = FALSE;
  168.   #ifdef FEAT_EVAL
  169. ***************
  170. *** 3225,3231 ****
  171.       else
  172.       noremap = REMAP_YES;
  173.   
  174. !     /* Accept <buffer>, <silent>, <expr> <script> and <unique> in any order. */
  175.       for (;;)
  176.       {
  177.   #ifdef FEAT_LOCALMAP
  178. --- 3216,3223 ----
  179.       else
  180.       noremap = REMAP_YES;
  181.   
  182. !     /* Accept <buffer>, <nowait>, <silent>, <expr> <script> and <unique> in
  183. !      * any order. */
  184.       for (;;)
  185.       {
  186.   #ifdef FEAT_LOCALMAP
  187. ***************
  188. *** 3242,3247 ****
  189. --- 3234,3249 ----
  190.   #endif
  191.   
  192.       /*
  193. +      * Check for "<nowait>": don't wait for more characters.
  194. +      */
  195. +     if (STRNCMP(keys, "<nowait>", 8) == 0)
  196. +     {
  197. +         keys = skipwhite(keys + 8);
  198. +         nowait = TRUE;
  199. +         continue;
  200. +     }
  201. +     /*
  202.        * Check for "<silent>": don't echo commands.
  203.        */
  204.       if (STRNCMP(keys, "<silent>", 8) == 0)
  205. ***************
  206. *** 3607,3612 ****
  207. --- 3609,3615 ----
  208.                   vim_free(mp->m_orig_str);
  209.                   mp->m_orig_str = vim_strsave(orig_rhs);
  210.                   mp->m_noremap = noremap;
  211. +                 mp->m_nowait = nowait;
  212.                   mp->m_silent = silent;
  213.                   mp->m_mode = mode;
  214.   #ifdef FEAT_EVAL
  215. ***************
  216. *** 3695,3700 ****
  217. --- 3698,3704 ----
  218.       }
  219.       mp->m_keylen = (int)STRLEN(mp->m_keys);
  220.       mp->m_noremap = noremap;
  221. +     mp->m_nowait = nowait;
  222.       mp->m_silent = silent;
  223.       mp->m_mode = mode;
  224.   #ifdef FEAT_EVAL
  225. ***************
  226. *** 4173,4178 ****
  227. --- 4177,4187 ----
  228.           arg = skipwhite(arg + 8);
  229.           continue;
  230.           }
  231. +         if (STRNCMP(arg, "<nowait>", 8) == 0)
  232. +         {
  233. +         arg = skipwhite(arg + 8);
  234. +         continue;
  235. +         }
  236.           if (STRNCMP(arg, "<silent>", 8) == 0)
  237.           {
  238.           arg = skipwhite(arg + 8);
  239. ***************
  240. *** 4229,4235 ****
  241.       {
  242.       count = 0;
  243.   
  244. !     for (i = 0; i < 5; ++i)
  245.       {
  246.           if (i == 0)
  247.           p = (char_u *)"<silent>";
  248. --- 4238,4244 ----
  249.       {
  250.       count = 0;
  251.   
  252. !     for (i = 0; i < 6; ++i)
  253.       {
  254.           if (i == 0)
  255.           p = (char_u *)"<silent>";
  256. ***************
  257. *** 4245,4250 ****
  258. --- 4254,4261 ----
  259.           else if (i == 4 && !expand_buffer)
  260.           p = (char_u *)"<buffer>";
  261.   #endif
  262. +         else if (i == 5)
  263. +         p = (char_u *)"<nowait>";
  264.           else
  265.           continue;
  266.   
  267. ***************
  268. *** 4857,4862 ****
  269. --- 4868,4875 ----
  270.               return FAIL;
  271.               if (buf != NULL && fputs(" <buffer>", fd) < 0)
  272.               return FAIL;
  273. +             if (mp->m_nowait && fputs(" <nowait>", fd) < 0)
  274. +             return FAIL;
  275.               if (mp->m_silent && fputs(" <silent>", fd) < 0)
  276.               return FAIL;
  277.   #ifdef FEAT_EVAL
  278. *** ../vim-7.3.1260/src/testdir/test75.in    2011-08-19 22:28:58.000000000 +0200
  279. --- src/testdir/test75.in    2013-06-29 13:48:42.000000000 +0200
  280. ***************
  281. *** 9,14 ****
  282. --- 9,16 ----
  283.   :call append('$', maparg('foo<C-V>'))
  284.   :call append('$', string(maparg('foo<C-V>', '', 0, 1)))
  285.   :call append('$', string(maparg('bar', '', 0, 1)))
  286. + :map <buffer> <nowait> foo bar
  287. + :call append('$', string(maparg('foo', '', 0, 1)))
  288.   :"
  289.   :map abc x<char-114>x
  290.   :call append('$', maparg('abc'))
  291. *** ../vim-7.3.1260/src/testdir/test75.ok    2011-08-19 22:28:58.000000000 +0200
  292. --- src/testdir/test75.ok    2013-06-29 13:50:08.000000000 +0200
  293. ***************
  294. *** 1,5 ****
  295.   is<F4>foo
  296. ! {'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
  297. ! {'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
  298.   xrx
  299.   yRy
  300. --- 1,6 ----
  301.   is<F4>foo
  302. ! {'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
  303. ! {'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
  304. ! {'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1}
  305.   xrx
  306.   yRy
  307. *** ../vim-7.3.1260/src/version.c    2013-06-29 12:58:27.000000000 +0200
  308. --- src/version.c    2013-06-29 13:25:13.000000000 +0200
  309. ***************
  310. *** 730,731 ****
  311. --- 730,733 ----
  312.   {   /* Add new patch number below this line */
  313. + /**/
  314. +     1261,
  315.   /**/
  316.  
  317. -- 
  318. GUARD #2:  It could be carried by an African swallow!
  319. GUARD #1:  Oh, yeah, an African swallow maybe, but not a European swallow,
  320.            that's my point.
  321. GUARD #2:  Oh, yeah, I agree with that...
  322.                                   The Quest for the Holy Grail (Monty Python)
  323.  
  324.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  325. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  326. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  327.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  328.