summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2025-07-08 10:25:35 +1000
committerMaxime Coste <mawww@kakoune.org>2025-07-08 10:25:35 +1000
commit2823c5e94c1bad72a7a22ea37452d2390d5b1e17 (patch)
treef96871dd6d5387d30a2ea64e2b6b36cb4112092c
parent2a9941c9a01597626135708cbc4566db5691489c (diff)
parent2eb6aa9e20901c53ec7c288d47592043649b1bbd (diff)
Merge remote-tracking branch 'pjungkamp/history'
-rw-r--r--doc/pages/expansions.asciidoc5
-rw-r--r--src/buffer_utils.cc2
-rw-r--r--src/buffer_utils.hh2
-rw-r--r--src/main.cc7
4 files changed, 14 insertions, 2 deletions
diff --git a/doc/pages/expansions.asciidoc b/doc/pages/expansions.asciidoc
index cf55902f..37e5811c 100644
--- a/doc/pages/expansions.asciidoc
+++ b/doc/pages/expansions.asciidoc
@@ -305,6 +305,11 @@ The following expansions are supported (with required context _in italics_):
history), and each _modification_ is presented as in
`%val{uncommitted_modifications}`.
+*%val{history_since_id}*::
+ _in buffer, window scope_ +
+ a partial history of the buffer in the same format as `%val{history}`
+ starting after entry _id_
+
*%val{history_id}*::
_in buffer, window scope_ +
history id of the current buffer, an integer value which refers to a
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc
index bb64e9c1..dca1a372 100644
--- a/src/buffer_utils.cc
+++ b/src/buffer_utils.cc
@@ -393,7 +393,7 @@ static String modification_as_string(const Buffer::Modification& modification)
modification.content->strview());
}
-Vector<String> history_as_strings(const Vector<Buffer::HistoryNode>& history)
+Vector<String> history_as_strings(ConstArrayView<Buffer::HistoryNode> history)
{
Vector<String> res;
for (auto& node : history)
diff --git a/src/buffer_utils.hh b/src/buffer_utils.hh
index 96e89743..f677c34e 100644
--- a/src/buffer_utils.hh
+++ b/src/buffer_utils.hh
@@ -97,7 +97,7 @@ void write_buffer_to_backup_file(Buffer& buffer);
void write_to_debug_buffer(StringView str);
-Vector<String> history_as_strings(const Vector<Buffer::HistoryNode>& history);
+Vector<String> history_as_strings(ConstArrayView<Buffer::HistoryNode> history);
Vector<String> undo_group_as_strings(const Buffer::UndoGroup& undo_group);
String generate_buffer_name(StringView pattern);
diff --git a/src/main.cc b/src/main.cc
index 0a2e68b0..60c0669e 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -315,6 +315,13 @@ static const EnvVarDesc builtin_env_vars[] = { {
[](StringView name, const Context& context) -> Vector<String>
{ return history_as_strings(context.buffer().history()); }
}, {
+ "history_since_", true,
+ [](StringView name, const Context& context) -> Vector<String>
+ { return history_as_strings(
+ ArrayView(context.buffer().history())
+ .subrange(str_to_int(name.substr(14_byte)) + 1)
+ ); }
+ }, {
"uncommitted_modifications", false,
[](StringView name, const Context& context) -> Vector<String>
{ return undo_group_as_strings(context.buffer().current_undo_group()); }