zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Add API wrapper to ${+_comps[...]}
Date: Mon, 5 Oct 2015 21:51:34 +0000	[thread overview]
Message-ID: <20151005215134.GA1959@tarsus.local2> (raw)
In-Reply-To: <151003174919.ZM31542@torch.brasslantern.com>

Bart Schaefer wrote on Sat, Oct 03, 2015 at 17:49:19 -0700:
> On Sep 30,  6:29pm, Daniel Shahaf wrote:
> } 
> } I wonder if this is useful enough to be added?
> 
> (Why two separate patches both to compsys.yo?)
> 

One logical change per commit.  I might have erred on the side of
splitting too much, but it's easier to unsplit than to split.)

> I don't see any particular reason not to add it, but I also find
> no existence tests of $_comps[...] anywhere in the contributed
> functions or my own local startup files or functions, so it may
> indeed be only minimally useful.
> 

I use them like this in my .zshrc:

    # TODO neither of this actually works, since _gnu_generic wants
    # --foo=[VALUE] and these have a space instead, but they get 90%
    # right and are better than nothing...
    _has_completion() { (( $# == 1 )) || return 2; (( $+_comps[$1] )) }
    _has_completion howdoi || compdef _gnu_generic howdoi
    _has_completion ag || compdef _gnu_generic ag

The idea is to be forward compatible — to only install the _gnu_generic
definition if there isn't an _ag already defined.

> On the other hand there are tests for whether a particular function
> is defined.  If that function is destined to be assigned to _comps[x]
> perhaps it would be better to check for _comps[x] already defined
> instead.

_comps[x] being already defined in what sense?  I can think of three
meanings: (a) hash key exists; (b) hash key exists and the value has
exists as a key in $functions; (c) same, plus the function is not
a "marked-for-autoload" stub.

The patch implements (a).  I think we could leave the patch doing (a)
— that's meaningful, it checks whether 'x <TAB>' has been hooked — and
let callers that care about (b) or (c) implement the extra check (b)
or (c) do it themselves?


  reply	other threads:[~2015-10-05 22:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30 18:29 Daniel Shahaf
2015-10-04  0:49 ` Bart Schaefer
2015-10-05 21:51   ` Daniel Shahaf [this message]
2015-10-05 22:11     ` Bart Schaefer
2015-10-05 22:33       ` Daniel Shahaf
2015-10-05 22:49         ` 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=20151005215134.GA1959@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=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).