zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 4/4] _normal: Add -P to reset precommands
@ 2019-04-02  3:13 Matthew Martin
  2019-04-02 17:45 ` dana
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Martin @ 2019-04-02  3:13 UTC (permalink / raw)
  To: zsh-workers

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
cargo-culted.

---
 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)
 )
 findex(_normal)
-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 ...)'.
 
 startitem()
+item(tt(-P))(
+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.
 )
 enditem()
 
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-03  2:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02  3:13 [PATCH 4/4] _normal: Add -P to reset precommands Matthew Martin
2019-04-02 17:45 ` dana
2019-04-02 20:27   ` Daniel Shahaf
2019-04-03  2:01     ` Matthew Martin

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