Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 4/4] _normal: Add -P to reset precommands

Add the ability to reset the precommands array to empty. Will be useful
for zsh -c and perhaps some other situations. Again the texi is

 Completion/Base/Core/_normal | 3 ++-
 Doc/Zsh/compsys.yo           | 9 +++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Completion/Base/Core/_normal b/Completion/Base/Core/_normal
index 7732837ac..0d84eae87 100644
--- a/Completion/Base/Core/_normal
+++ b/Completion/Base/Core/_normal
@@ -3,8 +3,9 @@
 local _comp_command1 _comp_command2 _comp_command precommand
 local -A opts
-zparseopts -A opts -D - p+:-=precommand s
+zparseopts -A opts -D - P p+:-=precommand s
 (( $+opts[-s] )) || _compskip=
+(( $+opts[-P] )) && precommands=()
 (( $#precommand )) && precommands+=(${precommand#-p})
 # Check for a history reference to complete modifiers.
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index af47f1fdb..f3f32db1e 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -4658,7 +4658,7 @@ fi
 return ret)
-xitem(tt(_normal) [ tt(-p) var(precommand) ])(
+xitem(tt(_normal) [ tt(-P) | tt(-p) var(precommand) ])(
 This is the standard function called to handle completion outside
 any special tt(-)var(context)tt(-).  It is called both to complete the command
 word and also the arguments for a command.  In the second case,
@@ -4674,9 +4674,14 @@ then calls `tt(_normal) tt(-p) tt($service)'.  The effect is that
 `tt(nohup) var(cmd ...)' is treated in the same way as `var(cmd ...)'.
+Reset the list of precommands. Should be used if completing a command
+line which allows internal commands (e.g. builtins and functions)
+regardless of prior precommands (e.g. `tt(zsh) tt(-c)').
 item(tt(-p) var(precommand))(
 Append var(precommand) to the list of precommands. Should be used in
-nearly all cases.
+nearly all cases in which tt(-P) is not applicable.

Messages sorted by: Reverse Date, Date, Thread, Author