From 3d7d0fecca885b00a7ae80180ea1841fab2c5993 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 11 Apr 2024 11:37:18 +1000 Subject: Introduce "local" scope in evaluate-commands When using `eval` a new scope named 'local' gets pushed for the whole evaluation, this makes it possible to temporarily set an option/hook/alias... Local scopes nest so nested evals do work as expected. Remove the now trivial with-option command --- src/context.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/context.cc') diff --git a/src/context.cc b/src/context.cc index 71a5becd..62171674 100644 --- a/src/context.cc +++ b/src/context.cc @@ -51,8 +51,10 @@ Client& Context::client() const return *m_client; } -Scope& Context::scope() const +Scope& Context::scope(bool allow_local) const { + if (allow_local and not m_local_scopes.empty()) + return *m_local_scopes.back(); if (has_window()) return window(); if (has_buffer()) @@ -70,6 +72,8 @@ void Context::set_window(Window& window) { kak_assert(&window.buffer() == &buffer()); m_window.reset(&window); + if (not m_local_scopes.empty()) + m_local_scopes.front()->reparent(window); } void Context::print_status(DisplayLine status) const @@ -314,6 +318,8 @@ void Context::change_buffer(Buffer& buffer, Optional> set_se ScopedSelectionEdition selection_edition{*this}; selections_write_only() = SelectionList{buffer, Selection{}}; } + if (not m_local_scopes.empty()) + m_local_scopes.front()->reparent(buffer); } if (has_input_handler()) -- cgit v1.2.3