From d571c207e64c917f78b5390f697e35c84a04dc7e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 9 Apr 2018 17:04:51 +1000 Subject: [PATCH] Make version available through $kak_version and debug info --- .gitignore | 1 + doc/pages/expansions.asciidoc | 3 +++ src/commands.cc | 3 +++ src/main.cc | 8 +++++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9119351a..7add1765 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ src/kak src/kak.debug src/kak.opt +src/.version* doc/kak.1 doc/kak.1.gz doc/manpages/*.gz diff --git a/doc/pages/expansions.asciidoc b/doc/pages/expansions.asciidoc index 19b51f93..ac7838f8 100644 --- a/doc/pages/expansions.asciidoc +++ b/doc/pages/expansions.asciidoc @@ -102,6 +102,9 @@ informations about Kakoune's state: *kak_config*:: directory containing the user configuration +*kak_version*:: + version of the current Kakoune server (git hash or release name) + *kak_count*:: count parameter passed to the command diff --git a/src/commands.cc b/src/commands.cc index 7d93afb8..7f7b8708 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -45,6 +45,8 @@ namespace Kakoune { +extern const char* version; + namespace { @@ -1146,6 +1148,7 @@ const CommandDesc debug_cmd = { { if (parser[0] == "info") { + write_to_debug_buffer(format("version: {}", version)); write_to_debug_buffer(format("pid: {}", getpid())); write_to_debug_buffer(format("session: {}", Server::instance().session())); #ifdef KAK_DEBUG diff --git a/src/main.cc b/src/main.cc index 8d6b2b67..53986525 100644 --- a/src/main.cc +++ b/src/main.cc @@ -37,6 +37,8 @@ namespace Kakoune { +extern const char* version; + static const char* startup_info = "Kakoune recent breaking changes:\n" " * Highlighters have been refactored to be part of scopes\n" @@ -122,6 +124,10 @@ static const EnvVarDesc builtin_env_vars[] = { { "config", false, [](StringView name, const Context& context) { return config_directory(); } + }, { + "version", false, + [](StringView name, const Context& context) -> String + { return version; } }, { "opt_", true, [](StringView name, const Context& context) @@ -671,7 +677,7 @@ int run_server(StringView session, StringView server_init, }); if (flags & ServerFlags::StartupInfo) - local_client->info_show("Welcome to Kakoune", startup_info, {}, InfoStyle::Prompt); + local_client->info_show(format("Kakoune {}", version), startup_info, {}, InfoStyle::Prompt); } while (not terminate and