patch 9.1.0401: filetype: zsh module files are not recognized

Commit: 
https://github.com/vim/vim/commit/887a38cee78c472fe406da60751fbba4a6ec19dd
Author: Wu, Zhenyu <wuzhe...@ustc.edu>
Date:   Thu May 9 20:35:13 2024 +0200

    patch 9.1.0401: filetype: zsh module files are not recognized
    
    Problem:  filetype: zsh module files are not recognized
    Solution: Detect '*.mdh' and '*.epro' as C filetype, '*.mdd' as zsh
              filetype, determine zsh-modules '*.pro' from from it's content
              (Wu, Zhenyu)
    
    closes: #14737
    
    Signed-off-by: Wu, Zhenyu <wuzhe...@ustc.edu>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 4e7d51793..dd4fd3063 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -406,14 +406,18 @@ export def FTidl()
   setf idl
 enddef
 
-# Distinguish between "default", Prolog and Cproto prototype file.
+# Distinguish between "default", Prolog, zsh module's C and Cproto prototype 
file.
 export def ProtoCheck(default: string)
+  # zsh modules use '#include "*.pro"'
+  # 
https://github.com/zsh-users/zsh/blob/63f086d167960a27ecdbcb762179e2c2bf8a29f5/Src/Modules/example.c#L31
+  if getline(1) =~ '/* Generated automatically */'
+    setf c
   # Cproto files have a comment in the first line and a function prototype in
   # the second line, it always ends in ";".  Indent files may also have
   # comments, thus we can't match comments to see the difference.
   # IDL files can have a single ';' in the second line, require at least one
   # chacter before the ';'.
-  if getline(2) =~ '.;$'
+  elseif getline(2) =~ '.;$'
     setf cpp
   else
     # recognize Prolog by specific text in the first non-empty line
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index f45866cb8..bc3a488ea 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1072,7 +1072,7 @@ au BufNewFile,BufRead */.icewm/menu               setf 
icemenu
 au BufNewFile,BufRead .indent.pro              setf indent
 au BufNewFile,BufRead indent.pro               call 
dist#ft#ProtoCheck('indent')
 
-" IDL (Interactive Data Language)
+" IDL (Interactive Data Language), Prolog, Cproto or zsh module C
 au BufNewFile,BufRead *.pro                    call 
dist#ft#ProtoCheck('idlang')
 
 " Indent RC
@@ -3093,6 +3093,13 @@ au BufNewFile,BufRead */etc/yum.repos.d/*        call 
s:StarSetf('dosini')
 au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
 au BufNewFile,BufRead zsh*,zlog*               call s:StarSetf('zsh')
 
+" Zsh module
+" *.mdd will generate *.mdh, *.pro and *.epro.
+" module's *.c will #include *.mdh containing module dependency information and
+" *.pro containing all static declarations of *.c
+" *.epro contains all external declarations of *.c
+au BufNewFile,BufRead *.mdh,*.epro             setf c
+au BufNewFile,BufRead *.mdd                    setf zsh
 
 " Help files match *.txt but should have a last line that is a modeline.
 au BufNewFile,BufRead *.txt
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index c98bb56df..b057253d3 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -131,7 +131,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     bst: ['file.bst'],
     bzl: ['file.bazel', 'file.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod'],
     bzr: ['bzr_log.any', 'bzr_log.file'],
-    c: ['enlightenment/file.cfg', 'file.qc', 'file.c', 
'some-enlightenment/file.cfg'],
+    c: ['enlightenment/file.cfg', 'file.qc', 'file.c', 
'some-enlightenment/file.cfg', 'file.mdh', 'file.epro'],
     cabal: ['file.cabal'],
     cabalconfig: ['cabal.config', expand("$HOME/.config/cabal/config")] + 
WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'),
     cabalproject: ['cabal.project', 'cabal.project.local'],
@@ -855,7 +855,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     zsh: ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh', 
'file.zsh-theme', 'file.zunit',
           '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', 
'.zsh_history',
           '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file',
-          'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'],
+          'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file', 
'file.mdd'],
 
     help: [$VIMRUNTIME .. '/doc/help.txt'],
     }
diff --git a/src/version.c b/src/version.c
index db95d7b56..d166268cc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    401,
 /**/
     400,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1s58lL-008sOU-Gt%40256bit.org.

Raspunde prin e-mail lui