summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDelapouite <delapouite@gmail.com>2017-06-06 14:29:06 +0200
committerDelapouite <delapouite@gmail.com>2017-06-06 14:29:06 +0200
commit09daaa8b3a37ddc10b20e41e779ed51887265c8a (patch)
tree6fc9cd978212df4ceab0afc543f01a022db8b6be
parent73ecbdbc97f422e67ef1da9972ba7b357fa3ca12 (diff)
Expose kak_buf_line_count
-rw-r--r--README.asciidoc1
-rw-r--r--doc/manpages/expansions.asciidoc4
-rw-r--r--src/main.cc4
3 files changed, 8 insertions, 1 deletions
diff --git a/README.asciidoc b/README.asciidoc
index 66dfc59b..fc5e3eab 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -780,6 +780,7 @@ Some of Kakoune state is available through environment variables:
* `kak_buffile`: full path of the file or same as `kak_bufname` when
there's no associated file
* `kak_buflist`: the current buffer list, each buffer separated by a colon
+ * `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_runtime`: directory containing the kak binary
diff --git a/doc/manpages/expansions.asciidoc b/doc/manpages/expansions.asciidoc
index 48e47fdd..96783a25 100644
--- a/doc/manpages/expansions.asciidoc
+++ b/doc/manpages/expansions.asciidoc
@@ -69,6 +69,8 @@ informations about Kakoune's state:
associated file
*kak_buflist*::
the current buffer list, each buffer separated by a colon
+*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
@@ -95,7 +97,7 @@ informations about Kakoune's state:
column of the end of the main selection (in byte)
*kak_cursor_char_column*::
column of the end of the main selection (in character)
-*kak_cursor_byte_offset*::
+*kak_cursor_byte_offset*::
Offset of the main selection from the beginning of the buffer (in bytes).
*kak_window_width*::
width of the current kakoune window
diff --git a/src/main.cc b/src/main.cc
index 11254e78..af7f62e1 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -94,6 +94,10 @@ void register_env_vars()
{ return join(BufferManager::instance() |
transform(std::mem_fn(&Buffer::display_name)), ':'); }
}, {
+ "buf_line_count", false,
+ [](StringView name, const Context& context) -> String
+ { return to_string(context.buffer().line_count()); }
+ }, {
"timestamp", false,
[](StringView name, const Context& context) -> String
{ return to_string(context.buffer().timestamp()); }