1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-27 06:22:20 +02:00

36587: use +LINE:COLUMN to place the cursor when invoking emacs variants, for emacsclient

This commit is contained in:
Barton E. Schaefer 2015-09-22 08:52:52 -07:00
parent acf5bd766a
commit 56ed4df898
2 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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