Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: edit-command-line problem with emacsclient
- X-seq: zsh-workers 36587
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: edit-command-line problem with emacsclient
- Date: Mon, 21 Sep 2015 15:31:24 -0700
- In-reply-to: <20150921211643.GJ1955@tarsus.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <55FE9C92.7030203@petervasil.net> <20150921211643.GJ1955@tarsus.local2>
On Sep 21, 9:16pm, Daniel Shahaf wrote:
}
} I wrote that. Sorry for the bug. I'm a vim user, and I sanity-tested
} the emacs case, but I don't actually speak emacs lisp, so I'm not
} surprised the patch was complete but not sound. I see now I forgot to
} state in the patch mail that the emacs codepath needed extra review :-/
S'ok, I think this should do it:
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 2c7f34b..103a1c1 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -11,13 +11,16 @@
# Compute the cursor's position in bytes, not characters.
setopt localoptions nomultibyte
- integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
# Open the editor, placing the cursor at the right place if we know how.
local editor=${${VISUAL:-${EDITOR:-vi}}}
case $editor in
- (*vim*) ${=editor} -c "normal! ${byteoffset}go" -- $1;;
- (*emacs*) ${=editor} $1 -eval "(goto-char ${byteoffset})";;
+ (*vim*)
+ integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
+ ${=editor} -c "normal! ${byteoffset}go" -- $1;;
+ (*emacs*)
+ local lines=( ${(f):-"$PREBUFFER$LBUFFER"} )
+ ${=editor} +${#lines}:$((${#lines[-1]} + 1)) $1;;
(*) ${=editor} $1;;
esac
Messages sorted by:
Reverse Date,
Date,
Thread,
Author