Using the approach that I describe above, I wrote a series of vimscript
functions that initialize an object such as I've shown interest in and shown
an example of:
Code: Select all
" ---------------------------------------------------------------------------------------
" Given the variable name typed in, expands to a general set statement
" --------------------------------------------------------------------------------------
function! NewlispQuickSet()
let wrd=expand("<cWORD>")
exe "norm! bdwa(set '" . wrd . " )\<Left>"
endfunction
" -----------------------------------------------------------------------------
" Given the variable name typed in, expands to a global initializer
" expression containing an initializer function
" Example: foo => (set 'foo (List! "foo"))
" ----------------------------------------------------------------------------
function! NewlispInitGlobalObject(o)
let w=expand("<cWORD>")
exe "norm! bdwa(set '" . w . "(" . a:o . "! \"" . w . "\" ))\<Left>\<Left>"
endfunction
" ----------------------------------------------------------------------------
" Given the variable name typed in, expands to a local initializer
" as would be contained in a let() initializer expression
" Example: foo => (foo (List! "foo"))
" ---------------------------------------------------------------------------
function! NewlispInitLocalObject(o)
let w=expand("<cWORD>")
exe "norm! bdwa(" . w . "(" . a:o . "! \"" . w . "\" ))\<Left>\<Left>"
endfunction
" --------------------------------------------------------------------
Note: The last two functions expand to a particular coding style, so
if you have stumbled across this, make sure to read my posts in this thread.
Also, for you vimmers, these functions are in turn called from functions which
are agnostic to the programming language.
so if you call them directly, then you'll need to add "a" to get back into
insert mode at the right place.
Key mapping examples:
Code: Select all
inoremap <T-Space> <Esc>:call StdInitializeVariable()<CR>a
inoremap <F2>l <Esc>:call StdInitGlobalList()<CR>a
inoremap <F2>m <Esc>:call StdInitLocalList()<CR>a
Note <T-Space> That is the vimscript notation for the "Super" modifier" following
by "Space"
Thanks again for this thread. I'm going to rip off a whole lot of the examples
submitted for my List! context.
cheers
tim