Skip to content

Commit

Permalink
Override after config loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
eraserhd committed Apr 18, 2024
1 parent 179ecf9 commit 459d3ca
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.asc
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
CHANGELOG
=========

== https://github.com/eraserhd/kak-ansi/compare/v0.2.7...HEAD[Unreleased]
== https://github.com/eraserhd/kak-ansi/compare/v0.2.8...HEAD[Unreleased]

== https://github.com/eraserhd/kak-ansi/compare/v0.2.7...HEAD[v0.2.8]

=== Fixed

* Override `man-impl` after configuration is loaded.

== https://github.com/eraserhd/kak-ansi/compare/v0.2.6...v0.2.7[v0.2.7]

Expand Down
2 changes: 1 addition & 1 deletion derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

stdenv.mkDerivation rec {
name = "kak-ansi";
version = "0.2.7";
version = "0.2.8";

src = ./.;

Expand Down
55 changes: 28 additions & 27 deletions rc/ansi.kak
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,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<space>${manout}<ret>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
} }
hook -once -group ansi global KakBegin '.*' %{
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<space>${manout}<ret>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
} }
}

0 comments on commit 459d3ca

Please sign in to comment.