mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
15279: ${(S)...%%...} etc. doc; 15288: bash word functions + doc
This commit is contained in:
parent
1348458447
commit
fe06b7a73d
8 changed files with 79 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2001-07-06 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 15288: Doc/Zsh/contrib.yo,
|
||||
Functions/Zle/bash-forward-word, Functions/Zle/bash-bacward-word,
|
||||
Functions/Zle/bash-kill-word, Functions/Zle/bash-backward-kill-word:
|
||||
complete set of bash-compatible word functions with documentation.
|
||||
|
||||
* 15279: Doc/Zsh/expn.yo: describe those ${(S)...%%...} things
|
||||
so that even I understand what the code does.
|
||||
|
||||
2001-07-06 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 15252 (and Akinori Musha: 15245): Completion/BSD/Command/_kld,
|
||||
|
|
|
@ -362,6 +362,23 @@ followed by an appropriate tt(bindkey) command to associate the function
|
|||
with a key sequence. Suggested bindings are described below.
|
||||
|
||||
startitem()
|
||||
tindex(bash-forward-word)
|
||||
tindex(bash-backward-word)
|
||||
tindex(bash-kill-word)
|
||||
tindex(bash-backward-kill-word)
|
||||
xitem(tt(bash-forward-word), tt(bash-backward-word))
|
||||
item(tt(bash-kill-word), tt(bash-backward-kill-word))(
|
||||
These work similarly to the corresponding builtin zle functions without the
|
||||
`tt(bash-)' prefix, but a word is considered to consist of alphanumeric
|
||||
characters only. If you wish to replace your existing bindings with these
|
||||
four widgets, the following is sufficient:
|
||||
|
||||
example(for widget in kill-word backward-kill-word \
|
||||
forward-word backward-word; do
|
||||
autoload bash-$widget
|
||||
zle -N $widget bash-$widget
|
||||
done)
|
||||
)
|
||||
tindex(cycle-completion-positions)
|
||||
item(tt(cycle-completion-positions))(
|
||||
After inserting an unambiguous string into the command line, the new
|
||||
|
|
|
@ -791,10 +791,26 @@ Search the var(expr)th match (where var(expr) evaluates to a number).
|
|||
This only applies when searching for substrings, either with the tt(S)
|
||||
flag, or with tt(${)...tt(/)...tt(}) (only the var(expr)th match is
|
||||
substituted) or tt(${)...tt(//)...tt(}) (all matches from the
|
||||
var(expr)th on are substituted). The var(expr)th match is counted
|
||||
such that there is either one or zero matches from each starting
|
||||
position in the string, although for global substitution matches
|
||||
overlapping previous replacements are ignored.
|
||||
var(expr)th on are substituted). The default is to take the first match.
|
||||
|
||||
The var(expr)th match is counted such that there is either one or zero
|
||||
matches from each starting position in the string, although for global
|
||||
substitution matches overlapping previous replacements are ignored. With
|
||||
the tt(${)...tt(%)...tt(}) and tt(${)...tt(%%)...tt(}) forms, the starting
|
||||
position for the match moves backwards from the end as the index increases,
|
||||
while with the other forms it moves forward from the start.
|
||||
|
||||
Hence with the string
|
||||
example(which switch is the right switch for Ipswich?)
|
||||
substitutions of the form
|
||||
tt(${)LPAR()tt(SI:)var(N)tt(:)RPAR()tt(string#w*ch}) as var(N) increases
|
||||
from 1 will match and remove `tt(which)', `tt(witch)', `tt(witch)' and
|
||||
`tt(wich)'; the form using `tt(##)' will match and remove `tt(which switch
|
||||
is the right switch for Ipswich)', `tt(witch is the right switch for
|
||||
Ipswich)', `tt(witch for Ipswich)' and `tt(wich)'. The form using `tt(%)'
|
||||
will remove the same matches as for `tt(#)', but in reverse order, and the
|
||||
form using `tt(%%)' will remove the same matches as for `tt(##)' in reverse
|
||||
order.
|
||||
)
|
||||
item(tt(M))(
|
||||
Include the matched portion in the result.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
DISTFILES_SRC='
|
||||
.distfiles
|
||||
bash-backward-kill-word bash-backward-word
|
||||
bash-kill-word bash-forward-word
|
||||
cycle-completion-positions incarg predict-on
|
||||
edit-command-line incremental-complete-word smart-insert-last-word
|
||||
history-search-end insert-files
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# function bash-backward-kill-word {
|
||||
# This implements a bash-style backward-kill-word.
|
||||
# To use,
|
||||
# zle -N bash-backward-kill-word
|
||||
# bindkey '...' bash-backward-kill-word
|
||||
# or if you wish to replace existing backward-kill-word bindings,
|
||||
# zle -N backward-kill-word bash-backward-kill-word
|
||||
|
||||
local WORDCHARS=''
|
||||
zle .backward-kill-word
|
||||
# }
|
||||
|
|
9
Functions/Zle/bash-backward-word
Normal file
9
Functions/Zle/bash-backward-word
Normal file
|
@ -0,0 +1,9 @@
|
|||
# This implements a bash-style backward-word.
|
||||
# To use,
|
||||
# zle -N bash-backward-word
|
||||
# bindkey '...' bash-backward-word
|
||||
# or if you wish to replace existing backward-word bindings,
|
||||
# zle -N backward-word bash-backward-word
|
||||
|
||||
local WORDCHARS=''
|
||||
zle .backward-word
|
9
Functions/Zle/bash-forward-word
Normal file
9
Functions/Zle/bash-forward-word
Normal file
|
@ -0,0 +1,9 @@
|
|||
# This implements a bash-style forward-word.
|
||||
# To use,
|
||||
# zle -N bash-forward-word
|
||||
# bindkey '...' bash-forward-word
|
||||
# or if you wish to replace existing forward-word bindings,
|
||||
# zle -N forward-word bash-forward-word
|
||||
|
||||
local WORDCHARS=''
|
||||
zle .forward-word
|
9
Functions/Zle/bash-kill-word
Normal file
9
Functions/Zle/bash-kill-word
Normal file
|
@ -0,0 +1,9 @@
|
|||
# This implements a bash-style kill-word.
|
||||
# To use,
|
||||
# zle -N bash-kill-word
|
||||
# bindkey '...' bash-kill-word
|
||||
# or if you wish to replace existing kill-word bindings,
|
||||
# zle -N kill-word bash-kill-word
|
||||
|
||||
local WORDCHARS=''
|
||||
zle .kill-word
|
Loading…
Reference in a new issue