From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14690 invoked by alias); 25 Nov 2010 20:27:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15582 Received: (qmail 15783 invoked from network); 25 Nov 2010 20:27:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.216.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=PnZwOpZkQEa6QimQPadZF/pQ88XiU+Sde+9gEqrlmGc=; b=R5+V5oDEQYQg+IVXSHAlq67BASSuY9PJvzM8DADpF1Zy0QDc8LJFYlF/yCYaoW2TNn dQIFldTwy5F3AK6onadztkbgZ5k+SHdZELZrRHkykXjXkPzvbsUFANE5lFa4ytx0o8Bt i44T0ueanVEQpWFf6XCPnMO+OhCC9usg5pDYE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=T1HuB6iWV6OMcW7ANkGU5U8KLmZtKh4iL4LTklDzlxlkxunAEixP/D9acUof3VcAUX iHVwlFK6HpcgB4z7CvgPNTMOvNLjkqjTKCx7aFePF4HOfkMJYTrLyoqhBWvLhStrgxoV 6nP8Bq5kXDMP/pUk4FMFhuYTyU+bX0Y7jlKNo= MIME-Version: 1.0 In-Reply-To: <20101125153250.703e1239@pwslap01u.europe.root.pri> References: <20101125134534.58a6e784@pwslap01u.europe.root.pri> <87lj4h4ieq.fsf@ft.bewatermyfriend.org> <20101125153250.703e1239@pwslap01u.europe.root.pri> From: Julien Nicoulaud Date: Thu, 25 Nov 2010 21:26:47 +0100 Message-ID: Subject: Re: todo.sh completion To: Peter Stephenson Cc: zsh-users Content-Type: multipart/alternative; boundary=0016e64dda7608f0840495e66e37 --0016e64dda7608f0840495e66e37 Content-Type: text/plain; charset=ISO-8859-1 Thank you for the quick answer and fix Peter ! I just built zsh from sources and it works fine now. By the way, for users who would want to build Zsh from sources on Ubuntu(/Debian?), I put the steps here: http://gist.github.com/715855. Regards, Julien 2010/11/25 Peter Stephenson > On Thu, 25 Nov 2010 15:34:56 +0100 > Julien Nicoulaud wrote: > > OK, I checked my zshrc and it turns out this was breaking the > > completion script: > > > > autoload -U zsh-mime-setup && zsh-mime-setup > > Useful research, thank you. > > > I guess this has to do with todo.sh ending with ".sh", since every > > others completion scripts work fine. > > Yes, what should happen is that _zsh-mime-handler finds it shouldn't be > handling todo.sh in this case and despatching to normal completion > instead. There were some (at least three) glitches with this. This > fixes the ones I found. > > - zsh-mime-handler didn't handle the "-l" option for stuff it passed > through without handling. (This should simply end up with $words > being pruned from the front.) > > - _zsh-mime-handler didn't keep empty arguments, which is what > you get when you first try completion on a word. > > - _zsh-mime-handler updated $words but didn't update $CURRENT. Best > guess is to keep $CURRENT at the same offset from the end of $words. > > Index: Completion/Zsh/Function/_zsh-mime-handler > =================================================================== > RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Function/_zsh-mime-handler,v > retrieving revision 1.1 > diff -p -u -r1.1 _zsh-mime-handler > --- Completion/Zsh/Function/_zsh-mime-handler 23 May 2010 19:54:03 -0000 > 1.1 > +++ Completion/Zsh/Function/_zsh-mime-handler 25 Nov 2010 15:29:27 -0000 > @@ -1,9 +1,19 @@ > #compdef zsh-mime-handler > > +# Given that the handler is likely to change the start of the command > +# line, we'll try to maintain the position from the end of the words > +# array. Hence for example CURRENT gets decremented by one if the > +# handler drops off the start. > +integer end_offset=$(( ${#words} - CURRENT )) > + > # zsh-mime-handler -l is supposed to print out the command line > # with quoting to turn it into a full executable line. So > # we need to use shell splitting to turn it into words and > # then unquoting on those words. > -words=(${(Q)${(z)"$(zsh-mime-handler -l ${words[2,-1]})"}}) > +words=(${(z)"$(zsh-mime-handler -l "${(@)words[2,-1]}")"}) > +# Careful unquoting: we need to keep a '' as a separate word. > +words=("${(@Q)words}") > + > +(( CURRENT = ${#words} - end_offset )) > > _normal > Index: Functions/MIME/zsh-mime-handler > =================================================================== > RCS file: /cvsroot/zsh/zsh/Functions/MIME/zsh-mime-handler,v > retrieving revision 1.13 > diff -p -u -r1.13 zsh-mime-handler > --- Functions/MIME/zsh-mime-handler 8 Aug 2010 17:20:55 -0000 > 1.13 > +++ Functions/MIME/zsh-mime-handler 25 Nov 2010 15:29:27 -0000 > @@ -144,7 +144,11 @@ if [[ ! -e $1 ]]; then > fi > done > if [[ -z $nonex_ok ]]; then > - "$@" > + if (( list )); then > + print -r -- "${(q)@}" > + else > + "$@" > + fi > return > fi > fi > > -- > Peter Stephenson Software Engineer > Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited > Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, > UK > > > Member of the CSR plc group of companies. CSR plc registered in England and > Wales, registered number 4187346, registered office Churchill House, > Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom > --0016e64dda7608f0840495e66e37--