From 1b44056fce951cb5b853202d26148ffa5d45a119 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 6 Dec 2017 14:49:38 +0800 Subject: [PATCH] man.kak: Better support for renaming a man buffer Fixes #1718 --- rc/core/man.kak | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rc/core/man.kak b/rc/core/man.kak index 22659bb8..7deba1f1 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -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${colout}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" } }