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.

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.

--
--
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