diff --git a/README.asciidoc b/README.asciidoc index 39aef0f1..2c96216a 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -792,6 +792,8 @@ Some of Kakoune state is available through environment variables: * `kak_buf_line_count`: the current buffer line count * `kak_timestamp`: timestamp of the current buffer, the timestamp is an integer value which is incremented each time the buffer is modified. + * `kak_history_id`: history id of the current buffer, the history id is an integer value + which is used to reference a specific buffer version in the undo tree * `kak_runtime`: directory containing the kak binary * `kak_count`: count parameter passed to the command * `kak_opt_`: value of option diff --git a/doc/manpages/expansions.asciidoc b/doc/manpages/expansions.asciidoc index 5e4bdc79..72f6daa3 100644 --- a/doc/manpages/expansions.asciidoc +++ b/doc/manpages/expansions.asciidoc @@ -74,6 +74,9 @@ informations about Kakoune's state: *kak_timestamp*:: timestamp of the current buffer, the timestamp is an integer value which is incremented each time the buffer is modified +*kak_history_id*:: + history id of the current buffer, the history id is an integer value + which is used to reference a specific buffer version in the undo tree *kak_runtime*:: directory containing the kak binary *kak_count*:: diff --git a/src/main.cc b/src/main.cc index 66394627..19a6d400 100644 --- a/src/main.cc +++ b/src/main.cc @@ -93,6 +93,10 @@ void register_env_vars() "timestamp", false, [](StringView name, const Context& context) -> String { return to_string(context.buffer().timestamp()); } + }, { + "history_id", false, + [](StringView name, const Context& context) -> String + { return to_string(context.buffer().current_history_id()); } }, { "selection", false, [](StringView name, const Context& context)