Patch 9.0.0006
Problem: Not all Visual Basic files are recognized.
Solution: Change detection of *.cls files. (Doug Kearns)
Files: runtime/autoload/dist/ft.vim, runtime/doc/filetype.txt,
runtime/filetype.vim, src/testdir/test_filetype.vim
*** ../vim-9.0.0005/runtime/autoload/dist/ft.vim 2022-04-16
21:04:20.000000000 +0100
--- runtime/autoload/dist/ft.vim 2022-06-29 14:33:55.745988864 +0100
***************
*** 72,93 ****
# most frequent FreeBASIC-specific keywords in distro files
var fb_keywords =
'\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
! var fb_preproc =
'\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)'
var fb_comment = "^\\s*/'"
# OPTION EXPLICIT, without the leading underscore, is common to many
dialects
var qb64_preproc =
'\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
! var lines = getline(1, min([line("$"), 100]))
!
! if match(lines, fb_preproc) > -1 || match(lines, fb_comment) > -1 ||
match(lines, fb_keywords) > -1
! setf freebasic
! elseif match(lines, qb64_preproc) > -1
! setf qb64
! elseif match(lines, ft_visual_basic_content) > -1
! setf vb
! else
! setf basic
! endif
enddef
export def FTbtm()
--- 72,106 ----
# most frequent FreeBASIC-specific keywords in distro files
var fb_keywords =
'\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
! var fb_preproc = '\c^\s*\%(' ..
! # preprocessor
! '#\s*\a\+\|' ..
! # compiler option
!
'option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\|'
..
! # metacommand
! '\%(''\|rem\)\s*\$lang\>\|' ..
! # default datatype
!
'def\%(byte\|longint\|short\|ubyte\|uint\|ulongint\|ushort\)\>' ..
! '\)'
var fb_comment = "^\\s*/'"
+
# OPTION EXPLICIT, without the leading underscore, is common to many
dialects
var qb64_preproc =
'\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
! for lnum in range(1, min([line("$"), 100]))
! var line = getline(lnum)
! if line =~ ft_visual_basic_content
! setf vb
! return
! elseif line =~ fb_preproc || line =~ fb_comment || line =~ fb_keywords
! setf freebasic
! return
! elseif line =~ qb64_preproc
! setf qb64
! return
! endif
! endfor
! setf basic
enddef
export def FTbtm()
***************
*** 126,131 ****
--- 139,161 ----
endif
enddef
+ export def FTcls()
+ if exists("g:filetype_cls")
+ exe "setf " .. g:filetype_cls
+ return
+ endif
+
+ if getline(1) =~ '^%'
+ setf tex
+ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx'
+ setf rexx
+ elseif getline(1) == 'VERSION 1.0 CLASS'
+ setf vb
+ else
+ setf st
+ endif
+ enddef
+
export def FTlpc()
if exists("g:lpc_syntax_for_c")
var lnum = 1
*** ../vim-9.0.0005/runtime/doc/filetype.txt 2022-06-28 11:21:05.000000000
+0100
--- runtime/doc/filetype.txt 2022-06-29 14:35:44.849678177 +0100
***************
*** 143,148 ****
--- 143,149 ----
*.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax|
*.bas g:filetype_bas |ft-basic-syntax|
*.cfg g:filetype_cfg
+ *.cls g:filetype_cls
*.csh g:filetype_csh |ft-csh-syntax|
*.dat g:filetype_dat
*.frm g:filetype_frm |ft-form-syntax|
*** ../vim-9.0.0005/runtime/filetype.vim 2022-06-29 13:48:45.352899052
+0100
--- runtime/filetype.vim 2022-06-29 14:33:55.745988864 +0100
***************
*** 1798,1813 ****
au BufNewFile,BufRead .slrnrc setf slrnrc
au BufNewFile,BufRead *.score setf slrnsc
! " Smalltalk (and TeX)
au BufNewFile,BufRead *.st setf st
! au BufNewFile,BufRead *.cls
! \ if getline(1) =~ '^%' |
! \ setf tex |
! \ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx' |
! \ setf rexx |
! \ else |
! \ setf st |
! \ endif
" Smarty templates
au BufNewFile,BufRead *.tpl setf smarty
--- 1798,1808 ----
au BufNewFile,BufRead .slrnrc setf slrnrc
au BufNewFile,BufRead *.score setf slrnsc
! " Smalltalk
au BufNewFile,BufRead *.st setf st
!
! " Smalltalk (and Rexx, TeX, and Visual Basic)
! au BufNewFile,BufRead *.cls call dist#ft#FTcls()
" Smarty templates
au BufNewFile,BufRead *.tpl setf smarty
*** ../vim-9.0.0005/src/testdir/test_filetype.vim 2022-06-29
13:48:45.352899052 +0100
--- src/testdir/test_filetype.vim 2022-06-29 14:33:55.745988864 +0100
***************
*** 837,843 ****
" Visual Basic
! call writefile(['Attribute VB_NAME = "Testing"'], 'Xfile.bas')
split Xfile.bas
call assert_equal('vb', &filetype)
bwipe!
--- 837,843 ----
" Visual Basic
! call writefile(['Attribute VB_NAME = "Testing"', 'Enum Foo', 'End Enum'],
'Xfile.bas')
split Xfile.bas
call assert_equal('vb', &filetype)
bwipe!
***************
*** 1719,1723 ****
--- 1719,1763 ----
filetype off
endfunc
+ func Test_cls_file()
+ filetype on
+
+ call writefile(['looks like Smalltalk'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('st', &filetype)
+ bwipe!
+
+ " Test dist#ft#FTcls()
+
+ let g:filetype_cls = 'vb'
+ split Xfile.cls
+ call assert_equal('vb', &filetype)
+ bwipe!
+ unlet g:filetype_cls
+
+ " TeX
+
+ call writefile(['%'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('tex', &filetype)
+ bwipe!
+
+ " Rexx
+
+ call writefile(['# rexx'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('rexx', &filetype)
+ bwipe!
+
+ " Visual Basic
+
+ call writefile(['VERSION 1.0 CLASS'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('vb', &filetype)
+ bwipe!
+
+ call delete('Xfile.cls')
+ filetype off
+ endfunc
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0005/src/version.c 2022-06-29 13:48:45.352899052 +0100
--- src/version.c 2022-06-29 14:37:00.829465872 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 6,
/**/
--
How To Keep A Healthy Level Of Insanity:
11. Specify that your drive-through order is "to go".
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220629133942.13C2D1C1E32%40moolenaar.net.