Fix clang.kak escaping, go back to a hook for removing tmp dir
Previous trap based solution could end up with sh waiting on a closed fifo.
This commit is contained in:
parent
604e95f771
commit
866b3358c9
12
rc/clang.kak
12
rc/clang.kak
|
@ -20,14 +20,16 @@ def -shell-params clang-parse %{
|
||||||
edit! -fifo ${dir}/fifo *clang-output*
|
edit! -fifo ${dir}/fifo *clang-output*
|
||||||
set buffer filetype make
|
set buffer filetype make
|
||||||
set buffer _make_current_error_line 0
|
set buffer _make_current_error_line 0
|
||||||
|
hook -group fifo buffer BufCloseFifo .* %{
|
||||||
|
nop %sh{ rm -r ${dir} }
|
||||||
|
rmhooks buffer fifo
|
||||||
|
}
|
||||||
}"
|
}"
|
||||||
# this runs in a detached shell, asynchronously, so that kakoune does
|
# this runs in a detached shell, asynchronously, so that kakoune does
|
||||||
# not hang while clang is running. As completions references a cursor
|
# not hang while clang is running. As completions references a cursor
|
||||||
# position and a buffer timestamp, only valid completions should be
|
# position and a buffer timestamp, only valid completions should be
|
||||||
# displayed.
|
# displayed.
|
||||||
(
|
(
|
||||||
trap "rm -r ${dir}" EXIT
|
|
||||||
|
|
||||||
case ${kak_opt_filetype} in
|
case ${kak_opt_filetype} in
|
||||||
cpp) ft=c++ ;;
|
cpp) ft=c++ ;;
|
||||||
obj-c) ft=objective-c ;;
|
obj-c) ft=objective-c ;;
|
||||||
|
@ -48,10 +50,8 @@ def -shell-params clang-parse %{
|
||||||
gsub(/ +$/, "", $3)
|
gsub(/ +$/, "", $3)
|
||||||
id=substr($2, 1, length($2)-1)
|
id=substr($2, 1, length($2)-1)
|
||||||
gsub(/:/, "\\:", id)
|
gsub(/:/, "\\:", id)
|
||||||
gsub(/"/, "\\\"", id)
|
|
||||||
desc=$4 ? $3 "\\n" $4 : $3
|
desc=$4 ? $3 "\\n" $4 : $3
|
||||||
gsub(/:/, "\\:", desc)
|
gsub(/:/, "\\:", desc)
|
||||||
gsub(/"/, "\\\"", desc)
|
|
||||||
if (id in completions)
|
if (id in completions)
|
||||||
completions[id]=completions[id] "\\n" desc
|
completions[id]=completions[id] "\\n" desc
|
||||||
else
|
else
|
||||||
|
@ -60,9 +60,9 @@ def -shell-params clang-parse %{
|
||||||
END {
|
END {
|
||||||
for (id in completions)
|
for (id in completions)
|
||||||
print id "@" completions[id]
|
print id "@" completions[id]
|
||||||
}' | sort | paste -s -d ':' | sed -e 's/\\n/\n/g')
|
}' | sort | paste -s -d ':' | sed -e "s/\\\\n/\\n/g; s/'/\\\\'/g")
|
||||||
echo "eval -client ${kak_client} echo completed
|
echo "eval -client ${kak_client} echo completed
|
||||||
set 'buffer=${kak_buffile}' clang_completions \"${header}:${compl}\"" | kak -p ${kak_session}
|
set 'buffer=${kak_buffile}' clang_completions '${header}:${compl}'" | kak -p ${kak_session}
|
||||||
else
|
else
|
||||||
clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr
|
clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user