zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Robert McLay <mclay@tacc.utexas.edu>
Cc: zsh-users@zsh.org
Subject: Re: How does a new software package provide Zsh tab completion scripts to users?
Date: Wed, 24 Apr 2013 10:00:40 +0100	[thread overview]
Message-ID: <20130424100040.535783e7@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAAH8Jevr7tJj1RzzFupRSsUach-cnzCe3kVbd+6zLsA_TD=dLQ@mail.gmail.com>

On Tue, 23 Apr 2013 16:21:59 -0500
Robert McLay <mclay@tacc.utexas.edu> wrote:
> I am the author of a software package and I'd like to provide Zsh tab
> completion scripts for users of my package.   In particular my package is
> Lmod.  It is updated tool to handle environment modules, similar to but not
> exactly the same as the TCL/C based environment modules.  Its main
> advantage is that makes dealing with multiple compilers and MPI stacks much
> easier along with the dependent libraries and applications.
> 
> The problem is that Lmod is typically installed by system administrators
> and not by users directly.   There is not a good way to tell the Zsh users
> that there is tab completion scripts available.    I also do not think that
> I'll get many site to put my zsh scripts in the system location.
> Eventually if/when Lmod takes over the world (;->),  my completion scripts
> will be in the standard zsh installation but until that day,  I'd like to
> know what options are available.

Phil gave a fairly full answer, but here's a simple reply to that
specific question...  Obviously, the key to avoiding clashes is having a
function name that's as likely to be unique as possible.  To make the
function available, it needs to be somewhere in the function path, and
the site function directory is the obvious one because it's designed to
be a standard place to put functions supplied by the local
administrator.  However, it depends how zsh was configured.  Assuming
it's been configured in a fairly standard manner, and the local
/etc/zshenv isn't doing something it shouldn't, your installation
programme could do:

zshfndir="`zsh -fc 'print -l $fpath' | grep site-functions | head -1`"

and use that directory to install your function.  That does the basics;
then you have to worry about more sophisticated things such as
non-standard zsh configurations, whether you're going to be smart
enough to uninstall it, whether you're going to look for your completion
function elsewhere in the path, and whatever paranoia occurs to you.

Putting the file in the right place should be most of the battle
(apart from what you noted next), since the #comdpef lines for
files in the function path are scanned automatically.

> To use Lmod, users must source something that defines a shell function.  In
> this file, I could also prepend a directory to FPATH and do
> 
>     autoload -U compinit
>     compinit -C
> 
> to make the Lmod completion available.  However  this seems like a bad
> idea.  What if a Zsh user is not using tab completion?

I tend to agree; it can take a while to start up as well, and it hooks
in various shell modules providing parameters in the main name space, so
it's not entirely without side effects.  I think at this level the user
has to make a decision, and you have to tell the user that zsh
completion is available if they want to use it.

> Has this been discussed before?   I did some searching but was unable to
> find anything.  I'm not sure what the right phrase would be.

Things like this have come up, though as you say it's kind of hard to
search for.  I don't think there was any grand conclusion beyond "there
are ways of doing this".

If there's a killer argument for one way of doing it, we could certainly
add support in the shell distribution to make it easier --- though
having said that you'd almost certainly want something that worked
with older versions of the shell.

-- 
Peter Stephenson <p.stephenson@samsung.com>       Principal Software
Engineer Tel: +44 (0)1223 434724              Samsung Cambridge
Solution Centre St John's House, St John's Innovation Park,
Cowley Road, Cambridge, CB4 0DS, UK


  parent reply	other threads:[~2013-04-24  9:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 21:21 Robert McLay
2013-04-23 22:15 ` Phil Pennock
2013-04-24  9:00 ` Peter Stephenson [this message]
2013-04-24 14:05   ` Valodim Skywalker

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=20130424100040.535783e7@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=mclay@tacc.utexas.edu \
    --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).