BufCreate hook is always called for every buffer, BufNew is called when creating a new file

This commit is contained in:
Maxime Coste 2012-06-12 18:27:57 +00:00
parent 20315eac85
commit bc359d7c90
2 changed files with 4 additions and 2 deletions

View File

@ -34,9 +34,11 @@ Buffer::Buffer(const String& name, Type type,
apply_modification(Modification::make_insert(begin(), initial_content)); apply_modification(Modification::make_insert(begin(), initial_content));
if (type == Type::NewFile) 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) else if (type == Type::File)
m_hook_manager.run_hook("BufOpen", name, Context(*this)); m_hook_manager.run_hook("BufOpen", name, Context(*this));
m_hook_manager.run_hook("BufCreate", name, Context(*this));
} }
Buffer::~Buffer() Buffer::~Buffer()

View File

@ -11,7 +11,7 @@ hook global WinCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) \
addfilter cleanup_whitespaces; \ addfilter cleanup_whitespaces; \
hook window InsertEnd .* exec xs\h+(?=\n)<ret>d hook window InsertEnd .* exec xs\h+(?=\n)<ret>d
hook global BufCreate .*\.(h|hh|hpp|hxx|H) \ hook global BufNew .*\.(h|hh|hpp|hxx|H) \
exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>xyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc> exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>xyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>
def alt edit \ def alt edit \