zsh-workers
 help / color / mirror / code / Atom feed
66b36c9e51b29af3ded7b9ef1602e74d367794cb blob 884 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
# Example of a widget that takes a vi motion

# Filter part of buffer corresponding to a vi motion through an external
# program.

# To enable with vi compatible bindings use:
#   autoload -Uz vi-pipe
#   bindkey -a '!' vi-pipe

autoload -Uz read-from-minibuffer
local _save_cut="$CUTBUFFER" REPLY

# Use the standard vi-delete to accept a vi motion.
zle .vi-delete || return
read-from-minibuffer "!"
local _save_cur=$CURSOR

# cut buffer contains the deleted text and can be modified
CUTBUFFER="$(eval $REPLY <<<$CUTBUFFER)"

# put the modified text back in position. 
if [[ CURSOR -eq 0 || $BUFFER[CURSOR] = $'\n' ]]; then
  # at the beginning of a line, vi-delete won't have moved the cursor
  # back to a previous line
  zle .vi-put-before -n 1
else
  zle .vi-put-after -n 1
fi

# restore cut buffer and cursor to the start of the range
CUTBUFFER="$_save_cut" CURSOR="$_save_cur"
debug log:

solving a28f211 ...
found a28f211 in https://inbox.vuxu.org/zsh-workers/2679.1467125211@thecus.kiddle.eu/

applying [1/1] https://inbox.vuxu.org/zsh-workers/2679.1467125211@thecus.kiddle.eu/
diff --git a/Functions/Zle/vi-pipe b/Functions/Zle/vi-pipe
new file mode 100644
index 0000000..a28f211

1:27: trailing whitespace.
# put the modified text back in position. 
Checking patch Functions/Zle/vi-pipe...
Applied patch Functions/Zle/vi-pipe cleanly.
warning: 1 line adds whitespace errors.

index at:
100644 66b36c9e51b29af3ded7b9ef1602e74d367794cb	Functions/Zle/vi-pipe

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).