Performance improvement: skip applying of modelines if nothing was done in `:doautocmd`

90 views
Skip to first unread message

Daniel Hahler

unread,
Oct 20, 2014, 2:23:50 AM10/20/14
to vim...@googlegroups.com
I have seen a noticeable performance problem when using the `vim-oblique` plugin, which was caused by calls to `doautocmd User ...` - although the user events did not exist (https://github.com/junegunn/vim-oblique/issues/30).

While there is the `<nomodeline>` option for `:doautocmd`, Vim could always skip applying the modeline (again) in case no commands were executed.

This makes especially sense when there are no events defined at all (that's what the fix for the plugin did: https://github.com/junegunn/vim-oblique/commit/32e1c4291e9138d55962e7408866a80d99726a28).


Regards,
Daniel.

Andy Wokula

unread,
Oct 20, 2014, 1:55:53 PM10/20/14
to vim...@googlegroups.com
Am 20.10.2014 um 08:23 schrieb Daniel Hahler:
> I have seen a noticeable performance problem when using the
> `vim-oblique` plugin, which was caused by calls to `doautocmd User
> ...` - although the user events did not exist
> (https://github.com/junegunn/vim-oblique/issues/30).
>
> While there is the `<nomodeline>` option for `:doautocmd`, Vim could
> always skip applying the modeline (again) in case no commands were
> executed.

I want unconditional execution of modelines.

" :DoModelines
" manually execute the modelines ("no matching autocmds" is a good thing
" here, we only need the side effect of :doautocmd); added 2010 Sep 27

com! -bar DoModelines :silent doautocmd User DoModelines

--
Andy

Daniel Hahler

unread,
Oct 20, 2014, 6:54:44 PM10/20/14
to vim...@googlegroups.com, anw...@yahoo.de
Am Montag, 20. Oktober 2014 19:55:53 UTC+2 schrieb Andy Wokula:

> I want unconditional execution of modelines.
>
> " :DoModelines
> " manually execute the modelines ("no matching autocmds" is a good thing
> " here, we only need the side effect of :doautocmd); added 2010 Sep 27
>
> com! -bar DoModelines :silent doautocmd User DoModelines

Ok. But this appears to be a candidate for a separate command then.

Wouldn't `:e` work for you, too?


Cheers,
Daniel.

Christian Brabandt

unread,
Oct 21, 2014, 10:51:26 AM10/21/14
to vim...@googlegroups.com
On Mo, 20 Okt 2014, Daniel Hahler wrote:

> Am Montag, 20. Oktober 2014 19:55:53 UTC+2 schrieb Andy Wokula:
>
> > I want unconditional execution of modelines.
> >
> > " :DoModelines
> > " manually execute the modelines ("no matching autocmds" is a good thing
> > " here, we only need the side effect of :doautocmd); added 2010 Sep 27
> >
> > com! -bar DoModelines :silent doautocmd User DoModelines
>
> Ok. But this appears to be a candidate for a separate command then.

Attached patch does that.

> Wouldn't `:e` work for you, too?

That loses your changes.

Best,
Christian
--
Auf 93 Millionen Meilen gibt es nichts zwischen der Sonne und meinem
Schatten. Ich bin immer irgendetwas im Wege ...
domodeline.diff

Andy Wokula

unread,
Oct 23, 2014, 3:35:48 PM10/23/14
to vim...@googlegroups.com
Am 21.10.2014 um 16:51 schrieb Christian Brabandt:
> On Mo, 20 Okt 2014, Daniel Hahler wrote:
>
>> Am Montag, 20. Oktober 2014 19:55:53 UTC+2 schrieb Andy Wokula:
>>
>>> I want unconditional execution of modelines.
>>>
>>> " :DoModelines
>>> " manually execute the modelines ("no matching autocmds" is a good thing
>>> " here, we only need the side effect of :doautocmd); added 2010 Sep 27
>>>
>>> com! -bar DoModelines :silent doautocmd User DoModelines
>>
>> Ok. But this appears to be a candidate for a separate command then.
>
> Attached patch does that.
>
>> Wouldn't `:e` work for you, too?
>
> That loses your changes.

So far this patch works for me.
:domodelines executes modelines.
:doau only executes modelines when there are matching autocommands.

--
Andy
Reply all
Reply to author
Forward
0 new messages