summaryrefslogtreecommitdiff
path: root/Functions/Zle/bracketed-paste-magic
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Zle/bracketed-paste-magic')
-rw-r--r--Functions/Zle/bracketed-paste-magic54
1 files changed, 24 insertions, 30 deletions
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index 2b2bc630d..fb584d595 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -20,7 +20,7 @@
# active-widgets
# Looked up in the context :bracketed-paste-magic to obtain a list of
# patterns that match widget names that should be activated during the
-# paste. All other key sequences are processed as self-insert-unmeta.
+# paste. All other key sequences are processed as "zle .self-insert".
# The default is 'self-*' so any user-defined widgets named with that
# prefix are active along with the builtin self-insert. If this style is
# not set (note: it must be explicitly deleted after loading this
@@ -31,7 +31,7 @@
#
# inactive-keys
# This is the inverse of active-widgets, it lists key sequences that
-# always use self-insert-unmeta even when bound to an active-widget.
+# always use "zle .self-insert" even when bound to an active-widget.
# Note that this is a list of literal key sequences, not patterns.
# This style is in context :bracketed-paste-magic and has no default.
#
@@ -145,27 +145,26 @@ bracketed-paste-magic() {
done
fi
- # Save context, create a clean slate for the paste
- integer bpm_mark=$MARK bpm_cursor=$CURSOR bpm_region=$REGION_ACTIVE
- integer bpm_numeric=${NUMERIC:-1}
- local bpm_buffer=$BUFFER
- fc -p -a /dev/null 0 0
- BUFFER=
-
zstyle -a :bracketed-paste-magic inactive-keys bpm_inactive
if zstyle -s :bracketed-paste-magic active-widgets bpm_active '|'; then
- # There are active widgets. Reprocess $PASTED as keystrokes.
- NUMERIC=1
- zle -U - $PASTED
-
+ # Save context, create a clean slate for the paste
+ integer bpm_mark=$MARK bpm_region=$REGION_ACTIVE
+ integer bpm_numeric=${NUMERIC:-1}
+ integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
+ BUFFER=
+ CURSOR=1
+ zle .split-undo
+ UNDO_LIMIT_NO=$UNDO_CHANGE_NO
+ fc -p -a /dev/null 0 0
if [[ $bmp_keymap = vicmd ]]; then
zle -K viins
fi
+ # There are active widgets. Reprocess $PASTED as keystrokes.
+ NUMERIC=1
+ zle -U - "$PASTED"
+
# Just in case there are active undo widgets
- zle .split-undo
- integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
- UNDO_LIMIT_NO=$UNDO_CHANGE_NO
while [[ -n $PASTED ]] && zle .read-command; do
PASTED=${PASTED#$KEYS}
@@ -175,7 +174,7 @@ bracketed-paste-magic() {
case $REPLY in
(${~bpm_active}) function () {
emulate -L $bpm_emulate; set -$bpm_opts
- zle $REPLY
+ zle $REPLY -w
};;
(*) zle .self-insert;;
esac
@@ -183,21 +182,16 @@ bracketed-paste-magic() {
done
PASTED=$BUFFER
- # Reset the undo state
- zle undo $bpm_undo
- UNDO_LIMIT_NO=$bpm_limit
-
+ # Restore state
zle -K $bpm_keymap
+ fc -P
+ MARK=$bpm_mark
+ REGION_ACTIVE=$bpm_region
+ NUMERIC=$bpm_numeric
+ zle .undo $bpm_undo
+ UNDO_LIMIT_NO=$bpm_limit
fi
- # Restore state
- BUFFER=$bpm_buffer
- MARK=$bpm_mark
- CURSOR=$bpm_cursor
- REGION_ACTIVE=$bpm_region
- NUMERIC=$bpm_numeric
- fc -P
-
# PASTED has been updated, run the paste-finish functions
if zstyle -a :bracketed-paste-magic paste-finish bpm_hooks; then
for bpm_func in $bpm_hooks; do
@@ -212,7 +206,7 @@ bracketed-paste-magic() {
# Reprocess $PASTED as an actual paste this time
zle -U - $PASTED$'\e[201~' # append paste-end marker
- zle .bracketed-paste
+ zle .bracketed-paste -- "$@"
zle .split-undo
# Arrange to display highlighting if necessary