zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>,
	zsh-workers@math.gatech.edu
Subject: Re: cdablevars and cd completion in 3.1.5
Date: Tue, 1 Dec 1998 10:09:55 -0800	[thread overview]
Message-ID: <981201100955.ZM5808@candle.brasslantern.com> (raw)
In-Reply-To: <199812011252.NAA10850@beta.informatik.hu-berlin.de>

On Dec 1,  1:52pm, Sven Wischnowsky wrote:
} Subject: Re: cdablevars and cd completion in 3.1.5
}
} Bart Schaefer wrote:
} > ...
} >     compctl -x 'S[/][~][./][../]' -/ \
} > 	    - 'n[-1,/], s[]' -K cdmatch -S '/' -q \
} > 	    -- cd pushd
} > ...
} > zsh% cd HE/zshfun
} >          ^
} > 	 With the cursor here, pressing tab does NOT call cdmatch!
} > 	 Why not?
} 
} The reason was that the `n[-1,/]' makes the part before the `/' be
} ignored so that the cursor isn't in a part that is considered for
} completion.

If the current word can't be completed because of the position of the
cursor, then shouldn't the position of the cursor also determine whether
the pattern matches the word in the first place?  Why would you ever
WANT a pattern to match and then NOT call the corresponding completion?

}     compctl -x 'S[/][~][./][../]' -/ \
} 	    - 'n[-1,/] s[], s[]' -K cdmatch -S '/' -q \
} 	    -- cd pushd
} 
} The interesting bit is the `s[]' before the comma. It makes the
} completion code use the prefix specified by `s[]' be ignored instead
} of the prefix specified by `n[-1,/]'.

Hm; I'd have expected them to be cumulative (though possibly overlapping),
but I can see where that'd be a mess particularly for something strange
like
	compctl -x 'n[1,/] n[-1,/]' ...

However, that doesn't work, because it stops ignoring the stuff up to
the last /, so now all the completions cdmatch puts in $reply have to
include that prefix when completing anything *after* that slash.  I.e.

zsh% cd HOME/z<TAB>

feeps because reply=(zshfun) and the code wants reply=(HOME/zshfun).

Your alternate compctl has the same problem.  It's probably possible to
fix my cdmatch to handle that, but it isn't straightforward, as it can't
simply use tilde-expansion and then lop off the path tail; instead it
has to convert the path head back into the corresponding named dir.  I
suppose a trick with print -P could be used, but that's another $().

(The other possibility would be to use the -U option and thus expand the
variable name into the full path it represents.)

} So with this the function will
} be called and we only have to change it accordingly, i.e.:
} 
}     reply=( ${${${(M)$(set):#${pref:-[A-Za-z]}*${2:h}*\=/*}:#*(PWD|:)*}%\=/*}${(M)2%%/*} )
} 
} (adding the last `${(M)...}').

That can complete to impossible paths because it doesn't check whether
the stuff in $2 really is a subdirectory of the named dir in $pref.  To
check correctly again requires tilde-expanding and then converting back
into a named dir.

So I think, all things considered, I'd give up completeinword on cdable
variables and take my original function and compctl.

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


  reply	other threads:[~1998-12-01 18:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-01 12:52 Sven Wischnowsky
1998-12-01 18:09 ` Bart Schaefer [this message]
1998-12-03 10:17 Sven Wischnowsky
1998-12-07 11:58 Sven Wischnowsky

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=981201100955.ZM5808@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).