zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: "Jun T" <takimoto-j@kba.biglobe.ne.jp>
Cc: zsh-workers@zsh.org
Subject: Re: adding '-p precmd' to _normal
Date: Tue, 29 Aug 2023 19:25:48 -0500	[thread overview]
Message-ID: <eb0b822a-442f-4954-9f2b-65dee67da426@app.fastmail.com> (raw)
In-Reply-To: <9A3B6734-18A2-4F18-9536-C8B5A9C535BA@kba.biglobe.ne.jp>

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


  reply	other threads:[~2023-08-30  0:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29  3:55 Jun T
2023-08-30  0:25 ` dana [this message]
2023-09-01 16:33   ` Jun. T
2023-09-01 16:35   ` Jun. T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb0b822a-442f-4954-9f2b-65dee67da426@app.fastmail.com \
    --to=dana@dana.is \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).