Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: 3.1.5-pws-8: dumping completions for speed
- X-seq: zsh-workers 5402
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: 3.1.5-pws-8: dumping completions for speed
- Date: Tue, 16 Feb 1999 16:15:47 +0100 (MET)
- In-reply-to: Sven Wischnowsky's message of Tue, 16 Feb 1999 15:23:38 +0100 (MET)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I wrote:
> Peter Stephenson wrote:
>
> > 4) I just made it check for $0.dump in init, so if it had to search the
> > path for init, it won't find init.dump (that's why perl sets $0 to a full
> > path name).
>
> How about making this the default, but if the user has set a parameter
> (COMPDUMP or something) and that contains the name of a file, source
> that one?
The patch below adds this (set COMPDUMP to the file name you want to
use before dotting init, $0.dump is the default).
It also adds an experimental auto-dumping. If the parameter AUTODUMP
is set to `yes' when init is dotted, it will automatically dump the
state on first invocation or if it thinks the number completion files
has changed. Hm, does this look like the right thing?
Bye
Sven
diff -u of/Completion/dump Functions/Completion/dump
--- of/Completion/dump Tue Feb 16 16:04:04 1999
+++ Functions/Completion/dump Tue Feb 16 16:13:05 1999
@@ -11,6 +11,14 @@
#
# It relies on KSH_ARRAYS not being set.
+# Print the number of files used for completion. This is used in init
+# to see if auto-dump should re-dump the dump-file.
+
+__d_files=( ${^~fpath}/__*~*~ )
+
+print "#files: $#__d_files"
+
+unset __d_files
# First dump the arrays comps, patcomps and keycomps; the middle one
# is an ordinary array, the other two are associative. The
diff -u of/Completion/init Functions/Completion/init
--- of/Completion/init Tue Feb 16 15:03:00 1999
+++ Functions/Completion/init Tue Feb 16 16:10:40 1999
@@ -208,10 +208,20 @@
fi
}
+__i_files=( ${^~fpath}/__*~*~ )
+__i_initname=$0
+__i_dumpname=${COMPDUMP-$0.dump}
+__i_done=''
-if [[ -f $0.dump ]]; then
- . $0.dump
-else
+if [[ -f $__i_dumpname ]]; then
+ read -rA __i_line < $__i_dumpname
+ if [[ "$AUTODUMP" != yes || $__i_line[2] -eq $#__i_files ]]; then
+ builtin . $__i_dumpname
+ __i_done=yes
+ fi
+ unset __i_line
+fi
+if [[ -z "$__i_done" ]]; then
# Now we make the files automatically autoloaded.
for __i_dir in $fpath; do
[[ $__i_dir = . ]] && continue
@@ -254,4 +264,8 @@
done
unset __i_dir __i_line __i_file
+
+ [[ "$AUTODUMP" = yes ]] && builtin . ${__i_initname:h}/dump > $__i_dumpname
fi
+
+unset __i_files __i_initname __i_dumpname __i_done
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author