Christian Brabandt wrote:
> On Do, 25 Mai 2017, Bram Moolenaar wrote:
>
> > Christian Brabandt wrote:
> >
> > > On Mi, 24 Mai 2017, fREW Schmidt wrote:
> > >
> > > > Yes. "If I replace the contents of /usr/share/vim/vim80/syntax/vb.vim with `let
> > > > b:current_syntax = "vb"` everything is fast and, as I would hope, the support
> > > > files are not loaded N times per buffer but instead exactly once."
> > >
> > > Well, I see the problem, although I cannot reproduce it.
> > >
> > > The markdown syntax script sources the html syntax script and that one
> > > does include a couple of other syntax scripts, like css.vim,
> > > javascript.vim and also vb.vim. However from my testing vb.vim is not
> > > guilty alone. If I uncomment vb.vim, the overall loading time only
> > > shrinks by 0.2 seconds or so (it needs here a total of around 7
> > > seconds). So you would need to disable all other to be included syntax
> > > scripts as well (for a test, you could set main_syntax='java').
> >
> > I haven't read the whole thread, but I suspect that the trick is to set
> > b:current_syntax (to anything), which will cause further syntax scripts to bail
> > out. Anyway, this is all working around the actual problem.
>
> Not for html, which explicitly resets b:current_syntax to be able to
> include several other syntax scripts and even provides the main_syntax
> global variable to make this work with other syntax scripts.
Well, it must be used somehwere to explain why making the file empty has
a different effect from only setting b:current_syntax in the file.
> > > However, I think you might have found a bug here. Your ftdetect script
> > > does this:
> > >
> > > autocmd BufNew,BufNewFile,BufRead *.md :set filetype=markdown
> > >
> > > The :args command does fill the argument list, calls ex_next() which
> > > calls eventually alist_set() and then iterates over the argument list
> > > and calls adlist_add(). This will finally call buflist_add() which in
> > > turn calls buflist_new(), which triggers the BufNew autocommand, which
> > > then triggers the FileType and finally the Syntax autocommands. So in
> > > the end, we are iterating over the whole list of arguments and call
> > > autocommands, for buffers that are not even going to be displayed next.
> > >
> > > So I wonder, if we can't do a little bit better, similar to how vimgrep
> > > sets the eventignore option to prevent at least the expensive FileType
> > > autocommand:
> >
> > I'm quite sure this will make other things fail. Just don't use
> > BufNew for detecting the filetype, that is the cause of the problem.
> > The file type should only be detected when the buffer is loaded.
> > Doing it earlier indeed causes the overhead experienced.
>
> Indeed, however, that doesn't mean, we shouldn't try to avoid this
> problem. Vimgrep does the same.
Avoid what problem? Detecting the filetype in cases it isn't used? Not
sure how we can predict that. For :vimgrep it's obvious, and it then
has to carefully jump to hoops later for when a buffer ends up not being
unloaded. Probably can't be turned into a generic solution, since we
don't know what happens next.
--
OLD WOMAN: Well, how did you become king, then?
ARTHUR: The Lady of the Lake, her arm clad in the purest shimmering samite,
held Excalibur aloft from the bosom of the water to signify by Divine
Providence ... that I, Arthur, was to carry Excalibur ... That is
why I am your king!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- 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_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Friday, May 26, 2017
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment