From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28044 invoked by alias); 21 Sep 2015 22:31:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36587 Received: (qmail 24801 invoked from network); 21 Sep 2015 22:31:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=65/wf5DaI0PLTpxte5IS+/ct+nAAERol4JwMZGY58+E=; b=Uen3dJ0mb799HwH3FxneY97g8Bb7oclO4d4Fu+Hsp9i3QWH/QWw4cXjtRQRqr1lXlT gdBfU2obeEDWUS3q9gQZcdjXpkuJe89T/mBWVRilpRFi4MZgmFomu6e7Qz/TcO13yazJ ZsujXwJhgwu81ZUshe11mZ34vW/snWVmsmx2+PpUsEjUXGokS2XJlQqtUgx3KHq+JxLb 7Jg9jFwr11Kh7s1SskCP9O55kFrS1TsRikdSw/CIn8fpKPZ8Gfl0ACo5EGS+2J2FX2/5 jMsZbLKP1QY3c4R8lbRnphXs+GsINuGAIuiPRdMAZESPszFNggG2mLQ7NCx2aFjaqm0z JxsA== X-Gm-Message-State: ALoCoQn3EmBDQ3QxW6wlhktLRGJICGhalGFEUK2Ehz6YZ3bGABwDoMn4wOTcqYHW6b7MOqIucRES X-Received: by 10.202.169.65 with SMTP id s62mr12770975oie.28.1442874686325; Mon, 21 Sep 2015 15:31:26 -0700 (PDT) From: Bart Schaefer Message-Id: <150921153124.ZM609@torch.brasslantern.com> Date: Mon, 21 Sep 2015 15:31:24 -0700 In-Reply-To: <20150921211643.GJ1955@tarsus.local2> Comments: In reply to Daniel Shahaf "Re: edit-command-line problem with emacsclient" (Sep 21, 9:16pm) References: <55FE9C92.7030203@petervasil.net> <20150921211643.GJ1955@tarsus.local2> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: edit-command-line problem with emacsclient MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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