From 5cefaa18195196aae3b73e42f12ae5f32aafcc12 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 18 Feb 2015 13:56:13 +0000 Subject: [PATCH] clang.kak: add a clang-diagnostics-next command clang-diagnostics-next will jump to the next line with a clang error/warning. --- rc/clang.kak | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rc/clang.kak b/rc/clang.kak index 91bd3aff..703c466c 100644 --- a/rc/clang.kak +++ b/rc/clang.kak @@ -73,7 +73,8 @@ def -shell-params clang-parse %{ " | paste -s -d ':') errors=$(cat ${dir}/stderr | sed -rne " - /^:[0-9]+:([0-9]+:)? (error|warning)/ { s/^:([0-9]+):([0-9]+:)? (.*)/\1,\3/; s/'/\\\\'/g; p }") + /^:[0-9]+:([0-9]+:)? (error|warning)/ { s/^:([0-9]+):([0-9]+:)? (.*)/\1,\3/; s/'/\\\\'/g; p } + " | sort -n) sed -e "s||${kak_bufname}|g" < ${dir}/stderr > ${dir}/fifo @@ -118,3 +119,21 @@ def clang-disable-diagnostics %{ rmhl hlflags_clang_flags rmhooks window clang-diagnostics } + +def clang-diagnostics-next %{ %sh{ + echo "${kak_opt_clang_errors}" | ( + line=-1 + first_line=-1 + while read line_content; do + candidate=${line_content%%,*} + first_line=$(( first_line == -1 ? candidate : first_line )) + line=$((candidate > kak_cursor_line && (candidate < line || line == -1) ? candidate : line )) + done + line=$((line == -1 ? first_line : line)) + if [ ${line} -ne -1 ]; then + echo "exec ${line} g" + else + echo 'echo -color Error no next clang diagnostic' + fi + ) +} }