Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: todo.sh completion
- X-seq: zsh-users 15582
- From: Julien Nicoulaud <julien.nicoulaud@xxxxxxxxx>
- To: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- Subject: Re: todo.sh completion
- Date: Thu, 25 Nov 2010 21:26:47 +0100
- Cc: zsh-users <zsh-users@xxxxxxx>
- 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=
- In-reply-to: <20101125153250.703e1239@xxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTimQY5=XdwL4XEO60Z5tcj2J0-Opf4m1=U+xQXvF@xxxxxxxxxxxxxx> <20101125134534.58a6e784@xxxxxxxxxxxxxxxxxxxxxxxxx> <87lj4h4ieq.fsf@xxxxxxxxxxxxxxxxxxxxxx> <AANLkTimYPQnYUYbLhmqTQJ0S+e-evpF6OLy8ziZPAWc-@xxxxxxxxxxxxxx> <20101125153250.703e1239@xxxxxxxxxxxxxxxxxxxxxxxxx>
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 <Peter.Stephenson@xxxxxxx>
> On Thu, 25 Nov 2010 15:34:56 +0100
> Julien Nicoulaud <julien.nicoulaud@xxxxxxxxx> 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 <pws@xxxxxxx> 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
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author