To: vim-dev@vim.org Subject: Patch 6.2.073 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.073 Problem: When adding detection of a specific filetype for a plugin you need to edit "filetype.vim". Solution: Source files from the "ftdetect" directory, so that a filetype detection plugin only needs to be dropped in a directory. Files: runtime/doc/filetype.txt, runtime/doc/usr_05.txt, runtime/doc/usr_41.txt, runtime/filetype.vim *** ../vim-6.2.072/runtime/doc/filetype.txt Sun Jun 1 12:20:32 2003 --- runtime/doc/filetype.txt Thu Aug 14 11:22:30 2003 *************** *** 1,4 **** ! *filetype.txt* For Vim version 6.2. Last change: 2003 Apr 25 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *filetype.txt* For Vim version 6.2. Last change: 2003 Aug 14 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 147,157 **** This means that the contents of compressed files are not inspected. *new-filetype* ! If a file type that you want to use is not detected yet, there are two ways to ! add it. In any way, it's better not modify the $VIMRUNTIME/filetype.vim file. ! It will be overwritten when installing a new version of Vim. ! A. If your file type can be detected by the file name. 1. Create your user runtime directory. You would normally use the first item of the 'runtimepath' option. Example for Unix: > :!mkdir ~/.vim --- 147,187 ---- This means that the contents of compressed files are not inspected. *new-filetype* ! If a file type that you want to use is not detected yet, there are three ways ! to add it. In any way, it's better not modify the $VIMRUNTIME/filetype.vim ! file. It will be overwritten when installing a new version of Vim. ! ! A. If you want to overrule all default file type checks. ! This works by writing one file for each filetype. The disadvantage is that ! means there can be many files. The advantage is that you can simply drop ! this file in the right directory to make it work. ! 1. Create your user runtime directory. You would normally use the first ! item of the 'runtimepath' option. Then create the directory "ftdetect" ! inside it. Example for Unix: > ! :!mkdir ~/.vim ! :!mkdir ~/.vim/ftdetect ! < ! 2. Create a file that contains an autocommand to detect the file type. ! Example: > ! au BufRead,BufNewFile *.mine set filetype=mine ! < Note that there is no "augroup" command, this has already been done ! when sourcing your file. You could also use the pattern "*" and then ! check the contents of the file to recognize it. ! Write this file as "mine.vim" in the "filetype" directory in your user ! runtime directory. For example, for Unix: > ! :w ~/.vim/ftdetect/mine.vim ! ! < 3. To use the new filetype detection you must restart Vim. ! ! The files in the "filetype" directory are used after all the default ! checks, thus they can overrule a previously detected file type. You can ! also use that in your command. For example, to use the file type ! "mypascal" when "pascal" has been detected: > ! au BufRead,BufNewFile * if ft == 'pascal' | set ft=mypascal ! | endif ! ! B. If your file type can be detected by the file name. 1. Create your user runtime directory. You would normally use the first item of the 'runtimepath' option. Example for Unix: > :!mkdir ~/.vim *************** *** 177,183 **** ":setfiletype" command will make sure that no other autocommands will set 'filetype' after this. *new-filetype-scripts* ! B. If your filetype can only be detected by inspecting the contents of the file. 1. Create your user runtime directory. You would normally use the first --- 207,213 ---- ":setfiletype" command will make sure that no other autocommands will set 'filetype' after this. *new-filetype-scripts* ! C. If your filetype can only be detected by inspecting the contents of the file. 1. Create your user runtime directory. You would normally use the first *** ../vim-6.2.072/runtime/doc/usr_05.txt Sun Jun 1 12:20:36 2003 --- runtime/doc/usr_05.txt Wed Aug 13 22:15:03 2003 *************** *** 1,4 **** ! *usr_05.txt* For Vim version 6.2. Last change: 2003 Mar 15 VIM USER MANUAL - by Bram Moolenaar --- 1,4 ---- ! *usr_05.txt* For Vim version 6.2. Last change: 2003 Aug 13 VIM USER MANUAL - by Bram Moolenaar *************** *** 406,411 **** --- 406,412 ---- |write-plugin| How to write a plugin script. |plugin-details| For more information about using plugins or when your plugin doesn't work. + |new-filetype| How to detect a new file type. ============================================================================== *05.5* Adding a help file *add-local-help* *matchit-install* *** ../vim-6.2.072/runtime/doc/usr_41.txt Sat Jul 5 19:20:12 2003 --- runtime/doc/usr_41.txt Thu Aug 14 11:22:51 2003 *************** *** 1,4 **** ! *usr_41.txt* For Vim version 6.2. Last change: 2003 Jun 03 VIM USER MANUAL - by Bram Moolenaar --- 1,4 ---- ! *usr_41.txt* For Vim version 6.2. Last change: 2003 Aug 14 VIM USER MANUAL - by Bram Moolenaar *************** *** 1432,1437 **** --- 1434,1457 ---- Using references to other parts of the help in || is recommended. This makes it easy for the user to find associated help. + + + FILETYPE DETECTION *plugin-filetype* + + If your filetype is not already detected by Vim, you should create a filetype + detection snippet in a separate file. It is usually in the form of an + autocommand that sets the filetype when the file name matches a pattern. + Example: > + + au BufNewFile,BufRead *.foo set filetype=foofoo + + Write this single-line file as "ftdetect/foofoo.vim" in the first directory + that appears in 'runtimepath'. For Unix that would be + "~/.vim/ftdetect/foofoo.vim". The convention is to use the name of the + filetype for the script name. + + You can make more complicated checks if you like, for example to inspect the + contents of the file to recognize the language. Also see |new-filetype|. SUMMARY *plugin-special* *** ../vim-6.2.072/runtime/filetype.vim Fri Jul 25 21:39:40 2003 --- runtime/filetype.vim Sun Aug 17 22:05:19 2003 *************** *** 1,7 **** " Vim support file to detect file types " " Maintainer: Bram Moolenaar ! " Last Change: 2003 Jul 23 " Listen very carefully, I will say this only once if exists("did_load_filetypes") --- 1,7 ---- " Vim support file to detect file types " " Maintainer: Bram Moolenaar ! " Last Change: 2003 Aug 17 " Listen very carefully, I will say this only once if exists("did_load_filetypes") *************** *** 1551,1556 **** --- 1575,1584 ---- \ || getline(4) =~ '^#' || getline(5) =~ '^#') | \ setf conf | \ endif + + " Use the plugin-filetype checks last, they may overrule any of the previously + " detected filetypes. + runtime! ftdetect/*.vim augroup END *** ../vim-6.2.072/src/version.c Tue Sep 2 22:22:59 2003 --- src/version.c Tue Sep 9 22:14:57 2003 *************** *** 632,633 **** --- 632,635 ---- { /* Add new patch number below this line */ + /**/ + 73, /**/ -- The war between Emacs and Vi is over. Vi has won with 3 to 1. http://www.ssc.com/lg/issue30/raymond.html /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///