zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Setup git-stash completion for a function: $line is wrong
Date: Thu, 16 Mar 2017 14:02:24 -0700	[thread overview]
Message-ID: <170316140224.ZM17994@torch.brasslantern.com> (raw)
In-Reply-To: <6e020492-e5f4-eca7-c4d4-07dc4257a5ce@thequod.de>

On Mar 15, 12:59am, Daniel Hahler wrote:
}
} It did not work initially, but luckily it seems to be just an off-by-one
} error when incrementing CURRENT.

Indeed, sorry about that.  words[1] is being replaced by $@ rather than
appended-to, so you have to take one away from the increment.

} > There's already (compdef cmd=service) e.g.
} > 
} >     compdef gsta=git
} 
} Yes, I am aware of that, and what I mean is more or less something in this
} regard, e.g. by making it handle command+arguments.

For other readers of this thread:  Any input here on whether this is
actually a common use case?

} maybe a list could be used:
} 
}     compdef gsta=(git stash)

That would require that 'compdef' be made a keyword, otherwise that's a
syntax error.  I don't think we're likely to embed compsys that deeply
into the shell syntax.

We could maybe do what some other compsys functions do:

compdef gsta='(git stash)'

Not sure what that would require of the lower-level code where the value
of the compdef is evaluated.

Probably the right way to approach this is to have a completer "_wrapper"
which looks up the replacement command via zstyle, fixes up $words etc.,
and then calls _complete.  The potentially tricky part is preventing the
replacement from changing the context, i.e. adding syntactic tokens
like globbing or pipes, or at least failing gracefully in that event.

} I am using it with the following to automatically update a ctags tags file

This sounds more like a job for a git hook ... except there isn't one
for "stash".



  reply	other threads:[~2017-03-16 21:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-12 16:37 Daniel Hahler
2017-03-12 22:27 ` Bart Schaefer
2017-03-14 23:59   ` Daniel Hahler
2017-03-16 21:02     ` Bart Schaefer [this message]
2017-03-16 23:54       ` Daniel Shahaf
2017-03-21  4:42         ` 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=170316140224.ZM17994@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).