2016-02-02 20:15:12 +01:00
|
|
|
|
|
|
|
decl str doc_path "/usr/share/doc/kak/manpages"
|
|
|
|
|
|
|
|
def -hidden -params 1..2 _doc-open %{
|
|
|
|
%sh{
|
|
|
|
manout=$(mktemp /tmp/kak-man-XXXXXX)
|
|
|
|
colout=$(mktemp /tmp/kak-man-XXXXXX)
|
|
|
|
|
|
|
|
MANWIDTH=${kak_window_width} man -l "$1" > $manout
|
|
|
|
retval=$?
|
|
|
|
|
|
|
|
col -b -x > ${colout} < ${manout}
|
|
|
|
rm ${manout}
|
|
|
|
|
|
|
|
if [ "${retval}" -eq 0 ]; then
|
|
|
|
echo "
|
|
|
|
edit! -scratch '*doc*'
|
|
|
|
exec |cat<space>${colout}<ret>gg
|
|
|
|
nop %sh{rm ${colout}}
|
|
|
|
set buffer filetype man
|
|
|
|
"
|
|
|
|
|
|
|
|
if [ $# -gt 1 ]; then
|
2016-02-03 20:09:17 +01:00
|
|
|
echo "try %{ exec '%<a-s><a-k>(?i)^\h+[^\n]*?\Q${2}\E<ret>\'' } catch %{ exec <space>gg }"
|
2016-02-02 20:15:12 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "echo -color Error %{doc '$@' failed: see *debug* buffer for details}"
|
|
|
|
rm ${colout}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def -params 1..2 \
|
|
|
|
-shell-completion %{
|
2016-02-03 20:09:17 +01:00
|
|
|
find "${kak_opt_doc_path}" -type f -iname "*$@*.gz" -printf '%f\n' | while read l; do
|
|
|
|
echo "${l%.*}"
|
|
|
|
done
|
2016-02-02 20:15:12 +01:00
|
|
|
} \
|
|
|
|
doc -docstring "Open a buffer containing the documentation about a given subject" %{
|
|
|
|
%sh{
|
2016-02-03 20:09:17 +01:00
|
|
|
readonly PATH_DOC="${kak_opt_doc_path}/${1}.gz"
|
2016-02-02 20:15:12 +01:00
|
|
|
|
|
|
|
shift
|
|
|
|
if [ ! -f "${PATH_DOC}" ]; then
|
|
|
|
echo "echo -color Error No such doc file: ${PATH_DOC}"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "eval -try-client %opt{docsclient} _doc-open ${PATH_DOC} $@"
|
|
|
|
}
|
|
|
|
}
|