From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 962 invoked from network); 9 Jun 1999 06:16:33 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jun 1999 06:16:33 -0000 Received: (qmail 10303 invoked by alias); 9 Jun 1999 06:15:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6534 Received: (qmail 10296 invoked from network); 9 Jun 1999 06:15:48 -0000 From: "Bart Schaefer" Message-Id: <990609061505.ZM28357@candle.brasslantern.com> Date: Wed, 9 Jun 1999 06:15:04 +0000 In-Reply-To: <199906090243.TAA01218@bebop.clari.net> Comments: In reply to Wayne Davison "Completion and global aliases" (Jun 8, 7:43pm) References: <199906090243.TAA01218@bebop.clari.net> X-Mailer: Z-Mail (5.0.0 30July97) To: Wayne Davison , "ZSH workers mailing list" Subject: PATCH: Re: Completion and global aliases MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 8, 7:43pm, Wayne Davison wrote: } Subject: Completion and global aliases } } It seems to me like we need the code that runs the completion } scripts to switch over to its own options/aliases/whatever-else } and then switch back when it finishes. I was about to say that the right thing would be to load all completion code (i.e. run compinit) before any aliases are defined, but that would still leave any autoloaded functions to get mishandled. So how about this: We add an option to `autoload' to mark the function as immune to alias expansion. It's a small change to execautofn() to recognize this flag and temporarily set the noaliases global. Then it's just up to `compinit' to deal with its own problems, maybe by doing some smart things with `disable -a'. The following patch implements `autoload -U ...' for this. Hmm, I didn't change `functions' to output anything for "unaliased" state; should it? Index: Completion/Core/compdump =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Completion/Core/compdump,v retrieving revision 1.2 diff -u -r1.2 compdump --- compdump 1999/04/20 16:13:52 1.2 +++ compdump 1999/06/09 06:06:57 @@ -74,7 +74,7 @@ # print them out: about five to a line looks neat while (( $#_d_als )); do - print -n autoload + print -n autoload -U for (( _i = 0; _i < 5; _i++ )); do if (( $#_d_als )); then print -n " $_d_als[1]" Index: Completion/Core/compinit =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Completion/Core/compinit,v retrieving revision 1.10 diff -u -r1.10 compinit --- compinit 1999/06/08 15:01:40 1.10 +++ compinit 1999/06/09 05:28:23 @@ -194,7 +194,7 @@ # and probably do autoloading. func="$1" - [[ -n "$autol" ]] && autoload "$func" + [[ -n "$autol" ]] && autoload -U "$func" shift case "$type" in @@ -363,7 +363,7 @@ fi ;; (\#autoload) - autoload ${_i_file:t} + autoload -U ${_i_file:t} ;; esac done Index: Doc/Zsh/builtins.yo =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Doc/Zsh/builtins.yo,v retrieving revision 1.22 diff -u -r1.22 builtins.yo --- builtins.yo 1999/06/07 05:42:42 1.22 +++ builtins.yo 1999/06/09 06:13:15 @@ -981,12 +981,13 @@ ) item(tt(-f))( The names refer to functions rather than parameters. No assignments -can be made, and the only other valid flags are tt(-t) -and tt(-u). The flag tt(-t) turns on execution tracing for this -function. The flag tt(-u) causes this function to be marked -for autoloading. The tt(fpath) parameter will be searched to find the -function definition when the function is first referenced; see -noderef(Functions). +can be made, and the only other valid flags are tt(-t), tt(-u) and +tt(-U). The flag tt(-t) turns on execution tracing for this +function. The tt(-u) and tt(-U) flags cause the function to be +marked for autoloading; tt(-U) also causes alias expansion to be +suppressed when the function is loaded. The tt(fpath) parameter +will be searched to find the function definition when the function +is first referenced; see noderef(Functions). ) item(tt(-i))( Use an internal integer representation. If var(n) is nonzero it Index: Src/builtin.c =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/builtin.c,v retrieving revision 1.28 diff -u -r1.28 builtin.c --- builtin.c 1999/05/31 19:06:05 1.28 +++ builtin.c 1999/06/09 05:22:39 @@ -43,7 +43,7 @@ BUILTIN(".", BINF_PSPECIAL, bin_dot, 1, -1, 0, NULL, NULL), BUILTIN(":", BINF_PSPECIAL, bin_true, 0, -1, 0, NULL, NULL), BUILTIN("alias", BINF_MAGICEQUALS, bin_alias, 0, -1, 0, "Lgmr", NULL), - BUILTIN("autoload", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "t", "u"), + BUILTIN("autoload", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "tU", "u"), BUILTIN("bg", 0, bin_fg, 0, -1, BIN_BG, NULL, NULL), BUILTIN("break", BINF_PSPECIAL, bin_break, 0, 1, BIN_BREAK, NULL, NULL), BUILTIN("bye", 0, bin_break, 0, 1, BIN_EXIT, NULL, NULL), @@ -64,7 +64,7 @@ BUILTIN("false", 0, bin_false, 0, -1, 0, NULL, NULL), BUILTIN("fc", BINF_FCOPTS, bin_fc, 0, -1, BIN_FC, "nlreIRWAdDfEim", NULL), BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL), - BUILTIN("functions", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "mtu", NULL), + BUILTIN("functions", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "mtuU", NULL), BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"), BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL), BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "dfmrv", NULL), @@ -1824,17 +1824,18 @@ int on = 0, off = 0; /* Do we have any flags defined? */ - if (ops['u'] || ops['t']) { - if (ops['u'] == 1) - on |= PM_UNDEFINED; - else if (ops['u'] == 2) - off |= PM_UNDEFINED; - - if (ops['t'] == 1) - on |= PM_TAGGED; - else if (ops['t'] == 2) - off |= PM_TAGGED; - } + if (ops['u'] == 1) + on |= PM_UNDEFINED; + else if (ops['u'] == 2) + off |= PM_UNDEFINED; + if (ops['U'] == 1) + on |= PM_UNALIASED|PM_UNDEFINED; + else if (ops['U'] == 2) + off |= PM_UNALIASED; + if (ops['t'] == 1) + on |= PM_TAGGED; + else if (ops['t'] == 2) + off |= PM_TAGGED; if (off & PM_UNDEFINED) { zwarnnam(name, "invalid option(s)", NULL, 0); Index: Src/exec.c =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/exec.c,v retrieving revision 1.22 diff -u -r1.22 exec.c --- exec.c 1999/05/29 10:02:05 1.22 +++ exec.c 1999/06/09 05:15:40 @@ -2752,7 +2752,13 @@ execautofn(Cmd cmd) { Shfunc shf = cmd->u.autofn->shf; - List l = getfpfunc(shf->nam); + int noalias = noaliases; + List l; + + noaliases = (shf->flags & PM_UNALIASED); + l = getfpfunc(shf->nam); + noaliases = noalias; + if(l == &dummy_list) { zerr("%s: function definition file not found", shf->nam, 0); return 1; Index: Src/zsh.h =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/zsh.h,v retrieving revision 1.26 diff -u -r1.26 zsh.h --- zsh.h 1999/05/31 19:06:06 1.26 +++ zsh.h 1999/06/09 04:50:07 @@ -948,7 +948,12 @@ #define PM_READONLY (1<<8) /* readonly */ #define PM_TAGGED (1<<9) /* tagged */ #define PM_EXPORTED (1<<10) /* exported */ + +/* The following are the same since they * + * both represent -U option to typeset */ #define PM_UNIQUE (1<<11) /* remove duplicates */ +#define PM_UNALIASED (1<<11) /* do not expand aliases when autoloading */ + #define PM_TIED (1<<12) /* array tied to colon-path or v.v. */ #define PM_SPECIAL (1<<13) /* special builtin parameter */ #define PM_DONTIMPORT (1<<14) /* do not import this variable */ -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com