Skip to content

Commit eb2aebe

Browse files
lacygoillchrisbra
authored andcommitted
patch 9.1.1606: filetype: a few more files are not recognized
Problem: filetype: a few more files are not recognized Solution: guess Mail, Info and Terminfo files by its content (lacygoill) closes: #17880 Signed-off-by: lacygoill <lacygoill@lacygoill.me> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 8a65a49 commit eb2aebe

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

runtime/autoload/dist/script.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def DetectFromText(line1: string)
264264

265265
# ELM Mail files
266266
elseif line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$'
267+
|| line1 =~ '^\creturn-path:\s<.*@.*>$'
267268
setl ft=mail
268269

269270
# Mason
@@ -453,6 +454,12 @@ def DetectFromText(line1: string)
453454
elseif line1 =~ '^#n\%($\|\s\)'
454455
setl ft=sed
455456

457+
elseif line1 =~ '^#\s\+Reconstructed via infocmp from file:'
458+
setl ft=terminfo
459+
460+
elseif line1 =~ '^File: .*\.info, Node: .*, \%(Next\|Prev\): .*, Up: \|This is the top of the INFO tree.'
461+
setl ft=info
462+
456463
else
457464
var lnum = 1
458465
while getline(lnum) =~ "^? " && lnum < line("$")

src/testdir/test_filetype.vim

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,6 +3024,39 @@ func Test_org_file()
30243024
filetype off
30253025
endfunc
30263026

3027+
func Test_info_file()
3028+
filetype on
3029+
3030+
call writefile(['File: coreutils.info, Node: Top, Next: Introduction, Up: (dir)', 'D'], 'Xfile', 'D')
3031+
split Xfile
3032+
call assert_equal('info', &filetype)
3033+
bwipe!
3034+
3035+
filetype off
3036+
endfunc
3037+
3038+
func Test_mail_file()
3039+
filetype on
3040+
3041+
call writefile(['Return-path: <lgc@debian.home.arpa>', 'D'], 'Xfile', 'D')
3042+
split Xfile
3043+
call assert_equal('mail', &filetype)
3044+
bwipe!
3045+
3046+
filetype off
3047+
endfunc
3048+
3049+
func Test_terminfo_file()
3050+
filetype on
3051+
3052+
call writefile(['# Reconstructed via infocmp from file: /etc/terminfo/x/xterm', 'D'], 'Xfile', 'D')
3053+
split Xfile
3054+
call assert_equal('terminfo', &filetype)
3055+
bwipe!
3056+
3057+
filetype off
3058+
endfunc
3059+
30273060
" Filetypes detected from names of existing files
30283061
func Test_pacmanlog()
30293062
filetype on

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1606,
722724
/**/
723725
1605,
724726
/**/

0 commit comments

Comments
 (0)