1
0
forked from aniani/vim

patch 9.1.0547: No way to get the arity of a Vim function

Problem:  No way to get the arity of a Vim function
          (Austin Ziegler)
Solution: Enhance get() Vim script function to return the function
          argument info using get(func, "arity") (LemonBoy)

fixes: #15097
closes: #15109

Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
LemonBoy
2024-07-09 18:24:59 +02:00
committed by Christian Brabandt
parent 03acd4761b
commit 48b7d05a4f
9 changed files with 136 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
*builtin.txt* For Vim version 9.1. Last change: 2024 Jun 23
*builtin.txt* For Vim version 9.1. Last change: 2024 Jul 09
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3574,7 +3574,7 @@ garbagecollect([{atexit}]) *garbagecollect()*
Return type: |String|
get({list}, {idx} [, {default}]) *get()*
get({list}, {idx} [, {default}]) *get()* *get()-list*
Get item {idx} from |List| {list}. When this item is not
available return {default}. Return zero when {default} is
omitted.
@@ -3583,7 +3583,7 @@ get({list}, {idx} [, {default}]) *get()*
<
Return type: any, depending on {list}
get({blob}, {idx} [, {default}])
get({blob}, {idx} [, {default}]) *get()-blob*
Get byte {idx} from |Blob| {blob}. When this byte is not
available return {default}. Return -1 when {default} is
omitted.
@@ -3592,7 +3592,7 @@ get({blob}, {idx} [, {default}])
<
Return type: |Number|
get({dict}, {key} [, {default}])
get({dict}, {key} [, {default}]) *get()-dict*
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
{default} is omitted. Useful example: >
@@ -3604,18 +3604,32 @@ get({dict}, {key} [, {default}])
<
Return type: any, depending on {dict}
get({func}, {what})
Get item {what} from Funcref {func}. Possible values for
get({func}, {what}) *get()-func*
Get item {what} from |Funcref| {func}. Possible values for
{what} are:
"name" The function name
"func" The function
"dict" The dictionary
"args" The list with arguments
"name" The function name
"func" The function
"dict" The dictionary
"args" The list with arguments
"arity" A dictionary with information about the number of
arguments accepted by the function (minus the
{arglist}) with the following fields:
required the number of positional arguments
optional the number of optional arguments,
in addition to the required ones
varargs |TRUE| if the function accepts a
variable number of arguments |...|
Note: There is no error, if the {arglist} of
the Funcref contains more arguments than the
Funcref expects, it's not validated.
Returns zero on error.
Preferably used as a |method|: >
myfunc->get(what)
<
Return type: any, depending on {func}
Return type: any, depending on {func} and {what}
*getbufinfo()*
getbufinfo([{buf}])

View File

@@ -7783,6 +7783,10 @@ gdb-version terminal.txt /*gdb-version*
ge motion.txt /*ge*
gender-neutral helphelp.txt /*gender-neutral*
get() builtin.txt /*get()*
get()-blob builtin.txt /*get()-blob*
get()-dict builtin.txt /*get()-dict*
get()-func builtin.txt /*get()-func*
get()-list builtin.txt /*get()-list*
get-ms-debuggers debug.txt /*get-ms-debuggers*
getbufinfo() builtin.txt /*getbufinfo()*
getbufline() builtin.txt /*getbufline()*

View File

@@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2024 Jul 06
*version9.txt* For Vim version 9.1. Last change: 2024 Jul 08
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -41577,6 +41577,8 @@ Changed~
- 'nrformat' accepts the new "blank" suboption, to determine a signed or
unsigned number based on whitespace in front of a minus sign.
- allow to specify a priority when defining a new sign |:sign-define|
- provide information about function arguments using the get(func, "arity")
function |get()-func|
*added-9.2*
Added ~