zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: Elliott Cable <me@ell.io>, zsh-users@zsh.org
Subject: Re: edit-command-line, vim, and pasting
Date: Mon, 02 Nov 2015 12:16:33 +0100	[thread overview]
Message-ID: <18028.1446462993@thecus.kiddle.eu> (raw)
In-Reply-To: <151101103921.ZM16163@torch.brasslantern.com>

Bart wrote:
> This is almost certainly yet another unexpected knock-on effect of the
> new bracketed-paste handling.

Indeed.

> We need a generalized fix for this.  Oliver?

I'm not sure we can do anything more generalized than the following
patch to edit-command-line. Perhaps the zle builtin could have an option
to cover the situation but that doesn't help much because the function
would still need to invoke the builtin. What did you have in mind?

This also changes the comments to suggest ! rather than v as the key for
edit-command-line (v overrides a default binding that was added since
edit-command-line was written: visual mode).

Oliver

diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 103a1c1..b814552 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -1,8 +1,8 @@
 # Edit the command line using your usual editor.
-# Binding this to 'v' in the vi command mode map,
+# Binding this to '!' in the vi command mode map,
 #   autoload -Uz edit-command-line
 #   zle -N edit-command-line
-#   bindkey -M vicmd v edit-command-line
+#   bindkey -M vicmd '!' edit-command-line
 # will give ksh-like behaviour for that key,
 # except that it will handle multi-line buffers properly.
 
@@ -10,7 +10,9 @@
   exec </dev/tty
 
   # Compute the cursor's position in bytes, not characters.
-  setopt localoptions nomultibyte
+  setopt localoptions nomultibyte noksharrays
+
+  (( $+zle_bracketed_paste )) && print -n $zle_bracketed_paste[2]
 
   # Open the editor, placing the cursor at the right place if we know how.
   local editor=${${VISUAL:-${EDITOR:-vi}}}
@@ -24,6 +26,8 @@
     (*) ${=editor} $1;;
   esac
 
+  (( $+zle_bracketed_paste )) && print -n $zle_bracketed_paste[1]
+
   # Replace the buffer with the editor output.
   print -Rz - "$(<$1)" 
 } =(<<<"$PREBUFFER$BUFFER")


  reply	other threads:[~2015-11-02 11:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-01 16:37 Elliott Cable
2015-11-01 18:39 ` Bart Schaefer
2015-11-02 11:16   ` Oliver Kiddle [this message]
2015-12-07  3:01     ` Elliott Cable
2015-12-07  6:38       ` Bart Schaefer
2015-12-11  5:33       ` Oliver Kiddle

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=18028.1446462993@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=me@ell.io \
    --cc=zsh-users@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).