Patch 9.0.0794
Problem: There is no way to find out if an escape sequence with
modifyOtherKeys has been seen.
Solution: Add a notice with ":verbose map".
Files: runtime/doc/map.txt, src/map.c
*** ../vim-9.0.0793/runtime/doc/map.txt 2022-09-01 12:58:46.580970180 +0100
--- runtime/doc/map.txt 2022-10-19 12:55:31.898053220 +0100
***************
*** 984,989 ****
--- 989,999 ----
WARNING: if you map <C-[> you may very well break any key codes that start
with Esc. Make sure it comes AFTER other mappings.
+ Vim automatically detects if the modifyOtherKeys mode was enabled when it
+ spots an escape sequence that must have been created by it. To see if Vim
+ detected such an escape sequence use `:verbose map`, the first line will then
+ show "Seen modifyOtherKeys: true" (possibly translated).
+
A known side effect is that in Insert mode the raw escape sequence is inserted
after the CTRL-V key. This can be used to check whether modifyOtherKeys is
enabled: In Insert mode type CTRL-SHIFT-V CTRL-V, if you get one byte then
*** ../vim-9.0.0793/src/map.c 2022-10-04 20:14:23.461997287 +0100
--- src/map.c 2022-10-19 13:04:52.460238009 +0100
***************
*** 136,141 ****
--- 136,144 ----
return (char_u *)mapmode.ga_data;
}
+ /*
+ * Output a line for one mapping.
+ */
static void
showmap(
mapblock_T *mp,
***************
*** 282,287 ****
--- 285,345 ----
}
/*
+ * List mappings. When "haskey" is FALSE all mappings, otherwise mappings
that
+ * match "keys[keys_len]".
+ */
+ static void
+ list_mappings(
+ int keyround,
+ int abbrev,
+ int haskey,
+ char_u *keys,
+ int keys_len,
+ int mode,
+ int *did_local)
+ {
+ if (p_verbose > 0 && keyround == 1 && seenModifyOtherKeys)
+ msg_puts(_("Seen modifyOtherKeys: true"));
+
+ // need to loop over all global hash lists
+ for (int hash = 0; hash < 256 && !got_int; ++hash)
+ {
+ mapblock_T *mp;
+
+ if (abbrev)
+ {
+ if (hash != 0) // there is only one abbreviation list
+ break;
+ mp = curbuf->b_first_abbr;
+ }
+ else
+ mp = curbuf->b_maphash[hash];
+ for ( ; mp != NULL && !got_int; mp = mp->m_next)
+ {
+ // check entries with the same mode
+ if (!mp->m_simplified && (mp->m_mode & mode) != 0)
+ {
+ if (!haskey) // show all entries
+ {
+ showmap(mp, TRUE);
+ *did_local = TRUE;
+ }
+ else
+ {
+ int n = mp->m_keylen;
+ if (STRNCMP(mp->m_keys, keys,
+ (size_t)(n < keys_len ? n : keys_len)) == 0)
+ {
+ showmap(mp, TRUE);
+ *did_local = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
* map[!] : show all key mappings
* map[!] {lhs} : show key mapping for {lhs}
* map[!] {lhs} {rhs} : set key mapping for {lhs} to {rhs}
***************
*** 503,510 ****
int did_local = FALSE;
int keyround1_simplified = keyround == 1 && did_simplify;
int round;
- int hash;
- int new_hash;
if (keyround == 2)
{
--- 561,566 ----
***************
*** 585,591 ****
&& haskey && hasarg && maptype != MAPTYPE_UNMAP)
{
// need to loop over all global hash lists
! for (hash = 0; hash < 256 && !got_int; ++hash)
{
if (abbrev)
{
--- 641,647 ----
&& haskey && hasarg && maptype != MAPTYPE_UNMAP)
{
// need to loop over all global hash lists
! for (int hash = 0; hash < 256 && !got_int; ++hash)
{
if (abbrev)
{
***************
*** 619,660 ****
// When listing global mappings, also list buffer-local ones here.
if (map_table != curbuf->b_maphash && !hasarg
&& maptype != MAPTYPE_UNMAP)
! {
! // need to loop over all global hash lists
! for (hash = 0; hash < 256 && !got_int; ++hash)
! {
! if (abbrev)
! {
! if (hash != 0) // there is only one abbreviation list
! break;
! mp = curbuf->b_first_abbr;
! }
! else
! mp = curbuf->b_maphash[hash];
! for ( ; mp != NULL && !got_int; mp = mp->m_next)
! {
! // check entries with the same mode
! if (!mp->m_simplified && (mp->m_mode & mode) != 0)
! {
! if (!haskey) // show all entries
! {
! showmap(mp, TRUE);
! did_local = TRUE;
! }
! else
! {
! n = mp->m_keylen;
! if (STRNCMP(mp->m_keys, keys,
! (size_t)(n < len ? n : len)) == 0)
! {
! showmap(mp, TRUE);
! did_local = TRUE;
! }
! }
! }
! }
! }
! }
// Find an entry in the maphash[] list that matches.
// For :unmap we may loop two times: once to try to unmap an entry with
--- 675,682 ----
// When listing global mappings, also list buffer-local ones here.
if (map_table != curbuf->b_maphash && !hasarg
&& maptype != MAPTYPE_UNMAP)
! list_mappings(keyround, abbrev, haskey, keys, len,
! mode, &did_local);
// Find an entry in the maphash[] list that matches.
// For :unmap we may loop two times: once to try to unmap an entry with
***************
*** 666,672 ****
&& !did_it && !got_int; ++round)
{
// need to loop over all hash lists
! for (hash = 0; hash < 256 && !got_int; ++hash)
{
if (abbrev)
{
--- 688,694 ----
&& !did_it && !got_int; ++round)
{
// need to loop over all hash lists
! for (int hash = 0; hash < 256 && !got_int; ++hash)
{
if (abbrev)
{
***************
*** 792,798 ****
// May need to put this entry into another hash
// list.
! new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]);
if (!abbrev && new_hash != hash)
{
*mpp = mp->m_next;
--- 814,820 ----
// May need to put this entry into another hash
// list.
! int new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]);
if (!abbrev && new_hash != hash)
{
*mpp = mp->m_next;
*** ../vim-9.0.0793/src/version.c 2022-10-19 11:54:42.929834804 +0100
--- src/version.c 2022-10-19 12:56:55.913924863 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 794,
/**/
--
INSPECTOR END OF FILM: Move along. There's nothing to see! Keep moving!
[Suddenly he notices the cameras.]
INSPECTOR END OF FILM: (to Camera) All right, put that away sonny.
[He walks over to it and puts his hand over the lens.]
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20221019120739.6E53A1C0EE2%40moolenaar.net.