From a2516ffcc0b6806cd9dc082b61fadb4613fb6d60 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Sun, 8 Jun 2025 22:19:37 -0400 Subject: [PATCH] AutoYADM commit: 2025-06-08 22:19:37 --- .config/kak/autoload/clipboard.kak | 42 +++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.config/kak/autoload/clipboard.kak b/.config/kak/autoload/clipboard.kak index fa2fa740..7143bfce 100644 --- a/.config/kak/autoload/clipboard.kak +++ b/.config/kak/autoload/clipboard.kak @@ -1,27 +1,38 @@ -# Goal: better multi-selection behavior -# If we copy multiple selections, it should be copied s.t. each selection is on its own line - +# TODO: Make it so that each selection is split by only a single newline, +# ie if the selection already has a newline at the end then don't add another one declare-option -docstring %{ - Command for copying to system clipboard + Command for copying to system clipboard. } str clipboard_copy_cmd 'wl-copy' -define-command -params 0..1 clip-copy %{ - evaluate-commands %sh{ - if [ ${#} = 1 ] && [ ${1} = split ]; then - echo "clip-copy-split" - else - echo "clip-copy-verbatim" - fi +define-command -docstring %{ + clip-copy [-split]: copy selections to system clipboard + Set the clipboard_copy_cmd option to change the command + Switches: + -split separate each selection with a newline +} -params 0..1 clip-copy %{ + evaluate-commands -save-regs 'a|' %{ + execute-keys '"ay' + edit -scratch + set-register | %opt{clipboard_copy_cmd} + execute-keys %sh{ + if [ ${#} = 1 ] && [ ${1} = '-split' ]; then + echo '"aagjd%' + else + echo '"a%' + fi + } + delete-buffer } } define-command -docstring %{ Copies selections to system clipboard, splitting each selection onto new lines. } clip-copy-split %{ - evaluate-commands -save-regs 'a' %{ + evaluate-commands -save-regs 'a|' %{ execute-keys '"ay' edit -scratch - execute-keys '"aagjd%%opt{clipboard_copy_cmd}' + set-register | %opt{clipboard_copy_cmd} + execute-keys '"aagjd%' delete-buffer } } @@ -29,10 +40,11 @@ define-command -docstring %{ define-command -docstring %{ Copies selections to system clipboard, does not split selections onto new lines. } clip-copy-verbatim %{ - evaluate-commands -save-regs 'a' %{ + evaluate-commands -save-regs 'a|' %{ execute-keys '"ay' edit -scratch - execute-keys '"a%%opt{clipboard_copy_cmd}' + set-register | %opt{clipboard_copy_cmd} + execute-keys '"a%' delete-buffer } }