1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-24 20:13:00 +03:00

Prevent the :format command from triggering hooks.

The :format command is often called from a BufWritePre hook to format the
current buffer, however the :format command itself calls `:write` to store the
buffer in a temporary location, potentially causing an infinite recursion.

If we disable hooks while running :format, there's no danger of that occurring.
This commit is contained in:
Tim Allen 2018-06-01 20:22:08 +10:00
parent 7591924f85
commit 3d0c19f8fb

View File

@ -1,7 +1,7 @@
declare-option -docstring "shell command to which the contents of the current buffer is piped" \ declare-option -docstring "shell command to which the contents of the current buffer is piped" \
str formatcmd str formatcmd
define-command format -docstring "Format the contents of the current buffer" %{ evaluate-commands -draft %{ define-command format -docstring "Format the contents of the current buffer" %{ evaluate-commands -draft -no-hooks %{
%sh{ %sh{
if [ -n "${kak_opt_formatcmd}" ]; then if [ -n "${kak_opt_formatcmd}" ]; then
path_file_tmp=$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX) path_file_tmp=$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX)