From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24717 invoked by alias); 22 Sep 2015 07:10:52 -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: 36593 Received: (qmail 14684 invoked from network); 22 Sep 2015 07:10:50 -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 Subject: Re: edit-command-line problem with emacsclient To: Bart Schaefer , zsh-workers@zsh.org References: <55FE9C92.7030203@petervasil.net> <20150921211643.GJ1955@tarsus.local2> <150921153124.ZM609@torch.brasslantern.com> From: Peter Vasil Message-ID: <5600FEF5.1010608@petervasil.net> Date: Tue, 22 Sep 2015 09:10:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <150921153124.ZM609@torch.brasslantern.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Hi Bart, Looks really good. I can confirm that your patch works for both emacs and emacsclient. Thanks so much! Cheers, Peter On 09/22/2015 12:31 AM, Bart Schaefer wrote: > 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 >