Hi Ingo! On Fr, 12 Dez 2014, Ingo Karkat wrote:
> Hello Vim developers, > > patch 7.4.468 (BTW it doesn't appear in the list on > ftp://ftp.vim.org/vol/2/vim/patches/7.4/README) addressed > > > Issue 26: CTRL-C does not interrupt after it was mapped and then > > unmapped > > However, it apparently fails to consider the mapping _modes_ of > CTRL-C, so when I have such insert mode mapping, then do :cmap <C-c> > ... | cunmap <C-c>, the insert mode mapping (though it still is listed > by :imap) becomes ineffective! (Same for other mode combinations.) I > have various mappings that include the <C-c> key (have I mentioned I'm > running out of keys?), and all of these get broken because one of my > plugins temporarily sets up a :cmap <C-c>. > > > I've used the following scriptlet to bisect the problem: > > nnoremap <C-c> :quit!<CR> > nnoremap <C-x> :cquit!<CR> > cnoremap <C-c> dummy > cunmap <C-c> > echomsg "Press <C-c><C-x> now" > > Interestingly, it requires actual typed keys, even :call > feedkeys("\<C-c>", 't') doesn't work. > > I can reproduce this both on Windows/x64 and Linux/x64, up to the > current Vim 7.4.542. > > Christian (as the author of the original patch), I hope you'll be able > to get a fix for that! The fix is easy. Simply increment the mapped_ctrl_c flag when mapping CTRL-C and decrement it when unmapping. Then Ctrl-C will work as interrupt only, when ctrl-c is never mapped. diff --git a/src/getchar.c b/src/getchar.c --- a/src/getchar.c +++ b/src/getchar.c @@ -3707,9 +3707,9 @@ do_map(maptype, arg, mode, abbrev) { if (!did_it) retval = 2; /* no match */ - else if (*keys == Ctrl_C) + else if (*keys == Ctrl_C && mapped_ctrl_c) /* If CTRL-C has been unmapped, reuse it for Interrupting. */ - mapped_ctrl_c = FALSE; + mapped_ctrl_c--; goto theend; } @@ -3744,7 +3744,7 @@ do_map(maptype, arg, mode, abbrev) /* If CTRL-C has been mapped, don't always use it for Interrupting. */ if (*keys == Ctrl_C) - mapped_ctrl_c = TRUE; + mapped_ctrl_c++; mp->m_keys = vim_strsave(keys); mp->m_str = vim_strsave(rhs); For some reason, I can't come up with a test. Seems like ctrl-c is somehow special and whatever I do, it doesn't work as expected, so I leave this part out. Best, Christian -- Viel öfter kommt, was unverhofft, als man hofft. -- Plautus (Mostellaria) -- -- 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]. For more options, visit https://groups.google.com/d/optout.
