Skip to content

Commit

Permalink
rc windowing new-client: copy buffer and selections from calling client
Browse files Browse the repository at this point in the history
"new" runs "kak -c" which opens a recently used buffer.  More often
than not, I rather want to preserve the calling client's buffer and
selections. For example I might select a word and run "new" followed by
"grep" on the selected word. If the selection is preserved I can use
"new grep".  A similar scenario is "new lsp-definition".

Make "new" use the calling client's buffer and selections to support
such scenarios. Center the viewport with vv, matching "edit <file>
<line>".

Vim does this in <c-w><c-v>.

Another scenario is when I want to look at two regions from a file,
side-by-side.

My initial patch used the code below but Zz seems better:

	echo "try %|
	    buffer -- '$(printf %s "$kak_buffile" | sed "s/'/''/g; s/|/||/g")'
	    select $kak_selections_desc
	    execute-keys vv
	|"
  • Loading branch information
krobelus committed Nov 13, 2023
1 parent 05477c9 commit 73a7f09
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions rc/windowing/new-client.kak
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ new [<commands>]: create a new Kakoune client
The ''terminal'' alias is being used to determine the user''s preferred terminal emulator
The optional arguments are passed as commands to the new client' \
%{
terminal kak -c %val{session} -e %sh{
for arg
do
printf %s "'$(printf %s "$arg" | sed "s/'/''/g")' "
done
terminal kak -c %val{session} -e %exp{
%{
evaluate-commands -save-regs ^ %{
try %{
execute-keys -client %val{client} -save-regs '' <esc>Z
execute-keys z
echo # clear message from z
}
}
}
%sh{
for arg
do
printf %s "'$(printf %s "$arg" | sed "s/'/''/g")' "
done
}
}
}

Expand Down

0 comments on commit 73a7f09

Please sign in to comment.