diff --git a/rc/core/man.kak b/rc/core/man.kak index f59872f7..ac1ba94c 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -1,5 +1,7 @@ decl str docsclient +decl -hidden str _manpage + hook global WinSetOption filetype=man %{ addhl group man-highlight # Sections @@ -10,6 +12,10 @@ hook global WinSetOption filetype=man %{ addhl -group man-highlight regex '^ {7}-[^\s,]+(,\s+-[^\s,]+)*' 0:yellow # References to other manpages addhl -group man-highlight regex [-a-zA-Z0-9_.]+\(\d\) 0:green + + hook -group man-hooks window WinResize .* %{ + _man %opt{_manpage} + } } hook global WinSetOption filetype=(?!man).* %{ @@ -17,7 +23,7 @@ hook global WinSetOption filetype=(?!man).* %{ rmhooks window man-hooks } -def -hidden -params .. _man %{ %sh{ +def -hidden -params 1..2 _man %{ %sh{ manout=$(mktemp /tmp/kak-man-XXXXXX) colout=$(mktemp /tmp/kak-man-XXXXXX) MANWIDTH=${kak_window_width} man "$@" > $manout @@ -25,10 +31,13 @@ def -hidden -params .. _man %{ %sh{ col -b -x > ${colout} < ${manout} rm ${manout} if [ "${retval}" -eq 0 ]; then - printf %s\\n "edit! -scratch '*man*' - exec |cat${colout}gk - nop %sh{rm ${colout}} - set buffer filetype man" + printf %s\\n " + edit -scratch '*man*' + exec '%|cat${colout}gk' + nop %sh{rm ${colout}} + set buffer filetype man + set window _manpage '$@' + " else printf %s\\n "echo -color Error %{man '$@' failed: see *debug* buffer for details }" rm ${colout}