zsh-workers
 help / color / mirror / code / Atom feed
* problem with quoting in completion function
@ 2002-04-13 20:16 Borsenkow Andrej
  2002-04-13 20:23 ` Borsenkow Andrej
  2002-04-16  7:59 ` Sven Wischnowsky
  0 siblings, 2 replies; 4+ messages in thread
From: Borsenkow Andrej @ 2002-04-13 20:16 UTC (permalink / raw)
  To: Zsh hackers list


This applies to 4.0.4 as distributed by Mandrake.

I spent some time trying to understand why the following (suggested by
Sven) does not work:

 compset -P "*,"
 all_sources=( ${all_sources:#(${~IPREFIX//,/|})} )

The intention being to remove already present matches (separated by
comma) from list of possible matches.

It turned out, completion internally quotes IPREFIX, and in my case it
had spaces inside (like "Installation CD") so pattern never matched.
I.e. it tried to match

Installation\ CD

against

Installation CD

If this quoting is intentional it does not seem to be described in
documentation. But I still do not like it, it comes unexpected enough.
It makes it impossible to simply  compare strings.

I had to finally do

    compset -P "*,"
    for i in ${(s:,:)IPREFIX}; do
        eval "all_sources=( \${all_sources:#$i} )"
    done

but that is just ugly.

-andrej




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

* Re: problem with quoting in completion function
  2002-04-13 20:16 problem with quoting in completion function Borsenkow Andrej
@ 2002-04-13 20:23 ` Borsenkow Andrej
  2002-04-14  5:03   ` Bart Schaefer
  2002-04-16  7:59 ` Sven Wischnowsky
  1 sibling, 1 reply; 4+ messages in thread
From: Borsenkow Andrej @ 2002-04-13 20:23 UTC (permalink / raw)
  To: Zsh hackers list

В Вск, 14.04.2002, в 00:16, Borsenkow Andrej написал:
> 
> It turned out, completion internally quotes IPREFIX,

Of course it does not quote IPREFIX. It quotes word inserted in command
line that becomes IPREFIX on next try.

And of course it could be quoted by user in different way.

Is there any general way inside completion to "dequote" word from
command line? 

-andrej


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

* Re: problem with quoting in completion function
  2002-04-13 20:23 ` Borsenkow Andrej
@ 2002-04-14  5:03   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2002-04-14  5:03 UTC (permalink / raw)
  To: Borsenkow Andrej, Zsh hackers list

On Apr 14, 12:16am, Borsenkow Andrej wrote:
}
} I spent some time trying to understand why the following (suggested by
} Sven) does not work:
} 
}  compset -P "*,"
}  all_sources=( ${all_sources:#(${~IPREFIX//,/|})} )

On Apr 14, 12:23am, Borsenkow Andrej wrote:
}
} > It turned out, completion internally quotes IPREFIX,
} 
} Of course it does not quote IPREFIX. It quotes word inserted in command
} line that becomes IPREFIX on next try.
} 
} Is there any general way inside completion to "dequote" word from
} command line? 

I was going to compare this to Jeremy Dolan's bug from the other day, but
after a bit of thought I see that it isn't, really -- the quoting of the
IPREFIX theoretically shouldn't matter, because it's ignored, after all.

I wonder if ${(Q)IPREFIX} would do what you need?  What should happen if
the ignored prefix contains e.g. an unmatched single-quote?  Probably you
should examine $compstate[all_quotes] to decide what to do.

Here's a different example of Jeremy's bug:

schaefer<512> ls "foo\<TAB>
Completing corrections
foo\!baz   foo\!bar 
Completing original
foo\\

Note that it thinks the original string has two backslashes, and only
supplies the other two choices as corrections.

In that case, the completion internals really did quote $PREFIX.  It's
already got both backslashes by the time _main_complete starts calling
the completers.  A quick peek at callcompfunc() shows that the prefix
gets passed through multiquote() in all cases except math expressions.
Again it might be possible to do something different depending on the
quoting state, but in this case it'd have to be in the C code.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: problem with quoting in completion function
  2002-04-13 20:16 problem with quoting in completion function Borsenkow Andrej
  2002-04-13 20:23 ` Borsenkow Andrej
@ 2002-04-16  7:59 ` Sven Wischnowsky
  1 sibling, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 2002-04-16  7:59 UTC (permalink / raw)
  To: zsh-workers


Borsenkow Andrej wrote:

> 
> This applies to 4.0.4 as distributed by Mandrake.
> 
> I spent some time trying to understand why the following (suggested by
> Sven) does not work:
> 
>  compset -P "*,"
>  all_sources=( ${all_sources:#(${~IPREFIX//,/|})} )

Bart already suggested using foo=( ${foo:#(${(Q)~IPREFIX//,/|})} ),
which works for me, even inside quotes etc., so nothing new here.

> ...
> 
> If this quoting is intentional it does not seem to be described in
> documentation. But I still do not like it, it comes unexpected enough.
> It makes it impossible to simply  compare strings.

What do you mean by `unexpected'? It has always been this way (module
a couple of bugs, as you know, having been here all the time ;-). And
the string is moved from $PREFIX to $IPREFIX without being changed, so
what could be more expectable?

And maybe you remember, that all this quoting stuff (which I won't
touch again without better reasons) always was a bit of a compromise,
being a very complicated matter -- nowadays even with the possibility
of nested quoting levels and whatnot. And still, it's cleaner now than
it was in previous stable versions.


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-13 20:16 problem with quoting in completion function Borsenkow Andrej
2002-04-13 20:23 ` Borsenkow Andrej
2002-04-14  5:03   ` Bart Schaefer
2002-04-16  7:59 ` 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).