To: vim_dev@googlegroups.com Subject: Patch 8.0.1007 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1007 Problem: No test for filetype detection for scripts. Solution: Add a first test file script filetype detection. Files: src/testdir/test_filetype.vim, runtime/scripts.vim *** ../vim-8.0.1006/src/testdir/test_filetype.vim 2017-08-11 20:50:00.722908598 +0200 --- src/testdir/test_filetype.vim 2017-08-27 16:16:51.028404406 +0200 *************** *** 527,530 **** --- 527,558 ---- if has('fname_case') call CheckItems(s:filename_case_checks) endif + filetype off endfunc + + " Filetypes detected from the file contents by scripts.vim + let s:script_checks = { + \ 'virata': [['% Virata'], + \ ['', '% Virata'], + \ ['', '', '% Virata'], + \ ['', '', '', '% Virata'], + \ ['', '', '', '', '% Virata']], + \ 'strace': [['execve("/usr/bin/pstree", ["pstree"], 0x7ff0 /* 63 vars */) = 0'], + \ ['15:17:47 execve("/usr/bin/pstree", ["pstree"], ... "_=/usr/bin/strace"]) = 0'], + \ ['__libc_start_main and something']], + \ } + + func Test_script_detection() + filetype on + for [ft, files] in items(s:script_checks) + for file in files + call writefile(file, 'Xtest') + split Xtest + call assert_equal(ft, &filetype) + bwipe! + endfor + endfor + call delete('Xtest') + filetype off + endfunc + *** ../vim-8.0.1006/runtime/scripts.vim 2017-06-11 17:09:50.614252000 +0200 --- runtime/scripts.vim 2017-08-27 16:03:59.365384433 +0200 *************** *** 1,7 **** " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar ! " Last change: 2017 Jun 11 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by --- 1,7 ---- " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar ! " Last change: 2017 Aug 27 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by *************** *** 306,312 **** set ft=virata " Strace ! elseif s:line1 =~# '^\(\[pid \d\+\] \)\=[0-9:.]* *execve(' || s:line1 =~# '^__libc_start_main' set ft=strace " VSE JCL --- 306,312 ---- set ft=virata " Strace ! elseif s:line1 =~# '[0-9:.]* *execve(' || s:line1 =~# '^__libc_start_main' set ft=strace " VSE JCL *** ../vim-8.0.1006/src/version.c 2017-08-27 15:23:37.516977242 +0200 --- src/version.c 2017-08-27 16:53:17.778292021 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1007, /**/ -- How To Keep A Healthy Level Of Insanity: 15. Five days in advance, tell your friends you can't attend their party because you're not in the mood. /// 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 ///