mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-25 17:20:25 +02:00
unposted: replace-argument can take negative prefix to count from end
This commit is contained in:
parent
341d443414
commit
6076c474f2
3 changed files with 16 additions and 7 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2014-07-24 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* unposted: Functions/Zle/replace-argument, Doc/Zsh/contrib.yo:
|
||||||
|
allow negative numeric prefix to count backwards from last
|
||||||
|
argument.
|
||||||
|
|
||||||
2014-07-23 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2014-07-23 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* Jai Keerthan: users/18981: Completion/Unix/Command/_tmux:
|
* Jai Keerthan: users/18981: Completion/Unix/Command/_tmux:
|
||||||
|
|
|
||||||
|
|
@ -2339,6 +2339,7 @@ is not executed). Arguments are as delimited by standard shell syntax,
|
||||||
|
|
||||||
If a numeric argument is given, that specifies the argument to be
|
If a numeric argument is given, that specifies the argument to be
|
||||||
replaced. 0 means the command name, as in history expansion.
|
replaced. 0 means the command name, as in history expansion.
|
||||||
|
A negative numeric argument counts backward from the last word.
|
||||||
|
|
||||||
If no numeric argument is given, the current argument is replaced;
|
If no numeric argument is given, the current argument is replaced;
|
||||||
this is the last argument if the previous history line is being used.
|
this is the last argument if the previous history line is being used.
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,23 @@ if (( ${#BUFFER} == 0 )); then
|
||||||
CURSOR=${#BUFFER}
|
CURSOR=${#BUFFER}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local widget=$WIDGET
|
local widget=$WIDGET numeric
|
||||||
integer numeric cursor=CURSOR
|
integer cursor=CURSOR
|
||||||
if (( ${+NUMERIC} )); then
|
if (( ${+NUMERIC} )); then
|
||||||
numeric=$NUMERIC
|
numeric=$NUMERIC
|
||||||
else
|
|
||||||
numeric=-1
|
|
||||||
fi
|
fi
|
||||||
local reply REPLY REPLY2
|
local reply REPLY REPLY2
|
||||||
integer index
|
integer index
|
||||||
split-shell-arguments
|
split-shell-arguments
|
||||||
|
|
||||||
if (( numeric >= 0 )); then
|
if [[ -n $numeric ]]; then
|
||||||
index=$(( 2 + 2*numeric ))
|
if (( numeric < 0 )); then
|
||||||
|
(( index = ${#reply} - 1 + 2*(numeric+1) ))
|
||||||
|
else
|
||||||
|
(( index = 2 + 2*numeric ))
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
index=$((REPLY & ~1 ))
|
(( index = REPLY & ~1 ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local edit
|
local edit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue