Patch 7.4.457

174 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 23, 2014, 10:50:23 AM9/23/14
to vim...@googlegroups.com

Patch 7.4.457
Problem: Using getchar() in an expression mapping may result in
K_CURSORHOLD, which can't be recognized.
Solution: Add the <CursorHold> key. (Hirohito Higashi)
Files: src/misc2.c


*** ../vim-7.4.456/src/misc2.c 2014-09-19 14:26:29.654405000 +0200
--- src/misc2.c 2014-09-23 16:25:18.726806328 +0200
***************
*** 2471,2476 ****
--- 2471,2477 ----
{K_SNR, (char_u *)"SNR"},
#endif
{K_PLUG, (char_u *)"Plug"},
+ {K_CURSORHOLD, (char_u *)"CursorHold"},
{0, NULL}
};

*** ../vim-7.4.456/src/version.c 2014-09-23 15:45:04.874801055 +0200
--- src/version.c 2014-09-23 16:47:43.738809266 +0200
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 457,
/**/

--
If Microsoft would build a car...
... Occasionally, executing a maneuver such as a left turn
would cause your car to shut down and refuse to restart, in
which case you would have to reinstall the engine.

/// Bram Moolenaar -- Br...@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 ///

mattn

unread,
Sep 23, 2014, 8:24:37 PM9/23/14
to vim...@googlegroups.com
I'm thinking this is breakable compatible for vim script.
We need to avoid to handle "\<CursorHold>" like below.

while c == "\<CursorHold>"
let c = getchar()
endwhile

Bram Moolenaar

unread,
Sep 24, 2014, 5:27:05 PM9/24/14
to mattn, vim...@googlegroups.com
I think you mean:

let c = getchar()
while c == "\<CursorHold>"
let c = getchar()
endwhile

I don't see what you mean with "breakable".

--
hundred-and-one symptoms of being an internet addict:
180. You maintain more than six e-mail addresses.

mattn

unread,
Sep 25, 2014, 4:24:28 AM9/25/14
to vim...@googlegroups.com, matt...@gmail.com
> I don't see what you mean with "breakable".

Sorry, I was confused. Until Patch 7.4.457, getchar() doesn't return "\<CursorHold>". (However 0x80 0xFD was returned)

I meant getchar() return only when it used with <expr>.


augroup hogehoge
autocmd!
autocmd CursorHold,CursorHoldI,WinEnter * setlocal cursorline
augroup END

function! s:foo()
let c = 0


while c == "\<CursorHold>"
let c = getchar()
endwhile

echomsg c
return ''
endfunction

nnoremap <expr>f <SID>foo()

Tony Mechelynck

unread,
Sep 25, 2014, 10:10:08 PM9/25/14
to vim...@googlegroups.com
This function will always echomsg 0 because at the start of the loop, c
is equal to zero which is != "\<CursorHold>"; hence Bram's :let c =
getchar() just before entering the loop.

Remember that

while (condition)
DoSomething
endwhile

is equivalent (in a modified vimscript language using goto's and labels) to

start: if (condition)
DoSomething
goto start
endif


Best regards,
Tony.
--
"There was only six Democrats in all of Hinsdale County and you, you son of
a bitch, you ate five of them."
-- Colorado judge, sentencing Alfred E. Packer for
cannibalism in 1874.

mattn

unread,
Sep 29, 2014, 11:01:16 PM9/29/14
to vim...@googlegroups.com
Sorry, but I mean, when using <expr>, we need to handle \<CursorHold>.
Is this right behavior?

Павлов Николай Александрович

unread,
Sep 29, 2014, 11:21:14 PM9/29/14
to vim...@googlegroups.com, Tony Mechelynck
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On September 26, 2014 6:10:35 AM GMT+03:00, Tony Mechelynck <antoine.m...@gmail.com> wrote:
>On 25/09/14 10:24, mattn wrote:
>>> I don't see what you mean with "breakable".
>>
>> Sorry, I was confused. Until Patch 7.4.457, getchar() doesn't return
>"\<CursorHold>". (However 0x80 0xFD was returned)
>>
>> I meant getchar() return only when it used with <expr>.
>>
>>
>> augroup hogehoge
>> autocmd!
>> autocmd CursorHold,CursorHoldI,WinEnter * setlocal cursorline
>> augroup END
>>
>> function! s:foo()
>> let c = 0
>> while c == "\<CursorHold>"
>> let c = getchar()
>> endwhile
>> echomsg c
>> return ''
>> endfunction
>>
>> nnoremap <expr>f <SID>foo()
>>
>
>This function will always echomsg 0 because at the start of the loop, c
>
>is equal to zero which is != "\<CursorHold>"; hence Bram's :let c =
>getchar() just before entering the loop.

Wondering whether you actually tested this. Unless "\<CursorHold>" starts with a number (it does not because all such things start with 0x80) it will be coerced to zero when comparing with numbers. So this loop is OK. I have not actually tested this either though.

>
>Remember that
>
> while (condition)
> DoSomething
> endwhile
>
> is equivalent (in a modified vimscript language using goto's and
>labels) to
>
> start: if (condition)
> DoSomething
> goto start
> endif
>
>
>Best regards,
>Tony.

-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQI1BAEBCgAfBQJUKiGUGBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
HhHSvlHwEACZBZdXbQ0664w3bN5vybUlYtBqQ2hjvDaWS7nlDZ+Vcw2p37qdmmWw
yZThd6Le0B7dji2ycqqqTR8TRH3cviwJBLjaraeMx59iX3Ipb7ICZ6poryEVRVaX
K1INnzqpqxxOizd+aCVPELtCfriOJ8E1uGgtzumcrdPRzG+uwSoKfrLeoM3LxIS4
OLsXkSxsMpKiLbQxLw0RK30ANXUvkoFYl3QoHZO1F5aeAh8Pw3ONksm7c97zdaRc
C0p+fTbC8KISF6VrqkPQsf5/grtfOSiYjKzrIu00G+6qMyZcrfeDCUyiFhNV/4kl
Xs81zZ50rZqBlpcwmIvACCuEGDwIbAG5mzUxpx/IKSorb8bTOp2B6rR63yRfJ7k0
ND18sYRQrQ/vB1FPxvvzN9Wl/HGajHR+AJNTwTilwUH4Ur6Fugcc9DT0Vy/Ap1TG
YCDyUU24OxSZWK5AY2AdponZjCWxmA6B8D8MayF6KbpBfyhE0ADGV6LBoqKP1Ex1
v8y7793H38316CD2Sn6cE6TYLveDOwTrCXfIhGrWJj6ExAP435drGrPkZuZ1kcGr
pCh4tgdZhfWcc4OYgc5qpbZ8BvoW+hhruH80r1CalTSwS28QDAp4y4kq3Pq/S3AS
kah3Yu4KLsbyVLVvpEp0sjnYypDRjfIfhErW7itRbPODb4YKyXiZKg==
=FqoR
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages