From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@sunsite.dk
Subject: Re: some way to inherit kill ring in su'd shell?
Date: Sun, 11 Jan 2009 23:00:10 -0500 [thread overview]
Message-ID: <m3k5916unp.fsf@klanderman.net> (raw)
In-Reply-To: <090111193317.ZM12655@torch.brasslantern.com> (Bart Schaefer's message of "Sun, 11 Jan 2009 19:33:17 -0800")
[redirected from zsh-users]
>>>>> Bart Schaefer <schaefer@brasslantern.com> writes:
> On Jan 11, 8:58pm, Greg Klanderman wrote:
> }
> } Is an enhancement something like this acceptable?
> }
> } +tindex(zle-line-finished)
> } +item(tt(zle-line-finished))(
> } +This is similar to tt(zle-line-init) but is executed every time the line
> } +editor is finished reading a new line of input.
> } +)
> In concept this is OK (though there might be a better suffix than
> "-finished", maybe even just "-finish")
Yep, whatever you guys like is fine by me..
> but I don't think your patch
> follows through some possible ramifications. For example, it might
> be preferable to save/restore errflag and retflag so that the values
> from the end of zlecore() are preserved, and it's possible that the
> zle-line-finish widget should not run when errflag != 0.
Those sound like good things to worry about getting right.
> I don't know all the ramifications of the values of various globals
> at the end of zlecore(). PWS?
Right, I certainly don't either..
Anyway, here's a new version of my previous code using this
enhancement which also preserves the kill ring. There isn't
a builtin module for base64 encoding is there? :-)
function zle-encode-strings () {
python -c '
import base64, sys
sys.stdout.write(":".join(map(lambda v: base64.encodestring(v).replace("\n", ""), sys.argv[1:])))
' $@
}
function zle-decode-string () {
python -c '
import base64, sys
sys.stdout.write(base64.decodestring(sys.argv[1]))
' $1
}
function zle-line-init () {
local v i=0
if [[ ${ZLEKILLRINGPID-} != $$ && -n ${ZLECUTBUFFER-} ]] ; then
CUTBUFFER="$(zle-decode-string $ZLECUTBUFFER)"
for v in ${(s-:-)ZLEKILLRING} ; do
killring[((i++))]="$(zle-decode-string $v)"
done
fi
}
zle -N zle-line-init
function zle-line-finished () {
export ZLEKILLRINGPID=$$
export ZLECUTBUFFER="$(zle-encode-strings $CUTBUFFER)"
export ZLEKILLRING="$(zle-encode-strings $killring[@])"
}
zle -N zle-line-finished
cheers,
Greg
next parent reply other threads:[~2009-01-12 4:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <18789.30656.261463.382208@gargle.gargle.HOWL>
[not found] ` <20090110095231.GA61601@redoubt.spodhuis.org>
[not found] ` <m33afq97gg.fsf@klanderman.net>
[not found] ` <20090111025418.GA7272@redoubt.spodhuis.org>
[not found] ` <m3tz857mkm.fsf@klanderman.net>
[not found] ` <090111110748.ZM12349@torch.brasslantern.com>
[not found] ` <m3r63975pd.fsf@klanderman.net>
[not found] ` <m3ocyd70aj.fsf@klanderman.net>
[not found] ` <090111193317.ZM12655@torch.brasslantern.com>
2009-01-12 4:00 ` Greg Klanderman [this message]
2009-01-12 5:33 ` Bart Schaefer
2009-01-12 19:33 ` Greg Klanderman
2009-01-12 23:55 ` Richard Hartmann
2009-01-16 23:54 ` PATCH: add zle-line-finish special widget Greg Klanderman
2009-01-17 17:48 ` Peter Stephenson
2009-01-17 18:08 ` Bart Schaefer
2009-01-23 0:50 ` Greg Klanderman
2009-01-23 9:37 ` Peter Stephenson
2009-01-28 4:38 ` Greg Klanderman
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=m3k5916unp.fsf@klanderman.net \
--to=gak@klanderman.net \
--cc=zsh-workers@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).