zsh-workers
 help / color / mirror / code / Atom feed
* Re: help with _match, globcomplete etc. (with PATCH)
@ 2000-02-14 13:03 Sven Wischnowsky
  2000-02-15 11:09 ` help with _match, globcomplete etc Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2000-02-14 13:03 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Sven Wischnowsky wrote:
> 
> > (there is almost no real reason to use
> > GLOB_COMPLETE nowadays, the _match completer should be better -- and
> > configurable).
> 
> I've just been trying to fathom out what is going on with respect to
> when zsh expands, menu completes expansions and doesn't expand. It all
> is a little bit complicated, especially as the behaviour is controlled
> by a mix of options, styles and the choice of widget that tab is bound
> to.
> 
> Part of the trouble is the way zsh's shell expansion works. If you use
> expand-or-complete, I can't see any way of customising what is and isn't
> expanded - variables, globs and history are, tildes are not. The
> behaviour which I would like is that variables are not expanded unless I
> specifically use a widget bound to '^X$' - like tcsh's expand-variables
> widget.

You can bind expand-word to ^X$. Expansion of parameter substitutions
is a problem, because the completion (shell) code doesn't get the
whole string. We only get the stuff after the $, so we can't really
change such things.

> Would it be possible for the shell expansion used in completion
> to be controlled by a style?

Have you had a look at the _expand completer? And the _expand_word
bindable command? (The latter had a bug -- result of copying the
context stuff -- that's what the first hunk is for).

> The reason I still use glob_complete is that it allows some action when
> completing glob patterns (menu completion though I'd prefer expansion in
> the case of files) while not expanding variables.
> 
> I can however see that the _match completer is better, mainly in that I
> can choose menu completion where only one argument is required and
> expansion where many are required.
> 
> Another thing which I would like to configure with expansion is when
> there is only one match, I'd prefer if the space suffix was not added -
> this is one of the things that makes the variable expansion annoying.
> Ideally, the suffix would be as if normal completion was used so
> directories would get a '/'.

When speaking about variables: see above. When speaking about other
expansions: _match does that and _expand could be made to do it
(adding a loop that appends slashes to directory names).


There were some problems with $compstate[last_prompt] and with
complist not giving up when we didn't go back to the previous prompt.

Bye
 Sven


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


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

* Re: help with _match, globcomplete etc.
  2000-02-14 13:03 help with _match, globcomplete etc. (with PATCH) Sven Wischnowsky
@ 2000-02-15 11:09 ` Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2000-02-15 11:09 UTC (permalink / raw)
  To: Zsh workers

Sven Wischnowsky wrote:

> You can bind expand-word to ^X$.

True though I was mainly after not having variable expansion ever when I
press tab.

Incidentally, I tried creating:
expand-variables() {
  setopt localoptions noglob
  zle expand-word
}
zle -N expand-variables

so that ^X$ wouldn't also glob complete but it comes back with any glob
characters quoted. It seems that expand-word always does this when
noglob is set. Surely this isn't right? In the process, I also noticed
that the quoting can go slightly wrong if there are opened but not
closed braces: $code[ai]/{a,b<Ctrl-X,*> comes back with a quoted '[' in
the middle.

> Have you had a look at the _expand completer? And the _expand_word

I have now but I can't get it to work. I've probably missed something
but this won't work:

zsh -f
autoload -U compinit
compinit
bindkey '^I' complete-word
zstyle -d
zstyle ':completion:*::::' completer _expand
echo *<tab>

I was expecting the last line to glob expand (as if tab was still bound
to expand-or-complete) but all I can get is a beep. I've tried changing
the related styles without any effect.

Thanks

Oliver


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

* Re: help with _match, globcomplete etc. (with PATCH)
@ 2000-02-14 13:07 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 2000-02-14 13:07 UTC (permalink / raw)
  To: zsh-workers


Err, sorry. Here is the patch.

Bye
 Sven

diff -ru ../z.old/Completion/Commands/_expand_word Completion/Commands/_expand_word
--- ../z.old/Completion/Commands/_expand_word	Mon Feb 14 11:54:38 2000
+++ Completion/Commands/_expand_word	Mon Feb 14 13:38:48 2000
@@ -8,7 +8,7 @@
 local curcontext="$curcontext"
 
 if [[ -z "$curcontext" ]]; then
-  curcontext="correct-word:::"
+  curcontext="expand-word:::"
 else
   curcontext="expand-word:${curcontext#*:}"
 fi
diff -ru ../z.old/Src/Zle/compcore.c Src/Zle/compcore.c
--- ../z.old/Src/Zle/compcore.c	Mon Feb 14 11:54:13 2000
+++ Src/Zle/compcore.c	Mon Feb 14 13:56:53 2000
@@ -295,10 +295,10 @@
 	haspattern = 0;
 	complistmax = getiparam("LISTMAX");
 	zsfree(complastprompt);
-	complastprompt = ztrdup((dolastprompt =
-				 ((isset(ALWAYSLASTPROMPT) && zmult == 1) ||
-				  (unset(ALWAYSLASTPROMPT) && zmult != 1))) ?
+	complastprompt = ztrdup(((isset(ALWAYSLASTPROMPT) && zmult == 1) ||
+				 (unset(ALWAYSLASTPROMPT) && zmult != 1)) ?
 				"yes" : "");
+	dolastprompt = 1;
 	zsfree(complist);
 	complist = ztrdup(isset(LISTROWSFIRST) ?
 			  (isset(LISTPACKED) ? "packed rows" : "rows") :
diff -ru ../z.old/Src/Zle/complist.c Src/Zle/complist.c
--- ../z.old/Src/Zle/complist.c	Mon Feb 14 11:54:13 2000
+++ Src/Zle/complist.c	Mon Feb 14 13:58:42 2000
@@ -780,7 +780,7 @@
     if (inselect)
 	clearflag = 0;
 
-    if (asklist()) {
+    if (asklist() || !clearflag) {
 	amatches = oamatches;
 	return (noselect = 1);
     }

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


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

end of thread, other threads:[~2000-02-15 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-14 13:03 help with _match, globcomplete etc. (with PATCH) Sven Wischnowsky
2000-02-15 11:09 ` help with _match, globcomplete etc Oliver Kiddle
2000-02-14 13:07 help with _match, globcomplete etc. (with PATCH) 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).