Fix and simplify ctags-funcinfo command

1. Enable the command to correctly show the prefix of a function name [prefix::basename],
   where prefix is the value gotten from a class, struct, or namespace field of the tag line.

2. Use a readtag filter expression to replace a use of grep.
This commit is contained in:
Steven Chan 2019-01-28 11:18:12 -08:00
parent 3e89148d74
commit 568d46bf72

View File

@ -62,7 +62,10 @@ define-command ctags-funcinfo -docstring "Display ctags information about a sele
try %{
execute-keys '[(;B<a-k>[a-zA-Z_]+\(<ret><a-;>'
evaluate-commands %sh{
sigs=$(readtags -e ${kak_selection%?} | grep kind:f | sed -re 's/^(\S+).*((class|struct|namespace):(\S+))?.*signature:(.*)$/\5 [\4::\1]/')
f=${kak_selection%?}
sig='\tsignature:(.*)'
csn='\t(class|struct|namespace):(\S+)'
sigs=$(readtags -e -Q '(eq? $kind "f")' "${f}" | sed -re "s/^.*${csn}.*${sig}$/\3 [\2::${f}]/ ;t ;s/^.*${sig}$/\1 [${f}]/")
if [ -n "$sigs" ]; then
printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -placement above '$sigs'}"
fi