zsh-workers
 help / color / mirror / code / Atom feed
b43fc39bb6986c64778a528502fb3fe10e54600c blob 1039 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
# Replace an argument to a command, delimited by normal shell syntax.
# Prompts for the replacement.
# With no numeric argument, replace the current argument.
# With a numeric argument, replace that argument: 0 = command word,
# as in history expansion.
# If editing buffer is empty, use previous history line.

autoload -Uz split-shell-arguments read-from-minibuffer

if (( ${#BUFFER} == 0 )); then
  (( HISTNO-- ))
  CURSOR=${#BUFFER}
fi

local widget=$WIDGET
integer numeric cursor=CURSOR
if (( ${+NUMERIC} )); then
  numeric=$NUMERIC
else
  numeric=-1
fi
local reply REPLY REPLY2
integer index
split-shell-arguments

if (( numeric >= 0 )); then
  index=$(( 2 + 2*numeric ))
else
  index=$((REPLY & ~1 ))
fi

local edit
if [[ $widget = *edit* ]]; then
  edit=$reply[$index]
fi
read-from-minibuffer "Replace $reply[$index] with: " $edit || return 1

integer diff=$(( ${#REPLY} - ${#reply[$index]} ))
reply[$index]=$REPLY

BUFFER=${(j..)reply}
if (( cursor > REPLY2 )); then
  (( CURSOR = cursor + diff ))
else
  (( CURSOR = REPLY2 ))
fi
debug log:

solving b43fc39 ...
found b43fc39 in https://git.vuxu.org/mirror/zsh/

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).