diff --git a/CHANGELOG.asc b/CHANGELOG.asc index 8b32284..cfb29ff 100644 --- a/CHANGELOG.asc +++ b/CHANGELOG.asc @@ -1,7 +1,14 @@ CHANGELOG ========= -== https://github.com/eraserhd/kak-ansi/compare/v0.2.6...HEAD[Unreleased] +== https://github.com/eraserhd/kak-ansi/compare/v0.2.7...HEAD[Unreleased] + +== https://github.com/eraserhd/kak-ansi/compare/v0.2.6...v0.2.7[v0.2.7] + +=== Added + +* Override Kakoune's default `man-impl` to use `ansi-enable`. The `man` + command brought in by Nix on Mac OS has started using ANSI escapes. == https://github.com/eraserhd/kak-ansi/compare/v0.2.5...v0.2.6[v0.2.6] diff --git a/derivation.nix b/derivation.nix index 8b905b9..fded394 100644 --- a/derivation.nix +++ b/derivation.nix @@ -2,7 +2,7 @@ stdenv.mkDerivation rec { name = "kak-ansi"; - version = "0.2.6"; + version = "0.2.7"; src = ./.; diff --git a/rc/ansi.kak b/rc/ansi.kak index 8999e13..35e6741 100644 --- a/rc/ansi.kak +++ b/rc/ansi.kak @@ -76,3 +76,32 @@ define-command \ } hook -group ansi global BufCreate '\*stdin(?:-\d+)?\*' ansi-enable + +define-command -override -hidden -params ..3 man-impl %{ evaluate-commands %sh{ + buffer_name="$1" + if [ -z "${buffer_name}" ]; then + exit + fi + shift + manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man.XXXXXX) + manerr=$(mktemp "${TMPDIR:-/tmp}"/kak-man.XXXXXX) + env MANWIDTH=${kak_window_range##* } man "$@" > "$manout" 2> "$manerr" + retval=$? + + if [ "${retval}" -eq 0 ]; then + printf %s\\n " + edit -scratch %{*$buffer_name ${*}*} + execute-keys '%|cat${manout}gk' + ansi-enable + nop %sh{ rm ${manout} ${manerr} } + set-option buffer filetype man + set-option window manpage $buffer_name $* + " + else + printf ' + fail %%{%s} + nop %%sh{ rm "%s" "%s" } + ' "$(cat "$manerr")" "${manout}" "${manerr}" + fi +} } +