zsh-users
 help / color / mirror / code / Atom feed
From: Mikel Ward <mikel@mikelward.com>
To: zsh-users@sunsite.dk
Subject: error using custom widget: widgets can only be called when ZLE is active
Date: Sun, 10 Dec 2006 10:18:38 +1100	[thread overview]
Message-ID: <457B444E.2020207@mikelward.com> (raw)

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


             reply	other threads:[~2006-12-09 23:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-09 23:18 Mikel Ward [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=457B444E.2020207@mikelward.com \
    --to=mikel@mikelward.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).