To: vim_dev@googlegroups.com Subject: Patch 8.2.3843 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3843 Problem: Dep3patch files are not recognized. Solution: Recognize dep3patch files by their location and content. (James McCoy, closes #9367) Files: runtime/autoload/dist/ft.vim, runtime/filetype.vim, src/testdir/test_filetype.vim *** ../vim-8.2.3842/runtime/autoload/dist/ft.vim 2021-11-30 13:02:55.120889114 +0000 --- runtime/autoload/dist/ft.vim 2021-12-17 20:51:31.096244024 +0000 *************** *** 811,816 **** --- 811,833 ---- endwhile endfunc + " This function is called for all files under */debian/patches/*, make sure not + " to non-dep3patch files, such as README and other text files. + func dist#ft#Dep3patch() + if expand('%:t') ==# 'series' + return + endif + + for ln in getline(1, 100) + if ln =~# '^\%(Description\|Subject\|Origin\|Bug\|Forwarded\|Author\|From\|Reviewed-by\|Acked-by\|Last-Updated\|Applied-Upstream\):' + setf dep3patch + return + elseif ln =~# '^---' + " end of headers found. stop processing + return + endif + endfor + endfunc " Restore 'cpoptions' let &cpo = s:cpo_save *** ../vim-8.2.3842/runtime/filetype.vim 2021-12-15 13:30:40.527268587 +0000 --- runtime/filetype.vim 2021-12-17 20:47:24.829978917 +0000 *************** *** 490,495 **** --- 490,498 ---- " Dictd config au BufNewFile,BufRead dictd*.conf setf dictdconf + " DEP3 formatted patch files + au BufNewFile,BufRead */debian/patches/* call dist#ft#Dep3patch() + " Diff files au BufNewFile,BufRead *.diff,*.rej setf diff au BufNewFile,BufRead *.patch *** ../vim-8.2.3842/src/testdir/test_filetype.vim 2021-12-15 13:30:40.527268587 +0000 --- src/testdir/test_filetype.vim 2021-12-17 20:47:24.829978917 +0000 *************** *** 1029,1032 **** --- 1029,1072 ---- filetype off endfunc + func Test_dep3patch_file() + filetype on + + call assert_true(mkdir('debian/patches', 'p')) + + " series files are not patches + call writefile(['Description: some awesome patch'], 'debian/patches/series') + split debian/patches/series + call assert_notequal('dep3patch', &filetype) + bwipe! + + " diff/patch files without the right headers should still show up as ft=diff + call writefile([], 'debian/patches/foo.diff') + split debian/patches/foo.diff + call assert_equal('diff', &filetype) + bwipe! + + " Files with the right headers are detected as dep3patch, even if they don't + " have a diff/patch extension + call writefile(['Subject: dep3patches'], 'debian/patches/bar') + split debian/patches/bar + call assert_equal('dep3patch', &filetype) + bwipe! + + " Files in sub-directories are detected + call assert_true(mkdir('debian/patches/s390x', 'p')) + call writefile(['Subject: dep3patches'], 'debian/patches/s390x/bar') + split debian/patches/s390x/bar + call assert_equal('dep3patch', &filetype) + bwipe! + + " The detection stops when seeing the "header end" marker + call writefile(['---', 'Origin: the cloud'], 'debian/patches/baz') + split debian/patches/baz + call assert_notequal('dep3patch', &filetype) + bwipe! + + call delete('debian/patches', 'rf') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3842/src/version.c 2021-12-17 20:36:11.204135975 +0000 --- src/version.c 2021-12-17 20:48:54.881279670 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3843, /**/ -- hundred-and-one symptoms of being an internet addict: 56. You leave the modem speaker on after connecting because you think it sounds like the ocean wind...the perfect soundtrack for "surfing the net". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///