zsh-users
 help / color / mirror / code / Atom feed
* _expand_word_and_keep of 'keeper suite' doesn't work
@ 2005-12-01  9:57 Hannu Koivisto
  2005-12-01 16:05 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Hannu Koivisto @ 2005-12-01  9:57 UTC (permalink / raw)
  To: Zsh Users' List

Greetings,

The version of _expand_word_and_keep below (from the magazine
article) doesn't seem to work in at least 4.2.5.  For some reason
the condition [[ $args[-J] == all-expansions ]] is never true when
and nothing is put to the kept variable.  I have no idea of what that
condition is there for, but just for the heck of it I tried
removing it completely.  Then, ... *.jpg<C-x e> caused *.jpg to be
put to the kept variable.

Any ideas?

_expand_word_and_keep() {
    function compadd() {
        local -A args
        zparseopts -E -A args J:
        if [[ $args[-J] == all-expansions ]]; then
            builtin compadd -A kept "$@"
            kept=( ${(Q)${(z)kept}} )
        fi
        builtin compadd "$@"
    }
    local result
    _main_complete _expand
    result=$?
    unfunction compadd
    return result
}

zle -C _expand_word complete-word _expand_word_and_keep

-- 
Hannu


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-01  9:57 _expand_word_and_keep of 'keeper suite' doesn't work Hannu Koivisto
@ 2005-12-01 16:05 ` Bart Schaefer
  2005-12-01 22:39   ` Hannu Koivisto
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2005-12-01 16:05 UTC (permalink / raw)
  To: Zsh Users' List

On Dec 1, 11:57am, Hannu Koivisto wrote:
}
} The version of _expand_word_and_keep below (from the magazine
} article) doesn't seem to work in at least 4.2.5.  For some reason
} the condition [[ $args[-J] == all-expansions ]] is never true

The accept-exact and keep-prefix styles can cause _expand to skip
the call to compadd entirely, and styles that affect the value of
$compstate[insert] can cause it to skip the step that passes the -J
flag.  What are your zstyle settings?


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-01 16:05 ` Bart Schaefer
@ 2005-12-01 22:39   ` Hannu Koivisto
  2005-12-02 16:57     ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Hannu Koivisto @ 2005-12-01 22:39 UTC (permalink / raw)
  To: Zsh Users' List

Bart Schaefer <schaefer@brasslantern.com> writes:

> The accept-exact and keep-prefix styles can cause _expand to skip
> the call to compadd entirely, and styles that affect the value of
> $compstate[insert] can cause it to skip the step that passes the -J
> flag.  What are your zstyle settings?

These:

zstyle ':completion:*:cd:*' tag-order local-directories directories -
zstyle ':completion:all-matches:*' old-matches only
zstyle ':completion:all-matches::::' completer _all_matches

-- 
Hannu


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-01 22:39   ` Hannu Koivisto
@ 2005-12-02 16:57     ` Bart Schaefer
  2005-12-02 19:40       ` Hannu Koivisto
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2005-12-02 16:57 UTC (permalink / raw)
  To: Zsh Users' List

On Dec 2, 12:39am, Hannu Koivisto wrote:
} Subject: Re: _expand_word_and_keep of 'keeper suite' doesn't work
}
} Bart Schaefer <schaefer@brasslantern.com> writes:
} 
} > What are your zstyle settings?
} 
} These:

Hmm, none of those should have an adverse effect.  Try this:

autoload -U zed
Run "zed -f _complete_debug"
Scroll down to the line that reads "_main_complete"
Replace that with "_expand_word_and_keep"
Type ctrl-x ctrl-w to save

Now, set up an expansion of the sort that fails to work as expected,
but instead of your usual expand-word binding, type ctrl-x ?
(yes, that's ctrl-x followed by a question mark).

This should produce a trace file of the commands executed by the
completion system, which you can examine to see whether "compadd -J"
is ever being called.  If you can't see what's wrong, post it somewhere
accessible (or at worst, mail it to zsh-users) so we can have a look.
Make sure it doesn't contain any sensitive data, first, of course.


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-02 16:57     ` Bart Schaefer
@ 2005-12-02 19:40       ` Hannu Koivisto
  2005-12-03  3:44         ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Hannu Koivisto @ 2005-12-02 19:40 UTC (permalink / raw)
  To: Zsh Users' List

Bart Schaefer <schaefer@brasslantern.com> writes:

> This should produce a trace file of the commands executed by the
> completion system, which you can examine to see whether "compadd -J"
> is ever being called.  If you can't see what's wrong, post it somewhere
> accessible (or at worst, mail it to zsh-users) so we can have a look.

The trace file is now available at
<http://www.iki.fi/azure/completion-debug-output.txt>.  I can see
compadd calls with -J parameter but I don't know what to make of
those.  This is a bit too black magic to me.

-- 
Hannu


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-02 19:40       ` Hannu Koivisto
@ 2005-12-03  3:44         ` Bart Schaefer
  2005-12-03 12:27           ` Hannu Koivisto
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2005-12-03  3:44 UTC (permalink / raw)
  To: Zsh Users' List

On Dec 2,  9:40pm, Hannu Koivisto wrote:
}
} The trace file is now available at
} <http://www.iki.fi/azure/completion-debug-output.txt>.

OK, the first thing to try is:

  zstyle ':completion:*:expand:*' group-name ''

If that doesn't work, then it has to do with the way that you're binding
the _expand_word_and_keep function to a widget, because when I try it
(successfully) I consistently get a context of
    :completion:expand-word:expand:::
but your trace output shows a context of
    :completion::expand:::

Can you show me that part of your setup?


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-03  3:44         ` Bart Schaefer
@ 2005-12-03 12:27           ` Hannu Koivisto
  2005-12-03 18:20             ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Hannu Koivisto @ 2005-12-03 12:27 UTC (permalink / raw)
  To: Zsh Users' List

Bart Schaefer <schaefer@brasslantern.com> writes:

> OK, the first thing to try is:
>
>   zstyle ':completion:*:expand:*' group-name ''
>
> If that doesn't work, then it has to do with

It seems to work.  Does that have any adverse effects on other
functionality?

> the way that you're binding the _expand_word_and_keep function to
> a widget, because when I try it
...
> Can you show me that part of your setup?

I'm using the code from the article:

zle -C _expand_word complete-word _expand_word_and_keep

-- 
Hannu


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-03 12:27           ` Hannu Koivisto
@ 2005-12-03 18:20             ` Bart Schaefer
  2005-12-04  5:44               ` Joakim Ryden
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2005-12-03 18:20 UTC (permalink / raw)
  To: zsh-users

On Dec 3,  2:27pm, Hannu Koivisto wrote:
} Subject: Re: _expand_word_and_keep of 'keeper suite' doesn't work
}
} Bart Schaefer <schaefer@brasslantern.com> writes:
} 
} >   zstyle ':completion:*:expand:*' group-name ''
} 
} It seems to work.  Does that have any adverse effects on other
} functionality?

It changes the way the completion listing or the menuselect menu are
displayed, but only for expansion.  In fact, changing it everywhere by
    zstyle ':completion:*' group-name ''
is often a recommended setting even though it's not the default.

I'll have to see if I can tweak the keeper suite in the 4.3 dist so
that it works without the group-name setting, or at least document
that the above style is needed.
 
} > the way that you're binding the _expand_word_and_keep function to
} > a widget, because when I try it

This turns out to be a red herring from my own configuration, though
it does indicate another potentially useful change to keeper.


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

* Re: _expand_word_and_keep of 'keeper suite' doesn't work
  2005-12-03 18:20             ` Bart Schaefer
@ 2005-12-04  5:44               ` Joakim Ryden
  0 siblings, 0 replies; 9+ messages in thread
From: Joakim Ryden @ 2005-12-04  5:44 UTC (permalink / raw)
  To: zsh-users

I'm a lurker on this list, maybe a posting a year or two, but I have to 
say...and pardon my French...Dammit Bart, thank you so much for your 
posts, they are incredibly enlightening, patient, and useful to no end. 
Same goes for Peter. Thank you guys for making this list a sheer joy to 
read.

--Jo


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

end of thread, other threads:[~2005-12-04  5:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-01  9:57 _expand_word_and_keep of 'keeper suite' doesn't work Hannu Koivisto
2005-12-01 16:05 ` Bart Schaefer
2005-12-01 22:39   ` Hannu Koivisto
2005-12-02 16:57     ` Bart Schaefer
2005-12-02 19:40       ` Hannu Koivisto
2005-12-03  3:44         ` Bart Schaefer
2005-12-03 12:27           ` Hannu Koivisto
2005-12-03 18:20             ` Bart Schaefer
2005-12-04  5:44               ` Joakim Ryden

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