zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: edit-command-line problem with emacsclient
Date: Mon, 21 Sep 2015 15:31:24 -0700	[thread overview]
Message-ID: <150921153124.ZM609@torch.brasslantern.com> (raw)
In-Reply-To: <20150921211643.GJ1955@tarsus.local2>

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
 


  reply	other threads:[~2015-09-21 22:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-20 11:46 Peter Vasil
2015-09-20 15:32 ` Bart Schaefer
     [not found]   ` <55FF3CE5.9070604@petervasil.net>
2015-09-21  4:06     ` Bart Schaefer
     [not found]       ` <56004B05.9000703@petervasil.net>
     [not found]         ` <150921120017.ZM426@torch.brasslantern.com>
2015-09-21 19:09           ` Peter Vasil
2015-09-21 21:16 ` Daniel Shahaf
2015-09-21 22:31   ` Bart Schaefer [this message]
2015-09-22  7:10     ` Peter Vasil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150921153124.ZM609@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).