Skip to content

Commit 4537f87

Browse files
committed
Document interaction between evaluate-commands and expansions
1 parent 6906818 commit 4537f87

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/pages/execeval.asciidoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,30 @@ are then restored when the keys have been executed: */*, *"*, *|*, *^*,
7070

7171
When using *evaluate-commands* a new scope, named `local` is inserted.
7272
See <<scopes#,`:doc scopes`>>
73+
74+
== Expansions in *evaluate-commands*
75+
76+
When using evaluate-commands to get expansion values (see <<expansions#,`:doc expansions`>>),
77+
care must be taken to get the desired values. In order to properly expand expansions
78+
in the target context, expansions must be wrapped in single quotes to avoid expanding
79+
them in the current context. See <<expansions#,`:doc expansions`>> for an explanation
80+
on how quoting affects expansions.
81+
82+
For example, if you have two Kakoune clients (client0 and client1) and you want to
83+
print `%val{client}` of the second client from the first client to the
84+
<<buffers#debug-buffers,*debug* buffer>>, you would run this command
85+
from the first client:
86+
87+
---
88+
evaluate-commands -client client1 -- echo -debug '%val{client}'
89+
---
90+
91+
This will print "client1" to the debug buffer. Notice the single quotes
92+
around the expansion. If you were to omit them, like so:
93+
94+
---
95+
evaluate-commands -client client1 -- echo -debug %val{client}
96+
---
97+
98+
It would print "client0" instead, because Kakoune has expanded it before
99+
*evaluate-commands* has run.

0 commit comments

Comments
 (0)