zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Nicholas Riley <njriley@illinois.edu>, zsh-workers@zsh.org
Subject: Re: Lazy loading completions
Date: Sat, 20 Apr 2013 08:26:15 -0700	[thread overview]
Message-ID: <130420082615.ZM10850@torch.brasslantern.com> (raw)
In-Reply-To: <njriley-E4EB8D.19535918042013@news.gmane.org>

On Apr 18,  7:53pm, Nicholas Riley wrote:
} 
} In article 
} <130418163739.ZM8718__6202.1464844749$1366328467$gmane$org@torch.brassla
} ntern.com>,
}  Bart Schaefer <schaefer@brasslantern.com> wrote:
} > In fact, someone should suggest to Doug Hellmann that he stop using
} > compctl commands in virtualenvwrapper.sh ... compctl won't work at all
} > for someone using compinit unless they've configured it to fall through
} > to old-style completions when no modern completion is found.
} 
} Huh, sounds like it's worth a bug report.  I don't have any mention of 
} compctl in my compinit but maybe I got lucky.

I forgot that it automatically kicks in if you have the zsh/compctl
module loaded, which has to autoload in order for the compctl command to
work, so by calling compctl Doug is setting up the necessary conditions.

However, someone could have
    zstyle ':completion:*' use-compctl no
in their startup, which would break things.  I guess actually that's
less likely to be present than compinit is to be missing, so if he's
going to have minimal dependencies he's made the best choice he could.

} > }     source /usr/local/bin/virtualenvwrapper_lazy.sh
} > }     _virtualenvwrapper_load_compctl() {
} > }       compctl + ${=_VIRTUALENVWRAPPER_API}
} > }       virtualenvwrapper_load
} > }       eval ${$(compctl | egrep '^'$_comp_command1' -K')[3]}
} > }     }
} > 
} > ??  Where is the value of $_comp_command1 coming from here?
} 
} It's being set by the completion system, I guess.

Indeed, it's "leaking" down from _normal.  If you try to make this work
you probably want $_comp_commmand here, in some cases $_comp_command1
will be a full path.

If you want to stick with Doug's approach and avoid reliance on compsys
entirely, use

  local command_name
  local -a command_args
  read -c command_name command_args

} Works great, thanks, though I now need to move the above to below where 
} I call compinit; that may break a lot of users of virtualenvwrapper.

There's no evaluable function that's equivalent to "compctl -D" and no
way to call one compctl from another (both of these are among reasons
that compsys was invented in the first place), so you're sort of stuck.
You might be able to fake it with:

  # Note, no leading underscore, so $1 and $2 will be set
  virtualenvwrapper_load_compctl() {
    local command_name
    local -a command_args
    read -c command_name command_args
    compctl + ${=_VIRTUALENVWRAPPER_API}
    virtualenvwrapper_load
    local loaded_compctl=${$(compctl | egrep '^'$command_name' -K')[3]}
    if [[ -n $loaded_compctl ]]
    then eval $loaded_compctl
    else reply=( $1*$2(N) ) # Pretend to do file completion
    fi
  }
  compctl -K virtualenvwrapper_load_compctl ${=_VIRTUALENVWRAPPER_API}


      reply	other threads:[~2013-04-20 15:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <njriley-497078.17231118042013@news.gmane.org>
     [not found] ` <130418163739.ZM8718__6202.1464844749$1366328467$gmane$org@torch.brasslantern.com>
2013-04-19  0:53   ` Nicholas Riley
2013-04-20 15:26     ` Bart Schaefer [this message]

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=130420082615.ZM10850@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=njriley@illinois.edu \
    --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).