Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bracketed paste
- X-seq: zsh-workers 35796
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: "Yuri D'Elia" <wavexx@xxxxxxxxxx>
- Subject: Re: bracketed paste
- Date: Wed, 15 Jul 2015 20:15:00 +0200
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GkRn8edCDqlMQU1jfVpLo63fe0W5gMR5BypU06pe+lw=; b=BKZmPd3lH6QCX0VN+9sV8MKOE06weUdqMUCOlLhYP//W2n5MNE7vw1+6dTl8XEJ58I Y6t/0/Wku86n9jWAYR2cfl5L3Hkhj4vHWtfLlKsmSNL9TYUu0PJBvwA4MHVvV6yg20i/ WYYlH3P495don0OJ/TUKtC8JIichfaGZ+Txps2EC0KCmxYO2ghTxPfC0zBt+PiRCpGjG a4zQLp8OroTfPEY60jsQmgAzIJTVscrY8Si7Qfxxtv9g3/mgROPrxrdCYVox/pI4yXD6 yl3RPl8Mw0ZeckVqrFi32HOHGdMwLRm4NfYLWAhHnEVBabf+PRrlaxhSiO72wrfMBqW9 erMw==
- In-reply-to: <mo65gp$4im$1@ger.gmane.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <mo6325$r5k$1@ger.gmane.org> <mo65gp$4im$1@ger.gmane.org>
On Wed, Jul 15, 2015 at 7:33 PM, Yuri D'Elia <wavexx@xxxxxxxxxx> wrote:
> On 15/07/15 18:51, Yuri D'Elia wrote:
>> I'd like to do the same using the final widget if possible.
>
> To give an example, if you still remember the code I posted earlier:
>
> function _end_paste() {
> bindkey -e
> setopt localoptions extendedglob
> _paste_content=${${_paste_content%%[[:space:]]#}##[[:space:]]#}
> [[ $_paste_quoted == 1 ]] && LBUFFER+=${(q)_paste_content} || LBUFFER+=$_paste_content
> unset _paste_content _paste_quoted
> }
>
> And yes, that whitespace trimming looks ugly.
> Is there a better way?
Here's my local .zshrc diff that adapts to the new widget, if that
helps, and yeah, you'll have to wait for 5.0.9.
diff --git a/.zshrc b/.zshrc
index 7fc4091..b972f40 100644
--- a/.zshrc
+++ b/.zshrc
@@ -443,9 +443,7 @@ zle -N _hextochar
zle -N _chartohex
zle -N zle-line-init _zle_line_init
zle -N zle-line-finish _zle_line_finish
-zle -N _start_paste
-zle -N _end_paste
-zle -N paste-insert _paste_insert
+zle -N bracketed-paste _start_paste
zle -N _spaceafterpastequote
zle -N self-insert-unmeta-right _self_insert_unmeta_right
zle -N overwrite-mode _overwrite_mode
@@ -547,13 +545,6 @@ bindkey "^[j" backward-char
bindkey "^[k" forward-char
bindkey "^[ " self-insert-unmeta-right
-# Hooks
-bindkey -N paste
-bindkey -R -M paste "^@"-"\M-^?" paste-insert
-bindkey '^[[200~' _start_paste
-bindkey -M paste '^[[201~' _end_paste
-bindkey -M paste -s '^M' '^J'
-
# Unbind defaults that conflict with keychains
bindkey -r "^_"
diff --git a/hooks.zsh b/hooks.zsh
index 5916774..d579aa3 100644
--- a/hooks.zsh
+++ b/hooks.zsh
@@ -486,8 +486,6 @@ function _zle_line_init() {
zle set-local-history -n 1
function _zle_line_init() {
zle -N zle-line-pre-redraw _line_redraw
- # Tell urxvt to send escape codes around a paste
- [[ $TERM == rxvt-unicode || $TERM = xterm ]] && printf '\e[?2004h'
bindkey -e
}
_zle_line_init
@@ -495,8 +493,6 @@ function _zle_line_init() {
function _zle_line_finish() {
[[ $CONTEXT = vared ]] || ZLE_LINE_ABORTED=$BUFFER
- # Tell it to stop
- [[ $TERM == rxvt-unicode || $TERM = xterm ]] && printf '\e[?2004l'
}
function _recover_line_or_else() {
@@ -510,18 +506,13 @@ function _recover_line_or_else() {
zle -N up-history _recover_line_or_else
function _start_paste() {
- unset _paste_content
- bindkey -A paste main
-}
-
-function _end_paste() {
- bindkey -e
+ local content
+ zle .$WIDGET -N content
if [[ $_SPACE_AFTER_PASTE_QUOTE = 1 ]]; then
- LBUFFER+=${(q-)_paste_content}' '
+ LBUFFER+=${(q-)content}' '
else
- LBUFFER+=$_paste_content
+ LBUFFER+=$content
fi
- unset _paste_content
}
function _spaceafterpastequote() {
@@ -721,10 +712,6 @@ function _chartohex() {
(( CURSOR = pos + $#new - 1 ))
}
-function _paste_insert() {
- _paste_content+=$KEYS
-}
-
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author