To: vim_dev@googlegroups.com Subject: Patch 9.0.1632 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1632 Problem: Not all cabal config files are recognized. Solution: Add a couple of patterns. (Marcin Szamotulski, closes #12463) Files: runtime/filetype.vim, src/testdir/test_filetype.vim *** ../vim-9.0.1631/runtime/filetype.vim 2023-06-09 19:19:59.627215494 +0100 --- runtime/filetype.vim 2023-06-14 19:42:45.298610704 +0100 *************** *** 784,790 **** au BufNewFile,BufRead *.git/config.worktree setf gitconfig au BufNewFile,BufRead *.git/worktrees/*/config.worktree setf gitconfig au BufNewFile,BufRead .gitmodules,*.git/modules/*/config setf gitconfig ! if !empty($XDG_CONFIG_HOME) au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig au BufNewFile,BufRead $XDG_CONFIG_HOME/git/attributes setf gitattributes au BufNewFile,BufRead $XDG_CONFIG_HOME/git/ignore setf gitignore --- 784,790 ---- au BufNewFile,BufRead *.git/config.worktree setf gitconfig au BufNewFile,BufRead *.git/worktrees/*/config.worktree setf gitconfig au BufNewFile,BufRead .gitmodules,*.git/modules/*/config setf gitconfig ! if exists('$XDG_CONFIG_HOME') au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig au BufNewFile,BufRead $XDG_CONFIG_HOME/git/attributes setf gitattributes au BufNewFile,BufRead $XDG_CONFIG_HOME/git/ignore setf gitignore *************** *** 886,891 **** --- 886,895 ---- au BufNewFile,BufRead *.chs setf chaskell au BufNewFile,BufRead cabal.project setf cabalproject au BufNewFile,BufRead $HOME/.cabal/config setf cabalconfig + if exists('$XDG_CONFIG_HOME') + au BufNewFile,BufRead $XDG_CONFIG_HOME/cabal/config setf cabalconfig + endif + au BufNewFile,BufRead $HOME/.config/cabal/config setf cabalconfig au BufNewFile,BufRead cabal.config setf cabalconfig " Haste *** ../vim-9.0.1631/src/testdir/test_filetype.vim 2023-06-09 19:19:59.627215494 +0100 --- src/testdir/test_filetype.vim 2023-06-14 19:43:37.830711332 +0100 *************** *** 40,45 **** --- 40,69 ---- filetype off endfunc + " If $XDG_CONFIG_HOME is set return "fname" expanded in a list. + " Otherwise return an empty list. + def s:WhenConfigHome(fname: string): list + if exists('$XDG_CONFIG_HOME') + return [expand(fname)] + endif + return [] + enddef + + " Return the name used for the $XDG_CONFIG_HOME directory. + def s:GetConfigHome(): string + return getcwd() .. '/Xdg_config_home' + enddef + + " saved value of $XDG_CONFIG_HOME + let s:saveConfigHome = '' + + def s:SetupConfigHome() + if empty(windowsversion()) + s:saveConfigHome = $XDG_CONFIG_HOME + setenv("XDG_CONFIG_HOME", GetConfigHome()) + endif + enddef + " Filetypes detected just from matching the file name. " First one is checking that these files have no filetype. def s:GetFilenameChecks(): dict> *************** *** 95,101 **** bzr: ['bzr_log.any', 'bzr_log.file'], c: ['enlightenment/file.cfg', 'file.qc', 'file.c', 'some-enlightenment/file.cfg'], cabal: ['file.cabal'], ! cabalconfig: ['cabal.config'], cabalproject: ['cabal.project', 'cabal.project.local'], cairo: ['file.cairo'], calendar: ['calendar', '/.calendar/file', '/share/calendar/any/calendar.file', '/share/calendar/calendar.file', 'any/share/calendar/any/calendar.file', 'any/share/calendar/calendar.file'], --- 119,125 ---- bzr: ['bzr_log.any', 'bzr_log.file'], c: ['enlightenment/file.cfg', 'file.qc', 'file.c', 'some-enlightenment/file.cfg'], cabal: ['file.cabal'], ! cabalconfig: ['cabal.config', expand("$HOME/.config/cabal/config")] + WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'), cabalproject: ['cabal.project', 'cabal.project.local'], cairo: ['file.cairo'], calendar: ['calendar', '/.calendar/file', '/share/calendar/any/calendar.file', '/share/calendar/calendar.file', 'any/share/calendar/any/calendar.file', 'any/share/calendar/calendar.file'], *************** *** 229,238 **** gedcom: ['file.ged', 'lltxxxxx.txt', '/tmp/lltmp', '/tmp/lltmp-file', 'any/tmp/lltmp', 'any/tmp/lltmp-file'], gemtext: ['file.gmi', 'file.gemini'], gift: ['file.gift'], ! gitattributes: ['file.git/info/attributes', '.gitattributes', '/.config/git/attributes', '/etc/gitattributes', '/usr/local/etc/gitattributes', 'some.git/info/attributes'], gitcommit: ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG', 'NOTES_EDITMSG', 'EDIT_DESCRIPTION'], ! gitconfig: ['file.git/config', 'file.git/config.worktree', 'file.git/worktrees/x/config.worktree', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig', '/usr/local/etc/gitconfig', '/etc/gitconfig.d/file', 'any/etc/gitconfig.d/file', '/.gitconfig.d/file', 'any/.config/git/config', 'any/.gitconfig.d/file', 'some.git/config', 'some.git/modules/any/config'], ! gitignore: ['file.git/info/exclude', '.gitignore', '/.config/git/ignore', 'some.git/info/exclude'], gitolite: ['gitolite.conf', '/gitolite-admin/conf/file', 'any/gitolite-admin/conf/file'], gitrebase: ['git-rebase-todo'], gitsendemail: ['.gitsendemail.msg.xxxxxx'], --- 253,262 ---- gedcom: ['file.ged', 'lltxxxxx.txt', '/tmp/lltmp', '/tmp/lltmp-file', 'any/tmp/lltmp', 'any/tmp/lltmp-file'], gemtext: ['file.gmi', 'file.gemini'], gift: ['file.gift'], ! gitattributes: ['file.git/info/attributes', '.gitattributes', '/.config/git/attributes', '/etc/gitattributes', '/usr/local/etc/gitattributes', 'some.git/info/attributes'] + WhenConfigHome('$XDG_CONFIG_HOME/git/attributes'), gitcommit: ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG', 'NOTES_EDITMSG', 'EDIT_DESCRIPTION'], ! gitconfig: ['file.git/config', 'file.git/config.worktree', 'file.git/worktrees/x/config.worktree', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig', '/usr/local/etc/gitconfig', '/etc/gitconfig.d/file', 'any/etc/gitconfig.d/file', '/.gitconfig.d/file', 'any/.config/git/config', 'any/.gitconfig.d/file', 'some.git/config', 'some.git/modules/any/config'] + WhenConfigHome('$XDG_CONFIG_HOME/git/config'), ! gitignore: ['file.git/info/exclude', '.gitignore', '/.config/git/ignore', 'some.git/info/exclude'] + WhenConfigHome('$XDG_CONFIG_HOME/git/ignore'), gitolite: ['gitolite.conf', '/gitolite-admin/conf/file', 'any/gitolite-admin/conf/file'], gitrebase: ['git-rebase-todo'], gitsendemail: ['.gitsendemail.msg.xxxxxx'], *************** *** 807,812 **** --- 831,842 ---- enddef def Test_filetype_detection() + SetupConfigHome() + if !empty(s:saveConfigHome) + defer setenv("XDG_CONFIG_HOME", s:saveConfigHome) + endif + mkdir(GetConfigHome(), 'R') + filetype on CheckItems(s:GetFilenameChecks()) if has('fname_case') *** ../vim-9.0.1631/src/version.c 2023-06-14 16:39:48.657873849 +0100 --- src/version.c 2023-06-14 19:44:08.922765583 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1632, /**/ -- Did you ever see a "Hit any key to continue" message in a music piece? /// 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 ///