Add BufWritePre and BufWritePost hooks
This commit is contained in:
parent
1b1031627c
commit
39512914ad
|
@ -580,6 +580,10 @@ existing hooks are:
|
|||
* +BufOpen+: A buffer for an existing file has been created, filename is
|
||||
used for filtering
|
||||
* +BufCreate+: A buffer has been created, filename is used for filtering
|
||||
* +BufWritePre+: Executre just before a buffer is written, filename is
|
||||
used for filtering.
|
||||
* +BufWritePost+: Executre just after a buffer is written, filename is
|
||||
used for filtering.
|
||||
* +RuntimeError+: an error was encountered while executing an user command
|
||||
the error message is used for filtering
|
||||
* +KakBegin+: Kakoune started, this is called just after reading the user
|
||||
|
|
|
@ -205,6 +205,8 @@ static void write(int fd, memoryview<char> data, const String& filename)
|
|||
|
||||
void write_buffer_to_file(Buffer& buffer, const String& filename)
|
||||
{
|
||||
buffer.run_hook_in_own_context("BufWritePre", buffer.name());
|
||||
|
||||
String eolformat = buffer.options()["eolformat"].get<String>();
|
||||
if (eolformat == "crlf")
|
||||
eolformat = "\r\n";
|
||||
|
@ -231,6 +233,8 @@ void write_buffer_to_file(Buffer& buffer, const String& filename)
|
|||
}
|
||||
if ((buffer.flags() & Buffer::Flags::File) and filename == buffer.name())
|
||||
buffer.notify_saved();
|
||||
|
||||
buffer.run_hook_in_own_context("BufWritePost", buffer.name());
|
||||
}
|
||||
|
||||
String find_file(const String& filename, memoryview<String> paths)
|
||||
|
|
Loading…
Reference in New Issue
Block a user