zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: completion with midword tildes
Date: Wed, 12 Jan 2000 10:07:58 +0100 (MET)	[thread overview]
Message-ID: <200001120907.KAA31890@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Clint Adams's message of Tue, 11 Jan 2000 14:14:34 -0500


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


             reply	other threads:[~2000-01-12  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-12  9:07 Sven Wischnowsky [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200001120907.KAA31890@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).