From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20743 invoked by alias); 14 Sep 2016 19:58:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39330 Received: (qmail 2786 invoked from network); 14 Sep 2016 19:58:48 -0000 X-Qmail-Scanner-Diagnostics: from nm25-vm6.bullet.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.82.97.39):SA:0(0.0/5.0):. Processed in 0.531901 secs); 14 Sep 2016 19:58:48 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.97.39 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1473882755; bh=umwSGho+/9fD7XTub59BHyGO1P0UjTfCz2F4kxzAzlw=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=Uq/WKk9K7S4C/FCiJ/0SZg4eprrOFgbqwpl/0wMhSKpwoxgrdegiBR00/fRK6hzYQ3CPH7CzfMIaWlfbRkRS77Wykk3wlZPNNAu+QHu2B5md9DoY0A3oV2XdB4TIIugCFMQjQEJrYL3S4S/n/xspxO1omBRgUsuosfNTXBwnvJhsjr7hJ0Nc0rDlnbvm67WIIj4mxH042LrMk1albpqS/XIO+OmiO6BnLT6oTZWg/ygRGF40lq4WvraU9J/IK64z94AWl9A3yXDejGQlX1XigzlYRBs2moVDFstEMuuyCo9yvbsTWKsxTAwHGd/KiCnGDs8sN/7XC5DL0gEvsBpt4g== X-Yahoo-Newman-Id: 858500.7135.bm@smtp145.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 5gE5.dIVM1m0ibASOglgysK4TPaDG497YEw_G0djRfPPwkc f0FmZ0PjxpUSIb4HDivGrEdoCxBOU3nG2axPv8ypjNY.KEtTEgMSSPYxUd2m CmzFohhKFkRaUboXrulnCrQSG1lJg4_K_Jl2PSSNVIH0c1IE8uET15c0odVv 48rmu0p053NFbJ7HVmtg_20FCMy5Xm_9N_eUNeB6RXffaOTKFo_PweeNHtH1 XG.KiBFL3XiYbZrGy9YNbYG0TBqrsWRrobPnhxMA5n_co9MAvOSQr6.sjnn7 5qJInv6iaxVYw3jFhNuuPj66DF69v7F8fAPSiB9mowwat_2w0ugEJxaIW39k dMnMPXWFPpa3UHTv606FBBJGmWuRBY1fuPb0rwztb.Rw7gXfcwpbYgJob_rp aMnXP1ViB7PjyJzWm3rJN6HR5NC3TnCMmD2tKp67fHNRulgg4yr7ml9qnSrZ ml5Y9uRgVi8ddI31Tc1EmKh1TUm9NJ6y6T6lgfx.PH.KYonapQml07K0oHo3 DqVSv2tJSxbaOTgVPyMv4FdZtczRgomUWDpbZYN4pU5o- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <160914075946.ZM28998@torch.brasslantern.com> From: Oliver Kiddle References: <20160911073031.GA19137@fujitsu.shahaf.local2> <160911191422.ZM21970@torch.brasslantern.com> <20160912230632.GA29577@fujitsu.shahaf.local2> <160912232853.ZM27002@torch.brasslantern.com> <20160914032254.GA32528@fujitsu.shahaf.local2> <160913222029.ZM13117@torch.brasslantern.com> <20160914061252.GA22452@fujitsu.shahaf.local2> <160914075946.ZM28998@torch.brasslantern.com> To: zsh-workers@zsh.org Subject: Re: compset -q oddities MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <67317.1473882754.1@hydra.kiddle.eu> Date: Wed, 14 Sep 2016 21:52:35 +0200 Message-ID: <67318.1473882755@hydra.kiddle.eu> Bart wrote: > } That's a bit tricky. I think it should append an escaped space, e.g., > } "sh -c touc" should append . > > No, that's *exactly* the kind of DWIM-ing that we abandoned. If the user > wants the space quoted, then he should start with "sh -c 'touc". For this specific case, I don't entirely agree because in theory the mechanics are in place for that to work. compset -q appears to disable the default suffix that completions have: _foo() { compset -q compadd one two three } foo "on completes one without a space suffix. I'm not sure why. Any ideas? The other problem in this case is that suffixes are not quoted in general. You're supposed to do that manually with compquote but we only ever bother to do that in generic helpers. So the following does work as Daniel wished: _foo() { suf=' ' compquote suf compadd -S $suf one two three } sh -c "foo on You might even use ${compstate[quote]:#\\}$suf as the suffix to close any inner quoting. -P prefixes and -S suffixes are added unquoted: in contrast to -p/-s. This was probably done so that it can include the closing quote. Either that or because that's how compctl originally did things long before completion was complex enough to worry much about quotes. Adding calls to compquote in every function that needs a suffix is not a good idea. With a code refactoring, perhaps the suffix could be quoted automatically but we'd need an option that makes it easier to indicate that quoting levels should be closed (accumulating them as completion functions call each other). And I'm not sure about prefixes. In the past, I've looked at the compset code when noticing other odd cases like those Daniel has mentioned. There's loads of edge cases that are handled with bits of code that all dig into the parser code. And the parser is not my favourite bit of zsh code either. Trying to fix them just involves adding more hacks that are only making it worse. A proper solution would need more flexible values in compqstack. One other thing I notice in the code for compset -q is that it is a completely different function internally from that which does the initial word split when completion starts. I don't entirely understand why because logically it ought to be possible to reuse the same code. It'd be nice if vared could be used without the initial parse: variable values aren't necessarily shell syntax. Oliver