add a kak_selections env var, which contains all selections separated by a comma
This commit is contained in:
parent
e5d93c2194
commit
60599917cc
|
@ -385,6 +385,7 @@ for example: %sh{ ls } is replaced with the output of the ls command.
|
|||
Some of kakoune state is available through environment variables:
|
||||
|
||||
* +kak_selection+: content of the main selection
|
||||
* +kak_selections+: content of the selection separated by commas
|
||||
* +kak_bufname+: name of the current buffer
|
||||
* +kak_timestamp+: timestamp of the current buffer, the timestamp is an
|
||||
integer value which is incremented each time the buffer is modified.
|
||||
|
|
|
@ -691,7 +691,12 @@ void register_env_vars()
|
|||
{ return int_to_str(context.buffer().timestamp()); });
|
||||
shell_manager.register_env_var("selection",
|
||||
[](const String& name, const Context& context)
|
||||
{ return context.editor().selections_content().back(); });
|
||||
{ return context.editor().main_selection().content(); });
|
||||
shell_manager.register_env_var("selections",
|
||||
[](const String& name, const Context& context)
|
||||
{ auto sels = context.editor().selections_content();
|
||||
return std::accumulate(sels.begin(), sels.end(), ""_str,
|
||||
[](const String& lhs, const String& rhs) { return lhs.empty() ? rhs : lhs + "," + rhs; }); });
|
||||
shell_manager.register_env_var("runtime",
|
||||
[](const String& name, const Context& context)
|
||||
{ return runtime_directory(); });
|
||||
|
|
Loading…
Reference in New Issue
Block a user