BuffOptions.vim - Per-buffer options and mappings
Introduction:
Some of Vim's options are set per-buffer, but not all. This extension allows you to set any options and also mappings for a particular buffer or filetype.

The idea is that you push options onto a stack (the old values are in fact what are pushed) with PushOption( ... ) and then restore the values with RestoreOptions().

An extension to the filetypes allow easy use of these macros for a specific filetype. The autocommands filetypeEnter and filetypeLeave have been added.

Base Commands:
PushOption( option1|map1|menu1|abbrev1, value1, ...) - Push any number option/value pairs where:
optionn is a vim 'option' name.
mapn is a map of the form '{n|v|o|i|c}map <lhs>' defining what kind of map is being defined (mandatory with multiple allowed)
abbrevn is an insert mode abbreviation - the abbreviation is set by push and deleted by RestoreOptions() (as it is not possible to silently check for original abbreviations).
menun is a menu setting of the form '{a|n|v|o|i|c}menu <lhs>' defining where the menu is available. <lhs> can include the position of the menu (eg '100.100 Tools.Test')
valuen is the value or mapping to set.
RestoreOptions() - Restore all options to their previous value
autocomd User filetypeEnter - Called on 'BufEnter' of a file of filetype.
autocomd User filetypeLeave - Called on 'BufLeave' of a file of filetype.
ReadFileTypeMap(types, filename) - Source filename with per-buffer map/menu options defaulting to the specified list offiletypes. Lines of the form:
" FileTypes: cpp
Example:

Mappings from filetype files
For when you have a file that is used for the mappings for a particular filetype.
All lines in the file except those starting with map and menu will get executed. Any maps/menus will get inserted into a BuffOption() for the specified filetype

Commands:
FTExe(Filetypes, command) - Have mapping/menu command executed as a per-buffer option for the specified (comma separated) filetypes
ReadFileTypeMap(filetypes,filename) - Sets all map/menu entries existing in filename to be specific to the filetypes specified and executes all other lines. Comment lines of the form:
"FileTypes: cpp,c,rc,idl

will cause the following maps/menus to be for the specified filetypes. A blank filetype string causes the maps/menus to be executed immediately.

This implementation requires the existance of buffoptions_mac.vim in the same directory as buffoptions.vim
The source code for that is in an if 0 block at the bottom of buffoptions.vim

Allow sourced scripts to have <buffer> tags and <SID> so that scripts can behave as file-type plugins for vim 6 as well as buffoptions SOURCE scripts for 5.6 and above.
Note that the buffoptions_mac.vim will need to be recreated (extract it from the bottom of the file).