Patch 9.0.0012
Problem:    Signature files not detected properly.
Solution:   Add a function to better detect signature files. (Doug Kearns)
Files:      runtime/autoload/dist/ft.vim, runtime/doc/filetype.txt,
            runtime/filetype.vim, src/testdir/test_filetype.vim


*** ../vim-9.0.0011/runtime/autoload/dist/ft.vim        2022-06-29 
14:39:07.909560028 +0100
--- runtime/autoload/dist/ft.vim        2022-06-30 16:11:25.909233143 +0100
***************
*** 459,465 ****
    setf nroff
  enddef
  
! # Returns true if file content looks like LambdaProlog
  def IsLProlog(): bool
    # skip apparent comments and blank lines, what looks like 
    # LambdaProlog comment may be RAPID header
--- 459,465 ----
    setf nroff
  enddef
  
! # Returns true if file content looks like LambdaProlog module
  def IsLProlog(): bool
    # skip apparent comments and blank lines, what looks like 
    # LambdaProlog comment may be RAPID header
***************
*** 848,853 ****
--- 848,874 ----
    return 0
  enddef
  
+ # LambdaProlog and Standard ML signature files
+ export def FTsig()
+   if exists("g:filetype_sig")
+     exe "setf " .. g:filetype_sig
+     return
+   endif
+ 
+   var lprolog_comment = '^\s*\%(/\*\|%\)'
+   var lprolog_keyword = '^\s*sig\s\+\a'
+   var sml_comment = '^\s*(\*'
+   var sml_keyword = '^\s*\%(signature\|structure\)\s\+\a'
+ 
+   var line = getline(nextnonblank(1))
+ 
+   if line =~ lprolog_comment || line =~# lprolog_keyword
+     setf lprolog
+   elseif line =~ sml_comment || line =~# sml_keyword
+     setf sml
+   endif
+ enddef
+ 
  export def FTsys()
    if exists("g:filetype_sys")
      exe "setf " .. g:filetype_sys
*** ../vim-9.0.0011/runtime/doc/filetype.txt    2022-06-29 14:39:07.909560028 
+0100
--- runtime/doc/filetype.txt    2022-06-30 16:13:56.852909515 +0100
***************
*** 157,162 ****
--- 157,163 ----
        *.pp            g:filetype_pp   |ft-pascal-syntax|
        *.prg           g:filetype_prg
        *.r             g:filetype_r
+       *.sig           g:filetype_sig
        *.sql           g:filetype_sql  |ft-sql-syntax|
        *.src           g:filetype_src
        *.sys           g:filetype_sys
*** ../vim-9.0.0011/runtime/filetype.vim        2022-06-29 14:39:07.909560028 
+0100
--- runtime/filetype.vim        2022-06-30 16:11:42.333197192 +0100
***************
*** 997,1004 ****
  " Limits
  au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf  
setf limits
  
! " LambdaProlog (see dist#ft#FTmod for *.mod)
! au BufNewFile,BufRead *.sig                   setf lprolog
  
  " LDAP LDIF
  au BufNewFile,BufRead *.ldif                  setf ldif
--- 997,1004 ----
  " Limits
  au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf  
setf limits
  
! " LambdaProlog or SML (see dist#ft#FTmod for *.mod)
! au BufNewFile,BufRead *.sig                   call dist#ft#FTsig()
  
  " LDAP LDIF
  au BufNewFile,BufRead *.ldif                  setf ldif
*** ../vim-9.0.0011/src/testdir/test_filetype.vim       2022-06-29 
14:39:07.909560028 +0100
--- src/testdir/test_filetype.vim       2022-06-30 16:21:59.667479391 +0100
***************
*** 313,319 ****
      \ 'lotos': ['file.lot', 'file.lotos'],
      \ 'lout': ['file.lou', 'file.lout'],
      \ 'lpc': ['file.lpc', 'file.ulpc'],
-     \ 'lprolog': ['file.sig'],
      \ 'lsl': ['file.lsl'],
      \ 'lss': ['file.lss'],
      \ 'lua': ['file.lua', 'file.rockspec', 'file.nse'],
--- 313,318 ----
***************
*** 1760,1763 ****
--- 1759,1817 ----
    filetype off
  endfunc
  
+ func Test_sig_file()
+   filetype on
+ 
+   call writefile(['this is neither Lambda Prolog nor SML'], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('', &filetype)
+   bwipe!
+ 
+   " Test dist#ft#FTsig()
+ 
+   let g:filetype_sig = 'sml'
+   split Xfile.sig
+   call assert_equal('sml', &filetype)
+   bwipe!
+   unlet g:filetype_sig
+ 
+   " Lambda Prolog
+ 
+   call writefile(['sig foo.'], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('lprolog', &filetype)
+   bwipe!
+ 
+   call writefile(['/* ... */'], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('lprolog', &filetype)
+   bwipe!
+ 
+   call writefile(['% ...'], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('lprolog', &filetype)
+   bwipe!
+ 
+   " SML signature file
+ 
+   call writefile(['signature FOO ='], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('sml', &filetype)
+   bwipe!
+ 
+   call writefile(['structure FOO ='], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('sml', &filetype)
+   bwipe!
+ 
+   call writefile(['(* ... *)'], 'Xfile.sig')
+   split Xfile.sig
+   call assert_equal('sml', &filetype)
+   bwipe!
+ 
+   call delete('Xfile.sig')
+   filetype off
+ endfunc
+ 
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0011/src/version.c       2022-06-30 12:30:13.823485781 +0100
--- src/version.c       2022-06-30 16:19:20.419923878 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     12,
  /**/

-- 
"Space is big.  Really big.  You just won't believe how vastly hugely mind-
bogglingly big it is.  I mean, you may think it's a long way down the
road to the chemist, but that's just peanuts to space."
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220630152617.4A85A1C0EFF%40moolenaar.net.

Raspunde prin e-mail lui