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

Re: Global aliases, eval, and completion (Re: Expanding interactively aliases)



Bart Schaefer wrote:

> On Feb 27, 11:11am, Sven Wischnowsky wrote:
> } Subject: Re: Global aliases, eval, and completion (Re: Expanding interacti
> }
> } Hmhm. Haven't looked through the completion functions yet, but below
> } is a patch to replace the (internal) `noaliases' with an option `ALIAS'.
> } Should I commit that?
> 
> I'd have left the internal `noaliases' as it was, and then tested the
> option in these two places:

Yes, I was torn in two, thinking that it might be useful somehow (no,
I don't know either...).

So, the patch below uses the option only in this place:

> } @@ -1556,8 +1551,8 @@
> }  
> }  	if (tok == STRING) {
> }  	    /* Check for an alias */
> } -	    an = noaliases ? NULL :
> } -		(Alias) aliastab->getnode(aliastab, yytext);
> } +	    an = opts[ALIASOPT] ?
> } +		(Alias) aliastab->getnode(aliastab, yytext) : NULL;
> }  	    if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
> }  				     inalmore)) {
> }  		inpush(an->text, INP_ALIAS, an);

but not here: (no need to use it here if we look it up at the only
place where aliases are expanded, which is the only place where
noaliases is used)

> } @@ -976,7 +977,7 @@
> }  
> }      /* This global flag is used to signal the lexer code if it should *
> }       * expand aliases or not.                                         */
> } -    noaliases = isset(COMPLETEALIASES);
> } +    opts[ALIASOPT] = !isset(COMPLETEALIASES);
> }  
> }      /* Find out if we are somewhere in a `string', i.e. inside '...', *
> }       * "...", `...`, or ((...)). Nowadays this is only used to find   *

The other hunks make noaliases be reset to its previous value in
several places just to be on the save side...

> } Should it (in options.c) use (OPT_ALL & ~OPT_SH) instead of OPT_ALL?
> 
> Turning off aliases when emulating sh sounds like the right thing to me.

No decision here, yet.


I've also renamed the option to `aliases'.  I was tempted to do that
yesterday but didn't know which one would sound better to English
speaking folks (esp. after Bart suggested `noalias' in 13529).


And this time I'm going to commit this.

Bye
 Sven

Index: Completion/Core/compinit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compinit,v
retrieving revision 1.16
diff -u -r1.16 compinit
--- Completion/Core/compinit	2001/02/16 14:57:50	1.16
+++ Completion/Core/compinit	2001/02/28 09:01:11
@@ -137,6 +137,7 @@
     NO_ksharrays
     NO_cshnullglob
     NO_allexport
+    NO_aliases
 )
 
 # These can hold names of functions that are to be called before/after all
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.13
diff -u -r1.13 options.yo
--- Doc/Zsh/options.yo	2001/02/14 17:58:13	1.13
+++ Doc/Zsh/options.yo	2001/02/28 09:01:12
@@ -53,6 +53,11 @@
 are changed from the default.
 
 startitem()
+pindex(ALIASES)
+cindex(aliases, expansion)
+item(tt(ALIASES) <D>)(
+Expand aliases.
+)
 pindex(ALL_EXPORT)
 cindex(export, automatic)
 item(tt(ALL_EXPORT) (tt(-a), ksh: tt(-a)))(
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.14
diff -u -r1.14 lex.c
--- Src/lex.c	2000/12/05 10:34:23	1.14
+++ Src/lex.c	2001/02/28 09:01:12
@@ -1556,7 +1556,7 @@
 
 	if (tok == STRING) {
 	    /* Check for an alias */
-	    an = noaliases ? NULL :
+	    an = (noaliases || unset(ALIASESOPT)) ? NULL :
 		(Alias) aliastab->getnode(aliastab, yytext);
 	    if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos ||
 				     inalmore)) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.6
diff -u -r1.6 options.c
--- Src/options.c	2000/08/10 16:19:12	1.6
+++ Src/options.c	2001/02/28 09:01:13
@@ -69,6 +69,7 @@
  * to avoid formatting problems.
  */
 static struct optname optns[] = {
+{NULL, "aliases",	      OPT_EMULATE|OPT_ALL,	 ALIASESOPT},
 {NULL, "allexport",	      OPT_EMULATE,		 ALLEXPORT},
 {NULL, "alwayslastprompt",    OPT_ALL,			 ALWAYSLASTPROMPT},
 {NULL, "alwaystoend",	      0,			 ALWAYSTOEND},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.24
diff -u -r1.24 zsh.h
--- Src/zsh.h	2000/12/05 10:34:23	1.24
+++ Src/zsh.h	2001/02/28 09:01:13
@@ -1305,6 +1305,7 @@
 
 enum {
     OPT_INVALID,
+    ALIASESOPT,
     ALLEXPORT,
     ALWAYSLASTPROMPT,
     ALWAYSTOEND,
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.44
diff -u -r1.44 compcore.c
--- Src/Zle/compcore.c	2001/01/18 14:41:40	1.44
+++ Src/Zle/compcore.c	2001/02/28 09:01:14
@@ -1237,7 +1237,7 @@
     LinkNode n;
     int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
     int tl, got = 0, i = 0, cur = -1, oll = ll, sl, remq;
-    int ois = instring, oib = inbackt, noffs = lp;
+    int ois = instring, oib = inbackt, noffs = lp, ona = noaliases;
     char *tmp, *p, *ns, *ol = (char *) line, sav, *qp, *qs, *ts, qc = '\0';
 
     s += lip;
@@ -1299,7 +1299,7 @@
 	}
 	i++;
     } while (tok != ENDINPUT && tok != LEXERR);
-    noaliases = 0;
+    noaliases = ona;
     strinend();
     inpop();
     errflag = zleparse = 0;
Index: Src/Zle/compctl.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compctl.c,v
retrieving revision 1.9
diff -u -r1.9 compctl.c
--- Src/Zle/compctl.c	2001/01/18 14:41:40	1.9
+++ Src/Zle/compctl.c	2001/02/28 09:01:15
@@ -2753,7 +2753,7 @@
     LinkNode n;
     int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
     int sl = strlen(ss), tl, got = 0, i = 0, cur = -1, oll = ll, remq;
-    int ois = instring, oib = inbackt;
+    int ois = instring, oib = inbackt, ona = noaliases;
     char *tmp, *p, *ns, *ol = (char *) line, sav, *oaq = autoq, *qp, *qs;
     char *ts, qc = '\0';
 
@@ -2813,7 +2813,7 @@
 	}
 	i++;
     } while (tok != ENDINPUT && tok != LEXERR);
-    noaliases = 0;
+    noaliases = ona;
     strinend();
     inpop();
     errflag = zleparse = 0;
@@ -3648,6 +3648,7 @@
 	LinkList foo = newlinklist();
 	LinkNode n;
 	int first = 1, ng = opts[NULLGLOB], oowe = we, oowb = wb;
+	int ona = noaliases;
 	char *tmpbuf;
 
 	opts[NULLGLOB] = 1;
@@ -3669,7 +3670,7 @@
 		addlinknode(foo, ztrdup(tokstr));
 	    first = 0;
 	} while (tok != ENDINPUT && tok != LEXERR);
-	noaliases = 0;
+	noaliases = ona;
 	strinend();
 	inpop();
 	errflag = zleparse = 0;
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.23
diff -u -r1.23 zle_tricky.c
--- Src/Zle/zle_tricky.c	2001/01/18 14:41:40	1.23
+++ Src/Zle/zle_tricky.c	2001/02/28 09:01:16
@@ -964,6 +964,7 @@
 get_comp_string(void)
 {
     int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0;
+    int ona = noaliases;
     char *s = NULL, *linptr, *tmp, *p, *tt = NULL;
 
     freebrinfo(brbeg);
@@ -1236,12 +1237,12 @@
 	    addedx = 0;
 	    goto start;
 	}
-	noaliases = 0;
+	noaliases = ona;
 	lexrestore();
 	return NULL;
     }
 
-    noaliases = 0;
+    noaliases = ona;
 
     /* Check if we are in an array subscript.  We simply assume that  *
      * we are in a subscript if we are in brackets.  Correct solution *
@@ -2138,7 +2139,7 @@
 doexpandhist(void)
 {
     unsigned char *ol;
-    int oll, ocs, ne = noerrs, err;
+    int oll, ocs, ne = noerrs, err, ona = noaliases;
 
     pushheap();
     metafy_line();
@@ -2165,7 +2166,7 @@
      * means that the expanded string is unusable.                       */
     err = errflag;
     noerrs = ne;
-    noaliases = 0;
+    noaliases = ona;
     strinend();
     inpop();
     zleparse = 0;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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