zsh-users
 help / color / mirror / code / Atom feed
* error using custom widget: widgets can only be called when ZLE is active
@ 2006-12-09 23:18 Mikel Ward
  2006-12-10  0:10 ` error using custom widget: widgets can only be called when ZLE is active [solved] Mikel Ward
  0 siblings, 1 reply; 5+ messages in thread
From: Mikel Ward @ 2006-12-09 23:18 UTC (permalink / raw)
  To: zsh-users

Hi


I'm trying to make a keyboard shortcut in Z Shell to expand the previous
word on the command line its canonical path ("realpath") if it's a file.

For example, I have a directory in /etc/apache2/mods-enabled that
contains symlinks to files in /etc/apache2/mods-available.

I want to be able to do:
> cd /etc/apache2/mods-enabled

> ls -l proxy.load<Press ^X />

and have the command change to:
> ls -l /etc/apache2/mods-available/proxy.load


>From what I gather, I can do this using a zle custom widget.  I chose to
call the function implementing it expand-word-path and bind this to ^X /.

For some reason, it doesn't work.  In zsh 4.3.2 on Debian Linux I get an
error that ZLE is inactive, as you can see below.

----------
> expand-word-path()
{
zle backward-word
zle set-mark-command
zle forward-word
zle copy-region-as-kill
file=$(zle yank-pop)
zle -U `realpath $file`
}

> zle -N expand-word-path

> bindkey "^X/" expand-word-path

> ls /etc/apache2/mods-enabled/rewrite.load<^X/>

zle:1: widgets can only be called when ZLE is active
realpath: need at least one filename
Usage:
 realpath [-s|--strip] [-z|--zero] filename ...
 realpath -h|--help
 realpath -v|--version

expand-word-path:zle:7: not enough arguments for -U
----------

The manual says:
    zle widget [ -n num ] [ -N ] args ...
        Invoke the specified widget. This can only be
        done when ZLE is active; normally this will be
        within a user-defined widget.

This suggests to me that ZLE should be active in the context I'm using
it, but clearly it's not.


I've tried searching for other custom widgets, but surprisingly there's
not any out there.


Can anyone suggest what I'm doing wrong or point me to some other custom
widgets that do work?


Thanks


Mike


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

end of thread, other threads:[~2006-12-14 11:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-09 23:18 error using custom widget: widgets can only be called when ZLE is active Mikel Ward
2006-12-10  0:10 ` error using custom widget: widgets can only be called when ZLE is active [solved] Mikel Ward
2006-12-10  0:33   ` zsh widget to resolve symlinks Mikel Ward
2006-12-10 17:56     ` Peter Stephenson
2006-12-14 11:22       ` PATCH: argument splitting (was Re: zsh widget to resolve symlinks) Peter Stephenson

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