mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-23 04:30:24 +02:00
36587: use +LINE:COLUMN to place the cursor when invoking emacs variants, for emacsclient
This commit is contained in:
parent
acf5bd766a
commit
56ed4df898
2 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue