To: vim_dev@googlegroups.com Subject: Patch 8.2.4274 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4274 Problem: Basic and form filetype detection is incomplete. Solution: Add a separate function for .frm files. (Doug Kearns, closes #9675) Files: runtime/autoload/dist/ft.vim, runtime/filetype.vim, src/testdir/test_filetype.vim *** ../vim-8.2.4273/runtime/autoload/dist/ft.vim 2022-01-28 14:15:06.440853078 +0000 --- runtime/autoload/dist/ft.vim 2022-01-31 17:03:55.584747171 +0000 *************** *** 67,72 **** --- 67,75 ---- endif endfunc + let s:ft_visual_basic_content = '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + + " See FTfrm() for Visual Basic form file detection func dist#ft#FTbas() if exists("g:filetype_bas") exe "setf " . g:filetype_bas *************** *** 86,92 **** setf freebasic elseif match(lines, qb64_preproc) > -1 setf qb64 ! elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1 setf vb else setf basic --- 89,95 ---- setf freebasic elseif match(lines, qb64_preproc) > -1 setf qb64 ! elseif match(lines, s:ft_visual_basic_content) > -1 setf vb else setf basic *************** *** 235,240 **** --- 238,258 ---- endif endfunc + func dist#ft#FTfrm() + if exists("g:filetype_frm") + exe "setf " . g:filetype_frm + return + endif + + let lines = getline(1, min([line("$"), 5])) + + if match(lines, s:ft_visual_basic_content) > -1 + setf vb + else + setf form + endif + endfunc + " Distinguish between Forth and F#. " Provided by Doug Kearns. func dist#ft#FTfs() *** ../vim-8.2.4273/runtime/filetype.vim 2022-01-29 12:45:43.958338766 +0000 --- runtime/filetype.vim 2022-01-31 17:03:55.584747171 +0000 *************** *** 2051,2057 **** \ endif " Visual Basic (also uses *.bas) or FORM ! au BufNewFile,BufRead *.frm call dist#ft#FTVB("form") " SaxBasic is close to Visual Basic au BufNewFile,BufRead *.sba setf vb --- 2051,2057 ---- \ endif " Visual Basic (also uses *.bas) or FORM ! au BufNewFile,BufRead *.frm call dist#ft#FTfrm() " SaxBasic is close to Visual Basic au BufNewFile,BufRead *.sba setf vb *** ../vim-8.2.4273/src/testdir/test_filetype.vim 2022-01-29 12:45:43.958338766 +0000 --- src/testdir/test_filetype.vim 2022-01-31 17:03:55.584747171 +0000 *************** *** 183,188 **** --- 183,189 ---- \ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'], \ 'fish': ['file.fish'], \ 'focexec': ['file.fex', 'file.focexec'], + \ 'form': ['file.frm'], \ 'forth': ['file.ft', 'file.fth'], \ 'fortran': ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'], \ 'fpcmake': ['file.fpc'], *************** *** 1278,1281 **** --- 1279,1309 ---- filetype off endfunc + func Test_frm_file() + filetype on + + call writefile(['looks like FORM'], 'Xfile.frm') + split Xfile.frm + call assert_equal('form', &filetype) + bwipe! + + " Test dist#ft#FTfrm() + + let g:filetype_frm = 'form' + split Xfile.frm + call assert_equal('form', &filetype) + bwipe! + unlet g:filetype_frm + + " Visual Basic + + call writefile(['Begin VB.Form Form1'], 'Xfile.frm') + split Xfile.frm + call assert_equal('vb', &filetype) + bwipe! + + call delete('Xfile.frm') + filetype off + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4273/src/version.c 2022-01-31 14:59:33.530943518 +0000 --- src/version.c 2022-01-31 17:06:53.226326429 +0000 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4274, /**/ -- CRONE: Who sent you? ARTHUR: The Knights Who Say GNU! CRONE: Aaaagh! (she looks around in rear) No! We have no licenses here. "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///