-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 13-Dec-2014 14:37, Christian Brabandt wrote:
> 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.
Thank you Christian! Doesn't this have to consider the current mode?
So when I have an :imap <C-c>, that mapping is used in insert mode,
but when I press <C-c> in normal mode (or any other), it interrupts.
Also, I wonder whether this increment / decrement is robust when using
:map <buffer> <C-c>; the applicability is then dependent on the
current buffer, and one usually don't :unmap <buffer>, but just
discards the buffer.
Nonetheless, I think your patch is an improvement and allows to use my
mentioned plugins without any issue. I'll try it out on Monday and
report back any issue.
> 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.
Yeah, that's probably why my scriptlet needed explicit user input,
too. I also couldn't reproduce the issue with :call feedkeys("\<C-c>",
't') somehow.
- -- regards, ingo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
iQEcBAEBAgAGBQJUjE94AAoJEA7ziXlAzQ/vQfoIAI8AOEYlMGK/237JjjUNTiU7
2XAQ+aEs8LpLz4f+bETwpfMtLa1hcaFwPHkEMJCXvhaYyWFZZghhNUG9OP0LGEAJ
5lRTz/JLKedpN2Itguizv2wOnRJ1s67vCWpQ/2VGMqc313dH/ewOFCuh7+NaNisE
Ih0qHGCtDPOZu0NnWArjKuax1H44JnMdVcdtxC06B73aPMFGfV6XwE3yVBDg2Xg8
mq+Ku/TeHAM6NvpOa3mhEUUasAr1vatYgswOOuMiDvLeUNBoXADBl9PyB1Rmticu
qoiYnIKFuLRjxV0EPdWpskoMBcZ2lcrpfauT7K9esXjdMB6f5KmtWNNZ60jm9ow=
=aoNI
-----END PGP SIGNATURE-----
--
--
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.