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

Re: adding '-p precmd' to _normal



On Mon 28 Aug 2023, at 22:55, Jun T wrote:
> If anyone knows any reason that this two-step method is
> better than '_normal -p precmd' then please let me know.

I don't think there's a reason to break them out like this any more,
usually, thanks to workers/44200 and workers/44201. Matthew updated
several existing users of _normal so that they wouldn't have to, but
must have missed the ones you mentioned, or wasn't confident about
changing them for some reason

Related: It's not really explained *why* using _normal with -p has this
benefit. Attached patch addresses that

PS: Currently it doesn't matter that much because we usually don't care
about exactly which commands are in the pre-commands list, just whether
there are any in there, but technically it would be more robust to use
`-p $service` than to hard-code it like `-p env`

dana


diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 33baeab49..5035097bb 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -4389,8 +4389,10 @@ the functions for the fields if they are called.
 findex(_command_names)
 item(tt(_command_names) [ tt(-e) | tt(-) ])(
 This function completes words that are valid at command position: names of
-aliases, builtins, hashed commands, functions, and so on.  With the tt(-e)
-flag, only hashed commands are completed.  The tt(-) flag is ignored.
+aliases, builtins, hashed commands, functions, and so on.  If the tt(-e)
+flag is given, or if the list of precommands contains a non-builtin command
+(e.g. because tt(_normal -p) has been used previously), only hashed commands
+are completed.  The tt(-) flag is ignored.
 )
 findex(_comp_locale)
 item(tt(_comp_locale))(
@@ -4776,7 +4778,11 @@ functions) regardless of prior precommands (e.g. `tt(zsh -c)').
 )
 item(tt(-p) var(precommand))(
 Append var(precommand) to the list of precommands. This option should be
-used in nearly all cases in which tt(-P) is not applicable.
+used in nearly all cases in which tt(-P) is not applicable. An advantage
+of using this option is that it can automatically signal to
+tt(_command_names) that subsequent completion should be limited to hashed
+commands, which is usually the desired behaviour following commands like
+tt(chroot) and tt(nohup).
 )
 enditem()
 




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