From 58e065669fc793374a880139589c7d48f81b8972 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Mon, 8 Apr 2019 09:08:56 +0300 Subject: [PATCH 1/2] remove surrounding quotes --- rc/modules/fzf-yank-ring.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/modules/fzf-yank-ring.kak b/rc/modules/fzf-yank-ring.kak index 7939538..a170dd5 100644 --- a/rc/modules/fzf-yank-ring.kak +++ b/rc/modules/fzf-yank-ring.kak @@ -24,6 +24,6 @@ define-command -hidden fzf-yank-ring %{ evaluate-commands %sh{ message="Swap between yanks." - printf "%s" "fzf -kak-cmd %{set-register dquote} -items-cmd %{cat $yanks} -filter %{sed \"s/␤/\\\n/g;s/^'|'$//\"}" + printf "%s\n" "fzf -kak-cmd %{set-register dquote} -items-cmd %{cat $yanks} -filter %{sed 's/␤/\\\\n/g;s/^.//;s/.\\\n$//'}" }} From bae554f28e3ebc0dd70e3a85c37c2144df084c54 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Mon, 8 Apr 2019 11:24:07 +0300 Subject: [PATCH 2/2] fix yank ring --- rc/modules/fzf-yank-ring.kak | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/rc/modules/fzf-yank-ring.kak b/rc/modules/fzf-yank-ring.kak index a170dd5..646615b 100644 --- a/rc/modules/fzf-yank-ring.kak +++ b/rc/modules/fzf-yank-ring.kak @@ -11,19 +11,33 @@ # ╰─────────────────────────────────────╯ try %{ declare-user-mode fzf } -map global fzf -docstring "open yank-ring" 'y' ': fzf-yank-ring' + +# this will fail if yank-ring.kak isn't installed +hook global -once WinCreate .* %{ + try %{ + set-option -add global yank_ring_history + map global fzf -docstring "open yank-ring" 'y' ': fzf-yank-ring' + } +} + +declare-option -hidden str fzf_yank_ring_result define-command -hidden fzf-yank-ring %{ evaluate-commands %sh{ yanks=$(mktemp ${TMPDIR:-/tmp}/kak-fzf-yanks.XXXXXX) eval "set -- $kak_opt_yank_ring_history" while [ $# -gt 0 ]; do - item=$(printf "%s" "$1" | awk 1 ORS='␤') + item=$(printf "%s" "$1" | sed "s/^'//;s/'$//" | awk 1 ORS='␤') printf "%s\n" "$item" >> $yanks shift done - message="Swap between yanks." - - printf "%s\n" "fzf -kak-cmd %{set-register dquote} -items-cmd %{cat $yanks} -filter %{sed 's/␤/\\\\n/g;s/^.//;s/.\\\n$//'}" + message="Swap between items in yank-ring." + printf "%s\n" "fzf -kak-cmd %{set-option global fzf_yank_ring_result} -items-cmd %{cat $yanks} -post-action %{fzf-yank-ring-set-dquote}" }} +define-command fzf-yank-ring-set-dquote %{ + set-register dquote %sh{ + printf "%s\n" "$kak_opt_fzf_yank_ring_result" | sed "s/␤/\n/g;" + } +} +