To: vim_dev@googlegroups.com Subject: Patch 8.2.0867 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0867 Problem: Using \{xxx} for encoding a modifier is not nice. Solution: Use \<*xxx> instead, since it's the same as \ but producing a different code. Files: runtime/doc/eval.txt, src/typval.c, src/misc2.c, src/vim.h, src/testdir/test_backspace_opt.vim, src/testdir/test_mapping.vim, src/testdir/test_messages.vim *** ../vim-8.2.0866/runtime/doc/eval.txt 2020-05-31 15:41:53.155138624 +0200 --- runtime/doc/eval.txt 2020-05-31 21:36:42.705148553 +0200 *************** *** 1351,1358 **** To use the double quote character it must be escaped: "". Don't use to get a utf-8 character, use \uxxxx as mentioned above. ! \{xxx} like \ but prepends a modifier instead of including it in the ! character. E.g. "\" is one character 0x17 while "\{C-w}" is four bytes: 3 for the CTRL modifier and then character "W". Note that "\xff" is stored as the byte 255, which may be invalid in some --- 1353,1360 ---- To use the double quote character it must be escaped: "". Don't use to get a utf-8 character, use \uxxxx as mentioned above. ! \<*xxx> Like \ but prepends a modifier instead of including it in the ! character. E.g. "\" is one character 0x17 while "\<*C-w>" is four bytes: 3 for the CTRL modifier and then character "W". Note that "\xff" is stored as the byte 255, which may be invalid in some *** ../vim-8.2.0866/src/typval.c 2020-05-30 21:52:49.238816739 +0200 --- src/typval.c 2020-05-31 21:47:33.818535941 +0200 *************** *** 1285,1300 **** ++name; break; ! // Special key, e.g.: "\" or "\{C-W}" case '<': - case '{': { int flags = FSK_KEYCODE | FSK_IN_STRING; ! if (*p == '<') flags |= FSK_SIMPLIFY; - else - flags |= FSK_CURLY; extra = trans_special(&p, name, flags, NULL); if (extra != 0) { --- 1285,1297 ---- ++name; break; ! // Special key, e.g.: "\" case '<': { int flags = FSK_KEYCODE | FSK_IN_STRING; ! if (p[1] != '*') flags |= FSK_SIMPLIFY; extra = trans_special(&p, name, flags, NULL); if (extra != 0) { *** ../vim-8.2.0866/src/misc2.c 2020-05-30 21:52:49.238816739 +0200 --- src/misc2.c 2020-05-31 21:43:22.051584894 +0200 *************** *** 2772,2784 **** int modifiers; int bit; int key; - int endchar = (flags & FSK_CURLY) ? '}' : '>'; uvarnumber_T n; int l; src = *srcp; ! if (src[0] != ((flags & FSK_CURLY) ? '{' : '<')) return 0; // Find end of modifier list last_dash = src; --- 2772,2785 ---- int modifiers; int bit; int key; uvarnumber_T n; int l; src = *srcp; ! if (src[0] != '<') return 0; + if (src[1] == '*') // <*xxx>: do not simplify + ++src; // Find end of modifier list last_dash = src; *************** *** 2796,2810 **** // Anything accepted, like . // or are not special in strings as " is // the string delimiter. With a backslash it works: ! if (!(in_string && bp[1] == '"') && bp[l + 1] == endchar) bp += l; else if (in_string && bp[1] == '\\' && bp[2] == '"' ! && bp[3] == endchar) bp += 2; } } if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) ! bp += 3; // skip t_xx, xx may be '-' or '>'/'}' else if (STRNICMP(bp, "char-", 5) == 0) { vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE); --- 2797,2811 ---- // Anything accepted, like . // or are not special in strings as " is // the string delimiter. With a backslash it works: ! if (!(in_string && bp[1] == '"') && bp[l + 1] == '>') bp += l; else if (in_string && bp[1] == '\\' && bp[2] == '"' ! && bp[3] == '>') bp += 2; } } if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) ! bp += 3; // skip t_xx, xx may be '-' or '>' else if (STRNICMP(bp, "char-", 5) == 0) { vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE); *************** *** 2818,2824 **** } } ! if (*bp == endchar) // found matching '>' or '}' { end_of_name = bp + 1; --- 2819,2825 ---- } } ! if (*bp == '>') // found matching '>' { end_of_name = bp + 1; *************** *** 2864,2870 **** l = mb_ptr2len(last_dash + off); else l = 1; ! if (modifiers != 0 && last_dash[l + off] == endchar) key = PTR2CHAR(last_dash + off); else { --- 2865,2871 ---- l = mb_ptr2len(last_dash + off); else l = 1; ! if (modifiers != 0 && last_dash[l + off] == '>') key = PTR2CHAR(last_dash + off); else { *** ../vim-8.2.0866/src/vim.h 2020-05-30 21:52:49.238816739 +0200 --- src/vim.h 2020-05-31 21:47:41.930500507 +0200 *************** *** 2666,2671 **** #define FSK_KEEP_X_KEY 0x02 // don't translate xHome to Home key #define FSK_IN_STRING 0x04 // TRUE in string, double quote is escaped #define FSK_SIMPLIFY 0x08 // simplify and - #define FSK_CURLY 0x10 // {C-x} instead of #endif // VIM__H --- 2666,2670 ---- *** ../vim-8.2.0866/src/testdir/test_backspace_opt.vim 2020-05-30 21:52:49.242816719 +0200 --- src/testdir/test_backspace_opt.vim 2020-05-31 21:44:47.811249865 +0200 *************** *** 86,92 **** set cpo-=< inoremap ! exe "normal Avim3\{C-U}\\" iunmap exe "normal Avim4\\\\" --- 86,92 ---- set cpo-=< inoremap ! exe "normal Avim3\<*C-U>\\" iunmap exe "normal Avim4\\\\" *************** *** 96,102 **** exe "normal A vim6\Azwei\u\\\" inoremap ! exe "normal A vim7\{C-U}\{C-U}\\" call assert_equal([ \ "1 this shouldn't be deleted", --- 96,102 ---- exe "normal A vim6\Azwei\u\\\" inoremap ! exe "normal A vim7\<*C-U>\<*C-U>\\" call assert_equal([ \ "1 this shouldn't be deleted", *** ../vim-8.2.0866/src/testdir/test_mapping.vim 2020-05-30 21:52:49.242816719 +0200 --- src/testdir/test_mapping.vim 2020-05-31 21:45:43.307024388 +0200 *************** *** 76,82 **** inoremap cnoremap dummy cunmap ! call feedkeys("GoTEST2: CTRL-C |\{C-C}A|\", "xt") call assert_equal('TEST2: CTRL-C |A|', getline('$')) unmap! set nomodified --- 76,82 ---- inoremap cnoremap dummy cunmap ! call feedkeys("GoTEST2: CTRL-C |\<*C-C>A|\", "xt") call assert_equal('TEST2: CTRL-C |A|', getline('$')) unmap! set nomodified *************** *** 85,91 **** func Test_map_ctrl_c_visual() " mapping of ctrl-c in Visual mode vnoremap :$put ='vmap works' ! call feedkeys("GV\{C-C}\", "xt") call assert_equal('vmap works', getline('$')) vunmap set nomodified --- 85,91 ---- func Test_map_ctrl_c_visual() " mapping of ctrl-c in Visual mode vnoremap :$put ='vmap works' ! call feedkeys("GV\<*C-C>\", "xt") call assert_equal('vmap works', getline('$')) vunmap set nomodified *************** *** 235,241 **** func Test_map_meta_quotes() imap foo ! call feedkeys("Go-\{M-\"}-\", "xt") call assert_equal("-foo-", getline('$')) set nomodified iunmap --- 235,241 ---- func Test_map_meta_quotes() imap foo ! call feedkeys("Go-\<*M-\">-\", "xt") call assert_equal("-foo-", getline('$')) set nomodified iunmap *** ../vim-8.2.0866/src/testdir/test_messages.vim 2020-05-31 21:27:58.331221914 +0200 --- src/testdir/test_messages.vim 2020-05-31 21:46:07.982914331 +0200 *************** *** 306,312 **** func Test_mapping_at_hit_return_prompt() nnoremap :echo "hit ctrl-b" call feedkeys(":ls\", "xt") ! call feedkeys("\{C-B}", "xt") call assert_match('hit ctrl-b', Screenline(&lines - 1)) nunmap endfunc --- 306,312 ---- func Test_mapping_at_hit_return_prompt() nnoremap :echo "hit ctrl-b" call feedkeys(":ls\", "xt") ! call feedkeys("\<*C-B>", "xt") call assert_match('hit ctrl-b', Screenline(&lines - 1)) nunmap endfunc *** ../vim-8.2.0866/src/version.c 2020-05-31 21:27:58.335221898 +0200 --- src/version.c 2020-05-31 21:52:14.793334787 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 867, /**/ -- Google is kind of like Dr. Who's Tardis; it's weirder on the inside than on the outside... /// 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 ///