Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] bracketed-paste: change quoting style



On Aug 12,  5:13am, Mikael Magnusson wrote:
} Subject: Re: [PATCH] bracketed-paste: change quoting style
}
} On Wed, Aug 12, 2015 at 4:52 AM, Bart Schaefer
} <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > I'm tempted simply to suggest that bracketed-paste should get
} > out of the way if there are no newlines in the pasted text, but
} > there may be other bindings that shouldn't run.
} 
} It's also nice for avoiding various other problems, like tabs.

How about this?

    bracketed-paste-magic() {
      local PASTED
      zle .bracketed-paste PASTED
      zle -U - $PASTED
      while [[ -n $PASTED ]] && zle .read-command
      do
	PASTED=${PASTED#$KEYS}
	case $REPLY in
	(self-insert*) zle $REPLY;;
	(*) zle self-insert-unmeta;;
	esac
      done
    }
    zle -N bracketed-paste bracketed-paste-magic

I actually wonder if implementing the above loop in C might not be
preferable to flatly calling doinsert().

} I feel like the widget is already getting quite DWIMmy, and what "we"
} mean might not be what everyone else means. (I'm not even convinced we
} all want the things it's already doing).

Yes, the above breaks the (so far undocumented?) vi-mode cutbuffer stuff,
doesn't handle overwriting the region or setting undo points, probably
breaks somehow with multibyte characters, etc.

} I would also argue that intentionally putting text in the paste buffer
} to invoke widgets by pasting it is somewhat perverse

I'm not sure what you're talking about here.  I'd put text in the paste
buffer in order to paste it.  For pasting to result in a widget being
invoked is no different than any other interaction with the editor and
amounts to an implemention detail of the real desire, which is to paste
the text without something unexpected happening.

Of course if what you are expecting is for it to behave as if you typed
each character individually, bracketed-paste is going to confuse you.  

} and if you want to do it, you get to change the default configuration
} to do it. It shouldn't depend on something mostly orthogonal like if
} there is a newline.

"If there is a newline" is shorthand for "if any action other than a
self-insert would occur".

} I thought earlier we may even want to add a
} bracketed-paste-raw/simple/literal function that just does what
} bracketed-paste does in the case of being passed a parameter, but also
} inserts it on the command line for you, and nothing more.

Yes, I could see the utility of this.



Messages sorted by: Reverse Date, Date, Thread, Author