From bc359d7c902a8131801fc78a415dc0a0b396807a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 12 Jun 2012 18:27:57 +0000 Subject: [PATCH] BufCreate hook is always called for every buffer, BufNew is called when creating a new file --- src/buffer.cc | 4 +++- src/rc/cpp.kak | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index a1f943e8..59ece2ae 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -34,9 +34,11 @@ Buffer::Buffer(const String& name, Type type, apply_modification(Modification::make_insert(begin(), initial_content)); if (type == Type::NewFile) - m_hook_manager.run_hook("BufCreate", name, Context(*this)); + m_hook_manager.run_hook("BufNew", name, Context(*this)); else if (type == Type::File) m_hook_manager.run_hook("BufOpen", name, Context(*this)); + + m_hook_manager.run_hook("BufCreate", name, Context(*this)); } Buffer::~Buffer() diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index 28db130e..41f4ebcc 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -11,7 +11,7 @@ hook global WinCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) \ addfilter cleanup_whitespaces; \ hook window InsertEnd .* exec xs\h+(?=\n)d -hook global BufCreate .*\.(h|hh|hpp|hxx|H) \ +hook global BufNew .*\.(h|hh|hpp|hxx|H) \ exec ggi%ggxs\.c_A_INCLUDEDxyppI#ifndefjI#definejI#endif//O def alt edit \