2000-04-01 22:43:43 +02:00
|
|
|
# This is a function to dump the definitions for new-style
|
1999-04-15 20:05:38 +02:00
|
|
|
# completion defined by 'compinit' in the same directory. The output
|
|
|
|
# should be directed into the "compinit.dump" in the same directory as
|
|
|
|
# compinit. If you rename init, just stick .dump onto the end of whatever
|
|
|
|
# you have called it and put it in the same directory. This is handled
|
|
|
|
# automatically if you invoke compinit with the option -d.
|
|
|
|
#
|
|
|
|
# You will need to update the dump every time you add a new completion.
|
|
|
|
# To do this, simply remove the .dump file, start a new shell, and
|
|
|
|
# create the .dump file as before. Again, compinit -d handles this
|
|
|
|
# automatically.
|
|
|
|
|
|
|
|
# Print the number of files used for completion. This is used in compinit
|
|
|
|
# to see if auto-dump should re-dump the dump-file.
|
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
emulate -L zsh
|
|
|
|
setopt extendedglob
|
|
|
|
|
|
|
|
typeset _d_file _d_f _d_bks _d_line _d_als
|
|
|
|
|
|
|
|
_d_file=${_comp_dumpfile-${0:h}/compinit.dump}.$HOST.$$
|
1999-04-15 20:05:38 +02:00
|
|
|
|
|
|
|
typeset -U _d_files
|
2000-04-01 22:43:43 +02:00
|
|
|
_d_files=( ${^~fpath:/.}/^([^_]*|*~|*.zwc)(N:t) )
|
1999-04-15 20:05:38 +02:00
|
|
|
|
|
|
|
print "#files: $#_d_files" > $_d_file
|
|
|
|
|
|
|
|
# First dump the arrays _comps and _patcomps. The quoting hieroglyphyics
|
|
|
|
# ensure that a single quote inside a variable is itself correctly quoted.
|
|
|
|
|
|
|
|
print "_comps=(" >> $_d_file
|
|
|
|
for _d_f in ${(ok)_comps}; do
|
2000-04-01 22:43:43 +02:00
|
|
|
print -r - "${(q)_d_f}" "${(q)_comps[$_d_f]}"
|
1999-04-15 20:05:38 +02:00
|
|
|
done >> $_d_file
|
|
|
|
print ")" >> $_d_file
|
|
|
|
|
|
|
|
print "\n_patcomps=(" >> $_d_file
|
2000-04-01 22:43:43 +02:00
|
|
|
for _d_f in "${(ok@)_patcomps}"; do
|
|
|
|
print -r - "${(q)_d_f}" "${(q)_patcomps[$_d_f]}"
|
|
|
|
done >> $_d_file
|
|
|
|
print ")" >> $_d_file
|
|
|
|
|
|
|
|
print "\n_postpatcomps=(" >> $_d_file
|
|
|
|
for _d_f in "${(ok@)_postpatcomps}"; do
|
|
|
|
print -r - "${(q)_d_f}" "${(q)_postpatcomps[$_d_f]}"
|
|
|
|
done >> $_d_file
|
|
|
|
print ")" >> $_d_file
|
|
|
|
|
|
|
|
print "\n_compautos=(" >> $_d_file
|
|
|
|
for _d_f in "${(ok@)_compautos}"; do
|
|
|
|
print -r - "${(q)_d_f}" "${(q)_compautos[$_d_f]}"
|
1999-04-15 20:05:38 +02:00
|
|
|
done >> $_d_file
|
|
|
|
print ")" >> $_d_file
|
|
|
|
|
|
|
|
print >> $_d_file
|
|
|
|
|
|
|
|
# Now dump the key bindings. We dump all bindings for zle widgets
|
|
|
|
# whose names start with a underscore.
|
|
|
|
# We need both the zle -C's and the bindkey's to recreate.
|
2000-04-01 22:43:43 +02:00
|
|
|
# We can ignore any zle -C which rebinds a standard widget (second
|
|
|
|
# argument to zle does not begin with a `_').
|
1999-04-15 20:05:38 +02:00
|
|
|
|
|
|
|
_d_bks=()
|
|
|
|
zle -lL |
|
|
|
|
while read -rA _d_line; do
|
2000-04-01 22:43:43 +02:00
|
|
|
if [[ ${_d_line[3]} = _* && ${_d_line[5]} = _* ]]; then
|
1999-04-15 20:05:38 +02:00
|
|
|
print -r - ${_d_line}
|
|
|
|
_d_bks=($_d_bks ${_d_line[3]})
|
|
|
|
fi
|
|
|
|
done >> $_d_file
|
|
|
|
bindkey |
|
|
|
|
while read -rA _d_line; do
|
|
|
|
if [[ ${_d_line[2]} = (${(j.|.)~_d_bks}) ]]; then
|
|
|
|
print -r "bindkey '${_d_line[1][2,-2]}' ${_d_line[2]}"
|
|
|
|
fi
|
|
|
|
done >> $_d_file
|
|
|
|
|
|
|
|
print >> $_d_file
|
|
|
|
|
|
|
|
|
|
|
|
# Autoloads: whence -w produces "_d_foo: function", so look for
|
|
|
|
# all functions beginning with `_'.
|
|
|
|
|
|
|
|
_d_als=($(whence -wm '_*' | sort |
|
|
|
|
while read -rA _d_line; do
|
|
|
|
[[ ${_d_line[2]} = function ]] && print -r - ${_d_line[1]%:}
|
|
|
|
done))
|
|
|
|
|
|
|
|
# print them out: about five to a line looks neat
|
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
_i=5
|
|
|
|
print -n autoload -U >> $_d_file
|
1999-04-15 20:05:38 +02:00
|
|
|
while (( $#_d_als )); do
|
2000-04-01 22:43:43 +02:00
|
|
|
if (( ! $+_compautos[$_d_als[1]] )); then
|
|
|
|
print -n " $_d_als[1]"
|
|
|
|
if (( _i-- && $#_d_als > 1 )); then
|
|
|
|
_i=5
|
|
|
|
print -n '\nautoload -U'
|
1999-04-15 20:05:38 +02:00
|
|
|
fi
|
2000-04-01 22:43:43 +02:00
|
|
|
fi
|
|
|
|
shift _d_als
|
1999-04-15 20:05:38 +02:00
|
|
|
done >> $_d_file
|
|
|
|
|
|
|
|
print >> $_d_file
|
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
for _i in "${(ok@)_compautos}"; do
|
|
|
|
print "autoload -U $_compautos[$_i] $_i" >> $_d_file
|
|
|
|
done
|
|
|
|
|
|
|
|
mv $_d_file ${_d_file%.$HOST.$$}
|
|
|
|
|
|
|
|
unfunction compdump
|
|
|
|
autoload -U compdump
|