zsh-users
 help / color / mirror / code / Atom feed
* Re: How to get prefix with quotes in completion widgets?
@ 2002-04-16 10:26 Ebourne, Martin
  2002-04-16 16:17 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Ebourne, Martin @ 2002-04-16 10:26 UTC (permalink / raw)
  To: 'zsh-users@sunsite.dk'

Sven Wischnowsky wrote:
> the whole `(...)' is reported to the completion code (from the lexer
> invoked by it) as one string, with quotes inside it, not at the
> beginning, so the completion code doesn't handle them specially.
> 
> So, to answer your question: in *this* case, with the probably not
> intended interpretation of the command line which can't be changed in
> the completion code, there is no way to find the quotes other than by
> looking e.g. at $BUFFER and $CURSOR of $words[CURRENT] (the former two
> are zle-parameters accessible read-only in the completion code).

I am finding that BUFFER/LBUFFER etc also have the quotes removed which
puzzled me. Does this mean these behave differently in a completion
widget to a ZLE one? Else how can the basic editing functions work?
If so, why do they behave differently?

The words array is the only thing that seems to come through intact.

eg:

BUFFER:example insert ( foo, bar ):
LBUFFER:example insert ( foo, b:
words:example insert ( 'foo', 'bar' ):

> But if the stuff you want to complete really looks different from what
> you sent, there might be a way. And anyway I'd like to know in which
> real-world case you need it, we might have other ideas to help you.

Well what I am completing is SQL. For years I've had a system which lets
me enter SQL directly at the command line to run it in whatever database
(currently Sybase & Oracle). Thus I can use the full power of Zsh
editing & history etc for SQL. It's always done basic completion of
tables & columns using a simple decoding of the statement to select the
right columns, even using compctl.

I re-wrote it when the new completion system came out & improved it then
to handle table aliases & joins etc, and currently it works fine for 90%
of stuff. However, I'm in the process of re-writing it to properly LL(k)
parse the SQL statement so that it produces the correct results all the
time. I've half written the parser and it handles most of the usual stuff
now but I'm having problems with the SQL syntax which includes quotes,
and particularly that which includes brackets.

The things I'm particularly interested in are insert statements,
sub-selects, etc. because they don't currently work.
eg.
  sql insert into TABLE ( column_1, column_2 ) values ( 'value1', 2 )

  sql select column_1 from TABLE_1 where column_2 in ( select values_1
      from TABLE_2 where values_2 in ( 1, 3, 5 ) )

The words array seems to have exactly what I want (just the command being
completed without other stuff on the command line, supplied otherwise
untouched), however although CURRENT tells me which word the cursor is
in, I can't get the character position reliably when () and quotes are
present.

Whole () expressions appear as one word in the words array, which doesn't
bother me because I join it together before parsing it, but does make the
cursor location even more important.

On a related note it has occurred to me I may get problems when offering
completions inside brackets, but I've not got to that yet. I'm hoping to
be able to get around it using PREFIX and SUFFIX or one of their
relatives.

Cheers,

Martin.


This message is for the named person's use only. It may contain sensitive and private proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is indicative only, is subject to change and does not constitute an offer to deal at any price quoted. Any reference to the terms of executed transactions should be treated as  preliminary only and subject to our formal written confirmation.



^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: How to get prefix with quotes in completion widgets?
@ 2002-04-18  8:33 Ebourne, Martin
  0 siblings, 0 replies; 6+ messages in thread
From: Ebourne, Martin @ 2002-04-18  8:33 UTC (permalink / raw)
  To: 'zsh-users@sunsite.dk'

Bart Schaefer wrote:
> On Apr 16, 11:26am, Ebourne, Martin wrote:
> }
> } Well what I am completing is SQL.
> Sorry, I don't think you're ever going to get this to work as you want it
> to, and I don't think Sven should expend any effort on making it work.

> The completion system's understanding of quoting is by necessity tightly
> tied to shell quoting syntax.  SQL quoting syntax is not equivalent, and
> the internals of zsh should not be in the business of understanding the
> syntax of other languages.

Of course, the correct solution to this problem (which should have been
obvious anyway) is that these special characters need escaping from the
shell. If you do this then everything works perfectly*. The quote keys etc.
can be programmed to automatically add the escape while entering text into
an sql command and so it is largely transparent anyway - even cutting &
pasting statements in works.

Cheers,

Martin.

(*) So far...

This message is for the named person's use only. It may contain sensitive and private proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is indicative only, is subject to change and does not constitute an offer to deal at any price quoted. Any reference to the terms of executed transactions should be treated as  preliminary only and subject to our formal written confirmation.



^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: How to get prefix with quotes in completion widgets?
@ 2002-04-16 11:13 Ebourne, Martin
  0 siblings, 0 replies; 6+ messages in thread
From: Ebourne, Martin @ 2002-04-16 11:13 UTC (permalink / raw)
  To: 'Norman.Azadian@swisscom.com'; +Cc: 'zsh-users@sunsite.dk'

Norman,

I certainly intend to. I thought about it before but didn't think it
was production quality. Hopefully this time round it will be.

Cheers,

Martin.

-----Original Message-----
From: Norman.Azadian@swisscom.com [mailto:Norman.Azadian@swisscom.com]
Sent: 16 April 2002 11:59
To: martin.ebourne@csfb.com
Subject: AW: How to get prefix with quotes in completion widgets?


I hope that you post your new SQL tools when you get them done.  Probably
a lot of people could use something like that.  Maybe it could even be
included in the distribution.

NHA
---
Norman.Azadian@Swisscom.com	+41 31 342 8129
MC-OP-MIT-SWM-TSW			Swisscom Mobile AG

This message is for the named person's use only. It may contain sensitive and private proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is indicative only, is subject to change and does not constitute an offer to deal at any price quoted. Any reference to the terms of executed transactions should be treated as  preliminary only and subject to our formal written confirmation.



^ permalink raw reply	[flat|nested] 6+ messages in thread
* How to get prefix with quotes in completion widgets?
@ 2002-04-15 13:53 Ebourne, Martin
  2002-04-16  8:11 ` Sven Wischnowsky
  0 siblings, 1 reply; 6+ messages in thread
From: Ebourne, Martin @ 2002-04-15 13:53 UTC (permalink / raw)
  To: 'zsh-users@sunsite.dk'

Hi,

How do I get access to a version of $PREFIX which includes the quotes within a completion widget?

eg. If I have a completion widget for example which prints the following:

	echo "il:$words:"
	echo "ll:$words[1,CURRENT-1]:"
	echo "pr:$PREFIX:"
	echo "ip:$IPREFIX:"
	echo "qi:$QIPREFIX:"
	echo "aq:$compstate[all_quotes]:"

And then I enter the line:

example insert ( 'foo', 'bar' )
                        ^^^
                        123

And complete on the three successive characters shown, I get:

1:
	il:example insert ( 'foo', 'bar' ):
	ll:example insert:
	pr:(\ foo,\ :
	ip::
	qi::
	aq:\:
2:
	il:example insert ( 'foo', 'bar' ):
	ll:example insert:
	pr:(\ foo,\ :
	ip::
	qi::
	aq:\:
3:
	il:example insert ( 'foo', 'bar' ):
	ll:example insert:
	pr:(\ foo,\ b:
	ip::
	qi::
	aq:\:

Here PREFIX has lost the ' which are present in words[CURRENT]. Is there a way to access a version of PREFIX which has not been so altered? Or alternatively, is there a way of getting the character position of the cursor inside words[CURRENT] so that I could use that?

I note especially that although the cursor is in a different position for 1 & 2 (1: outside the quote, 2: inside the quote), there is no difference in the information available at completion time that I can see.

Cheers,

Martin.

This message is for the named person's use only. It may contain sensitive and private proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is indicative only, is subject to change and does not constitute an offer to deal at any price quoted. Any reference to the terms of executed transactions should be treated as  preliminary only and subject to our formal written confirmation.



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

end of thread, other threads:[~2002-04-18  8:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-16 10:26 How to get prefix with quotes in completion widgets? Ebourne, Martin
2002-04-16 16:17 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2002-04-18  8:33 Ebourne, Martin
2002-04-16 11:13 Ebourne, Martin
2002-04-15 13:53 Ebourne, Martin
2002-04-16  8:11 ` Sven Wischnowsky

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