zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: autoload path completion with expansions
Date: Sun, 5 Sep 2021 11:54:37 -0700	[thread overview]
Message-ID: <CAH+w=7ZpZ1FUen4PinnO8RvqmwrPp0U+Kb_NJZ9pxdaDP1P3vw@mail.gmail.com> (raw)

Starting from zsh -f + compinit + zstyle '*' format %d (so, no completer style)

% autoload $PWD/<TAB>
`vars' or `shell function'

This surprised me, because

% ls $PWD/<TAB>
file
(list of files in the current directory)

Turns out this is because _typeset (which handles autoload) only calls
_files when the word on the command line already begins with "/" or
"~".

I debated also adding \` to the pattern.  Thoughts?

diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index d3304bed0..26eab0b21 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -101,9 +101,9 @@ if [[ "$state" = vars_eq ]]; then
     elif (( $+opt_args[-w] )); then
       _wanted files expl 'zwc file' _files -g '*.zwc(-.)' && ret=0
     elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
-      if [[ $PREFIX[1] = [/~] ]]; then
+      if [[ $PREFIX[1] = [$/~] ]] && _files; then
        # Autoload by absolute path
-       _files && ret=0
+       ret=0
       else
          args=(${^fpath}/*(-.:t))
          # Filter out functions already loaded or marked for autoload.


             reply	other threads:[~2021-09-05 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05 18:54 Bart Schaefer [this message]
2021-09-07 23:04 ` Bart Schaefer

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='CAH+w=7ZpZ1FUen4PinnO8RvqmwrPp0U+Kb_NJZ9pxdaDP1P3vw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --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).