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

Hi

The error message lead me to believe the error was in the first line of
the function (i.e. zsh backward-word), but by deduction I found out the
actual problem was trying to run zle in a subshell.

Manipulating the kill ring array directly instead of calling "zle
yank-pop" seems to work.

expand-word-path ()
{
        zle backward-word
        zle set-mark-command
        zle forward-word
        zle copy-region-as-kill
        word=$killring[0]
        killring[0]=()
        realpath=$(realpath $word 2>/dev/null)
        if test -n "$realpath"
        then
                zle backward-kill-word
                zle -U "$realpath"
        fi
}

The only thing now is invoking it on an empty word multiple times does
weird things.  Probably some edge cases I have to look at, such as when
$word is empty.


  reply	other threads:[~2006-12-10  0:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Mikel Ward [this message]
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=457B5073.90206@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).