man.kak: Better support for renaming a man buffer

Fixes #1718
This commit is contained in:
Maxime Coste 2017-12-06 14:49:38 +08:00
parent 70e2122ae6
commit 1b44056fce

View File

@ -17,7 +17,7 @@ hook -group man-highlight global WinSetOption filetype=man %{
hook global WinSetOption filetype=man %{
hook -group man-hooks window WinResize .* %{
man-impl %opt{manpage}
man-impl %val{bufname} %opt{manpage}
}
}
@ -27,7 +27,9 @@ hook global WinSetOption filetype=(?!man).* %{
remove-hooks window man-hooks
}
define-command -hidden -params 1..2 man-impl %{ %sh{
define-command -hidden -params 2..3 man-impl %{ %sh{
buffer_name="$1"
shift
manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
MANWIDTH=${kak_window_width} man "$@" > $manout 2>/dev/null
@ -36,7 +38,7 @@ define-command -hidden -params 1..2 man-impl %{ %sh{
rm ${manout}
if [ "${retval}" -eq 0 ]; then
printf %s\\n "
edit -scratch '*man*'
edit -scratch '$buffer_name'
execute-keys '%|cat<space>${colout}<ret>gk'
nop %sh{rm ${colout}}
set-option buffer filetype man
@ -67,5 +69,5 @@ The page can be a word, or a word directly followed by a section number between
;;
esac
printf %s\\n "evaluate-commands -collapse-jumps -try-client %opt{docsclient} man-impl $pagenum $subject"
printf %s\\n "evaluate-commands -collapse-jumps -try-client %opt{docsclient} man-impl *man* $pagenum $subject"
} }