Buffer Menus : Add menus for the current buffer only.
| script karma
Downloaded by 2845
Comments, bugs, improvements
script versions (upload new version)
|Adds menus for the current buffer. When you leave the buffer, they get removed, and when you go back in, they are added again.
It cannot be used effectively to replace a menu as it is not possible to find out what the mapping used to be (as for map commands), and therefore not possible to restore it (*sigh*)
This is taken from my 'buffoptions' script, and should be useful in enabling menus to be added to ftplugin scripts.
NOTE: When adding to ftplugin scripts make VERY sure that the menus only get added ONCE (reinclude protection is good here).
TODO: (Please email me to add to this list)
- Allow 'Unmenu' of individual menus
:Bmenu[!] ["<silent>"] ["<unmenu>"|"<disable>"] [<modes>] [<priority>] <Menuname> <Mapping>
Add menus to different modes for the current buffer. (Bang is used to
:B[ivacn]menu[!]["<silent>"] ["<unmenu>"|"<disable>"] [<priority>] <Menuname> <Mapping>
Add menu for one mode (or 'a' for all modes) for the current buffer.
(Bang is used to specify 'noremenu')
B[ivacn]noremenu ["<silent>"] ["<unmenu>"|"<disable>"] [<modes>] [<priority>] <Menuname> <Mapping>
Adds a 'norecursive' menu.
The above commands accept '<silent>' as a flag to do a silent mapping.
They also allow <SID> (providing you have done the "exe FindBufferSID()"
at the beginning of the script), and will expand <leader> and <localleader>
in menu names.
If g:buffermenu_use_disable is set to 1 then all buffermenus use
enable/disable to update the menus. Otherwise, they will use menu/unmenu.
To override for one menu only, use <unmenu> or <disable>
Remove all menus for the current buffer
BufferOneShot( <ident> )
Use this to make sure Bmenus only get added ONCE per buffer.
Bmenu 10.20 Test.Test iHello<esc>
A buffer local-variable called b:buffer_oneshot_MyProgram will be
created (just in case you want to unlet it when testing).
:exe the result of this function when using <SID> in menu commands so that the correct
function gets called.
|This should be used as a general plugin - dump it into the plugin directory.
(Without the s: and <SID> it should work for 5.6, 5.7 as well, sourced from your vimrc )
Click on the package to download.
ip used for rating: 188.8.131.52
||Added noremenu mappings and <silent> support (thanks Luc).
Updated the documentation.
Made provision for using <SID> in a mapping - careful you'll need to read the docs on this one.
Added a global option to use menu enable menu disable instead of unmenu.
Added <unmenu> and <disable> options to specify explicitly whether to disable or unmenu the mapping.
||Fix up a bug where spaces are used in the mapping part were causing an error to be reported.
||For some reason when pressing ctrl+^ I was getting two buffer unloads - this was causing menus to be undone twice and lots of errors. I have now fixed it to make sure it only undoes the menus once.
||Allow menus with spaces to work.
Echo errors using echoerr so that they are reported properly
||Don't add menus to the buffer-list that produce an error when first adding.
- <maplocalleader> and <mapleader> now get expanded when adding - this means you can do:
Bamenu Test.Test<tab><maplocalleader>aa <maplocalleader>aa
And get a menu with the 'help' showing the actual localleader/leader
- Bamenu Bcmenu Bnmenu now pass the correct parameters and won't give an error
- Bunmenuall now works.