To: vim_dev@googlegroups.com Subject: Patch 9.0.1623 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1623 Problem: The program to filetype translation is not exported. Solution: Export Exe2filetype(). Files: runtime/autoload/dist/ft.vim, runtime/autoload/dist/script.vim *** ../vim-9.0.1622/runtime/autoload/dist/ft.vim 2023-05-29 19:59:38.217805411 +0100 --- runtime/autoload/dist/ft.vim 2023-06-09 20:57:34.635375695 +0100 *************** *** 3,9 **** # Vim functions for file type detection # # Maintainer: Bram Moolenaar ! # Last Change: 2022 Apr 13 # These functions are moved here from runtime/filetype.vim to make startup # faster. --- 3,9 ---- # Vim functions for file type detection # # Maintainer: Bram Moolenaar ! # Last Change: 2023 Jun 09 # These functions are moved here from runtime/filetype.vim to make startup # faster. *************** *** 362,369 **** else # recognize Prolog by specific text in the first non-empty line # require a blank after the '%' because Perl uses "%list" and "%translate" ! var l = getline(nextnonblank(1)) ! if l =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' setf prolog else exe 'setf ' .. default --- 362,369 ---- else # recognize Prolog by specific text in the first non-empty line # require a blank after the '%' because Perl uses "%list" and "%translate" ! var lnum = getline(nextnonblank(1)) ! if lnum =~ '\' || lnum =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || lnum =~ ':-' setf prolog else exe 'setf ' .. default *************** *** 472,483 **** def IsLProlog(): bool # skip apparent comments and blank lines, what looks like # LambdaProlog comment may be RAPID header ! var l: number = nextnonblank(1) ! while l > 0 && l < line('$') && getline(l) =~ '^\s*%' # LambdaProlog comment ! l = nextnonblank(l + 1) endwhile # this pattern must not catch a go.mod file ! return getline(l) =~ '\ 0 && lnum < line('$') && getline(lnum) =~ '^\s*%' # LambdaProlog comment ! lnum = nextnonblank(lnum + 1) endwhile # this pattern must not catch a go.mod file ! return getline(lnum) =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' setf prolog else setf perl --- 504,511 ---- else # recognize Prolog by specific text in the first non-empty line # require a blank after the '%' because Perl uses "%list" and "%translate" ! var line = getline(nextnonblank(1)) ! if line =~ '\' || line =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || line =~ ':-' setf prolog else setf perl *************** *** 678,703 **** enddef # Called from filetype.vim and scripts.vim. ! export def SetFileTypeSH(name: string) ! if did_filetype() # Filetype was already detected ! return endif ! if expand("") =~ g:ft_ignore_pat ! return endif if name =~ '\' # Some .sh scripts contain #!/bin/csh. ! SetFileTypeShell("csh") ! return elseif name =~ '\' # Some .sh scripts contain #!/bin/tcsh. ! SetFileTypeShell("tcsh") ! return elseif name =~ '\' # Some .sh scripts contain #!/bin/zsh. ! SetFileTypeShell("zsh") ! return elseif name =~ '\' b:is_kornshell = 1 if exists("b:is_bash") --- 678,701 ---- enddef # Called from filetype.vim and scripts.vim. ! # When "setft" is passed and false then the 'filetype' option is not set. ! export def SetFileTypeSH(name: string, setft = true): string ! if setft && did_filetype() # Filetype was already detected ! return '' endif ! if setft && expand("") =~ g:ft_ignore_pat ! return '' endif if name =~ '\' # Some .sh scripts contain #!/bin/csh. ! return SetFileTypeShell("csh", setft) elseif name =~ '\' # Some .sh scripts contain #!/bin/tcsh. ! return SetFileTypeShell("tcsh", setft) elseif name =~ '\' # Some .sh scripts contain #!/bin/zsh. ! return SetFileTypeShell("zsh", setft) elseif name =~ '\' b:is_kornshell = 1 if exists("b:is_bash") *************** *** 724,757 **** unlet b:is_bash endif endif ! SetFileTypeShell("sh") enddef # For shell-like file types, check for an "exec" command hidden in a comment, # as used for Tcl. # Also called from scripts.vim, thus can't be local to this script. ! export def SetFileTypeShell(name: string) ! if did_filetype() # Filetype was already detected ! return endif ! if expand("") =~ g:ft_ignore_pat ! return endif ! var l = 2 ! while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' # Skip empty and comment lines. ! l += 1 endwhile ! if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' # Found an "exec" line after a comment with continuation ! var n = substitute(getline(l), '\s*exec\s\+\([^ ]*/\)\=', '', '') if n =~ '\