From da19b67388770514b44f28796d9de4dd239297bd Mon Sep 17 00:00:00 2001 From: Stephane Chazelas Date: Wed, 1 Jan 2020 21:18:09 +0000 Subject: 45183: Improve documentation examples --- Doc/Zsh/contrib.yo | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 558342711..011a75c77 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -4418,24 +4418,28 @@ the elements from the tt(input) list in each run. If no var(command) is provided, then no var(arg) list may be provided, and in that event the default command is `tt(print)' with arguments `tt(-r -)tt(-)'. -For example, to get a long tt(ls) listing of all plain files in the -current directory or its subdirectories: +For example, to get a long tt(ls) listing of all non-hidden plain files +in the current directory or its subdirectories: example(autoload -U zargs -zargs -- **/*(.) -- ls -l) +zargs -- **/*(.) -- ls -ld --) -Note that `tt(-)tt(-)' is used both to mark the end of the var(option) -list and to mark the end of the var(input) list, so it must appear twice -whenever the var(input) list may be empty. If there is guaranteed to be -at least one var(input) and the first var(input) does not begin with a -`tt(-)', then the first `tt(-)tt(-)' may be omitted. +The first and third occurrences of `tt(-)tt(-)' are used to mark the end +of options for tt(zargs) and tt(ls) respectively to guard against +filenames starting with `tt(-)', while the second is used to separate the +list of files from the command to run (`tt(ls -ld --)'). + +The first `tt(-)tt(-)' would also be needed if there was a chance the +list might be empty as in: + +example(zargs -r -- ./*.back(#qN) -- rm -f) In the event that the string `tt(-)tt(-)' is or may be an var(input), the tt(-e) option may be used to change the end-of-inputs marker. Note that this does em(not) change the end-of-options marker. For example, to use `tt(..)' as the marker: -example(zargs -e.. -- **/*(.) .. ls -l) +example(zargs -e.. -- **/*(.) .. ls -ld --) This is a good choice in that example because no plain file can be named `tt(..)', but the best end-marker depends on the circumstances. -- cgit 1.4.1 From 759daf2362c80c1840abbdea48db15450d8b44d0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 2 Jan 2020 16:08:17 +0000 Subject: unposted (after 45183): Fix yodl error: "contrib.yo:4457: No macro: back(...)". --- ChangeLog | 3 +++ Doc/Zsh/contrib.yo | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index 355dd30b4..701801339 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2020-01-02 Daniel Shahaf + * unposted (after 45183): Doc/Zsh/contrib.yo: Fix yodl error: + "contrib.yo:4457: No macro: back(...)". + * 45181: Src/glob.c, Test/D04parameter.ztst: Fix workers/45164: ${(S)%%} will now consider the empty string as a potential match. diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 011a75c77..6a80cd253 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -4432,7 +4432,7 @@ list of files from the command to run (`tt(ls -ld --)'). The first `tt(-)tt(-)' would also be needed if there was a chance the list might be empty as in: -example(zargs -r -- ./*.back(#qN) -- rm -f) +example(zargs -r -- ./*.back+LPAR()#qN+RPAR() -- rm -f) In the event that the string `tt(-)tt(-)' is or may be an var(input), the tt(-e) option may be used to change the end-of-inputs marker. Note that -- cgit 1.4.1 From 2ce5f6d79a70060c65b2d1ff456e5b505309e0be Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sat, 11 Jan 2020 14:07:19 +0000 Subject: users/24628 (fixed): More doc for selectw-word-style widgets. Add example of how to add a new binding for a widget that fixes a particular word behaviour using styles. --- ChangeLog | 5 +++++ Doc/Zsh/contrib.yo | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'Doc/Zsh/contrib.yo') diff --git a/ChangeLog b/ChangeLog index dd668e9bd..0b904e482 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-11 Peter Stephenson + + * users/24628 (fixed up): Doc/Zsh/contrib.yo: Add example of how + to bind word matching widget with a fixed style. + 2020-01-10 Daniel Shahaf * 45266: Completion/Linux/Command/_losetup: Fix losetup diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 6a80cd253..c6bf745b7 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2227,7 +2227,20 @@ is set in the context tt(:zle:*) to tt(true) if the word style is tt(bash) and tt(false) otherwise. It may be overridden by setting it in the more specific context tt(:zle:forward-word*). -Here are some examples of use of the styles, actually taken from the +It is possible to create widgets with specific behaviour by defining +a new widget implemented by the appropriate generic function, then +setting a style for the context of the specific widget. For example, +the following defines a widget tt(backward-kill-space-word) using +tt(backward-kill-word-match), the generic widget implementing +tt(backward-kill-word) behaviour, and ensures that the new widget +always implements space-delimited behaviour. + +example(zle -N backward-kill-space-word backward-kill-word-match +zstyle :zle:backward-kill-space-word word-style space) + +The widget tt(backward-kill-space-word) can now be bound to a key. + +Here are some further examples of use of the styles, actually taken from the simplified interface in tt(select-word-style): example(zstyle ':zle:*' word-style standard -- cgit 1.4.1