diff --git a/src/client.cc b/src/client.cc index b2e5a259..5ccba1ee 100644 --- a/src/client.cc +++ b/src/client.cc @@ -942,6 +942,8 @@ public: else if ( key == ctrl('u')) context().buffer().commit_undo_group(); + context().hooks().run_hook("InsertKey", key_to_str(key), context()); + if (update_completions) m_idle_timer.set_next_date(Clock::now() + idle_timeout); if (moved) @@ -986,7 +988,7 @@ private: auto& buffer = m_edition.editor().buffer(); for (auto& sel : m_edition.editor().selections()) buffer.insert(buffer.iterator_at(sel.last()), str); - context().hooks().run_hook("InsertKey", str, context()); + context().hooks().run_hook("InsertChar", str, context()); } void prepare(InsertMode mode) diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index 1db0ca5a..ad841cf6 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -18,11 +18,11 @@ hook global WinSetOption filetype=cpp %~ addhl -group cpp-highlight regex "^\h*?#.*?(?s\h+$d } } - hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft ks^\h+yjP } ] # preserve previous line indent - hook window InsertKey \n -id cpp-hooks %[ try %[ exec -draft k[{(]\h*$j ] ] # indent after lines ending with { or ( - hook window InsertKey \} -id cpp-hooks %[ try %[ exec -draft ^\h+\}$< ] ] # deindent on insert } alone on a line - hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft ks\h+$d } ] # cleanup trailing white space son previous line + hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft s\h+$d } } # cleanup trailing whitespaces when exiting insert mode + hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft ks^\h+yjP } ] # preserve previous line indent + hook window InsertChar \n -id cpp-hooks %[ try %[ exec -draft k[{(]\h*$j ] ] # indent after lines ending with { or ( + hook window InsertChar \} -id cpp-hooks %[ try %[ exec -draft ^\h+\}$< ] ] # deindent on insert } alone on a line + hook window InsertChar \n -id cpp-hooks %[ try %{ exec -draft ks\h+$d } ] # cleanup trailing white space son previous line ~ hook global WinSetOption filetype=(?!cpp).* %{