zsh-workers
 help / color / mirror / code / Atom feed
* Re: completion with midword tildes
@ 2000-01-12  9:07 Sven Wischnowsky
  2000-01-12 16:49 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 2000-01-12  9:07 UTC (permalink / raw)
  To: zsh-workers


Clint Adams wrote:

> In dev-14 and the latest jaist CVS snapshot, at least, complete
> will not complete a word containing a tilde if the tilde is
> specified.  It will, however, do so if a backslash is specified.
> This happens whether or not EXTENDED_GLOB is set. That is to say
> 
> % mkdir a~b
> % cd a<TAB>   --> cd a\~b
> % cd a~<TAB>  --> cd a~<BEEP>
> % cd a\<TAB>  --> cd a\~b
> % cd a\~<TAB> --> cd a\~b
> 
> Some older behavior used to allow
> 
> % cd a~<TAB>  --> cd a\~b
> 
> Is the old behavior undesirable?  Particularly when EXTENDED_GLOB
> is unset, I would expect a~ to complete.

The old behaviour looks desirable, but in terms of cleanness it
isn't. Remember all the problems we had with quoting? Most of them had 
to do with the fact that the string from the line had its backslashes
removed (sometimes due to tokenizing followed by a remnulargs(),
sometimes due to rembslash()), and re-inserted by calling something
like quotename(). Most or all of this is removed now, making the
quoting rules quite simple -- the string on the line is not changed
and has to look like the stuff that would be inserted for the
match(es).

*But*: the quoting function we use has this nasty habit of quoting
some characters even if it isn't really necessary.

A pure user-code solution would be to use a match spec such as 'm:=\\'
(or several of these, making the backslash only optional before some
special characters) in ones $compmatchers, but maybe we should make
the completion code do that by default. What I want to say is that
nowadays I would implement it in exactly this way -- modify the
matching function to ignore backslashes. That's what the patch below
tries to attempt -- it works but there may be some complicated
interactions with complex match specs, I'll have to test that. Anyway, 
if we agree that this auto-backslash behaviour is a godd thing, the
patch should be used.

Bye
 Sven

diff -ru ../z.old/Src/Zle/compmatch.c Src/Zle/compmatch.c
--- ../z.old/Src/Zle/compmatch.c	Wed Jan 12 09:30:37 2000
+++ Src/Zle/compmatch.c	Wed Jan 12 10:03:52 2000
@@ -436,7 +436,7 @@
 	  int sfx, int test, int part)
 {
     int ll = strlen(l), lw = strlen(w), oll = ll, olw = lw;
-    int il = 0, iw = 0, t, ind, add, he = 0, bpc, obc = bc;
+    int il = 0, iw = 0, t, ind, add, he = 0, bpc, obc = bc, bslash;
     VARARR(unsigned char, ea, ll + 1);
     char *ow;
     Cmlist ms;
@@ -736,12 +736,15 @@
 	if (mp)
 	    continue;
 
-	if (l[ind] == w[ind]) {
+	bslash = 0;
+	if (l[ind] == w[ind] ||
+	    (bslash = (lw > 1 && w[ind] == '\\' &&
+		       (ind ? (w[0] == l[0]) : (w[1] == l[0]))))) {
 	    /* No matcher could be used, but the strings have the same
 	     * character here, skip over it. */
-	    l += add; w += add;
-	    il++; iw++;
-	    ll--; lw--;
+	    l += add; w += (bslash ? (add + add ) : add);
+	    il++; iw += 1 + bslash;
+	    ll--; lw -= 1 + bslash;
 	    bc++;
 	    if (!test)
 		while (bp && bc >= (useqbr ? bp->qpos : bp->pos)) {

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: completion with midword tildes
  2000-01-12  9:07 completion with midword tildes Sven Wischnowsky
@ 2000-01-12 16:49 ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2000-01-12 16:49 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On Jan 12, 10:07am, Sven Wischnowsky wrote:
} Subject: Re: completion with midword tildes
}
} A pure user-code solution would be to use a match spec such as 'm:=\\'
} (or several of these, making the backslash only optional before some
} special characters) in ones $compmatchers, but maybe we should make
} the completion code do that by default. What I want to say is that
} nowadays I would implement it in exactly this way -- modify the
} matching function to ignore backslashes. That's what the patch below
} tries to attempt -- it works but there may be some complicated
} interactions with complex match specs, I'll have to test that.

What happens if the file name (or whatever else is being completed)
actually *contains* a backslash?  I.e. the backslash isn't just there
to quote some other special character.

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


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

* Re: completion with midword tildes
@ 2000-01-13  8:24 Sven Wischnowsky
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 2000-01-13  8:24 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Jan 12, 10:07am, Sven Wischnowsky wrote:
> } Subject: Re: completion with midword tildes
> }
> } A pure user-code solution would be to use a match spec such as 'm:=\\'
> } (or several of these, making the backslash only optional before some
> } special characters) in ones $compmatchers, but maybe we should make
> } the completion code do that by default. What I want to say is that
> } nowadays I would implement it in exactly this way -- modify the
> } matching function to ignore backslashes. That's what the patch below
> } tries to attempt -- it works but there may be some complicated
> } interactions with complex match specs, I'll have to test that.
> 
> What happens if the file name (or whatever else is being completed)
> actually *contains* a backslash?  I.e. the backslash isn't just there
> to quote some other special character.

I guess you tried it already: here one needs two backslashes on the
line to complete. Hm. The only thing I can say to defend this
behaviour is that the backslash (of course) always shows slightly
different behaviour (comparing `a\b', `a\\b' and `a~b', `a\~b').

Should we change that? (Consider me saying this very timidly.)

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* completion with midword tildes
@ 2000-01-11 19:14 Clint Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Clint Adams @ 2000-01-11 19:14 UTC (permalink / raw)
  To: zsh-workers

In dev-14 and the latest jaist CVS snapshot, at least, complete
will not complete a word containing a tilde if the tilde is
specified.  It will, however, do so if a backslash is specified.
This happens whether or not EXTENDED_GLOB is set. That is to say

% mkdir a~b
% cd a<TAB>   --> cd a\~b
% cd a~<TAB>  --> cd a~<BEEP>
% cd a\<TAB>  --> cd a\~b
% cd a\~<TAB> --> cd a\~b

Some older behavior used to allow

% cd a~<TAB>  --> cd a\~b

Is the old behavior undesirable?  Particularly when EXTENDED_GLOB
is unset, I would expect a~ to complete.


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

end of thread, other threads:[~2000-01-13  8:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-12  9:07 completion with midword tildes Sven Wischnowsky
2000-01-12 16:49 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-01-13  8:24 Sven Wischnowsky
2000-01-11 19:14 Clint Adams

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