1
0
forked from aniani/vim

patch 8.1.1915: more functions can be used as methods

Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.
This commit is contained in:
Bram Moolenaar
2019-08-23 22:31:37 +02:00
parent d019039ccd
commit 1a3a89168d
12 changed files with 84 additions and 31 deletions

View File

@@ -3410,6 +3410,9 @@ char2nr({expr} [, {utf8}]) *char2nr()*
let list = map(split(str, '\zs'), {_, val -> char2nr(val)})
< Result: [65, 66, 67]
Can also be used as a |method|: >
GetChar()->char2nr()
chdir({dir}) *chdir()*
Change the current working directory to {dir}. The scope of
the directory change depends on the directory of the current
@@ -3430,6 +3433,9 @@ chdir({dir}) *chdir()*
" ... do some work
call chdir(save_dir)
endif
< Can also be used as a |method|: >
GetDir()->chdir()
<
cindent({lnum}) *cindent()*
Get the amount of indent for line {lnum} according the C
@@ -3440,12 +3446,18 @@ cindent({lnum}) *cindent()*
feature, -1 is returned.
See |C-indenting|.
Can also be used as a |method|: >
GetLnum()->cindent()
clearmatches([{win}]) *clearmatches()*
Clears all matches previously defined for the current window
by |matchadd()| and the |:match| commands.
If {win} is specified, use the window with this number or
window ID instead of the current window.
Can also be used as a |method|: >
GetWin()->clearmatches()
<
*col()*
col({expr}) The result is a Number, which is the byte index of the column
position given with {expr}. The accepted positions are:
@@ -3481,6 +3493,9 @@ col({expr}) The result is a Number, which is the byte index of the column
\<C-O>:set ve=all<CR>
\<C-O>:echo col(".") . "\n" <Bar>
\let &ve = save_ve<CR>
< Can also be used as a |method|: >
GetPos()->col()
<
complete({startcol}, {matches}) *complete()* *E785*
@@ -3512,6 +3527,10 @@ complete({startcol}, {matches}) *complete()* *E785*
< This isn't very useful, but it shows how it works. Note that
an empty string is returned to avoid a zero being inserted.
Can also be used as a |method|, the second argument is passed
in: >
GetMatches()->complete(col('.'))
complete_add({expr}) *complete_add()*
Add {expr} to the list of matches. Only to be used by the
function specified with the 'completefunc' option.
@@ -3521,6 +3540,9 @@ complete_add({expr}) *complete_add()*
See |complete-functions| for an explanation of {expr}. It is
the same as one item in the list that 'omnifunc' would return.
Can also be used as a |method|: >
GetMoreMatches()->complete_add()
complete_check() *complete_check()*
Check for a key typed while looking for completion matches.
This is to be used when looking for matches takes some time.
@@ -3581,6 +3603,9 @@ complete_info([{what}])
call complete_info(['mode'])
" Get only 'mode' and 'pum_visible'
call complete_info(['mode', 'pum_visible'])
< Can also be used as a |method|: >
GetItems()->complete_info()
<
*confirm()*
confirm({msg} [, {choices} [, {default} [, {type}]]])
@@ -3636,6 +3661,9 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
don't fit, a vertical layout is used anyway. For some systems
the horizontal layout is always used.
Can also be used as a |method|in: >
BuildMessage()->confirm("&Yes\n&No")
*copy()*
copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
@@ -3765,12 +3793,18 @@ cursor({list})
position within a <Tab> or after the last character.
Returns 0 when the position could be set, -1 otherwise.
Can also be used as a |method|: >
GetCursorPos()->cursor()
debugbreak({pid}) *debugbreak()*
Specifically used to interrupt a program being debugged. It
will cause process {pid} to get a SIGTRAP. Behavior for other
processes is undefined. See |terminal-debugger|.
{only available on MS-Windows}
Can also be used as a |method|: >
GetPid()->debugbreak()
deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
@@ -3792,6 +3826,9 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
{noref} set to 1 will fail.
Also see |copy()|.
Can also be used as a |method|: >
GetObject()->deepcopy()
delete({fname} [, {flags}]) *delete()*
Without {flags} or with {flags} empty: Deletes the file by the
name {fname}. This also works when {fname} is a symbolic link.
@@ -3813,6 +3850,9 @@ delete({fname} [, {flags}]) *delete()*
To delete a line from the buffer use |:delete| or
|deletebufline()|.
Can also be used as a |method|: >
GetName()->delete()
deletebufline({expr}, {first} [, {last}]) *deletebufline()*
Delete lines {first} to {last} (inclusive) from buffer {expr}.
If {last} is omitted then delete line {first} only.
@@ -3824,6 +3864,9 @@ deletebufline({expr}, {first} [, {last}]) *deletebufline()*
when using |line()| this refers to the current buffer. Use "$"
to refer to the last line in buffer {expr}.
Can also be used as a |method|: >
GetBuffer()->deletebufline(1)
*did_filetype()*
did_filetype() Returns |TRUE| when autocommands are being executed and the
FileType event has been triggered at least once. Can be used
@@ -3845,6 +3888,9 @@ diff_filler({lnum}) *diff_filler()*
line, "'m" mark m, etc.
Returns 0 if the current window is not in diff mode.
Can also be used as a |method|: >
GetLnum()->diff_filler()
diff_hlID({lnum}, {col}) *diff_hlID()*
Returns the highlight ID for diff mode at line {lnum} column
{col} (byte index). When the current line does not have a
@@ -3856,6 +3902,8 @@ diff_hlID({lnum}, {col}) *diff_hlID()*
The highlight ID can be used with |synIDattr()| to obtain
syntax information about the highlighting.
Can also be used as a |method|: >
GetLnum()->diff_hlID(col)
environ() *environ()*
Return all of environment variables as dictionary. You can
check if an environment variable exists like this: >