From 56ed4df8988249338b0f8f2d999df4217ca533e6 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Tue, 22 Sep 2015 08:52:52 -0700 Subject: 36587: use +LINE:COLUMN to place the cursor when invoking emacs variants, for emacsclient --- Functions/Zle/edit-command-line | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Functions') diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line index 2c7f34b8b..103a1c1a5 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 -- cgit 1.4.1