From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 841 invoked from network); 16 Feb 1999 15:17:06 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Feb 1999 15:17:06 -0000 Received: (qmail 16585 invoked by alias); 16 Feb 1999 15:16:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5402 Received: (qmail 16578 invoked from network); 16 Feb 1999 15:16:29 -0000 Date: Tue, 16 Feb 1999 16:15:47 +0100 (MET) Message-Id: <199902161515.QAA02910@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Sven Wischnowsky's message of Tue, 16 Feb 1999 15:23:38 +0100 (MET) Subject: Re: PATCH: 3.1.5-pws-8: dumping completions for speed 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@informatik.hu-berlin.de