Add client_list var

This commit is contained in:
Delapouite 2017-10-05 16:41:36 +02:00
parent 2f251c9861
commit d03858280a
3 changed files with 12 additions and 3 deletions

View File

@ -813,8 +813,9 @@ Some of Kakoune state is available through environment variables:
* `kak_opt_<name>`: value of option <name> * `kak_opt_<name>`: value of option <name>
* `kak_reg_<r>`: value of register <r> * `kak_reg_<r>`: value of register <r>
* `kak_session`: name of the current session * `kak_session`: name of the current session
* `kak_client`: name of current client * `kak_client`: name of the current client
* `kak_client_pid`: pid of the current client * `kak_client_pid`: pid of the current client
* `kak_client_list`: list of clients connected to the current session
* `kak_modified`: buffer has modifications not saved * `kak_modified`: buffer has modifications not saved
* `kak_source`: path of the file currently getting executed (through the source command) * `kak_source`: path of the file currently getting executed (through the source command)
* `kak_cursor_line`: line of the end of the main selection * `kak_cursor_line`: line of the end of the main selection

View File

@ -88,9 +88,11 @@ informations about Kakoune's state:
*kak_session*:: *kak_session*::
name of the current session name of the current session
*kak_client*:: *kak_client*::
name of current client name of the current client
*kak_client_pid*:: *kak_client_pid*::
process id of current client process id of the current client
*kak_client_list*::
list of clients connected to the current session
*kak_source*:: *kak_source*::
path of the file currently getting executed (through the source path of the file currently getting executed (through the source
command) command)

View File

@ -135,6 +135,12 @@ void register_env_vars()
"client_pid", false, "client_pid", false,
[](StringView name, const Context& context) -> String [](StringView name, const Context& context) -> String
{ return to_string(context.client().pid()); } { return to_string(context.client().pid()); }
}, {
"client_list", false,
[](StringView name, const Context& context) -> String
{ return join(ClientManager::instance() |
transform([](const std::unique_ptr<Client>& c) -> const String&
{ return c->context().name(); }), ':'); }
}, { }, {
"modified", false, "modified", false,
[](StringView name, const Context& context) -> String [](StringView name, const Context& context) -> String