port ctags.kak to posix awk

This commit is contained in:
Maxime Coste 2014-03-28 21:15:39 +00:00
parent 126d61aa86
commit 71374139c9

View File

@ -8,22 +8,14 @@ def -shell-params \
-docstring 'jump to tag definition' \ -docstring 'jump to tag definition' \
tag \ tag \
%{ %sh{ %{ %sh{
if [ -z "$1" ]; then tagname=${kak_selection}; else tagname="$1"; fi export tagname=${1:-${kak_selection}}
matches=$(readtags ${tagname}) readtags ${tagname} | awk -F '\t|\n' -e '
if [ -z "${matches}" ]; then /[^\t]+\t[^\t]+\t\/\^.*\$\// {
echo "echo tag not found ${tagname}" gsub("^/\\^", "", $3); gsub("\\$/$", "", $3); gsub("(\\{|\\}).*$", "", $3);
else out = out " %{" $2 " [" $3 "]} %{try %{ edit %{" $2 "}; exec %{/\\Q" $3 "<ret>vc} } catch %{ debug %{" $3 "}; echo %{unable to find tag} } }"
menuparam=$(readtags ${tagname} | perl -i -ne ' }
/([^\t]+)\t([^\t]+)\t\/\^([^{}]*).*\$\// and print "%{$2 [$3]} %{try %{ edit %{$2}; exec %{/\\Q$3<ret>vc} } catch %{ echo %{unable to find tag} } } "; /[^\t]+\t[^\t]+\t([0-9]+)/ { out = out " %{" $2 ":" $3 "} %{edit %{" $2 "} %{" $3 "}}" }
/([^\t]+)\t([^\t]+)\t(\d+)/ and print "%{$2:$3} %{edit %{$2} %{$3}}"; END { print length(out) == 0 ? "echo -color Error no such tag " ENVIRON["tagname"] : "menu -auto-single " out }'
' | sed -e 's/\n/ /g')
if [ -z "${menuparam}" ]; then
echo "echo no such tag ${tagname}";
else
echo "menu -auto-single ${menuparam}";
fi
fi
}} }}
def tag-complete %{ eval -draft %{ def tag-complete %{ eval -draft %{