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

Re: Moving completion functions



On Mar 18, 10:20pm, Oliver Kiddle wrote:
} Subject: Re: Moving completion functions
}
} Bart wrote:
} > Aliasing is not the only reason for making compinit a function.
} 
} More user's would understand what they are doing when told to source a
} file than the autoloading. And, it would avoid the zsh always setting
} fpath stuff that I mentioned my dislike for before.

What exactly would you like fpath to contain by default?  Nothing?

The current scheme doesn't set fpath just to get the Completion functions;
it also sets it to get the stuff from the Functions subdirectory, etc.

If we remove the Completion directories from the default fpath, then we
must also give up --enable-function-subdirs.  Not that we can't use the
subdirs for installation, but that we must hardwire the installation so
that compinit can know what to add to fpath.  Even then, compinit needs
to get the base path (to which to append /Completion/...) from somewhere.

Either that, or compinit needs to become a manufactured file, built from
a .in that can substitute the necessary fpath from configure.  I don't
find that a particularly exciting prospect.

Issues of setting fpath aside, the following patch makes it possible to
source compinit.  (Not committed yet, pending further discussion.)  One
thing that bothers me a bit is that the (ARGC=0) test will give the wrong
result if compinit is sourced from within some other function; as far as
I can tell, there's no completely reliable way to determine that "source"
(or ".") is in progress.

Index: Completion/Core/compinit
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Completion/Core/compinit,v
retrieving revision 1.75
diff -c -r1.75 compinit
--- Completion/Core/compinit	2001/03/19 02:32:16	1.75
+++ Completion/Core/compinit	2001/03/19 04:13:16
@@ -65,6 +65,8 @@
 # queried for whether to use or ignore the insecure directories (which
 # means compinit should not be called from non-interactive shells).
 
+compinit() {
+
 emulate -L zsh
 setopt extendedglob
 
@@ -481,3 +483,11 @@
 autoload -U compinit compaudit
 
 return 0
+
+}
+
+# Find out if this file is being read with "source" or ".", or called as
+# an autoloaded function, and re-call as appropriate.
+
+local -i ARGC	# Harmless if sourced, removes readonly if autoloaded.
+{ (ARGC=0) 2>/dev/null && [[ -o kshautoload ]] } || compinit "$@"


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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