* Functions/Zle/edit-command-line
@ 2001-03-04 19:33 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2001-03-04 19:33 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-03-04 19:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-04 19:33 Functions/Zle/edit-command-line 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).