zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Wayne Davison <wayne@clari.net>,
	"ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Subject: PATCH: Re: Completion and global aliases
Date: Wed, 9 Jun 1999 06:15:04 +0000	[thread overview]
Message-ID: <990609061505.ZM28357@candle.brasslantern.com> (raw)
In-Reply-To: <199906090243.TAA01218@bebop.clari.net>

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


  reply	other threads:[~1999-06-09  6:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-09  2:43 Wayne Davison
1999-06-09  6:15 ` Bart Schaefer [this message]
1999-06-09  7:48   ` PATCH: " Peter Stephenson
1999-06-09 15:40     ` Bart Schaefer
1999-06-09  8:53 Sven Wischnowsky
1999-06-09  9:17 ` Andrej Borsenkow
1999-06-09  9:01   ` Peter Stephenson
1999-06-09 16:49     ` Bart Schaefer
1999-06-09 17:05       ` Andrej Borsenkow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=990609061505.ZM28357@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=wayne@clari.net \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).