hello world,

This is my attempt to add neat menus in vim using buffers. It can be
usefull if you have a script that can save some options in a file.

the idea is: 

- call NewBufferAsMenu('Foo') opens a new buffer with some content (r!ls
  is just for test). Foo will be executed when the <space> key is
  pressed. 
- Foo stores the current line in g:boom that will be used for another
  function.

My pb is that Foo doesn't carre about the line under the cursor and
always reply 0. 

I don't want to debug this script in particular: i just want to have a
menu that can return a value that can be different to the thing actually
showed (for exemple: return the id of a label in a database). Don't
hesitate to tell me another (more vimish?) way.

regards

function! NewBufferAsMenu( cb )
        " Create a new buffer as menu
        " usage: NewBufferAsMenu('Foo')
        " hi CursorLine ctermfg=white ctermbg=red
        unlet! g:CallBack
        let g:CallBack = function(a:cb)
        new
        r!ls " this is just for test
        " Todo:  resize buffer
        setlocal nomodifiable
        setlocal cursorline
        nnoremap <buffer> <space> :echo g:CallBack()<cr>
endfunction

function! Foo()
        echo 'find '.line('').', add'.getline(line(''))
        let g:boom=getline(line(''))
        bd!
endfunc

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to