From 625e7f8249d02a42a1ec11dcad8e1f5bffe7bc99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Ros=C3=A9n?= Date: Thu, 18 May 2017 17:36:06 +0200 Subject: [PATCH] Add modified value if buffer has modifications not saved Closes #1386 --- README.asciidoc | 1 + doc/manpages/expansions.asciidoc | 2 ++ src/main.cc | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index e075b35f..5e340a5c 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -782,6 +782,7 @@ Some of Kakoune state is available through environment variables: * `kak_reg_`: value of register * `kak_session`: name of the current session * `kak_client`: name of current client + * `kak_modified`: buffer has modifications not saved * `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_column`: column of the end of the main selection (in byte) diff --git a/doc/manpages/expansions.asciidoc b/doc/manpages/expansions.asciidoc index 0c84a045..739d712b 100644 --- a/doc/manpages/expansions.asciidoc +++ b/doc/manpages/expansions.asciidoc @@ -87,6 +87,8 @@ informations about Kakoune's state: *kak_source*:: path of the file currently getting executed (through the source command) +*kak_modified*:: + buffer has modifications not saved *kak_cursor_line*:: line of the end of the main selection *kak_cursor_column*:: diff --git a/src/main.cc b/src/main.cc index 1fbb5f7e..e717e593 100644 --- a/src/main.cc +++ b/src/main.cc @@ -123,6 +123,10 @@ void register_env_vars() "client", false, [](StringView name, const Context& context) -> String { return context.name(); } + }, { + "modified", false, + [](StringView name, const Context& context) -> String + { return context.buffer().is_modified() ? "true" : "false"; } }, { "cursor_line", false, [](StringView name, const Context& context) -> String