Benji Fisher wrote:
On Fri, Jun 09, 2006 at 02:03:33PM +0200, A.J.Mechelynck wrote:
To ask only if something more than just time or mode have changed, you
can paste the following (untested, but I believe it should work) into
your vimrc:
:autocmd FileChangedShell *
\ if (v:fcs_reason == "mode") || (v:fcs_reason == "time") |
\ let v_fcs_choice = "" |
\ else |
\ let v:fcs_choice = "ask" |
\ endif
Murphy's Law strikes again: if it is untested, then there is a typo.
Change v_fcs_choice to v:fcs_choice . This would make a good example to
include in the docs. I wonder if I can get it down to one or two lines:
:au FileChangedShell * let v:fcs_choice = (v:fcs_reason == "mode") ? "" : "ask"
Not really short enough. The following restores the "mode or time"
behavior of your version and is a little shorter, but it is too cryptic
to be used in the docs:
:au FileChangedShell * let v:fcs_choice=(v:fcs_reason=~"e$")?"":"ask"
HTH --Benji Fisher
Thanks Benji, for spotting the typo. Looks like I'm only too prone to
hit the wrong key these times. Recently I typed "Big or Hige" -- instead
of Huge of course -- and only saw the error when the post came back on
the list.
Your second example (ask only if it doesn't end in "e") may also make
less obvious "why it doesn't work anymore" if the set of possible values
of v:fcs_reason someday changes. Maybe
:au FileChangedShell * let v:fcs_choice = ((v:fcs_reason =~
'^mode$\|^time$')?"":"ask")
Still "untested, but I think it'll work", of course. ;-) (I also think
that in this case it's important to quote the pattern with _single_ quotes.)
It's even longer than your "not short enough" example, of course. But
whether it is "short enough" is a question of opinion.
Best regards,
Tony.