about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-01-28 19:13:39 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2014-01-28 19:13:39 -0800
commit8d3d34cfa46c1bfdd0e473e3942edfa45f66e47c (patch)
tree9c8b60e4f8acefdab3045f9d656b8cfd804399c6
parenta2098b0b26b47917cc725b387c63d75dfe0098f2 (diff)
parent584ea888115e48da43b01b5f5a7e1511a469f081 (diff)
downloadzsh-8d3d34cfa46c1bfdd0e473e3942edfa45f66e47c.tar.gz
zsh-8d3d34cfa46c1bfdd0e473e3942edfa45f66e47c.tar.xz
zsh-8d3d34cfa46c1bfdd0e473e3942edfa45f66e47c.zip
Merge branch 'master' of git://git.code.sf.net/p/zsh/code
Conflicts:
	ChangeLog
-rw-r--r--ChangeLog15
-rw-r--r--Completion/Zsh/Context/_brace_parameter3
-rw-r--r--Completion/Zsh/Type/_parameters5
-rw-r--r--Src/Zle/compcore.c14
-rw-r--r--Src/Zle/zle_main.c2
-rw-r--r--Src/Zle/zle_vi.c27
6 files changed, 62 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fdffb7cba..c9037b3ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,22 @@
+2014-01-28  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 32303: Src/Zle/compcore.c, Completion/Zsh/Type/_parameters,
+	Completion/Zsh/Context/_brace_parameter: allow completion
+	of modifiers for parameters in a fairly simplistic way.
+
+2014-01-28  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 32308 (slightly modified to use "a" as the vi command at start
+	of line): Src/Zle/zle_main.c, Src/Zle/zle_vi.c: improve
+	initialising of vi mode change when entering viins at start of
+	editing.
+
 2014-01-27  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* users/18368: Completion/Unix/Command/_git: in __git_files,
 	retry ls-files if nothing matched the prefix pattern, to give
 	_multi_parts a shot at the whole file list.  Restores partial
-	path completion inadvertently removed by 31159.
+	 path completion inadvertently removed by 31159.
 
 2014-01-27  Peter Stephenson  <p.stephenson@samsung.com>
 
diff --git a/Completion/Zsh/Context/_brace_parameter b/Completion/Zsh/Context/_brace_parameter
index c0ecf251b..2aeb12bf4 100644
--- a/Completion/Zsh/Context/_brace_parameter
+++ b/Completion/Zsh/Context/_brace_parameter
@@ -185,6 +185,9 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then
   )
   _describe -t flags "parameter flag" flags -Q -S ''
   return
+elif compset -P '*:'; then
+    _history_modifiers p
+    return
 fi
 
 _parameters -e
diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters
index 5156e3e2d..eaad3ca9d 100644
--- a/Completion/Zsh/Type/_parameters
+++ b/Completion/Zsh/Type/_parameters
@@ -8,6 +8,11 @@
 
 local expl pattern fakes faked tmp pfilt
 
+if compset -P '*:'; then
+  _history_modifiers p
+  return
+fi
+
 pattern=(-g \*)
 zparseopts -D -K -E g:=pattern
 
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 5c5628a8d..ac7785ab7 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1260,6 +1260,20 @@ check_param(char *s, int set, int test)
 	    ispar = (br >= 2 ? 2 : 1);
 	    b[we-wb] = '\0';
 	    return b;
+	} else if (offs > e - s && *e == ':') {
+	    /*
+	     * Guess whether we are in modifiers.
+	     * If the name is followed by a : and the stuff after
+	     * that is either colons or alphanumerics we probably are.
+	     * This is a very rough guess.
+	     */
+	    char *offsptr = s + offs;
+	    for (; e < offsptr; e++) {
+		if (*e != ':' && !ialnum(*e))
+		    break;
+	    }
+	    ispar = (br >= 2 ? 2 : 1);
+	    return NULL;
 	}
     }
     return NULL;
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 040b7cb83..a2b20df25 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1204,7 +1204,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish)
      * no user operation to indicate this.
      */
     if (openkeymap("main") == openkeymap("viins"))
-	viinsert(NULL);
+	viinsert_init();
     selectlocalmap(NULL);
     fixsuffix();
     if ((s = getlinknode(bufstack))) {
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 173a49ef9..31f293387 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -67,6 +67,13 @@ int viinsbegin;
 static struct modifier lastmod;
 static int inrepeat, vichgrepeat;
 
+/**
+ * im: >= 0: is an insertmode
+ *    -1: skip setting insert mode
+ *    -2: entering viins at start of editing from clean --- don't use
+ *        inrepeat or lastchar, synthesise an i to enter insert mode.
+ */
+
 /**/
 static void
 startvichange(int im)
@@ -75,7 +82,7 @@ startvichange(int im)
 	insmode = im;
 	vichgflag = 1;
     }
-    if (inrepeat) {
+    if (inrepeat && im != -2) {
 	zmod = lastmod;
 	inrepeat = vichgflag = 0;
 	vichgrepeat = 1;
@@ -84,7 +91,11 @@ startvichange(int im)
 	if (vichgbuf)
 	    free(vichgbuf);
 	vichgbuf = (char *)zalloc(vichgbufsz = 16);
-	vichgbuf[0] = lastchar;
+	if (im == -2) {
+	    vichgbuf[0] = 'a';
+	} else {
+	    vichgbuf[0] = lastchar;
+	}
 	vichgbufptr = 1;
 	vichgrepeat = 0;
     }
@@ -303,6 +314,18 @@ viinsert(UNUSED(char **args))
     return 0;
 }
 
+/*
+ * Go to vi insert mode when we first start the line editor.
+ * Iniialises some other stuff.
+ */
+
+/**/
+void
+viinsert_init(void)
+{
+    startvitext(-2);
+}
+
 /**/
 int
 viinsertbol(UNUSED(char **args))