-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 01-Nov-2018 21:09 +0100, Bram Moolenaar wrote:

> Ingo Karkat wrote:
> 
>> On 30-Oct-2018 07:48 +0100, Christian Brabandt wrote:
>> 
>>> On Mo, 29 Okt 2018, Bok Woon Chua wrote:
>>> 
>>>> I have an autocmd that saves the current file on
>>>> InsertLeave. Using C-c in insert mode doesn't trigger this
>>>> save (as desired), but if I use it into an inoremap mapping
>>>> like so
>>>> 
>>>> inoremap <C-a> <C-c>I
>>>> 
>>>> ,it triggers InsertLeave whenever I use C-a to jump to the
>>>> start of the line and hence saves the file.
>>>> 
>>>> Is this intentional behavior? Is C-c supposed to avoid 
>>>> InsertLeave only if used interactively, rather than in a
>>>> script?
>>> 
>>> I believe this is intentionally and expected. <c-c> does not
>>> work as "abort" key if it comes from a mapping (or has been
>>> mapped).
>> 
>> Yes, that is the current behavior, but I agree with Bok Woon Chua
>> that this is unexpected and inconsistent with how other mappings
>> behave (i.e. they transparently forward the original behavior
>> without changing it). The problem even occurs when mapping <C-c>
>> onto itself (:inoremap <C-c> <C-c>).
>> 
>> I know that relying on <C-c> not triggering InsertLeave is bad
>> form, and Vim's Todo list is very long, but especially in light
>> of the recent poll about what plugin writers want, fixing such
>> inconsistencies would be very welcome. In some situations,
>> details like this can make or break a plugin implementation.
> 
> Unfortunately this behavior has been documented and users may rely
> on the current behavior.

Do you mean with "this behavior" that <C-c> does not trigger
InsertLeave? I would want to keep it that way, as this indeed is
documented. What I would like to change is that when <C-c> is used in
the right-hand side of a mapping, it should also not trigger
InsertLeave, but right now it does. That's the complaint of the OP and
the inconsistency I meant.
Having keys to trigger (<Esc>) and not trigger (<C-c>) InsertLeave is
documented and can be helpful. But it's surprising that this special
property of <C-c> gets lost when it is part of a mapping. I haven't seen
that part documented anywhere yet, and I think it's a side effect of the
current implementation, not planned behavior.

> I was planning to add a more generic mode-change autocommand.
> There is a request for Visual mode enter/leave, for example. 
> Perhaps triggering whenever the return value of mode() would change
> is the most generic solution.  But that needs some more
> investigation.

That sounds really good. I also remember questions about hooking into
entering visual mode, and the current workaround (mapping all v / V /
CTRL-V variants) is not very nice. I don't think it would help with OP's
mapping problem, though.

- -- regards, ingo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJb22UEAAoJEA7ziXlAzQ/vfvMIAIFx5YspbuaISQAvL80E+UXW
x7cCFpWwjEOgstkKZie9iAlYDsYHoWU/UqFu9bfzSxN4qvDCs8hf5dV59DmQckqm
N14pIXyV7qRUsKJ1JQOiyRpx5T9es7Xmt+e6+xmO+T7ga79xSZnBDWDIT+onhqCz
DK9jYKXpQy1alR8V/sKeOrQrFT9eYqdmgdwL5KGSwbeDpGv5daU6lH28bSC2SKNt
bByISqoAl4kNVvFdOlz/jIrM3GSuwZHMrxuhn+CLvc27EF1EXcsWsXelVuV1a9eL
9jM5HMCM+xDmlhQkTmkTrYHrVqUf0dhByrxVwoVizn5gLdkw7bZzv4id7Qtm8Ss=
=kobq
-----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.

Raspunde prin e-mail lui