To: vim_dev@googlegroups.com Subject: Patch 8.1.1593 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1593 Problem: Filetype not detected for C++ header files without extension. Solution: Recognize the file by the Emacs file mode. (Dmitry Ilyin, closes #4593) Files: runtime/scripts.vim, src/testdir/test_filetype.vim *** ../vim-8.1.1592/runtime/scripts.vim 2018-02-03 22:31:58.000000000 +0100 --- runtime/scripts.vim 2019-06-25 21:29:55.974051821 +0200 *************** *** 195,201 **** if s:line1 =~# '^:$' call dist#ft#SetFileTypeSH(s:line1) " defined in filetype.vim ! " Z shell scripts elseif s:line1 =~# '^#compdef\>' || s:line1 =~# '^#autoload\>' || \ "\n".s:line1."\n".s:line2."\n".s:line3."\n".s:line4."\n".s:line5 =~# '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>' set ft=zsh --- 195,201 ---- if s:line1 =~# '^:$' call dist#ft#SetFileTypeSH(s:line1) " defined in filetype.vim ! " Z shell scripts elseif s:line1 =~# '^#compdef\>' || s:line1 =~# '^#autoload\>' || \ "\n".s:line1."\n".s:line2."\n".s:line3."\n".s:line4."\n".s:line5 =~# '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>' set ft=zsh *************** *** 204,218 **** elseif s:line1 =~# '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' set ft=mail ! " Mason elseif s:line1 =~# '^<[%&].*>' set ft=mason ! " Vim scripts (must have '" vim' as the first line to trigger this) elseif s:line1 =~# '^" *[vV]im$' set ft=vim ! " MOO elseif s:line1 =~# '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$' set ft=moo --- 204,223 ---- elseif s:line1 =~# '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' set ft=mail ! " Mason elseif s:line1 =~# '^<[%&].*>' set ft=mason ! " Vim scripts (must have '" vim' as the first line to trigger this) elseif s:line1 =~# '^" *[vV]im$' set ft=vim ! " libcxx and libstdc++ standard library headers like "iostream" do not have ! " an extension, recognize the Emacs file mode. ! elseif s:line1 =~? '-\*-.*C++.*-\*-' ! set ft=cpp ! ! " MOO elseif s:line1 =~# '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$' set ft=moo *** ../vim-8.1.1592/src/testdir/test_filetype.vim 2019-06-03 23:07:21.828486877 +0200 --- src/testdir/test_filetype.vim 2019-06-25 21:33:41.845159035 +0200 *************** *** 586,591 **** --- 586,593 ---- \ 'cfengine': [['#!/path/cfengine']], \ 'erlang': [['#!/path/escript']], \ 'haskell': [['#!/path/haskell']], + \ 'cpp': [['// Standard iostream objects -*- C++ -*-'], + \ ['// -*- C++ -*-']], \ } func Test_script_detection() *** ../vim-8.1.1592/src/version.c 2019-06-25 06:50:26.908412868 +0200 --- src/version.c 2019-06-25 21:33:13.985268632 +0200 *************** *** 779,780 **** --- 779,782 ---- { /* Add new patch number below this line */ + /**/ + 1593, /**/ -- This sentence is not sure that it exists, but if it does, it will certainly consider the possibility that other sentences exist. /// 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 ///