From ae6c214f52c573b777ed8e188cb23722f020b5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Fred=C3=A9n?= Date: Tue, 12 Jun 2018 18:31:23 +0200 Subject: [PATCH 2/3] Add BufReload hook which is triggered on buffer reload --- src/client.cc | 2 ++ src/commands.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client.cc b/src/client.cc index 313011d0..7baf551b 100644 --- a/src/client.cc +++ b/src/client.cc @@ -283,6 +283,8 @@ void Client::reload_buffer() reload_file_buffer(buffer); context().print_status({ format("'{}' reloaded", buffer.display_name()), context().faces()["Information"] }); + + m_window->hooks().run_hook("BufReload", buffer.name(), context()); } catch (runtime_error& error) { diff --git a/src/commands.cc b/src/commands.cc index b8223508..bc73f45c 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -801,7 +801,7 @@ const CommandDesc remove_highlighter_cmd = { }; static constexpr auto hooks = { - "BufCreate", "BufNewFile", "BufOpenFile", "BufClose", "BufWritePost", + "BufCreate", "BufNewFile", "BufOpenFile", "BufClose", "BufWritePost", "BufReload", "BufWritePre", "BufOpenFifo", "BufCloseFifo", "BufReadFifo", "BufSetOption", "InsertBegin", "InsertChar", "InsertDelete", "InsertEnd", "InsertIdle", "InsertKey", "InsertMove", "InsertCompletionHide", "InsertCompletionShow", "InsertCompletionSelect", From cb8270feaad8c31ca1baa35c65b500d4237a9736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Fred=C3=A9n?= Date: Wed, 13 Jun 2018 00:38:39 +0200 Subject: [PATCH 3/3] Add documentation of BufReload hook --- doc/pages/hooks.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/pages/hooks.asciidoc b/doc/pages/hooks.asciidoc index 8c23d5e0..b0e16152 100644 --- a/doc/pages/hooks.asciidoc +++ b/doc/pages/hooks.asciidoc @@ -106,6 +106,10 @@ of the given *group*. *BufWritePost* `filename`:: executed just after a buffer is written +*BufReload* `filename`:: + executed after a buffer reload has been triggered by an external + modification to its file + *BufClose* `buffer name`:: executed when a buffer is deleted, while it is still valid