Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Better completion in quotes
- X-seq: zsh-workers 6471
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: Better completion in quotes
- Date: Fri, 4 Jun 1999 16:47:37 +0000
- In-reply-to: <199906040933.LAA03117@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <199906040933.LAA03117@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
On Jun 4, 11:33am, Sven Wischnowsky wrote:
} Subject: Re: Better completion in quotes
}
} 1) We make get_comp_string() always return quoted strings as a whole,
} in the form the lexer returns them. We could then look if the word
} begins with a quote, remember that and use this information to
} offer automatically inserted ending-quotes. But [...]
} This means that we would have to keep information about quotes in
} the word and we have to re-insert them the way we do it for braces
} already. [...]
} So, as a much simpler solution I suggest to make the completion
} code turn strings with quotes into a generic quoted form, using
} backslashes. But it is a bit ugly that
}
} % ls 'foo b<TAB>
}
} would be turned into foo\ bar.
How about this: We turn the string into whatever is the simplest generic
quoted form for the completion code to handle, which I take it is using
backslashes, and remember that the original was quoted. After generating
the list of matches, we rewrite those to "beautified quote form" which
puts the entire word in some kind of outer quote marks, and use that for
the strings that get inserted on the command line.
So starting from
'foo b
the completion system would work on
foo\ b
and then the matches would get rewritten as
'foo bar' 'foo blat'
before insertion. This does mean that if you actually started with
"foo b
you'd still get
'foo bar'
on the command line, but that's not too bad (unless what you planned
to type was "foo bar $ding" -- but you can't have everything).
For "beautified form" I suggest starting with the assumption that single
quotes will work, and if you encounter a String token or a Qtick, simply
close the single quote and start again with double quote. So something
like
"this is a $parameter
becomes
'this is a '"$parameter
which is IMO better than
this\ is\ a\ $parameter
because for one thing that last is wrong when SH_WORD_SPLIT is set.
(Z-Mail uses an algorithm much like this for generating quoted strings
in its supposedly-human-readable saved-options files.)
} 2) I still like the option Bart suggested and would like to make it
} work.
I don't know how what I just said about (1) might mess up what you've
said about (2). As with most of the new completion stuff, I've have
to actually see some of it written down to judge how baroque it is, but
it sounds OK in theory.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author