diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-15 19:47:21 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-15 19:47:21 -0500 |
commit | 9536a4c2b46e6851db41bab2806c7bdeee8edbb8 (patch) | |
tree | 5a7be6c2376ed92884557d0257d0ed8c3dc1e796 /config/kak/phantom-selection.kak | |
parent | d09be0d5ced1b31e40a1114581abfce0db06c540 (diff) | |
download | rcm-9536a4c2b46e6851db41bab2806c7bdeee8edbb8.tar.gz rcm-9536a4c2b46e6851db41bab2806c7bdeee8edbb8.tar.bz2 rcm-9536a4c2b46e6851db41bab2806c7bdeee8edbb8.zip |
Add kak and more
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 |