diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-04-11 11:37:18 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-04-12 15:28:40 +1000 |
| commit | 3d7d0fecca885b00a7ae80180ea1841fab2c5993 (patch) | |
| tree | 94218f4a6dab3f448ceaff034e51079a0ecc2e3c /src/context.cc | |
| parent | b1c114bf6d950684df0524e450782a151e6a0323 (diff) | |
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
Diffstat (limited to 'src/context.cc')
| -rw-r--r-- | src/context.cc | 8 |
1 files changed, 7 insertions, 1 deletions
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<FunctionRef<void()>> 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()) |
