zsh-users
 help / color / mirror / code / Atom feed
* Filename completion and quotes
@ 2010-02-23 17:49 Joke de Buhr
  2010-02-23 19:30 ` Piotr Karbowski
  2010-02-25 16:18 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Joke de Buhr @ 2010-02-23 17:49 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: Text/Plain, Size: 675 bytes --]

Hi,

is there a way to make filename completion use double quotes instead of 
blackshlash quoting?

Now zsh completion works this way

    touch "my very own file"
    vim my<TAB>        =>     vim my\ very\ own\ file
    vim "my<TAB>       =>     vim "my very own file"

But I would like to get the results double quoted if by default (if quotation 
is needed). It should work exactly the other way around:

    touch "my very own file"
    vim my<TAB>        =>     vim "my very own file"
    vim my\ <TAB>      =>     vim my\ very\ own\ file

Is there any way to get zsh to do this. I can't find any hint within the 
completion system's documentation.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Filename completion and quotes
  2010-02-23 17:49 Filename completion and quotes Joke de Buhr
@ 2010-02-23 19:30 ` Piotr Karbowski
  2010-02-25 16:18 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Piotr Karbowski @ 2010-02-23 19:30 UTC (permalink / raw)
  To: Joke de Buhr; +Cc: Zsh Users

+1, I am also interesed.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Filename completion and quotes
  2010-02-23 17:49 Filename completion and quotes Joke de Buhr
  2010-02-23 19:30 ` Piotr Karbowski
@ 2010-02-25 16:18 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2010-02-25 16:18 UTC (permalink / raw)
  To: Zsh Users

On Feb 23,  6:49pm, Joke de Buhr wrote:
}
} is there a way to make filename completion use double quotes instead of 
} blackshlash quoting?

Background:  Completion wants to incrementally append stuff to the ZLE
buffer whenever it can; anytime you have a case where it inserts into
or changes the part of the word that's already there, a programmer must
have done the extra work (in the script that generates the list of the
possible completions) to instruct it to do so, and to "manually" limit
the set of matches to the appropriate replacement (instead of allowing
the internals to automatically filter against the prefix).

So you can't just turn that behavior on and off at will, and hence why
it can do what you want provided that the initial quote is already in
the prefix.

However, what you CAN do is create your own ZLE widget that wraps
around completion and fixes things up.  There is an example of this
called quote-and-complete-word in the set of functions supplied along
with the shell.  What this function actually does is rewrite the line
to put the quote at the beginning of the word, and THEN run normal
completion, and then possibily remove the quote again -- so it does
not do exactly what you've asked for, because the quotes will remain
in cases where it's not strictly necessary.

    autoload -U quote-and-complete-word
    zle -N quote-and-complete-word

and now bind this to a key (I don't recommend going directly for the
tab key on the first try).

This function is meant as an example and isn't documented because it
has oddball edge-case behaviors and doesn't work well with approximate
completion, e.g., when correcting other mistakes on the line.

It also may be tickling some bugs in zsh ... hey, PWS:

If I invoke quote-and-complete-word via execute-named-command on an
empty buffer, I get this:

schaefer<525> 11: ../../../zsh-4.0/Src/Zle/zle_tricky.c:661: BUG: 0 <= wb <=
zlemetacs <= we is not true!

The same error does not occur when invoking it via a direct binding.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-25 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-23 17:49 Filename completion and quotes Joke de Buhr
2010-02-23 19:30 ` Piotr Karbowski
2010-02-25 16:18 ` Bart Schaefer

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).