]> granicus.if.org Git - vim/commitdiff
patch 8.1.0771: some shell filetype patterns end in a star v8.1.0771
authorBram Moolenaar <Bram@vim.org>
Fri, 18 Jan 2019 20:46:47 +0000 (21:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 18 Jan 2019 20:46:47 +0000 (21:46 +0100)
Problem:    Some shell filetype patterns end in a star.
Solution:   Make sure that patterns not ending in a star are preferred.

runtime/autoload/dist/ft.vim
runtime/filetype.vim
src/version.c

index 973d3b028066055c3fc8fe68770a2795f2861c49..de45faa4f8df799d75cf2400909ad07c84aeb1ec 100644 (file)
@@ -1,7 +1,7 @@
 " Vim functions for file type detection
 "
 " Maintainer:  Bram Moolenaar <Bram@vim.org>
-" Last Change: 2017 Dec 05
+" Last Change: 2019 Jan 18
 
 " These functions are moved here from runtime/filetype.vim to make startup
 " faster.
@@ -484,6 +484,10 @@ endfunc
 
 " Called from filetype.vim and scripts.vim.
 func dist#ft#SetFileTypeSH(name)
+  if did_filetype()
+    " Filetype was already detected
+    return
+  endif
   if expand("<amatch>") =~ g:ft_ignore_pat
     return
   endif
@@ -531,6 +535,10 @@ endfunc
 " as used for Tcl.
 " Also called from scripts.vim, thus can't be local to this script.
 func dist#ft#SetFileTypeShell(name)
+  if did_filetype()
+    " Filetype was already detected
+    return
+  endif
   if expand("<amatch>") =~ g:ft_ignore_pat
     return
   endif
@@ -551,6 +559,10 @@ func dist#ft#SetFileTypeShell(name)
 endfunc
 
 func dist#ft#CSH()
+  if did_filetype()
+    " Filetype was already detected
+    return
+  endif
   if exists("g:filetype_csh")
     call dist#ft#SetFileTypeShell(g:filetype_csh)
   elseif &shell =~ "tcsh"
index 72a756d84ba782046ce10b373758b1363303bda2..cdfbbffeb92b5819ba020453955c5fcefcb4ef17 100644 (file)
@@ -1462,9 +1462,11 @@ au BufNewFile,BufRead sgml.catalog*              call s:StarSetf('catalog')
 
 " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
 " Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts
-au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,bash-fc[-.]*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call dist#ft#SetFileTypeSH("bash")
-au BufNewFile,BufRead .kshrc*,*.ksh call dist#ft#SetFileTypeSH("ksh")
-au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call dist#ft#SetFileTypeSH(getline(1))
+" NOTE: Patterns ending in a star are further down, these have lower priority.
+au BufNewFile,BufRead .bashrc,bashrc,bash.bashrc,.bash[_-]profile,.bash[_-]logout,.bash[_-]aliases,bash-fc[-.],*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD call dist#ft#SetFileTypeSH("bash")
+au BufNewFile,BufRead .kshrc,*.ksh call dist#ft#SetFileTypeSH("ksh")
+au BufNewFile,BufRead */etc/profile,.profile,*.sh,*.env call dist#ft#SetFileTypeSH(getline(1))
+
 
 " Shell script (Arch Linux) or PHP file (Drupal)
 au BufNewFile,BufRead *.install
@@ -1475,14 +1477,14 @@ au BufNewFile,BufRead *.install
        \ endif
 
 " tcsh scripts
-au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login   call dist#ft#SetFileTypeShell("tcsh")
+au BufNewFile,BufRead .tcshrc,*.tcsh,tcsh.tcshrc,tcsh.login    call dist#ft#SetFileTypeShell("tcsh")
 
 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
-au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call dist#ft#CSH()
+au BufNewFile,BufRead .login,.cshrc,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call dist#ft#CSH()
 
 " Z-Shell script
 au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks  setf zsh
-au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
+au BufNewFile,BufRead .zsh,.zlog,.zcompdump    call s:StarSetf('zsh')
 au BufNewFile,BufRead *.zsh                    setf zsh
 
 " Scheme
@@ -2074,6 +2076,20 @@ au BufRead,BufNewFile *.rdf                      call dist#ft#Redif()
 " Remind
 au BufNewFile,BufRead .reminders*              call s:StarSetf('remind')
 
+" Shell scripts ending in a star
+au BufNewFile,BufRead .bashrc*,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,bash-fc[-.]*,,PKGBUILD* call dist#ft#SetFileTypeSH("bash")
+au BufNewFile,BufRead .kshrc* call dist#ft#SetFileTypeSH("ksh")
+au BufNewFile,BufRead .profile* call dist#ft#SetFileTypeSH(getline(1))
+
+" tcsh scripts ending in a star
+au BufNewFile,BufRead .tcshrc* call dist#ft#SetFileTypeShell("tcsh")
+
+" csh scripts ending in a star
+au BufNewFile,BufRead .login*,.cshrc*  call dist#ft#CSH()
+
+" Z-Shell script ending in a star
+au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
+
 " Vim script
 au BufNewFile,BufRead *vimrc*                  call s:StarSetf('vim')
 
index 217d13d468d8b9736f18e802a7d91129826c6d96..1c764572ebdd67838750c1c0e5e6db3b79d05656 100644 (file)
@@ -791,6 +791,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    771,
 /**/
     770,
 /**/