From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Functions/Zle/edit-command-line
Date: Sun, 4 Mar 2001 19:33:15 +0000 [thread overview]
Message-ID: <1010304193316.ZM15803@candle.brasslantern.com> (raw)
I wrote:
} I see that Clint's committed 13323, but I'm not convinced that it's the
} correct fix.
The problem with Clint's version is that it puts the entire multi-line
construct into the editor file:
print -R - "$PREBUFFER$BUFFER" >$tmpfile
But then it presumes that the user won't edit anything but the last line:
BUFFER=${"$(<$tmpfile)"/$PREBUFFER/}
If you actually do change anything that originated in $PREBUFFER, the whole
editor file will replace what used to be just the last line of the input,
leaving the original $PREBUFFER unchanged, which is clearly not correct.
The following "correct" solution unfortunately does not work:
edit-command-line () {
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
zle push-input # This line aborts the function
read -r -z -E > $tmpfile
exec < /dev/tty
${VISUAL:-${EDITOR:-vi}} $tmpfile
BUFFER="$(<$tmpfile)"
CURSOR=$#BUFFER
command rm -f $tmpfile
}
The reason that it doesn't work is that push-input (and push-line-or-edit)
must set errflag to force ZLE and the lexer to reset all the way to the PS1
prompt, and setting errflag causes ZLE to abort as if send-break were used.
That suggests the following alternate solution:
edit-command-line () {
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
print -R - "$PREBUFFER$BUFFER" > $tmpfile
exec < /dev/tty
${VISUAL:-${EDITOR:-vi}} $tmpfile
print -z - "$(<$tmpfile)"
command rm -f $tmpfile
zle send-break
}
This works exactly as desired except that it causes zsh to feep when the
editor exits. Unless somebody has a better idea (e.g., to fix push-input
so it does not need to simulate an error), I propose using the above.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
reply other threads:[~2001-03-04 19:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1010304193316.ZM15803@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--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).