To: vim_dev@googlegroups.com Subject: Patch 7.4.2236 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2236 Problem: The 'langnoremap' option leads to double negatives. And it does not work for the last character of a mapping. Solution: Add 'langremap' with the opposite value. Keep 'langnoremap' for backwards compatibility. Make it work for the last character of a mapping. Make the test work. Files: runtime/doc/options.txt, runtime/defaults.vim, src/option.c, src/option.h, src/macros.h, src/testdir/test_mapping.vim *** ../vim-7.4.2235/runtime/doc/options.txt 2016-08-20 16:56:48.250624340 +0200 --- runtime/doc/options.txt 2016-08-21 16:42:21.557677230 +0200 *************** *** 4623,4635 **** feature} This option allows switching your keyboard into a special language mode. When you are typing text in Insert mode the characters are ! inserted directly. When in command mode the 'langmap' option takes care of translating these special characters to the original meaning of the key. This means you don't have to change the keyboard mode to be able to execute Normal mode commands. This is the opposite of the 'keymap' option, where characters are mapped in Insert mode. ! Also consider setting 'langnoremap' to avoid 'langmap' applies to characters resulting from a mapping. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. --- 4626,4638 ---- feature} This option allows switching your keyboard into a special language mode. When you are typing text in Insert mode the characters are ! inserted directly. When in Normal mode the 'langmap' option takes care of translating these special characters to the original meaning of the key. This means you don't have to change the keyboard mode to be able to execute Normal mode commands. This is the opposite of the 'keymap' option, where characters are mapped in Insert mode. ! Also consider resetting 'langremap' to avoid 'langmap' applies to characters resulting from a mapping. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. *************** *** 4686,4701 **** :source $VIMRUNTIME/menu.vim < Warning: This deletes all menus that you defined yourself! ! *'langnoremap'* *'lnr'* ! 'langnoremap' 'lnr' boolean (default off) global {not in Vi} {only available when compiled with the |+langmap| feature} ! When on, setting 'langmap' does not apply to characters resulting from a mapping. This basically means, if you noticed that setting ! 'langmap' disables some of your mappings, try setting this option. ! This option defaults to off for backwards compatibility. Set it on if that works for you to avoid mappings to break. *'laststatus'* *'ls'* --- 4689,4714 ---- :source $VIMRUNTIME/menu.vim < Warning: This deletes all menus that you defined yourself! ! *'langnoremap'* *'lnr'* *'nolangnoremap'* *'nolnr'* ! 'langnoremap' 'lnr' boolean (default off, set in |defaults.vim|) ! global ! {not in Vi} ! {only available when compiled with the |+langmap| ! feature} ! This is just like 'langremap' but with the value inverted. It only ! exists for backwards compatibility. When setting 'langremap' then ! 'langnoremap' is set to the inverted value, and the other way around. ! ! *'langremap'* *'lrm'* *'nolangremap'* *'nolrm'* ! 'langremap' 'lrm' boolean (default on, reset in |defaults.vim|) global {not in Vi} {only available when compiled with the |+langmap| feature} ! When off, setting 'langmap' does not apply to characters resulting from a mapping. This basically means, if you noticed that setting ! 'langmap' disables some of your mappings, try resetting this option. ! This option defaults to on for backwards compatibility. Set it off if that works for you to avoid mappings to break. *'laststatus'* *'ls'* *** ../vim-7.4.2235/runtime/defaults.vim 2016-08-20 19:22:13.412939701 +0200 --- runtime/defaults.vim 2016-08-21 16:35:40.737234768 +0200 *************** *** 1,7 **** " The default vimrc file. " " Maintainer: Bram Moolenaar ! " Last change: 2016 Aug 20 " " This is loaded if no vimrc file was found. " Except when Vim is run with "-u NONE" or "-C". --- 1,7 ---- " The default vimrc file. " " Maintainer: Bram Moolenaar ! " Last change: 2016 Aug 21 " " This is loaded if no vimrc file was found. " Except when Vim is run with "-u NONE" or "-C". *************** *** 107,115 **** \ | wincmd p | diffthis endif ! if has('langmap') && exists('+langnoremap') " Prevent that the langmap option applies to characters that result from a ! " mapping. If unset (default), this may break plugins (but it's backward " compatible). ! set langnoremap endif --- 107,115 ---- \ | wincmd p | diffthis endif ! if has('langmap') && exists('+langremap') " Prevent that the langmap option applies to characters that result from a ! " mapping. If set (default), this may break plugins (but it's backward " compatible). ! set nolangremap endif *** ../vim-7.4.2235/src/option.c 2016-08-14 19:54:16.328930182 +0200 --- src/option.c 2016-08-21 16:40:47.818509362 +0200 *************** *** 1705,1710 **** --- 1705,1717 ---- (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, + {"langremap", "lrm", P_BOOL|P_VI_DEF, + #ifdef FEAT_LANGMAP + (char_u *)&p_lrm, PV_NONE, + #else + (char_u *)NULL, PV_NONE, + #endif + {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, #ifdef FEAT_WINDOWS (char_u *)&p_ls, PV_NONE, *************** *** 7894,7899 **** --- 7901,7915 ---- compatible_set(); } + #ifdef FEAT_LANGMAP + if ((int *)varp == &p_lrm) + /* 'langremap' -> !'langnoremap' */ + p_lnr = !p_lrm; + else if ((int *)varp == &p_lnr) + /* 'langnoremap' -> !'langremap' */ + p_lrm = !p_lnr; + #endif + #ifdef FEAT_PERSISTENT_UNDO /* 'undofile' */ else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) *** ../vim-7.4.2235/src/option.h 2016-08-20 16:56:48.250624340 +0200 --- src/option.h 2016-08-21 16:41:02.458379407 +0200 *************** *** 604,609 **** --- 604,610 ---- #ifdef FEAT_LANGMAP EXTERN char_u *p_langmap; /* 'langmap'*/ EXTERN int p_lnr; /* 'langnoremap' */ + EXTERN int p_lrm; /* 'langremap' */ #endif #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) EXTERN char_u *p_lm; /* 'langmenu' */ *** ../vim-7.4.2235/src/macros.h 2016-08-17 21:31:54.437870436 +0200 --- src/macros.h 2016-08-21 17:26:37.514021722 +0200 *************** *** 135,141 **** do { \ if (*p_langmap \ && (condition) \ ! && (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \ && !KeyStuffed \ && (c) >= 0) \ { \ --- 135,141 ---- do { \ if (*p_langmap \ && (condition) \ ! && (p_lrm || (!p_lrm && KeyTyped)) \ && !KeyStuffed \ && (c) >= 0) \ { \ *************** *** 150,156 **** do { \ if (*p_langmap \ && (condition) \ ! && (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \ && !KeyStuffed \ && (c) >= 0 && (c) < 256) \ c = langmap_mapchar[c]; \ --- 150,156 ---- do { \ if (*p_langmap \ && (condition) \ ! && (p_lrm || (!p_lrm && KeyTyped)) \ && !KeyStuffed \ && (c) >= 0 && (c) < 256) \ c = langmap_mapchar[c]; \ *** ../vim-7.4.2235/src/testdir/test_mapping.vim 2016-08-14 16:07:44.725705357 +0200 --- src/testdir/test_mapping.vim 2016-08-21 17:39:10.999491069 +0200 *************** *** 35,63 **** endfunc func Test_map_langmap() ! " langmap should not get remapped in insert mode ! inoremap { FAIL_ilangmap ! set langmap=+{ langnoremap call feedkeys("Go+\", "xt") call assert_equal('+', getline('$')) ! ! " Insert-mode expr mapping with langmap ! inoremap { "FAIL_iexplangmap" call feedkeys("Go+\", "xt") call assert_equal('+', getline('$')) - iunmap { ! " langmap should not get remapped in Command-line mode ! cnoremap { FAIL_clangmap call feedkeys(":call append(line('$'), '+')\", "xt") call assert_equal('+', getline('$')) - cunmap { - " Command-line mode expr mapping with langmap - cnoremap { "FAIL_cexplangmap" - call feedkeys(":call append(line('$'), '+')\", "xt") - call assert_equal('+', getline('$')) - cunmap { set nomodified endfunc --- 35,107 ---- endfunc func Test_map_langmap() ! if !has('langmap') ! return ! endif ! ! " check langmap applies in normal mode ! set langmap=+- nolangremap ! new ! call setline(1, ['a', 'b', 'c']) ! 2 ! call assert_equal('b', getline('.')) ! call feedkeys("+", "xt") ! call assert_equal('a', getline('.')) ! ! " check no remapping ! map x + ! 2 ! call feedkeys("x", "xt") ! call assert_equal('c', getline('.')) ! ! " check with remapping ! set langremap ! 2 ! call feedkeys("x", "xt") ! call assert_equal('a', getline('.')) ! ! unmap x ! bwipe! ! ! " 'langnoremap' follows 'langremap' and vise versa ! set langremap ! set langnoremap ! call assert_equal(0, &langremap) ! set langremap ! call assert_equal(0, &langnoremap) ! set nolangremap ! call assert_equal(1, &langnoremap) ! ! " langmap should not apply in insert mode, 'langremap' doesn't matter ! set langmap=+{ nolangremap call feedkeys("Go+\", "xt") call assert_equal('+', getline('$')) ! set langmap=+{ langremap call feedkeys("Go+\", "xt") call assert_equal('+', getline('$')) ! " langmap used for register name in insert mode. ! call setreg('a', 'aaaa') ! call setreg('b', 'bbbb') ! call setreg('c', 'cccc') ! set langmap=ab langremap ! call feedkeys("Go\a\", "xt") ! call assert_equal('bbbb', getline('$')) ! call feedkeys("Go\\a\", "xt") ! call assert_equal('bbbb', getline('$')) ! " mapping does not apply ! imap c a ! call feedkeys("Go\c\", "xt") ! call assert_equal('cccc', getline('$')) ! imap a c ! call feedkeys("Go\a\", "xt") ! call assert_equal('bbbb', getline('$')) ! ! " langmap should not apply in Command-line mode ! set langmap=+{ nolangremap call feedkeys(":call append(line('$'), '+')\", "xt") call assert_equal('+', getline('$')) set nomodified endfunc *** ../vim-7.4.2235/src/version.c 2016-08-21 15:26:50.989702872 +0200 --- src/version.c 2016-08-21 17:43:01.537491309 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2236, /**/ -- Microsoft is to software what McDonalds is to gourmet cooking /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///