Address code-review comments.
This commit is contained in:
parent
e493eba46d
commit
3c8d160a62
|
@ -12,9 +12,9 @@ or more alphabetic characters), a nestable punctuation character (`(`, `[`,
|
||||||
`{}` are most common. For example, the command `echo %val{session}` will
|
`{}` are most common. For example, the command `echo %val{session}` will
|
||||||
echo the ID of the current Kakoune session.
|
echo the ID of the current Kakoune session.
|
||||||
|
|
||||||
Expansions are processed when unquoted and anywhere inside double-quoted or
|
Expansions are processed when unquoted and anywhere inside double-quoted
|
||||||
%-strings, but not inside unquoted words, inside single-quoted strings, or
|
strings, but not inside unquoted words, inside single-quoted strings, or
|
||||||
inside other expansions. So:
|
inside %-strings or other expansions. So:
|
||||||
|
|
||||||
* `echo %val{session}` echoes the current session ID
|
* `echo %val{session}` echoes the current session ID
|
||||||
|
|
||||||
|
@ -24,13 +24,17 @@ inside other expansions. So:
|
||||||
|
|
||||||
* `echo "x%val{session}x"` echoes the current session ID, surrounded by `x`
|
* `echo "x%val{session}x"` echoes the current session ID, surrounded by `x`
|
||||||
|
|
||||||
* `echo %{x%val{session}x}"` echoes the current session ID, surrounded by `x`
|
* `echo %{%val{session}}"` echoes the the literal text `%val{session}`
|
||||||
|
|
||||||
* `echo %sh{ echo %val{session} }"` echoes the literal text `%val{session}`
|
* `echo %sh{ echo %val{session} }"` echoes the literal text `%val{session}`
|
||||||
|
|
||||||
When processing an expansion, Kakoune ensures the result is properly quoted so
|
Like "variable expansion" and "command substitution" in shell programming,
|
||||||
that any special characters do not interfere with the rest of the command. If
|
Kakoune expansions can expand to multiple "words" - that is, separate
|
||||||
an expansion expands to multiple values, each value is individually quoted.
|
arguments on the resulting command-line. However, unlike shell programming,
|
||||||
|
Kakoune expansions cannot _accidentally_ expand to multiple words, even if
|
||||||
|
the expansion contains whitespace or other special characters. While in
|
||||||
|
shell-programming it's good practice to always wrap expansions in
|
||||||
|
double-quotes, in Kakoune it's perfectly safe to leave expansions unquoted.
|
||||||
|
|
||||||
== Argument expansions
|
== Argument expansions
|
||||||
|
|
||||||
|
@ -45,7 +49,7 @@ The following expansions are available:
|
||||||
expands to argument number _n_ of the current command
|
expands to argument number _n_ of the current command
|
||||||
|
|
||||||
*%arg{@}*::
|
*%arg{@}*::
|
||||||
expands to all the arguments of the current command, individually quoted
|
expands to all the arguments of the current command, as individual words
|
||||||
|
|
||||||
== Option expansions
|
== Option expansions
|
||||||
|
|
||||||
|
@ -127,11 +131,11 @@ echo %sh{ env | grep ^kak_ }
|
||||||
...will find none of Kakoune's special environment variables, but:
|
...will find none of Kakoune's special environment variables, but:
|
||||||
|
|
||||||
----
|
----
|
||||||
echo %sh{ env | grep ^kak_ # $kak_session }
|
echo %sh{ env | grep ^kak_ # kak_session }
|
||||||
----
|
----
|
||||||
|
|
||||||
...will find the `$kak_session` variable because it was mentioned inside the
|
...will find the `$kak_session` variable because it was mentioned by name
|
||||||
shell script, even just in a comment.
|
in a comment, even though it wasn't directly used.
|
||||||
|
|
||||||
TIP: These environment variables are also available in other contexts where
|
TIP: These environment variables are also available in other contexts where
|
||||||
Kakoune uses a shell command, such as the `|`, `!` or `$` normal mode commands
|
Kakoune uses a shell command, such as the `|`, `!` or `$` normal mode commands
|
||||||
|
@ -139,10 +143,12 @@ Kakoune uses a shell command, such as the `|`, `!` or `$` normal mode commands
|
||||||
|
|
||||||
== Value expansions
|
== Value expansions
|
||||||
|
|
||||||
Expansions with the type `val` can be used in various places, depending on the
|
Expansions with the type `val` give access to Kakoune internal data that is
|
||||||
specific value.
|
not stored in an option or a register. Some value expansions can only be used
|
||||||
|
in certain contexts, like `%val{hook_param}` that expands to the parameter
|
||||||
|
string of the currently-executing hook, and is not available outside a hook.
|
||||||
|
|
||||||
The following expansions are supported:
|
The following expansions are supported (with required context _in italics_):
|
||||||
|
|
||||||
*%val{buffile}*::
|
*%val{buffile}*::
|
||||||
_in buffer scope_ +
|
_in buffer scope_ +
|
||||||
|
|
Loading…
Reference in New Issue
Block a user