zsh-workers
 help / color / mirror / code / Atom feed
* zle -U "$selected" doesn't handle (some?) multibyte characters
@ 2016-01-10  8:18 Sebastian Gniazdowski
  2016-01-10  8:40 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-10  8:18 UTC (permalink / raw)
  To: Zsh hackers list

I have a following code in which "$selected" resolves to "The\ Voice\
of\ Poland\ VI\ –\ Marta\ Moszczyńska\ –\ „Sail”\ –\
Live-h9KgwUAlCjE.mkv":

if [ "$REPLY" -gt 0 ]; then
    selected="$reply[REPLY]"
    echo "$selected" > /tmp/d
    # ZLE?
    if [ "${(t)CURSOR}" = "integer-local-special" ]; then
        zle redisplay
        zle kill-whole-line
        zle -U "$selected"
    else
        print -zr "$selected"
    fi
else
    [ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay
fi

So two paths, one for the script being run from Zle, and other one
when run as function. The function path works, string is not
disrupted. The "echo" also outputs non-disrupted string. However, zle
-U "$selected" outputs: "The\ Voice\ of\ Poland\ VI\  \ Marta\
MoszczyŃska\  \  Sail \  \ Live-h9KgwUAlCjE.mkv"

The quotation marks are missing. The letter "ń" is also disrupted and
outputted as "Ń"

Best regards,
Sebastian Gniazdowski


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

* Re: zle -U "$selected" doesn't handle (some?) multibyte characters
  2016-01-10  8:18 zle -U "$selected" doesn't handle (some?) multibyte characters Sebastian Gniazdowski
@ 2016-01-10  8:40 ` Sebastian Gniazdowski
  2016-01-10  9:21   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-10  8:40 UTC (permalink / raw)
  To: Zsh hackers list

A simple testing code:

a() { zle -U "The\ Voice\ of\ Poland\ VI\ –\ Marta\ Moszczyńska\ –\
„Sail”\ –\ Live-h9KgwUAlCjE.mkv" }
zle -N a a
bindkey "^T" a

Best regards,
Sebastian Gniazdowski


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

* Re: zle -U "$selected" doesn't handle (some?) multibyte characters
  2016-01-10  8:40 ` Sebastian Gniazdowski
@ 2016-01-10  9:21   ` Sebastian Gniazdowski
  2016-01-10 11:38     ` Sebastian Gniazdowski
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-10  9:21 UTC (permalink / raw)
  To: Zsh hackers list

It works on zsh-5.1.1, doesn't work on 5.0.8, so it has been fixed
somewhere in between. Ignore my emails

Best regards,
Sebastian Gniazdowski


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

* Re: zle -U "$selected" doesn't handle (some?) multibyte characters
  2016-01-10  9:21   ` Sebastian Gniazdowski
@ 2016-01-10 11:38     ` Sebastian Gniazdowski
  2016-01-10 20:51       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-10 11:38 UTC (permalink / raw)
  To: Zsh hackers list

It was in fact zsh-5.1.1-dev-0 that fixed this, with of course this commit:

8e77fcb050ed09042cc2464f804ac023c0f88b42 is the first bad commit
commit 8e77fcb050ed09042cc2464f804ac023c0f88b42
Author: Barton E. Schaefer <schaefer@zsh.org>
Date:   Sat Sep 12 16:13:01 2015 -0700

    36522: unmetafy the argument of "zle -U"


Is there any alternative to zle -U, to support older Zshells?

Best regards,
Sebastian Gniazdowski


On 10 January 2016 at 10:21, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> It works on zsh-5.1.1, doesn't work on 5.0.8, so it has been fixed
> somewhere in between. Ignore my emails
>
> Best regards,
> Sebastian Gniazdowski


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

* Re: zle -U "$selected" doesn't handle (some?) multibyte characters
  2016-01-10 11:38     ` Sebastian Gniazdowski
@ 2016-01-10 20:51       ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2016-01-10 20:51 UTC (permalink / raw)
  To: Zsh hackers list

On Jan 10, 12:38pm, Sebastian Gniazdowski wrote:
}
} Is there any alternative to zle -U, to support older Zshells?

There's not really an alternative to "zle -U" because of the way the
input stack works, but with some effort you can work around the
metafication problem.  You need to define a new key sequence for each
metafied character (similar to the way insert-composed-char works)
and substitute those into the string before pushing it with "zle -U".

If the only reason you need zle -U is for delayed-action self-insert
(no movement/command widgets involved), then you can define a widget
that manages a stack (array param) of values to be appended onto
LBUFFER, and each time you "zle -U" the key bound to that widget you
also put a new value on the stack array.

There might also be a way to work "bindkey -s" in there so that you
can "execute" the value from the top of the stack instead of just
appending it to LBUFFER, but I'm not going to try to figure that out.


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

end of thread, other threads:[~2016-01-10 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-10  8:18 zle -U "$selected" doesn't handle (some?) multibyte characters Sebastian Gniazdowski
2016-01-10  8:40 ` Sebastian Gniazdowski
2016-01-10  9:21   ` Sebastian Gniazdowski
2016-01-10 11:38     ` Sebastian Gniazdowski
2016-01-10 20:51       ` Bart Schaefer

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