On 02/09/13 03:42, Geoff Greer wrote:
This patch adds asynchronous functions to vimscript. If you want to perform an 
action in 700ms, simply:

let timeout_id = settimeout(700, 'echo("hello")')

To cancel the timeout before it's fired:

canceltimeout(timeout_id)

setinterval() also returns an id that can be used with canceltimeout.

The reason for this patch is simple: asynchronous functionality is needed to 
implement real-time collaborative editing in Vim. This is one of the most 
voted-for features (see http://www.vim.org/sponsor/vote_results.php).

Along with Matt Kaniaris, I founded Floobits to build real-time collaboration 
into every editor. We wrote a plugin for Vim, but we had to use hacks to get 
async behavior (abusing feedkeys or client-server). These methods had 
side-effects such as breaking leaderkeys or other shortcuts. After a lot of 
experimenting, we decided to try patching Vim.

Since Vim is character-driven, we had to munge some low-level input functions 
to get the desired behavior. We changed gui_wait_for_chars() and mch_inchar() 
so that call_timeouts() is run every ticktime milliseconds. The default 
ticktime is 100ms.

This patch isn't finished yet, but it works on unix-based OSes. If the reaction 
is positive, our intention is to change mch_inchar() (or something similar) in 
other OS-specific files. That will get async functions working for everyone.

Even if our patch isn't the best approach, we'd love to help get async 
functions in Vim. Doing so will open the door to a lot of cool plugins.

Oh, and this is the first time either myself or Matt have submitted a patch to 
Vim, so please be gentle.

Sincerely,

Geoff Greer

Your patch is not in the approved coding style (see :help style-examples)

Wrong:

        void
insert_timeouts(timeout_T *to) {
        timeout_T *cur = timeouts
        timeout_T *prev = NULL


OK:
/*
 * Explanation of what the function is used for
 * and of how to call it
 */
        void
insert_timeouts(to)
        timeout_T *to;                  /* short comment about to */
{
        timeout_T *cur = timeouts;      /* short comment about cur */
        timeout_T *prev = NULL;         /* short comment about prev */

NOTE: Don't use ANSI style function declarations. A few people still have to
use a compiler that doesn't support it.




Best regards,
Tony.
--
Consensus Terrorism:
        The process that decides in-office attitudes and behavior.
                -- Douglas Coupland, "Generation X: Tales for an Accelerated
                   Culture"

--
--
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui