zsh-workers
 help / color / mirror / code / Atom feed
* problem with _expand (I think)
@ 2006-02-24 22:20 Wayne Davison
  2006-02-25  0:56 ` Barton Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Wayne Davison @ 2006-02-24 22:20 UTC (permalink / raw)
  To: zsh-workers

Here's something strange where a global alias of mine seems to be
skipped by _expand in certain circumstances.  To duplicate this,
start with "zsh -f" and enter these commands:

    autoload -U compinit
    compinit
    zstyle ':completion:*' completer _expand _complete
    bindkey '\t' complete-word
    alias -g ,f='|fgrep'

OK, that ensures that tab does not use expand-or-complete, which does
not exhibit the bug.  Note that I created a global alias that lets me
type ",f" instead of "|fgrep".  We also need a file named "some-file"
with the following lines in it:

    foo
    bar

Now let's try to use TAB to expand a back-tick expression:

    echo `fgrep some-file o ,f -v a`

That outputs "foo" when run, but the expansion gets "some-file:bar"
instead of "foo" if TAB is pressed.  This is apparently because the ",f"
was treated as a file, and the -v option was reordered in front of the
'o' (due to gnu's non-posix command-line parsing).

I tried this in 4.2.5 and 4.3.0-dev-5, and both fail to get this right.
FYI.

..wayne..


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

* Re: problem with _expand (I think)
  2006-02-24 22:20 problem with _expand (I think) Wayne Davison
@ 2006-02-25  0:56 ` Barton Schaefer
  2006-02-25  9:36   ` Wayne Davison
  0 siblings, 1 reply; 4+ messages in thread
From: Barton Schaefer @ 2006-02-25  0:56 UTC (permalink / raw)
  To: zsh-workers

On Fri, 24 Feb 2006 3:02pm, Wayne Davison wrote:
> Here's something strange where a global alias of mine seems to be
> skipped by _expand in certain circumstances.

One of the first things that _main_complete does is "setopt 
NO_aliases".

Perhaps _expand needs to "setopt aliases"?


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

* Re: problem with _expand (I think)
  2006-02-25  0:56 ` Barton Schaefer
@ 2006-02-25  9:36   ` Wayne Davison
  2006-03-08  7:57     ` Wayne Davison
  0 siblings, 1 reply; 4+ messages in thread
From: Wayne Davison @ 2006-02-25  9:36 UTC (permalink / raw)
  To: Barton Schaefer; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

On Fri, Feb 24, 2006 at 04:56:32PM -0800, Barton Schaefer wrote:
> Perhaps _expand needs to "setopt aliases"?

Probably so.  I managed to tweak _expand to avoid the problem, but I
don't know if my change is the right solution or not.  Patch attached.

..wayne..

[-- Attachment #2: alias-tweak.diff --]
[-- Type: text/plain, Size: 439 bytes --]

--- Completion/Base/Completer/_expand	21 Jan 2005 09:33:14 -0000	1.10
+++ Completion/Base/Completer/_expand	25 Feb 2006 08:28:13 -0000
@@ -85,9 +85,11 @@ if [[ "$force" = *s* ]] ||
 ###  the following expression, too.  We don't want that, but I have no
 ###  idea how to fix it.
 
+  setopt aliases
   eval 'exp=( ${${(e)exp//\\[ 	
 ]/ }//(#b)([ 	
 ])/\\$match[1]} )' 2>/dev/null
+  setopt NO_aliases
 else
   exp=( ${exp:s/\\\$/\$} )
 fi

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

* Re: problem with _expand (I think)
  2006-02-25  9:36   ` Wayne Davison
@ 2006-03-08  7:57     ` Wayne Davison
  0 siblings, 0 replies; 4+ messages in thread
From: Wayne Davison @ 2006-03-08  7:57 UTC (permalink / raw)
  To: Barton Schaefer; +Cc: zsh-workers

On Sat, Feb 25, 2006 at 01:36:18AM -0800, Wayne Davison wrote:
> I managed to tweak _expand to avoid the problem, but I
> don't know if my change is the right solution or not.

Since this change fixes the problem and seems reasonable to me, I went
ahead and committed it.  If it's incomplete or could be done in a better
way, I'm sure someone will feel free to improve on it.

..wayne..


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

end of thread, other threads:[~2006-03-08  7:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-24 22:20 problem with _expand (I think) Wayne Davison
2006-02-25  0:56 ` Barton Schaefer
2006-02-25  9:36   ` Wayne Davison
2006-03-08  7:57     ` Wayne Davison

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