diff options
author | Marc Coquand <marc@mccd.space> | 2024-09-05 12:27:17 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-09-05 12:27:17 -0500 |
commit | e233e7f028366ce8f5d58fe1cc8a88210664ddb3 (patch) | |
tree | 2c1cec3a19866bc39706de8a38035e15813018ed /config/kak/phantom-selection.kak | |
parent | 3783cab095a9167256afcbfe987d11f35a7003b1 (diff) | |
download | bsd-e233e7f028366ce8f5d58fe1cc8a88210664ddb3.tar.gz bsd-e233e7f028366ce8f5d58fe1cc8a88210664ddb3.tar.bz2 bsd-e233e7f028366ce8f5d58fe1cc8a88210664ddb3.zip |
add kak
Diffstat (limited to 'config/kak/phantom-selection.kak')
-rw-r--r-- | config/kak/phantom-selection.kak | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/config/kak/phantom-selection.kak b/config/kak/phantom-selection.kak new file mode 100644 index 0000000..e64c468 --- /dev/null +++ b/config/kak/phantom-selection.kak @@ -0,0 +1,84 @@ +provide-module phantom-selection %{ + +set-face global PhantomSelection black,green+F + +declare-option -hidden str-list phantom_selections +declare-option -hidden range-specs phantom_selections_ranges + +add-highlighter global/ ranges phantom_selections_ranges + +define-command -hidden phantom-selection-store-and-highlight %{ + set window phantom_selections %reg{^} + set window phantom_selections_ranges %val{timestamp} + eval -no-hooks -draft -itersel %{ + set -add window phantom_selections_ranges "%val{selection_desc}|PhantomSelection" + } +} + +define-command -hidden phantom-selection-iterate-impl -params 1 %{ + eval -save-regs ^ %{ + reg ^ %opt{phantom_selections} + try %{ + exec z + exec %arg{1} + # keep the main selection and put all the other in the mark + # a recent change to Kakoune swaps <space> with "," (and + # <a-space> with <a-,>). Try both to make sure we clear selections + # both with and without this breaking change. Pad them with <esc> + # to cancel out the key with the other behavior. + exec -save-regs '' 'Z' + phantom-selection-store-and-highlight + exec '<space><esc><,><esc>' + } catch %{ + fail 'No phantom selections' + } + } +} + +define-command phantom-selection-iterate-next -docstring " +Turn secondary selections into phantoms and select the next phantom +" %{ + phantom-selection-iterate-impl ')' +} + +define-command phantom-selection-iterate-prev -docstring " +Turn secondary selections into phantoms and select the previous phantom +" %{ + phantom-selection-iterate-impl '(' +} + +define-command phantom-selection-clear -docstring " +Remove all phantom selections +" %{ + unset window phantom_selections + unset window phantom_selections_ranges +} + +define-command phantom-selection-select-all -docstring " +Select all phantom selections +" %{ + eval -save-regs ^ %{ + reg ^ %opt{phantom_selections} + try %{ + exec z + echo "" + } catch %{ + fail 'No phantom selections' + } + } +} + +define-command phantom-selection-add-selection -docstring " +Create phantoms out of the current selections +" %{ + eval -draft -save-regs ^ %{ + reg ^ %opt{phantom_selections} + try %{ exec "<a-z>a" } + exec -save-regs '' "Z" + phantom-selection-store-and-highlight + } +} + +} + +require-module phantom-selection |