summaryrefslogtreecommitdiff
path: root/src/client_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-06-05 19:49:35 +1000
committerMaxime Coste <mawww@kakoune.org>2024-06-05 19:49:35 +1000
commit51ec633718b5d31853110fd08e971eafa6ecb603 (patch)
treed712aa397604cd368a4de478dc4e2290cfcb3723 /src/client_manager.cc
parent727d2391c7695056ce6bb170b127c6e6ca9e1ab4 (diff)
Echo an information message about *scratch* buffer and leave it empty
Having to manually clear the scratch was never really nice and hopefully this will be less annoying and as helpful to newcomers.
Diffstat (limited to 'src/client_manager.cc')
-rw-r--r--src/client_manager.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/client_manager.cc b/src/client_manager.cc
index 53caeea0..0ad5392f 100644
--- a/src/client_manager.cc
+++ b/src/client_manager.cc
@@ -64,24 +64,28 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui, int pi
std::move(on_exit)};
m_clients.emplace_back(client);
+ auto& context = client->context();
+ if (buffer->name() == "*scratch*")
+ context.print_status({"This *scratch* buffer won't be automatically saved",
+ context.faces()["Information"]});
+
if (init_coord)
{
- auto& selections = client->context().selections_write_only();
+ auto& selections = context.selections_write_only();
selections = SelectionList(*buffer, buffer->clamp(*init_coord));
- client->context().window().center_line(init_coord->line);
+ context.window().center_line(init_coord->line);
}
try
{
- auto& context = client->context();
context.hooks().run_hook(Hook::ClientCreate, context.name(), context);
CommandManager::instance().execute(init_cmds, context);
}
catch (Kakoune::runtime_error& error)
{
- client->context().print_status({error.what().str(), client->context().faces()["Error"]});
- client->context().hooks().run_hook(Hook::RuntimeError, error.what(),
- client->context());
+ context.print_status({error.what().str(), context.faces()["Error"]});
+ context.hooks().run_hook(Hook::RuntimeError, error.what(),
+ context);
}
// Do not return the client if it already got moved to the trash