comparison runtime/doc/eval.txt @ 8538:c337c813c64d v7.4.1559

commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 14 23:05:14 2016 +0100 patch 7.4.1559 Problem: Passing cookie to a callback is clumsy. Solution: Change function() to take arguments and return a partial.
author Christian Brabandt <cb@256bit.org>
date Mon, 14 Mar 2016 23:15:05 +0100
parents 09041d2fd7d0
children 63dc856bd13d
comparison
equal deleted inserted replaced
8537:cc20abebafa3 8538:c337c813c64d
1 *eval.txt* For Vim version 7.4. Last change: 2016 Mar 13 1 *eval.txt* For Vim version 7.4. Last change: 2016 Mar 14
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
1893 foldclosedend( {lnum}) Number last line of fold at {lnum} if closed 1893 foldclosedend( {lnum}) Number last line of fold at {lnum} if closed
1894 foldlevel( {lnum}) Number fold level at {lnum} 1894 foldlevel( {lnum}) Number fold level at {lnum}
1895 foldtext() String line displayed for closed fold 1895 foldtext() String line displayed for closed fold
1896 foldtextresult( {lnum}) String text for closed fold at {lnum} 1896 foldtextresult( {lnum}) String text for closed fold at {lnum}
1897 foreground() Number bring the Vim window to the foreground 1897 foreground() Number bring the Vim window to the foreground
1898 function( {name}) Funcref reference to function {name} 1898 function({name} [, {arglist}] [, {dict}])
1899 Funcref reference to function {name}
1899 garbagecollect( [{atexit}]) none free memory, breaking cyclic references 1900 garbagecollect( [{atexit}]) none free memory, breaking cyclic references
1900 get( {list}, {idx} [, {def}]) any get item {idx} from {list} or {def} 1901 get( {list}, {idx} [, {def}]) any get item {idx} from {list} or {def}
1901 get( {dict}, {key} [, {def}]) any get item {key} from {dict} or {def} 1902 get( {dict}, {key} [, {def}]) any get item {key} from {dict} or {def}
1902 getbufline( {expr}, {lnum} [, {end}]) 1903 getbufline( {expr}, {lnum} [, {end}])
1903 List lines {lnum} to {end} of buffer {expr} 1904 List lines {lnum} to {end} of buffer {expr}
3566 |remote_foreground()| instead. 3567 |remote_foreground()| instead.
3567 {only in the Win32, Athena, Motif and GTK GUI versions and the 3568 {only in the Win32, Athena, Motif and GTK GUI versions and the
3568 Win32 console version} 3569 Win32 console version}
3569 3570
3570 3571
3571 function({name}) *function()* *E700* 3572 *function()* *E700* *E922* *E923*
3573 function({name} [, {arglist}] [, {dict}])
3572 Return a |Funcref| variable that refers to function {name}. 3574 Return a |Funcref| variable that refers to function {name}.
3573 {name} can be a user defined function or an internal function. 3575 {name} can be a user defined function or an internal function.
3576
3577 When {arglist} or {dict} is present this creates a partial.
3578 That mans the argument list and/or the dictionary is stored in
3579 the Funcref and will be used when the Funcref is called.
3580
3581 The arguments are passed to the function in front of other
3582 arguments. Example: >
3583 func Callback(arg1, arg2, name)
3584 ...
3585 let Func = function('Callback', ['one', 'two'])
3586 ...
3587 call Func('name')
3588 < Invokes the function as with: >
3589 call Callback('one', 'two', 'name')
3590
3591 < The Dictionary is only useful when calling a "dict" function.
3592 In that case the {dict} is passed in as "self". Example: >
3593 function Callback() dict
3594 echo "called for " . self.name
3595 endfunction
3596 ...
3597 let context = {"name": "example"}
3598 let Func = function('Callback', context)
3599 ...
3600 call Func() " will echo: called for example
3601
3602 < The argument list and the Dictionary can be combined: >
3603 function Callback(arg1, count) dict
3604 ...
3605 let context = {"name": "example"}
3606 let Func = function('Callback', ['one'], context)
3607 ...
3608 call Func(500)
3609 < Invokes the function as with: >
3610 call context.Callback('one', 500)
3574 3611
3575 3612
3576 garbagecollect([{atexit}]) *garbagecollect()* 3613 garbagecollect([{atexit}]) *garbagecollect()*
3577 Cleanup unused |Lists| and |Dictionaries| that have circular 3614 Cleanup unused |Lists| and |Dictionaries| that have circular
3578 references. There is hardly ever a need to invoke this 3615 references. There is hardly ever a need to invoke this