aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-14 17:37:38 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-15 18:30:03 -0400
commitb34dc4c458dbec6982c70eed71f0a83c745e46c5 (patch)
tree561d4f50ff4ba22194639ab4b096ac4700432a9e
parentb8c0fac762f4b03f0438d3888ccf3f200648b882 (diff)
downloadrneovim-b34dc4c458dbec6982c70eed71f0a83c745e46c5.tar.gz
rneovim-b34dc4c458dbec6982c70eed71f0a83c745e46c5.tar.bz2
rneovim-b34dc4c458dbec6982c70eed71f0a83c745e46c5.zip
ex_cmds: port :eval
Cherry-picked from patch v8.1.1807. Required for patch v8.2.2761.
-rw-r--r--runtime/doc/eval.txt16
-rw-r--r--src/nvim/ex_cmds.lua6
-rw-r--r--src/nvim/ex_eval.c9
3 files changed, 31 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index c3736d9a3e..cc84bb6c97 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -10099,6 +10099,8 @@ This function can then be called with: >
The recursiveness of user functions is restricted with the |'maxfuncdepth'|
option.
+It is also possible to use `:eval`. It does not support a range.
+
AUTOMATICALLY LOADING FUNCTIONS ~
*autoload-functions*
@@ -10532,6 +10534,20 @@ text...
Unlock the internal variable {name}. Does the
opposite of |:lockvar|.
+ *:eval*
+:eval {expr} Evaluate {expr} and discard the result. Example: >
+ :eval append(Filter(Getlist()), '$')
+
+< The expression is supposed to have a side effect,
+ since the resulting value is not used. In the example
+ the `append()` call appends the List with text to the
+ buffer. This is similar to `:call` but works with any
+ expression.
+
+ The command can be shortened to `:ev` or `:eva`, but
+ these are hard to recognize and therefore not to be
+ used.
+
:if {expr1} *:if* *:end* *:endif* *:en* *E171* *E579* *E580*
:en[dif] Execute the commands until the next matching ":else"
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 2965ea7496..d99383303b 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -928,6 +928,12 @@ module.cmds = {
func='ex_edit',
},
{
+ command='eval',
+ flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN),
+ addr_type='ADDR_NONE',
+ func='ex_eval',
+ },
+ {
command='ex',
flags=bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
addr_type='ADDR_NONE',
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 0917c6dd02..5ca88002f1 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -788,6 +788,15 @@ void report_discard_pending(int pending, void *value)
}
}
+// ":eval".
+void ex_eval(exarg_T *eap)
+{
+ typval_T tv;
+
+ if (eval0(eap->arg, &tv, &eap->nextcmd, !eap->skip) == OK) {
+ tv_clear(&tv);
+ }
+}
/*
* ":if".