about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-08-24 10:18:56 +0100
committerPeter Stephenson <pws@zsh.org>2015-08-24 10:18:56 +0100
commit2bc4680e3b3973451b9449f970de35afdb105c37 (patch)
tree0f51ad15656a74b98d27b923e76110365a99cb7b
parente5d5a76dce1cc488627c8623f0cd972c3d52644d (diff)
parent2e69ece5cfab850b8ba00b272f35ccdaf727c781 (diff)
downloadzsh-2bc4680e3b3973451b9449f970de35afdb105c37.tar.gz
zsh-2bc4680e3b3973451b9449f970de35afdb105c37.tar.xz
zsh-2bc4680e3b3973451b9449f970de35afdb105c37.zip
Merge branch 'master' of https://git.code.sf.net/p/zsh/code
-rw-r--r--ChangeLog26
-rw-r--r--Config/version.mk4
-rw-r--r--Functions/Zle/bracketed-paste-magic51
-rw-r--r--Src/Modules/zpty.c3
-rw-r--r--Src/Zle/zle_misc.c2
-rw-r--r--Src/Zle/zle_move.c4
-rw-r--r--Src/Zle/zle_vi.c2
-rw-r--r--Src/builtin.c11
-rw-r--r--Src/parse.c2
9 files changed, 87 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 4166fcbe4..a42d76487 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2015-08-23  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+	* users/20455: Src/Modules/zpty.c: do not use posix_openpt()
+	on OpenBSD
+
+2015-08-22  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 36274: Src/Zle/zle_vi.c: clear virangeflag when getvirange()
+	has an error (the next keystroke is not a motion/selection).
+
+	* 36273: Src/Zle/zle_move.c: teach endofline() and endoflinehist()
+	about invicmdmode() cursor placement.
+
+2015-08-21  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* unposted: Config/version.mk, Src/parse.c, Src/Zle/zle_misc.c:
+	update to 5.0.8-test-2 and fix some exports.
+
+2015-08-21  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 36266: Functions/Zle/bracketed-paste-magic: preserve emulation
+	and setopt context for init and finish functions, handle vi modes
+
+	* 36256: Src/builtin.c: local options should remain in effect
+	for "emulate -L" even if additional option settings are applied
+
 2015-08-21  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 36268: Test/C04funcdef.ztst: test for 36265.
diff --git a/Config/version.mk b/Config/version.mk
index 6f6d1bc7d..99a749ebf 100644
--- a/Config/version.mk
+++ b/Config/version.mk
@@ -27,5 +27,5 @@
 # This must also serve as a shell script, so do not add spaces around the
 # `=' signs.
 
-VERSION=5.0.8-dev-1
-VERSION_DATE='June 19, 2015'
+VERSION=5.0.8-test-2
+VERSION_DATE='August 21, 2015'
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index da106d1ac..daf5aec5a 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -40,7 +40,6 @@
 #  Also looked up in the context :bracketed-paste-magic, these styles
 #  each are a list of function names.  They are executed in widget
 #  context but are called as functions (NOT as widgets with "zle name").
-#  They also run in zsh emulation context set by bracketed-paste-magic.
 #  As with hooks, the functions are called in order until one of them
 #  returns a nonzero exit status.  The parameter PASTED contains the
 #  current state of the pasted text, other ZLE parameters are as usual.
@@ -68,7 +67,7 @@ zstyle -m :bracketed-paste-magic active-widgets '*' ||
 # TODO: rewrite this using match-words-by-style
 #
 backward-extend-paste() {
-    : emulate -LR zsh	# Already set by bracketed-paste-magic
+    emulate -L zsh
     integer bep_mark=$MARK bep_region=$REGION_ACTIVE
     if (( REGION_ACTIVE && MARK < CURSOR )); then
 	zle .exchange-point-and-mark
@@ -99,7 +98,7 @@ backward-extend-paste() {
 #       zstyle :bracketed-paste-magic:finish quote-style none
 #
 quote-paste() {
-    : emulate -LR zsh	# Already set by bracketed-paste-magic
+    emulate -L zsh
     local qstyle
     # If there's a quoting style, be sure .bracketed-paste leaves it alone
     zstyle -s :bracketed-paste-magic:finish quote-style qstyle && NUMERIC=1
@@ -117,16 +116,28 @@ quote-paste() {
 # Now the actual function
 
 bracketed-paste-magic() {
-    emulate -LR zsh
+    # Fast exit in the vi-mode cut-buffer context
+    if [[ "$LASTWIDGET" = *vi-set-buffer ]]; then
+	zle .bracketed-paste
+	return
+    fi
+
+    # Really necessary to go to this much effort?
+    local bpm_emulate="$(emulate)" bpm_opts="$-"
+
+    emulate -L zsh
     local -a bpm_hooks bpm_inactive
-    local PASTED bpm_func bpm_active
+    local PASTED bpm_func bpm_active bpm_keymap=$KEYMAP
 
     # Set PASTED and run the paste-init functions
     zle .bracketed-paste PASTED
     if zstyle -a :bracketed-paste-magic paste-init bpm_hooks; then
 	for bpm_func in $bpm_hooks; do
 	    if (( $+functions[$bpm_func] )); then
-		$bpm_func || break
+		function () {
+		    emulate -L $bpm_emulate; set -$bpm_opts
+		    $bpm_func || break
+		}
 	    fi
 	done
     fi
@@ -143,18 +154,37 @@ bracketed-paste-magic() {
         # There are active widgets.  Reprocess $PASTED as keystrokes.
 	NUMERIC=1
 	zle -U - $PASTED
+
+	if [[ $bmp_keymap = vicmd ]]; then
+	    zle -K viins
+	fi
+
+	# 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}
 	    if [[ $KEYS = ${(~j:|:)${(b)bpm_inactive}} ]]; then
 		zle .self-insert-unmeta
 	    else
 		case $REPLY in
-		    (${~bpm_active}) zle $REPLY;;
+		    (${~bpm_active}) function () {
+			emulate -L $bpm_emulate; set -$bpm_opts
+			zle $REPLY
+		    };;
 		    (*) zle .self-insert-unmeta;;
 		esac
 	    fi
 	done
 	PASTED=$BUFFER
+
+	# Reset the undo state
+	zle undo $bpm_undo
+	UNDO_LIMIT_NO=$bpm_limit
+
+	zle -K $bpm_keymap
     fi
 
     # Restore state
@@ -169,7 +199,10 @@ bracketed-paste-magic() {
     if zstyle -a :bracketed-paste-magic paste-finish bpm_hooks; then
 	for bpm_func in $bpm_hooks; do
 	    if (( $+functions[$bpm_func] )); then
-		$bpm_func || break
+		function () {
+		    emulate -L $bpm_emulate; set -$bpm_opts
+		    $bpm_func || break
+		}
 	    fi
 	done
     fi
@@ -187,6 +220,6 @@ bracketed-paste-magic() {
 }
 
 # Handle zsh autoloading conventions
-if [[ $zsh_eval_context = *loadautofunc && ! -o kshautoload ]]; then
+if [[ "$zsh_eval_context" = *loadautofunc && ! -o kshautoload ]]; then
     bracketed-paste-magic "$@"
 fi
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 12e42b5bd..9741ee287 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -154,7 +154,8 @@ getptycmd(char *name)
     return NULL;
 }
 
-#ifdef USE_DEV_PTMX
+/* posix_openpt() seems to have some problem on OpenBSD */
+#if defined(USE_DEV_PTMX) && !defined(__OpenBSD__)
 
 #ifdef HAVE_SYS_STROPTS_H
 #include <sys/stropts.h>
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index d25e4ebef..2d1862813 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -738,7 +738,7 @@ yankpop(UNUSED(char **args))
 }
 
 /**/
-char *
+mod_export char *
 bracketedstring(void)
 {
     static const char endesc[] = "\033[201~";
diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c
index f49df8647..155fda80d 100644
--- a/Src/Zle/zle_move.c
+++ b/Src/Zle/zle_move.c
@@ -344,6 +344,8 @@ endofline(char **args)
 	    zlecs = zlell;
 	    return 0;
 	}
+	if ((zlecs += invicmdmode()) == zlell)
+	    break;
 	if (zleline[zlecs] == '\n')
 	    if (++zlecs == zlell)
 		return 0;
@@ -414,6 +416,8 @@ endoflinehist(char **args)
 	    zlecs = zlell;
 	    break;
 	}
+	if ((zlecs += invicmdmode()) == zlell)
+	    break;
 	if (zleline[zlecs] == '\n')
 	    if (++zlecs == zlell)
 		break;
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 1a11ca7d5..42dc46e7e 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -224,6 +224,7 @@ getvirange(int wf)
 	    ZS_memcpy(zleline, lastline, zlell = lastll);
 	    zlecs = pos;
 	    mark = mpos;
+	    virangeflag = 0;
 	    return -1;
 	}
 
@@ -232,6 +233,7 @@ getvirange(int wf)
 	if (!zlell || (zlecs == pos && (mark == -1 || mark == zlecs) &&
 		    virangeflag != 2) || ret == -1) {
 	    mark = mpos;
+	    virangeflag = 0;
 	    return -1;
 	}
 	virangeflag = 0;
diff --git a/Src/builtin.c b/Src/builtin.c
index 3d34aa74c..97022addf 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5465,8 +5465,8 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
 
     /* with single argument set current emulation */
     if (!argv[1]) {
-	emulate(shname, OPT_ISSET(ops,'R'), &emulation, opts);
-	if (OPT_ISSET(ops,'L'))
+	emulate(shname, opt_R, &emulation, opts);
+	if (opt_L)
 	    opts[LOCALOPTIONS] = opts[LOCALTRAPS] = opts[LOCALPATTERNS] = 1;
 	clearpatterndisables();
 	return 0;
@@ -5476,7 +5476,7 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
     memcpy(saveopts, opts, sizeof(opts));
     memcpy(new_opts, opts, sizeof(opts));
     savehackchar = keyboardhackchar;
-    emulate(shname, OPT_ISSET(ops,'R'), &new_emulation, new_opts);
+    emulate(shname, opt_R, &new_emulation, new_opts);
     optlist = newlinklist();
     if (parseopts("emulate", &argv, new_opts, &cmd, optlist)) {
 	ret = 1;
@@ -5508,8 +5508,11 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
 	    goto restore2;
 	}
 	*--argv = cmd;	/* on stack, never free()d, see execbuiltin() */
-    } else
+    } else {
+	if (opt_L)
+	    opts[LOCALOPTIONS] = opts[LOCALTRAPS] = opts[LOCALPATTERNS] = 1;
 	return 0;
+    }
 
     save_sticky = sticky;
     sticky = hcalloc(sizeof(*sticky));
diff --git a/Src/parse.c b/Src/parse.c
index 09317610b..7c2d20250 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -66,7 +66,7 @@ int infor;
 /* != 0 if parsing arguments of typeset etc. */
 
 /**/
-int intypeset;
+mod_export int intypeset;
 
 /* list of here-documents */