sponsor Vim development Vim logo Vim Book Ad

Buffer Menus : Add menus for the current buffer only.

 script karma  Rating 9/6, Downloaded by 2565    Comments, bugs, improvements  Vim wiki

created by
Michael Geddes
 
script type
utility
 
description
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


Usage -
:Bmenu[!] ["<silent>"] ["<unmenu>"|"<disable>"] [<modes>] [<priority>] <Menuname> <Mapping>
Add menus to different modes for the current buffer.  (Bang is used to
        specify 'noremenu')
: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>


:Bunmenuall
      Remove all menus for the current buffer

BufferOneShot( <ident> )
Use this to make sure Bmenus only get added ONCE per buffer.
eg:
if BufferOneShot('MyProgram')
Bmenu 10.20 Test.Test iHello<esc>
endif
A buffer local-variable called b:buffer_oneshot_MyProgram will be
created (just in case you want to unlet it when testing).

exe FindBufferSID()
:exe the result of this function when using <SID> in menu commands so that the correct
function gets called.

 
install details
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 )
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
buffermenu.vim 1.9 2002-04-10 6.0 Michael Geddes 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.

buffermenu.vim 1.6 2002-04-03 6.0 Michael Geddes Fix up a bug where spaces are used in the mapping part were causing an error to be reported.
buffermenu.vim 1.5 2002-04-02 6.0 Michael Geddes 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.
buffermenu.vim 1.3 2002-04-02 6.0 Michael Geddes Allow menus with spaces to work.
Echo errors using echoerr so that they are reported properly
buffermenu.vim 1.2 2002-03-21 6.0 Michael Geddes Don't add menus to the buffer-list that produce an error when first adding.
buffermenu.vim 1.1 2002-03-21 6.0 Michael Geddes Enhancements:
- <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

Bugfixes:
- Bamenu Bcmenu Bnmenu  now pass the correct parameters and won't give an error
- Bunmenuall now works.
buffermenu.vim 1.0 2002-03-13 6.0 Michael Geddes Initial upload
ip used for rating: 54.166.61.100

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo