From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14841 invoked by alias); 12 Aug 2010 16:58:59 -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: 15277 Received: (qmail 27250 invoked from network); 12 Aug 2010 16:58:57 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <100812085733.ZM20113@torch.brasslantern.com> Date: Thu, 12 Aug 2010 08:57:33 -0700 In-reply-to: <20100812103126.64aa5bce@csr.com> Comments: In reply to Peter Stephenson "Re: Completion and double quotes" (Aug 12, 10:31am) References: <201008112130.10895.joke@seiken.de> <20100812103126.64aa5bce@csr.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-users" Subject: Re: Completion and double quotes MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 12, 10:31am, Peter Stephenson wrote: } } The code for handling quoting in completion is utterly impenetrable. To be both more and less specific, the code for handling just about anything in _path_files is utterly impenetrable. } It's actually at it's worst when you're in a nested expression, for } example inside: } } su -c 'ls /path/to/"file with" } } which is quite liable to crash the shell (I didn't dare try). That may be a slight exaggeration: schaefer<501> su -c 'ls /home/schaefer/Desktop/Camera\ Dump\ 2010-08-07/ Completing corrections Camera\ Dump\ 2010-08-07/ Camera\ Dump\ 2010-01-24/ Camera\ Dump\ 2010-03-19/ Camera\ Dump\ 2009-12-31/ Camera\ Dump\ 2010-02-06/ Camera\ Dump\ 2007-08-13/ Camera\ Dump\ 2010-01-30/ Completing original ls /home/schaefer/Desktop/"Camera Dump" } Even so, it's bad enough even in the "simple" case that I don't think } it's ever going to be able to second guess intentions to the sort of } level you want. The guessing problem could be solved just by keeping the original quoting, but of course it's not that simple -- in order to decide what to match, the quoting has to be removed/canonicalized internally, and in the most general case it's then difficult if not impossible to figure out what part of the completed string corresponds to the quoted portion of the original string. Remember, zsh completion can insert characters almost anywhere (or even replace the entire original string with something that doesn't resemble it at all), not merely append at the end. With regard to putting the quote before the tilde ... that's not going to work, because unless zsh expanded the tilde before completing, the resulting word will still have a quoted tilde in it, which in turn will not be expanded when the command is eventually executed. Not often what you want, I suspect. You may be able to create a wrapper widget along the lines of Functions/Zle/quote-and-complete-word that restores a more palatable quoting after completion has finished.