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

RE: ISUFFIX



Ebourne, Martin wrote (quite some time ago):

> ...
> 
> If I complete after the E as in
> 	MODULE=value
> it does nothing. But if I complete after the E as in
> 	MODULEvalue
> it goes to
> 	MODULE_PATH value

Problem is that this is caught deep in the guts of completion (in
get_comp_string()). There it simply prohibits completion when the
cursor is before the equal sign. Due to the quoting problematic in the
first word I don't see another solution than to introduce a new
special context (name `-assign-parameter-' in the shell code).


Bye
  Sven

Index: Completion/Zsh/Context/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/.distfiles,v
retrieving revision 1.2
diff -u -r1.2 .distfiles
--- Completion/Zsh/Context/.distfiles	29 Jun 2001 05:53:12 -0000	1.2
+++ Completion/Zsh/Context/.distfiles	1 Jul 2002 08:20:34 -0000
@@ -1,6 +1,6 @@
 DISTFILES_SRC='
 .distfiles
-_autocd
+_assign           _autocd
 _brace_parameter  _equal            _math             _subscript
 _condition        _first            _parameter        _tilde
 _default          _in_vared         _redirect         _value
Index: Completion/Zsh/Context/_assign
===================================================================
RCS file: Completion/Zsh/Context/_assign
diff -N Completion/Zsh/Context/_assign
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Zsh/Context/_assign	1 Jul 2002 08:20:34 -0000
@@ -0,0 +1,3 @@
+#compdef -assign-parameter-
+
+_parameters -g "^*readonly*" -S ''
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.158
diff -u -r1.158 compsys.yo
--- Doc/Zsh/compsys.yo	26 Jun 2002 11:07:46 -0000	1.158
+++ Doc/Zsh/compsys.yo	1 Jul 2002 08:20:34 -0000
@@ -2515,6 +2515,10 @@
 for completing the name of a parameter expansion within braces
 (`tt(${...})').
 )
+kindex(-assign-parameter-, completion context)
+item(tt(-assign-parameter-))(
+for completing the name of a parameter in an assignment.
+)
 kindex(-command-, completion context)
 item(tt(-command-))(
 for completing in a command position.
Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.33
diff -u -r1.33 compwid.yo
--- Doc/Zsh/compwid.yo	4 Jan 2002 12:09:31 -0000	1.33
+++ Doc/Zsh/compwid.yo	1 Jul 2002 08:20:35 -0000
@@ -158,6 +158,9 @@
 when completing the name of a parameter in a parameter expansion beginning
 with tt(${).
 )
+item(tt(assign_parameter))(
+when completing the name of a parameter in a parameter assignment.
+)
 item(tt(command))(
 when completing for a normal command (either in command position or for
 an argument of the command).
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.38
diff -u -r1.38 zsh.h
--- Src/zsh.h	20 Jun 2002 16:39:58 -0000	1.38
+++ Src/zsh.h	1 Jul 2002 08:20:35 -0000
@@ -1318,6 +1318,8 @@
 #define IN_COND    3
 /* In a parameter assignment (e.g. `foo=bar'). */
 #define IN_ENV     4
+/* In a parameter name in an assignment. */
+#define IN_PAR     5
 
 
 /******************************/
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.61
diff -u -r1.61 compcore.c
--- Src/Zle/compcore.c	26 Jun 2002 11:07:46 -0000	1.61
+++ Src/Zle/compcore.c	1 Jul 2002 08:20:35 -0000
@@ -553,6 +553,8 @@
 	compparameter = compredirect = "";
 	if (ispar)
 	    compcontext = (ispar == 2 ? "brace_parameter" : "parameter");
+        else if (linwhat == IN_PAR)
+            compcontext = "assign_parameter";
 	else if (linwhat == IN_MATH) {
 	    if (insubscr) {
 		compcontext = "subscript";
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.37
diff -u -r1.37 zle_tricky.c
--- Src/Zle/zle_tricky.c	13 May 2002 09:32:00 -0000	1.37
+++ Src/Zle/zle_tricky.c	1 Jul 2002 08:20:35 -0000
@@ -1256,12 +1256,25 @@
 		insubscr = 2;
 	    else
 		insubscr = 1;
-	} else if (*s == '=' && cs > wb + (s - tt)) {
-	    s++;
-	    wb += s - tt;
-	    t0 = STRING;
-	    s = ztrdup(s);
-	    inwhat = IN_ENV;
+	} else if (*s == '=') {
+            if (cs > wb + (s - tt)) {
+                s++;
+                wb += s - tt;
+                s = ztrdup(s);
+                inwhat = IN_ENV;
+            } else {
+                char *p = s;
+
+                if (p[-1] == '+')
+                    p--;
+                sav = *p;
+                *p = '\0';
+                inwhat = IN_PAR;
+                s = ztrdup(tt);
+                *p = sav;
+                we = wb + p - tt;
+            }
+            t0 = STRING;
 	}
 	lincmd = 1;
     }

-- 
Sven Wischnowsky                          wischnow@xxxxxxxxx



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