Skip to content

Commit

Permalink
Make version available through $kak_version and debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
mawww committed Apr 9, 2018
1 parent fc86acd commit d571c20
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
src/kak
src/kak.debug
src/kak.opt
src/.version*
doc/kak.1
doc/kak.1.gz
doc/manpages/*.gz
Expand Down
3 changes: 3 additions & 0 deletions doc/pages/expansions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
namespace Kakoune
{

extern const char* version;

namespace
{

Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d571c20

Please sign in to comment.