Re: Patch 8.0.1281

2017-11-11 Fir de Conversatie Bram Moolenaar

Andy Wokula wrote:

> Am 09.11.2017 um 20:46 schrieb Bram Moolenaar:
> > Patch 8.0.1281
> > Problem:Loading file type detection slows down startup.
> > Solution:   Move functions to an autoload script.
> > Files:  runtime/filetype.vim, runtime/autoload/filetype.vim,
> >  runtime/scripts.vim
> 
> Can we have a dedicated folder for autoload scripts shipped with Vim?
>  for the sake of avoiding name clashes.
> Eg autoload/vi/ is short and seems to be unused (more likely to be unused 
> than autoload/vim/).
> 
> I think a missing dedicated folder is biggest impediment
> for shipping more functionality in autoload scripts.

Hmm, I suppose we can do that.  We can use "dist", since we already use
that elsewhere.

The function names are getting a bit long: "dist#filetype#Check_inp()".
I suppose there is no problem with using a bit more cryptic name:
"dist#ft#Check_inp()".

-- 
Bad programs can be written in any language.

 /// Bram Moolenaar -- b...@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_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/d/optout.


Re: Patch 8.0.1281

2017-11-09 Fir de Conversatie 'Andy Wokula' via vim_dev

Am 09.11.2017 um 20:46 schrieb Bram Moolenaar:

Patch 8.0.1281
Problem:Loading file type detection slows down startup.
Solution:   Move functions to an autoload script.
Files:  runtime/filetype.vim, runtime/autoload/filetype.vim,
 runtime/scripts.vim


Can we have a dedicated folder for autoload scripts shipped with Vim?
 for the sake of avoiding name clashes.
Eg autoload/vi/ is short and seems to be unused (more likely to be unused than 
autoload/vim/).

I think a missing dedicated folder is biggest impediment
for shipping more functionality in autoload scripts.

--
Andy

--
--
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/d/optout.


Patch 8.0.1281

2017-11-09 Fir de Conversatie Bram Moolenaar

Patch 8.0.1281
Problem:Loading file type detection slows down startup.
Solution:   Move functions to an autoload script.
Files:  runtime/filetype.vim, runtime/autoload/filetype.vim,
runtime/scripts.vim


*** ../vim-8.0.1280/runtime/filetype.vim2017-08-11 20:50:00.722908598 
+0200
--- runtime/filetype.vim2017-11-09 20:35:00.182149228 +0100
***
*** 1,7 
  " Vim support file to detect file types
  "
  " Maintainer: Bram Moolenaar 
! " Last Change:2017 Aug 11
  
  " Listen very carefully, I will say this only once
  if exists("did_load_filetypes")
--- 1,7 
  " Vim support file to detect file types
  "
  " Maintainer: Bram Moolenaar 
! " Last Change:2017 Nov 09
  
  " Listen very carefully, I will say this only once
  if exists("did_load_filetypes")
***
*** 52,78 
  au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt   setf help
  
  " Abaqus or Trasys
! au BufNewFile,BufRead *.inp   call s:Check_inp()
! 
! func! s:Check_inp()
!   if getline(1) =~ '^\*'
! setf abaqus
!   else
! let n = 1
! if line("$") > 500
!   let nmax = 500
! else
!   let nmax = line("$")
! endif
! while n <= nmax
!   if getline(n) =~? "^header surface data"
!   setf trasys
!   break
!   endif
!   let n = n + 1
! endwhile
!   endif
! endfunc
  
  " A-A-P recipe
  au BufNewFile,BufRead *.aap   setf aap
--- 52,58 
  au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt   setf help
  
  " Abaqus or Trasys
! au BufNewFile,BufRead *.inp   call filetype#Check_inp()
  
  " A-A-P recipe
  au BufNewFile,BufRead *.aap   setf aap
***
*** 174,217 
  
  " Assembly (all kinds)
  " *.lst is not pure assembly, it has two extra columns (address, byte codes)
! au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm()
! 
! " This function checks for the kind of assembly that is wanted by the user, or
! " can be detected from the first five lines of the file.
! func! s:FTasm()
!   " make sure b:asmsyntax exists
!   if !exists("b:asmsyntax")
! let b:asmsyntax = ""
!   endif
! 
!   if b:asmsyntax == ""
! call s:FTasmsyntax()
!   endif
! 
!   " if b:asmsyntax still isn't set, default to asmsyntax or GNU
!   if b:asmsyntax == ""
! if exists("g:asmsyntax")
!   let b:asmsyntax = g:asmsyntax
! else
!   let b:asmsyntax = "asm"
! endif
!   endif
! 
!   exe "setf " . fnameescape(b:asmsyntax)
! endfunc
! 
! func! s:FTasmsyntax()
!   " see if file contains any asmsyntax=foo overrides. If so, change
!   " b:asmsyntax appropriately
!   let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
!   \" ".getline(5)." "
!   let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
!   if match != ''
! let b:asmsyntax = match
!   elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? 
'\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
! let b:asmsyntax = "vmasm"
!   endif
! endfunc
  
  " Macro (VAX)
  au BufNewFile,BufRead *.mar   setf vmasm
--- 154,160 
  
  " Assembly (all kinds)
  " *.lst is not pure assembly, it has two extra columns (address, byte codes)
! au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call filetype#FTasm()
  
  " Macro (VAX)
  au BufNewFile,BufRead *.mar   setf vmasm
***
*** 241,257 
  au BufNewFile,BufRead *.mch,*.ref,*.imp   setf b
  
  " BASIC or Visual Basic
! au BufNewFile,BufRead *.bas   call s:FTVB("basic")
! 
! " Check if one of the first five lines contains "VB_Name".  In that case it is
! " probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
! func! s:FTVB(alt)
!   if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 
'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
! setf vb
!   else
! exe "setf " . a:alt
!   endif
! endfunc
  
  " Visual Basic Script (close to Visual Basic) or Visual Basic .NET
  au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl  setf vb
--- 184,190 
  au BufNewFile,BufRead *.mch,*.ref,*.imp   setf b
  
  " BASIC or Visual Basic
! au BufNewFile,BufRead *.bas   call filetype#FTVB("basic")
  
  " Visual Basic Script (close to Visual Basic) or Visual Basic .NET
  au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl  setf vb
***
*** 269,282 
\ if getline(1) =~ &