zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: expansion
@ 2000-06-09  7:32 Sven Wischnowsky
  2000-06-09 10:45 ` Oliver Kiddle
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-06-09  7:32 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Peter Stephenson wrote:
> > 
> > > Glob expansion including tilde expansion was the final annoyance that
> > > made me stop using _expand altogether.
> > 
> > You might want to try again with the latest keep-prefix style (which has a
> > sensible default) to see if it's any better, and what if anything remains
> > to do.
> 
> That's certainly better but it has reminded me why I stopped using
> _expand:
> 
> cd ~+<tab> expands, even with keep-prefix. I use the autopushd option
> and really like being able to do cd ~+<tab and using the list of
> directories to return to a previous directory.
> 
> Similar to this is the following:
> hash -d abc=whatever
> hash -d abcd=whatever
> 
> I'm always used to completion not doing anything where there is more
> than one match so I don't like it when ~abc<tab> expands ~abc.

Hm, do you want it to ever expand tildes at all? We could add more
fine-grained control over the kinds of substitutions tried.

> One thing which I like about the way expand-or-complete works is that
> for example, $HOME<tab> will expand but $HOME/<tab> doesn't. In general,
> I prefer variables and tildes not to be expanded but in some cases I
> specifically want them expanded and if I press tab immediately after
> something, I've probably conciously thought to do the expansion.

Yes, that was always the problem with expansion -- guessing if the
user wants it or not. Hm, maybe some kind of expand-ambiguous style.

Does anyone have other ideas for conditions when to expand or not?
Let's collect them.

Bye
 Sven


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


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

* Re: PATCH: expansion
  2000-06-09  7:32 PATCH: expansion Sven Wischnowsky
@ 2000-06-09 10:45 ` Oliver Kiddle
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Kiddle @ 2000-06-09 10:45 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> 
> Hm, do you want it to ever expand tildes at all? 

Not particularly. I wouldn't mind if it only did straight after the
tilde reference like expand-or-complete does for parameters but it would
have to be intelligent enough to see if it could be a partial reference
to a longer named directory. Whatever the completion does, it would also
be useful to be able to bind ^X~ to expand tildes.

> We could add more fine-grained control over the kinds of substitutions tried.

I think we should add fine-grained control though I fear it isn't easy
to do. It's a pity that the nearest I can get the the behaviour I want
is not by using _expand.

> Does anyone have other ideas for conditions when to expand or not?
> Let's collect them.

The only thing I can think of at the moment is the same thing I was
saying about tilde expansions with parameter substitutions: if I had a
$MAIL and $MAILPATH parameter, $MAIL<tab> should do completion and not
expansion. To a certain extent, this is what you might get if you had
the _expand completer after _complete if it wasn't for the fact that
completion would generally not give expansion a chance.

Oliver


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

* Re: PATCH: expansion
@ 2000-06-14  6:21 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-06-14  6:21 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Jun 13,  1:24pm, Sven Wischnowsky wrote:
> } Subject: PATCH: expansion
> }
> }   Note that I've used the same default value in _expand as it has
> }   elsewhere (`false'), which means that without further configuring,
> }   this now behaves differently. Should we make it default to `true' in 
> }   _expand?
> 
> If it now behaves by default more like the way the old expand-or-complete
> behaved, then I think we should leave it.

It is more like e-o-c. So this makes me wonder if the default for the
suffix style should be changed (currently its default is like the old
_expand, changing it would make it like e-o-c).

> Either that or the default
> should be different depending on whether _expand was used as a completer
> or called from _expand_word ... hrmm ...

I'm never too happy with adding differences between a completer and
the bindable command for it...

Bye
 Sven


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


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

* Re: PATCH: expansion
  2000-06-13 11:24 Sven Wischnowsky
@ 2000-06-13 16:41 ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-06-13 16:41 UTC (permalink / raw)
  To: zsh-workers

On Jun 13,  1:24pm, Sven Wischnowsky wrote:
} Subject: PATCH: expansion
}
}   Note that I've used the same default value in _expand as it has
}   elsewhere (`false'), which means that without further configuring,
}   this now behaves differently. Should we make it default to `true' in 
}   _expand?

If it now behaves by default more like the way the old expand-or-complete
behaved, then I think we should leave it.  Either that or the default
should be different depending on whether _expand was used as a completer
or called from _expand_word ... hrmm ...

-- 
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] 8+ messages in thread

* PATCH: expansion
@ 2000-06-13 11:24 Sven Wischnowsky
  2000-06-13 16:41 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-06-13 11:24 UTC (permalink / raw)
  To: zsh-workers


[ sunsite.auc.dk seems to be down, at least I don't get my mails
  back... I'll just keep on sending patches ;-]

We were discussing these... This adds the style `suffix' and makes
`accept-exact' be used by _expand:

- With `suffix', expansion is not done if there is anything after a
  `~foo' or `$foo'. I.e. it will not expand `~foo/<TAB>', but it will
  expand `~foo'.
- With `accept-exact' set it will expand `$MAIL', with it unset, it
  will not expand it (if there are other parameters starting with
  `MAIL').
  We were using rexexact in the old expansion code, so I thought we
  should just use `accept-exact' which is the style equivalent of
  recexact.
  Note that I've used the same default value in _expand as it has
  elsewhere (`false'), which means that without further configuring,
  this now behaves differently. Should we make it default to `true' in 
  _expand?

Ok. Is this good enough? Oliver?

Bye
 Sven

Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.15
diff -u -r1.15 _expand
--- Completion/Core/_expand	2000/06/08 08:39:51	1.15
+++ Completion/Core/_expand	2000/06/13 11:22:46
@@ -18,12 +18,6 @@
       force="$force$opt"
     done
 
-if [[ "$funcstack[2]" = _prefix ]]; then
-  word="$IPREFIX$PREFIX$SUFFIX"
-else
-  word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
-fi
-
 # First, see if we should insert all *completions*.
 
 if [[ "$force" = *c* ]] ||
@@ -33,8 +27,25 @@
   [[ "$curcontext" = expand-word:* ]] && _complete && return 0
   return 1
 fi
+
+if [[ "$funcstack[2]" = _prefix ]]; then
+  word="$IPREFIX$PREFIX$SUFFIX"
+else
+  word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
+fi
+
+zstyle -t ":completion:${curcontext}:" suffix &&
+  [[ "$word" = (\~*/*|\$[a-zA-Z0-9_]##[^a-zA-Z0-9_]*|\$\{*\}?*) ]] &&
+  return 1
+
+zstyle -t ":completion:${curcontext}:" accept-exact ||
+  { [[ "$word" = \~(|[-+]) ||
+       ( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) ||
+       ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -ne 1 ) ||
+       ( "$word" = \$[a-zA-Z0-9_]## && 
+         ${#parameters[(I)${word[2,-1]}*]} -ne 1 ) ]] && return 1 }
 
-# In exp we will collect the expansion.
+# In exp we will collect the expansions.
 
 exp=("$word")
 
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.60
diff -u -r1.60 compsys.yo
--- Doc/Zsh/compsys.yo	2000/06/08 08:39:51	1.60
+++ Doc/Zsh/compsys.yo	2000/06/13 11:22:48
@@ -779,6 +779,12 @@
 matches.  If it is set to `true' for at least one match which is the
 same as the string on the line, this match will immediately be
 accepted.
+
+Note that this is also used by the tt(_expand) completer to decide if
+words beginning with a tilde or parameter expansion should be
+expanded. This means that if, for example, there are parameters
+tt(foo) and tt(foobar), the string `tt($foo)' will only be expanded if 
+tt(accept-exact) is set to `true'.
 )
 kindex(add-space, completion style)
 item(tt(add-space))(
@@ -1785,6 +1791,14 @@
 
 substitution will be performed only if given an explicit numeric
 argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'.
+)
+kindex(suffix, completion style)
+item(tt(suffix))(
+This is used by the tt(_expand) completer if the word starts with a
+tilde or parameter expansion. If it is set to `true', the word will
+only be expanded if it doesn't have a suffix, i.e. if it is something
+like `tt(~foo)' or `tt($foo)', but not if it is `tt(~foo/)' or
+`tt($foo/bar)'. The default for this style is `false'.
 )
 kindex(tag-order, completion style)
 item(tt(tag-order))(

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


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

* Re: PATCH: expansion
       [not found] <0FVU001OT0DZC6@la-la.cambridgesiliconradio.com>
@ 2000-06-08 16:50 ` Oliver Kiddle
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Kiddle @ 2000-06-08 16:50 UTC (permalink / raw)
  To: Zsh workers

Peter Stephenson wrote:
> 
> > Glob expansion including tilde expansion was the final annoyance that
> > made me stop using _expand altogether.
> 
> You might want to try again with the latest keep-prefix style (which has a
> sensible default) to see if it's any better, and what if anything remains
> to do.

That's certainly better but it has reminded me why I stopped using
_expand:

cd ~+<tab> expands, even with keep-prefix. I use the autopushd option
and really like being able to do cd ~+<tab and using the list of
directories to return to a previous directory.

Similar to this is the following:
hash -d abc=whatever
hash -d abcd=whatever

I'm always used to completion not doing anything where there is more
than one match so I don't like it when ~abc<tab> expands ~abc.

One thing which I like about the way expand-or-complete works is that
for example, $HOME<tab> will expand but $HOME/<tab> doesn't. In general,
I prefer variables and tildes not to be expanded but in some cases I
specifically want them expanded and if I press tab immediately after
something, I've probably conciously thought to do the expansion. Tab is
always much handier than ^X$ so this is something I like. Globs aren't
mixed with completion as often so I generally do want globs expanded
which is why I wanted subst-only-globs.

Oliver


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

* Re: PATCH: expansion
  2000-06-07 22:21 ` PATCH: expansion Wayne Davison
@ 2000-06-08 10:03   ` Oliver Kiddle
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Kiddle @ 2000-06-08 10:03 UTC (permalink / raw)
  To: Wayne Davison; +Cc: zsh-workers

Wayne Davison wrote:
> 
> I assume that should be spelled "subst-globs-only".  I can't get this
> style to work for me.  If I only set subst-globs-only (without anything
> like "glob" set), it does nothing.  If I also set "glob", it expands
> tildes.

For subst-globs-only to be useful, you will want to set both substitute
and glob as well. What it does is allow substitutions only when globbing
is going to do something so if you type cd $HOME/<tab>, $HOME will not
be expanded but if you type echo $HOME/*<tab> it will be because the
expansion is necessary for the globbing to work.

Whether this is something that you want I don't know. For me, it made
the behaviour better but still a long way from the way I'd like it to
be.

Glob expansion including tilde expansion was the final annoyance that
made me stop using _expand altogether.

Oliver Kiddle


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

* Re: PATCH: expansion
  2000-06-07  6:46 PATCH: expansion (was: Re: PATCH: Re: blah*[TAB] (difference between 3.1.6 and 3.1.9)) Sven Wischnowsky
@ 2000-06-07 22:21 ` Wayne Davison
  2000-06-08 10:03   ` Oliver Kiddle
  0 siblings, 1 reply; 8+ messages in thread
From: Wayne Davison @ 2000-06-07 22:21 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

On Wed, 7 Jun 2000, Sven Wischnowsky wrote:
> I wrote:
> > Finally, one of the just-committed cvs changes has introduced a bug
> > where an extra space is getting added when it shouldn't be.  Now, if
> > you type "~/.z<tab>" you get "/home/wayne/.z " even though that file
> > does not exist.
> 
> We are talking about *expansion* here.

Yes, I was switching topics a bit and talking about a bug in the
_expand module.  When I type the string "ls ~/.z<tab>" hoping to
complete the filename, instead the _expand module expands the ~ into
my home directory, and it now adds a space to the end of the string.
That means I have to backspace over the space to continue completing
the filename.

> Wayne Davison wrote:
> > However, no matter what I try, tab does not expand wildcards with
> > expand-or-complete set.
> 
> [Scratching head...] Hm. It works for me.

...And it would have worked for me too if glob_complete hadn't been
turned on in the /etc/zshrc file.  I apparently didn't notice that
Mandrake Linux does this (because I have been attempting to use the
new expansion/completion system on my Linux box).

> [Going back to the glob discussion...]
> You can also try the substs-globs-only style.

I assume that should be spelled "subst-globs-only".  I can't get this
style to work for me.  If I only set subst-globs-only (without anything
like "glob" set), it does nothing.  If I also set "glob", it expands
tildes.  I.e.:

% zsh -f
% bindkey '\t' complete-word
% autoload -U compinit
% compinit -D
% zstyle ':completion:*' completer _expand _complete
% zstyle ':completion:*:expand:::' subst-globs-only 1
% zstyle ':completion:*:expand:*' tag-order all-expansions
% touch tmp{1..3}
% ls tmp*<tab>

This fails to do anything (but beep).  If I add this line:

% zstyle ':completion:*:expand:::' glob 1

then "ls tmp*<tab>" expands correctly, but "~/.z<tab>" expands the
tilde instead of doing nothing.

..wayne..


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

end of thread, other threads:[~2000-06-14  9:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-09  7:32 PATCH: expansion Sven Wischnowsky
2000-06-09 10:45 ` Oliver Kiddle
  -- strict thread matches above, loose matches on Subject: below --
2000-06-14  6:21 Sven Wischnowsky
2000-06-13 11:24 Sven Wischnowsky
2000-06-13 16:41 ` Bart Schaefer
     [not found] <0FVU001OT0DZC6@la-la.cambridgesiliconradio.com>
2000-06-08 16:50 ` Oliver Kiddle
2000-06-07  6:46 PATCH: expansion (was: Re: PATCH: Re: blah*[TAB] (difference between 3.1.6 and 3.1.9)) Sven Wischnowsky
2000-06-07 22:21 ` PATCH: expansion Wayne Davison
2000-06-08 10:03   ` Oliver Kiddle

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