about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-09-22 08:52:52 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-09-22 08:52:52 -0700
commit56ed4df8988249338b0f8f2d999df4217ca533e6 (patch)
treea93782432a72b189767609700b31fa6c7ebf2b00
parentacf5bd766a7b5d656cdf1c636c8508492c1aadf4 (diff)
downloadzsh-56ed4df8988249338b0f8f2d999df4217ca533e6.tar.gz
zsh-56ed4df8988249338b0f8f2d999df4217ca533e6.tar.xz
zsh-56ed4df8988249338b0f8f2d999df4217ca533e6.zip
36587: use +LINE:COLUMN to place the cursor when invoking emacs variants, for emacsclient
-rw-r--r--ChangeLog5
-rw-r--r--Functions/Zle/edit-command-line9
2 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e5ea4fd30..6d69e6d61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-22  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 36587: Functions/Zle/edit-command-line: use +LINE:COLUMN to
+	place the cursor when invoking emacs variants, for emacsclient
+
 2015-09-22  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 36586: Han Pingtian: Src/Zle/compmatch.c: tweak to completion
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