Justin Keyes wrote:

> On Tue, Sep 27, 2016 at 10:10 PM, Christian Brabandt <[email protected]> 
> wrote:
> > Bram,
> > I maintain the popular eye-candy plugin vim-airline. For files
> > maintained in git, it checks the current branch and displays it in the
> > statusline using system('git status...') and caches the result, so that
> > it is not called to often. However after a ShellCmdPost autocommand, it
> > invalidates the cache and runs the command to update it (since the user
> > could have interacted with git using !git..)
> 
> Why *must* the plugin do this in ShellCmdPost? Why can't it set a flag
> and then refresh the cache on CursorMoved or CursorHold? This is not a
> strong case for making this variable writable.
> 
> Keeping variables read-only makes it easier to reason about things.
> Very few v: vars are writable, and each time it's slightly convenient
> someone asks to make them writable.
> 
> I believe ZyX also noted that calling system() in a ShellCmdPost is a
> code smell.

Right.  How about using a timer?  That way you can also avoid too many
updates (set timer for 1 second, if another shell command is used
kill the timer and start another one).

-- 
You know you use Vim too much when you have this alias in your
~/.bashrc file: alias :e=/bin/vim             (Eljay Love-Jensen)

 /// Bram Moolenaar -- [email protected] -- 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    ///

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