From 84d8447a5803f818a7a1fa68087a32b06538af1c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 12 Jun 2015 13:43:46 +0100 Subject: [PATCH] Notify user on kakrc parsing errors Fixes #281 --- src/main.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 4eacbcb9..f2b5a310 100644 --- a/src/main.cc +++ b/src/main.cc @@ -228,7 +228,7 @@ void register_options() } template -void create_local_client(StringView init_command) +void create_local_client(StringView init_command, bool kakrc_error) { struct LocalUI : UI { @@ -261,6 +261,13 @@ void create_local_client(StringView init_command) static Client* client = ClientManager::instance().create_client( make_unique(), get_env_vars(), init_command); + + if (kakrc_error) + client->print_status({ + "error while sourcing kakrc, see *debug* buffer for details", + get_face("Error") + }); + signal(SIGHUP, [](int) { if (client) ClientManager::instance().remove_client(*client); @@ -386,6 +393,7 @@ int run_server(StringView session, StringView init_command, Server server(session.empty() ? to_string(getpid()) : session.str()); + bool kakrc_error = false; if (not ignore_kakrc) try { Context initialisation_context{Context::EmptyContextFlag{}}; @@ -394,10 +402,12 @@ int run_server(StringView session, StringView init_command, } catch (Kakoune::runtime_error& error) { + kakrc_error = true; write_to_debug_buffer(format("error while parsing kakrc:\n {}", error.what())); } catch (Kakoune::client_removed&) { + kakrc_error = true; write_to_debug_buffer("error while parsing kakrc: asked to quit"); } @@ -426,9 +436,9 @@ int run_server(StringView session, StringView init_command, if (not daemon) { if (dummy_ui) - create_local_client(init_command); + create_local_client(init_command, kakrc_error); else - create_local_client(init_command); + create_local_client(init_command, kakrc_error); } while (not terminate and (not client_manager.empty() or daemon))