kakoune/doc/manpages/hooks

128 lines
3.3 KiB
Plaintext

.TH KAKOUNE 1 "" "" "HOOKS"
.TP
Commands can be registred to be executed when certain events arise. To register a hook use the following command:
.RS 3
.TP
.BR hook " [-group <group>] <scope> <hook_name> <filtering_regex> <commands>"
.RE
.IR <scope>
can be one of
.IR global ", " buffer " or " window
.IR <command>
is a string containing the commands to execute when the hook is called
For example to automatically use line numbering with .cc files, use the following command:
.RS 3
.TP
.BR hook " global WinCreate .*\.cc %{ addhl number_lines }"
.RE
if
.IR <group>
is given, make this hook part of the named group. Groups are used for removing hooks with the following command:
.RS 3
.TP
.BR rmhooks " <scope> <group>"
.RE
A call to the command above will remove every hooks in
.IR <scope>
that are part of the given group.
.SS Default hooks
.TP
.BR NormalIdle
a certain duration has passed since last key was pressed in normal mode
.TP
.BR NormalBegin
entering normal mode
.TP
.BR NormalEnd
leaving normal mode
.TP
.BR NormalKey
a key is received in normal mode, the key is used for filtering
.TP
.BR InsertIdle
a certain duration has passed since last key was pressed in insert mode
.TP
.BR InsertBegin
entering insert mode
.TP
.BR InsertEnd
leaving insert mode
.TP
.BR InsertKey
a key is received in insert mode, the key is used for filtering
.TP
.BR InsertMove
the cursor moved (without inserting) in insert mode, the key that triggered the move is used for filtering
.TP
.BR WinCreate
a window was created, the filtering text is the buffer name
.TP
.BR WinClose
a window was detroyed, the filtering text is the buffer name
.TP
.BR WinDisplay
a window was bound a client, the filtering text is the buffer name
.TP
.BR WinSetOption
an option was set in a window context, the filtering text is
.IR <option_name>=<new_value>
.TP
.BR BufSetOption
an option was set in a buffer context, the filtering text is
.IR <option_name>=<new_value>
.TP
.BR BufNew
a buffer for a new file has been created, filename is used for filtering
.TP
.BR BufOpen
a buffer for an existing file has been created, filename is used for filtering
.TP
.BR BufCreate
a buffer has been created, filename is used for filtering
.TP
.BR BufWritePre
executed just before a buffer is written, filename is used for filtering
.TP
.BR BufWritePost
executed just after a buffer is written, filename is used for filtering
.TP
.BR BufClose
executed when a buffer is deleted, while it is still valid
.TP
.BR BufOpenFifo
executed when a buffer opens a fifo
.TP
.BR BufReadFifo
executed after some data has been red from a fifo and inserted in the buffer
.TP
.BR BufCloseFifo
executed when a fifo buffer closes its fifo file descriptor either because the buffer is being deleted, or because the writing end has been closed
.TP
.BR RuntimeError
an error was encountered while executing an user command the error message is used for filtering
.TP
.BR KakBegin
kakoune has started, this hook is called just after reading the user configuration files
.TP
.BR KakEnd
kakoune is quitting
.TP
.BR FocusIn
on supported clients, triggered when the client gets focused. the filtering text is the client name
.TP
.BR FocusOut
on supported clients, triggered when the client gets unfocused. the filtering text is the client name
.RE
When not specified, the filtering text is an empty string.