Merge remote-tracking branch 'Delapouite/buf_line_count'

This commit is contained in:
Maxime Coste 2017-06-07 07:48:32 +01:00
commit d214969d5b
3 changed files with 8 additions and 1 deletions

View File

@ -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 * `kak_buffile`: full path of the file or same as `kak_bufname` when
there's no associated file there's no associated file
* `kak_buflist`: the current buffer list, each buffer separated by a colon * `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 * `kak_timestamp`: timestamp of the current buffer, the timestamp is an
integer value which is incremented each time the buffer is modified. integer value which is incremented each time the buffer is modified.
* `kak_runtime`: directory containing the kak binary * `kak_runtime`: directory containing the kak binary

View File

@ -69,6 +69,8 @@ informations about Kakoune's state:
associated file associated file
*kak_buflist*:: *kak_buflist*::
the current buffer list, each buffer separated by a colon the current buffer list, each buffer separated by a colon
*kak_buf_line_count*::
the current buffer line count
*kak_timestamp*:: *kak_timestamp*::
timestamp of the current buffer, the timestamp is an integer value timestamp of the current buffer, the timestamp is an integer value
which is incremented each time the buffer is modified which is incremented each time the buffer is modified

View File

@ -93,6 +93,10 @@ void register_env_vars()
[](StringView name, const Context& context) [](StringView name, const Context& context)
{ return join(BufferManager::instance() | { return join(BufferManager::instance() |
transform(std::mem_fn(&Buffer::display_name)), ':'); } 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, "timestamp", false,
[](StringView name, const Context& context) -> String [](StringView name, const Context& context) -> String