diff options
97 files changed, 17745 insertions, 3805 deletions
diff --git a/ChangeLog b/ChangeLog index a1a22e495..a811be6ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7003 @@ +2000-04-01 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 10376: LICENCE: new file, with licence as it appears + in some (but not all) files in distribution. + + * Bart: 10372: Doc/Zsh/builtins.yo, Doc/Zsh/mod_zutil.yo: + cross-reference builtin descriptions in modules. + + * Chmouel: 10370: zsh-3.1.6-dev-20/Completion/Linux/_rpm: rpm -p + handling. + + * Bart: 10368: Doc/Zsh/mod_zle.yo: improved bindkey -R description. + + * Oliver: 10367: Completion/Builtins/_nothing, + Completion/Builtins/_cd, Completion/Builtins/_emulate, + Completion/Builtins/_enable, Completion/Builtins/_disable, + Completion/Builtins/_fc: update some functions to use _arguments. + + * Bart: 10366: Doc/Zsh/builtins.yo: reword 10364. + + * Sven: 10364: Doc/Zsh/builtins.yo, Src/parse.c: -c and -a flags + for current and autoloadable functions are now orthogonal. + + * Bart: 10360: Doc/zsh.yo, Doc/Zsh/compctl.yo, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Doc/Zsh/manual.yo, Doc/Zsh/mod_compctl.yo, + Doc/Zsh/modules.yo, Doc/Zsh/zftpsys.yo, Doc/Zsh/zle.yo: reorder + completion manual entries. + + * Sven: 10358: Doc/Zsh/params.yo, Src/jobs.c, Src/params.c, + Src/zsh.h: $pipestatus gives return values for all commands in + pipeline. + + * Sven: 10353: Completion/Commands/_history_complete_word: + updated to use latest tags mechanism. + + * Sven: 10352: Src/exec.c: fix 10331 for script names. + +2000-03-30 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 10335: Functions/Misc/zrecompile: -[rm] should be -[RM] in + one more place. + + * Sven: 10332: Completion/Core/compinstall: temporary fix-up for + old compinstall. + + * Sven: 10331: Src/exec.c: keep old script name for autoloading. + + * Sven: 10329, 10334: Src/Zle/compmatch.c: ** in match specs. + + * Sven: 10328: Src/Zle/iwidgets.list, Src/Zle/zle_utils.c: undo + fixes for completion (don't need double undo any more) and + for history stuff. + + * Sven: 10327: Completion/Builtins/_autoload, + Completion/Builtins/_zcompile, Completion/Core/_path_files: new + and improved completions. + + * Bart: 10322: Test/11glob.ztst, Test/53completion.ztst: + more comprehensive globbing tests, plus problem when TERM is + too dumb in completion test. + +2000-03-29 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 10320: Src/pattern.c: freeing of buffer was messed up in + 10284. + +2000-03-28 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Bart: 10319: Doc/Zsh/compsys.yo: add kindex entry for tag-order. + + * Bart: 10317: Test/11glob.ztst: real glob tests to pick up ** and + ~ things. + + * Sven: 10311: Doc/Zsh/builtins.yo, Src/builtin.c, Src/parse.c: + zcompile -a to force functions marked for autoloading to be dumped + as wordcode. + + * Sven: 10310: Src/exec.c: arguments in kshautoloaded function + problem: keep old zsh way of doing things for now. + + * Sven: 10309: Completion/Base/_arguments, + Completion/Base/_describe, Completion/Base/_jobs, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Builtins/_compdef, + Completion/Builtins/_pids, Completion/Builtins/_popd, + Completion/Builtins/_sched, Completion/Builtins/_signals, + Completion/Builtins/_stat, Completion/Builtins/_zftp, + Completion/Builtins/_zpty, Completion/Builtins/_zstyle, + Completion/Core/.distfiles, Completion/Core/_alternative, + Completion/Core/_path_files, Completion/Core/_requested, + Completion/Core/_wanted, Completion/User/_gdb, + Completion/User/_getconf, Completion/User/_groups, + Completion/User/_lp, Completion/User/_make, Completion/User/_mh, + Completion/User/_netscape, Completion/User/_tiff, + Completion/User/_urls, Completion/User/_users, + Completion/User/_users_on, Completion/X/_x_colormapid, + Completion/X/_x_extension, Completion/X/_x_font, + Completion/X/_x_keysym, Completion/X/_x_window, + Completion/X/_xmodmap, Completion/X/_xutils, Completion/X/_xwit, + Doc/Zsh/compsys.yo, Etc/completion-style-guide, + Functions/Zftp/zfcd_match, Functions/Zftp/zfget_match: + rename _try by _next_label and _loop by _all_labels; files + themselves also renamed. + + * Clint: 10303: Doc/Zsh/params.yo, Src/params.c: restore + $MACHTYPE, run-time determination of $CPUTYPE. + +2000-03-27 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 10297: Doc/Zsh/builtins.yo, Functions/Misc/zrecompile, + Src/parse.c: restrict -c option not to work with -k, swap -r -m + and -R -M options. + + * Sven: 10294: Doc/Zsh/builtins.yo, Src/Modules/parameter.c, + Src/builtin.c, Src/cond.c, Src/exec.c, Src/hashtable.c, + Src/loop.c, Src/parse.c, Src/zsh.h: natural behaviour of autoload + +X for ksh-style autoloading. + + * Sven: 10293: Completion/Base/_default, + Completion/Commands/_complete_help, + Completion/Core/_main_complete, Doc/Zsh/compsys.yo: improve help + formatting and information content. + + * Sven: 10292: Completion/Core/_approximate, + Completion/Core/_complete, Completion/Core/_correct, + Completion/Core/_expand, Completion/Core/_ignored, + Completion/Core/_list, Completion/Core/_main_complete, + Completion/Core/_match, Completion/Core/_menu, + Completion/Core/_oldlist, Completion/Core/_path_files, + Completion/Core/_prefix, Doc/Zsh/compsys.yo: aliases for + completers; allow more flexibility with contexts at upper + levels. + +2000-03-26 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 10284: Src/pattern.c: exclusions with absolute path + didn't work; closures after exclusions in subdirectories crashed + the shell. + + * Sven: 10272, 10275: Doc/Zsh/builtins.yo, Src/builtin.c, Src/exec.c: + autoload can force zsh/ksh styles with -z, -k; integrate + execautofn() and loadautofn(). Side effect that -kX must run the + code to get at the function defintion. + + * Sven: 10273: Src/Zle/complete.c: problem with test for empty + prefix. + + * Sven: 10271: Completion/Core/_expand: _requested problem. + + * Sven: 10267: Completion/Builtins/_zstyle, + Completion/Commands/_next_tags, Completion/Core/_files, + Completion/Core/_tags, Doc/Zsh/compsys.yo, Src/Zle/computil.c: + better consistency between _file tags and other tags using + improved file-patterns style; remove tag-aliases style, better + done in other way.s + + * Bart: 10266: Doc/Zsh/compsys.yo: update for 10263. + + * Sven: 10265: Completion/Builtins/_zstyle, + Completion/Core/_approximate, Doc/Zsh/compsys.yo: tag-order and + file-patterns completions; subst-glob-only and _approximate + improvements. + + * Sven: 10264: Completion/Core/_call, Completion/Core/compdump, + Completion/Core/compinit, Doc/Zsh/compsys.yo, + Functions/Zle/incremental-complete-word, Functions/Zle/predict-on: + Allow options to #autoload tag; fix uses of force-list. + + * Bart: 10263: Doc/Zsh/compsys.yo, Doc/Zsh/index.yo, + Doc/Zsh/manual.yo, Doc/Zsh/zftpsys.yo: style and tags index, + removed unused key index. + + * Sven: 10262: Src/Zle/compcore.c: compadd -D problem. + + * Sven: 10260: Doc/Zsh/compwid.yo: resolve incompatibilities + between 10258 and 10230. + + * Sven: 10179: Src/text.c: a bit more safety in printing wordcode + structures. + + * Sven: 10233: Completion/X/_x_colormapid, Completion/X/_xwit: + some uses of tag aliases. + + * Sven: 10231: Completion/Builtins/_zstyle, + Completion/Commands/_next_tags, Completion/Core/_tags, + Doc/Zsh/compsys.yo, Src/Zle/computil.c: tag-order can take + patterns, new tag-aliases style, aliases starting with a hyphen + are appended to existing tag. + + * Sven: 10230: Completion/Builtins/_zstyle, + Completion/Core/_description, Completion/Core/_ignored, + Completion/Core/_main_complete, Completion/Core/_path_files, + Completion/Core/_prefix, Completion/Core/_setup, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, + Functions/Zle/incremental-complete-word, Src/Zle/comp.h, + Src/Zle/compcore.c, Src/Zle/complete.c, Src/Zle/compresult.c: + Remove builtin alternate matching and implement as _ignored + completer. + + * Bart: 10258: Doc/ztexi.yo, Doc/Zsh/builtins.yo, + Doc/Zsh/compctl.yo, Doc/Zsh/compwid.yo, Doc/Zsh/expn.yo, + Doc/Zsh/filelist.yo, Doc/Zsh/files.yo, Doc/Zsh/redirect.yo, + Doc/Zsh/zle.yo: more enhanced documentation. + + * Bart: 10250: Doc/Zsh/builtins.yo, Doc/Zsh/files.yo, + Doc/Zsh/func.yo: improved documentation for new wordcode dumping + and loading. + +2000-03-24 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Bart: 10243: Completion/User/_groups, Src/Modules/zpty.c: + 9897 and 10089 weren't merged properly; bit which got missed + out of 9981 because it was applied by hand. + + * Clint: 10242: configure.in, Src/params.c: determine $MACHTYPE at + run time. + +2000-03-23 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: 3.1.6-dev-20 + + * Tanaka Akira: 10234, 10236: Completion/X/_xwit: _message passing. + + * Tanaka Akira; 10232: Test/comptest, Test/ztst.zsh, ChangeLog(!): + minor test fixes and typo. + + * Sven: 10226: Completion/Core/_path_files: quoting problem. + + * Sven: 10225: Completion/Core/_path_files: dot problems with + files. + + * Tanaka Akira: 10223: Completion/Base/_regex_arguments, + Completion/X/_x_colormapid, Completion/X/_xwit: + new X completions. + + * Bart: 10218: Src/prompt.c: possible realloc() in + putpromptchar(). + +2000-03-22 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 10215: Completion/User/_nedit: and this one. + + * Sven: 10214: Completion/Builtins/_cd, + Completion/Builtins/_zstyle, Completion/User/_pbm, + Completion/User/_pspdf, Completion/User/_tiff, + Completion/User/_zdump: some _path_files calls now need loop for + tags. + + * Sven: 10210: Completion/Commands/_next_tags, + Completion/Core/_main_complete, Completion/Core/compinit, + Doc/Zsh/compsys.yo: _next_tags doesn't need to be in completer + list any more; $compprefuncs array does pre-completion functions. + + * Sven: 10209: Completion/Core/_loop, Completion/Core/_try: + missing functions form 10195. + + * 10204: Completion/Base/_arguments, Completion/Base/_values, + Completion/Core/_alternative, Completion/Core/_tags, + Completion/Core/_wanted, Src/Zle/computil.c: additions to 10195. + + * Sven: 10195: Completion/Base/_arguments, + Completion/Base/_brace_parameter, Completion/Base/_condition, + Completion/Base/_default, Completion/Base/_describe, + Completion/Base/_first, Completion/Base/_jobs, + Completion/Base/_math, Completion/Base/_parameter, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Builtins/_arrays, + Completion/Builtins/_autoload, Completion/Builtins/_bindkey, + Completion/Builtins/_builtin, Completion/Builtins/_cd, + Completion/Builtins/_command, Completion/Builtins/_compdef, + Completion/Builtins/_echotc, Completion/Builtins/_functions, + Completion/Builtins/_hash, Completion/Builtins/_limits, + Completion/Builtins/_pids, Completion/Builtins/_popd, + Completion/Builtins/_sched, Completion/Builtins/_signals, + Completion/Builtins/_stat, Completion/Builtins/_vars, + Completion/Builtins/_zftp, Completion/Builtins/_zle, + Completion/Builtins/_zmodload, Completion/Builtins/_zpty, + Completion/Builtins/_zstyle, Completion/Commands/_next_tags, + Completion/Core/_alternative, Completion/Core/_files, + Completion/Core/_main_complete, Completion/Core/_multi_parts, + Completion/Core/_options, Completion/Core/_parameters, + Completion/Core/_path_files, Completion/Core/_requested, + Completion/Core/_sep_parts, Completion/Core/_set_options, + Completion/Core/_setup, Completion/Core/_tags, + Completion/Core/_unset_options, Completion/Core/_wanted, + Completion/Debian/_apt, Completion/Debian/_deb_packages, + Completion/Linux/_rpm, Completion/User/_archie, + Completion/User/_cvs, Completion/User/_dd, + Completion/User/_domains, Completion/User/_gcc, + Completion/User/_gdb, Completion/User/_getconf, + Completion/User/_gprof, Completion/User/_groups, + Completion/User/_gs, Completion/User/_hosts, Completion/User/_lp, + Completion/User/_mailboxes, Completion/User/_make, + Completion/User/_man, Completion/User/_mh, Completion/User/_mount, + Completion/User/_mutt, Completion/User/_mysql_utils, + Completion/User/_netscape, Completion/User/_nslookup, + Completion/User/_pbm, Completion/User/_perl_basepods, + Completion/User/_perl_builtin_funcs, + Completion/User/_perl_modules, Completion/User/_ports, + Completion/User/_rcs, Completion/User/_rlogin, + Completion/User/_socket, Completion/User/_ssh, + Completion/User/_stty, Completion/User/_tar, + Completion/User/_telnet, Completion/User/_tiff, + Completion/User/_urls, Completion/User/_user_at_host, + Completion/User/_users, Completion/User/_users_on, + Completion/User/_whois, Completion/User/_yp, + Completion/X/_x_color, Completion/X/_x_cursor, + Completion/X/_x_display, Completion/X/_x_extension, + Completion/X/_x_font, Completion/X/_x_keysym, + Completion/X/_x_modifier, Completion/X/_x_window, + Completion/X/_xmodmap, Completion/X/_xutils, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_zutil.yo, Etc/completion-style-guide, + Functions/Zftp/zfcd_match, Functions/Zftp/zfget_match, + Src/Modules/zutil.c, Src/Zle/computil.c: implement tag aliases, + which allows neat tricks with styles. + + * Sven: 10197: Src/exec.c, Src/init.c: %_ sometimes got cmdstack + wrong in source(); $(...) didn't show up at all. + + * Bart: 10193: Src/prompt.c: prompttrunc() didn't track realloc()'s. + + * Bart: 10181: Functions/Prompts/prompt_bart_setup: Bart's Theme + and Variations. + + * Sven: 10178: Completion/Commands/_next_tags, Doc/Zsh/compsys.yo: + don't bind _next_tags by default and add some more docs. + + * Sven: 10176: Src/Zle/compresult.c, Src/init.c, Src/parse.c: + optimize list-packed. + + * Sven: 10174: Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo: tweaks on + completer and -V. + + * Bart: 10173: Functions/Prompts/prompt_bart_setup, + Functions/Prompts/promptinit: Bart's Theme. + + * Sven: 10172: Completion/Core/_main_complete: typo. + + * Bart: 10168: Src/init.c: move hbegin() to get it right in + precmd. + + * Oliver: 10166: Completion/X/_xt_arguments, + Completion/User/_nedit: new and improved. + + * Bart: 10165: Doc/Zsh/builtins.yo, Doc/Zsh/compsys.yo: move doc + for using a completer twice; zcompile doc tweak. + + * Oliver: 10162: Completion/Core/_expand: use nullglob option + instead of (N) so that user's qualifiers work. + + * Sven: 10159: Src/Zle/compresult.c: wrong calculation of display + length when not using zsh/complist. + + * Sven: 10156: Src/exec.c: possible invalid field in function + definition when loading. + + * Zefram: 10152: Src/mem.c: fix ordering ambiguity ANSI wouldn't + have liked. + + * Bart: 10150: Src/exec.c, Test/51xtrace.ztst: `one last' xtrace + redirection fix. + + * Sven: 10149: Doc/Zsh/builtins.yo, Src/builtin.c, Src/exec.c, + Src/parse.c: allows native and ksh-like wordcode function styles. + + * Sven: 10148: Src/Zle/comp.h, Src/Zle/compcore.c, Src/mem.c: + optimization for added matches where things didn't change. + + * Sven: 10146: Completion/Core/_sort_tags, Completion/Core/_tags, + Doc/Zsh/compsys.yo: return value of function called by _tags used + to decide dispositions. + + * Sven: 10145: Doc/Zsh/mod_zle.yo: confess to users that zle input + is on a stack. + + * Sven: 10144: Doc/Zsh/builtins.yo, Src/Modules/parameter.c, + Src/builtin.c, Src/exec.c, Src/linklist.c, Src/parse.c: dump + functions from current shell. + + * Sven: 10143: Src/init.c, Src/math.c: better ignoring of bits + that shouldn't get evaluated in math expressions. + + * Sven: 10135: Doc/Zsh/compsys.yo, Src/Zle/computil.c: complex + argument handling expressions. + + * Sven: 10131: Src/Modules/stat.c, Src/Modules/zpty.c, + Src/Modules/zutil.c, Src/Zle/compctl.c, Src/Zle/complete.c, + Src/Zle/computil.c, Src/Zle/zle_main.c, Src/Zle/zle_thingy.c, + Src/parse.c: more consistent zerrnam/zwarnnam usage. + + * Sven: 10129: Doc/Zsh/builtins.yo, Src/builtin.c, Src/parse.c: + autoload -w can mark all functions in .zwc files for autoloading. + + * Sven: 10128: Doc/Zsh/zle.yo, Src/Zle/zle_main.c, Src/init.c, + Src/signals.c, Src/zsh.h: zle parameters available readonly in + traps. + + * Sven: 10127: Doc/Zsh/zle.yo, Src/Zle/compresult.c, + Src/Zle/iwidgets.list, Src/Zle/zle_main.c, Src/Zle/zle_misc.c, + Src/Zle/zle_refresh.c, Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c: + end-of-list widget to display prompt under command line, plus + $MARK documentation. + + * Sven: 10126: Src/Zle/compcore.c: quotes in $PREFIX and $SUFFIX. + + * Sven: 10125: Src/math.c, Src/params.c: restore old cruddy + behaviour removed in 10104, but using recursion counter. + + * Sven: 10120: Src/exec.c, Src/loop.c, Src/parse.c: state not + tested properly in some constructs. + + * Sven: 10117: Doc/Zsh/mod_zle.yo, Src/Zle/zle_params.c, + Src/Zle/zle_thingy.c: zle on its own returns zle status; + MARK parameter; disallow widgets in traps. + + * Oliver: 10116: Completion/Builtins/_source: wasn't looking + through the path. + + * Sven: 10112: Completion/Base/_condition, Src/Zle/zle_tricky.c: + fix up altmodische _condition; `[[ ... && ' thought it was in + command position for completion. + + * Sven: 10108: Completion/Commands/.distfiles, + Completion/Commands/_next_tags, Completion/Core/_files, + Completion/Core/_main_complete, Completion/Core/_requested, + Completion/Core/_wanted, Doc/Zsh/compsys.yo, + Functions/Misc/.distfiles: _next_tags allows you to cycle through + sets of completions according to the tags. + + * Sven: 10107: Doc/Zsh/compwid.yo, Src/Zle/complete.c, + Src/Zle/compmatch.c: ** in match spec allows matching including + the anchor as well. + + * Sven: 10106: Functions/Misc/zrecompile, Src/exec.c, Src/parse.c, + Src/zsh.h: recompilation of wordcode files and related bugs. + + * Sven: 10105: Src/lex.c: single exclamation marks in conditions. + + * Sven: 10104: Src/math.c, Src/params.c: retrieve parameters in + math evaluations more directly rather than recursively calling + matheval(), which was kind of stupid, so stupid I could quite + possible have put it in myself, but I don't think I did this time. + + * Sven: 10103: Src/glob.c: bad handling of ./ and ../ in + closures. + + * Bart: 10098: configure.in, Src/cond.c: check for AIX's + faccessx() and neaten configure library function tests. + + * Oliver: 10088: Completion/User/_groups, + Completion/Base/_condition: better handling of files after + conditions, checking of use of NIS. + + * Adam: 10087: Completion/User/_perl_modules, + Completion/User/_perl: new and enhanced perl completions. + + * Oliver: 10073: Src/cond.c: /dev/fd emulation for access tests. + + * Adam: 10072: Completion/User/_mysql_utils: new completion + function for something with suspcicious `SQL' bit in its name. + + * Bart: 10071: Src/exec.c: xtrace output redirection problem. + + * Sven: 10059: Src/builtin.c, Src/lex.c, Src/parse.c, Src/text.c, + Src/zsh.h: bugs found by ksh tests: typeset -Ai didn't create + assocs (still doesn't create ints), some heredoc difficulties, |& + difficulties. + + * Alexandre: 10058: Completion/User/_prcs, Completion/User/_diff, + Completion/User/_diff_options: another solution for the GNU diff + completion problem. + + * Bart: 10056: Etc/MACHINES: RLIM_INFINITY incompatibility with + some Linux/GNU libraries. + + * Sven: 10044: Completion/User/_diff, Completion/User/_use_lo: + gdiff should use diff completion, pretty obviously. + + * Sven: 10041: Doc/Zsh/builtins.yo, Doc/Zsh/files.yo, + Doc/Zsh/func.yo, Src/init.c, Src/parse.c: enhancements for digest + files including digests of sourced files. Or maybe digestion of + sauce. + + * Sven: 10040: Completion/User/_diff_options: can test for GNU + diff. + + * Oliver: 10029: Src/utils.c: bad handling of '^^' in keystring + parsing. + + * Andrej: 10028: Completion/Builtins/_cd: remove local directory + from cdpath. + + * Sven: 10025: Functions/Misc/nslookup, Src/Modules/zpty.c: + optimizations for pty reads. + + * Sven: 10017: Doc/Zsh/builtins.yo, Src/lex.c, Src/parse.c: + fix buffer problem for autoloading and unportable macro. + + * Oliver: 10013: Completion/Builtins/_compdef, + Completion/Builtins/_zpty, Completion/User/_getconf: two new + functions and one updated. + + * Andrej: 10011: Completion/User/_sudo: options for recent sudo. + + * Bart: 10009: Completion/Base/_subscript: didn't get arrays the + right length. + + * Bart: 10006: configure.in, Src/utils.c: use mktemp() if + available. + + * Bart: 9992: Functions/Zle/predict-on: tweaks. + + * Bart: 9990: Test/07cond.ztst: compatibility fix for chmod g+s. + + * Bart: 9982: Test/53completion.ztst, Test/Makefile.in, + Test/comptest, Test/ztst.zsh: better handling of uninstalled + modules. + + * Andrej: 9981: Src/Modules/zpty.c: SYSV-related pty stuff. + + * Bart: 9980: Src/Makefile.in: separate mymods.conf and xmods.conf + dependencies. + + * Sven: 9966: Doc/Zsh/builtins.yo, Doc/Zsh/func.yo, Src/parse.c: + require .zwc ending for digest files. + + * Bart: 9963: Test/11glob.ztst: existing globbing tests run under + new test harness. + + * Bart: 9961: INSTALL, Src/Makefile.in, Test/53completion.ztst, + Test/comptest: errors trying to load zpty for static shell in + tests; INSTALL didn't describe mymods.conf properly. + + * Tanaka Akira: 9960: Test/comptest, Test/53completion.ztst: avoid + zpty timing problem. + + * Sven: 9958: Src/parse.c: sharing strings made test fail with + new wordcode. + + * Tanaka Akira: 9957: Test/comptest: clear to end. + + * Sven: 9953: Src/Zle/complist.c: was incorrectly omitting some + display sequences. + + * Tanaka Akira: 9952: Test/comptest: compatibility, quoting and + debugging fixes. + + * Sven: 9951: Completion/Core/_multi_parts: was producing + mysterious blank entries. + + * Sven: 9948: Src/exec.c, Src/parse.c: stripkshdef() was broken. + + * Sven: 9947: Completion/Core/compdump, Completion/Core/compinit, + Doc/Zsh/builtins.yo, Doc/Zsh/func.yo, Src/builtin.c, Src/cond.c, + Src/exec.c, Src/glob.c, Src/lex.c, Src/loop.c, Src/math.c, + Src/mem.c, Src/parse.c, Src/text.c, Src/utils.c, Src/zsh.h: + Wordcode compilation for functions using .zwc or `digest + functions' in $fpath. + + * Bart: 9946: Src/subst.c: return type in 9937. + + * Bart: 9945: Src/prompt.c: truncation messed up non-literal + parts of the prompt. + + * Bart: 9942: Src/prompt.c: truncation in true part of ternary + expression incorrectly showed false part and closing parenthesis. + + * Sven: 9937: Src/subst.c: parsing problem with parameter + substitution which showed up in file completion. + + * Sven: 9938: Src/Modules/parameter.c: problem assigning to + dirstack. + + * Tanaka Akira: 9936: Src/Zle/complist.c, Test/comptest, + Test/53completion.ztst: tests for completion using zpty. + + * Tanaka Akira: 9935: Test/52zregexparse.ztst: tests for + zregexparse. + +2000-03-21 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9920: Completion/Core/.distfiles, Completion/Core/_call: + the function needed for 9897. + + * Bart: 9912: Completion/User/_mailboxes: further improvements. + + * Sven: 9904: Src/utils.c: getquery() and rmstarsilent. + + * Sven: 9902: Completion/Core/_path_files: _files -g problem. + + * Sven: 9900, 9903: Src/exec.c: parsing oddity in here documents. + + * 9897: Completion/Base/_arguments, Completion/Builtins/_pids, + Completion/Linux/_rpm, Completion/User/_a2ps, + Completion/User/_archie, Completion/User/_diff_options, + Completion/User/_finger, Completion/User/_groups, + Completion/User/_gs, Completion/User/_killall, + Completion/User/_lp, Completion/User/_telnet, + Completion/User/_users_on, Completion/User/_yp, + Completion/X/_x_font, Completion/X/_x_window, Doc/Zsh/compsys.yo: + use _call function and `command' style to override command + used in various completions. + + * Sven: 9895: Completion/Base/_combination, + Completion/Builtins/_zstyle, Completion/User/_telnet, + Doc/Zsh/compsys.yo: usage of combination styles. + + * Sven: 9893: Completion/Core/_multi_parts: return values. + + * Sven: 9892: Completion/Core/_main_complete, + Completion/Core/_path_files, Completion/Core/compdump, + Completion/Core/compinit: improved fix for 9886; typo in + _main_complete; compdump uses (q) flag; remove compstyle; update + compconf. + + * Bart: 9891: Completion/User/_cvs: kshautoload problem. + + * Bart: 9889: acconfig.h, configure.in, Src/exec.c, + Src/prototypes.h: from 3.0.8: detect mknod(), minor redirection + tweaks. + + * Bart: 9886: Completion/Core/_path_files: matcher problem. + + * Tanaka Akira: 9885: Completion/User/_dvi, Completion/User/_lynx, + Completion/X/_xutils: extra arguments for completion functions. + + * Alexandre: 9882: Completion/User/_prcs: error messages. + + * Sven: 9880: Completion/Core/_path_files: error message with + ~unknown. + + * Sven: 9879: Completion/User/_tilde_files: use of magicequalsubst + with completion. + + * Sven: 9877: Src/parse.c: wordcode bug in functions with failed + builtins. + + * Sven: 9876: Completion/Base/_combination, + Completion/User/_rlogin, Completion/User/_ssh, + Completion/User/_user_at_host, Doc/Zsh/compsys.yo: more flexible + handling of separators in combinations. + + * Sven: 9870: Completion/Core/_path_files, + Completion/User/.distfiles, Completion/User/_dd, + Completion/User/_tilde_files, Src/Zle/compresult.c: better + handling of paths beginning ~ in various places. + + * Sven: 9865: Completion/Builtins/_zstyle, + Completion/Core/_main_complete, Completion/Core/_setup, + Doc/Zsh/compsys.yo, Src/Zle/compcore.c, Src/Zle/compresult.c: + implement prefer-ignored style to prefer alternative matches + to going on to another completer. + + * Sven: 9863: Src/parse.c, Src/text.c: wordcode problems, using + old code. + + * Sven: 9861: Completion/Core/_main_complete: interaction of + _main_complete and _oldlist. + + * Sven: 9860: Src/Zle/compctl.c: storing of match and display list. + + * Sven: 9855: Completion/Core/_multi_parts, Doc/Zsh/compsys.yo: + _multi_parts accepts -f. + +2000-02-23 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9845: Functions/Zle/incremental-complete-word: another + context change. + + * Sven: 9844: Functions/Zle/predict-on: rationalize 9837. + + * Sven: 9840: config.sub: test for alphaev6 systems. + + * Sven: 9839: Src/Builtins/sched.c, Src/Modules/example.c, + Src/Modules/mapfile.c, Src/Modules/parameter.c, + Src/Modules/zftp.c, Src/Modules/zprof.c, Src/Modules/zpty.c, + Src/Modules/zutil.c, Src/Zle/compcore.c, Src/Zle/compctl.c, + Src/Zle/complete.c, Src/Zle/complist.c, Src/Zle/compresult.c, + Src/Zle/computil.c, Src/Zle/zle_hist.c, Src/Zle/zle_main.c, + Src/Zle/zle_misc.c, Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, + Src/Zle/zleparameter.c, Src/builtin.c, Src/cond.c, Src/exec.c, + Src/glob.c, Src/hist.c, Src/init.c, Src/jobs.c, Src/lex.c, + Src/linklist.c, Src/loop.c, Src/main.c, Src/math.c, Src/mem.c, + Src/module.c, Src/params.c, Src/parse.c, Src/pattern.c, + Src/prompt.c, Src/signals.c, Src/subst.c, Src/utils.c, Src/zsh.h: + Eliminate `useheap' variable and consequent HEAPALLOC/PERMALLOC + usage throughout the shell (hooray!) All memory allocation is + either explicitly on the heap or permanent. + + * Sven: 9838: Src/Modules/parameter.c, Src/Zle/computil.c, + Src/Zle/zle_main.c, Src/builtin.c, Src/cond.c, Src/exec.c, + Src/glob.c, Src/hashtable.c, Src/init.c, Src/jobs.c, Src/lex.c, + Src/linklist.c, Src/loop.c, Src/params.c, Src/parse.c, + Src/signals.c, Src/signals.h, Src/subst.c, Src/text.c, + Src/version.h, Src/zsh.h: parser now emits wordcode directly; a + whole heap of optimisations of the execution tree. + + * Sven: 9837: Completion/User/_gunzip, Functions/Zle/predict-on: + no. of colons in predict-on, typo in _gunzip. + + * Sven: 9835: Completion/Builtins/_zstyle, + Completion/Core/_main_complete, Doc/Zsh/compsys.yo: document + single-ignored style, better handling of descriptions with + warnings about no matches. + + * Bart: 2930: Completion/User/_ssh: basic completion for remote + files. + +2000-02-22 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9831: Completion/Core/_multi_parts: better separator + removal. + + * Sven: 9830: Completion/X/_x_arguments: reverse 9824, but use + _default instead of _files if no special arguments. + + * Bart: 9828: Completion/User/_mailboxes: $i -> "$i" missed out. + +2000-02-21 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Clint: 9824: Completion/X/_x_arguments: `*/X11/*' was too broad + a definition for X commands taking standard arguments to be + useful. + + * Clint: 9823: configure.in: open fifo read/write in test to avoid + possible (unconfirmed) hang. + + * Bart: 9822: Completion/User/_mailboxes: add completions for mush + and tkrat; allow pine to complete mh folders. + + * Sven: 9816: Completion/Core/_multi_parts, + Completion/User/_mailboxes: improved version of 9812/9815. + + * Bart: 9812, 9815: Completion/User/_mailboxes, + Completion/User/_mutt: improved mailbox completion for all sorts + of types, currently only used for mutt. + + * Sven: 9810: Completion/Core/_multi_parts: difficulties with + separator as initial character. + + * Sven: 9809: Completion/Builtins/_popd, + Completion/Core/_approximate, Doc/Zsh/compsys.yo: documentation + improvements and typo fixes. + + * Tanaka Akira/Sven: 9807: Completion/Core/_main_complete: + single-ignored style, as yet undocumented, for handling of + alternate match set. + + * Sven: 9806: Completion/Core/_multi_parts: problems with literal + (parenthesised) arrays. + + * Sven: 9805: Completion/Core/_path_files: difficulties with + suffixes when expanding paths. + + * Sven: 9802: Src/utils.c: no need to quote !'s in ${(qq)...} + because they're not active in single quotes. + + * Bart: 9799: Src/utils.c: better interpretation of typeahead when + querying user e.g. for spell checking. + + * Adam: 9798: Doc/Makefile.in: use `texi' and `html' for targets + to avoid duplicated name complaint by gmake. + +2000-02-20 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: 3.1.6-dev-19. + + * Bart: 9794: Src/exec.c, Test/.distfiles, Test/51xtrace.ztst: + pick up some problems with 9792. + +2000-02-19 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Bart: 9792: Src/builtin.c, Src/cond.c, Src/exec.c, Src/init.c, + Src/loop.c, Src/utils.c: `xtrerr' replaces stderr for output from + xtrace, to avoid problems with redirection. + + * Sven: 9791: Completion/X/_x_arguments: complete filenames by + default. + + * Sven: 9790: Completion/Builtins/_zstyle, + Completion/Core/.distfiles, Completion/Core/_message, + Completion/X/_x_borderwidth, Completion/X/_x_geometry, + Completion/X/_x_locale, Completion/X/_x_name, + Completion/X/_x_resource, Completion/X/_x_selection_timeout, + Completion/X/_x_title, Doc/Zsh/compsys.yo: arguments problem with + _x_geometry; matcher-list completed in zstyle. + + * Sven: 9787: Completion/Core/_expand, Src/utils.c: parameter + expansion problems expanding; problem quoting in backquoted + expressions. + + * Chmouel: 9784: Completion/User/_tar, + Completion/User/_tar_archive: obsolete -y option for bzip2 filter. + + * Chmouel: 9781: Completion/Linux/_rpm: add --freshen. + +2000-02-17 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9777: Src/Zle/compctl.c, Src/Zle/zle_tricky.c, Src/exec.c, + Src/glob.c, Src/subst.c: yet more difficulties with completing + brace-expanded expressions. + + * Sven: 9776: Completion/Core/_main_complete, Src/glob.c, + Src/params.c: substitution bugs: ${foo[1,1]...} was treated + incorrectly as a scalar rather than an array slice; extra + duplication required when performing replacement on parameter. + + * Sven: 9775: Completion/Core/_path_files: extra array copy + required. + + * Sven: 9774: Src/Zle/compresult.c: completion inserted some + incorrect strings. + + * Sven: 9773: Completion/Core/_multi_parts, + Completion/User/_groups, Completion/User/_ports, + Completion/User/_users, Doc/Zsh/compsys.yo: remove some + unnecessary tags which are more logically expressed by an empty + tag field in the context. + + * Sven: 9772: Completion/Core/_approximate, + Completion/Core/_description, Completion/Core/_expand, + Completion/Core/_list, Completion/Core/_main_complete, + Completion/Core/_match, Completion/Core/_menu, + Completion/Core/_oldlist, Completion/Core/_prefix, + Doc/Zsh/compsys.yo: matcher-list style replaces matcher; + _matcher completer is now defunct. + + * Sven: 9770: Src/Zle/computil.c: bogus empty descriptions. + + * Sven: 9768: Completion/Core/_path_files: completing empty + directories. + +2000-02-16 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Oliver: 9761: Completion/Core/_expand: auto-removable suffixes. + + * Oliver: 9752: Completion/Core/_expand: subst-globs-only style + bails out if no globs expanded. + + * Sven: 9765: Completion/Core/_sep_parts: problems with separators + with metacharacters. + + * Sven: 9764: Completion/Core/_multi_parts, + Completion/Core/_path_files, Doc/Zsh/compsys.yo: problems with + _oldlist in _multi_parts; new -i option to complete _multi_parts + bits in one go if possible. + + * Sven: 9763: Src/subst.c: addition to 9757. + + * Sven: 9759: Completion/Base/_default, Doc/Zsh/compsys.yo, + Src/Zle/comp.h, Src/Zle/compcore.c, Src/Zle/compctl.c, + Src/Zle/complete.c: use-compctl style to use existing compctls; + on by default if zsh/compctl is loaded; extra hook needed to allow + compctl to clear up if invoked via new completion. + + * Sven: 9757: Src/subst.c: quoting with ${(e)...}. + +2000-02-15 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9755: Completion/Core/_sep_parts: typo. + + * Bart: 9750: Src/jobs.c, Src/signames2.awk, + Src/Modules/parameter.c: better handling for signals received by + shell which were not in the range found when configuring (e.g. if + OS was upgraded). + + * Sven: 9749: Src/Zle/zle_tricky.c: completion in braces. + + * Sven: 9746: Src/Zle/compctl.c: broken old-style completion. + + * Sven: 9734: Doc/Zsh/compwid.yo: descriptions for matching. + + * Sven: 9733: Completion/Core/_main_complete, + Completion/Core/_setup: can't set defaults ZLS_COLORS and + SELECTMIN inside completion functions, because they may already + have been set. + + * Sven: 9732: Src/Zle/complist.c: bad test without + alwayslastprompt. + + * Sven: 9731: Completion/Base/_arguments, + Completion/Base/_describe, Completion/Base/_jobs, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Builtins/_pids, Completion/Builtins/_popd, + Completion/Builtins/_sched, Completion/Builtins/_signals, + Completion/Builtins/_stat, Completion/Core/_approximate, + Completion/Core/_files, Completion/Core/_main_complete, + Completion/Core/_normal, Completion/Core/_path_files, + Completion/Core/_setup, Completion/Core/_tags, + Completion/Core/compinit, Completion/Debian/_apt, + Completion/User/_lp, Completion/User/_socket, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c: Style defaults are now + hard-wired in, so all user styles take precedence without having + to delete existing patterns; _complete is now the default + completer in every context, including non-completion widgets. + +2000-02-14 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9722: Completion/Commands/_expand_word, + Src/Zle/compcore.c, Src/Zle/complist.c: last_prompt, expansion + problems. + + * Sven: 9713: Completion/Base/_arguments, Src/Zle/computil.c: two + more arguments problems. + + * Sven: 9711: Completion/Commands/_complete_help: number of colons + in context brought up to date. + + * Sven: 9710: Completion/Core/_files, Completion/Core/_path_files, + Src/Modules/zutil.c: a few random bugs: sorting of styles, bad + directory completion, globbing problems. + + * Zefram: 9709: Src/mkmodindex.sh: should be global subst in 9701. + + * Sven: 9705: Src/exec.c: comment esprefork, esglob. + + * Sven: 9704: Completion/Core/_path_files: incorrect parameter + name. + +2000-02-13 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9701: INSTALL, configure.in, Config/defs.mk.in, + Src/Makefile.in, Src/mkmodindex.sh: allow --enable-omit-modules=foo,... + to omit a list of modules from compilation and installation. + + * Tanaka Akira: 9697: Completion/User/.distfiles, + Completion/User/_ps, Completion/User/_psutils: completion for all + psutils commands. + + * Bart: 9694: Src/init.c: more portable attempt to force shell to + suspend if running interactively in background. + + * Oliver: 9693: Src/params.c, Src/Zle/compcore.c, + Src/Zle/complete.c: AIX module exports. + +2000-02-11 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Bart: 9684: Completion/User/_mailboxes: sort of help find + mailboxes with + prefix. + + * Bart: 2913: Completion/User/_mutt: don't set muttrc. + + * pws: Config/version.mk: 3.1.6-dev-18 + + * Tanaka Akira: 9683: Completion/User/_diff_options: shut up error + messages (after other attempts from Oliver and Bart). + + * Alexandre: 9681: Completion/User/_prcs: argument handling. + + * Sven: 9680: Completion/Core/_files, + Completion/Core/_multi_parts, Completion/Core/_path_files, + Completion/Core/_sep_parts: use of -M option. + + * Sven: 9677, 9679: Completion/Commands/_read_comp, + Completion/Core/_approximate, Completion/Core/_expand, + Completion/Core/_main_complete, Completion/Core/_match, + Doc/Zsh/compctl.yo, Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, + Src/Zle/comp.h, Src/Zle/compcore.c, Src/Zle/compctl.c, + Src/Zle/complete.c: $compmatchers bites the dust, use new matcher + style. + + * Sven: 9676: Src/Zle/computil.c: yet more argument subtleties. + + * Tanaka Akira: 9674: Test/10prompt.ztst: some nameless idiot got + the bits of the date wrong. + + * Sven: 9664: Completion/Core/_path_files: optimisation with + arrays. + + * Sven: 9659: Doc/Zsh/compsys.yo: mention complete-in-words + behaviour. + + * Sven: 9657: Completion/Core/_approximate, + Completion/Core/_description, Completion/Core/_main_complete, + Completion/Core/_matcher, Completion/Core/_path_files, + Completion/Core/_prefix, Doc/Zsh/compsys.yo, Src/Zle/complete.c + (plus Completion/Core/.distfiles change by hand): new _matcher + completer allows more control along the lines of $compmatchers. + + * Johan: 9653: Functions/Misc/is-at-least, + Functions/Misc/.distfiles (added by hand): function to check + version numbers. + + * Johan: 9651: Completion/User/_cvs: handle no CVS tags case better. + + * Sven: 9650: Completion/User/_gunzip, Completion/User/_gzip: + handle .tgz files. + + * Sven: 9648: Completion/Core/_files, + Completion/Core/_multi_parts, Completion/Core/_path_files, + Completion/Core/_sep_parts, Doc/Zsh/mod_zutil.yo, + Src/Modules/zutil.c: Bartised version of zparseopts; + fix _path_files -S ''. + + * Bart: 9639: Doc/Zsh/options.yo, Doc/Zsh/redirect.yo: typos in + 9625. + + * Tanaka Akira: 9638: Completion/User/_cvs: _cvs_rtag had no + default implementation. + + * Sven: 9635: Completion/Core/_description, + Completion/Core/_files, Completion/Core/_multi_parts, + Completion/Core/_path_files, Completion/Core/_sep_parts, + Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c, Src/Modules/zutil.mdd: + improved performance for completion functions; option-parsing + builtin. + + * Akim Demaille <akim@epita.fr>: 9634: Src/builtin.c: trap '' 1 + segfaulted. + + * Sven: 9633: Src/init.c: change logic in 9591. + + * Sven: 9632: Test/05command.ztst: error spotted by improved + autoload error checking. + + * Alexandre: 9625: Src/zsh.h, Src/options.c, Src/init.c, + Src/exec.c, Doc/Zsh/redirect.yo, Doc/Zsh/options.yo: SHNULLCMD and + CSHNULLCMD options to allow better sh/csh emulation without + fiddling with parameters. + + * Sven: 9623: Completion/Core/_path_files: another version of + 9616. + + * Sven: 9621: Src/Zle/computil.c: completion incorrectly adding + space. + + * Sven: 9619: Completion/User/_texi: completion for texinfo; + added Completion/User/.distfiles by hand. + + * Sven: 9618: Src/Zle/computil.c: memory leak in caching. + + * Sven: 9616: Completion/Core/_path_files: bad test with a + pattern. + + * Sven: 9615: Completion/Builtins/_zstyle, Doc/Zsh/compsys.yo: + rename and document some styles. + + * Sven: 9614: Src/exec.c: esglob wasn't initialised properly. + + * Alexandre: 9606: Completion/Builtins/_zstyle: two missing + styles. + + * Sven: 9600: Src/exec.c: wordcode problem in execpline(). + + * Bart: 9591: Src/init.c: zsh/compctl didn't get loaded + automatically any more. + + * Geoff: 9589: Doc/Makefile.in: put back ^A's from 9584. + + * Tanaka Akira: 9585: Doc/Makefile.in: possible logic problems + with 9584. + + * Geoff: 9584: Doc/Makefile.in: sh problems with creating + modlist.yo. + + * Alexandre: 9583: Functions/Misc/nslookup: fix context name for + new scheme. + + * Sven: 9390, 9394, hunk from 9396: ./Doc/Makefile.in, + Doc/Zsh/mod_zpty.yo, Doc/Zsh/.distfiles, Functions/Misc/nslookup, + Src/Modules/.distfiles, Src/Modules/zpty.c, Src/Modules/zpty.mdd, + Src/builtin.c, Src/init.c, Src/zsh.h: zpty module. + +2000-02-05 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9579: Completion/Debian/_deb_packages: was using + bad cache variable. + +2000-02-04 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9569: Completion/Core/_main_complete, + Completion/Core/_prefix, Doc/Zsh/compsys.yo, Src/Zle/compcore.c: + new complete-prefix completer _prefix; fix suffix matching + problems. + + * Sven: 9568: Src/Zle/computil.c: fix difficulties with remaining + arguments. + + * Sven: 9562: Completion/Base/_arg_compile, + Completion/Base/_arguments, Completion/Base/_command_names, + Completion/Builtins/_hash, Completion/User/_gdb, + Completion/User/_ssh, Completion/User/_strip, Completion/X/_xrdb, + Completion/X/_xutils, Src/Zle/computil.c: failure to follow links + completing commands; bad long option handling in some cases + + * Sven: 9560 (second hunk only): Src/Zle/computil.c: more + argument fixes. + + * Sven: 9559: Doc/Zsh/compsys.yo: better documentation for `+' + argument handling. + + * Sven: 9558: Src/exec.c, Src/parse.c: trapping of autoloading + errors wasn't up to scratch. + + * Alexandre: 9557: Completion/User/_flex: problem handling + `+' argument. + +2000-02-03 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Oliver: 9547: Src/parse.c, Src/hist.c: more fixups for exporting + on AIX. + + * Sven: 9546: Completion/Base/_arguments, + Completion/Base/_combination, Completion/Base/_describe, + Completion/Base/_first, Completion/Base/_jobs, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Builtins/_pids, + Completion/Builtins/_popd, Completion/Builtins/_sched, + Completion/Builtins/_signals, Completion/Builtins/_stat, + Completion/Builtins/_zftp, Completion/Builtins/_zstyle, + Completion/Commands/_complete_help, + Completion/Commands/_correct_word, + Completion/Commands/_expand_word, + Completion/Commands/_history_complete_word, + Completion/Core/_alternative, Completion/Core/_approximate, + Completion/Core/_complete, Completion/Core/_correct, + Completion/Core/_description, Completion/Core/_expand, + Completion/Core/_files, Completion/Core/_list, + Completion/Core/_main_complete, Completion/Core/_match, + Completion/Core/_menu, Completion/Core/_message, + Completion/Core/_normal, Completion/Core/_oldlist, + Completion/Core/_path_files, Completion/Core/_setup, + Completion/Core/_sort_tags, Completion/Core/_tags, + Completion/Core/compinit, Completion/Debian/_apt, + Completion/Debian/_deb_packages, Completion/User/_cvs, + Completion/User/_domains, Completion/User/_groups, + Completion/User/_hosts, Completion/User/_ports, + Completion/User/_socket, Completion/User/_urls, + Completion/User/_users, Completion/X/_x_color, Doc/Zsh/compsys.yo, + Etc/completion-style-guide, + Functions/Zle/incremental-complete-word, Functions/Zle/predict-on: + more consistent form for style contexts in completion system, + :completion:<func>:<completer>:<command>:<argument>:<tag>. + + * Sven: 9545: Src/Modules/zutil.c: don't use freed structs. + + * Tanaka Akira: 9544: Src/Modules/zutil.c: handle case for + undefined match data in zregexparse. + + * Sven: 9542: Src/Zle/complete.c: use permanently allocated memory + for copied special parameters. + + * Sven: 9541: Src/Modules/zutil.c: zstyle looks up style names + first. + +2000-02-02 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: version 3.1.6-dev-17 + + * Bart: 9533: Src/signals.c: make sure shell doesn't send itself + SIGHUP when exiting. + + * Sven: 9528: Completion/Core/_files: missing variable + initialization. + + * Sven: 9527: Doc/Zsh/compsys.yo: extra description for styles. + + * Sven: 9526: Src/Zle/computil.c: missing tokenization in + completion listing. + + * Sven: 9524: Src/text.c: wordcode bug outputting function + definitions. + + * Sven: 9522: Src/utils.c: return on various conditions when + reading a character from the terminal. + + * Sven: 9521: Src/exec.c: another job-waiting fix. + +2000-02-01 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9518: Test/.distfiles, Test/10prompt.ztst: test for prompt + escapes. + + * Clint/Sven: 9500 rewritten as 9505: Src/mem.c: more graceful exit + after mmap() failure when used for heap allocation. + + * Alexandre: 9504: Completion/Builtins/_zstyle: complete name of + packageset style. + + * Sven: 9503: Src/exec.c: problem updating job entry without any + processes. + + * Alexandre: 9502: Completion/User/_urls, + Completion/Core/compinit, Completion/Core/_menu, + Completion/Core/_match, Completion/Base/_combination: fix 9463 + to use ':completion:...' prefix with zstyle. + +2000-01-31 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9496: Src/loop.c: failure to check for return status in + for loop. + + * Bart: 9495: Src/exec.c: re-block after waiting for jobs. + + * Sven: 9494: Src/Zle/computil.c: extraneous space with option + description. + + * Bart: 9493: Test/09funcdef.ztst: regression test for function + definition. + + * Sven: 9489: Src/Zle/complist.c, Src/Zle/compresult.c: avoid menu + selection with no list and asking whether to list twice. + + * Sven: 9488: Src/exec.c: remove unnecessary child_block(). + + * Sven: 9487: Src/exec.c: wordcode fix: expand names in function + definitions. + + * Sven: 9486: Doc/Zsh/compwid.yo: fix docs for compadd -1 with -J + +2000-01-30 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9476: Completion/User/_cvs, + Completion/User/_patch: prefer LC_ALL to LANG as the former + overrides the latter. + + * Tanaka Akira: 9475: Completion/User/_telnet: simplify by using + (K) parameter flag. + + * Tanaka Akira: 9473: Completion/User/_patch: improved support for + different versions of `patch'. + + * Bart: 9472: Doc/Makefile.in: dependencies on texinfo files when + building out of source tree. + + * Tanaka Akira: 9470: Completion/Debian/_deb_packages: updage + should be update throughout. + + * Clint: 9469: Completion/Debian/_deb_packages, + Completion/Debian/_dpkg, Doc/Zsh/compsys.yo: new packageset style + to select Debian package. + +2000-01-29 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Alexandre: 1684: Completion/User/.distfiles: add _diff and + _diff_options. + + * Alexandre: 9463: Completion/User/_urls, + Completion/Core/compinit, Completion/Core/_menu, + Completion/Core/_match, Completion/Base/_combination: switch to + using zstyle instead of compstyle in various functions. + + * Sven: 9458: Src/Zle/complete.c, Src/Zle/compresult.c: used freed + memory in completion; should have been using heaps all along. + + * Sven: 9457: Src/params.c: tokenisation problem with patterns + using parameter flag (K). + + * Sven: 9454: Completion/Core/_path_files: handling path prefixes + with patterns more cleverly. + + * Sven: 9452: Completion/Base/_arguments: `--exclude=' shouldn't + show both argument list and completions of --exclude.... + + * Bart: 9448: Makefile.in: treat Test subdirectory along with + others in make procedures (notably distclean). + + * Sven: 9442: Src/Zle/compresult.c: problems with suffixes when + cursor style set. + + * Sven: 9441: Completion/Core/_files, + Completion/User/_diff_options: _files sometimes didn't use + ignored-patterns; use $(command diff) just in case, plus more + verbose descriptions. + + * Alexandre: 9436: Completion/User/_prcs, + Completion/User/_diff_options, Completion/User/_diff: prcs + enhancements with builtin diff support, plus diff options for use + directly with GNU diff. + +2000-01-25 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Etc/FAQ.yo: updated from latest posted version. + + * Sven: 9424: Src/Modules/parameter.c: problems with 9421 with + aliases and dir parameters. + +2000-01-24 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9421: Src/params.c: PM_REMOVABLE parameters are freeable + since they were created by an ordinary createparam() (fixes + memory leak). + + * Alexandre: 9419: Src/Zle/complist.c: more problems with + backreferences in list-colors: aborts after failed backref, + nested backrefs not handled. + + * Sven: 9417: Src/Zle/compcore.c: prefix code confused by matcher + specifications. + + * Sven: 9416: Completion/Core/_setup, Src/Zle/complist.c: problems + using backreferences in list-colors, check zsh/complist is loaded + if needed. + + * Sven: 9415: Doc/Zsh/mod_complist.yo: typo in pattern example. + + * Sven: 9414: Completion/Core/_path_files: use _comp_ignore. + + * Sven: 9413: Functions/Zftp/zfinit, Src/Modules/zutil.c, + Src/loop.c: cleanups for module name, new completion test, + compilation warnings. + + * Sven: 9361: Src/exec.c: simplifty getoutput() test. + +2000-01-23 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk, Src/Modules/.distfiles: 3.1.6-dev-16; + zprof.mdd, zfprof.c finally added to distribution. + +2000-01-22 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9408: Src/pattern.c, Doc/Zsh/expn.yo: failed + backreferences, such as (...)# matching zero times or (|(...)) + matching first part of branch now set match to null string and + indices to -1 instead of crashing the shell. + + * Clint: 9405: Makefile.in: $(DESTDIR) missing in front of + $(sitefndir). + + * Tanaka Akira: 9404: Completion/Core/_path_files: `%' missing in + parameter expansion. + +2000-01-21 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9403: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + brace problems with squeeze-slashes. + + * Sven: 9402: Completion/Builtins/_zstyle, + Completion/Core/_path_files, Doc/Zsh/compsys.yo: ignore-parents + style for more tunable path completion. + + * Sven: 9401: Src/Modules/parameter.c, Src/exec.c, Src/zsh.h: use + list-based instead of function-based system for shell function + wrappers. + + * Tanaka Akira: 9400: Completion/User/.distfiles: add _finger + + * Sven: 9399: Functions/Zftp/zfinit: bad reverse index. + + * Sven: 9398: Functions/Zftp/zfcd_match, + Functions/Zftp/zfget_match: fix _description calls + + * Sven: 9397: Functions/Zftp/zfinit: incorrect zmodload for + autoloaded builtin + + * Sven: 9396: Doc/Zsh/mod_zle.yo, Src/Zle/zle_main.c: better + retrieval of history in vared. + + * Sven: 9395: Src/exec.c, Src/parse.c, Src/text.c: problems with + ksh-format autoload and core dump due to bad termination in + function execution. + + * Sven: 9388, 9389: Completion/User/_domains: try to completion + host domains better. + +2000-01-20 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Alexandre: 9387: Doc/Zsh/compsys.yo: document brace problems + with 9383. + + * Sven: 9386: Completion/Core/_multi_parts, + Completion/Core/_sep_parts: both functions support -F option. + + * Alexandre: 9385: Completion/User/_prcs: tilde expansion in prcs + repository path. + + * Alexandre: 9383: Doc/Zsh/compsys.yo, Completion/Core/_path_files, + Completion/Builtins/_zstyle: add squeeze-slashes style not to take + multiple slashes as multiple completable directories; add + file-patterns to zstyle completion. + + * Sven: 9382: Src/Modules/parameter.c, Src/exec.c, Src/mem.c, + Src/parse.c, Src/text.c: fix problems with empty lists in wordcode + programmes and some comments. + + * Sven: 9381: Src/Zle/compresult.c: don't expand parameters quite + so often for tests. + +2000-01-19 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9373: Src/Modules/parameter.c: missing keys with special + parameters. + + * Sven: 9371: Completion/Core/_files, Completion/Core/_path_files, + Doc/Zsh/compsys.yo: file-patterns style for overriding choices for + file completion built into completion functions. + + * Sven: 9370: Src/text.c: missing tstack initialisation. + + * pws: 9367: Src/cond.c, Src/parse.c, Test/04redirect.ztst, + Test/07cond.ztst: fixes for 9332: `[' tests didn't work, skipping + conditions with `&&' and `||' didn't work, always use WC_END + marker to terminate code. + + * Tanaka Akira: 9360: Completion/User/_cvs: new -C option to cvs + update, better descriptions. + + * Tanaka Akira: 9359: Completion/Debian/_apt, + Completion/Base/_regex_arguments: argument handling for apt-cache. + +2000-01-18 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9354: Etc/MACHINES: problems reported on SPARC. + + * Sven: 9336: Src/signals.c: addition to 9332. + + * Sven: 9332: Src/Modules/example.c, Src/Modules/parameter.c, + Src/Modules/zftp.c, Src/Modules/zprof.c, Src/Zle/compcore.c, + Src/Zle/compctl.c, Src/Zle/complete.c, Src/Zle/zle_main.c, + Src/Zle/zle_misc.c, Src/builtin.c, Src/cond.c, Src/exec.c, + Src/glob.c, Src/hashtable.c, Src/init.c, Src/loop.c, Src/parse.c, + Src/signals.c, Src/text.c, Src/utils.c, Src/zsh.h: Use word code + instead of structs for passing executable chunks around. + + * Sven: 9353: Completion/Base/_jobs: bad prefix test + + * Sven: 9348: Src/Modules/zutil.c: various minor regex fixes + + * Sven: 9345: Src/exec.c, Src/jobs.c, Src/zsh.h: + bug with job control when group leader exits; other problems + with subshells. + + * Alexandre: 9340: Src/Zle/computil.c: bug with adding `=' after + options. + + * Sven: 9335: Completion/Core/_path_files: fix special-dirs style. + +2000-01-17 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Clint: 9333: Completion/User/_a2ps: a2ps can take PostScript + input files. + + * Johan Sundström: 9331: Doc/Zsh/compwid.yo: typo. + + * Sven: 9330: Src/mem.c: debugging message not needed when using + mmap(). + + * Sven: 9329: Src/Modules/parameter.c, Src/Zle/complete.c, + Src/Zle/zleparameter.c, Src/glob.c, Src/mem.c: memory management + fixes for hashtables and heaps. + +2000-01-16 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9328: Completion/User/_finger, + Completion/User/_other_accounts: new finger completion. + .distfiles also updated. + +2000-01-15 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9325: Src/init.c: misspelled SITEFPATH_DIR + + * Alexandre: 9324: Completion/User/_tar_archive: .tgz completion + didn't work. + +2000-01-14 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9322: INSTALL, Makefile.in, configure.in, + Config/defs.mk.in, Config/funcinst.mk, Config/installfns.sh, + Config/uninstallfns.sh, Src/init.c, Src/zsh.mdd: install.fns + creates site-functions, parallel to /usr/share/zsh/3.1.6-dev-15 + or wherever; no functions.old directory saved or used; functions + directory is version-specific anyway, so just delete old one. + + * Sven: 9318: Src/exec.c, Src/init.c, Src/zsh.h: cases where we + don't need to make up the job text. + + * Tanaka Akira: 9317: Completion/User/_urls: don't quote bookmarks + when inserted. + + * Tanaka Akira: 9316: Completion/User/_cvs: detects zsh/stat + module more carefully. + + * Sven: 9315: Src/module.c: bad error status when using zmodload + in static shell. + + * Tanaka Akira: 9311: Completion/Builtins/_zmodload, + Doc/Makefile.in, Test/.distfiles: missing stuff in 3.1.6-dev-15: + unused parameter in _zmodload, deleting too many files with clean + in Doc, 08traps.ztst wasn't in distribution list. + +2000-01-13 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9309: Completion/Core/_path_files, + Completion/Builtins/_zstyle: fixes for 9298: test for non-zero + $FIGNORE, zstyle completion for ignored-patterns. + + * Sven: 9306: Doc/Zsh/mod_zle.yo, Src/Zle/zle_thingy.c: allow + permanent (until next return) message with zle -M. + + * Sven: 9305: Src/Zle/compcore.c: sometimes failed to switch to + alternate match set. + +2000-01-12 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: 3.1.6-dev-15. + + * pws: 9301: configure.in: use quoted '${VERSION}' in function + directory to be determined at compile time, avoids having to + re-make config.status. + + * Sven: 9298: Completion/Core/_description, + Completion/Core/_main_complete, Completion/Core/_path_files, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, Src/Zle/compcore.c: + ignored-suffixes becomes ignored-patterns for more general + ignorance. + + * Sven: 9297: Completion/Core/_alternative: typo. + + * Sven: 9296: Src/Zle/compmatch.c: matcher ignores backslashes by + default. + +2000-01-11 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9295: Doc/Zsh/grammar.yo, Src/loop.c, + Src/Modules/parameter.c: problem with aliased options with + negative number when retrieving $options; bad test for use of + terminal with `select'; defective description of tests for + alternative forms using if ... { ... } etc. + + * Sven: 9291: Completion/Core/_main_complete: insufficient care + with ksharrays affected _cd completion. + + * Sven: 9287: Src/exec.c: unbalanced use of heaps. + +2000-01-10 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Sven: 9283: Src/mem.c: hrealloc() problem with mmap(). + + * Tanaka Akira: 9281, 9282: Completion/Builtins/_popd: too eager + to insert slash suffix. + +2000-01-09 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9280: Src/subst.c: failed to copy parameter properly using + ${(P)...} flag. + + * pws: 9279: Src/mem.c: use munmap() instead of zfree() for + one more heap reference. + + * pws: 9278: Completion/Core/_path_files: overenthusiastic use of + $fignore on explicitly globbed files. + + * Tanaka Akira: 9274: Completion/X/_xutils: completing options of + X commands didn't work. + + * Tanaka Akira: 9273: Completion/User/_cvs: various tweaks. + + * Bart: 9272: Src/Aliases/alias.mdd.in: file missed in 9253. + + * Bart: 9270: Doc/Zsh/.cvsignore, Doc/Zsh/.distfiles, + Doc/Makefile.in: Doc/Zsh/manmodmenu.yo is a generated file. + +2000-01-08 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9269: Completion/User/_pack: bogus space in _pack. + +2000-01-07 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9267: Src/signals.c, Test/08traps.ztst, Test/50cd.ztst, + Test/ztst.zsh: fix remaining(?) trap issues by simplifying + save/restore code; add tests for traps (with unpleasantness + testing trap triggering). + + * pws: 9266: configure.in, INSTALL: move $ZSH_VERSION to before + functions, to allow other zsh versioned stuff to be collected. + + * Sven: 9264 (minus `make clean' hunk): ./Doc/Makefile.in, + Doc/Zsh/manual.yo: remove yodl comments to avoid makeinfo + problems. + + * Sven: 9263: Completion/Builtins/_zmodload, + Completion/Core/_files, Completion/Core/_path_files: _path_files + handles (:r) modifier; _files handles -/g; _zmodload handles + hierarchical modules. + + * Sven: 9262: Completion/Builtins/_hash, Completion/Linux/_rpm, + Completion/User/_dd, Completion/User/_gs, Completion/User/_make: + 9260 add-on for various uses of compset. + + * Sven: 9261: Completion/User/_a2ps: missing backslash. + + * Sven: 9260: Completion/Core/_main_complete: completion after `='. + +2000-01-06 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9256: configure.in, INSTALL: add $ZSH_VERSION to default + function install path. + + * Oliver: 9253: Src/Aliases/cap.mdd, Src/Aliases/clone.mdd, + Src/Aliases/compctl.mdd, Src/Aliases/complete.mdd, + Src/Aliases/complist.mdd, Src/Aliases/computil.mdd, + Src/Aliases/deltochar.mdd, Src/Aliases/example.mdd, + Src/Aliases/files.mdd, Src/Aliases/mapfile.mdd, + Src/Aliases/mathfunc.mdd, Src/Aliases/parameter.mdd, + Src/Aliases/rlimits.mdd, Src/Aliases/sched.mdd, + Src/Aliases/stat.mdd, Src/Aliases/zftp.mdd, Src/Aliases/zle.mdd, + Src/Aliases/zleparameter.mdd, Src/Aliases/zutil.mdd, + Src/linklist.c, Src/mkmakemod.sh, Src/params.c, Src/utils.c: more + fixes for dynamical linking on AIX. + + * Tanaka Akira: 9252: Completion/User/_lp: typo in 9242. + + * Sven: 9250: Src/Zle/complete.c: extend 9237 for compset. + + * Sven: 9248: Completion/Core/_tags, Doc/Zsh/compsys.yo: simplify + undoability of 9245 and suchlike by making `!tag' valid in + tag-order style. + + * Sven: 9245: Completion/Base/_command_names, + Completion/Base/_parameter: complete parameters in command + position (now undoable using styles). + + * Sven: 9244: Completion/Builtins/_zstyle: partial word completion + for style names. + + * Sven: 9242: Completion/User/_lp: better completion of printer + names. + + * Alexandre: 9240: Completion/User/_urls: handle URLs from + bookmarks with spaces by quoting. + + * Sven: 9237: Doc/Zsh/compwid.yo, Src/Zle/compcore.c: fix literal + handling of completion prefix/suffix. + + * Sven: 9236: Src/Zle/compresult.c, Src/Zle/zle_misc.c: + listmatches called with bogus list, plus extra paranoia. + + * Tanaka Akira: 9235: Test/07cond.ztst: chgrp to workaround + inherited groups. + + * Tanaka Akira: 9228: Completion/Builtins/_popd: probllem listing + directories. + + * Tanaka Akira: 9227: Test/04redirect.ztst: problem with .nfs* + files remaining when deleting directory. + + * Tanaka Akira: 9226: Completion/User/_lp: explanation typo. + + * Tanaka Akira: 9225: Completion/Core/_path_files, + Doc/Zsh/compsys.yo: file completion in root directory. + +2000-01-05 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: zsh-3.1.6-dev-14 (note change of + string). + + * Sven: 9219: Functions/Zle/predict-on: zstyle typo. + + * Sven: 9217: Completion/User/_lp, Doc/Zsh/compsys.yo: additions + to foregoing. + + * Sven: zsh-users/2830: Completion/User/.distfiles, + Completion/User/_lp, Completion/User/_ps: completion for printer + commands. + + * Alexandre: 9216: Src/Zle/computil.c, Completion/User/.distfiles, + Completion/User/_prcs: Don't skip too many characters at start of + option; completion for prcs revision control. + +2000-01-04 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9212: Src/zsh.h, Src/Zle/zle_main.c, Src/Zle/zle_hist.c: + make cleaner use of flags to zleread(). + + * pws: 9209: Src/Makefile.in, Src/Makemod.in.in, Doc/Makefile.in: + rearrange 9181 to better order. + + * Tanaka Akira: 9206 (+ tweaks): Src/zsh.h: use __attribute__ + to get alignment for struct heap for gcc. + + * Gene Cohler: 9200: Src/module.c: fix for dynamic linking on + latest HP-UX 11 systems. + + * Sven: 9199: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + allow sorting with sort style for files. + + * Sven: 9198: Completion/Base/_arguments, Completion/Base/_values, + Completion/Core/_alternative: avoid mangling spaces with evals. + + * Sven: 9197: Completion/Core/_multi_parts, + Completion/Core/_path_files, Completion/Core/_sep_parts: + tweak approximation for file completion etc. + + * Sven: 9195: Src/Zle/compcore.c: PS to 9189. + + * Sven: 9193: Completion/Builtins/_zstyle: fix typos etc. + + * Sven: 9191: Completion/Base/_default, + Completion/Core/_description, Completion/Core/_path_files, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, Src/Zle/complete.c: + style control of matcher specification. + + * Sven: 9190: Completion/Core/compinit: tweak default completion + styles. + + * Sven: 2826: Completion/Commands/_complete_help: help is more + helpful about what functions completion is in. + + * Sven: 9189: Src/Zle/compcore.c: problem with not recognizing + prefix lengths when adding matches from patterns. + + * Sven: 9188: Src/loop.c: repeat with a negative count. + + * Sven: 9187: Src/Zle/computil.c: bug with :*pat: patterns + in styles. + + * Helmut: 9186: Src/zsh.h: heaps struct was no longer properly + aligned. + +2000-01-02 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9181: Src/Makefile.in, Src/Makemod.in.in, Doc/Makefile.in: + add .PHONY targets to prevent GNU make creating them sometimes. + +2000-01-01 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9174: Test/ztst.zsh: missing `$'. + + * Geoff: 9173: Completion/User/_tar: bogus `}'. + + * Tanaka Akira: 9170: Completion/Builtins/_unhash, + Completion/User/_mutt: typos. + + * Geoff: 9169: Completion/Builtins/_stat: bogus `fi'. + +1999-12-29 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9166: Completion/Builtins/_zstyle, + Doc/Zsh/compsys.yo, Doc/Zsh/mod_zutil.yo: remove unnecessary + cache-path tag. + + * Clint: 9165: Completion/Debian/_dpkg: dpkg improvement. + + * Tanaka Akira: 9164: Test/01grammar.ztst: use zsh instead of sh + to check - modifier. + + * Tanaka Akira: 9163: Test/ztst.zsh: use absolute path for test + directory. + +1999-12-28 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9162: Completion/Base/_regex_arguments, + Src/Modules/zutil.c: rename regexparse to zregexparse. + + * Tanaka Akira: 9161: Completion/Debian/_apt, + Completion/Debian/_deb_packages: improved 9160. + + * Clint: 9160: Completion/Debian/_deb_packages: handle -J option. + + * Vin Shelton: 9159: Test/Makefile.in, Test/ztst.zsh, + Test/07cond.ztst: fix testing when source and build tree are + separate. + + * Tanaka Akira: 9158: Src/Modules/zutil.mdd: fix module + dependencies (showed up only in static linking). + + * Tanaka Akira: 9154, 9156: Completion/Base/_regex_arguments, + Src/Modules/zutil.c: re-implement parsing for _regex_arguments in + C. + +1999-12-23 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: zsh-3.1.6-pws-13. + + * Zefram: 9143: Util/mkdisttree.sh: same find change here. + + * Andrej: 9142: Util/preconfig: work around probably find bug + + * Alexandre: 9139: Functions/Zftp/zftp_chpwd, Etc/FAQ.yo: + kterm understands xterm sequences. + + * pws: 9150: Completion/Builtins/.distfiles, + Completion/Builtins/_zstyle, Test/.distfiles: added _zstyle + for zstyle completion, also some missed .distfiles entries + for 9129. + + * pws: 9149: Completion/Builtins/_cd, Completion/Core/_path_files: + _cd wouldn't complete in $cdpath and _path_files messed up + array entries with spaces. + +1999-12-22 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Tanaka Akira: 9138: Util/preconfig: problem with pattern + matching `.' in find. + + * Tanaka Akira: 9137: Test/07cond.ztst: compatibility fixes for + tests in 9129. + + * Clint: 9136: Completion/Debian/_dpkg: handle dpkg-deb options. + + * Zefram: 9134: Src/Makefile.in, Src/mkbltnmlst.sh, + Src/xmods.conf, Src/zsh.mdd: aliased libraries with static + linking. + +1999-12-21 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 9129: Src/math.c, Test/04redirect.ztst, + Test/05command.ztst, Test/06arith.ztst, Test/07cond.ztst, + Test/ztst.zsh: fix bug with `(( 4 : 3 ))'; some more tests + for shell basics. + +1999-12-20 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Clint: 9121: Functions/Zftp/zfdir: some idiot messed up + selection of pager. + + * Zefram: 9120: .distfiles, .preconfig, INSTALL, Util/.distfiles, + Util/preconfig: better pre-configuration support. + + * Zefram: 9119: Doc/Zsh/intro.yo: zshzftpsys manual omitted. + + * Zefram: 9118: Doc/Makefile.in, Doc/Zsh/builtins.yo, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, Doc/Zsh/mod_cap.yo, + Doc/Zsh/mod_clone.yo, Doc/Zsh/mod_compctl.yo, + Doc/Zsh/mod_complete.yo, Doc/Zsh/mod_complist.yo, + Doc/Zsh/mod_computil.yo, Doc/Zsh/mod_deltochar.yo, + Doc/Zsh/mod_example.yo, Doc/Zsh/mod_files.yo, + Doc/Zsh/mod_mapfile.yo, Doc/Zsh/mod_mathfunc.yo, + Doc/Zsh/mod_parameter.yo, Doc/Zsh/mod_sched.yo, + Doc/Zsh/mod_stat.yo, Doc/Zsh/mod_zftp.yo, Doc/Zsh/mod_zle.yo, + Doc/Zsh/mod_zleparameter.yo, Doc/Zsh/mod_zprof.yo, + Doc/Zsh/mod_zutil.yo, Doc/Zsh/params.yo, Doc/Zsh/zftpsys.yo, + Doc/Zsh/zle.yo: proper names for info files. + + * Zefram: 9117: Src/mkmakemod.sh: remove unnecessary blanks. + + * Adam: 9109: Completion/User/_hosts: globsubst problem. + + * Sven: 9107: Completion/Core/compinit: fix SELECTMIN. + + * Zefram: 9105: Src/mkbltnmlst.sh: non-existent module problems. + + * Sven: 9099: Src/mem.c, Src/zsh.h: heap memory uses mmap() + as long as MAP_ANONYMOUS is available. + + * Sven: 9098: Src/lex.c: double input buffer with inbufct as + maximum when more memory required. + + * pws: 9123: Src/Modules/mathfunc.c, Doc/Zsh/mod_mathfunc.yo: + removed drem() as not present on Solaris. + + * Clint: 9094: Completion/User/_tar: handle -Cf. + + * Clint: 9093: Completion/User/_tar_archive: bzip2 support + + * Oliver: 9088: Completion/Core/_description: failed to sort + listings numerically. + + * Oliver: 9087: Src/module.c, Src/Modules/zutil.mdd: more + dependency problems with .export files. + + * Sven: 9086: ./Doc/Makefile.in, Doc/Zsh/.distfiles, + Doc/Zsh/mod_zprof.yo: zprof doc. + + * Sven: 9085: Doc/Zsh/compsys.yo: :completion missing, default tag + doc. + + * Zefram: 9084: Src/Aliases/.cvsignore, Src/Aliases/.distfiles, + Src/Aliases/.exrc, Src/Aliases/.preconfig, Src/Aliases/alias.c.in, + Src/Aliases/alias.mdd.in, Src/xmods.conf: alias old modules to new + hierarchical names, zle -> zsh/zle etc. + + * Zefram: 9083: Completion/User/_cvs, Doc/Makefile.in, + Doc/Zsh/builtins.yo, Doc/Zsh/mod_cap.yo, Doc/Zsh/mod_clone.yo, + Doc/Zsh/mod_compctl.yo, Doc/Zsh/mod_complete.yo, + Doc/Zsh/mod_complist.yo, , Doc/Zsh/mod_computil.yo, + Doc/Zsh/mod_deltochar.yo, Doc/Zsh/mod_example.yo, + Doc/Zsh/mod_files.yo, Doc/Zsh/mod_mapfile.yo, + Doc/Zsh/mod_mathfunc.yo, Doc/Zsh/mod_parameter.yo, + Doc/Zsh/mod_sched.yo, Doc/Zsh/mod_stat.yo, Doc/Zsh/mod_zftp.yo, + Doc/Zsh/mod_zle.yo, Doc/Zsh/mod_zleparameter.yo, + Doc/Zsh/mod_zutil.yo, Doc/Zsh/modules.yo, Doc/Zsh/options.yo, + Doc/Zsh/restricted.yo, Doc/Zsh/zftpsys.yo, + Etc/zsh-development-guide, Functions/Misc/zls, + Functions/Zftp/zfinit, Src/Builtins/rlimits.c, + Src/Builtins/rlimits.mdd, Src/Builtins/sched.c, + Src/Builtins/sched.mdd, Src/Makemod.in.in, Src/Modules/cap.c, + Src/Modules/cap.mdd, Src/Modules/clone.c, Src/Modules/clone.mdd, + Src/Modules/example.c, Src/Modules/example.mdd, + Src/Modules/files.c, Src/Modules/files.mdd, Src/Modules/mapfile.c, + Src/Modules/mapfile.mdd, Src/Modules/mathfunc.c, + Src/Modules/mathfunc.mdd, Src/Modules/parameter.c, + Src/Modules/parameter.mdd, Src/Modules/stat.c, + Src/Modules/stat.mdd, Src/Modules/zftp.c, Src/Modules/zftp.mdd, + Src/Modules/zutil.c, Src/Modules/zutil.mdd, Src/Zle/compctl.c, + Src/Zle/compctl.mdd, Src/Zle/complete.c, Src/Zle/complete.mdd, + Src/Zle/complist.c, Src/Zle/complist.mdd, Src/Zle/computil.c, + Src/Zle/computil.mdd, Src/Zle/deltochar.c, Src/Zle/deltochar.mdd, + Src/Zle/zle.mdd, Src/Zle/zle_main.c, Src/Zle/zle_thingy.c, + Src/Zle/zleparameter.c, Src/Zle/zleparameter.mdd, Src/init.c, + Src/makepro.awk, Src/mkbltnmlst.sh, Src/mkmakemod.sh, + Src/mkmodindex.sh, Src/module.c, Src/xmods.conf, Src/zsh.mdd, + Test/ztst.zsh, configure.in, Src/Modules/zprof.c, + Src/Modules/zprof.mdd: Improved hierarchical naming scheme for + modules. + + * Sven: 9019: Src/Modules/zprof.c, Src/Modules/zprof.mdd: + profiling module, documentation to follow. + + * Zefram: 9081: Src/Modules/parameter.mdd: make sure parameter + jobdirs autoloads parameter module. + + * Sven: 9079: Src/exec.c, Src/lex.c: memory allocation for token + strings and input lines changed; autoloading didn't free source + code; more pushing and popping of heaps; saves ca. 800KB with + completion loaded. + + * Sven: 9078: Completion/Commands/.distfile, + Completion/Commands/_verbose_list: _verbose_list is not needed any + more. + + * Sven: 9077: Src/Zle/compresult.c, Src/Zle/computil.c, + Src/Zle/zle_main.c, Src/Zle/zle_tricky.c, Src/pattern.c: + `unitialised' warnings and unnecessary function. + + * Sven: 9076: Src/Zle/compcore.c: better handling of globbing and + approximation together. + + * Sven: 9075: Completion/Core/compinit: use ZLS_COLORS for style + defaults. + + * Sven: 9074: Functions/Zle/predict-on: tidier 9064 + +1999-12-15 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: version 3.1.6-pws-12. + + * pws: 9067: Doc/Zsh/zftpsys.yo, Functions/Zftp/zfanon, + Functions/Zftp/zfcd, Functions/Zftp/zfcget, + Functions/Zftp/zfclose, Functions/Zftp/zfcput, + Functions/Zftp/zfdir, Functions/Zftp/zfgcp, Functions/Zftp/zfget, + Functions/Zftp/zfgoto, Functions/Zftp/zfhere, + Functions/Zftp/zfinit, Functions/Zftp/zfls, Functions/Zftp/zfmark, + Functions/Zftp/zfopen, Functions/Zftp/zfparams, + Functions/Zftp/zfpcp, Functions/Zftp/zfput, + Functions/Zftp/zfsession, Functions/Zftp/zfstat, + Functions/Zftp/zftp_chpwd, Functions/Zftp/zftp_progress, + Functions/Zftp/zftransfer, Functions/Zftp/zftype, + Functions/Zftp/zfuget, Functions/Zftp/zfuput: use _patcomps in + zfinit differently due to 9035; zfput -r does recursive put; + use styles instead of zfconfig entries; new styles titlebar + and chpwd. + + * Clint: 9065: Src/builtin.c: change order of tests in 9028. + + * Bart: 9064: Functions/Zle/predict-on: shouldn't use _style any + more. + + * Sven: 9058: Completion/Base/_arguments, + Completion/Base/_combination, Completion/Base/_command_names, + Completion/Base/_jobs, Completion/Base/_tilde, + Completion/Builtins/_cd, Completion/Builtins/_kill, + Completion/Builtins/_stat, Completion/Builtins/_wait, + Completion/Core/_path_files, Completion/Core/_sort_tags, + Completion/Core/_tags, Completion/Core/compinit, + Doc/Zsh/compsys.yo, Src/Makemod.in: Many small cleanups, plus + change sort-tags to tag-order and add to syntax a bit. + + * Tanaka Akira: 9054: Test/50cd.ztst: get PWD without symlinks, to + avoid messing up cd tests. + +1999-12-14 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Oliver: 9047: Src/Zle/compcore.c, Src/Zle/compresult.c, + Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, Src/mkmakemod.sh: + hack .export files to be made in time for use. + + * Sven: 9039: Doc/Zsh/mod_compctl.yo: description change. + + * Sven: 9035: Completion/Core/_main_complete, + Completion/Core/_normal, Completion/Core/compdump, + Completion/Core/compinit: more small optimisations: _patcomps, + postpatcomps are assocs; avoid post-processing in _main_complete; + fix command name in _normal. + + * Sven: 9031: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + complete .. only for special-dirs. + + * Clint: 9028: Src/builtin.c: hack to be able to change to + subdirectories even when the current directory is renamed. + Hopefully to be replaced by something more elegant eventually. + + * pws: 9048: Completion/Core/_sort_tags, Completion/Core/compinit, + Completion/User/_mh, Doc/Zsh/compsys.yo, + Functions/Zle/incremental-complete-word: assorted completion + fixes, documentation improvement, plus sort-tags style. + +1999-12-13 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Zefram: 9023: Doc/Makefile.in, Doc/Zsh/.cvsignore, + Doc/Zsh/.distfiles, Doc/Zsh/manual.yo, Doc/Zsh/mod_cap.yo, + Doc/Zsh/mod_clone.yo, Doc/Zsh/mod_compctl.yo, + Doc/Zsh/mod_complete.yo, Doc/Zsh/mod_complist.yo, + Doc/Zsh/mod_computil.yo, Doc/Zsh/mod_deltochar.yo, + Doc/Zsh/mod_example.yo, Doc/Zsh/mod_files.yo, + Doc/Zsh/mod_mapfile.yo, Doc/Zsh/mod_mathfunc.yo, + Doc/Zsh/mod_parameter.yo, Doc/Zsh/mod_sched.yo, + Doc/Zsh/mod_stat.yo, Doc/Zsh/mod_zftp.yo, Doc/Zsh/mod_zle.yo, + Doc/Zsh/mod_zleparameter.yo, Doc/Zsh/mod_zutil.yo, + Doc/Zsh/modules.yo: generate module documentation automatically + from a single list in the makefile. + + * Sven: 9020: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + special-dirs style allows completion of . and .. + + * Sven: 9018: Completion/Builtins/_pids, + Completion/Core/_path_files, Completion/User/_cvs, + Completion/User/_pbm: completion optimisations. + + * Zefram: 9013: patching file Doc/Zsh/mod_files.yo, + Src/Modules/files.c: use . as alternative to : for user and group + separator. + + * Sven: 2776: Completion/Core/_path_files: handling of . and .. in + path. + + * Felix: 1 chunk of 9008: Doc/Zsh/mod_parameter.yo: docs for $jobdirs. + + * Felix: (most of) 9007: Src/Modules/parameter.c, + Src/modules/parameter.mdd, mod_parameter.yo: jobdirs special assoc + array. + + * Bart: 9005: Src/exec.c: problem backgrounding shell script. + + * Tanaka Akira: 9004: Test/Makefile.in: run tests with zsh -f. + + * pws: 9024: Etc/zsh-development-guide, Test/.distfiles, + Test/01grammar.ztst, Test/02alias.ztst, Test/03quoting.ztst, + Test/50cd.ztst, Test/cd.ztst, Test/ztst.zsh: new tests for basic + shell stuff. + +1999-12-10 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: 8997: Src/builtin.c, Src/exec.c, Src/params.c: exported + values respect upper-/lowercase flags at the point at which they + are set. + + * Alexandre: 8994: Functions/Zftp/zftp_chpwd, Etc/FAQ.yo, + Doc/Zsh/zftpsys.yo: extend 8993. + + * Clint: 8993: Functions/Zftp/zftp_chpwd: titlebar support in more + general xterm-like emulators. + + * Sven: 8992: Completion/Base/_arguments, + Completion/Base/_combination, Completion/Base/_describe, + Completion/Base/_first, Completion/Base/_jobs, + Completion/Base/_regex_arguments, Completion/Base/_subscript, + Completion/Base/_tilde, Completion/Builtins/_pids, + Completion/Builtins/_popd, Completion/Builtins/_sched, + Completion/Builtins/_signals, Completion/Builtins/_stat, + Completion/Commands/_history_complete_word, + Completion/Core/_approximate, Completion/Core/_description, + Completion/Core/_expand, Completion/Core/_list, + Completion/Core/_main_complete, Completion/Core/_match, + Completion/Core/_message, Completion/Core/_oldlist, + Completion/Core/_path_files, Completion/Core/_requested, + Completion/Core/_setup, Completion/Core/_tags, + Completion/Core/compinit, Completion/Debian/_apt, + Completion/User/_cvs, Completion/User/_groups, + Completion/User/_hosts, Completion/User/_ports, + Completion/User/_socket, Completion/User/_urls, + Completion/User/_users, Completion/X/_x_color, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_clone.yo, Doc/Zsh/mod_complete.yo, + Doc/Zsh/mod_computil.yo, Doc/Zsh/mod_zutil.yo, Doc/Zsh/modules.yo, + Etc/completion-style-guide, + Functions/Zle/incremental-complete-word, Src/Modules/zutil.c, + Src/Modules/zutil.mdd, Src/Zle/complist.c, Src/Zle/computil.c, + Src/Zle/computil.mdd, Src/xmods.conf: compstyle is now + implemented in terms of the new zstyle and zformat commands in + the new zutil module. + + * Tanaka Akira: 8990: Completion/User/_ports, + Completion/User/_socket: completion after `socket hosts'. + +1999-12-09 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Zefram: 8982: Doc/Zsh/mod_files.yo, Src/Modules/files.c, + Src/Modules/files.mdd, Src/system.h, configure.in: chown and + chgrp are implemented as builtins in the files module. + + * Sven: 8981: Src/Zle/complist.c: don't use old list with + accept-and-infer-next-history's completion form. + + * Andrej: 8973: Completion/User/_sudo: revised version. + + * Zefram: 8968: Config/config.mk: dependencies for rebuilding + defs.mk from defs.mk.in. + + * Zefram: 8966: Config/defs.mk.in, Doc/Makefile.in, Makefile.in: + proper install.html. + + * Sven: 8965: Completion/Core/_description, + Completion/Core/_files, Completion/Core/_main_complete, + Completion/Core/_multi_parts, Completion/Core/_path_files, + Completion/Core/_sep_parts, Doc/Zsh/compsys.yo, + Etc/completion-style-guide: doc cleanup and tweak some option + passing. + + * Tanaka Akira: 8962: cd to test directory before removing + temporaries. + + * Tanaka Akira: 8957: Completion/User/.distfiles, Src/Makefile.in: + _sudo missed out of 3.1.6-pws-11, and Src/Makefile.in didn't + get patched properly. + +1999-12-08 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Config/version.mk: version 3.1.6-pws-11. + + * pws: 8955: Src/Modules/zftp.c: command name buffer wasn't large + enough for "zftp session". + + * pws: 8954: Makefile.in, Etc/zsh-development-guide, Test/Makefile.in: + targets for testing should be `check' and `test', which are there + already. + + * Zefram: 8952: Util/mkdisttree.sh: portability and error handling + improvements. + + * Zefram: 8950: Config/defs.mk.in, Doc/.cvsignore, Doc/.distfiles, + Doc/Makefile.in, Makefile.in, Src/Makefile.in: revised name + transformation: nothing in the build tree and everything out of + it is transformed; also fix make portability problems. + + * Zefram: 8946: Makefile.in: distclean in Test; old stamp-h.in + creation bug. + + * Sven: 8945: Doc/Zsh/mod_complist.yo, Src/Zle/compcore.c, + Src/Zle/complist.c: `mu'ltiple is now `du'plicate. + + * Sven: 8944: Completion/Core/_main_complete, + Completion/Core/_setup, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_complist.yo: more detailed choices for when to use + menu completion via menu style. One mod_complist.yo hunk + omitted due to clash with 8942. + + * Bart: 8942: Doc/Zsh/mod_complist.yo: completion doc fixes. + + * Sven: 8939: Doc/Zsh/mod_complist.yo, Src/Zle/comp.h, + Src/Zle/compcore.c, Src/Zle/complist.c, Src/Zle/compresult.c: + menu selection with hidden entries. + +1999-12-07 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Clint: 8933: Doc/Makefile.in: make man pages refer to one + another when transforming file name. + + * Sven: 8932: Src/Zle/computil.c, Src/Zle/zle_tricky.c, + Functions/Zle/incremental-complete-word, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_computil.yo, Completion/Core/_approximate, + Completion/Core/_description, Completion/Core/_expand, + Completion/Core/_message, Completion/Core/_tags: + More standard styles used in _expand and _approximate; + hidden style can apply to any tag; _description does + more printf-type formatting and tests a `format' tag. + + * Clint: 8931: Doc/Makefile.in: sed portability. + + * pws: 8936: configure.in, Etc/zsh-development-guide, + Test/Makefile.in, Test/cd.ztst, Test/ztst.zsh (plus + unposted Test/.cvsignore and Test/.distfiles): basis for + new testing system. + + * Sven: 8930: Completion/Core/_setup, Doc/Zsh/compsys.yo: + _setup gets one argument and has doc. + +1999-12-06 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Bart: 8923: aczsh.m4, configure.in: configuration for + program_transform_name. + + * Bart: 8917: Doc/Makefile.in: better transforming for installed + filenames. + + * Clint: 8915: Doc/Makefile.in: more name transformation stuff + for manual names. + + * Sven: 8911: Src/Zle/comp.h, Src/Zle/compcore.c, + Src/Zle/complete.c, Src/Zle/compresult.c, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Doc/Zsh/params.yo, + Completion/Commands/_complete_help, + Completion/Core/_approximate, Completion/Core/_expand, + Completion/Core/_list, Completion/Core/_main_complete, + Completion/Core/_message, Completion/Core/_setup, + Completion/Core/_style: added some completion styles and + some compstate keys. + + * Sven: 8910: Src/Modules/parameter.c, Src/builtin.c, Src/exec.c, + Src/module.c: don't try to unload modules when shell exits + normally; fix bug with parameter module that old parameters + didn't get removed properly. + + * Sven: 8906: Completion/Core/_path_files: trailing / in vars with + _path_files -W varname now optional. + + * Bart: 8903, 8904, 8905: Makefile.in, configure.in, Doc/.cvsignore, + Doc/.distfiles, Doc/Makefile.in, Src/Makefile.in: More + consistent renaming when altering programme name. + + * Adam: 8902: Completion/Commands/_history_complete_word: + directions broken. + +1999-12-05 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Andrej/Sven/Clint: 8892: Completion/User/_sudo: completion + for sudo. + +1999-12-03 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: unposted: Completion/User/.distfiles, + Completion/Core/.distfiles: add _zdump and _setup. + + * Clint: 8889: Completion/User/_zdump: completion for zdump. + + * Clint: 8879: configure.in: fix some sub-makes in configure.in. + + * Sven: 8876, 8883: Completion/Core/_approximate, + Completion/Core/_expand, Completion/Core/_setup, + Doc/Zsh/compsys.yo: better grouping support in _expand and + _approximate using _setup. + + * Sven: 8874: Completion/Base/_arguments, Completion/User/_use_lo: + fix with _arguments --. + + * Sven: 8869: Completion/Builtins/_cd, Doc/Zsh/compsys.yo: + local-directories and path-directories tags for cd completion. + + * Sven: 8868: Src/Zle/complist.c: better memory of which colour + was just used. + + * Sven: 8864: Completion/Core/_description, + Completion/Core/_files, Completion/Core/_main_complete, + Completion/Core/compinit, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Doc/Zsh/mod_complist.yo, Src/Zle/computil.c: + list-colors style sets up ZLS_COLO[U]RS appropriately. + + * Clint: 8863: Makefile.in, configure.in, Doc/Makefile.in, + Src/Makefile.in: only calculate basename of renamed zsh once. + + * Clint: 8862: Src/builtin.c: fix problem failing to unload zle + with abrupt shell termination. + + * Bart: 8860: Doc/Makefile.in: fix zsh.info build with 8857. + + * Bart: 8857: Doc/Makefile.in: fix zsh.yo.in reference when + source and build trees are separate. + + * Sven: 8852: Src/Zle/complist.c, Src/pattern.c, + Doc/Zsh/mod_complist.yo: whacky colouring of different parts + of listing strings. + + * Sven: 8851: Src/Zle/compcore.c, Src/Zle/complist.c, + Doc/Zsh/mod_complist.yo: grouping possible in ZLS_COLO[U]RS + + * Zefram: 8843: Etc/zsh-development-guide, Src/.cvsignore, + Src/.distfiles, Src/Builtins/.cvsignore, Src/Makefile.in, + Src/Makemod.in.in, Src/Modules/.cvsignore, + Src/Zle/.cvsignore, Src/Zle/.distfiles, + Src/Zle/compcore.c, Src/Zle/complete.c, + Src/Zle/complete.mdd, Src/Zle/compmatch.c, + Src/Zle/compresult.c, Src/Zle/zle.mdd, + Src/Zle/zle_bindings.c, Src/Zle/zle_keymap.c, + Src/Zle/zle_main.c, Src/Zle/zle_misc.c, + Src/Zle/zle_params.c, Src/Zle/zle_refresh.c, + Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, + Src/Zle/zle_utils.c, Src/builtin.c, Src/compat.c, + Src/cond.c, Src/exec.c, Src/glob.c, Src/hashtable.c, + Src/hist.c, Src/init.c, Src/input.c, Src/jobs.c, + Src/lex.c, Src/linklist.c, Src/loop.c, Src/makepro.awk, + Src/math.c, Src/mem.c, Src/mkmakemod.sh, Src/module.c, + Src/options.c, Src/params.c, Src/parse.c, Src/pattern.c, + Src/prompt.c, Src/signals.c, Src/signames2.awk, + Src/subst.c, Src/text.c, Src/utils.c, Src/zsh.h: + use mod_export keyword to generate symbols in .export + files automatically. + + * Clint: 8842: Completion/Debian/_dupload, + Completion/Debian/.distfiles: completion for dupload. + + * Clint: 8841: Doc/zsh.yo.in: patch to 8827. + + * Sven: 8840: Src/Zle/compcore.c, Doc/Zsh/compsys.yo, + Etc/completion-style-guide, Completion/Base/_arguments, + Completion/Base/_brace_parameter, Completion/Base/_describe, + Completion/Base/_first, Completion/Base/_jobs, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Builtins/_popd, + Completion/Commands/_history_complete_word, + Completion/Core/_alternative, Completion/Core/_description, + Completion/Core/_files, Completion/Core/_parameters, + Completion/Core/_path_files, Completion/Core/_requested, + Completion/Core/_tags, Completion/Core/_wanted, + Completion/Core/compinit, Completion/Debian/_apt, + Completion/Linux/_rpm, Completion/User/_bunzip2, + Completion/User/_bzip2, Completion/User/_compress, + Completion/User/_dd, Completion/User/_dvi, Completion/User/_gdb, + Completion/User/_gprof, Completion/User/_gs, + Completion/User/_gunzip, Completion/User/_gzip, + Completion/User/_mh, Completion/User/_mutt, + Completion/User/_netscape, Completion/User/_nslookup, + Completion/User/_pack, Completion/User/_pbm, + Completion/User/_pdf, Completion/User/_ps, + Completion/User/_pspdf, Completion/User/_ssh, + Completion/User/_strip, Completion/User/_tar_archive, + Completion/User/_tex, Completion/User/_tiff, + Completion/User/_uncompress, Completion/User/_unpack, + Completion/User/_users_on, Completion/X/_x_window, + Completion/X/_xmodmap: tags can now be used to define groups for + display. + + * Zefram: 8839: Src/.cvsignore, Src/Builtins/.cvsignore, + Src/Makemod.in.in, Src/Modules/.cvsignore, Src/Zle/.cvsignore, + Src/Zle/compcore.c, Src/Zle/compctl.c, Src/Zle/complete.c, + Src/Zle/compmatch.c, Src/Zle/compresult.c, Src/makepro.awk, + Src/mkmakemod.sh, Src/zsh.mdd: separate local and global + prototype files. + + * Sven: 8838: Doc/Zsh/compsys.yo: colons in argument specifiers. + + * Alexandre: 8836: Completion/User/_prompt: fix for _arguments + use. + + * Sven: 8834: Src/Zle/compcore.c, Src/Zle/complete.c: make sure + grouping commands create groups. + + * Zefram: 8833: Src/Modules/zftp.c: forward declaration of + struct in_addr. + +1999-11-30 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * Clint: 8827: Makefile.in, Doc/.cvsignore, Doc/.distfiles, + Doc/Makefile.in, Src/Makefile.in: partial program transform + support in texinfo docs. + + * Zefram: 8826: configure.in, Src/Modules/zftp.c: workaround + for systems without inet_aton(). + + * Clint: 8824: Src/Makefile.in: use AC_ARG_PROGRAM, already set + by configure. + +1999-11-29 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * pws: Convig/version.mk: version 3.1.6-pws-10 + + * Sven: 8796: Src/Zle/computil.c, Src/utils.c: make freearray() + safer w.r.t. null pointers. + + * pws: 8794: Completion/User/_man: handle .bz2 files. + + * pws: 8793: Src/jobs.c: matheval called incorrectly with + heap allocation. + +1999-11-26 Peter Stephenson <pws@supanet.com> + + * Sven: 8787: Completion/Core/_approximate, + Completion/Core/_correct, Completion/Core/_expand, + Completion/Core/_main_complete: don't prepend completer name if + there; save/restore $curcontext; typo. + + * Tanaka Akira: 8786: Completion/User/_gs: ghostscript can handle + PDF. + + * Tanaka Akira: 8785: Completion/Debian/_apt: quoting typo. + + * Bart: 8782, 8783: Src/lex.c: fix line numbers for `unmatched + ...' errors. + + * Clint: 8779: Src/utils.c: more compiler like error messages. + + * Sven: 8777: Completion/Core/_normal, Completion/Core/_sort_tags, + Doc/Zsh/compsys.yo: extra colon in ordinary argument contexts + for consistency. + + * Sven: 8776: Src/mkbltnmlst.sh, Src/module.c: error in static + shell loading unknown module; don't use autoload stuff in + static shells. + +1999-11-24 Peter Stephenson <pws@supanet.com> + + * Sven: 8770: Src/Builtins/rlimits.c, Src/Builtins/sched.c, + Src/Modules/cap.c, Src/Modules/clone.c, Src/Modules/example.c, + Src/Modules/files.c, Src/Modules/mapfile.c, + Src/Modules/mathfunc.c, Src/Modules/parameter.c, + Src/Modules/stat.c, Src/Modules/zftp.c, Src/Zle/compctl.c, + Src/Zle/complete.c, Src/Zle/complist.c, Src/Zle/computil.c, + Src/Zle/deltochar.c, Src/Zle/zle_hist.c, Src/Zle/zle_keymap.c, + Src/Zle/zle_main.c, Src/Zle/zle_thingy.c, + Src/Zle/zleparameter.c, Src/builtin.c, Src/exec.c, Src/init.c, + Src/mkbltnmlst.sh, Src/module.c, Src/params.c, Src/zsh.h, + Doc/Zsh/builtins.yo, Etc/zsh-development-guide: zmodload now + behaves same for builtin as for dynamically loaded modules + (need to call `zmodload' or autoload explicitly even in statically + linked shells). + + * Sven: 8768: Completion/Core/_complete: change the current + context only if called from _main_complete. + + * Sven: 8766: Src/module.c: don't try to load linked-in module. + + * Zefram: 8764: Src/Modules/zftp.c, acconfig.h, configure.in: + Support for IPv6 in zftp. + +1999-11-23 Peter Stephenson <pws@supanet.com> + + * Adam: 8756: Doc/Zsh/compsys.yo: typo. + + * Sven: 8754: INSTALL: this really does remove comp1, and rewrites + the instructions for systems where module symbols are not + intervisible. + + * Tanaka Akira: more funky telnet options. + + * Sven: 8750: Completion/User/_perldoc: update. + + * Sven: 8749: Src/Zle/computil.c, Completion/Base/_arguments: + mixing single-letter and long options. + + * Sven: 8747: INSTALL: remove comp1 references. + + * Sven: 8746: Src/Zle/computil.c, Completion/Base/_arguments: + (not compsys.yo hunk): escape :'s in computils; fix nesting of + loops in arguments. + + * Oliver: 8745: Completion/User/_mount: handles IRIX 5.3 and AIX, + improves Linux. + + * Sven: 8744: Src/init.c: make compctlreadptr visible after 8741. + + * Sven/Alexandre: 8742: Completion/Builtins/_pids: added more + matches than descriptions; also use command ps. + + * Adam: 8741: Src/init.c: remove references to deleted comp1 + module. + + * pws: 8738: Completion/Builtins/_vars, Completion/User/_make, + Doc/Zsh/compsys.yo, Src/math.c, configure.in: parts missing + in 3.1.6-pws-9. + +1999-11-22 Peter Stephenson <pws@supanet.com> + + * Alexandre: 8728: Completion/Base/_arguments: extra local. + + * Oliver: 8726: Completion/User/_netscape: was broken. + + * Oliver: 8725: Src/zsh.export, Src/Zle/compctl.mdd, + Src/Zle/complete.export, Src/Zle/computil.mdd, + Src/Zle/zle.export, Src/Zle/.distfiles: lastest changes + necessary for dynamical AIX support. + + * Sven: 8722: Completion/Base/_arguments, + Completion/Core/_path_files, Completion/User/_telnet, + Doc/Zsh/compsys.yo: ignored-suffixes style. + + * Sven: 8721: Src/signals.c: null sigfuncs when being saved. + + * Sven: 8720: Doc/Zsh/compsys.yo, + Functions/Zle/incremental-complete-word, + Functions/Zle/predict-on, Completion/Base/_combination, + Completion/Base/_describe, Completion/Base/_jobs, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Builtins/_pids, Completion/Builtins/_popd, + Completion/Builtins/_sched, Completion/Core/_approximate, + Completion/Core/_complete, Completion/Core/_correct, + Completion/Core/_expand, Completion/Core/_list, + Completion/Core/_main_complete, Completion/Core/_match, + Completion/Core/_menu, Completion/Core/_oldlist, + Completion/Core/compinit, Completion/User/_groups, + Completion/User/_hosts, Completion/User/_my_accounts, + Completion/User/_other_accounts, Completion/User/_ports, + Completion/User/_rlogin, Completion/User/_socket, + Completion/User/_ssh, Completion/User/_telnet, + Completion/User/_user_at_host, Completion/User/_users: various + parameters have become styles. + + * Sven: 8718: Src/Zle/compcore.c: addmatches() with fignore. + + * Sven: 8715: Src/Zle/complist.mdd: module depends on zle. + + * Sven: 8716: Completion/Base/_arguments, Src/Zle/computil.c: + option completion fixes; careful with multiple use of tags. + + * Bart: 8501: configure.in: don't try testing for job control + if stdin is not a terminal. + +1999-11-21 Peter Stephenson <pws@supanet.com> + + * pws: Configure/version.mk: 3.1.6-pws-9 made available. + + * Clint: 8702: Completion/Debian/_dpkg: typo. + + * Bart: 8696: Completion/User/_cvs: `cvs watch add' failed. + + * Clint: 8695: Doc/Zsh/params.yo, Src/params.c: LC_NUMERIC support. + + * Clint: 8609, 8693: Src/math.c: make decimal point use + independent of locale. + + * Bart: 8692: Src/Zle/computil.c: core dump in completion. + + * Alexandre: 8691: Completion/User/_mount: upgrade for + Solaris (tested), OSF and Linux (not). + + * Oliver: 8690: Src/makepro.awk: printf locals -> print locals + avoiding buffer size limit on some systems. + + * Sven: 8679: Completion/Base/_jobs, Doc/Zsh/compsys.yo: use + strings style in _jobs. + + * Tanaka Akira: 8678: Completion/User/_cvs: tag name after `cvs + tag'. + + * Sven: 8677: Completion/User/_killall: careful with incompatible + versions. + + * Sven: zsh-users/2742: Src/Makefile.in: remove comp1 from Makefile.in + for building into statically linked shells. + + * Sven: 8675: Completion/Builtins/_kill, + Completion/Builtins/_signals, Completion/Builtins/_trap, + Completion/User/_killall: better use of tags with signal + handling completion. + + * Bart: 8674: Src/builtin.c: make `typeset -x' equivalent to export + by forcing -g. + + * Adam: 8672: Functions/Prompts/.distfiles, + Functions/Prompts/prompt_adam2_setup, + Functions/Prompts/prompt_fire_setup, + Fuanctions/Prompts/promptinit: fix $prompt_theme use; restore after + preview; add distfiles. + + * Sven: 8681: Completion/Builtins/.distfiles: and _signals. + + * Sven: 8683: Completion/Core/.distfiles: add _funcall. + + * Oliver: 8684: Prompts/prompt_off_setup, + Prompts/prompt_oliver_setup, Prompts/prompt_redhat_setup, + Prompts/prompt_suse_setup, Prompts/prompt_zefram_setup, + Prompts/promptinit: tweaks for 8667. + + * Adam: 8669: Misc/bash2zshprompt: and this one, too. + + * Adam: 8667: Functions/Misc/colors, + Functions/Prompts/prompt_adam1_setup, + Functions/Prompts/prompt_adam2_setup, + Functions/Prompts/prompt_bigfade_setup, + Functions/Prompts/prompt_blue_setup, + Functions/Prompts/prompt_combo_setup, + Functions/Prompts/prompt_cyan_setup, + Functions/Prompts/prompt_elite2_setup, + Functions/Prompts/prompt_elite_setup, + Functions/Prompts/prompt_fade_setup, + Functions/Prompts/prompt_fire_setup, + Functions/Prompts/prompt_green_setup, + Functions/Prompts/prompt_magenta_setup, + Functions/Prompts/prompt_off_setup, + Functions/Prompts/prompt_oliver_setup, + Functions/Prompts/prompt_red_setup, + Functions/Prompts/prompt_suse_setup, + Functions/Prompts/prompt_white_setup, + Functions/Prompts/prompt_yellow_setup, + Functions/Prompts/prompt_zefram_setup, + Functions/Prompts/promptinit: new prompt themes with better + handling of colours. + + * Sven: 8665, 8664: Doc/Zsh/compsys.yo, Completion/Core/_funcall, + Completion/Core/compinit, Completion/Linux/_rpm, + Completion/User/_nslookup: manual clean-ups. + + * Adam: 8658: Completion/Core/compinit, Doc/Zsh/compsys.yo: + fix some typos. + + * Tanaka Akira: 8657: Completion/Base/.distfiles, + Completion/Builtins/.distfiles, Completion/Commands/.distfiles, + Completion/Core/.distfiles, Completion/Debian/.distfiles, + Misc/.distfiles, Src/Zle/.distfiles: new and moved files. + + * Sven: 8655: Completion/Base/_arguments: for 8654. + + * Sven: 8654: Doc/Zsh/compsys.yo, + Functions/Zle/incremental-complete-word, + Functions/Zle/predict-on, Completion/Base/_describe, + Completion/Base/_first, Completion/Base/_regex_arguments, + Completion/Builtins/_echotc, + Completion/Commands/_history_complete_word, + Completion/Core/compinit: documentation for new tags code. + + * Sven: 8648: Completion/Base/_brace_parameter, + Completion/Base/_subscript, Completion/Builtins/_sched, + Completion/Builtins/_stat, Completion/User/_tar: get rid of some + _requested and rationalise tag names. + + * Sven: 8647: Completion/Builtins/_hash, + Completion/Builtins/_sched, Completion/Builtins/_stat, + Completion/Core/compinit, Completion/User/_cvs, + Completion/User/_urls, Completion/User/_user_at_host, + Completion/User/_whois, Completion/X/_xutils: additional fixes + for latest tags code. + + * Sven: 8646: Src/Zle/computil.c: add comments + + * Tanaka Akira: 8645: Completion/User/_make, Doc/Zsh/compsys.yo: + fixes for 8639. + + * Sven: 8644: Completion/Base/_arguments, Completion/Base/_values: + loop for only a few options, so don't use getopts. + + * Sven: 8642: Completion/Base/_arguments, Completion/Base/_values: + don't shift OPTINDS-1. + + * Sven: 8640: Completion/Commands/.distfiles: remove _verbose_list. + + * Sven: 8639: Src/Zle/computil.c, Src/Zle/computil.mdd, + Completion/Base/_arg_compile, Completion/Base/_arguments, + Completion/Base/_brace_parameter, + Completion/Base/_command_names, Completion/Base/_condition, + Completion/Base/_default, Completion/Base/_describe, + Completion/Base/_equal, Completion/Base/_first, + Completion/Base/_jobs, Completion/Base/_math, + Completion/Base/_parameter, Completion/Base/_regex_arguments, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Builtins/_aliases, + Completion/Builtins/_arrays, Completion/Builtins/_autoload, + Completion/Builtins/_bindkey, Completion/Builtins/_builtin, + Completion/Builtins/_cd, Completion/Builtins/_command, + Completion/Builtins/_compdef, Completion/Builtins/_disable, + Completion/Builtins/_echotc, Completion/Builtins/_enable, + Completion/Builtins/_functions, Completion/Builtins/_hash, + Completion/Builtins/_kill, Completion/Builtins/_limits, + Completion/Builtins/_pids, Completion/Builtins/_popd, + Completion/Builtins/_sched, Completion/Builtins/_stat, + Completion/Builtins/_trap, Completion/Builtins/_unhash, + Completion/Builtins/_vars, Completion/Builtins/_wait, + Completion/Builtins/_which, Completion/Builtins/_zftp, + Completion/Builtins/_zle, Completion/Builtins/_zmodload, + Completion/Commands/_complete_help, + Completion/Commands/_correct_word, + Completion/Commands/_expand_word, + Completion/Commands/_history_complete_word, + Completion/Commands/_read_comp, Completion/Core/.distfiles, + Completion/Core/_alternative, Completion/Core/_approximate, + Completion/Core/_complete, Completion/Core/_correct, + Completion/Core/_description, Completion/Core/_expand, + Completion/Core/_files, Completion/Core/_list, + Completion/Core/_main_complete, Completion/Core/_match, + Completion/Core/_menu, Completion/Core/_message, + Completion/Core/_normal, Completion/Core/_oldlist, + Completion/Core/_options, Completion/Core/_parameters, + Completion/Core/_path_files, Completion/Core/_requested, + Completion/Core/_set_options, Completion/Core/_sort_tags, + Completion/Core/_style, Completion/Core/_tags, + Completion/Core/_unset_options, Completion/Core/_wanted, + Completion/Core/compdump, Completion/Core/compinit, + Completion/Core/compinstall, Completion/Debian/_apt, + Completion/Debian/_deb_packages, Completion/Linux/_rpm, + Completion/User/_archie, Completion/User/_cvs, + Completion/User/_dd, Completion/User/_flex, + Completion/User/_gcc, Completion/User/_gdb, + Completion/User/_gprof, Completion/User/_groups, + Completion/User/_gs, Completion/User/_hosts, + Completion/User/_killall, Completion/User/_lynx, + Completion/User/_mailboxes, Completion/User/_make, + Completion/User/_man, Completion/User/_mh, + Completion/User/_mount, Completion/User/_mutt, + Completion/User/_netscape, Completion/User/_nslookup, + Completion/User/_pbm, Completion/User/_perl_basepods, + Completion/User/_perl_builtin_funcs, + Completion/User/_perl_modules, Completion/User/_ports, + Completion/User/_rcs, Completion/User/_rlogin, + Completion/User/_socket, Completion/User/_ssh, + Completion/User/_stty, Completion/User/_tar, + Completion/User/_telnet, Completion/User/_tiff, + Completion/User/_urls, Completion/User/_use_lo, + Completion/User/_user_at_host, Completion/User/_users, + Completion/User/_users_on, Completion/User/_wget, + Completion/User/_whois, Completion/User/_yp, + Completion/X/_x_arguments, Completion/X/_x_color, + Completion/X/_x_cursor, Completion/X/_x_display, + Completion/X/_x_extension, Completion/X/_x_font, + Completion/X/_x_keysym, Completion/X/_x_modifier, + Completion/X/_x_window, Completion/X/_xmodmap, + Completion/X/_xt_arguments, Completion/X/_xutils, + Doc/Zsh/compsys.yo, Doc/Zsh/mod_computil.yo, + Etc/completion-style-guide: contexts extended to multiple levels; + tags and styles replace configuration keys; _complete_help (C-xh) + shows context and accepted tags. + + * Bart: 8638: Completion/Base/.distfiles, + Completion/Builtins/.distfiles: mv _vars from Base to _Builtins. + + * Sven: 8633: Doc/Zsh/compsys.yo: documentation for -O options + to _arguments and _values.o + + * Sven: 8632: Completion/User/_telnet: remove set -x + + * Sven: 8630: Src/Zle/computil.c, Doc/Zsh/compsys.yo, + Completion/Base/_arguments, Completion/Base/_brace_parameter, + Completion/Base/_command_names, Completion/Base/_condition, + Completion/Base/_default, Completion/Base/_describe, + Completion/Base/_equal, Completion/Base/_jobs, + Completion/Base/_math, Completion/Base/_parameter, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Base/_vars, + Completion/Builtins/_aliases, Completion/Builtins/_arrays, + Completion/Builtins/_autoload, Completion/Builtins/_bindkey, + Completion/Builtins/_builtin, Completion/Builtins/_cd, + Completion/Builtins/_command, Completion/Builtins/_compdef, + Completion/Builtins/_disable, Completion/Builtins/_echotc, + Completion/Builtins/_enable, Completion/Builtins/_functions, + Completion/Builtins/_hash, Completion/Builtins/_kill, + Completion/Builtins/_limits, Completion/Builtins/_pids, + Completion/Builtins/_popd, Completion/Builtins/_sched, + Completion/Builtins/_stat, Completion/Builtins/_trap, + Completion/Builtins/_unhash, Completion/Builtins/_wait, + Completion/Builtins/_which, Completion/Builtins/_zftp, + Completion/Builtins/_zle, Completion/Builtins/_zmodload, + Completion/Core/_alternative, Completion/Core/_complete, + Completion/Core/_files, Completion/Core/_main_complete, + Completion/Core/_message, Completion/Core/_normal, + Completion/Core/_options, Completion/Core/_parameters, + Completion/Core/_requested, Completion/Core/_set_options, + Completion/Core/_sort_tags, Completion/Core/_style, + Completion/Core/_tags, Completion/Core/_unset_options, + Completion/Core/compinit, Completion/Debian/_apt, + Completion/Linux/_rpm, Completion/User/_archie, + Completion/User/_flex, Completion/User/_gcc, + Completion/User/_gprof, Completion/User/_groups, + Completion/User/_gs, Completion/User/_hosts, + Completion/User/_lynx, Completion/User/_mount, + Completion/User/_mutt, Completion/User/_netscape, + Completion/User/_nslookup, Completion/User/_pbm, + Completion/User/_ports, Completion/User/_rlogin, + Completion/User/_socket, Completion/User/_ssh, + Completion/User/_telnet, Completion/User/_tiff, + Completion/User/_urls, Completion/User/_user_at_host, + Completion/User/_users, Completion/User/_users_on, + Completion/User/_wget, Completion/User/_whois, + Completion/User/_yp, Completion/X/_x_color, + Completion/X/_x_cursor, Completion/X/_x_display, + Completion/X/_x_extension, Completion/X/_x_font, + Completion/X/_x_keysym, Completion/X/_x_modifier, + Completion/X/_x_window, Completion/X/_xmodmap: tags rewrite. + + * Bart: 8617: Src/signals.c: warning, not error, if jobs running + at exit. + + * Akim Demaille <akim@epita.fr>, Tanaka Akira: 8612, 8615: + Completion/User/_make: avoid empty branch in awk pattern by + using `?'. + + * Clint: 8611: Completion/Debian/_apt: complete package to show. + + * Sven: 8607: Src/builtin.c, Src/math.c: initialize mathevall() + return value, but not hunk reset errflag in zexit() (except + kept braces). + + * Sven: 8604: Src/Builtins/.cvsignore, Src/Modules/.cvsignore, + Src/Zle/.cvsignore: ignore so_locations. + + * Sven: 8603: Completion/Base/_arguments, Completion/Base/_describe, + Completion/Base/_values, Completion/Builtins/_kill, + Completion/Builtins/_wait, Completion/Core/_alternative, + Completion/Core/_files, Completion/Core/_main_complete, + Completion/Core/_requested, Completion/Core/_style, + Completion/Core/_tags, Completion/Core/compinit: simplified tags + mechanism and new style mechanism. + + * Bart: 8601: Src/Zle/compcore.c: add DPUTS for 8599. + + * Sven: 8599: Src/Zle/compcore.c: fix problems with quoting + + * Adam: 8598: Misc/make-zsh-urls: perl script for creating URLs to + complete. + + * Tanaka Akira: 8597: Completion/User/_whois: handle fwhois. + + * Clint: 8594: Completion/Debian/_bug: improvements. + + * Sven: 8591: Src/Zle/zle_main.c: fix up vared in subshell by + re-opening file + + * Sven: 8590: Src/Zle/zle.h, Src/Zle/zle_tricky.c, + Src/Zle/zle_utils.c, Completion/Core/_path_files: keeping + track of prefixes and suffixes in file completion and tracking + cursor position for undo. + + * Sven: 8588, 8589: Src/Zle/comp.h, Src/Zle/compcore.c, + Src/Zle/compctl.c, Src/Zle/complete.c, Src/Zle/compmatch.c, + Src/Zle/compresult.c, Src/Zle/computil.c, Src/Zle/computil.mdd, + Src/Zle/zle_tricky.c, Src/params.c, Doc/Zsh/compwid.yo, + Doc/Zsh/mod_computil.yo, Completion/Core/_path_files: mega patch + for nested quotes in completion. + + * Clint: 8585: Src/Zle/compresult.c: count mismatch displaying lines + + * Clint: 8576: configure.in: fix up options descriptions + + * Clint: 8575: Completion/Debian.new/_bug: handle reportbug + + * Sven: 8573: Src/utils.c: more careful quoting re-inserted ~, too. + + * Sven: 8569: Src/utils.c: 8565 after colon. + + * Sven: 8566: Completion/Core/_tags: local var is $ttags, not $tags. + + * Sven: 8565: Src/utils.c, Completion/Core/_expand: don't quote = + in normal argument except at start. + +1999-11-19 Peter Stephenson <pws@supanet.com> + + * Sven: 8562: Completion/Core/_path_files: handle noglobdots but + still find explicitly typed dotfiles. + + * Sven: 8560: Src/Zle/complete.export, Src/Zle/compresult.c, + Src/Zle/zle.export, Src/Zle/zle_tricky.c, Src/zsh.export: move + functions around. + + * Bart: 8558: Completion/Builtins/.distfiles: update + + * Oliver: 8547: zle.export, complete.export, zsh.export + + * Clint: 8545, 7546: Functions/Misc/run-help: .->dot and :->colon; + check $HELPDIR and english, don't invoke man if not necessary. + + * Bart: 8541: configure.in, Completion/Base/.distfiles, + Completion/Builtins/.distfiles, Completion/Core/.distfiles, + Completion/Debian/.distfiles: fix getpwent() test and update + .distfiles. + + * Clint: 8540: Completion/Debian/_bug: completion for Debian `bug'. + + * Sven: 8537: Completion/Base/_describe, Completion/Base/_values, + Completion/Builtins/_kill, Completion/Builtins/_pids, + Completion/Builtins/_wait, Completion/Core/_tags, + Completion/User/_gdb: _pids to complete PIDs; -i option to _tags. + + * Sven: 8536: Src/lex.c: don't try to balance parentheses in + parameter expressions inside math evals. + + * Sven: 8535: Src/Zle/compcore.c, Src/Zle/complist.c, + Src/Zle/zle_tricky.c: drop back to ordinary completion to query + user for listing when in menu-select. + + * Sven: 8533: Completion/Base/_arguments, Completion/Base/_describe, + Completion/Base/_values, Completion/Builtins/_kill, + Completion/Builtins/_wait, Completion/Core/_files, + Completion/Core/_main_complete, Completion/Core/_tags: remove + prios parameters by using $funcstack. + + * Clint: 8532: Completion/Debian/_dpkg, + Completion/Debian/_dpkg-source: new support for Debian package + management functions. + + * 8520: Completion/Base/_arguments, Completion/Base/_describe, + Completion/Base/_values, Completion/Builtins/_kill, + Completion/Builtins/_wait, Completion/Core/_files, + Completion/Core/_main_complete, Completion/Core/_tags, + Completion/Core/compinit: add _tags functionality + + * Sven: 8519: Src/Zle/complist.c: don't use old list after a menu + selction. + + * Sven: 8518: Src/Modules/parameter.c, Src/Modules/parameter.mdd, + Completion/Base/_command_names, Completion/Builtins/_aliases, + Completion/Builtins/_enable, Completion/Builtins/_unhash, + Completion/Builtins/_which, Doc/Zsh/builtins.yo, + Doc/Zsh/mod_parameter.yo: dis* parameter keys are now all + dis_*. + + * Sven: 8517: Src/Zle/zleparameter.c: when to calculate values + for zle parameters (update to 8474). + + * Sven: 8515: Src/Zle/comp.h, Src/Zle/compctl.h, Src/builtin.c, + Src/module.c, Doc/Zsh/builtins.yo, + Completion/Base/_command_names, Completion/Builtins/_bg_jobs, + Completion/Builtins/_fg_jobs, Completion/Builtins/_hash, + Completion/Builtins/_jobs, Completion/Builtins/_kill, + Completion/Builtins/_wait, Completion/User/_gdb, + Completion/User/_perldoc: completion file headers; + zmodload in static shells; changes in job control + completion. + + * Bart: 8512: Completion/Core/compinit: workaround zmodload -i + unavailibity in statically linked shell. + +1999-11-03 Bart Schaefer <schaefer@zsh.org> + + * Config/version.mk: Set version string to 3.1.6-bart-8. + + * Doc/Zsh/Makefile.in, Src/Zle/zle.mdd: The comp1 module is obsolete. + +1999-11-02 Bart Schaefer <schaefer@zsh.org> + + * Src/Zle/comp1.c, Src/Zle/comp1.export, Src/Zle/comp1.mdd: Sven: + 8424: These files are obsolete now. + + * Src/Zle/compcore.c: Sven: 8495: The wrong cline struct was being + tested, causing improper auto-suffix-removal behavior. + + * Completion/Core/_path_files: Sven: 8494: Fix up prefix/suffix + manipulations. + + * Completion/Base/_value: Tanaka: 8491: Call _value after + redefining it. + + * Src/Zle/compcore.c, Src/Zle/compresult.c, Src/Zle/computil.c: + Sven: 8490: Fix display bugs and a fencepost error. + + * Src/Modules/parameter.c: Sven: 8490: Use the correct scan for + disabled aliases. + + * Completion/User/_urls: Sven: 8490: Don't use "hosts" as a local + paramter name, _hosts wants to see the global when it gets called + later. + + * Src/exec.c: Sven: 8488: Pass a copy of the function name to + module wrappers in case the function undefines/redefines itself. + + * Completion/Base/_value: Tanaka: 8487: Completions after + parameter assignments. + + * Completion/User/_make: Tanaka: 8486: Some BSD-variant special cases. + + * Completion/Debian/_apt, Completion/User/_archie: Tanaka: 8485: + Fix typos and minor omissions. + + * Completion/User/_cvs, Completion/User/_whois, + Completion/Core/compinit, Completion/Base/_combination: Sven: + 8484: Use parameter module for testing function existence; fix a + couple of small bugs. + + * Src/Modules/parameter.c: Sven: 8482: Make sure special AA param + keys are set when needed. + + * Src/Zle/compcore.c, Src/Zle/compmatch.c: Sven: 8481: An empty + string in compmatchers means try global match specs. + + * Doc/Zsh/mod_parameter.yo, Src/Modules/parameter.c, + Src/Modules/parameter.mdd, Completion/Core/compinit: Sven: 8480: + Add funcstack parameter. + + * Completion/Core/_path_files: Sven: 8479: Use globdots throughout. + + * Completion/Base/_first: Sven: 8479: Fix example code (in comment). + + * Doc/Zsh/expn.yo, Src/glob.c: Sven: zsh-users/2713: Qualifier (n) + sets numeric-glob-sort for current glob. + + * Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, Doc/Zsh/compctl.yo, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, Doc/Zsh/intro.yo, + Doc/Zsh/manual.yo, Doc/Zsh/mod_complete.yo, Doc/Zsh/modules.yo, + Doc/Zsh/zle.yo, Src/Zle/comp.h, Src/Zle/compcore.c, + Src/Zle/complete.c, Src/Zle/complete.mdd, Src/Zle/complist.c, + Src/Zle/compmatch.c, Src/Zle/compresult.c, Src/Zle/zle.h, + Src/Zle/zle_main.c, Src/Zle/zle_misc.c, Doc/zsh.yo: Sven: 8478 (as + described in 8475 and 8476): Continue the re-modularization of the + new completion system, moving some doc into new sections and + moving most of the completion code from zle_tricky.c into three + new files. + + * Completion/Core/compinit: Sven: 8475: Call zmodload on parameter + and zleparameter. This may not be necessary, as it wasn't + included in the correction in 8478. + + * Src/Modules/parameter.c: Sven: 8474: Fix computation from + previous patch for whether values are needed. + + * Src/hashtable.c: Sven: 8474: Fall back on getpwent() if NIS + and/or NIS+ don't find anything. + + * Src/signals.c: Sven: 8473: Reset sigtrapped[] during dosavetrap(). + + * Src/Modules/parameter.c, Src/Zle/zleparameter.c: Sven: 8472: + Don't calculate values for special parameters unless needed. + + * Functions/Zle/predict-on: Use a "repeat 1" instead of "while + true" for a dummy loop. (Unposted.) + + * Completion/Builtins/_functions, Completion/Builtins/_unhash, + Completion/Builtins/_which, Completion/Builtins/_zle, + Completion/Builtins/_zmodload, Doc/Zsh/mod_parameter.yo, + Doc/Zsh/mod_zleparameter.yo, Src/Modules/parameter.c, + Src/Modules/parameter.mdd, Src/Zle/zleparameter.c, + Src/Zle/zleparameter.mdd, Completion/Base/_command_names, + Completion/Base/_equal, Completion/Builtins/_aliases, + Completion/Builtins/_bindkey, Completion/Builtins/_builtin, + Completion/Builtins/_disable, Completion/Builtins/_enable: Sven: + 8471: Split some paramters into enabled and disabled variants. + + * Functions/Zle/predict-on: Sven: 8470: Test list_max of 0 as a + special case. + + * configure.in: Zefram: 8459: More places to hunt for signals and + resources. + + * Completion/Core/compinit, Doc/Zsh/compsys.yo, Src/xmods.conf: + Sven: 8440: Auto-autoload the parameter modules, because + completion won't work without them. + + * Src/Zle/zle_tricky.c: Sven: 8439: Completion lists respect + NUMERIC_GLOB_SORT. + + * Src/Zle/zle_tricky.c: Sven: 8438: Force recompute of completion + list in listlist(). + + * Src/Zle/complist.c, Src/Zle/zle_tricky.c: Sven: 8437: Fix crash + in menu-select and remove old ref to ZLS_SELECT param. + + * Src/Zle/compctl.mdd, Src/Zle/complete.c, Src/Zle/complete.mdd, + Src/Zle/complist.c, Src/Zle/complist.mdd, Src/Zle/computil.mdd, + Src/Zle/zle.h, Src/Zle/zle_keymap.c, Src/Zle/zle_main.c, + Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, + Src/Zle/zleparameter.c, Src/Zle/zleparameter.mdd, + Doc/Zsh/compwid.yo, Doc/Zsh/expn.yo, Doc/Zsh/manual.yo, + Doc/Zsh/mod_clone.yo, Doc/Zsh/mod_compctl.yo, + Doc/Zsh/mod_complete.yo, Doc/Zsh/mod_computil.yo, + Doc/Zsh/mod_parameter.yo, Doc/Zsh/mod_zle.yo, + Doc/Zsh/mod_zleparameter.yo, Doc/Zsh/modules.yo, + Src/Modules/parameter.c, Src/Modules/parameter.mdd, + Src/Zle/comp.h, Src/Zle/compctl.h, Src/hashtable.c, Src/module.c, + Src/params.c, Src/subst.c, Src/xmods.conf, Completion/User/_cvs, + Completion/User/_gdb, Completion/User/_man, Completion/User/_mh, + Completion/User/_nslookup, Completion/User/_tar, + Completion/User/_urls, Completion/User/_users, + Completion/User/_whereis, Completion/User/_whois, + Completion/X/_x_font, Completion/X/_x_window, + Completion/X/_xmodmap, Doc/Makefile.in, Doc/Zsh/compctl.yo, + Doc/Zsh/compsys.yo, Completion/Debian/_apt, + Completion/Core/_approximate, Completion/Core/_main_complete, + Completion/Core/_normal, Completion/Core/_options, + Completion/Core/_parameters, Completion/Core/_path_files, + Completion/Core/compinit, Completion/Commands/_bash_completions, + Completion/Commands/_history_complete_word, + Completion/Commands/_read_comp, Completion/Builtins/_aliases, + Completion/Builtins/_arrays, Completion/Builtins/_bg_jobs, + Completion/Builtins/_bindkey, Completion/Builtins/_builtin, + Completion/Builtins/_cd, Completion/Builtins/_command, + Completion/Builtins/_compdef, Completion/Builtins/_disable, + Completion/Builtins/_enable, Completion/Builtins/_fc, + Completion/Builtins/_functions, Completion/Builtins/_hash, + Completion/Builtins/_jobs, Completion/Builtins/_kill, + Completion/Builtins/_set, Completion/Builtins/_stat, + Completion/Builtins/_trap, Completion/Builtins/_unhash, + Completion/Builtins/_wait, Completion/Builtins/_which, + Completion/Builtins/_zle, Completion/Builtins/_zmodload, + Completion/Base/_arguments, Completion/Base/_brace_parameter, + Completion/Base/_command_names, Completion/Base/_describe, + Completion/Base/_equal, Completion/Base/_first, + Completion/Base/_job, Completion/Base/_regex_arguments, + Completion/Base/_tilde, Completion/Base/_values: Sven: 8424: + Rearrange completion code to make the new function-based system + the default and begin separating zle_tricky, the old compctl + stuff, and the new system into better-segregated modules. + + * Src/Zle/compctl.c: Port from zle_tricky.c my local stubbornness + patch to use short job names, not whole job listings, in job + completions. + + * Src/Zle/compctl.c: Sven: 8424: Rearrange completion code to make + the new function-based system the default and begin separating + zle_tricky, the old compctl stuff, and the new system into + better-segregated modules. + +1999-10-27 Bart Schaefer <schaefer@zsh.org> + + * Functions/Zle/predict-on: Better handling of automenu, and don't + generate a listing if nmatches is so big that it would generate a + "do you wish ...?" prompt. + + * Functions/Zle/predict-on, Doc/Zsh/compsys.yo: Sven: 8442: "Pour + some compconfig over" predict-on. + +1999-10-26 Bart Schaefer <schaefer@zsh.org> + + * Functions/Zle/predict-on: As per Sven's suggestion, use a + comppostfuncs function to suppress the "do you wish to see all + possibilities?" message on long listings. + +1999-10-25 Bart Schaefer <schaefer@zsh.org> + + * Src/Zle/complist.c: Alexandre Duret-Lutz: 8413: Tweak 8412 to + extend the menu-selection highlight to the full width of the + column. + + * Src/Zle/complist.c, Doc/Zsh/mod_complist.yo: Sven: 8412: Add + separate colorings for the file-type-marker and for background + spaces, to be able to more closely copy GNU color-ls. + + * Src/Modules/parameter.c: Bart: 8404: Implement "autoload -X" and + change the value of "$functions" to fit. Also fix a crash-bug + when unloading this module. + + * Src/builtin.c, Src/exec.c, Src/hashtable.c, Doc/Zsh/builtins.yo, + Doc/Zsh/func.yo: Bart: 8404: Implement "autoload -X" and change the + output of "functions" to fit. + + * Doc/Zsh/zle.yo: Sven: 8400: BLINES -> BUFFERLINES + +1999-10-24 Bart Schaefer <schaefer@zsh.org> + + * Src/zsh.mdd: Don't forcibly rebuild zshpaths.h; instead make it + depend on the usual configuration-related makefile fragments. + + * Src/parse.c: Fix function-body parsing bug introduced by earlier + optimizations. + +1999-10-22 Bart Schaefer <schaefer@zsh.org> + + * Src/Modules/stat.c: Alexandre Duret-Lutz: 8371: Make "stat -g" + correspond to the doc for it. + + * Src/hist.c: Alexandre Duret-Lutz: 8376: !# history expansion now + works during completion, as it has in 3.0 since June 1, 1997. + + * Src/main.c, Src/params.c, Src/system.h, INSTALL, acconfig.h, + configure.in: Zefram: 8372: Configure option to disable + setlocale() support, and also do a linkage test for it rather than + simply test for the LC_ALL constant. + + * Functions/Zle/predict-on: Back out Sven's suggested compmatchers + for now; turn off prediction when a delete-char-or-list is + performed. + +1999-10-21 Bart Schaefer <schaefer@zsh.org> + + * Functions/Zle/predict-on: Refine, and improve commentary. + + * Completion/Builtins/_cd, Completion/Builtins/_popd: Oliver: + 8361: Factor out handling of +/- dirstack offsets from _cd to make + completer for _popd; fix _cd handling of directory names that + actually do begin with a + or -. + + * Src/Zle/computil.c: Sven: 8360: Still more parsing fixes. + + * Completion/User/_bison: Sven: 8360: Improved option recognition. + + * Completion/Base/_arguments, Completion/Base/_values: Sven: 8360: + More computil-related tweaking. + + * Completion/Builtins/_sched: Oliver: 8359: Complete scheduled + jobs for removal. + + * Src/Zle/computil.c: Sven: 8357: More options-parsing tweaks. + + * Functions/Prompts/promptinit, + Functions/Prompts/prompt_oliver_setup: Oliver: 8353: Simplified + handling of prompt_opts. + + * Src/Zle/computil.c: Sven: 8352: Fix parsing bugs. + + * Completion/User/_bison: Sven: 8352: Complete .y files as well. + + * Completion/Base/_arguments: Sven: 8352: Delay calling _message + so it won't confuse compstate[insert]. + + * Src/Zle/zle_tricky.c: Sven: 8350: Fixes to cline handling of + position of braces and of cursor following completion in nested + braces. + + * Functions/Zle/predict-on: If history-beginning-search-backward + fails, attempt complete-word. + + * Completion/Core/_path_files: Sven: 8350: Fix prefix/suffix settings. + + * configure.in: Clint Adams: 8346: Fix typos. + + * Src/Zle/computil.c: Sven: 8340: Fix memory management bugs and + confusion about word ranges when restricting compwords. + + * Completion/Core/_path_files: Sven: 8340: Fix completion on empty + string. + +1999-10-20 Bart Schaefer <schaefer@zsh.org> + + * Functions/Prompts/promptinit: Oliver: 8335: Provide the + prompt_opts assoc. array to specify what options are needed by a + given prompt theme, and arrange to set them by putting the + localoptions-affected guts of the prompt function into set_prompt + and then calling setopt after it finishes. (Tweaked to avoid + reindentation.) + +1999-10-19 Bart Schaefer <schaefer@zsh.org> + + * Src/Zle/comp.h, Src/Zle/complist.c, Src/Zle/zle_tricky.c: Sven: + 8333: Handle completion in nested brace-expressions. + + * Src/Builtins/rlimits.c: Display the sockbufsize and maxpthreads + limits in "ulimit -a" output. + + * Src/Builtins/rlimits.awk, Doc/Zsh/builtins.yo: Add the + "maxpthreads" limit as reported by Albert Chin. + + * Src/Zle/comp1.export, Src/Zle/compctl.export, + Src/Zle/zle.export: Oliver: 8323: Declarations needed to build + shared objects on AIX. + + * Src/Zle/zle_tricky.c: Sven: 8322: Fix overeager slash-addition + and suffix-elimination. + + * Completion/Core/_path_files: Sven: 8322: Complete directories up + to a trailing slash even if there are no further subdirectories, + but continue to make any subdirectories candidates for further + completion when a trailing slash is present. + + * Src/Builtins/rlimits.awk, Doc/Zsh/builtins.yo: Rename + "sktbuffersize" as "sockbufsize". + + * Src/cond.c: Sven: 8321: Fix bug in new cmpile-once "case" handling. + +1999-10-18 Bart Schaefer <schaefer@zsh.org> + + * Src/Builtins/rlimits.awk, Src/Builtins/rlimits.c, + Src/Builtins/rlimits.mdd: Zefram: 8320: Sort the resource list for + "limit", rename "sbsize" to "sktbuffersize", fix problems handling + memory type limits vs pure numeric vs time spans. + + * Doc/Zsh/builtins.yo: Zefram: 8320: Sort the resource list for + "limit", rename "sbsize" to "sktbuffersize". + + * Src/cond.c, Src/loop.c, Src/parse.c, Src/pattern.c, Src/utils.c, + Src/zsh.h: Sven: 8319: Compile patterns in "case" statements on + demand, then keep them in the parse tree so they only have to be + compiled once. + + * Src/Zle/zle_tricky.c: Sven: 8317: Reset state so that a leading + "~" isn't assumed to be part of an extendedglob pattern. + + * Completion/Base/_tilde: Sven: 8317: Use _users. + + * Src/Zle/computil.c: Sven: 8316: Report when arguments are not + allowed at a position. + + * Completion/Base/_arguments: Sven: 8316: Extraneous "break". + + * Src/Zle/computil.c: Sven: 8315: Save and restore parser state + around "restricting rest-argument-definitions". + + * Src/Zle/zle_tricky.c: Sven: 8313: Try harder to use match specs + correctly, even when `globcomplete'. + + * Doc/Zsh/compsys.yo, Completion/Core/_path_files: Sven: 8313: + conconfig[path_expand] now has "prefix" and "suffix" choices. + + * Completion/Core/compinit: Sven: 8313: Minor cleanup of "funcall". + + * Completion/Core/_main_complete: Sven: 8313: A warning message + should be printed only when the last global match spec was tried. + + * Completion/Core/_main_complete: Sven: 8312: Missing "local" decl. + + * Doc/Zsh/builtins.yo: Document the `sbsize' limit. + + * Src/Builtins/rlimits.awk: Jos Backus: 8309: FreeBSD has an + SBSIZE limit. + +1999-10-17 Bart Schaefer <schaefer@zsh.org> + + * Completion/User/_man: Oliver: 8139: Use the "manpath" command if + available, splitting at colons. + + * Src/Modules/mathfunc.c: Oliver: 8138: Remove excess comma that + causes picky compilers to choke. + + * Src/builtin.c, Src/options.c, Src/zsh.h, Doc/Zsh/options.yo: + Bart: 8308: The `CHECK_JOBS' option, based on Clint Adams' 8109, + with sense reversed as suggested by Zefram in 8111, and adapted + doc from PWS in 8110. + + * Doc/Zsh/compsys.yo, Completion/Commands/_history_complete_word: + Adam: 8028,8063,8070; and PWS: 8098: Revised history completion. + + * Src/.cvsignore: Ignore .pro files only if they begin with + alphanumerics, to keep .indent.pro. + +1999-10-16 Bart Schaefer <schaefer@zsh.org> + + * Config/version.mk: Set version string to 3.1.6-bart-7. + + * Completion/User/_whois: Tanaka: 8296: New completion for "whois". + + * Completion/User/_archie: Tanaka: 8295: New completion for "archie". + +1999-10-15 Bart Schaefer <schaefer@zsh.org> + + * Completion/Debian/_apt, Completion/Base/_regex_arguments: + Tanaka: 8289: Misc. cleanup. + + * Completion/User/_pbm: Tanaka: 8287: Add missing + continuation-line backslashes. + + * Completion/User/_urls: Tanaka: 8286: Misc. cleanup. + + * Misc/bash2zshprompt: Adam: 8278: Emit "setopt promptsubst". + + * Completion/User/_urls: Oliver: 8276: More autoremoval fixes. + + * Src/Zle/zle_tricky.c: Sven: 8283: Fix bug in tracking number of + matches added. + + * Doc/Zsh/compctl.yo, Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo: + Sven: 8283: Improve documentation about match-specs. + + * Completion/Core/compinit: Sven: 8273: "compconf -L" sorts its + output. + + * Completion/Core/compinit, Src/Zle/computil.c, + Src/Zle/computil.mdd, Src/xmods.conf: Sven: 8272: The computil + module is now auto-autoloaded; minor bugfix. + + * Doc/Zsh/mod_complist.yo, Doc/Zsh/mod_computil.yo, + Doc/Zsh/mod_deltochar.yo, Doc/Zsh/modules.yo: Sven: 8272: Assorted + computil documentation. + + * Completion/Base/_describe, Completion/Base/_values: Sven: 8272: + Clean-up related to usages of new computil functions. + + * Src/Zle/computil.c, Completion/Base/_arguments: Sven: 8270: + Assorted computil debugging. + + * Src/math.c: Sven: 8267: Fix core dump caused by bad error handling. + + * Completion/User/_urls: Tanaka: 8263: Avoid bad autoremove behavior. + + * Completion/User/_killall, Completion/User/_pack, + Completion/User/_unpack, Completion/User/_whereis: Oliver: 8262: + More new completers. + + * Completion/User/_uncompress, Completion/User/_users, + Completion/User/_gzip, Completion/User/_hosts: Oliver: 8262: Fix + misc. minor omissions. + + * Completion/Builtins/_nothing: Oliver: 8262: Use this for the + "whoami" command. + + * Src/zsh.h, Src/params.c: Sven: 8254: Implement (k) and (K) + subscript modifiers. + + * Doc/Zsh/params.yo: Sven: 8254: Document the new (k) and (K) + subscript modifiers. + + * Functions/Prompts/prompt_adam2_setup, + Functions/Prompts/prompt_fire_setup, + Functions/Prompts/prompt_redhat_setup, + Functions/Prompts/promptinit: Fix a few bugs, mostly involving + `setopt promptsubst'. + + * Functions/Prompts/promptinit: Sven: 8251: Tweak to properly + expand the $fpath array. + + * Src/Zle/compctl.c, Src/Zle/compctl.mdd: Sven: 8249: Add the + "compmatchers" array. + + * Doc/Zsh/compctl.yo, Doc/Zsh/compsys.yo: Sven: 8249: Clarify + documentaion of declarations needed by some completers; document a + couple of new features. + + * Completion/Core/_description, Completion/Core/_files, + Completion/Core/_main_complete, Completion/Core/_message, + Completion/Core/_multi_parts, Completion/Core/_path_files, + Completion/Core/_sep_parts: Sven: 8249: Accept standard compadd + arguments, fix a few bugs, use the new compconfig[warning_format], + etc. + + * Completion/Builtins/_nothing: Sven: 8249: A completer which just + prints a warning that the current context does not expect any + words at all (e.g., a command that takes no arguments). + +1999-10-14 Bart Schaefer <schaefer@zsh.org> + + * Completion/Core/_main_complete, Completion/Core/compinit: Sven: + 8256: Missing hunks of 8227. + + * Src/Zle/zle_tricky.c: Sven: 8247: When completing with a match + spec, don't insert anchors if there are characters missing to the + left of them. + + * Src/Zle/zle_tricky.c: Sven: 8244: Fix failure to list ambiguous + matches completing after a quote. + + * configure.in: Tanaka: 8241: Test for a gcc 2.95 bug. + + * Src/Builtins/rlimits.awk, Src/Builtins/rlimits.c, + Doc/Zsh/builtins.yo: Zefram: 8229: Support for the AIO_OPS and + AIO_MEM resource limits. + +1999-10-13 Bart Schaefer <schaefer@zsh.org> + + * Src/Zle/compctl.c, Src/Zle/computil.c, Src/Zle/computil.mdd, + Src/Zle/zle_tricky.c, Doc/Zsh/compsys.yo, + Completion/Core/compinit, Completion/Base/_arguments, + Completion/Base/_describe, Completion/Base/_values: Sven: 8219: + Add and make use of the "computil" module, which moves several of + the operations previously done by shell functions into C code. + + * Completion/User/_netscape: Oliver: 8230: Better browser and url + completion. + + * Completion/User/_tiff: Sven: 8132: Change "options" to "opt_args". + + * Src/Zle/zle_tricky.c: Sven: 8231: Remove unnecessary tokenization. + + * Src/utils.c: Sven: 8231: Don't attempt to use a null name in + zwarnnam(). + + * Doc/Zsh/compsys.yo, Completion/X/_xmodmap, + Completion/User/_flex, Completion/User/_gcc, + Completion/User/_gprof, Completion/User/_gs, + Completion/User/_lynx, Completion/User/_mount, + Completion/User/_nslookup, Completion/User/_rlogin, + Completion/User/_socket, Completion/User/_ssh, + Completion/User/_telnet, Completion/User/_urls, + Completion/User/_wget, Completion/User/_yp, Completion/Linux/_rpm: + Sven: 8231,8232: Rename "options" as "opt_args" in a lot of places + to avoid conflicts with the parameters module. + + * Completion/User/_urls, Completion/User/_webbrowser, + Doc/Zsh/compsys.yo: Oliver: 8230: Better browser and url + completion. + + * Functions/Zle/incremental-complete-word, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Doc/Zsh/zle.yo, Src/Zle/comp.h, + Src/Zle/comp1.c, Src/Zle/compctl.c, Src/Zle/complist.c, + Src/Zle/zle_main.c, Src/Zle/zle_params.c, Src/Zle/zle_tricky.c: + Sven: 8227: Compute the list of matches more frequently and + earlier so that compstate[nmatches] is accurate more often; + replace compstate[normal_nmatches] with + compstate[alternate_nmatches] as a consequence; add + compstate[list_lines] and BUFFERLINES for testing how big a screen + is needed to edit; add an array comppostfuncs to hold callback + shell functions run during completion; fix a display bug. + + * Src/Zle/zle_tricky.c: Sven: 8222: More cursor position + heuristics: prefer to place the cursor in the matched portion of + an ambiguous word, rather than in a prefix or suffix. + + * Completion/Core/_approximate, Completion/Core/_complete, + Completion/Core/_expand, Completion/Core/_list, + Completion/Core/_main_complete, Completion/Core/_match, + Completion/Core/_path_files, Completion/Base/_default: Sven: 8217: + Remove large comments that are now redundant with the compsys + manual; misc other cleanup. + + * Src/Zle/zle_tricky.c: Sven: 8216: Improve code readability. + + * Src/Zle/zle_tricky.c: Sven: 8215: Fix problem with + accept-and-menu-complete. + + * Functions/Misc/nslookup: A space is required between "read -k" + and the number of bytes to read. + + * Doc/Zsh/builtins.yo: Document vagaries of "read -k" argument + parsing. + +1999-10-12 Bart Schaefer <schaefer@zsh.org> + + * config.sub: Handle newer flavors of hppa2.0 as computed by + configure. + +1999-10-11 Bart Schaefer <schaefer@zsh.org> + + * Completion/Core/_path_files: Sven: 8206: Fix setting of PREFIX + when there's a leading slash. + + * Src/Zle/zle_tricky.c: Sven: 8205: Misc. fixes involving uninit'd + variables, ragged alignment of output in calclist(), etc. + + * Completion/User/_yodl: Sven: 8204: Handle .yo file-suffix as + well as .yodl. + + * Completion/Builtins/_cd, Completion/Base/_tilde: Oliver: 8181: + Clean up directory stack handling. + +1999-10-10 Bart Schaefer <schaefer@zsh.org> + + * Src/options.c: Zefram: 8152: A batch of tweaks to emulation + behavior (exec change omitted). + + * Doc/Zsh/options.yo, Src/options.c: Zefram: 8154: Change default + behavior of shortloops (extendedglob change omitted). + + * Src/exec.c: Add the coproc descriptors to those that can't be + copied by redirection. + + * Doc/Zsh/redirect.yo: Zefram: 8186: More accurate redirection doc. + + * Src/exec.c: Tweak 8187 to test the fdtable[] array rather than + simply > 9. + + * Src/glob.c, Src/exec.c: Zefram: 8187: Don't permit redirection + to grab zsh's internal descriptors. + + * Doc/Zsh/redirect.yo: Document the "&>" redirection and the use + of multi-digit numbers on the RHS of "<&" and ">&" redirections. + + * Src/lex.c: Fix parsing of the "&>" redirection. + + * Src/exec.c: Plug lead of a copy of the coproc input descriptor. + +1999-10-07 Bart Schaefer <schaefer@zsh.org> + + * Completion/User/_urls: Oliver K: 8155: Handle "file:" urls. + + * Src/Zle/zle_tricky.c: Tweak last patch slightly to avoid the + possibility of returning NULL. + + * Src/Zle/zle_tricky.c: Don't prematurely free/recreate the cached + value of $compstate[ambiguous]. + + * Functions/Prompts/promptinit: This function requires extendedglob. + +1999-10-06 Bart Schaefer <schaefer@zsh.org> + + * Functions/Misc/colors: + Adam: 8147: Use $'...' rather than $(echo -n '...'). + + * Misc/bash2zshprompt: Adam: 8144: Small fix. + + * Misc/bash2zshprompt, Functions/Prompts/prompt_adam1_setup, + Functions/Prompts/prompt_adam2_setup, + Functions/Prompts/prompt_blue_setup, + Functions/Prompts/prompt_combo_setup, + Functions/Prompts/prompt_cyan_setup, + Functions/Prompts/prompt_elite2_setup, + Functions/Prompts/prompt_elite_setup, + Functions/Prompts/prompt_fire_setup, + Functions/Prompts/prompt_green_setup, + Functions/Prompts/prompt_magenta_setup, + Functions/Prompts/prompt_off_setup, + Functions/Prompts/prompt_red_setup, + Functions/Prompts/prompt_redhat_setup, + Functions/Prompts/prompt_suse_setup, + Functions/Prompts/prompt_white_setup, + Functions/Prompts/prompt_yellow_setup, + Functions/Prompts/promptinit, Functions/Misc/colors, + Completion/User/_prompt: Adam: 8129: "Themed prompts" system + copied (and translated) from bash. + + * INSTALL, configure.in: Adam: 8145: Install the themed-prompt stuff. + + * Src/Modules/stat.c, Src/system.h: Zefram: 8137: Support for + Solaris "doors". + + * Src/jobs.c: Reattach the tty and resize the terminal after a + foreground job is stopped. + +1999-10-04 Bart Schaefer <schaefer@zsh.org> + + * Src/Zle/zle_refresh.c: Geoff: 8126: Fix infinite loop in + tc_rightcurs(). + +1999-10-03 Bart Schaefer <schaefer@zsh.org> + + * Src/builtin.c, Doc/Zsh/builtins.yo: PWS: 8093: Back out 8084. + + * Src/prompt.c: Use zcalloc() to allocate the buffer in + promptexpand(), so as not to leave garbage beyond the end of the + prompt after expansion. + + * Src/builtin.c: When computing the new directory for $PWD, don't + duplicate a trailing slash. + + * Etc/FAQ.yo: PWS: zsh-announce/100: Latest FAQ changes. + +1999-10-02 Bart Schaefer <schaefer@zsh.org> + + * Src/exec.c: Start the path search over from the beginning, not + from where it was last left off, after removing a bad element at + attempted-execute-time. + +1999-09-30 Bart Schaefer <schaefer@zsh.org> + + * Doc/Zsh/compsys.yo, Completion/Commands/_bash_completions: PWS: + 8108: Completions for bash equivalence. + + * Doc/Makefile.in: Adam: 8106: Use $(DESTDIR) when installing + info, too. + + * Completion/User/_my_accounts, Completion/User/_other_accounts, + Completion/User/_user@host, Completion/User/_user_at_host: Adam: + 8101: Change @ to _at_ in file names. + + * Completion/User/_perl_modules, Completion/User/_perldoc: Adam: + 8100: Small bugfix, whitespace cleanup. + + * Completion/Core/compinit, Doc/Zsh/compsys.yo: PWS: 8098: Add + "compdef -K" to map multiple widgets to the same function. + + * Doc/Zsh/guide.yo: PWS: 8097: Renamed to manual.yo. + + * Doc/Zsh/guide.yo, Doc/Zsh/intro.yo, Doc/Zsh/manual.yo, + Doc/Makefile.in, Doc/zsh.yo, Doc/ztexi.yo: PWS: 8097: Rename + "guide" to "manual" as PWS is working on another "guide." + + * Completion/User/_a2ps: Alexandre Duret-Lutz: 8094: Update for + newer versions of a2ps. + + * Src/params.c: Don't use tokenized strings as associative array keys. + + * Src/exec.c: PWS: 8086: Don't singsub() the LHS of assignments at + exec time. + + * Src/Zle/complist.c: PWS: 8072: Fix allocation state bug (massive + reindentation but no other real changes). + + * Doc/Zsh/builtins.yo: PWS: 8084: Reset $PWD in the "pwd" builtin + if unable to stat(pwd). This leaves the dirstack in an + inconsistent state and needs more looking-at. + + * Src/exec.c: Be a little smarter about fixing up the command + table when we find a bad element at attempted-execute-time. + +1999-09-28 Bart Schaefer <schaefer@zsh.org> + + * Src/builtin.c: PWS: 8084: Reset $PWD in the "pwd" builtin if + unable to stat(pwd). This leaves the dirstack in an inconsistent + state and needs more looking-at. + + * Completion/User/_man: Tanaka: 8082: Fix PWS's silly thinko. + +1999-09-27 Bart Schaefer <schaefer@zsh.org> + + * Completion/User/_user@host: Adam: 8065: Add forgotten file used + by _my_accounts and _other_accounts. + + * Doc/Zsh/compsys.yo: Adam: 8064: Documentation for _my_accounts + and _other_accounts usages. + + * Completion/User/_my_accounts, Completion/User/_other_accounts: + Adam: 8064,8065,8066: Assorted fixes and documentation. + + * Completion/User/_man: Adam: 8062: Fix to handle colon-delimited + "manpath" output (as corrected by PWS: 8067.) + +1999-09-26 Bart Schaefer <schaefer@zsh.org> + + * Src/signals.c: PWS: 8056: Wrap getiparam() in HEAPALLOC block + for math evaluation reasons. + +1999-09-26 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: Config/version.mk: 3.1.6-pws-6 + + * pws: 8051: Completion/User/_users_on: typos. + + * pws: 8050: Src/utils.c: getkeystring() used in ##<char> + (formally #\<char>) should return unsigned char. + + * pws: 8049: Src/math.c: use HEAPALLOC for math evals. + + * Adam: 8048: Completion/User/_my_accounts, + Completion/User/_other_accounts, Completion/User/_rlogin, + Completion/User/_ssh, Completion/User/_users_on: use + my_accounts and other_accounts for ssh and friends; + user users for write and potentially elsewhere. + + * Adam: 8047: Completion/User/_users: lasts uses _users. + + * Tanaka Akira: 8044: Completion/Base/_regex_arguments, + Completion/Debian/_apt: remove NULs from cache files, + fix some typos. + + * Tanaka Akira: 8042: Doc/Zsh/expn.yo, Src/subst.c, Src/utils.c: + ${(qqqq)...} now does $'...' quotation; rejigging unprintable + characters is now ${(V)...}. + +1999-09-24 Peter Stephenson <pws@ibmth.df.unipi.it> + * Tanaka Akira: 8039: Src/utils.c: quoting of backslashes inside + ${(qqq)...}. + + * pws: 8038: Completion/User/_tar: wouldn't use tar archives + beginning with a ~. + +1999-09-23 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 8033: Src/math.c: use '##' to get code for literal + character as less error-prone than `#\'. + + * Sven: 8030: Src/utils.c: 8019 needed to expand the buffer + even more. + + * pws: 8026: Src/math.c: idiotically made buffer too short + for error message. + + * Sven: 8023: Src/subst.c, Src/utils.c, Doc/Zsh/expn.yo: + ${(qqqq)...} quotes unprintables in bindkey fashion. + + * pws: 8022: Src/Zle/zle_misc.c: digit argument with metafied + digits didn't work. + + * Sven: 8021: Src/Zle/complist.c: keep better track of cursor + position when moving in a menu selection. + + * Vin Shelton and pws: 8020: Src/Zle/deltochar.c, + Doc/Zsh/mod_deltochar.yo: new zap-to-char, uses deltochar() + function but doesn't delete last occurrence (replaces 8010). + + * Sven: 8019: Src/utils.c: buffer overflow quoting newlines. + + * Sven: 8015: Completion/Commands/_history_complete_word, + Src/Zle/zle_tricky.c: bug without history_stop in + _history_complete_word; go backwards on line when scanning + history words. + + * pws: 8014: Src/math.c: arguments after the first in math + function skipped first character. + + * Sven: 8013: Completion/X/_x_keysym, Completion/X/_x_modifier, + Completion/X/_xmodmap: completion for keys and modifiers + in xmodmap. + + * Sven: 8012: Doc/Zsh/compsys.yo: document + incremental-complete-word configuration keys. + + * Sven: 8011: Src/Zle/comp.h, Src/Zle/complist.c, + Src/Zle/zle_tricky.c: better menu insertion with braces. + +1999-09-22 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 8004: Src/Zle/complist.c, Src/Zle/zle_tricky.c, + Doc/Zsh/compctl.yo, Doc/Zsh/compwid.yo: crash in selecting; + documentation for 8001. + + * Sven: 8001: Src/Zle/comp.h, Src/Zle/compctl.c, + Src/Zle/zle_tricky.c, Doc/Zsh/compctl.yo, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Completion/Core/_description: -1 and -2 + flags to completion commands allow removal of consecutive and + non-consecutive duplicates. + + * pws: 7999, 8000: Doc/Makefile.in, Doc/Zsh/guide.yo, + Doc/Zsh/mod_mapfile.yo, Doc/Zsh/mod_mathfunc.yo, + Doc/Zsh/modules.yo, Doc/Zsh/mod_parameter.yo, + Src/Modules/mathfunc.c, Src/Modules/mathfunc.mdd, Src/math.c: + mathfunc module, contains 46 functions for use in math + evaluations; make function arguments behave like normal mathevals. + + * Sven: 7998: Src/Zle/comp.h, Src/Zle/complist.c, + Src/Zle/zle_tricky.c, Src/options.c, Src/zsh.h, + Doc/Zsh/options.yo: Display column sizes can be different + for different completion groups; LIST_PACKED and LIST_ROWS_FIRST + options change listing display behaviour; clean functions up. + + * pws: 7995: Completion/Builtin/_zmodload: when looking for module, + restrict to *.s[ol]. + + * Tanaka Akira: 7989: Completion/Base/_combination, + Completion/Debian/_apt, Completion/Base/_regex_arguments, + Doc/Zsh/compsys.yo: document _combination and _regex_arguments, + clean up relevant completion functions. + +1999-09-21 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7985: Src/Zle/zle_tricky.c: crash in old completion + with non-existent file. + + * pws: 7983: Src/hist.c: bug that hungetc() blindly went + ahead after keyboard interrupt fixed by testing for errflag + in hungetc(). + + * pws: 7981, 7982: Src/math.c, Src/zsh.h: use dupstring() + instead of lvalue stack; better ternary expression parsing; + old `unbalanced stack' messages shouldn't show up so become + debugging messages; arithmetical errors in unevaluated + portions don't cause shell errors. + + * Sven: 7978: Src/exec.c, Src/init.c, Src/utils.c: grow and shrink + underscore parameters properly. + + * Sven: 7976, 7977: Src/builtin.c, Src/math.c, Src/mkbltnmlst.sh, + Src/mkmakemod.sh, Src/module.c, Src/zsh.h, Src/Modules/example.c, + Src/Modules/example.mdd, Doc/Zsh/arith.yo, Doc/Zsh/builtins.yo, + Etc/zsh-development-guide: system for loading math functions + for use in math evals. + + * Sven: 7974: Src/Zle/zle_tricky.c: remove duplicates. + + * Bart: 7968: Completion/User/_mailboxes: mutt fixes. + +1999-09-20 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7963: Src/math.c, Src/subst.c: better error checking + for math evals; don't pass surrounding parentheses down for + $(( ... )). + + * Adam: 7961: Completion/User/_mailboxes: fun with variables and + elm. + + * Sven: 7960: Src/Zle/zle_tricky.c: too much deleted in path + completion. + + * Sven: 7959: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + fixes from previous patches which missed 3.1.6-pws-5. + + * pws: 7957: Src/module.c: `zmodload -e modname' in statically + linked shell didn't work. + + * pws: Config/version.mk: version 3.1.6-pws-5 + + * Sven: 7953: Completion/Commands/_expand_word, + Completion/Core/_expand, Doc/Zsh/compsys.yo: expand_completions + configuration key. + + * pws: 7952: Completion/X/_xutils: xrdb should complete file + arguments. + + * Sven: 7951: Src/subst.c, Doc/Zsh/expn.yo: parameter expansion flags + for quoting with single or double quotes. + + * Sven: 7950: Src/utils.c, Src/Zle/complist.c: more careful + with VARARR's. + + * Sven: 7949: Completion/X/_x_color, + Completion/X/_x_extension, Completion/X/_x_window, + Completion/X/_xutils: completion for standard X utilities. + + * pws: 7948: Src/glob.c, Src/pattern.c: indexes weren't + calculate properly in $mbegin, $mend, $MBEGIN, $MEND because + of Meta bytes. + + * Sven: 7947: Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo: + compstate[insert] can be all to insert all matches. + + * Sven: 7945: Src/Zle/zle_tricky.c, Completion/Core/_multi_parts, + Completion/Core/_path_files: better path completion with braces + + * Sven: 7944: Src/Zle/zle_tricky.c, Completion/Core/_multi_parts, + Completion/Core/_path_files, Completion/Core/_sep_parts: + new heuristic for deciding whether to add strings under match + control or if they are too ambiguous to be useful. + + * Sven: 7943: Doc/Zsh/compsys.yo: docs for long args syntax + in _arguments. + + * Bart: zsh-users/2610: Completion/Builtins/_kill, + Completion/Builtins/_wait, Completion/User/_gdb: split words + for ps arguments (replaces 2609). + + * Bart: 7938: Completion/Base/_arg_compile, Completion/Base/_describe: + pre-compiler for _arguments and typo in describe. + + * Tanaka Akira: 7937: Completion/User/_cvs, Completion/User/_lynx, + Completion/User/_wget: it's good to have _values. + + * Bart: 7934: Completion/User/_telnet: improvement. + + * Bart: 7932: Completion/User/_mailboxes: more generic. + + * Bart: 7929: Src/hist.c, Src/Zle/zle_tricky.c: handle gaps + in history when scanning through it. + + * Bart: 7928: Doc/Zsh/builtins.yo: typo in float stuff. + + * Bart: 7925: Functions/Misc/run-help: various functions and + builtins in manual pages other than zshbuiltins. + + * Adam: 7923: Completion/Core/compinit: compconf quoting tweak. + +1999-09-17 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7921: Src/glob.c: bad test in rarely used + (string/)# globbing construct. + + * Oliver: 7919: Completion/User/_man: try to find a manpath if + none (slightly adapted). + + * Sven: 7917: Src/loop.c: hunk missed from 7915. + + * pws: 7915: Doc/Zsh/arith.yo, Doc/Zsh/builtins.yo, + Src/Modules/parameter.c, Src/builtin.c, Src/cond.c, Src/exec.c, + Src/math.c, Src/mem.c, Src/params.c, Src/subst.c, Src/zsh.h, + configure.in: Floating point support via typeset -F and + typeset -E for variables and in matheval(). mnumber struct + passes around float or integer. + + * Sven: 7903: Completion/Builtins/_cd: more careful with + things from cdablevars. + + * Sven: 7902, 7912: Completion/Base/_arguments, + Doc/Zsh/compsys.yo: autodescribe_options. + + * Sven: 7900: Completion/Commands/_history_complete_word, + Doc/Zsh/compsys.yo: history_stop config opt stops history + cycling past end. + + * Sven: 7896: Src/Zle/zle_tricky.c: cursor positioning. + + * Tanaka Akira: 7892: Completion/User/_webbrowser: initial + implementation of completion for web browsers. + + * Adam: 7891: Completion/Core/compinit: error message in compdef. + + * Tanaka Akira: 7888: Completion/User/_wget: completion for wget. + + * Tanaka Akira; 7887: Completion/User/_telnet: try to get + valid telnet options. + + * Tanaka Akira: 7886: Completion/Base/_describe, + Completion/Debian/_apt, Completion/User/_cvs: -d option for + descriptions. + + * Adam: 7882: Doc/Zsh/expn.yo: parentheses. + +1999-09-16 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Adam: 7871: Completion/User/_perl_basepods, + Completion/User/_perl_builtin_funcs, + Completion/User/_perl_modules, Completion/User/_perldoc: + perl completion. + + * Sven: 7864: Src/Zle/zle_tricky.c: crash when browsing + directory hierarchies with select and selecting an entry. + + * Sven: 7863: Doc/Zsh/mod_parameter.yo, Src/Modules/parameter.c, + Src/Modules/parameter.mdd: $dirstack and $modules special + parameters. + + * Sven: 7866: Doc/Zsh/compsys.yo, Completion/User/_mutt: + action necessary. + + * Sven: 7862: Completion/Base/_arguments, Completion/User/_gcc, + Doc/Zsh/compsys.yo, Src/Zle/zle_tricky.c: completion for gcc, + -M match spec for _arguments, remove duplicate matches. + + * Clint: 7860: Completion/User/_mailboxes, Completion/User/_mutt: + mutt support. + +1999-09-15 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7855: Doc/Zsh/zftpsys.yo, Functions/Zftp/zfopen: + failed zfopen with arguments deletes the stored open parameters. + + * Oliver: 7852: Completion/Builtins/_compdef, + Completion/User/_man: new compdef support, _man works for whatis + and apropos. + + * Sven: 7850: Completion/Base/_arguments: minor cleanup. + + * Sven: 7844: Src/Zle/complist.c, Src/Zle/zle_tricky.c, + Doc/Zsh/compsys.yo, Etc/completion-style-guide, + Completion/Base/_arguments, Completion/Base/_describe, + Completion/Base/_subscript, Completion/Base/_tilde, + Completion/Base/_values, Completion/Builtins/_cd, + Completion/Builtins/_kill, Completion/Builtins/_wait, + Completion/Core/_approximate, Completion/Core/_expand, + Completion/User/_gdb: various matching display bugs + (with compadd -d) and enhancements to correction and + approximation keys. + + * Tanaka Akira: 7840: Completion/Base/_tilde, + Completion/Builtins/_cd: use compadd -d. + + * pws: 7836: Src/Modules/zftp.c: bug from 7767: zftp rmsession + incremented node pointer wrongly and assigned new session + wrongly. + + * pws: 7834: Src/pattern.c: bug from 7825, pure string path + segments wouldn't approximate. + +1999-09-14 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7827: Src/Zle/comp.h, Src/Zle/compctl.c, + Src/Zle/complist.c, Src/Zle/zle_tricky.c, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Completion/Base/_arguments, + Completion/Base/_values, Completion/Core/_display, + Completion/User/_mount: compadd -d for list of elements + to display instead of matches, -l to show one per line, + plus changes in _display and uses thereof; typos in _mount. + + * pws: 7825, 7848: Doc/Zsh/expn.yo, Src/glob.c, Src/pattern.c, + Src/subst.c, Src/zsh.h: (#b) and (#m) globbing flags and + inverses; speed up compilation of pure string patterns. + + * Sven: 7823: Src/Zle/zle_tricky.c: improve joining of completion + strings with different match control behaviour. + + * Sven: 7824: Completion/Base/_arguments, Completion/Core/_message: + improve `no more arguments' message. + + * Sven: 7819: Completion/Base/_arguments, Doc/Zsh/compsys.yo: + use of $options for single character options. + + * Tanaka Akira: 7817: Completion/Debian/_apt, + Completion/User/_socket, Completion/User/_perl_builtin_funcs: + several improvements. + + * Tanaka Akira: 7815: Completion/User/_combination, + Completion/User/_ports, Completion/User/_socket, + Completion/User/_telnet: more sophisticated port/user + combinations via general combination mechanism. + + * Bart: 7813: Src/subst.c: correct incorrect application of + correction in 7697. + + * Tanaka Akira: 7740: Completion/User/_man: handle gzipped and + SGML manual pages. + +1999-09-13 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: zsh-users/2598: Functions/Zle/incarg: zle function to + increment number under cursor. + + * pws: 7812: Completion/X/_xrdb: now exists. + + * Tanaka Akira: 7809: Completion/Debian/_apt, Completion/User/_patch: + new apt options and typo in _patch. + + * Sven: 7808: Completion/Base/_arguments: don't add long options + sometimes. + + * pws: Config/version.mk: 3.1.6-pws-4. + + * Tanaka Akira: 7806: Completion/Users/_pbm: missing backslash. + + * Sven: 7804: Completion/Base/_arguments: `no more arguments' + message. + + * Sven: 7801: Completion/Base/_arguments: listing problem with + arguments. + + * Sven: 7800: Completion/Core/_normal: terminate whence options to + avoid error message. + + * Sven: 7798: Doc/Zsh/compwid.yo, Src/Zle/comp.h, + Src/Zle/compctl.c, Src/Zle/zle_tricky.c, + Completion/Base/_brace_parameter, Completion/Base/_parameter, + Completion/Core/_parameters: compadd -e treats arguments as + parameters for AUTO_PARAM_SLASH and AUTO_PARAM_KEYS. + + * Sven: 7797: Doc/Zsh/compsys.yo, + Completion/Commands/_verbose_list, Completion/Core/_oldlist: + _verbose_list widget makes completion function lists + progressively more verbose. + + * Sven: 7796: _arguments uses describe_values config key; other + misc. fixes. + + * Sven: 7795: Completion/User/_mount: mounting excitement. + + * Sven: 7793: Completion/User/_ispell: ispell completions. + + * Sven: 7792: Completion/User/_bison, Completion/User/_flex: + not particularly hairy bison and flex completions. + + * Sven: 7791: Src/Zle/zle_tricky.c: completion code numbers. + + * Sven: 7790: Completion/User/_pbm, Completion/User/_ssh, + Completion/Linux/_rpm: miscellaneous tidying. + + * Sven: 7789: Completion/User/_tiff: completions for conversions + to/from tiff format. + + * Bart: 7784, 7787: Src/utils.c: memory use in bslashquote + (cf. 7713). + + * Tanaka Akira: 7779, 7781: Completion/User/_hosts, + Completion/User/_telnet, Completion/User/_socket: telnet and + socket completions with ports. + + * Bart and pws: 2592: Functions/Zle/history-search-end, + Functions/Zle/predict-on: new Zle functions for fancy history + searching. + + * Tanaka Akira: 7778: Completion/Base/_regex_arguments: implement + cache. + + * Tanaka Akira: 7777: Completion/Base/_regex_arguments, + Completion/Debian/_apt: more apt utilities handled, condensed to + single file; _apt-cache, _apt-get and _apt_arguments deleted. + +1999-09-10 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7767: Completion/Builtins/_zftp, Doc/Zsh/mod_zftp.yo, + Doc/Zsh/zftpsys.yo, Functions/Zftp/zfanon, + Functions/Zftp/zfautocheck, Functions/Zftp/zfcd, + Functions/Zftp/zfcd_match, Functions/Zftp/zfcget, + Functions/Zftp/zfdir, Functions/Zftp/zffcache, + Functions/Zftp/zfgcp, Functions/Zftp/zfget, + Functions/Zftp/zfget_match, Functions/Zftp/zfgoto, + Functions/Zftp/zfinit, Functions/Zftp/zfmark, + Functions/Zftp/zfopen, Functions/Zftp/zfparams, + Functions/Zftp/zfpcp, Functions/Zftp/zfrglob, + Functions/Zftp/zfsession, Functions/Zftp/zfstat, + Functions/Zftp/zftp_chpwd, Functions/Zftp/zftp_progress, + Functions/Zftp/zftransfer, Functions/Zftp/zfuget, + Functions/Zftp/zfuput, Src/Modules/zftp.c: + new session management for zftp (session, rmsession); new + functions zfsession, zftransfer, zffcache; various completion + and argument-handling improvements. + + * pws: 7765: Src/builtin.c, Src/exec.c: getopts didn't reset + counter for index into option list properly; didn't set option + variable to "?" when printing its own error message. + + * Tanaka Akira: 7763: Completion/Base/_arguments: bad argument + indexing. + +1999-09-09 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7750: Completion/Base/_arguments: fix option aliasing. + + * Tanaka Akira: 7748: Completion/User/_urls, + Completion/Core/_display: missing "$@" and X. + + * Sven: 7747: Doc/Zsh/compsys.yo, Completion/Base/_first, + Completion/Commands/_history_complete_word, + Completion/User/_cvs, Completion/User/_groups, + Etc/completion-style-guide: Mainly documentation changes: group + configuration keys into a single section. + + * Tanaka Akira: 7744: Completion/User/_patch: argument changes. + + * Sven: 7739: Completion/User/_rlogin: improvements. + + * pws: 7738: Completion/User/_man: didn't work with correction + and approximation. + + * Sven: 7737: Completion/User/_ssh, Completion/User/_users: + slogin, scp, and user@host; use array $users if defined. + + * Sven: 7736: Src/Zle/zle_tricky.c, Completion/Core/_display: + + * Sven: 7734: Src/Zle/complist.c, Src/Zle/zle_tricky.c: + displays of lists with disparate lengths and different groups of + matches with the same name. + + * Tanaka Akira: 7729, 7735: Completion/Debian/_apt-get, + Completion/Debian/_apt_arguments, Completion/Debian/_apt-cache: + apt-get and apt-cache completion improvments. + +1999-09-08 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Tanaka Akira: 7723: Completion/User/_cvs: typo. + + * Sven: 7722: Completion/User/_dvi, Completion/User/_rlogin, + Completion/User/_ssh, Completion/User/_yodl, + Completion/User/_yp: new _yodl and all-round improvements. + + * Tanaka Akira: 7720: Completion/Base/_regex_arguments, + Completion/Debian/_apt_arguments, _apt-get: regular expression + argument parsing, used for apt-get. + + * Sven: 7718, 7719: Completion/Base/_arguments, + Completion/Linux/_rpm, Doc/Zsh/compsys.yo: better handling for + combined single-letter options. + + * Sven: 7716: Completion/Core/_complete, Completion/Core/_normal, + Completion/Base/_precommand: modify 7693 so that _normal always + resets _compskip unless called from _complete (via -s option). + + * Sven: 7714: Src/Zle/zle_tricky.c: problem displaying multiople + completion messages. + + * Sven: 7713: Src/utils.c: buffer for backslash quoting was too + short. + + * Sven: 7712: Src/text.c: fix core dump in case. + + * Bart: 7707: Config/installfns.sh, Config/uninstallfns.sh: + insert $DESTDIR as internal prefix of $fndir. + + * Bart, Tanaka Akira: 7705, 7706, 7709: Completion/User/_cvs: + select cvs function by substitution. + + * Clint: 7704: Makefile.in, Completion/Makefile.in, + Doc/Makefile.in, Functions/Makefile.in: betting distclean for + Completion/Makefile, Functions/Makefile, Config/defs.mk. + + * Clint: 7703: Config/installfns.sh: $DESTDIR prefixes $fndir. + + * Bart: 7697: Src/subst.c: sroted -> sorted. + +1999-09-07 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7693: Completion/Base/_precommand: unset _compskip for + redoing _normal after _precommand. + + * Sven: 7690: Completion/Base/_arguments, Completion/User/_gprof, + Completion/User/_gs, Completion/User/_gv, + Completion/User/_patch, Completion/User/_xargs, + Completion/X/_x_arguments, Completion/X/_xt_arguments, + Doc/Zsh/compsys.yo: more exclusion lists and states, different + return value for using states. + + * Sven: 7687: Completion/Base/_arguments, Completion/User/_yp, + Doc/Zsh/compsys.yo: _arguments allows case where an option turns + off normal argument handling, new _yp function, space in action + means no action. + + * Sven: zsh-users/2576, zsh-users/2578: fix typeset -Z and typeset + -R. + + * Tanaka Akira: 7675: Completion/User/_hosts: remove nslookup, + since that uses _nslookup. + + * Adam: 7674: Doc/Zsh/compsys.yo, Etc/completion-style-guide: + typos. + + * Adam: 7671: Completion/Linux/_rpm: tyeset -> typeset, + build_b completes *.spec. + + * Tanaka Akira: 7670, 7686: Completion/User/_cvs, INSTALL, + configure.in: _cvs back in one function, remove Completion/Cvs. + + * John Williams: 7669: Src/builtin.c: __CYGWIN should be __CYGWIN__ + +1999-09-06 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7662: Etc/completion-style-guide: subcommands and using + funcall to test state functions. + + * pws: 7660: Src/Modules/cap.c: changes as per 7591; initialize + variables to silence compiler. + + * Sven: 7656: Doc/Zsh/compsys.yo: display fixes. + + * Sven: 7655: Src/Zle/zle_tricky.c: bug completing on continuation + line. + + * Sven: 7654: Src/Zle/zle_thingy.c: error calling zle -R outside + widget. + + * pws: Config/version.mk: 3.1.6-pws-3 + + * Sven: 7652: Doc/Zsh/compsys.yo, Completion/Base/_values, + Completion/User/_hosts, Completion/User/_nslookup, + Functions/Misc/nslookup: complete assignment-like arguments, + nslookup wrapper with completion. + + * pws: 7651: Doc/Zsh/options.yo: document HIST_FIND_NO_DUPS. + + * Sven: 7650: Doc/Zsh/compsys.yo, Completion/Base/_arguments, + Completion/Core/_display, Completion/Core/compinit, + Completion/Linux/_rpm, Completion/User/_urls, + Completion/X/_x_color, Etc/completion-style-guide: + urls_dir -> urls_path, colors_path allow paths for URLs and X + colours; funcall; _arguments changes: options assoc, states + available using '->name', option descriptions for mutually + incompatible options, descriptions of individual options, + option_prefix allows ~command; _display for compadd -y; + new _rpm; style guide additions. + + * pws: 7649: Src/pattern.c: bug with excluding multiple + directories with ~ in 7611, 7626. + + * Adam Spiers: 7647: Completion/User/_perl_basepods, + Completion/User/_perl_builtin_funcs, + Completion/User/_perl_modules, Completion/User/_perldoc: + completion for perldoc. + + * Tanaka Akira: 7641, 7646: Completion/Debian/_apt-get, + Completion/Debian/_deb_packages: handle different apt-get + keywords. + +1999-09-03 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7639: Doc/Zsh/expn.yo, Src/glob.c: remember that + (foo/)# is a special case for file globbing; fix bug that + that pattern generated a null string. + + * pws: 7637: Doc/Zsh/expn.yo: clarify some glob descriptions + including change that / inside parentheses is error (rather than + just screwing up pattern) for file globbing. + + * Bart: zsh-users/2567: Doc/Zsh/options.yo: new improved + GLOB_COMPLETE description. + + * pws: 7636: Doc/Zsh/builtins.yo, Doc/Zsh/params.yo, + Src/builtin.c, Src/zsh.h, Src/Modules/mapfile.c, + Src/Modules/parameter.c: typeset -h allows locals to hide + specials; turned on automatically for specials in mapfile and + parameter modules. + + * Sven: 7635: Completion/User/_urls: change configuration key to + urls_dir. + + * Tanaka Akira: 7634: Completion/Debian/_apt-get, + Completion/Debian/_deb_packages: completion for apt-get. + + * Tanaka Akira: 7633: Completion/User/_lynx, + Completion/User/_urls: completion for lynx and general URL + completion. + +1999-09-02 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7632: Doc/Zsh/zftpsys.yo, Functions/Zftp/zfautocheck, + Functions/Zftp/zfinit, Functions/Zftp/zfrglob, + Functions/Zftp/zftp_progress: bar-style progress meter, zfconfig + associative array for configuration. + + * Sven: 7631: Completion/User/_pbm: comment about overriding + definitions. + + * Sven: 7630: Src/zle_tricky.c: when using a matcher spec + generating matches with missing characters, position on last set + of missing characters instead of first. + + * Sven: 7628: Src/params.c, Src/Modules/parameter.c, + Completion/Core/_parameters, Completion/Core/_path_files: + parameters gives `undefined' message; _parameters doesn't + load undefined parameters; do partial path expansion after + parameters. + + * pws: 7627: Src/params.c: don't autoload parameter just to + unset it (replaces 7616). + + * Sven: 7625: Completion/Base/_arguments: expansion fix. + + * Tanaka Akira: 7623: Completion/X/_xv: complete .jpg and .png + files. + + * Bart: 7618: Config/installfns.sh, Config/uninstallfns.sh: + space required in $sdir substitution. + + * Bart: 7617: Src/signals.c: set err to -1. + +1999-09-01 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7613: Completion/User/_gv: typos + + * pws: 7611, 7626: Src/pattern.c, Src/parse.c, Doc/Zsh/expn.yo: + strip parentheses from case label with open and close + parentheses; use unions for pattern alignment, optimize lowest + level character reading routine, optimize ...*string pattern, + optimize search for characters terminating processing, document + some more existing pattern features. + + * Sven: 7607: Completion/Base/_arguments: behaviour after a + non-option when using `*::'. + + * Sven: 7605: Src/exec.c, Src/jobs.c: use killpg instead of + altering process group when leader exits, fix fg test to use + killpg. + + * Sven: 7598: Src/Zle/zle_tricky.c: REC_EXACT behaviour. + + * Sven: 7596, 7601: Completion/Base/_arguments: interaction of option + arguments with default. + + * pws: 7591: Src/utils.c: cap_free should take caps (not pointer + to it) as arg. + + * Bart: 7584: Src/jobs.c, Src/signals.c, Src/system.h: handle + broken ESRCH by redefining ESRCH to EINVAL. + + * Tanaka Akira: 7580: Completion/Cvs/_cvs, + Completion/Cvs/_cvs_diff, Completion/Cvs/_cvs?history_x: + arguments for options; cvs diff description. + + * Sven: 7574, 7577, 7597: Src/subst.c, Doc/Zsh/expn.yo: modify + 7539 so that the % flag just does % expansion, while %% does + full prompt expansion. + + * Sven: 7573: Src/signals.c, Src/exec.c, Src/utils.c: fix return + value of killjb(); pipelines which lose their leader get a new + one. + +1999-08-31 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Will Day: 7362: Src/Makefile.in, Src/hist.c, Src/jobs.c, + Src/signals.c, Src/system.h, acconfig.h: support for BeOS: test + more capabilities. This was present in 6-pws-1, but without + a Changelog entry. + + * Sven: -7540: withdrawn, use ${${${(M)name#pattern}:+then}:-else}. + + * Tanaka Akira: 7436: Src/exec.c: exec last command in sequence + properly; don't increment SHLVL when exec'ing. + + * Sven: 7564: Completion/X/_xterm, Completion/Pbmplus/_pgmtoppm, + Completion/Pbmplus/_pnmalias, Completion/Pbmplus/_pnmmargin, + Completion/Pbmplus/_ppmchange, Completion/Pbmplus/_ppmmake, + Completion/Pbmplus/_ppmtoacad, Completion/User/_gs, + Completion/X/_xdvi, Completion/X/_xfig, Completion/X/_xsetroot, + Completion/X/_xt_arguments, Completion/X/_xterm, + Completion/X/_xv: change some names. + + * Bart: 7562: corresponding fix for Config/uninstallfns.sh + + * Tanaka Akira: 7561: Config/installfns.sh: administrative files + from Functions and Completion were installed by mistake. + + * Bart: 7414: Doc/ztexi.yo: @'@' breaks texinfo; use '@:'. + + * Bart: 7557: Src/Makefile.in: typo adding $(DESTDIR) patch by + hand. (Also from Ollivier Robert, 7558, and Oliver Kiddle). + +1999-08-30 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: Config/version.mk: 3.1.6-pws-2 made available. + + * Tanaka Akira: 7551: Doc/Zsh/expn.yo: mismatched parenthesis. + + * Sven: 7549: Src/hist.c: shell wouldn't exit if writing history + file failed. + + * Sven: 7548: Completion/User/_xargs: new. + + * Sven: 7541: Completion/Base/_arguments: fix. + + * Sven: 7540: Src/subst.c, Doc/Zsh/expn.yo: ${name^pat^then^else} + tests string and substitutes appropriately. + + * Sven: 7539: Src/subst.c, Doc/Zsh/expn.yo: % parameter flag does + prompt escapes. + + * Sven: 7538: Completion/Base/_arguments: completion of trailing + non-option arguments. + + * Sven: 7535: Src/glob.c: don't restore badcshglob. + + * Sven: 7533: Completion/Rpm/*, Completion/Base/_arguments, + Completion/User/_a2ps, Completion/User/_configure, + Completion/User/_dvi, Completion/User/_gdb, Completion/User/_gs, + Completion/User/_gs_name, Completion/User/_patch, + Completion/User/_pspdf, Completion/User/_tar, + Completion/User/_use_lo, Completion/User/_xfig, + Completion/User/_xsetroot, Completion/User/_xterm, + Completion/X/_gv, Completion/X/_xdvi, + Completion/X/_xt_arguments, Completion/X/_xv, + Doc/Zsh/compsys.yo: argument handling; new rpm functions. + + * Sven: 7532: Src/Zle/zle_tricky.c: completion bug. + + * Bart, Sven: 7529, 7530: process groups not continued properly. + + * Bart: 7527: KSH_ARRAYS messed up assignment to a + hash, plus 7521 typo. + + * Bart: 7521: Src/init.c: replace 7472 and 7490 with thing that + tests if hashed command is really there. + + * Sven: 7517: Completion/Base/_arguments, + Completion/Pbmplus/_pbmtext, Completion/Pbmplus/_pbmtopk, + Completion/Pbmplus/_pktopbm, Completion/Pbmplus/_pnmcomp, + Completion/Pbmplus/_pnmtoddif, Completion/Pbmplus/_psidtopgm, + Completion/Pbmplus/_pstopnm, Completion/User/_gdb, + Completion/User/_gprof, Completion/User/_x_options, + Completion/User/_xfig, Completion/User/_xsetroot, + Completion/X/_x_borderwidth, Completion/X/_x_geometry, + Completion/X/_x_locale, Completion/X/_x_name, + Completion/X/_x_resource, Completion/X/_x_selection_timeout, + Completion/X/_x_title, Completion/X/_xv: use _arguments more. + + * Tanaka Akira: 7516: Completion/Base/_arguments, + Completion/Cvs/_cvs, Completion/Cvs/_cvs_command: fixes. + + * Sven: 7515: Doc/Zsh/compsys.yo, Completion/Base/_arguments, + Completion/Pbmplus/_pnmtotiff, Completion/Pbmplus/_ppmtomitsu, + Completion/User/_find: _arguments allows descriptions in list of + possibilities. + + * Sven: 7514: Src/glob.c, Doc/Zsh/expn.yo: use REPLY to set + filename. + + * Bart: 7510: Src/init.c: zsh -ce interprets e as option, not + command. + + * Sven: 7512: Completion/Base/_arguments: complete function. + + * Sven: 7500: Completion/Base/_arguments, + Completion/Cvs/_cvs_command, Completion/User/_find: + word-splitting in _arguments. + + * Tanaka Akira: 7495: Completion/Cvs/_cvs*: new cvs functions. + + * Sven: 7496: Src/glob.c, Src/zsh.h, Doc/Zsh/expn.yo: glob + qualifier e:string: with $_ set to filename. + + * Sven: 7492: Completion/Base/_arguments, Completion/User/_find, + Completion/X/_x_font: speed up _arguments. + + * Sven: 7490: Src/exec.c: change 7472 not to try test on hashed + command. + + * Sven: zsh-users/2511: Src/Zle/zle_tricky.c: bad (old) completion + after `$(<'. + + * Sven: 7482: Src/exec.c, Src/glob.c, Src/zsh.h, Doc/Zsh/expn.yo: + F:func: glob qualifier calls func to determine whether to + include file. + + * Sven: 7480: Src/Zle/zle_tricky.c, Completion/Core/_multi_parts, + Completion/User/_xterm, Completion/X/_x_font, + Completion/X/_xt_arguments: matching bug. + + * Sven: 7478: Doc/Zsh/compsys.yo, Completion/Base/_arguments, + Completion/Builtins/_vars_eq: handling of :: in _arguments. + + * Tanaka Akira: 7477: Completion/User/_xterm, + Completion/X/_x_borderwidth, Completion/X/_x_font, + Completion/X/_x_geometry, Completion/X/_x_locale, + Completion/X/_x_name, Completion/X/_x_resource, + Completion/X/_x_selection_timeout, Completion/X/_x_title, + Completion/X/_xt_arguments, Completion/X/_xt_session_id: + use standard XToolkit arguments. + + * Sven: 7472: Src/exec.c: crash in isreallycom(). + + * Sven: 7469: Completion/Base/_arguments, + Completion/Base/_command_names, Completion/Builtins/_zftp, + Completion/Core/_complete, Completion/Core/_main_complete, + Completion/Core/_normal, Completion/User/_x_display, + Completion/User/_x_options, Completion/User/_xterm: fix + word-splitting for _arguments. + + * Sven: zsh-users/2505: parameter with non-empty prefix. + + * Tanaka Akira: 7468: Completion/User/_xterm: xterm argument + completion. + + * Sven: zsh-users/2502: completing '=$' erased word. + + * Sven: 7467: Doc/Zsh/compsys.yo, Completion/Base/_arguments, + Completion/Base/_long_options: allow an _arguments option to + swallow everything to end of line. + + * Sven: 7465: Src/params.c: reverse indexing of associative + arrays. + + * Sven: 7463: Src/Zle/compctl.c, Doc/Zsh/compsys.yo, + Completion/Base/_arguments, Completion/Base/_brace_parameter, + Completion/Base/_condition, Completion/Base/_long_options, + Completion/Base/_math, Completion/Base/_parameter, + Completion/Base/_tilde, Completion/Base/_vars, + Completion/Builtins/_vars_eq, Completion/Builtins/_zftp, + Completion/Commands/_correct_filename, + Completion/Commands/_correct_word, + Completion/Commands/_expand_word, + Completion/Commands/_history_complete_word, + Completion/Commands/_most_recent_file, + Completion/Commands/_read_comp, Completion/Core/_parameters, + Completion/Core/compinit, Completion/User/_chown, + Completion/User/_dir_list, Completion/User/_exec_funcs, + Completion/User/_find, Completion/User/_gprof, + Completion/User/_rlogin, Completion/User/_su, + Completion/User/_tar, Completion/User/_users, + Util/completion-style-guide: miscellaneous completion fixes. + + * Tanaka Akira: 7460. 7461: Completion/Base/_arguments, + Completion/User/_patch: _arguments -s handling with --. + + * Clint Adams: 7459: Config/funcinst.mk, Config/installfns.sh, + Doc/Makefile.in, Src/Makefile.in, Src/Makemod.in.in: can set + DESTDIR to specify install prefix. + + * Tanaka Akira: 7458: Completion/Base/_arguments, + Completion/Base/_long_options, Completion/User/_patch: + _patch function and required fixes. + + * Sven: 7457: Doc/Zsh/compsys.yo, Completion/Base/_arguments: + handle short options. + + * Sven: 7455: Src/Zle/complist.c: handle lengths of capabilities. + + * Sven: 7454: Doc/Zsh/compsys.yo, Completion/Base/_arguments, + Completion/Core/_message: option prefix configuration. + + * Sven: 7429: _pbm: more stuff + + * Tanaka Akira: 7451: Completion/Core/_message, + Completion/Pbmplus/_pbmtoepsi, Completion/Pbmplus/_pktopbm, + Completion/Pbmplus/_yuvtoppm, Doc/Zsh/compsys.yo: some small + mistakes. + + * Sven: 7441: Src/Zle/zle_tricky.c: matching control bug. + + * Sven: 7450: Completion/Base/_arguments, + Completion/Base/_long_options, Completion/Base/_subscript, + Completion/Builtins/_zmodload, Completion/User/_colors, + Completion/User/_cvs, Completion/User/_gdb: explanations and + arguments. + + * Tanaka Akira: 7431: Completion/User/_colors: null glob. + + * Tanaka Akira: 7432: Completion/User/_cvs: update. + + * Sven: 7449: Src/module.c, Src/params.c: better errors for failed + autoloading; + + * Sven: 7448: too many files under Completion to list, including + new Pbmplus directory: revised pbm completion; pattern completion + only if no specific completion; descriptions for completions; + better handling for command line arguments. + + * Tanaka Akira: 7417: Completion/User/_pdf, Completion/User/_ps, + Completion/User/_pspdf: more programs that take ps or pdf files. + + * Sven: 7430: matching control bug: Src/Zle/zle_tricky.c, + Completion/User/_colors, Completion/User/_cursors, + Completion/User/_x_options, Completion/User/_xsetroot: + bug in matching control. + + * Tanaka Akira: 7428: Completion/User/_pbm, + Completion/User/_colors: fix some problems. + + * Sven: 7420: Src/Zle/zle_tricky.c, Doc/Zsh/compsys.yo, + Completion/Base/_first, Completion/Builtins/_zftp, + Completion/Core/_complete, Completion/Core/_main_complete, + Completion/Core/_normal, Completion/User/_colors, + Completion/User/_pbm, Completion/User/_x_options: _compskip + extended to allow choice of what to skip. + + * Sven: 7418: Completion/User/_pbm: new + + * Sven: 7446: print -P %s didn't work. + + * Bart: 7410: parameter flags doc for M. + + * Sven: 7404: Src/glob.c: repeatedly matching empty string + (somehow). + +1999-08-06 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: Config/version.mk: 3.1.6-pws-1 made available. + + * Sven: 7386: Src/subst.c: Order of q and Q parameter flags matters. + +1999-08-05 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7380: Src/hist.c, Src/subst.c, Doc/Zsh/expn.yo: flag X for + reporting errors de-quoting. + + * Sven: 7374: Src/subst.c, Doc/Zsh/expn.yo: modifier to remove one + level of quotation, corresponding flags. + + * Sven: 7373: Src/Zle/comp.h, Src/Zle/zle_tricky.c, + Completion/Base/_brace_parameter: support nested parameter + expansion type of deal. + +1999-08-04 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7355: Src/Zle/compctl.c, Src/Zle/zle_tricky.c: make + compadd quoting consistent with compgen. + +1999-08-02 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7349: Src/loop.c, Src/signals.c: restore errflags in + select after a zleread; fix problem restoring function-style trap + after a function set it to something else. + + * Sven: 7348: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + remove path_keepdir configuration key but don't do keepdir + trick unless _files had no type arguments. + + * Sven: 7345, 7346, 7347: Src/Zle/zle_tricky.c: match control + problems. + + * Sven: 7344, 7353: Src/cond.c, Src/Modules/example.c, + Src/Zle/compctl.c, Util/zsh-development-guide: conditions can + get the tokenized string; better quoting behaviour in + IPREFIX/ISUFFIX. + + * Sven: 7343: Src/Zle/zle_tricky.c: quote path prefix and suffix + earlier. + + * pws: 7342: Doc/Makfile.in: use makeinfo ... || exit 0 to + ignore result of makeinfo. + + * Irving Wolfe: 7336: utils.c: same fcntl() change. + + * Geoff: 7335: init.c: third argument for fcntl(). + +1999-08-01 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: Config/version.mk: zsh 3.1.6 released. + +1999-07-30 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws, Bart: 7321, 7325: Src/hist.c: NO_BANG_HIST wasn't working + at all, but be careful not to disable too much when it's + in effect. + + * Tanaka Akira: 7318: Completion/User/_cvs: more improvements + +1999-07-29 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7316: Doc/Zsh/compsys.yo: mention that compctl -M control + is available and fix some typos. + + * pws: unposted: Doc/Zsh/metafaq.yo: sites in Italy and Poland + (the one in Italy is not `official', but is actively mirroring + ftp.zsh.org anyway). + + * Felix Rosencrantz: 7311: Src/Zle/zle_tricky.c: matching control + left dangling pointers. + + * Tanaka Akira: 7312: Completion/User/_cvs: don't quote ignore + patterns. + +1999-07-28 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7308, 7309: Src/Zle/zle_tricky.c: glob patterns were + limited to PATH_MAX and length wasn't tested. + + * Tanaka Akira: 7307: Completion/User/_cvs: remove parentheses, + complete argument options. + + * pws: 7305: Doc/Zsh/zftpsys.yo, Functions/Zftp/zfanon, + Functions/Zftp/zfget, Functions/Zftp/zfopen, + Functions/Zftp/zftp_chpwd: use URL-style paths in opening; + zfget -c sends output to stdout; don't delete current directory + information if we haven't really changed directory. + + * Bart: 7301: Completion/User/_cvs: restored .file completion + +1999-07-27 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7300: Completion/Core/compdump: wasn't ignoring . in fpath, + although compinit was. + + * pws: 7299: configure.in: don't use gcc -pedantic any more, since + there are too many messages about `long long' and variable-sized + arrays not being available in ISO C. + + * pws: 7298: Src/Zle/zle_tricky.c: missing dupstring() in + comp_match. + + * pws: 7297: Completion/Core/_path_files, Doc/Zsh/compsys.yo: + path_keepdir config key required for 7141 to come into effect + due to significant side effects. + + * Tanaka Akira: 7290, 7292: Completion/User/_cvs: condensed + version of all _cvs completion stuff; completes files if not + under CVS control; use compgen -p to work around problem with + quoted characters. + + * Andrej: 7827: Etc/Machines: Siemens info + + * Bart: 7285, applied by hand: Completion/User/_cvs: parameter + fixes, commit bug. + + * Tanaka Akira: 7284: Completion/Core/compdump: careful when + two shells start at once. + + * Tanaka Akira: 7282: Completion/User/_cvs, + Completion/User/_cvsaddp, Completion/User/_cvsentries_modified, + Completion/User/_cvsprefix, Completion/User/_cvsremovep, + Completion/User/_cvstargets, Completion/User/_cvstargets_modified: + handle modified files using stat module. + +1999-07-26 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Tanaka Akira: 7278: Completion/Base/_complete_opts: + less verbosity + +1999-07-25 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Tanaka Akira: 7276, 7277, 7279: Completion/User/{_cvs, _cvsaddp, + _cvsentries, _cvsprefix, _cvsremovep, _cvsrepositories, + _cvsrevisions, _cvstargets, _cvstest}, Misc/compctl-examples: + more modular cvs new completion support including CVS/Entries; + bug fix for old CVS completion. + + * Bart: 7275: Doc/intro.ms: now works with groff. + + * Bart: 7274: Src/Zle/zle_tricky.c: don't go beyond end of line + + * pws: from Bart: Etc/CONTRIBUTORS, Etc/NEWS: updates for 3.0.6 + +1999-07-24 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: version 3.1.6-test-3 + + * pws: lastest FAQ.yo, FAQ + +1999-07-23 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7264: Completion/Commands/_correct_filename, + Completion/Commands/_correct_word, + Completion/Commands/_expand_word, + Completion/Commands/_history_complete_word, + Completion/Commands/_most_recent_file, + Completion/Commands/_read_comp, Completion/Core/compinit, + Doc/Zsh/compsys.yo: compdef -k takes -n option not to override + existing keybinding; used in completion command widgets to + keep user bindings during compinit. + + * Sven: 7260: Completion/Core/_main_complete: commented-out + option saving bit can uses parameter module + + * Sven: 7259, 7261: Src/subst.c, Src/Modules/parameter.c, + Doc/Zsh/expn.yo, Completion/Core/_normal, + Completion/Core/_parameters: parameter module provides + local information; used in _parameters; _normal uses + $commands when available. + + * pws: 7257: Completion/Core/_parameters: simplify. + + * Tanaka Akira: 7256: Completion/User/_bzip2, + Completion/User/_bunzip2: new. + + * Tanaka Akira: 7255: Completion/User/_make: complete after =. + + * Oliver: 7254: Completion/Builtins/_aliases: do unalias. + +1999-07-22 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7253: Doc/Zsh/arith.yo, Doc/Zsh/builtins.yo, + Doc/Zsh/compctl.yo, Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, + Doc/Zsh/cond.yo, Doc/Zsh/expn.yo, Doc/Zsh/files.yo, + Doc/Zsh/func.yo, Doc/Zsh/grammar.yo, Doc/Zsh/invoke.yo, + Doc/Zsh/jobs.yo, Doc/Zsh/mod_stat.yo, Doc/Zsh/mod_zle.yo, + Doc/Zsh/options.yo, Doc/Zsh/params.yo, Doc/Zsh/redirect.yo, + Doc/Zsh/zle.yo, Doc/ztexi.yo, Util/zsh-development-guide: + General documentation fixes and enhancements. + + * Sven: 7251: Src/Zle/zle_tricky.c: completion words wrapper + tweak thing. + +1999-07-21 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Bart: 7246: Completion/Builtin/_functions: complete for + _functions. + + * Tanaka Akira, Sven: 7243, 7250: Completion/Base/_complete_opts, + Completion/User_cvs: enhancements for cvs completion. + + * Sven: 7241: Completion/Base/_first: typos + + * pws: 7231: README, Etc/CONTRIBUTORS: notes for latest release + including possible incompatibilities. + + * Bart: 7230: Src/exec.c: cancd2 didn't free string properly + (or at all, in fact). + + * Tanaka Akira, Bart: 7228: Completion/User/_cvs, + Completion/User/_complete_opts: completion for cvs. + +1999-07-20 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7226: INSTALL: mention that dependent libraries of zle + can't be used if zle is dynamically loaded on systems without + working RTLD_GLOBAL. + + * pws: 7223: Doc/Makefile.in, Doc/Zsh/compsys.yo, + Doc/Zsh/compwid.yo, Doc/Zsh/mod_complist.yo, + Doc/Zsh/mod_zftp.yo, Doc/Zsh/mod_zle.yo, Doc/Zsh/zftpsys.yo: + dependences for texinfo manual; extra index entries. + + * Sven: 7220: Src/Zle/complist.c: `*=' works and the last + column is set. + + * Sven: 7219: Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo: + compstate[force_list] now works as documented. + + * Sven: 2456: Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo: + clear explanation string; document compstate[insert]='' + is same as unsetting. + + * pws: 7218: Doc/Makefile.in, Doc/zman.yo: delete all manual + page lines beginning .'; work around yodl .SH ""NAME problem. + + * Sven: 7217: Src/exec.c: duplicate function name for scriptname. + + * Sven: 7216: Src/Zle/zle_tricky.c: insertion with old and + new completion. + + * Tanaka Akira: 7213: Doc/Makefile.in: postprocess manual pages + to remove yodl cruft. + + * Ollivier: 7209, 7210: configure.in, Etc/MACHINES: Elf and a.out + dynamic loading on FreeBSD (MACHINES entry adapted). + +1999-07-19 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Tanaka Akira: 7205: Src/Modules/mapfile.c: MS_SYNC was not + defined on SunOS 4. + + * pws: 7202: Src/Modules/clone.c: add an extra zero argument + to ioctl() to make three. + + * pws: from Ollivier Robert: Etc/MACHINES: FreeBSD 4.0 builds OK. + + * pws: 7196: Src/Zle/zle_tricky.c: try to handle multiple supplied + (-P) prefixes better. + + * pws: 2446: Completion/User/_rlogin: handle user@host better. + + * pws: version 3.1.6-test-2 + + * pws: 7192: Src/glob.c: bug with null in pattern if at end of + test string (matched as if a real character). + +1999-07-18 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7185: Src/glob.c: don't use strcoll() for character + ranges [...] because it can have side effects. + + * pws: 7184: Src/lex.c: histactive didn't get get zeroed before + non-interactive history use, hence interactive lines with + remhist() were junked more than once. + + * Wayne: 7181: Doc/Zsh/options.y, Doc/Zsh/params.yo: history docs. + + * Wayne: 7180: Src/Zle/complist.c, Src/utils.c: warnings. + +1999-07-16 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7172: Doc/Zsh/options.yo, Src/builtin.c, Src/exec.c, + Src/options.c, Src/utils.c, Src/zsh.h: minor bugs with + 7164 fixed; CHASE_DOTS resolves ..'s to physical path; + CHASE_LINKS doesn't do logical path rationalization; + xsymlink() and xsymlinks() simplified and option-dependence + removed. + + * Sven: 7171: Src/builtin.c: alternate form of Digital/gcc + bug workaround. + +1999-07-15 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7164: Src/builtin.c, Src/exec.c: AUTOCD now allows + paths with symlinks (as real cd always did); simplify code + for testing for existing directory on foo/.. before removing + foo/..; as a side effect, relative cd's from directory which + has been deleted don't work. + + * Sven: 7161: Src/Zle/comp.h, Src/Zle/complist.c, + Src/Zle/zle_tricky.c, Completion/Base/_brace_parameter: + be more careful with quote-prefix/suffix and path-prefix/suffix + especially with accept-and-menu-complete. + + * pws: 7155: Functions/Zftp/zfgoto, Functions/Zftp/zfinit: + zfgoto can cd without needing to re-login; zfinit uses + zmodload -e to check for zftp. + + * Sven: 7154: Src/Zle/complist.c, Src/Zle/zle_refresh.c, + Src/Zle/zle_tricky.c, Doc/Zsh/mod_complist.yo: don't + list too many times on ambiguous completion; don't do + menu-selection if no alwayslastprompt behaviour. + +1999-07-14 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7148: INSTALL: User subdirectory + + * Thomas Köhler: 7146: Completion/User/_make: didn't work. + + * pws: 7145: Completion/User/_sh: use compset -q for completing + after -c option + + * Sven: 7143: Src/Zle/complist.c, Src/Zle/zle_tricky.c: + listing got confused with only hidden matches. + + * Sven: 7141: Completion/Core/_path_files: if there are + no completions in a valid directory when we have a path ending + in /, use the directory as a completion, to avoid + correction/approximation of the existing directory. + + * pws: 7139: Src/builtin.c: not particularly pleasant fix + to problem that `cd nonexistent/..' silently did nothing, while + making `cd ..' work even if current directory has gone. + + * Sven: 7138: Completion/User/_hosts, Completion/User/_x_options: + _hosts passes arguments as options to compadd. + + * Oliver: 7136: Completion/User/_rlogin, + Completion/User/_x_options: use _hosts. + + * Sven: 7135: Src/Zle/zle_tricky.c, Completion/Core/_path_files: + change quoting of files again. + + * Sven: 7133: Doc/Zsh/expn.yo, Doc/Zsh/mod_complist.yo: + ZLS_COLOURS not required for complist to work. + + * pws: 7127: configure.in: help now shows --disable-dynamic + and --disable-lfs. + + * Sven: 7126: Src/Zle/comp.h, Src/Zle/comp1.c, Src/Zle/compctl.c, + Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo, + Functions/Zle/incremental-complete-word: compstate key + normal_nmatches; more i-c-w prompt escapes + + * Sven: 7123: Src/Zle/zle_tricky.c: clear list on expansion + failure. + +1999-07-13 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7119: Src/Zle/zle_tricky.c: status from expansion + functions. + + * Sven: 7116: Doc/Zsh/compwid.yo, Doc/Zsh/expn.yo: minor + changes. + + * pws: 7114: Src/parse.c, Src/utils.c: line numbers again: + flushing line in a script made lineno appear one too large; + introduce zwarn() function. + + * Sven/pws: 7112: Src/Zle/zle_params.c, Doc/Zsh/zle.yo: change + array keys to scalar KEYS, works more like read -k; + documentation. + + * Sven: 7110: Src/Modules/zftp.c, Doc/Zsh/compsys.yo, + Etc/MACHINES: signed char warnings in zftp; document + _long_options options; Digital UNIX problem. + + * Sven: 2432: Src/builtin.c: workaround Digital UNIX 4.0 + + gcc 2.8.1 bug. + + * Sven: zsh-users/2430: Etc/NEWS: mention chmod-like mode glob + qualifier. + + * Sven: 7108: Misc/job-control-tests: more tests + + * Bart: 7107: configure.in: too many x's in lfs handling. + + * Sven: 7106: Functions/Zle/incremental-complete-word: prompting + changes. + + * pws: unposted: update .distfiles and .cvsignore: _sh, _su + zshcompsys.yo, zshcompwid.yo, zshzftp.yo, zshcompsys.1, + zshcompwid.1, zshzftp.1 were missing from the distribution. + + * Sven: 7105: Src/Zle/Zle_tricky.c: restore the command line + in more places. + +1999-07-12 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 7103: Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo: update + CURRENT with compset -q; modify test for quoted delimiters. + + * pws: version 3.1.6-test-1 + + * Sven: 7099: Completion/Core/_main_complete, Doc/Zsh/compsys.yo: + config key last_prompt means don't turn off alwayslastprompt on + prefix. + + * Sven: 7097: Completion/Core/_oldlist: keeps old command line. + +1999-07-09 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7091: configure.in, INSTALL: change defaults for + dynamic and large file support to be enabled. + + * Sven: 7083: Src/Zle/compctl.c, Src/Zle/zle_tricky.c, + Doc/Zsh/compwid.yo: compset -q unconditionally splits + the current word. + + * Sven: 7082: Completion/Base/_parameter: use _parameters + + * pws: 7076: Completion/Base/_command_names, + Completion/Base/_first, Completion/User/_su: %resume should be + in _command_names; _su should check $SHELL. + + * pws: 7075, 7080, 7092: Completion/Core/compinit, + Config/funcinst.mk, Config/installfns.sh, + Config/uninstallfns.sh, INSTALL: Yet another attempt to install + shell functions in a sensible way; compinit adds to the end of + $fpath; fixed typo that it didn't check existing fpath properly. + + * Oliver: 7067: Completion/Base/_first, Completion/User/_su, + Completion/User/_sh: check for %resume on command line; + new completions for _su and _sh. + + * pws: 7066: configure.in: function install makefile in + source, not build, hierarchy. + + * Sven: 7062: Src/Zle/complist.c, Src/Zle/zle_tricky.c, + Doc/Zsh/compsys.yo, Doc/Zsh/mod_complist.yo: undo works + inside menu-selection for items completed by + accept-and-infer-next-history; display is more reliable. + + * Sven: 7058: Src/Zle/zle_params.c: turn off menu completion + if the command line gets altered by a zle function. + +1999-07-08 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7049: Src/builtin.c: eval didn't save/restore lexical + state. + + * pws: 7046: Src/loop.c: xtrace for case and for statements. + + * Sven: 7043: Completion/Core/_oldlist: Extra sophistication + when using _oldlist with a particular completer. + + * pws: 7042: Etc/BUGS, Etc/CONTRIBUTORS, Etc/NEWS, + Doc/Zsh/builtins.yo, Doc/Zsh/expn.yo, Doc/Zsh/mod_complist.yo, + Doc/Zsh/params.yo: Changes to admin files for 3.1.6; some minor + documentation changes. + + * Sven: 7039: Completion/Commands/_read_comp: trapping SIGINT + no longer necessary after 7038. + + * pws: 7038: Src/Zle/zle_main.c: restore breaks whenever errflag + is restored as SIGINT handler sets both. + + * Sven: 7036: Src/Zle/complist.c: make sure old list is thrown + away when doing accept-and-infer-next-history in menu-completion. + + * Sven: 7028: Src/Zle/zle_tricky.c, + Functions/Zle/incremental-complete-word: problems when BUFFER + changes, %u in i-c-w prompt, config key for showing list. + + * Sven: 7026: Completion/Core/_main_complete, + Completion/Core/_match, Completion/Core/_oldlist, + Completion/Core/compinit: More information stored in assoc array + _lastcomp about the previous completion. + + * Sven: 7025: Src/Zle/complist.c: remove list when accepting + and retrying completion when unambiguous. + +1999-07-07 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 7021: Src/utils.c: error message in findsep() was + erroneous. + + * pws: 7020: Src/params.c: error message for whole assoc array + assignment. + + * Oliver: 7005: Src/builtin.c, Doc/Zsh/builtins.yo: alias + takes +g and + flags. + + * Sven: 7004: Src/Zle/zle_refresh.c: reset showinglist on + clearlist. + + * pws: 7002: Completion/Commands/_read_comp: does completion + lists; handle errors better. + + * pws: 7001: Src/hist.c: line numbers were wrong in some error + messages (e.g. conditions) when reading from a string + (e.g. autoloaded functions). + + * pws: 6998: Src/Zle/zle_bindings.c: restore history-search + bindings \M-n, \M-p. + + * Sven: 6996: Src/Zle/complist.c, Src/Zle/zle_tricky.c, + Doc/Zsh/mod_complist.yo: accept-and-infer-next-history + in menu-select accepts a match, then restarts menu selection. + + * Sven: 6995, 7000: Src/math.c, Src/utils.c, Doc/Zsh/arith.yo: + allow bindkey strings in after #\ in math mode. Also + incremental-complete-word and insert-files, added by hand + to directory Functions/Zle, with appropriate changes to + configure.in and INSTALL. + + * Sven: 6992: Src/Zle/zle_main.c, Src/Zle/zle_misc.c, + Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, Doc/Zsh/mod_zle.yo: + zle -R can take list arguments; zle -cR clears the list; + zle -U puts keys in the unget queue. + + * Geoff: 6991: configure.in: NetBSD can use both ELF and a.out. + +1999-07-06 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Andrej: 6990: Completion/Builtins/_cd, + Completion/Core/_path_files: some local variable fixes. + + * pws: 6987: Src/builtin.c: `typeset +f' and `functions +' + should just print the function name. + + * pws: 6986: Doc/Zsh/builtins.yo, Doc/Zsh/params.yo, + Src/builtin.c, Src/params.c, Src/zsh.h: special parameters + can become local, remaining special; be more careful that + only the most global parameter can appear in the environment. + + * pws: 6984: Doc/Zsh/compsys.yo: typo in 6973 docs + +1999-07-05 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6982: Src/exec.c: variable assignment with redirection is + interpreted as variable assignment with redirection, not + nullcmd. + + * pws: 6981: Completion/Commands/_read_comp: -n should be -z. + + * Sven: 6979: Completion/Core/_path_files: compconfig[path_expand] + fix. + + * Sven: 6977: Completion/Core/_match: cosmetic `if' change. + + * Sven: 6975: Src/Zle/zle_tricky.c: fix quoting of tildes at + the start of file names. + + * Sven: 6974: Src/exec.c: mark superjob as locked as soon + as started. + + * pws: 6973: Completion/Commands/_read_comp, Doc/Zsh/compsys.yo: + _read_comp allows function arguments and ^U but won't add + non-printables; document Completion/Commands widgets. + + * Sven: 6971: Src/exec.c, Src/jobs.c: backgrounding jobs forked + from current shell works again; job table not filled up by + current shell subjobs; current/previous job not lost. + +1999-07-04 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6970: Completion/Base/_default, Completion/Builtins/_cd, + Completion/Commands/_read_comp: handle magicequalsubst and + cdablevars optios; _read_comp can read and execute a completion + function (_*) or compgen argument (-*) on the fly. + + * pws: 6969: Doc/Zsh/builtins.yo, Src/builtin.c: print -b + uses full bindkey string possibilities. + + * Tanaka Akira: 6968: Completion/Core/compinit: compinit -D + didn't actually work. + + * pws: 6967: Completion/Core/_path_files: final return status + inverted. + + * pws: 6966: Completion/Makefile.in, Functions/Makefile.in, + Config/funcinst.mk, configure.in, INSTALL: prevent overwriting + of changed shell functions on installation; move function + installation code to funcinst.mk; clear up INSTALL a bit. + +1999-07-03 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6962: Doc/Zsh/prompt.yo, Src/prompt.c: %/ and %~ take + numbers for trailing path segments like %c and %C, %N can too; + function promptpath() to implement this. + + * pws: 6957: 3.1.5-pws-25 made available + + * pws: 6955, 6956: Completion/Core/compinit, + Completion/Core/compinstall, Doc/Zsh/compsys.yo: better handling + of subdirectory structure for completion functions; -d is default + for compinit, -D turns it off; documentation updated for installed + files; bugfix for compinstall re-using compconf arguments. + +1999-07-02 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Tanaka Akira: 6953: Completion/Builtins/_cd: use pushd code for cd + + * Sven: 6945: Completion/Core/_expand: error expanding :] + + * Sven: 6941: Src/exec.c, Src/jobs.c: neater fix for time builtin. + + * Oliver: 6939: Completion/User/_hosts, + Completion/Base/_subscript, Misc/compctl-examples: better way of + using /etc/hosts; complete POSIX character classes. + + * Sven: 6937: Doc/Zsh/mod_complist.yo, Src/Zle/complist.c: use + send-break to exit menu selection and return to normal menu + completion. + +1999-07-01 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 6936: Src/jobs.c: time builtin was broken. + + * Sven: 6933: Src/exec.c, Src/jobs.c, Src/Signals.c: More job + control fixes: running external command after loop in function; + function on left hand side of pipeline with loop on right. + +1999-06-29 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 6908, 6926: Src/exec.c, Src/jobs.c, Src/zsh.h: more job + control fixes: functions with programs that send strange + signals to parents should work. + + * Sven: 6904: Src/Makefile.in: bugs with cleaning up modules + in Src. + + * Sven: 6903: Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo: + compstate[insert] can have a space at the end to force inserting + a space after completion. + + * Sven: 6902: Src/Zle/complist.c, Doc/Zsh/mod_complist.yo: + menu-select will use %S/%s if ZLS_COLO[U]RS is not defined. + + * Sven: 6901: Src/exec.c, Src/init.c, Src/jobs.c: back off + some (but not all) recent job handling patches to avoid more + serious problems with recalcitrant programs. + +1999-06-28 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6899: Doc/Zsh/params.yo, Doc/Zsh/prompt.yo, Src/init.c: + default PS4 is now "+%N:%i> ", except in [k]sh emulation. + + * Andrej: 6893: aczsh.m4: use existing environment value when + testing for large file support. + + * pws: 6890: Doc/Zsh/params.yo, Doc/Zsh/prompt.yo, Src/prompt.c: + %N and %i prompt escapes provide script or function name and + line number. + + * Sven: 6887: Src/exec.c, Src/jobs.c: another loop killing problem. + + * Geoff: 6884: Src/Zle/zle_refresh.c: bug when redisplaying line + one shorter than terminal width + +1999-06-27 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6881: Doc/Zsh/mod_zle.yo: explain keymap linking + + * pws: 6879: Src/exec.c: update command hash pointer if builtin + is autoloaded after a prefork(). + + * Bart: 6873: Src/Zle/zle_tricky.c: magic-space doesn't feep + quite so much. + + * Geoff: 6871: Src/Zle/complist.c: optimi[sz]ations for outputing + coloured/colorized output. + + * pws: 6866: Src/exec.c, Src/init.c: signed/unsigned character + problems; one was causing SunOS 4.1.3_U1 with gcc 2.7.0 to hang. + +1999-06-26 Peter Stephenson <pws@ibmth.df.unipi.it> + + * 3.1.5-pws-24 made available + +1999-06-25 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6857: Completion/Core/compinit, + Completion/Core/compinstall, Doc/Zsh/compsys.yo: compinit and + compinstall are now functions which unfunction and autoload + themselves. _compdir is used by compinstall to record where + it found the completion directories. compinit is now otherwise + stuck with fpath. + + * pws: 6851, 6853: typeset -g doesn't locallize parameters; bug + that unset parameters were recreated global instead of at + some higher local level; handle PM_AUTOLOAD consistent with other + flags. + + * Sven: 6850: Src/init.c: always generate a new pgrp for the + shell, since the parent (e.g. xterm) may not have done that + and zsh now runs programs in its own pgrp. + + * Sven: 6848: Src/exec.c: don't suspend if the shell is the + only thing to suspend (or something like that). + + * Sven: 6841: Src/loop.c: %_ in else branches for PS4 + +1999-06-24 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6834: Src/glob.c, Src/hashtable.c: dyncat() changed always + to use heap memory (as it erroneously claimed); hashtable element + tablename (used for debugging) freed. + + * Bart: 6830: Src/params.c: don't create the hashtable for an + assoc array on assignment unless there is something to put in it. + + * Sven: 6825: Src/Zle_tricky.c: make sure path prefix and suffix + are quoted in filename completion; recalculate length of match + string. + + * Sven: 6824: Src/exec.c, Src/signals.c: functions got deleted + from the process table too early for job control. + + * pws: 6823: Src/exec.c, Src/utils.c: names and line numbers + of functions printed for errors during execution. + + * Sven: 6822: Src/Zle/complist.c, Src/Zle/zle_tricky.c: assorted + completion fixes: crash with old completion; too many spaces + with menu inserting; too many beeps with LISTBEEP. + + * Sven: 6819: Src/exec.c, Src/jobs.c, Src/signals.c: Run + jobs inside shell constructs in the same process group as the + shell itself. + + * Sven: 6817: Src/Zle/comp.h, Src/Zle/complist.c, + Src/Zle/zle_tricky.c: Change ZLS_SELECT to SELECTMIN; + don't automatically switch on select widget until there are + $SELECTMIN choices. + +1999-06-23 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6816: Doc/Zsh/params.yo, Src/utils.c: ZBEEP parameter + gives string to output instead of beeping. + + * Sven: 6815: Src/Zle/complist.c: switch off menu-select for + hidden matches. + + * pws: 6814: Doc/Zsh/mod_zle.yo, Doc/Zsh/options.yo, + Doc/Zsh/zle.yo, Src/Zle/deltochar.c, Src/Zle/iwidgets.list, + Src/Zle/zle_hist.c, Src/Zle/zle_main.c, Src/Zle/zle_misc.c, + Src/Zle/zle_move.c, Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c, + Src/Zle/zle_utils.c, Src/Zle/zle_vi.c, Src/Zle/zle_word.c: + Zle determines whether to feep by the return status (except + for some inner code loops); completion widgets return 1 if + something failed in the hierarchy outside the widget function; + the -n and -N options work properly. + + * pws: 6812: Src/subst.c: ${(AA)foo=}, or anything that gives + a null string after the =, creates an empty assoc array. + + * pws: 6806: Completion/Core/compdump, Completion/Core/compinit, + Completion/Core/compinstall, Doc/Zsh/compsys.yo: compdump is now + a function which unfunctions itself; default dumpfile location + is now ${ZDOTDIR:-$HOME}/.zcompdump + + * Sven: 6807: Src/Zle/complist.c: accept-and-menu-complete + advances the menu-select selection too. + + * Sven: 6802: Src/Zle/complist.c: change some default colours + + * pws: 6801: Doc/Zsh/builtins.yo, Src/builtin.c: Make emulate -L + turn on LOCAL_TRAPS, too. + + * Sven: 6796: Src/Zle/zle_main.c, Src/Zle/zle_thingy.c, + Doc/Zsh/mod_zle.yo, Completion/Core/compinit: zle -la lists + all widgets, just the name; zle -la <NAME> tests if <NAME> is + defined. + + * Sven: 6793: Src/Zle/complist.c, Src/Zle/zle_keymap.c, + Src/Zle/zle_main.c, Doc/Zsh/mod_complist.yo: Local keymaps can be + defined, currently only used with menu-select. + +1999-06-22 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 6786: Src/Zle/zle_tricky.c, Doc/Zsh/compctl.yo: only use + a range when you are after the first pattern in it. + + * Sven: 6780: Src/Zle/complist.c: wasn't showinglist when it + thought it was. + + * Sven: 6778: don't delete function from job tables + + * pws: 6776: Doc/Makefile.in, Doc/Zsh/compsys.yo, + Doc/Zsh/mod_complist.yo: Tweakchen for menu-select patch; + also (unposted) changed name collist to complist wherever it + occurs. + + * Sven: 6774, 6775: Src/Zle/collist.c, Src/Zle/comp.h, + Src/Zle/zle.h, Src/Zle/zle_main.c, Src/Zle/zle_tricky.c, + Doc/Zsh/compsys.yo, Doc/Zsh/mod_collist.yo, + Doc/Zsh/mod_compctl.yo, Doc/Zsh/mod_deltochar.yo, + Doc/Zsh/modules.yo, Completion/Core/_path_files: Improvements + for menu-select widget; ZLS_SELECT turns menu-completion + into menu-selection; key bindings more natural; highlighting + more useful + + * Oliver: 6772: Src/Zle/zle_tricky.c: use the whole + command text for job completion. + +1999-06-21 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Sven: 6760: Src/Zle/zle_tricky.c: menucompletion displaying new + list of matches sometimes got confused. + + * Sven: 6755: Src/jobs.c: status of restarted job including + current shell processes was wrong. + + * Sven: 6753: Src/Zle/collist.c, Src/xmods.conf: + load collist + + * Sven: 6747: Src/Zle/collist.c, Src/Zle/zle_main.c, + Src/Zle/zle_tricky.c: menu-select allows you to move + cursor to select completions; uses ma list colouring + capability. + + * Sven: 6742: Src/Zle/collist.c, Src/Zle/collist.mdd, + Src/Zle/zle_main.c, Src/Zle/zle_tricky.c, Src/module.c, + Src/zsh.h, Doc/Zsh/mod_collist.yo, Doc/Zsh/mod_compctly.yo, + Doc/Zsh/mod_deltochar.yo, Doc/Zsh/modules.yo, + Util/zsh-development-guide: collist module: colour completion + lists by setting ZLS_COLOURS (or even ZLS_COLORS) variables. + + * pws: 6737: Doc/Zsh/builtins.yo, Doc/Zsh/zle.yo: simplifications + suggested by Bart. + + * Bart: 6732: Doc/Zsh/compsys.yo: restore missing bits of Sven's + patches (not the zle_tricky.c hunk). + + * Bart: 6731: Doc/Zsh/compctl.yo: spelling correction + +1999-06-20 Peter Stephenson <pws@ibmth.df.unipi.it> + + * zsh-3.1.5-pws-23 made available + + * Sven/pws: 6616, 6609, 6726 (merged): `zle [ -N ] [ -n num ] + widget args'; internal widgets handle arguments and return + values; search commands use arguments; read -[kq] can use + zle's key mechanism; zle -R [msg] redisplays line editor; + digit-argument feeps if the keypress wasn't a digit; + universal-argument handles argument as numeric. + + * pws: 6725: Src/signals.c: more local traps: now don't add trap + to list to restore when outside a function, but do if the function + simply unsets a trap which was set outside. + +1999-06-18 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6718: Completion/Core/compinit, Completion/Core/compdump, + Doc/Zsh/compsys.yo: rebind existing completion widgets for new + completion instead of defining new ones. + + * pws: 6717: Doc/Zsh/options.yo, Src/exec.c, Src/options.c, + Src/signals.c, Src/zsh.h: Option LOCAL_TRAPS saves and restores + traps on exit from functions; set for ksh emulation. + + * Tanaka Akira: 6716: Completion/User/_chown: some systems use `:' + as separator in chown. + + * Oliver/Sven: 6709, 6710: Completion files Base/_subscript, + User/_chown, User/_groups, User/_x_options: _subscript shows + listing for ordinary arrays; new chown and chgrp completions; + example _x_options can complete displays. + + * Sven: 6707: Src/exec.c: Shell structures not at the end + of a pipeline are suspendable. This is the only way + of stopping a command in such a structure where the command + handles interruptions in such a way that zsh doesn't see them. + +1999-06-17 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6705: Doc/Zsh/builtins.yo, Src/builtin.c, Src/exec.c, + Src/init.c, Src/input.c, Src/parse.c: some more LINENO + subtleties: embedded function definitions have correct line + number; all lines, not just ones with new PS1, are counted + interactively; traps with trap builtin use line no. of + surrounding environment. + + * Sven: 6693: Src/Modules/parameter.c, Src/builtin.c, Src/exec.c, + Src/input.c, Src/zsh.h: update LINENO properly when parsing a + string. + + * Sven: 6692: Src/Zle/comp.h, Src/Zle/compctl.c, + Src/Zle/zle_tricky.c, Doc/Zsh/compwid.yo, + Completion/Builtins/_kill, Completion/Builtins/_wait, + Completion/User/_gdb: allow the -y option to compadd for + specifying an array to use when listing. + + * Sven: 6689: Src/Zle/zle_tricky.c, Completion/Base/_subscript: + test for closing bracket in get_comp_string(). + + * Oliver: 6688: Zsh/compsys.yo, Zsh/func.yo, Zsh/mod_zle.yo, + Zsh/params.yo, Zsh/zftpsys.yo: spelling changes. + + * Wayne: 6682: Src/hist.c: Uniquified history commands are limited + to size $SAVEHIST, so that the last $((HISTSIZE-SAVEHIST)) + commands are always available even with HIST_EXPIRE_DUPS_FIRST. + + * Sven: 6686: Completion/Core/_match, Completion/Core/_path_files, + Doc/Zsh/compsys.yo: New configuration keys path_cursor, + match_insert. + + * Sven: 6685: Src/Zle/compctl.c, Src/Zle/zle_params.c, + Doc/Zsh/zle.yo, Completion/Base/_first, + Completion/Commands/_correct_filename, + Completion/Commands/_most_recent_file, + Completion/Core/_approximate, Completion/Core/_expand, + Completion/Core/_list: NUMERIC is unset if no prefix was given; + it may be unset explicitly, and if set again will be restored in + the expected way. + + * Wayne: 6683: Src/exec.c: ambiguous brace + + * Wayne: 6681: Src/builtin.c: start-of-loop check for history -r + was wrong. + +1999-06-16 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6679: Src/Zle/zle_thingy.c, Doc/Zsh/compwid.yo: always + use .complete-word etc. as widget type in zle -C. + + * pws: 6677: Doc/Zsh/guide.yo: avoid TeX overfull hbox problem. + + * Andrej: 6674: Doc/zsh.yo, Doc/ztexi.yo: change order of initial + formatting instructions to make interaction with system + configuration files better. + + * pws: 6660: Doc/Zsh/compctl.yo: pointer to new completion system + at top of compctl documentation. + + * pws: 6659: Src/Zle/zle_tricky.c: a couple of NULL's should be 0's + + * pws: 6658: Doc/Zsh/options.yo, Src/init.c: options strings at + shell startup can end with whitespace (for #!), but anything + after the whitespace causes an error. + + * Sven: 6657: Completion files Base/_subscript, + Builtins/_autoload, Builtins/_bindkey, Builtins/_echotc, + Builtins/_kill, Builtins/_limits, Builtins/_wait, + Builtins/_zmodload, User/_dd, User/_find, User/_gdb, User/_make, + User/_mh, User/_rlogin, User/_x_options: New gdb completion; + improved make completion; use compadd in preference to compgen + -[sk]; configuration keys ps_args, ps_listsargs. + + * Sven: 6654: Src/Zle/zle_tricky.c: empty display list after -y. + + * Bart: 6652: Src/exec.c: trailing spaces confused #! emulation. + + * Sven: 6649: Src/Zle/zle_tricky.c: behaviour of compctl -l. + + * Bart: 6646: Src/lex.c: extra braces to enhance beauty of code + which appeared in 3.0.5. + +1999-06-15 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Tanaka Akira: 6642: Completion/Base/_tilde: complete directory + stack elements after ~+ or ~-. + + * Tanaka Akira: 6641: Src/subst.c: treat ~-0 like ~0 + + * pws: 6639: configure.in: don't try type of $enable_val if empty + (needed when off_t/ino_t are 64-bit without explicit enabling). + + * zsh-3.1.5-pws-22 made available + + * Oliver: 6636: Completion/Builtins/_limits: wasn't working + + * Bart: 6617 + minor changes: Src/utils.c: Be more careful keeping + $COLUMNS and $LINES correct, particularly if exported. + + * Sven: zsh-users/2388: Src/jobs.c: while loops etc. in shells + running without MONITOR were hard to kill. + + * Bart: 6628: Src/params.c: setting slices of unset array + caused a crash. + +1999-06-14 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6626: Src/mem.c: in zsh's malloc, try to make sure when + sbrk'ing that it's sufficiently well aligned. + + * Oliver: 6624: Completion/Builtins/_kill, + Completion/Builtins/_wait: more widely functioning process + handling + + * pws: 6623: Completion/Makefile.in, Config/defs.mk.in, + Functions/Makefile.in, INSTALL, Src/init.c, Src/zsh.mdd, + configure.in: --enable-function-subdirs allows installation + into subdirectories of the function directory and sets the + initial $fpath appropriately. + + * Oliver: 6620: Completion/Builtins/_jobs: handle disown, too. + + * pws: 6618: Doc/Zsh/func.yo, Doc/Zsh/grammar.yo, Src/lex.c: + with SH_GLOB set, function definition parentheses after the + first word on the line allow spaces inside. + + * Sven: 6614: Src/Zle/zle_tricky.c, Completion/Brace/_brace_parameter: + completion after quotes in parameters + + * pws: 6610: Src/glob.c: globbing flags shouldn't be active + without extendedglob. + + * Bart: 6608: Doc/Zsh files compctl.yo, compsys.yo, compwid.yo, + expn.yo, files.yo, mod_mapfile.yo, mod_zftp.yo, params.yo, + zftpsys.yo, zle.yo: spelling corrections + +1999-06-12 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6601: Src/Makefile.in: don't remake Makemod just + to clean up files + + * pws: 6600: Doc/Zsh/arith.yo, Doc/Zsh/compctl.yo, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, Doc/Zsh/expn.yo, + Doc/Zsh/guide.yo, Doc/Zsh/jobs.yo, Doc/Zsh/metafaq.yo, + Doc/Zsh/mod_compctl.yo, Doc/Zsh/mod_zftp.yo, Doc/Zsh/params.yo, + Doc/Zsh/redirect.yo, Doc/Zsh/zftpsys.yo, Doc/Zsh/zle.yo, + Doc/zman.yo, Doc/ztexi.yo, Util/zsh-development-guide: + Formatting of unfilled text now handled by three distinct + macros example(), indent(), nofill(); compctl description node + is now called `Programmable Completion Using compctl' to + distinguish it from widget completion; don't put chapters on + separate pages because many are too short. + + * Wayne: 6599: Src/Zle/zle_tricky.c: unitialised variable warnings + from gcc + +1999-06-11 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6598: Doc/Zsh/zftpsys.yo, Functions/Zftp/zfinit, + Functions/Zftp/zfgoto, Functions/Zftp/zfmark, + Functions/Zftp/zftp_chpwd, Completion/Builtins/_zftp: + add zfmark and zfgoto implementing bookmarks (including use + ncftp bookmarks) for zftp function suite; autoload functions + from zfinit; patcomps -> _patcomps. + + * pws: 6596: Doc/Zsh/arith.yo: update on size of integers and + increase in clarity of presentation + + * Sven: 6589: Completion/Core/_path_files: use :h and :t instead + of pattern matching + + * Sven: 6587, 6588: Src/Zle/zle_misc.c, Doc/Zsh/options.yo: < and + > shouldn't remove a suffix, but | does + + * Sven: 6586: Src/exec.c, Src/lex.c, Src/loop.c: don't modify + struct cmd to insert cmd args and flags, always pass those + separately + +1999-06-10 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Andrej: 6581: Doc/Makefile: dependencies for manuals + + * Sven: 6579: Src/exec.c: old hack of storing shell function + args in struct cmd doesn't work any more + + * Sven: 6577: Src/exec.c, Src/text.c, Src/utils.c: expunge + simplifyright(), which appears no longer to have an effect + + * pws: 6575: Doc/Zsh/mod_mapfile.yo: avoid mapping long files + + * pws: 6571: Src/Builtins/rlimits.c: use appropriate printf() + routine in printulimit() instead of just casting to long + + * pws: 6570: configure.in, INSTALL: some systems have + sizeof(off_t) or sizeof(ino_t) == 8 and sizeof(long) == 4 even + without explicit enabling, so check and if so use the + --enable-lfs code. + + * pws/Sven: 6567, 6568: Completion/Base/_vars: complete assoc + array keys + + * pws: 6566: Src/params.c: junk testhash assoc array + + * pws: 6563: sporadic: minor changes affecting casts, sizes + of integers, unused variables; add index for subscripts in + manual + + * Bart: email: Src/zsh.h: alternative definition for zulong + + * Bart: 6558: Src/builtins.c: printing functions with the + UNALIASED flag + + * Sven: 6557: Doc/zsh/compsys.yo: a few typos + +1999-06-09 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Andrej: 6556: aczsh.m4: don't disable setting variables + for --enable-lfs just because some other variables were set + + * Sven: 6554: Src/Zle/zle_tricky.c: display bugs with compadd -X: + newline missing and display unnecessarily altered + + * pws: 6552: configure.in, aczsh.m4, acconfig.h, Src/zsh.h: + define separate unsigned 64-bit integer; try __int64_t and + __uint64_t. + + * Sven: 6548: Src/Zle/zle_tricky.c: fix `compctl -l' + + * Andrej: 6544: configure displays info on function installation + + * Sven: 6542: Src/builtin.c, Src/exec.c, Src/hist.c, Src/init.c, + Src/lex.c: when not using interactive history, don't allocate + history at all + + * Andrej: 6541: configure.in: add missing `test' + + * Sven: 6535: Completion/core/_normal: an eval was unnecessary + + * Bart: 6534: Completion/Core/compdump, Completion/Core/compinit, + Doc/Zsh/builtins.yo, Src/builtin.c, Src/exec.c, Src/zsh.h: + autoload -U defines functions which don't use expand aliases + during loading; used in new completion code to protect + functions. + + * Sven: 6527: Src/builtin.c, Src/cond.c, Src/exec.c, Src/glob.c, + Src/hashtable.c, Src/init.c, Src/jobs.c, Src/lex.c, + Src/linklist.c, Src/loop.c, Src/math.c, Src/mem.c, Src/params.c, + Src/parse.c, Src/signals.c, Src/text.c, Src/utils.c, Src/zsh.h: + various sets of patches: + - make zhalloc() use a pointer to the first free heap + - make zsh-mem allocators keep some memory back when freeing + - reduce the amount of allocation work done in the exec.c + execution hierarchy + - don't duplicate execution trees any more than necessary, e.g. + execute functions from stored tree + + * pws: Etc/MACHINES: Danek Duvall reports --enable-dynamic OK + on Solaris 2.7, despite previous reports; Sven says on Digital + UNIX 4.0, you need special DLLD and LDFLAGS. + +1999-06-08 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: 6525: Src/lex.c (gettokstr): allow parentheses after + first character in command word + + * Tanaka Akira: 6522: configure.in: help string for --enable-fndir + had wrong default directory + + * pws: 6520: configure.in: --enable-fndir might be yes, + so turn it into ${datadir}/zsh/functions + + * 3.1.5-pws-21 made available + + * Sven: 6515: Src/Zle/zle_tricky.c: fix memory problems with 6492 + + * Wayne: 6510: Completion/Core/compinit: another nounset problem + +1999-06-07 Peter Stephenson <pws@ibmth.df.unipi.it> + + * pws: configure.in, Config/defs.mk.in, Functions/Makefile.in, + Completion/Makefile.in, rearrangement of Functions + subdirectories: --enable-fndir allows function installation, + defaults to ${datadir}/zsh/functions; is compiled into $fpath; + FUNCTIONS_INSTALL can specify functions to install e.g. + 'Core/* Base/* Builtins/* Zftp/*'. + + * pws: 6509: Src/Zle/zle_tricky.c: comp_setunset -> comp_setunsetptr + + * pws: 6506: Completion/Core/compinit, Doc/Zsh/compsys.yo: if + completion dumpfile is not writeable, use + ${ZDOTDIR:-$HOME}/.zcompdump + + * Sven: 6502: Doc/Zsh/options.yo: document 6496 + + * Sven: 6496: Src/Zle/zle_misc.c (makesuffix): more characters + that can't be part of a filename + + * Sven: 6493: Completion/Core/_approximate, + Completion/Core/_expand: %e wasn't being replaced properly in + correction prompts + + * Sven: 6492: Src/Zle/comp.h, Src/Zle/comp1.c, Src/Zle/compctl.c, + Src/Zle/zle_main.c, Src/Zle/zle_tricky.c, Doc/Zsh/compctl.yo, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, + Completion/Base/_brace_parameter: Completion inside quotes + now acts as if the file name is the entire quoted string; + `compctl -h' takes a command line from inside a quoted string; + the compctl tests q[s], q[d], q[b] are true if we are in single, + double, back quotes; compset -q tests quotes and splits the word, + affecting $PREFIX, $SUFFIX and setting $IQPREFIX, $IQSUFFIX for + the bits which will now be ignored. + + * pws: 6490: Completion/Core/compinit: nounset workaround + + * Bart: 6485: Src/loop.c: only show one screenful at a time + in select, as LINES doc implies it should do + + * Sven: 6484: Src/Zle/zle_main.c, Src/Zle/zle_tricky.c: close + fd 0 during zle widgets and completion and redup back afterwards + (removed unnecessary zclose()'s) + + * Wayne: 6481: Doc/Zsh/builtins.yo, Doc/Zsh/options.yo, + Src/hist.c: improved new history documentation and comments + + * Wayne: 6480: Src/hist.c: Ignore some lines in remhist() to + workaround crashes attempting to add already removed lines + + * Tanaka Akira: 6478: Completion/User/_make: complete files + as fallback (but use _files instead of compgen -f) + +1999-06-06 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Naoki Wakamatsu <naoki-w@ht-net21.ne.jp>: 6477: configure.in: + undefine etcdir, not zshenv + +1999-06-05 Peter Stephenson <pws@ibmth.df.unipi.it> + + * Merge ChangeLog entry from patchlist.txt in 3.1.5-pws-20 + These are briefer than normal ChangeLog entries, but upgrading + all of them is too much work. + + * pws: 6473: Src/Modules/mapfile.c: munmap() after writing file + + * Bart: 6472: doc for 6458 + + * pws: 6470: options.yo doc for globalrcs + + * Sven: 6468: -first- context example; allow $compcontext for + direct context in _complete; other stuff + + * pws: 6464: fix problem with 6433; disallow nested parameter + substitution without braces + + * Sven: 6458: allow seconds in globbing qualifier time comparisons + + * Zefram: off-list: metafaq updates + + * pws: 6437: rearrange quotes in expn.yo, zftpsys.yo, minor + corrections + + * pws: 6433: allow quotes around names of parameters in braces + + * pws: 6431: su saga again: new documentation + + * Bart: 4127: su saga: 6299 and 6313 backed off; this alters + ZSH_NAME using zgetenv("SHELL"). It can be turned into an + --enable if anyone complains. + + * Wayne: 6430: history tweaks: more careful ignoring history with + foreign lines, changed name incappendhistory + + * pws: 6424: reduce excess quoting in info files + + * pws: 6421: _mh should use $words instead of $argv + + * pws: 6416: document ${(f)"$(foo)"} change and nesting of quotes + in braces + + * Sven: 6414: completing parameters with extra quotes, don't + complete local parameters + + * Sven: 6411: fix display bug on terminals which can do + TCMULTRIGHT (gap left when clearing list). + + * pws: 6410: RCS option can now take affect at any point during + initialisation, new GLOBAL_RCS applies to /etc/z* files. + + * Bart: 6404: singleton arrays treated as scalars locally (as + before), but correct array/scalar status is passed to enclosing + substitutions. + + * Bart: 6395: uninstall info files over 9, too + + * Sven: 6212 (previously missed): an extra clear list + + * Andrej: 6392: install info files higher than 9 + + * 3.1.5-pws-20 + + * Sven: 6388: completion in braces removes later arguments + + * Sven: 6374: autoremove behaviour on -r and -R, documentation + + * Bart: 6369: fix use of relative paths in compinstall + + * Bart: 6368: don't use cp -f, use rm -f in configure.in + + * Sven: 6355: ALL_EXPORT crashed the shell if set on command line + + * Sven: 6352, 6354: more quoting in completion + + * pws: 6346: msync() missing from mapfile.c, somehow + + * pws: 6345: Config/defs.mk is now in build tree, not source tree + + * Sven: 6343: test length of anchor in partial word matching + + * pws: 6340: INSTALL didn't work if it was install-sh after 6330 + + * pws: 6335: now you can do ${(f)"$(...)"} to get arrays + + * pws: 6332: mapfile module + + * pws: 6331: protect against null hash tables in parameter module + + * pws: 6330: rewrite configuration system to use AC_SUBST_FILE + instead of including files by ed trickery (ed is now no longer + required). + + * Sven: 6326: compadd -r and -R work on automatically added + suffixes, too + + * Sven: 6322: reverse indexing of nested arrays + + * Sven: 6318: memory fixes for parameter module (and compctl). + + * 3.1.5-pws-19 made available + + * pws: unposted: updated some .distfiles + + * pws: 6314: in something like `{ false; } || true', errexit + shouldn't be used at all on the left of the || + + * pws: 6313: fix 6299 to use $SHELL to decide emulation + + * pws: 6307, 6312: wider support for 64-bit integers on 32-bit + architectures + + * Tanaka Akira: 6303: _path_files: find files after symbolic link + + * Sven: 6302: more list_pipe intricacies + + * Sven: 6301: expanded ignored prefix ignored for testing + + * pws: 6299: if called as su* or -su*, zsh doesn't do sh emulation + + * Sven: 6298: (mult_isarr) ${*:-word} didn't use the default word + + * pws: 6294: typeset -U MANPATH performs uniqueness test straight + away + + * pws: 6291: zftp only checks for system type after login. + + * pws: 6290: parameter module uses global scope, $parameters gets + unreadonlied, gcc warning + + * Sven: 6285: tty/job handling when executing some command in + current shell code within RHS of pipeline + + * Sven: 6283: compadd -U didn't quote characters properly + + * Sven: 6278: fix ${$(foo)...} to produce an array + + * Tatsuo Furukawa: 6274: updated form of zle_refresh patch + + * Tatsuo Furukawa: 6273: don't need to defined _POSIX* flags + specially on HPUX + + * pws: 6272: correct even more mistakes some bozo (guess who) made + with rlim_t: put back RLIM_T_IS_UNSIGNED code. + + * pws: 6271: make sure -D_LARGEFILE_SOURCE is defined any time + there are other -D's for large file support + + * pws: 6284, should have been in 6269: changes to large file + support + + * Sven: 6268: parameter module for access to internal tables + + * pws: 6263: incrementalappendhistory -> incappendhistory + + * 3.1.5-pws-18 made available + + * pws: 6259: second version of compinstall + + * pws: 6258: yet another attempt at the same problem + + * pws: 6257: rewrite 6240 for any old builtin structure after the + pipeline + + * Wayne: 6255: more history: zle toggle between local/global + history; `zle widget' can now take a direct numeric argument; + small tweaks + + * Sven: 6249: fix for 6046 (problem showed up with $(...)) + + * pws: 6246: doc changes for 6046, plus subscripts done properly + + * Sven: 6046: nested parameter expansions can return either arrays + or scalars. + + * Wayne: 6241: history editing can use foreign history commands; + history appended in hend() instead of hbegin() + + * pws: 6240: a pipeline ending in a builtin didn't attach to the + tty pgrp. + + * pws: 6239: need space after incrementalappendhistory for + kshoptionprint + + * pws: 6238: Wayne's share_history option set in ksh emulation + + * pws: 6237: window size code upgraded from 3.0.6-pre2, plus + Bart's patch 4447. + + * Wayne: 6236: history changes to improve management of duplicate + lines, incremental history read/write, and sharing history + + * pws: 6235: unset -m shouldn't restore unset parameters; + unsetting a global should remove it from paramtab even inside a + function. + + * pws: 6227: configuration for large file support (from bash + aclocal.m4). + + * pws: 6224: alter 6205 to read chars only when necessary, but + ensure terminal is set appropriately. + + * Wayne: 6220: various compilation warnings + + * Tanaka Akira: 6219: initialize a variable in zle_tricky.c + + * Bart: 6213: race condition in $(...), use waitforpid() instead + of unblocking child (which shouldn't happen until later). + + * pws: 6205: use FIONREAD wherever defined, read chars immediately + into buffer + + * pws: 6202: trivial _correct_filename change, ^Xc -> ^XC + + * Sven: 6197: off by one error parsing assignment in completion + + * Sven: 6195: _expand_word and _correct_word change. + + * Sven: 6194: complete assoc array arguments by default where + necessary + + * pws: 6193: [un]setopt shouldn't complain when setting an + unsettable option to the value it already has + + * Bart: 6188: compinit speedup + + * 3.1.5-pws-17 made available + + * pws: 6180: Completion/Core/compinstall + + * Bart: 6171 as rewritten in 6174: old RedHat Linux doesn't have + normal definitions for poll. + + * Sven: 6167: show unloaded parameters as undefined + + * pws: 6165: globsubst'd foo='~/bin' depended on extendedglob + being set + + * Bart: 6162: autoloadable parameter code links without dynamic + loading + + * Sven: 6153: realparamtab to smooth access to autoloaded parameters + + * Sven: 6152: compstate[vared] + + * Sven: 6150: alwayslastprompt sometimes failed in M-x + + * Sven: 6133: autoloaded parameters + + * Sven: 6132: compctl.mdd + + * Ville Herva: 6131, see 6126: reset tv.tv_sec before select for + Linux + + * Sven: 6129: comments for struct cadata + + * Sven: 6128: completion after an expansion; list after a + non-completion list + + * Sven: 6124: menu completion wasn't consistent between tabs + + * Sven: 6121: try harder with braces after a parameter expansion + + * Sven: 6119: don't insert word separator before ignored suffix + + * pws: 6118: _closequote and _oldlist completers + + * Sven: 6117: position of ignored suffix in inserted match + + * Sven: 6113: compadd -D, nuke element in an array for each failed + match + + * Sven: 6109: completion in parameter assignment should set + context `value' + + * Bart: 6106: short documentation fixes in expn.yo, options.yo, + redirect.yo + + * Sven: 6105: _make patch whitespace + + * Geoff: 6104: multi-line prompt fix (6101 backed off) + + * 3.1.5-pws-16 made available + + * pws: 6101: multi-line prompt ending in '\n' got another newline + + * Tanaka Akira: 6092: _find, bad glob pattern + + * Tanaka Akira: 6085: _make can hang when no [mM]akefile + + * pws: zsh-announce/94: FAQ and FAQ.yo updated + + * Sven: 6079: compwid.yo typo + + * Tanaka Akira: 6078: _find syntax error + + * Sven: 6077: do_single() fix for old completion + + * pws: 6074: zftp function suite moved to Functions/Zftp and + provided with documentation. + + * pws: 6070: ~ in character class in parentheses with extendedglob + failed + + * Sven: 6066: create list of modules built into the base executable + + * Sven: 6062: test whether using the same widget when doing + menucompletion + + * Sven: 6060: don't invalidatelist() in zle_main.c before calling + completion functions + + * Sven: 6058: small changes in _path_files, compinit and + documentation + + * Sven: 6056: compwid.yo + + * pws: 6053: compwid.yo + + * 3.1.5-pws-15 made available + + * Sven: 6031: defcomp -> compdef + + * pws: 6030: compsys.yo + + * Sven: 6026: _path_files slight rewrite for speed + + * Sven: 6021: _path_files expanding path fix + + * pws: 6018: (#l) and friends with a trailing / on the glob + pattern always failed + + * pws: 6016: compinit and _zftp + + * Andrej: 6017 (ex 6014): -i and -s options for _long_options + + * Sven: 6013: pass ignored prefix and suffix in _path_files + + * Sven: 6011: compadd uses first (not last) occurrence of an option + + * Sven: 6010: _match_pattern and _match_test replaced by options + to compadd (and deleted from distribution) + + * Sven: extracted from 6009: chunk for getmatcharr() + + * Sven: 6008: %{ works in completion listings + + * Sven: 6005: Misc/compctl-examples altered for latest (more + consistent) nested parameter expansion rules + + * Bart: 6002, 6003: in ${foo/#bar/thing}, the `#' can appear from + substitution and can be quoted + + * Sven: 5999: ~foo<TAB> completes with / + + * Sven: 5996: compsys.yo, special contexts + + * Sven: 5995: should fix 5969 + + * Sven: 5986: compstate[insert] + + * Sven: 5983: documentation for Completion/ system (compsys.1). + + * Sven: 5982: menu behaviour + + * Sven: 5981: bit masks in comp.h + + * Sven: 5972: compconf without arguments lists; _compalso takes + extra arguments + + * Sven: 5971: shell code control over re-using existing completion + lists + + * Sven: 5970: completion fix compilation; #defcomp is now #compdef + + * Sven: 5969: clear to end of display optimization (may need + modifying for some terminals) + + * Sven: 5968: fix brace re-insertion problem in completion + + * pws: 5965: _correct_word + + * Sven: 5960: $PREBUFFER: lines before current $BUFFER + + * Sven: 5959: quoting characters in completion + + * Bruce: 5958: _make + + * Sven: 5955: more compstate choices: list_max, last_prompt, to_end + + * 3.1.5-pws-14 made avaliable + + * pws: unposted: updated .distfiles under Completion + + * Sven: 5947: completion functions fix + + * Sven: 5942: spaces in file names with old completion + + * Sven: 5940: move cursor + + * Sven: 5938, 5937: compset to replace modifying conditions + + * Sven: 5936: replace modifying completion tests with compset + + * pws: 5934: option GLOBAL_RCS_FIRST runs /etc/z* files before + user's files. + + * Sven: 5933: don't complete local parameters; _setopt/_unsetopt + complete all options (code to use currently unset/set options + remains in comments) + + * pws: 5931: more parameter substitution rules + + * Sven: 5928: copy context in zle_tricky + + * Sven: 5926: $HISTNO + + * Sven: 5925: path_expand + + * Sven: 5918: _list completer + + * Sven: 5916: _expand completer + + * pws: 5915: minor type fixes + + * Sven: 5914: _main_complete takes optional completer arguments + + * Sven: 5913: zle -C test + + * Sven: 5912: compiler warnings + + * pws: 5905: _main_complete should at least try to get + _unset_options correct. + + * Sven: 5904: print local for parameters + + * Sven: 5895, 5898, 5906: fix completion prefixes + + * Sven: 5890: _match completer + + * Sven: 5879, 5899: completion documentation + + * Sven: 5872, 5881, 5889: corresponding Completion function rewrite + + * Sven: 5871, 5875: big zle_tricky.c cleanup, with compstate + changes and IFSUFFIX + + * Bart: 5868: expn.yo fixes + + * 3.1.5-pws-13 made available + + * pws: 5863: substitution rules + + * Sven: 5862: _path_files (turning on menu) and _cd (include . in + path) + + * pws: 5854: man page dependencies in Doc/Makefile.in + + * Sven: 5852: warnings about _long_options + + * pws: 5844: don't set errflag if noerrs = 2. + + * Sven: 5831: in subscripts and math environments, the whole + string is always passed down to the function handler. + + * Sven: 5830: in ${#:-stuff}, stuff is treated as a single word + (unless split for some other reason). + + * Sven: 5829: clear the completion list in more zle functions + + * Sven: 5818: parameter name in subscript which looks math-like; + _subscript. + + * Sven: 5811: put back _multi_parts which got left out when it was + moved into Core. + + * Sven: 5804: _pdf + + * Sven: 5800: _path_files; path altered when no possible match + + * pws: 5797: set CLOBBERS_TYPEAHEAD for Irix; old config.guess + change for Reliant UNIX and Apple Rhapsody re-imported from old + config.guess. + + * Sven: 5796: globcomplete shouldn't always turn on menucompletion + + * Sven: 5795: parsing change for assignment and arrays in nested + substitution. + + * Sven (reposted by Bart): 5783: zerr() sets errflag even if + noerrs is set + + * pws: 5780: Completion/Base/_brace_parameter change + + * 3.1.5-pws-12 made available + + * Geoff: 5779: correct mistakes some bozo (guess who) made testing + rlim_t for long long. + + * pws: unposted archive changes: .distfiles in Completion + hierarchy, dunno what these do but it looks better; _comp_parts + is now _sep_parts; moved _long_options into Base and mentioned + it in Completion/README. + + * pws: 5776: untested patch for typeahead problems when reading + multiple lines of input + + * Sven: 5775: correcting completion will not ignore everything the + user has typed; prefix quote fix + + * Sven: 5770: _path_files again + + * Sven: 5766: _path_files closer to compctl/compgen behaviour + + * Sven: 5761: remove unnecessary compiler warnings in compctl.c + + * Sven: 5759: math environment fixes + + * pws: www archive: updated Etc/FAQ finally, keep forgetting + + * Sven: 5758: _path_files accepts -q, -r and -R options + + * Sven: 5757: compconfig + + * Sven: 5756: compstate[force_list] + + * Lehti Rami: 5754: --disable-restricted-r stops the shell + becoming restricted when its name starts with r + + * Sven: zsh-users/2211 (+ p -> s): setopt -m handles underscores + and case sensitivity + + * pws: 5737: ${foo#* } is more efficient in ordinary cases + + * Sven: 5736: completion before = in assignment + + * Sven: 5732: _a2ps, _long_options + + * pws: 5729: _bindkey doc + + * Sven: 5726: zle_tricky.c: ctokenize() fix and parameter completion + + * Will Day: 5724 (+postprocessing, 5741): signames2.awk: match + extra spaces if produced by CPP. + + * Andrej: 5719: _bindkey can use - as anchor for wildcard matching + + * Sven: 5716: zle.h, zle_misc.c, zle_tricky.c: iremovesuffix() can + be told whether to keep a list of matches + + * Sven: 5714: _path_files: failed completions get left alone more + often + + * Sven: 5713: zle_tricky.c, interesting code specimen made extinct + + * Sven: 5712: _path_files, noglobcomplete fix + + * Sven: 5710: zle_tricky.c, completion inside words + + * Sven: 5708: completion manual, -M anchors must be matched + explicitly + + * Sven: 5707: tokenization changes + + * Sven: 5704: _long_options + + * Sven: 5701: _main_complete, _multi_parts, _path_files, a few + cosmetic changes. + + * Sven: 5699: matching prefixes of various sorts + + * Sven: 5698: array indexing in _long_options and _multi_parts + + * Sven: 5696, 5697: "${${path}[1]}" indexes on characters again + + * Sven: 5692: remove compstate[matcher] test from _long_options + + * Sven: 5682: bindkey fix + + * Sven: 5677, 5679: Completion/User/_long_options and consequent + upgrades for Completion/User files which use long GNU-style + options. + + * Sven: 5676: all Completion example functions return a status + + * pws: from autoconf 2.13: new config.guess, too. + + * Sven: 5675: tidying up for zle_tricky.c + + * Sven: 5671: another small parameter fix for multiple braces + + * Sven: 5670: parameter completion fix + + * 3.1.5-pws-11 made available + + * pws: from autoconf 2.13: new config.sub + + * Sven: 5666: calling inststrlen() with a null string + + * Sven: 5665: return values from completion functions + + * Sven: 5663: compctl -i _completion_function + + * Sven: 5662: / following brace parameter + + * Sven: 5659: globcomplete changes + + * Sven: 5651: widespread completion fixes + + * Andrej: 5650: more tricks with _configure + + * Sven: 5647: _multi_parts doesn't replace so many *'s + + * Sven: 5640: _multi_parts, _path_files, _tar + + * Sven: 5637: mustuseheap check in complistflags + + * Sven: 5634: return values for compgen and compadd + + * Sven: 5631: compilation warnings + + * Sven: 5629: approximate correction patches + + * pws: 5628: _builtin, _cd, _most_recent_file + + * Sven: 5624: CCORIG required to be offered original string when + correcting using COMPCORRECT + + * Sven: 5623: -X strings with compadd were mishandled + + * Sven: 5622: zshcompwid manual: clarifications + + * Sven: 5621: manual for nmatches and matcher + + * Sven: 5620: fix for completion inside expansible braces + + * Bart: 5614: Completion/Base/_match_test works out of the box + + * Sven: 5613: copy scalar variable used for compgen -y + + * Sven: 5605: explanation listing fix + + * Sven: 5604: approximate completion. + + * Sven: 5603: compstat[pattern_match] + + * pws: 5602: _tar + + * Sven: 5601: compstate[exact_string] and compstate[total_matchers] + + * Sven: 5599: _comp_parts, _path_files tweaks + + * Sven: 5598: a neater way of handling compadd -p/-P + + * pws; 5597: Use separate file mymods.conf for your own builtin + modules rather than the automatically generated modules-bltin. + + * Matt: 5596: Makefile dependencies for module compilation + + * Sven: 5593: _path_files -w + + * Sven: 5590: compadd -p, -s and -P fixes + + * Sven: 5588: fix _most_recent_file idiocy + + * Sven: 5586: addmatch fix (old completion wasn't working) + + * pws: 5583: post-patch restructuring of _mh, _zftp, + _most_recent_file. + + * Sven: 5582: _path_files will expand /u/ -> /usr/ even if /u + exists if nothing later on would match otherwise (got that?) + + * Sven: 5574, 5578: Completion/README notes + + * Sven: 5571: Functions/Builtins/_cd tests if $cdpath is set + + * Sven: 5566: $foo[(b.<index>.i)<match>] starts searching $foo for + for <match> at <index> + + * Sven: 5565, 5576: $NUMERIC gives the numeric argument in a zle + widget + + * Sven: 5564, 5577, 5579: massive new completion reworking with + $words, $compstate, etc., etc. + + * pws: 5561: attempted (untested) fix for QNX4 compilation; + halloc() is now zhalloc(). (By private email from + probin@qnx.co.uk, it seems the QNX problems are more + considerable with 3.1.5.) + + * Sven: 5560: subscripting fixes in params.c: flags for scalars + and converting integer AA element to string + + * pws: 5559: cd /.. doesn't show .. (except if RFS was detected). + + * Larry P. Schrof: 5550: last -> previous in history documentation + + * pws: 5557: configure.in for making sure signals really are + defined in the file found. This was in pws-10, but the patch + didn't appear on the list for four days. + + * 3.1.5-pws-10 made available + + * pws: unposted: Functions/Completion moved to Completion; + subdirectories Core, Base, Builtins, User, Commands created; + Completion/README created. + + * Matt: 5553: under _WIN32, .exe suffix is optional for commands + + * Sven: 5548: _path_files, _comp_parts + + * Sven: 5547: group handling -J/-V in compadd + + * pws: 5545: silly set -x mistake + + * Sven: 5544: another completion cleanup + + * Sven: 5543: compadd -X, zshcompwid manual + + * pws: 5538: approximate pattern matching, (#a1)readme etc. + + * pws: 5531: small init fix + + * Sven: 5529: cleanup for Functions/Completion + + * Sven: 5521: improved option handling for _path_files + + * Sven: 5512, 5525: globcomplete fix for new completion + + * Sven: 5511: make sure compctl is available for new completion + + * pws: 5508: init and dump, globbing and printing. + + * pws: unposted, see 5503: remove dynamic=no from configure.in when + underscore is needed. + + * Sven: 5490: unset test for AA elements when substituting + + * Sven: 5489: control for matching in _path_files and _comp_parts + + * Sven: 5483: completeinword fixes + + * Sven: 5476: quoting of tildes in Functions/Completion/_path_files + + * Sven: 5471: range code knows not to handle associative arrays + + * Sven: 5470: new completion conditions didn't handle untokenization + consistently. + + * Sven: 5469: init fix and Functions/Completion/_comp_parts + + * Sven: 5467: expn manual typo + + * Sven: 5466: compwid manual for -after and -between + + * Sven: 5455: keep track of which matcher specification to use + + * Matt: 5330: I've put this back the way it original was. I hate + sed almost as much as awk. + + * Martin Buchholz: 5448: libc.h can't be included on Debian Linux, + so only include it on NeXT where it's necessary. + + * 3.1.5-pws-9 made available + + * pws: unposted (but see 5440): zftp changes: more return 6's, + functions now do auto-open and avoid subshells. + + * pws: 5436: set -x for function calls and ((...)). + + * Sven: 5430: rewrite Functions/Completions with simplified syntax + (no #array type completions). + + * Sven: 5429: $CONTEXT strings + + * pws: 5425: fix pattern matching for new completion + + * Sven: 5424: addmatches fix when not doing matching + + * Sven: 5423: compadd accepts either - or -- to end options + + * Sven: 5422: braces in completions were not tokenized; array + parameters wereused uncopied + + * pws: 5421: setting same element of assoc array in full array + assignment crashed + + * Sven: 5418: small addmatches fixes + + * Sven: 5417: multiple subscripts with undefined array + + * Sven: 5415: anchors in matchers shouldn't match variable part of + completion + + * Sven: 5412: better matcher control + + * Helmut Jarausch/pws: 5410: IRIX 6.5 problems in Etc/MACHINES + + * pws: 5408: set -x output for [[ ... ]] + + * pws: 5403: magicequalsubst now affects all ...=~...:~ + + * Sven: 5401: files -> __files + + * Sven: 5400, 5402: print needs - in dump; auto-dump and use + $COMPDUMP file + + * Sven: 5399, 5407: do_ambiguous overhaul + + * pws: 5398: fixlet for __path_files + + * pws: 5393: dump new completion status for faster init + + * Sven: 5384, 5397: manual for new completion so far + + * Andrej: 5377: Reliant UNIX configuration + + * Oliver: 5374: compctl -T doc for ~dirs + + * Oliver: 5372: change of mailing list host + + * Bart: 5367: CVS ignores version.h + + * 3.1.5-pws-8 made available + + * pws: 5365: make dependencies for main.o, Makemod, zshpaths.h + + * pws: 5364: 5281 now works + + * pws: Misc/Completion now Functions/Completion, some new + new-style completions + + * pws: 5362: #key-* completions allow >= 0 key bindings + + * Sven: 5355: compadd -R function for suffix removal + + * Sven: 5354: redisplaying completion lists, don't show if + completion failed + + * Sven: 5352: new fignore handling + + * pws/Bart: 5349, 5361: "$foo[@]" didn't get removed if $foo + wasn't set + + * pws/Sven: 5341, 5351: completion init and __normal + + * Sven: 5342, 5343: ignoring ignored prefix in new conditions + + * Sven: 5341: modularise new completion shell code + + * Sven: 5335: printing zle condition codes + + * pws: 5332: emulate -L + + * Sweth/Bart/pws: zsh-users/2121: Functions/allopt with the odd + emulate and local added + + * pws/Matt: 5326, 5329, 5330: signames.c generation + + * pws: 5321: compctl -LM + + * Sven: 5320: keys available in zle widgets + + * Sven: 5316: compctl matcher users reference counts + + * Matt: 5311: CHAR(+) -> CHAR(43) in zmacros + + * Bart: 5305: trashzle() crashed shell with loading dynamic but + zle builtin + + * Bart: 5299: PWD, OLDPWD export confusion + + * Bart: 5297: local variables and $argv doc + + * Geoff: 5295: no ld -g on NetBSD + + * 3.1.5-pws-7 made available + + * pws; 5281: interrupts in getquery() weren't handled gracefully + + * Sven: 5266: get matcher number in new completion functions + + * Sven: 5265, 5284: rewrite of $foo:q and doc + + * Sven: 5262: compctl -M, REC_EXACT fixes + + * Sven: 5261, 5268: GLOB_COMPLETE docs + + * Bart: 5260: new mailing lists in Meta-FAQ + + * Bart: 5258: parameter scoping docs + + * pws: 5247: typeset -T fix + + * pws: Etc/MACHINES: Linux Alpha with egcs + + * pws: 5233: .zlogout doc + + * pws/Sven: 5229, 5234, 5235, 5269: bashautolist option + + * Sven: 5120: use ${foo:q} for quoting completion prefix/suffix + + * Sven: 5208: preliminary version of ${foo:q} + + * Sven: 5207: completion in conditions + + * Sven: 5206: completion in arrays + + * Sven: 5203: o -> f, O -> o, O = ^o + + * Sven: 5201: zle commands erase listing when minibuffer used + + * pws: 5185, 5198: compctl documentation tidy-up + + * Sven: 5183, 5199, 5200: ${(P)...} flag + + * Sven: 5178: fix for command completion and pattern completions + + * Bart: 5174: unset assoc array elements + + * Sven: 5145, 5204: compadd -m, -F, -r + + * Sven: 5144: partial word completion fix + + * Matt: 5133: cygwin needs native getcwd() + + * Matt Armstrong: 5132, 5151: makepro.awk can spit out + preprocessor lines, move init.pro inclusion + + * Bart: 5129: vared assoc array and elements thereof + + * Bart: 4965, missing hunk: unset assoc array when assigned as + scalar + + * pws: 5054: zls + + * 3.1.5-pws-6 made available + + * Drazen Kacar/pws: 5118: unlock terminal device on Solaris + + * pws: 5111: unsetting special zle variables + + * Sven: 5107: glob qualifier o for modes + + * pws: 5105: remove old zle -C, zle -C does new completion + + * Sven: 5104: zle and widget information via variables + + * Drazen Kacar/pws/Bart: 5103, 5113: terminal bug on Solaris with + Openwindows + + * Sven: 5102: glob qualifiers doc + + * pws: 5094, 5120: typeset -T MYPATH mypath; MYPATH=(foo), + mypath=foo fix; PATH=(foo) bug + + * Sven: 5092: extra completion context + + * Sven: 5060: completion in brace expansion + + * Sven: 5059, 5065, 5085: compcall, compctl -K ' func', avoid + recursion, fix dynamic loading + + * pws: 5047: make install doesn't make install.info + + * Phil/Bart: 5032, 5037: zless with localoptions added + + * Sven: 5022, 5045, 5078: ${(t)param} and nounset behaviour + + * Andrej: 5016: insert zsh.info into dir when installing + + * pws: new mirror site ftp://ftp.win.ne.jp/pub/shell/zsh/ + + * Sven: 4986, 4988: new-style completion after redirection + + * Sven: 4981: fix completion whitespace for copy-previous-word + + * Sven: 4979, 4987: new glob modifiers for sort order and + selecting items from list + + * Sven: 4976: compadd and new-completion-examples + + * Sven: 4975, 5007: comptl -M matches with *'s + + * Sven: 4974: compctl list with single string + + * Andrej: 5021: configuration on Reliant UNIX + + * Bart: 4965: add-on + + * Sven: 4957: completion after redirection + + * Made available as 3.1.5-pws-5; top level directory now + zsh-3.1.5-pws-5 + + * Helmut Jarausch: 4947: part of patch missed + + * Sven: 4850, 4881, 4941, 4942, 4943, 4944, 4946, 4949, 4950, + 4945: New completion system + + * Sven: 4940: compctl -t (minor incompatibility) + + * pws: 4939: configure checks for tgetent() accepts null but then + tgetstr() dumps core + + * pws: 4931: compiler warnings + + * Sven: 4930: completion after reserved words + + * pws/Bart: 4923, 4924: findcmd() memory leak and comment + + * pws: 4912: Etc/MACHINES + + * pws: 4902: typeset neatness, -a, -m + + * Bart: 4893: setting assoc array elements inside a substitution + + * Andrej Borsenkow + pws: 4888: zftp shouldn't dup sockets until + connected + + * Oliver Kiddle: 4887: configure + + * Sven: 4880: conditions from module again + + * Sven: 4879: group completion + + * Sven: 4878: accept-and-menu-complete + + * Bart: 4874: array slices + + * Geoff: 4855: refresh line the same length as terminal width + + * pws: 4852: zftp test subcommand + + * Bart: 4851: sethparam(), part got missed + + * 3.1.5-pws-4 made available + + * Sven: 4845: isident() + + * Sven: 4837, 4842: more for loadable conditions + + * Sven: 4828: ignored character + + * Bart/Sven: 4826, 4831, 4836: assoc array fixes + + * Gene Cohler + pws: 4824, 4833, 4843: dynamical loading under + HPUX + + * Sven: 4821: network byte order in zftp + + * Bart: 4817: parameter documentation + + * Sven: 4806, 4815, 4820, 4822, 4830: be careful when unloading + modules which may have side effects + + * pws: 4805: define INADDR_NONE in zftp if not defined + + * pws: 4801: compilation without HAVE_GETPWUID + + * Bart: 4792: Handle --program-{suf,pre}fix in configure + + * Bart: 4791: don't hash PWD after all + + * Bart: 4789, 4794, 4795: sethparam(), setsparam; allow assoc + array assignment ${(AA)=assoc::=key1 val1 ...} + + * Bart: 4788: some missing patches put back + + * Phil: 4784: unused variable j in glob.c + + * Phil: 4783: wtmp is in /var/log on Linux + + * pws: 4779: compiling statically linked + + * pws: version 3.1.5-pws-3 made available + + * Sven: 4767: completion listing fix + + * Bart: 4763, 4766, 4764: associative arrays using subscripting + flags and typeset output + + * Bart: 4762: use of conddef without dynamic loading + + * pws: 4761: zftp module + + * Phil: 4737: typeset -a docs + + * pws: 4736, 4754: ${foo/orig/new} subst as in bash; optimize + pattern matching in strings + + * Phil Pennock: 4727: associative arrays in stat builtin + + * Sven: 4716, 4732, 4734, 4742, 4769: allow modules for + conditions and wrappers around functions + + * Sven: 4700: heap memory fixes suggested by Phil Pennock + + * Sven: 4698, 4707: ignore completions if cursor not in + completable part of word + + * Sven: 4697: zle_tricky.c + + * pws: 4693: case-indendent globbing fix + + * Bart: 4678: viforwardword + + * pws: don't use vifirstnonblank()in vioperswapcase() + + * Bart: 4674: scanmatchtable() + + * Bart: 4482: cdmatch2 + + * Bart: 4644: delimiters in parameter substitution flags + + * Bart: 4624: don't be too clever with optimizing when doing *** + + * pws: 4612: 8 bit character input problem if char was signed + + * Bart: 4606: error messages from parameters + + * pws: 4601: rewrite prompt truncation in more predictable, + delimitable way + + * Bart: 4599, 4602, 4608, 4641, 4653, 4654: associative arrays + + * pws: 4596: allow PWD to be hashed on explicit user request + + * pws: 4595: globbing fix for problem which showed up in `case' + + * Wilfredo Sanchez: 4594: fix configure problems + + * pws: 4591: test line length in prompt e.g. %(40l.yes.no) + + * Bart: 4589: PWD and OLDPWD fix + + * Bart: 4472: doc fixes + + * Bart: 4471: fixes for shell functions + + * Bart: line missed in zle_tricky.c when patching + + * Bart: 4589: chpwd + + * pws: lete2ctl update + + * pws: fixsuffix() missed in delcharorlist() when patching + + * Bart: 4574: doc fix + + * Bart: 4570: flags to allow zle command not to interrupt + cumulative effects, deltochar + + * pws: 4564: fix completion suffix for yank + + * pws: 4533: ~PWD should not be displayed as such + + * pws: 4513, 4552: case-insensitive globbing (#i) + + * Sven: 4509, 4510, 4526, 4527, 4534, 4557: alternative matches in + completion (compctl -t), mapping between characters on line and + in matches (compctl -M) + + * pws: 4477: change function names to avoid dynamic loading + clashes + + * Bart: 4473, 4475, 4476: collected minor fixes since 3.1.5 + + * Zoli: 3933: AIX dynamic patch + Thu Oct 29 21:51:10 1998 Andrew Main <zefram@zsh.org> * Config/version.mk: Version 3.1.5. diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index 5170acb84..bf263d6e9 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -3,386 +3,345 @@ # Complete the arguments of the current command according to the # descriptions given as arguments to this function. -local long args rest ws cur nth def nm expl descr action opt arg tmp +local long cmd="$words[1]" descr mesg subopts opt usecc autod +local oldcontext="$curcontext" hasopts -# Associative arrays used to collect information about the options. +long=$argv[(I)--] +if (( long )); then + local name tmp tmpargv -typeset -A opts mopts dopts dmopts odopts odmopts - -# See if we support long options, too. + if [[ long -eq 1 ]]; then + tmpargv=() + else + tmpargv=( "${(@)argv[1,long-1]}" ) + fi -nth=$argv[(I)--] -if (( nth )); then - long=( "${(@)argv[nth+1,-1]}" ) - argv=("${(@)argv[1,nth-1]}") -else - long=() -fi + name=${~words[1]} + [[ "$name" != /* ]] && tmp="$PWD/$name" -# Now parse the arguments... + name="_args_cache_${name}" + name="${name//[^a-zA-Z0-9_]/_}" -args=() -nth=1 -while (( $# )); do + if (( ! ${(P)+name} )); then + local iopts sopts pattern tmpo cur cache + typeset -U lopts - # This describes a one-shot option. + cache=() - if [[ "$1" = [-+]* ]]; then - if [[ "$1" = *:* ]]; then + # We have to build a new long-option cache, get the `-i' and + # `-s' options. - # If the option name ends in a `-', the first argument comes - # directly after the option, if it ends in a `+', the first - # argument *may* come directly after the option, otherwise it - # is in the next word. + set -- "${(@)argv[long+1,-1]}" - if [[ "$1" = [^:]##-:* ]]; then - dopts[${${1%%:*}[1,-2]}]="${1#*:}" - elif [[ "$1" = [^:]##+:* ]]; then - odopts[${${1%%:*}[1,-2]}]="${1#*:}" + iopts=() + sopts=() + while [[ "$1" = -[is]* ]]; do + if [[ "$1" = -??* ]]; then + tmp="${1[3,-1]}" + cur=1 else - opts[${1%%:*}]="${1#*:}" + tmp="$2" + cur=2 fi - else - opts[$1]='' - fi - elif [[ "$1" = \*[-+]* ]]; then - - # The same for options that may appear more than once. - - if [[ "$1" = *:* ]]; then - if [[ "$1" = [^:]##-:* ]]; then - dmopts[${${1[2,-1]%%:*}[1,-2]}]="${1#*:}" - elif [[ "$1" = [^:]##+:* ]]; then - odmopts[${${1[2,-1]%%:*}[1,-2]}]="${1#*:}" + if [[ "$tmp[1]" = '(' ]]; then + tmp=( ${=tmp[2,-2]} ) else - mopts[${1[2,-1]%%:*}]="${1#*:}" + tmp=( "${(@P)tmp}" ) fi - else - mopts[${1[2,-1]}]='' - fi - elif [[ "$1" = \*:* ]]; then + if [[ "$1" = -i* ]]; then + iopts=( "$iopts[@]" "$tmp[@]" ) + else + sopts=( "$sopts[@]" "$tmp[@]" ) + fi + shift cur + done - # This is `*:...', describing `all other arguments'. + # Now get the long option names by calling the command with `--help'. + # The parameter expansion trickery first gets the lines as separate + # array elements. Then we select all lines whose first non-blank + # character is a hyphen. Since some commands document more than one + # option per line, separated by commas, we convert commas int + # newlines and then split the result again at newlines after joining + # the old array elements with newlines between them. Then we select + # those elements that start with two hyphens, remove anything up to + # those hyphens and anything from the space or comma after the + # option up to the end. - rest="${1[3,-1]}" - elif [[ "$1" = :* ]]; then + lopts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$(_call options ${~words[1]} --help 2>&1)//\[--/ +--}:#[ ]#-*}//,/ +}}:#[ ]#--*}#*--}%%[], ]*}:#}") + lopts=( "${(@)lopts:#--}" ) - # This is `:...', describing `the next argument'. + # Now remove all ignored options ... - args[nth++]="${1#*:}" - else + while (( $#iopts )); do + lopts=( ${lopts:#$~iopts[1]} ) + shift iopts + done - # And this is `n:...', describing the `n'th argument. + # ... and add "same" options - args[${1%%:*}]="${1#*:}" - nth=$(( ${1%%:*} + 1 )) - fi - shift -done + while (( $#sopts )); do + lopts=( $lopts ${lopts/$sopts[1]/$sopts[2]} ) + shift 2 sopts + done -if [[ $#long -ne 0 && "$PREFIX" = --* ]]; then + # Then we walk through the descriptions plus a few builtin ones. - # If the current words starts with `--' and we should use long - # options, just call... + set -- "$@" '*=FILE*:file:_files' \ + '*=(DIR|PATH)*:directory:_files -/' '*: :' - _long_options "$long[@]" -else + while (( $# )); do - # Otherwise parse the command line... + # First, we get the pattern and the action to use and take them + # from the positional parameters. - ws=( "${(@)words[2,-1]}" ) - cur=$(( CURRENT-2 )) - nth=1 + pattern="${${${(M)1#*[^\\]:}[1,-2]}//\\\\:/:}" + descr="${1#${pattern}}" + shift - # ...until the current word is reached. + # We get all options matching the pattern and take them from the + # list we have built. If no option matches the pattern, we + # continue with the next. - while [[ cur -gt 0 ]]; do + tmp=("${(@M)lopts:##$~pattern}") + lopts=("${(@)lopts:##$~pattern}") - # `def' holds the description for the option we are currently after. - # Check if the next argument for the option is optional. + (( $#tmp )) || continue - if [[ "$def" = :* ]]; then - opt=yes - else opt='' - fi - arg='' - - # Remove one description/action pair from `def' if that isn't empty. - if [[ -n "$def" ]]; then - if [[ "$def" = ?*:*:* ]]; then - def="${def#?*:*:}" - else - def='' - fi - else + # If there are option strings with a `[=', we take these get an + # optional argument. - # If it is empty, and the word starts with `--' and we should - # complete long options, just ignore this word, otherwise make sure - # we test for options below and handle normal arguments. + tmpo=("${(@M)tmp:#*\[\=*}") + if (( $#tmpo )); then + tmp=("${(@)tmp:#*\[\=*}") + tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") - if [[ $#long -eq 0 || "$ws[1]" != --* ]]; then - opt=yes - arg=yes - else - def='' + if [[ "$descr" = ::* ]]; then + cache=( "$cache[@]" "${(@)^tmpo}=${descr}" ) + else + cache=( "$cache[@]" "${(@)^tmpo}=:${descr}" ) + fi fi - fi - - if [[ -n "$opt" ]]; then - - # `opt' was set above if we have to test if the word is an option. - # We first test for the simple options -- those without arguments or - # those whose arguments have to be given as separate words. - - if (( $+opts[$ws[1]] )); then - - # Options that may only be given once are removed from the - # associative array so that we are not offered them again. - def="$opts[$ws[1]]" - unset "opts[$ws[1]]" - elif (( $+mopts[$ws[1]] )); then - def="$mopts[$ws[1]]" - else + # Descriptions with `=': mandatory argument. - # If the word is none of the simple options, test for those - # whose first argument has to or may come directly after the - # option. This is done in four loops looking very much alike. + tmpo=("${(@M)tmp:#*\=*}") + if (( $#tmpo )); then + tmp=("${(@)tmp:#*\=*}") + tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") - if (( $#dopts )); then + cache=( "$cache[@]" "${(@)^tmpo}=${descr}" ) + fi - # First we get the option names. + # Everything else is just added as a option without arguments. - tmp=( "${(@k)dopts}" ) + if (( $#tmp )); then + tmp=("${(@)tmp//[^a-zA-Z0-9-]}") + cache=( "$cache[@]" "$tmp[@]" ) + fi + done + eval "${name}=( \"\${(@)cache:# #}\" )" + fi + set -- "$tmpargv[@]" "${(@P)name}" +fi - # Then we loop over them and see if the current word begins - # with one of the option names. +subopts=() +while [[ "$1" = -(O*|C) ]]; do + case "$1" in + -C) usecc=yes; shift ;; + -O) subopts=( "${(@P)2}" ); shift 2 ;; + *) subopts=( "${(@P)1[3,-1]}" ); shift ;; + esac +done - while (( $#tmp )); do - [[ "$ws[1]" = ${tmp[1]}* ]] && break - shift 1 tmp - done +zstyle -s ":completion:${curcontext}:options" auto-description autod - if (( $#tmp )); then +if (( $# )) && comparguments -i "$autod" "$@"; then + local nm="$compstate[nmatches]" action noargs aret expl local + local next direct odirect equal single match matched ws tmp1 tmp2 tmp3 + local opts subc prefix suffix + local origpre="$PREFIX" origipre="$IPREFIX" - # It does. So use the description for it, but only from - # the second argument on, because we are searching the - # description for the next command line argument. + if comparguments -D descr action; then + comparguments -C subc + curcontext="${oldcontext%:*}:$subc" - opt='' - def="$dopts[$tmp[1]]" - unset "dopts[$tmp[1]]" - if [[ "$def" = ?*:*:* ]]; then - def="${def#?*:*:}" - else - def='' - fi - fi - fi - if [[ -n "$opt" && $#dmopts -ne 0 ]]; then - tmp=( "${(@k)dmopts}" ) - while (( $#tmp )); do - [[ "$ws[1]" = ${tmp[1]}* ]] && break - shift 1 tmp - done - - if (( $#tmp )); then - opt='' - def="$dmopts[$tmp[1]]" - if [[ "$def" = ?*:*:* ]]; then - def="${def#?*:*:}" - else - def='' - fi - fi - fi - if [[ -n "$opt" && $#odopts -ne 0 ]]; then - tmp=( "${(@k)odopts}" ) - while (( $#tmp )); do - [[ "$ws[1]" = ${tmp[1]}* ]] && break - shift 1 tmp - done - - if (( $#tmp )); then - opt='' - def="$odopts[$tmp[1]]" - unset "odopts[$tmp[1]]" - - # For options whose first argument *may* come after the - # option, we skip over the first description only if there - # is something after the option name on the line. - - if [[ "$ws[1]" != "$tmp[1]" ]]; then - if [[ "$def" = ?*:*:* ]]; then - def="${def#?*:*:}" - else - def='' - fi - fi - fi - fi - if [[ -n "$opt" && $#odmopts -ne 0 ]]; then - tmp=( "${(@k)odmopts}" ) - while (( $#tmp )); do - [[ "$ws[1]" = ${tmp[1]}* ]] && break - shift 1 tmp - done - - if (( $#tmp )); then - opt='' - def="$odmopts[$tmp[1]]" - if [[ "$ws[1]" != "$tmp[1]" ]]; then - if [[ "$def" = ?*:*:* ]]; then - def="${def#?*:*:}" - else - def='' - fi - fi - fi - fi - - # If we didn't find a matching option description and we were - # told to use normal argument descriptions, just increase - # our counter `nth'. - - if [[ -n "$opt" && -n "$arg" ]]; then - def='' - (( nth++ )) - fi - fi + if comparguments -O next direct odirect equal; then + opts=yes + _tags arguments options + else + _tags arguments + fi + else + if comparguments -a; then + noargs='no more arguments' + else + noargs='no arguments' fi + comparguments -O next direct odirect equal || return 1 - shift 1 ws - (( cur-- )) - done + opts=yes + _tags options + fi - # Now generate the matches. + while true; do + while _tags; do + if [[ -n "$matched" ]] || _requested arguments; then + _description arguments expl "$descr" + + if [[ "$action" = -\>* ]]; then + comparguments -W line opt_args + state="${${action[3,-1]##[ ]#}%%[ ]#}" + if [[ -n "$usecc" ]]; then + curcontext="${oldcontext%:*}:$subc" + else + context="$subc" + fi + compstate[restore]='' + aret=yes + else + if [[ -z "$local" ]]; then + local line + typeset -A opt_args + local=yes + fi - nm="$compstate[nmatches]" + comparguments -W line opt_args - if [[ -z "$def" || "$def" = :* ]]; then + if [[ "$action" = \ # ]]; then - # We either don't have a description for an argument of an option - # or we have a description for a optional argument. + # An empty action means that we should just display a message. - if [[ -z "$def" ]]; then + [[ -n "$matched" ]] && compadd -n -Q -S '' -s "$SUFFIX" - "$PREFIX" + mesg="$descr" - # If we have none at all, use the one for this argument position. + elif [[ "$action" = \(\(*\)\) ]]; then - def="$args[nth]" - [[ -z "$def" ]] && def="$rest" - fi + # ((...)) contains literal strings with descriptions. - # In any case, we have to complete option names here, but we may - # be in a string that starts with an option names and continues with - # the first argument, test that (again, four loops). + eval ws\=\( "${action[3,-3]}" \) - opt=yes - if (( $#dopts )); then + _describe "$descr" ws -M "$match" "$subopts[@]" - # Get the option names. + elif [[ "$action" = \(*\) ]]; then - tmp=( "${(@k)dopts}" ) - while (( $#tmp )); do - if compset -P "$tmp[1]"; then + # Anything inside `(...)' is added directly. - # The current string starts with the option name, so ignore - # that and complete the rest of the string. + _all_labels arguments expl "$descr" \ + compadd "$subopts[@]" - ${=action[2,-2]} + elif [[ "$action" = \{*\} ]]; then - def="$dopts[$tmp[1]]" - opt='' - break - fi - shift 1 tmp - done - fi - if [[ -n "$opt" && $#dmopts -ne 0 ]]; then - tmp=( "${(@k)dmopts}" ) - while (( $#tmp )); do - if compset -P "$tmp[1]"; then - def="$dmopts[$tmp[1]]" - opt='' - break - fi - shift 1 tmp - done - fi - if [[ -n "$opt" && $#odopts -ne 0 ]]; then - tmp=( "${(@k)odopts}" ) - while (( $#tmp )); do - if compset -P "$tmp[1]"; then - def="$odopts[$tmp[1]]" - opt='' - break - fi - shift 1 tmp - done - fi - if [[ -n "$opt" && $#odmopts -ne 0 ]]; then - tmp=( "${(@k)odmopts}" ) - while (( $#tmp )); do - if compset -P "$tmp[1]"; then - def="$odmopts[$tmp[1]]" - opt='' - break - fi - shift 1 tmp - done - fi - if [[ -n "$opt" ]]; then - - # We aren't in an argument directly after a option name, so - # all option names are possible matches. - - _description expl option - compadd "$expl[@]" - "${(@k)opts}" "${(@k)mopts}" \ - "${(@k)dopts}" "${(@k)dmopts}" \ - "${(@k)odopts}" "${(@k)odmopts}" - fi - fi + # A string in braces is evaluated. - # Now add the matches from the description, if any. + while _next_label arguments expl "$descr"; do + eval "$action[2,-2]" + done + elif [[ "$action" = \ * ]]; then - if [[ -n "$def" ]]; then + # If the action starts with a space, we just call it. - # Ignore the leading colon describing optional arguments. + eval "action=( $action )" + while _next_label arguments expl "$descr"; do + "$action[@]" + done + else - [[ "$def" = :* ]] && def="$def[2,-1]" + # Otherwise we call it with the description-arguments. - # Get the description and the action. + eval "action=( $action )" + _all_labels arguments expl "$descr" \ + "$action[1]" "$subopts[@]" "${(@)action[2,-1]}" + fi + fi + fi - descr="${def%%:*}" - action="${${def#*:}%%:*}" + if [[ -z "$matched$hasopts" ]] && _requested options && + { ! zstyle -T ":completion:${curcontext}:options" prefix-needed || + [[ "$origpre" = [-+]* || + ( -z "$aret$mesg" && nm -eq compstate[nmatches] ) ]] } ; then + local prevpre="$PREFIX" previpre="$IPREFIX" + + hasopts=yes + + PREFIX="$origpre" + IPREFIX="$origipre" + + comparguments -M match + + if comparguments -s single; then + + _description options expl option + + if [[ "$single" = direct ]]; then + compadd "$expl[@]" -QS '' - "${PREFIX}${SUFFIX}" + elif [[ "$single" = next ]]; then + compadd "$expl[@]" -Q - "${PREFIX}${SUFFIX}" + elif [[ "$single" = equal ]]; then + compadd "$expl[@]" -QqS= - "${PREFIX}${SUFFIX}" + else + tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" ) + tmp3=( "${(M@)tmp1:#[-+]?[^:]*}" ) + tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" ) + tmp2=( "${PREFIX}${(@M)^${(@)${(@)tmp1%%:*}#[-+]}:#?}" ) + + _describe -o option \ + tmp1 tmp2 -Q -S '' -- \ + tmp3 -Q + fi + single=yes + else + next=( "$next[@]" "$odirect[@]" ) + _describe -o option \ + next -Q -M "$match" -- \ + direct -QS '' -M "$match" -- \ + equal -QqS= -M "$match" + fi + PREFIX="$prevpre" + IPREFIX="$previpre" + fi + done + if [[ -n "$opts" && -z "$aret$matched$mesg" && + nm -eq compstate[nmatches] ]]; then - _description expl "$descr" + PREFIX="$origpre" + IPREFIX="$origipre" - if [[ -z "$action" ]]; then + prefix="${PREFIX#*\=}" + suffix="$SUFFIX" + PREFIX="${PREFIX%%\=*}" + SUFFIX='' + compadd -M "$match" -D equal - "${(@)equal%%:*}" - # An empty action means that we should just display a message. - _message "$descr" - return 1 - elif [[ "$action[1]" = \( ]]; then + if [[ $#equal -eq 1 ]]; then + PREFIX="$prefix" + SUFFIX="$suffix" + IPREFIX="${IPREFIX}${equal[1]%%:*}=" + matched=yes - # Anything inside `(...)' is added directly. + comparguments -L "${equal[1]%%:*}" descr action subc + curcontext="${oldcontext%:*}:$subc" - compadd "$expl[@]" - ${=action[2,-2]} - elif [[ "$action" = \ * ]]; then + _tags arguments - # If the action starts with a space, we just call it. + continue + fi + fi + break + done - $=action - else + [[ -z "$aret" || -z "$usecc" ]] && curcontext="$oldcontext" - # Otherwise we call it with the description-arguments built above. + [[ -n "$aret" ]] && return 300 - action=( $=action ) - "$action[1]" "$expl[@]" "${(@)action[2,-1]}" - fi - fi + [[ -n "$mesg" ]] && _message "$mesg" + [[ -n "$noargs" ]] && _message "$noargs" # Set the return value. - [[ nm -ne "$compstate[nmatches]" ]] + [[ nm -ne "$compstate[nmatches]" ]] +else + return 1 fi diff --git a/Completion/Base/_default b/Completion/Base/_default index 8bcf14f6a..fd5869e2e 100644 --- a/Completion/Base/_default +++ b/Completion/Base/_default @@ -1,13 +1,23 @@ -#defcomp -default- +#compdef -default- -# We first try the `compctl's. This is without first (-T) and default (-D) -# completion. If you want them add `-T' and/or `-D' to this command. -# If there is a `compctl' for the command we are working on, we return -# immediatly. If you want to use new style completion anyway, remove the -# `|| return'. Also, you may want to use new style completion if the -# `compctl' didn't produce any matches. In that case remove the `|| return' -# and at the line `[[ -nmatches 0 ]] || return' after `compcall'. +local ctl -compcall || return +if { zstyle -s ":completion:${curcontext}:" use-compctl ctl || + zmodload -e zsh/compctl } && [[ "$ctl" != (no|false|0|off) ]]; then + local opt -_files + opt=() + [[ "$ctl" = *first* ]] && opt=(-T) + [[ "$ctl" = *default* ]] && opt=("$opt[@]" -D) + compcall "$opt[@]" || return 0 +fi + +_wanted files || return 1 + +_files && return 0 + +# magicequalsubst allows arguments like <any-old-stuff>=~/foo to do +# file name expansion after the =. In that case, it's natural to +# allow completion to handle file names after any equals sign. + +[[ -o magicequalsubst ]] && compset -P 1 '*=' && _files diff --git a/Completion/Base/_describe b/Completion/Base/_describe index e01c77509..6e6f4f4a9 100644 --- a/Completion/Base/_describe +++ b/Completion/Base/_describe @@ -2,154 +2,52 @@ # This can be used to add options or values with descriptions as matches. -setopt localoptions extendedglob +local _opt _expl _tmps _tmpd _tmpmd _tmpms _ret=1 _showd _nm _hide _args +local _type=values _descr -local gdescr isopt cmd opt nsets tmp descr match descrs matches adescr i -local disps disp expl tmps tmpd tmpmd tmpms name ret=1 showd _nm +# Get the option. -cmd="$words[1]" - -# Get the options. - -while getopts 'oc:' opt; do - if [[ "$opt" = o ]]; then - isopt=yes - else - cmd="$OPTARG" - fi -done -shift OPTIND-1 +if [[ "$1" = -o ]]; then + _type=options + shift +fi # Do the tests. `showd' is set if the descriptions should be shown. -if [[ -n "$isopt" ]]; then - - # We take the value to test the number of patches from a non-local - # parameter `nm' if that exists and contains only digits. It's a hack. - - if [[ "$nm" = [0-9]## ]]; then - _nm="$nm" - else - _nm=0 - fi - [[ -n "$compconfig[option_prefix]" && - "$compconfig[option_prefix]" != *\!${cmd}* && - "$PREFIX" != [-+]* && - ( "$compconfig[option_prefix]" = *nodefault* || - _nm -ne compstate[nmatches] ) ]] && return 1 +_wanted "$_type" || return 1 - [[ -n "$compconfig[describe_options]" && - "$compconfig[describe_options]" != *\!${cmd}* ]] && showd=yes -else - [[ -n "$compconfig[describe_values]" && - "$compconfig[describe_values]" != *\!${cmd}* ]] && showd=yes -fi +zstyle -T ":completion:${curcontext}:$_type" verbose && _showd=yes -gdescr="$1" +_descr="$1" shift -# Now interpret the arguments. +[[ "$_type" = options ]] && + zstyle -t ":completion:${curcontext}:options" prefix-hidden && _hide=yes -nsets=0 -adescr=() -descrs=() -matches=() -while (( $# )); do - (( nsets++ )) - descr="$1" - [[ -n "$showd" ]] && adescr=( "$adescr[@]" "${(@PM)^descr:#*:?*},$nsets" ) - if [[ "$2" = -* ]]; then - match='' - shift - else - match="$2" - shift 2 - fi - tmp=$argv[(i)--] - if [[ tmp -eq 1 ]]; then - opt=() - else - opt=( "${(@)argv[1,tmp-1]}" ) - fi - if [[ tmp -gt $# ]]; then - argv=() +while _next_label "$_type" _expl "$_descr"; do + + if [[ -n "$_showd" ]]; then + compdescribe -I ' -- ' "$@" else - shift tmp + compdescribe -i "$@" fi - # `descr' and `matches' collect the names of the arrays containing the - # possible matches with descriptions and the matches to add. - # The options to give to `compadd' are stored in local arrays. + while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do - descrs[nsets]="$descr" - matches[nsets]="$match" - typeset -a _descr_opts_$nsets - eval "_descr_opts_${nsets}=( \"\$opt[@]\" )" -done - -(( nsets )) || return 1 - -# Build the display strings if needed. - -[[ -n "$showd" ]] && _display disps "$adescr[@]" -_description expl "$gdescr" + # See if we should remove the option prefix characters. -# Loop through the array/option sets we have. - -i=0 -while [[ ++i -le nsets ]]; do - name=_descr_opts_$i - [[ -n "$showd" ]] && disp=( "${(@)${(@M)disps:#*,${i}}%,*}" ) - descr=( "${(@P)descrs[i]}" ) - - # We collect the strings to display in `tmpd' (one string per line) - # and `tmps' (in columns) and the matches to add in `tmpmd' and `tmpms'. - - tmpd=() - tmps=() - tmpmd=() - tmpms=() - if [[ -n "$matches[i]" ]]; then - match=( "${(@P)matches[i]}" ) - while (( $#match )); do - if [[ -n "$showd" && "$descr[1]" = *:?* ]]; then - tmpd=( "$tmpd[@]" "$disp[1]" ) - tmpmd=( "$tmpmd[@]" "$match[1]" ) - shift 1 disp - else - tmps=( "$tmps[@]" "${descr[1]%%:*}" ) - tmpms=( "$tmpms[@]" "$match[1]" ) + if [[ -n "$_hide" ]]; then + if [[ "$PREFIX" = --* ]]; then + _tmpd=( "${(@)_tmpd#--}" ) + _tmps=( "${(@)_tmps#--}" ) + elif [[ "$PREFIX" = [-+]* ]]; then + _tmpd=( "${(@)_tmpd#[-+]}" ) + _tmps=( "${(@)_tmps#[-+]}" ) fi - shift 1 match - shift 1 descr - done - else - while (( $#descr )); do - if [[ -n "$showd" && "$descr[1]" = *:?* ]]; then - tmpd=( "$tmpd[@]" "$disp[1]" ) - tmpmd=( "$tmpmd[@]" "${descr[1]%%:*}" ) - shift 1 disp - else - tmps=( "$tmps[@]" "${descr[1]%%:*}" ) - tmpms=( "$tmpms[@]" "${descr[1]%%:*}" ) - fi - shift 1 descr - done - fi - - # See if we should remove the option prefix characters. - - if [[ -n "$isopt" && "$compconfig[option_prefix]" = hide* ]]; then - if [[ "$PREFIX" = --* ]]; then - tmpd=( "${(@)tmpd#--}" ) - tmps=( "${(@)tmps#--}" ) - elif [[ "$PREFIX" = [-+]* ]]; then - tmpd=( "${(@)tmpd#[-+]}" ) - tmps=( "${(@)tmps#[-+]}" ) fi - fi - compadd "${(@P)name}" "$expl[@]" -ld tmpd - "$tmpmd[@]" && ret=0 - compadd "${(@P)name}" "$expl[@]" -d tmps - "$tmpms[@]" && ret=0 -done -return ret + compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0 + compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0 + done +done +return _ret diff --git a/Completion/Base/_jobs b/Completion/Base/_jobs index 869aeeb8a..45983ad16 100644 --- a/Completion/Base/_jobs +++ b/Completion/Base/_jobs @@ -1,27 +1,85 @@ #autoload -local expl disp jobs job jids +local expl disp jobs job jids pfx='%' desc how expls + +_wanted jobs || return 1 + +if [[ "$1" = -t ]]; then + zstyle -T ":completion:${curcontext}:jobs" prefix-needed && + [[ "$PREFIX" != %* && compstate[nmatches] -ne 0 ]] && return 1 + shift +fi +zstyle -t ":completion:${curcontext}:jobs" prefix-hidden && pfx='' +zstyle -T ":completion:${curcontext}:jobs" verbose && desc=yes if [[ "$1" = -r ]]; then jids=( "${(@k)jobstates[(R)running*]}" ) shift - _description expl 'running job' + expls='running job' elif [[ "$1" = -s ]]; then jids=( "${(@k)jobstates[(R)running*]}" ) shift - _description expl 'suspended job' + expls='suspended job' else [[ "$1" = - ]] && shift jids=( "${(@k)jobtexts}" ) - _description expl job + expls=job fi -disp=() -jobs=() -for job in "$jids[@]"; do - disp=( "$disp[@]" "${(l:3:: ::%:)job} -- ${jobtexts[$job]}" ) - jobs=( "$jobs[@]" "$job" ) -done +if [[ -n "$desc" ]]; then + disp=() + for job in "$jids[@]"; do + [[ -n "$desc" ]] && + disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" ) + done +fi + +zstyle -s ":completion:${curcontext}:jobs" numbers how + +if [[ "$how" = (yes|true|on|1) ]]; then + jobs=( "$jids[@]" ) +else + local texts i text str tmp num max=0 -compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]" + # Find shortest unambiguous strings. + texts=( "$jobtexts[@]" ) + jobs=() + for i in "$jids[@]"; do + text="$jobtexts[$i]" + str="${text%% *}" + if [[ "$text" = *\ * ]]; then + text="${text#* }" + else + text="" + fi + tmp=( "${(@M)texts:#${str}*}" ) + num=1 + while [[ -n "$text" && $#tmp -ge 2 ]]; do + str="${str} ${text%% *}" + if [[ "$text" = *\ * ]]; then + text="${text#* }" + else + text="" + fi + tmp=( "${(@M)texts:#${str}*}" ) + (( num++ )) + done + + [[ num -gt max ]] && max="$num" + + jobs=( "$jobs[@]" "$str" ) + done + + if [[ "$how" = [0-9]## && max -gt how ]]; then + jobs=( "$jids[@]" ) + else + [[ -z "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" ) + fi +fi + +if [[ -n "$desc" ]]; then + _all_labels jobs expl "$expls" compadd "$@" -ld disp - "%$^jobs[@]" +else + _all_labels jobs expl "$expls" compadd "$@" - "%$^jobs[@]" +fi diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript index 2b827a117..60d45370b 100644 --- a/Completion/Base/_subscript +++ b/Completion/Base/_subscript @@ -1,4 +1,56 @@ -#defcomp -subscript- +#compdef -subscript- -_compalso -math- "$@" -[[ ${(Pt)${COMMAND}} = assoc* ]] && complist -k "( ${(kP)${COMMAND}} )" +local expl + +if [[ "$PREFIX" = :* ]]; then + _wanted characters expl 'character class' \ + compadd -p: -S ':]' alnum alpha blank cntrl digit graph \ + lower print punct space upper xdigit +elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then + local suf + + [[ "$RBUFFER" != \]* ]] && suf=']' + + _wanted association-keys expl 'association key' \ + compadd -S "$suf" - "${(@kP)${compstate[parameter]}}" +elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then + local list i j ret=1 disp + + _tags indexes parameters + + while _tags; do + if _requested indexes; then + ind=( {1..${#${(P)${compstate[parameter]}}}} ) + if zstyle -T ":completion:${curcontext}:indexes" verbose; then + list=() + for i in "$ind[@]"; do + if [[ "$i" = ${PREFIX}*${SUFFIX} ]]; then + list=( "$list[@]" + "${i}:$(print -D ${(P)${compstate[parameter]}[$i]})" ) + else + list=( "$list[@]" '' ) + fi + done + zformat -a list ' -- ' "$list[@]" + disp=( -d list) + else + disp=() + fi + + if [[ "$RBUFFER" = \]* ]]; then + _all_labels -V indexes expl 'array index' \ + compadd -S '' "$disp[@]" - "$ind[@]" && ret=0 + else + _all_labels -V indexes expl 'array index' \ + compadd -S ']' "$disp[@]" - "$ind[@]" && ret=0 + fi + fi + _requested parameters && _parameters && ret=0 + + (( ret )) || return 0 + done + + return 1 +else + _compalso -math- +fi diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde index aef575e19..7ab058e01 100644 --- a/Completion/Base/_tilde +++ b/Completion/Base/_tilde @@ -1,10 +1,53 @@ -#defcomp -tilde- +#compdef -tilde- # We use all named directories and user names here. If this is too slow # for you or if there are too many of them, you may want to use -# `compgen -k friends -qS/' or something like that. To get all user names -# if there are no matches in the `friends' array, add -# `(( compstate[nmatches] )) || compgen -nu -qS/' -# below that. +# `compadd -qS/ - "$friends[@]"' or something like that. -compgen -nu -qS/ +local expl suf dirs list lines revlines i ret disp nm="$compstate[nmatches]" + +if [[ "$SUFFIX" = */* ]]; then + ISUFFIX="/${SUFFIX#*/}$ISUFFIX" + SUFFIX="${SUFFIX%%/*}" + suf=(-S '') +else + suf=(-qS/) +fi + +_tags users named-directories directory-stack + +while _tags; do + _requested users && _users "$suf[@]" "$@" && ret=0 + _requested named-directories expl 'named directory' \ + compadd "$suf[@]" "$@" - "${(@k)nameddirs}" + + if _requested directory-stack && + { ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed || + [[ "$PREFIX" = [-+]* || nm -eq compstate[nmatches] ]] }; then + if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then + integer i + + lines=("${PWD}" "${dirstack[@]}") + + if [[ ( -prefix - && ! -o pushdminus ) || + ( -prefix + && -o pushdminus ) ]]; then + revlines=( $lines ) + for (( i = 1; i <= $#lines; i++ )); do + lines[$i]="$((i-1)) -- ${revlines[-$i]}" + done + else + for (( i = 1; i <= $#lines; i++ )); do + lines[$i]="$((i-1)) -- ${lines[$i]}" + done + fi + list=( ${PREFIX[1]}${^lines%% *} ) + disp=( -ld lines ) + else + list=( ${PREFIX[1]}{0..${#dirstack}} ) + disp=() + fi + _all_labels -V directory-stack expl 'directory stack' \ + compadd "$suf[@]" "$disp[@]" -Q - "$list[@]" && ret=0 + fi + (( ret )) || return 0 +done diff --git a/Completion/Base/_values b/Completion/Base/_values index 4be3e8203..62cf0e409 100644 --- a/Completion/Base/_values +++ b/Completion/Base/_values @@ -1,322 +1,103 @@ #autoload -setopt localoptions extendedglob +local subopts opt usecc -local name arg def descr xor str tmp ret=1 expl nm="$compstate[nmatches]" -local snames odescr gdescr sep -typeset -A names onames xors _values +subopts=() +while [[ "$1" = -(O*|C) ]]; do + case "$1" in + -C) usecc=yes; shift ;; + -O) subopts=( "${(@P)2}" ); shift 2 ;; + *) subopts=( "${(@P)1[3,-1]}" ); shift ;; + esac +done -# Probably fill our cache. +if compvalues -i "$@"; then -if [[ "$*" != "$_vals_cache_args" ]]; then - _vals_cache_args="$*" + local noargs args opts descr action expl sep subc + local oldcontext="$curcontext" - unset _vals_cache_{sep,descr,names,onames,snames,xors,odescr} + if ! compvalues -D descr action; then - typeset -gA _vals_cache_{names,onames,xors} - _vals_cache_snames=() - _vals_cache_odescr=() + _wanted values || return 1 - # Get the separator, if any. + curcontext="${oldcontext%:*}:values" - if [[ "$1" = -s ]]; then - _vals_cache_sep="$2" - shift 2 - fi - - # This is the description string for the values. - - _vals_cache_descr="$1" - shift - - # Now parse the descriptions. - - while (( $# )); do - - # Get the `name', anything before an unquoted colon. - - if [[ "$1" = *[^\\]:* ]]; then - name="${${${(M)1#*[^\\]:}[1,-2]}//\\\\:/:}" - else - name="$1" - fi - - descr='' - xor='' - - # Get a description, if any. - - if [[ "$name" = *\[*\] ]]; then - descr="${${name#*\[}[1,-2]}" - name="${name%%\[*}" - fi - - # Get the names of other values that are mutually exclusive with - # this one. - - if [[ "$name" = \(*\)* ]]; then - xor="${${name[2,-1]}%%\)*}" - name="${name#*\)}" - fi - - # Finally see if this value may appear more than once. - - if [[ "$name" = \** ]]; then - name="$name[2,-1]" - else - xor="$xor $name" - fi - - # Store the information in the cache. - - _vals_cache_odescr=( "$_vals_cache_odescr[@]" "${name}:$descr" ) - [[ -n "$xor" ]] && _vals_cache_xors[$name]="${${xor##[ ]#}%%[ ]#}" - - # Get the description and store that. - - if [[ "$1" = *[^\\]:* ]]; then - descr=":${1#*[^\\]:}" - else - descr='' - fi - - if [[ "$descr" = ::* ]]; then + compvalues -V noargs args opts - # Optional argument. - - _vals_cache_onames[$name]="$descr[3,-1]" - elif [[ "$descr" = :* ]]; then - - # Mandatory argument. - - _vals_cache_names[$name]="$descr[2,-1]" - else - - # No argument. - - _vals_cache_snames=( "$_vals_cache_snames[@]" "$name" ) - fi - shift - done -fi - -snames=( "$_vals_cache_snames[@]" ) -names=( "${(@kv)_vals_cache_names}" ) -onames=( "${(@kv)_vals_cache_onames}" ) -xors=( "${(@kv)_vals_cache_xors}" ) -odescr=( "$_vals_cache_odescr[@]" ) -gdescr="$_vals_cache_descr" -sep="$_vals_cache_sep" - -if [[ -n "$sep" ]]; then - - # We have a separator character. We parse the PREFIX and SUFFIX to - # see if any of the values that must not appear more than once are - # already on the line. - - while [[ "$PREFIX" = *${sep}* ]]; do - - # Get one part, remove it from PREFIX and put it into IPREFIX. - - tmp="${PREFIX%%${sep}*}" - PREFIX="${PREFIX#*${sep}}" - IPREFIX="${IPREFIX}${tmp}${sep}" - - # Get the value `name'. - - name="${tmp%%\=*}" - - if [[ "$tmp" = *\=* ]]; then - _values[$name]="${tmp#*\=}" - else - _values[$name]='' - fi - - # And remove the descriptions for the values this one makes - # superfluous. - - if [[ -n "$xors[$name]" ]]; then - snames=( "${(@)snames:#(${(j:|:)~${=xors[$name]}})}" ) - odescr=( "${(@)odescr:#(${(j:|:)~${=xors[$name]}}):*}" ) - unset {names,onames,xors}\[${^=tmp}\] - fi - done - if [[ "$SUFFIX" = *${sep}* ]]; then - - # The same for the suffix. + if [[ "$PREFIX" = *\=* ]]; then + local name - str="${SUFFIX%%${sep}*}" - SUFFIX="${SUFFIX#*${sep}}" - while [[ -n "$SUFFIX" ]]; do - tmp="${PREFIX%%${sep}*}" - if [[ "$SUFFIX" = *${sep}* ]]; then - SUFFIX="${SUFFIX#*${sep}}" + name="${PREFIX%%\=*}" + if compvalues -L "$name" descr action; then + IPREFIX="${IPREFIX}${name}=" + PREFIX="${PREFIX#*\=}" else - SUFFIX='' + local prefix suffix + + prefix="${PREFIX#*\=}" + suffix="$SUFFIX" + PREFIX="$name" + SUFFIX='' + args=( "$args[@]" "$opts[@]" ) + compadd -M 'r:|[_-]=* r:|=*' -D args - "${(@)args[@]%%:*}" + + [[ $#args -ne 1 ]] && return 1 + + PREFIX="$prefix" + SUFFIX="$suffix" + IPREFIX="${IPREFIX}${args[1]%%:*}=" + compvalues -L "${args[1]%%:*}" descr action subc + curcontext="${oldcontext%:*}:$subc" fi - PREFIX="${PREFIX#*${sep}}" - IPREFIX="${IPREFIX}${tmp}${sep}" - - name="${tmp%%\=*}" - - if [[ "$tmp" = *\=* ]]; then - _values[$name]="${tmp#*\=}" + else + compvalues -d descr + if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s sep; then + sep=( "-qQS" "$sep" ) else - _values[$name]='' + sep=() fi - if [[ -n "$xors[$name]" ]]; then - snames=( "${(@)snames:#(${(j:|:)~${=xors[$name]}})}" ) - odescr=( "${(@)odescr:#(${(j:|:)~${=xors[$name]}}):*}" ) - unset {names,onames,xors}\[${^=tmp}\] - fi - done - SUFFIX="$str" - fi -fi - -descr='' -str="$PREFIX$SUFFIX" - -if [[ "$str" = *\=* ]]; then - - # The string from the line contains a `=', so we get the stuff before - # it and after it and see what we can do here... - - name="${str%%\=*}" - arg="${str#*\=}" - - if (( $snames[(I)${name}] )); then - - # According to our information, the value doesn't get an argument, - # so give up. - - _message "\`${name}' gets no value" - return 1 - elif (( $+names[$name] )); then - - # It has to get an argument, we skip over the name and complete - # the argument (below). - - def="$names[$name]" - if ! compset -P '*\='; then - IPREFIX="${IPREFIX}${name}=" - PREFIX="$arg" - SUFFIX='' - fi - elif (( $+onames[$name] )); then + _describe "$descr" \ + noargs "$sep[@]" -M 'r:|[_-]=* r:|=*' -- \ + args -S= -M 'r:|[_-]=* r:|=*' -- \ + opts -qS= -M 'r:|[_-]=* r:|=*' - # Gets an optional argument, same as previous case. + curcontext="$oldcontext" - def="$onames[$name]" - if ! compset -P '*\='; then - IPREFIX="${IPREFIX}${name}=" - PREFIX="$arg" - SUFFIX='' + return fi else - local pre="$PREFIX" suf="$SUFFIX" - - # The part before the `=' isn't a known value name, so we see if - # it matches only one of the known names. - - if [[ "$PREFIX" = *\=* ]]; then - PREFIX="${PREFIX%%\=*}" - pre="${pre#*\=}" - SUFFIX='' - else - SUFFIX="${SUFFIX%%\=*}" - pre="${suf#*\=}" - suf='' - fi - - tmp=( "${(@k)names}" "${(@k)onames}" ) - compadd -M 'r:|[-_]=* r:|=*' -D tmp - "$tmp[@]" - - if [[ $#tmp -eq 1 ]]; then - - # It does, so we use that name and immediatly start completing - # the argument for it. - - IPREFIX="${IPREFIX}${tmp[1]}=" - PREFIX="$pre" - SUFFIX="$suf" - - def="$names[$tmp[1]]" - [[ -z "$def" ]] && def="$onames[$tmp[1]]" - elif (( $#tmp )); then - _message "ambiguous option \`${PREFIX}${SUFFIX}'" - return 1 - else - _message "unknown option \`${PREFIX}${SUFFIX}'" - return 1 - fi + compvalues -C subc + curcontext="${oldcontext%:*}:$subc" fi -else - - # No `=', just complete value names. - - _description expl "$gdescr" - [[ -n "$sep" && ${#snames}+${#names}+${#onames} -ne 1 ]] && - expl=( "-qS$sep" "$expl[@]" ) - - tmp='' - if [[ -n "$compconfig[describe_values]" && - "$compconfig[describe_values]" != *\!${words[1]}* ]]; then - if _display tmp odescr -M 'r:|[_-]=* r:|=*'; then - if (( $#snames )); then - compadd "$expl[@]" -y tmp -M 'r:|[_-]=* r:|=*' - \ - "$snames[@]" && ret=0 - compadd -n -S= -J "_$gdescr" -M 'r:|[_-]=* r:|=*' - \ - "${(@k)names}" && ret=0 - compadd -n -qS= -J "_$gdescr" -M 'r:|[_-]=* r:|=*' - \ - "${(@k)onames}" && ret=0 - elif (( $#names )); then - compadd -n -S= "$expl[@]" -y tmp -M 'r:|[_-]=* r:|=*' - \ - "${(@k)names}" && ret=0 - compadd -n -qS= -J "_$gdescr" -M 'r:|[_-]=* r:|=*' - \ - "${(@k)onames}" && ret=0 - else - compadd -n -qS= "$expl[@]" -y tmp -M 'r:|[_-]=* r:|=*' - \ - "${(@k)onames}" && ret=0 - fi - fi - fi - if [[ -z "$tmp" ]]; then - compadd "$expl[@]" -M 'r:|[_-]=* r:|=*' - "$snames[@]" && ret=0 - compadd -S= "$expl[@]" -M 'r:|[_-]=* r:|=*' - "${(@k)names}" && ret=0 - compadd -qS= "$expl[@]" -M 'r:|[_-]=* r:|=*' - "${(@k)onames}" && ret=0 + if ! _tags arguments; then + curcontext="$oldcontext" + return 1 fi - return ret -fi - -if [[ -z "$def" ]]; then - _message 'no value' - return 1 -else - local action - - descr="${${${(M)def#*[^\\]:}[1,-2]}//\\\\:/:}" - action="${${def#*[^\\]:}//\\\\:/:}" - _description expl "$descr" + _description arguments expl "$descr" # We add the separator character as a autoremovable suffix unless # we have only one possible value left. - [[ -n "$sep" && ${#snames}+${#names}+${#onames} -ne 1 ]] && + [[ ${#snames}+${#names}+${#onames} -ne 1 ]] && compvalues -s sep && expl=( "-qS$sep" "$expl[@]" ) if [[ "$action" = -\>* ]]; then - values=( "${(@kv)_values}" ) + compvalues -v val_args state="${${action[3,-1]##[ ]#}%%[ ]#}" + if [[ -n "$usecc" ]]; then + curcontext="${oldcontext%:*}:$subc" + else + context="$subc" + fi compstate[restore]='' return 1 else - typeset -A values + typeset -A val_args - values=( "${(@kv)_values}" ) + compvalues -v val_args if [[ "$action" = \ # ]]; then @@ -332,36 +113,44 @@ else eval ws\=\( "${action[3,-3]}" \) - if _display tmp ws; then - compadd "$expl[@]" -y tmp - "${(@)ws%%:*}" - else - _message "$descr" - return 1 - fi + _describe "$descr" ws -M 'r:|[_-]=* r:|=*' "$subopts[@]" + elif [[ "$action" = \(*\) ]]; then # Anything inside `(...)' is added directly. - compadd "$expl[@]" - ${=action[2,-2]} + _all_labels arguments expl "$descr" \ + compadd "$subopts[@]" - ${=action[2,-2]} elif [[ "$action" = \{*\} ]]; then # A string in braces is evaluated. - eval "$action[2,-2]" - + while _next_label arguments expl "$descr"; do + eval "$action[2,-2]" + done elif [[ "$action" = \ * ]]; then # If the action starts with a space, we just call it. - ${(e)=~action} + eval "action=( $action )" + while _next_label arguments expl "$descr"; do + "$action[@]" + done else # Otherwise we call it with the description-arguments built above. - action=( $=action ) - ${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]} + eval "action=( $action )" + _all_labels arguments expl "$descr" \ + "$action[1]" "$subopts[@]" "${(@)action[2,-1]}" fi fi -fi -[[ nm -ne "$compstate[nmatches]" ]] + curcontext="$oldcontext" + + [[ nm -ne "$compstate[nmatches]" ]] +else + curcontext="$oldcontext" + + return 1; +fi diff --git a/Completion/Builtins/_autoload b/Completion/Builtins/_autoload index 4f506baeb..238b79e95 100644 --- a/Completion/Builtins/_autoload +++ b/Completion/Builtins/_autoload @@ -1,3 +1,10 @@ -#defcomp autoload +#compdef autoload -complist -s '${^fpath}/*(N:t)' +local expl + +if (( $words[(I)[-+]*w*] )); then + _description files expl 'zwc file' + _files "$expl[@]" -g '*.zwc' +else + _wanted functions expl 'shell function' compadd - ${^fpath}/*(N:t) +fi diff --git a/Completion/Builtins/_cd b/Completion/Builtins/_cd index f3ce67ec7..803bcbda5 100644 --- a/Completion/Builtins/_cd +++ b/Completion/Builtins/_cd @@ -1,3 +1,47 @@ -#defcomp cd +#compdef cd chdir pushd -_files -W cdpath -g '*(-/)' +# Handling of cd. +# - Normally just completes directories. Uses cdpath if that's set +# and the string doesn't begin with ~, /, ./ or ../. +# - In the second argument to cd for the form `cd old new', completes +# possible `new' strings by examining `old' and $PWD. +# - After - or +, completes numbers, but the listing +# gives you the list of directories to complete. This turns on +# menu-completion and lists the possibilities automatically, otherwise +# it's not a lot of use. If you don't type the + or - it will +# complete directories as normal. + +setopt localoptions nonomatch + +local expl + +if [[ CURRENT -eq 3 ]]; then + # cd old new: look for old in $PWD and see what can replace it + local rep + # Get possible completions using word in position 2 + rep=(${~PWD/$words[2]/*}~$PWD(-/N)) + # Now remove all the common parts of $PWD and the completions from this + rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}}) + (( $#rep )) && _wanted -C replacement strings expl replacement compadd $rep +elif _popd || [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then + local tdir tdir2 + + # With cdablevars, we can convert foo/bar/... to ~foo/bar/... if + # there is no directory foo. In that case we could also complete + # variable names, but it hardly seems worth it. + # Note we need a tilde because cdablevars also allows user home + # directories, hence we also need nonomatch to suppress error messages. + if [[ -o cdablevars && -n "$PREFIX" && ! -d ${tdir::=${PREFIX%%/*}} && + -d ${~tdir2::="~$tdir"} ]]; then + PREFIX="~$PREFIX" + _wanted directories expl directory _path_files -/ + else + local tmpcdpath + tmpcdpath=(${${(@)cdpath:#.}:#$PWD}) + _alternative \ + 'local-directories:local directories:_path_files -/' \ + "path-directories:directories in cdpath:_path_files -W tmpcdpath -/" + fi +else + _wanted directories expl directory _path_files -/ +fi diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef index 1df5758b3..d47a560c9 100644 --- a/Completion/Builtins/_compdef +++ b/Completion/Builtins/_compdef @@ -1,22 +1,40 @@ #compdef compdef -local func base=2 +local state line expl list disp -while [[ $words[base] = -* ]]; do - case $words[base] in - -d) delete=yes ;; - -p) type=pattern ;; - -k) type=key ;; - esac - (( base++ )) -done +_arguments -C -s \ + '(-d)-a[make function autoloadable]' \ + '(-d -p -P)-n[leave existing definitions intact]' \ + '(-a -n -p -P -k -K)-d[delete]:*:completed command:->ccom' \ + '(-n -d -P -k -K)-p[completion for command matching pattern]:completion function:->cfun:pattern' \ + '(-n -d -p -k -K)-P[as -p for commands without own completion]:completion function:->cfun:pattern' \ + '(-d -p -P -K)-k[define widget and key binding]:completion function:->cfun:widget name::style:->style:*:key' \ + '(-d -p -P -k)-K[define multiple widgets based on function]:completion function:->cfun:widget name::style:->style:*:key' \ + '1:completion function:->cfun' \ + '2:commands:_command_names' + -if [ "$delete" ]; then - compadd ${(k)_comps} -else - if [[ CURRENT -eq base ]]; then - for func in ${^~fpath:/.}/_(|*[^~])(N:t); compadd -P_ - ${func#_} - else - compgen -c - fi -fi +case $state in + ccom) + _wanted commands expl 'completed command' compadd - ${(k)_comps} + ;; + cfun) + if _wanted functions; then + list=( ${^fpath:/.}/_(|*[^~])(N:t) ) + if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then + disp=( ${list[@]#_} ) + _all_labels functions expl 'completion function' \ + compadd -d disp - "$list[@]" + else + _all_labels functions expl 'completion function' compadd - "$list[@]" + fi + fi + ;; + style) + _wanted widgetstyle expl 'widget style' \ + compadd -M 'r:|-=* r:|=*' \ + complete-word delete-char-or-list expand-or-complete \ + expand-or-complete-prefix list-choices menu-complete \ + menu-expand-or-complete reverse-menu-complete + ;; +esac diff --git a/Completion/Builtins/_disable b/Completion/Builtins/_disable index 063b65a7d..b3c2632ed 100644 --- a/Completion/Builtins/_disable +++ b/Completion/Builtins/_disable @@ -1,6 +1,8 @@ -#defcomp disable +#compdef disable -[[ -mcurrent -1 -*a* ]] && complist -ea -[[ -mcurrent -1 -*f* ]] && complist -eF -[[ -mcurrent -1 -*r* ]] && complist -ew -[[ ! -mcurrent -1 -* ]] && complist -eB +_arguments -C -s \ + "(-f -r)-a[act on aliases]:*:aliases:(${(k)aliases} ${(k)galiases})" \ + "(-a -r)-f[act on functions]:*:functions:(${(k)functions})" \ + "(-a -f)-r[act on reserved words]:*:reserved-words:(${(k)reswords})" \ + '-m[treat arguments as patterns]' \ + "*:builtin command:(${(k)builtins})" diff --git a/Completion/Builtins/_emulate b/Completion/Builtins/_emulate new file mode 100644 index 000000000..82096a77e --- /dev/null +++ b/Completion/Builtins/_emulate @@ -0,0 +1,6 @@ +#compdef emulate + +_arguments -C -s \ + '-L[set local_options and local_traps as well]' \ + '-R[reset all options instead of only those needed for script portability]' \ + '1::shell to emulate:(zsh sh ksh csh)' diff --git a/Completion/Builtins/_enable b/Completion/Builtins/_enable index 22ff53ee7..991286276 100644 --- a/Completion/Builtins/_enable +++ b/Completion/Builtins/_enable @@ -1,6 +1,8 @@ -#defcomp enable +#compdef enable -[[ -mcurrent -1 -*a* ]] && complist -da -[[ -mcurrent -1 -*f* ]] && complist -dF -[[ -mcurrent -1 -*r* ]] && complist -dw -[[ ! -mcurrent -1 -* ]] && complist -dB +_arguments -C -s \ + "(-f -r)-a[act on aliases]:*:aliases:(${(k)dis_aliases})" \ + "(-a -r)-f[act on functions]:*:functions:(${(k)dis_functions})" \ + "(-a -f)-r[act on reserved words]:*:reserved-words:(${(k)dis_reswords})" \ + '-m[treat arguments as patterns]' \ + "*:builtin command:(${(@k)dis_builtins})" diff --git a/Completion/Builtins/_fc b/Completion/Builtins/_fc index f0d2c03fd..e97492604 100644 --- a/Completion/Builtins/_fc +++ b/Completion/Builtins/_fc @@ -1,7 +1,27 @@ -#defcomp fc +#compdef fc history -if [[ -mcurrent -1 -*e ]]; then - complist -c -elif [[ -mcurrent -1 -[ARWI]## ]]; then - _files +local fc_common + +fc_common=( \ + '(-A -R -W -I)-m[treat first argument as a pattern]' \ + '(-A -R -W -I)-r[reverse order of the commands]' \ + '(-A -R -W -I -e)-n[suppress line numbers]' \ + '(-A -R -W -I -e -f -E -i)-d[print time-stamps]' \ + '(-A -R -W -I -e -d -E -i)-f[mm/dd/yyyy format time-stamps]' \ + '(-A -R -W -I -e -d -f -i)-E[dd.mm.yyyy format time-stamps]' \ + '(-A -R -W -I -e -d -f -E)-i[yyyy-mm-dd format time-stamps]' \ + '(-A -R -W -I -e)-D[print elapsed times]' \ + '(-A -R -W -I)*::commands:_command_names -e' ) + +if [[ $words[1] = *history ]]; then + _arguments -C -s "$fc_common[@]" +else + _arguments -C -s \ + '(-A -R -W -I -e)-l[list resulting commands on stdout]' \ + '(-A -R -W -I -l -n -d -f -E -i -D)-e[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-l -m -e -r -n -d -f -E -i -D -A -W *)-R[read history from file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -R -W *)-A[append history to file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -R -A *)-W[write history to file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -A -W *)-I[read/write new events only]:history file:_files' \ + "$fc_common[@]" fi diff --git a/Completion/Builtins/_nothing b/Completion/Builtins/_nothing index 35a2558cc..38f6bee77 100644 --- a/Completion/Builtins/_nothing +++ b/Completion/Builtins/_nothing @@ -1,3 +1,3 @@ -#compdef true false +#compdef true false log times whoami _message 'no argument or option' diff --git a/Completion/Builtins/_pids b/Completion/Builtins/_pids index 0ffda900b..7dec90e7d 100644 --- a/Completion/Builtins/_pids +++ b/Completion/Builtins/_pids @@ -3,16 +3,32 @@ # If given the `-m <pattern>' option, this tries to complete only pids # of processes whose command line match the `<pattern>'. -local list expl match +local out list expl match desc listargs args + +_wanted processes || return 1 if [[ "$1" = -m ]]; then match="${2}*" shift 2 fi -_description expl 'process ID' +zstyle -s ":completion:${curcontext}:pids" command args + +out="$(_call pids ps 2>/dev/null)" -list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}") +if zstyle -T ":completion:${curcontext}:processes" verbose; then + zstyle -s ":completion:${curcontext}:pids-list" command listargs + (( $#listargs )) || listargs=( "$args[@]" ) + if [[ "$listargs" = "$args" ]]; then + list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}") + else + list=("${(@Mr:COLUMNS-1:)${(f@)$(_call pids-list ps 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}") + fi + desc=(-ld list) +else + desc=() +fi -compadd "$expl[@]" "$@" -ld list - \ - ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *} +_all_labels processes expl 'process ID' \ + compadd "$@" "$desc[@]" - \ + ${${${(M)${(f)"${out}"}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]#*${~match}}## #}%% *} diff --git a/Completion/Builtins/_popd b/Completion/Builtins/_popd index 9054befb7..2a3413253 100644 --- a/Completion/Builtins/_popd +++ b/Completion/Builtins/_popd @@ -5,36 +5,39 @@ # way round if pushdminus is set). Note that this function is also called # from _cd for cd and pushd. -emulate -L zsh setopt extendedglob nonomatch -[[ $PREFIX = [-+]* ]] || return 1 +local expl list lines revlines disp -local expl list lines revlines ret=1 i +! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed || + [[ $PREFIX = [-+]* ]] || return 1 -IPREFIX=$PREFIX[1] -PREFIX=$PREFIX[2,-1] +_wanted directory-stack || return 1 -# get the list of directories with their canonical number -# and turn the lines into an array, removing the current directory -lines=( ${${(f)"$(dirs -v)"}##0*} ) -if [[ ( $IPREFIX = - && ! -o pushdminus ) || - ( $IPREFIX = + && -o pushdminus ) ]]; then - integer i - revlines=( $lines ) - for (( i = 1; i <= $#lines; i++ )); do - lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}" - done +if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then + # get the list of directories with their canonical number + # and turn the lines into an array, removing the current directory + lines=("${dirstack[@]}") + + if [[ ( $PREFIX[1] = - && ! -o pushdminus ) || + ( $PREFIX[1] = + && -o pushdminus ) ]]; then + integer i + revlines=( $lines ) + for (( i = 1; i <= $#lines; i++ )); do + lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}" + done + else + for (( i = 1; i <= $#lines; i++ )); do + lines[$i]="$i -- ${lines[$i]##[0-9]#[ ]#}" + done + fi + # get the array of numbers only + list=( ${PREFIX[1]}${^lines%% *} ) + disp=( -ld lines ) else - for (( i = 1; i <= $#lines; i++ )); do - lines[$i]="$i -- ${lines[$i]##[0-9]#[ ]#}" - done + list=( ${PREFIX[1]}{0..${#dirstack}} ) + disp=() fi -# get the array of numbers only -list=(${lines%% *}) -_description expl 'directory stack index' -compadd "$expl[@]" -ld lines -V dirs -Q - "$list[@]" && ret=0 -[[ -z $compstate[list] ]] && compstate[list]=list && ret=0 -[[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0 - -return ret + +_all_labels -V directory-stack expl 'directory stack' \ + compadd "$@" "$disp[@]" -Q - "$list[@]" diff --git a/Completion/Builtins/_sched b/Completion/Builtins/_sched index 1e8ae3445..98ecb3642 100644 --- a/Completion/Builtins/_sched +++ b/Completion/Builtins/_sched @@ -1,3 +1,23 @@ -#defcomp sched +#compdef sched -[[ -position 2 -1 ]] && _normal "$@" +local expl lines disp + +if [[ CURRENT -eq 2 ]]; then + if compset -P -; then + _wanted -C - jobs || return 1 + + lines=(${(f)"$(sched)"}) + if zstyle -T ":completion:${curcontext}:jobs" verbose; then + disp=( -ld lines ) + else + disp=() + fi + [[ -z $lines ]] || _all_labels jobs expl 'scheduled jobs' \ + compadd "$disp[@]" - {1..$#lines} + return + else + _message 'time specification' + return 1 + fi +fi +compset -n 3 && _normal diff --git a/Completion/Builtins/_signals b/Completion/Builtins/_signals index c79350044..aa95a8499 100644 --- a/Completion/Builtins/_signals +++ b/Completion/Builtins/_signals @@ -20,17 +20,19 @@ done [[ "$1" = -(|-) ]] && shift -if _wanted signals expl signal && - { [[ -z "$minus" ]] || ! _style signals prefix-needed || +if _wanted signals && + { [[ -z "$minus" ]] || + ! zstyle -T ":completion:${curcontext}:signals" prefix-needed || [[ "$PREFIX" = -* ]] } ; then local disp tmp - if _style signals prefix-hidden; then + if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then tmp=( "${(@)signals[1,last]}" ) disp=(-d tmp) else disp=() fi - compadd "$@" "$expl[@]" "$disp[@]" -M 'm:{a-z}=${A-Z}' - \ - "${minus}${(@)^signals[1,last]}" + _all_labels signals expl signal \ + compadd "$@" "$disp[@]" -M 'm:{a-z}={A-Z}' - \ + "${minus}${(@)^signals[1,last]}" fi diff --git a/Completion/Builtins/_stat b/Completion/Builtins/_stat index 3cdbb2618..5ba06388b 100644 --- a/Completion/Builtins/_stat +++ b/Completion/Builtins/_stat @@ -1,10 +1,20 @@ #compdef stat +local expl ret=1 + if [[ "$words[CURRENT-1]" = -[AH] ]]; then - compgen -A + _arrays else - [[ "$PREFIX[1]" = + ]] && - compadd - +device +inode +mode +nlink +uid +gid +rdev +size \ - +atime +mtime +ctime +blksize +block +link - _files + _tags files options || return 1 + + while _tags; do + _requested files && _files && ret=0 + _requested options && + { ! zstyle -T ":completion:${curcontext}:options" prefix-needed || + [[ "$PREFIX[1]" = + || ret -eq 1 ]] } && + _all_labels options expl 'inode element' \ + compadd - +device +inode +mode +nlink +uid +gid +rdev \ + +size +atime +mtime +ctime +blksize +block +link + (( ret )) || return 0 + done fi diff --git a/Completion/Builtins/_zcompile b/Completion/Builtins/_zcompile new file mode 100644 index 000000000..5ec6f96ce --- /dev/null +++ b/Completion/Builtins/_zcompile @@ -0,0 +1,22 @@ +#compdef zcompile + +local context state line expl +typeset -A opt_args + +_arguments -s \ + '(-c -m -a)-U[don'\''t expand aliases]' \ + '(-M)-R[mark as read]' \ + '(-R)-M[mark as mapped]' \ + '(-c -z -m -a)-k[ksh-style autoloading]' \ + '(-c -k -m -a)-z[zsh-style autoloading]' \ + '(-U -z -k)-c[currently defined functions]' \ + '(-U -z -k)-m[use names as patterns]' \ + '(-U -z -k)-a[write autoload functions]' \ + ':zwc file:_files' \ + '*:function:->function' && return 0 + +if (( $+opt_args[-c] )); then + _wanted functions expl 'function to write' compadd - ${(k)functions} +else + _wanted file expl 'zsh source file' _files +fi diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp index 9be9c94db..0d6530dfc 100644 --- a/Completion/Builtins/_zftp +++ b/Completion/Builtins/_zftp @@ -1,50 +1,92 @@ -#defpatcomp zf* - -# Don't try any more completion after this. -_compskip=1 +#compdef -p zf* # Completion for zftp builtin and zf* functions. The functions -# zfcd_match and zfget_match (used for old-style completion) +# zfcd_match and zfget_match (also used for old-style completion) # need to be installed for remote file and directory completion to work. -local subcom +# emulate -L zsh + +# Don't try any more completion after this. +_compskip=all + +local subcom expl curcontext="${curcontext}" -if [[ $COMMAND = zftp ]]; then - if [[ $CURRENT -eq 1 ]]; then - compadd -m open params user login type ascii binary mode put \ - putat get getat append appendat ls dir local remote mkdir rmdir +if [[ $words[1] = zftp ]]; then + if [[ $CURRENT -eq 2 ]]; then + _wanted commands expl sub-command \ + compadd open params user login type ascii binary mode put \ + putat get getat append appendat ls dir local remote mkdir rmdir \ + session rmsession return fi - subcom=$1 + subcom=$words[2] + curcontext="${curcontext/:zftp:/:zftp-${words[2]}:}" else - subcom=$COMMAND + subcom=$words[1] fi case $subcom in *(cd|ls|dir)) - # complete remote directories; we could be smarter about hiding prefixes - zfcd_match $PREFIX $SUFFIX - (( $#reply )) && compadd -m -S/ -q $reply - ;; + # complete remote directories + _wanted directories && zfcd_match $PREFIX $SUFFIX + ;; *(get(|at)|gcp|delete|remote)) - # complete remote files - zfget_match $PREFIX $SUFFIX - (( $#reply )) && compadd -F fignore -m $reply - ;; + # complete remote files + _wanted files && zfget_match $PREFIX $SUFFIX + ;; *(put(|at)|pcp)) - # complete local files - _files - ;; + # complete local files + _wanted files && _files + ;; *(open|anon|params)) - # complete hosts: should do cleverer stuff with user names - complist -k hosts - ;; + # complete hosts: should do cleverer stuff with user names + _wanted hosts && _hosts + ;; + + *(goto|mark)) + # complete bookmarks. First decide if ncftp mode is go. + _wanted bookmarks || return 1 + if [[ $words[2] = -*n* ]]; then + if [[ -f ~/.ncftp/bookmarks ]]; then + _all_labels bookmarks expl bookmark \ + compadd - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks) + fi + else + if [[ -f ${ZFTP_BMFILE:=${ZDOTDIR:-$HOME}/.zfbkmarks} ]]; then + _all_labels bookmarks expl bookmark \ + compadd - $(awk '{print $1}' $ZFTP_BMFILE) + fi + fi + ;; + + *session) + # complete sessions, excluding the current one. + _wanted sessions expl 'another FTP session' \ + compadd - ${$(zftp session):#$ZFTP_SESSION} + ;; + + *transfer) + # complete arguments like sess1:file1 sess2:file2 + if [[ $PREFIX = *:* ]]; then + # complete file in the given session + _wanted files || return 1 + local sess=${PREFIX%%:*} oldsess=$ZFTP_SESSION + compset -p $(( $#sess + 1 )) + [[ -n $sess ]] && zftp session $sess + zfget_match $PREFIX $SUFFIX + [[ -n $sess && -n $oldsess ]] && zftp session $oldsess + else + # note here we can complete the current session + _wanted sessions expl 'FTP session' compadd -S : - $(zftp session) + fi + ;; *) - # dunno... try ordinary completion after all. - unset _compskip - ;; + # dunno... try ordinary completion after all. + _compskip='' + return 1 + ;; esac diff --git a/Completion/Builtins/_zpty b/Completion/Builtins/_zpty index b197b4128..d8c77ff2e 100644 --- a/Completion/Builtins/_zpty +++ b/Completion/Builtins/_zpty @@ -7,17 +7,17 @@ _arguments -C -s \ '(-d -w -r -L)-b[io to pseudo-terminal blocking]' \ '(-e -b -w -r -L)-d[delete command]:*:name:->name' \ '(-e -b -d -r -L)-w[send string to command]:name:->name:*:strings to write' \ - '(-e -b -d -w -L)-r[read string from command]:name:->name:param:_parameters:*:nothing:_nothing' \ + '(-e -b -d -w -L *)-r[read string from command]:name:->name:param:_parameters' \ '(-e -b -d -w -r)-L[list defined commands as calls]' \ - '*::args:_normal' + '(-r)*::args:_normal' -if [[ $state = name ]] && _wanted zptynames expl 'zpty command names'; then +if [[ $state = name ]] && _wanted names; then list=( ${${(f)"$(zpty)"}#*\) } ) names=( ${list%%:*} ) if zstyle -T ":completion:${curcontext}" verbose; then zformat -a list ' --' ${${(f)"$(zpty)"}#*\) } - compadd "$expl[@]" -d list - "$names[@]" + _all_labels names expl 'zpty command names' compadd -d list - "$names[@]" else - compadd "$expl[@]" - "$names[@]" + _all_labels names expl 'zpty command names' compadd - "$names[@]" fi fi diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle index f072f79ae..cd470598a 100644 --- a/Completion/Builtins/_zstyle +++ b/Completion/Builtins/_zstyle @@ -1,7 +1,8 @@ #compdef zstyle -local curcontext="$curcontext" state ostate line expl ctop -local nm=$compstat[nmatches] +local curcontext="$curcontext" state context ostate line expl ctop +local nm=$compstate[nmatches] mesg +typeset -A opt_args typeset -A styles # Assoc array of styles; the values give the possible top-level @@ -9,15 +10,18 @@ typeset -A styles # followed by a colon, followed by a state to enter, empty if none. styles=( accept-exact c:bool + add-space c:bool arguments c: auto-description c: - cache-path 'c:_path_files -/' + break c: completer c:completer completions c: condition c: - cursor c:bool + cursor c:cursor disable-stat c:bool + domains c: expand c: + file-patterns c:filepat format c: glob c: group-name c: @@ -26,8 +30,9 @@ styles=( hidden c:bool hosts c:_hosts hosts-ports c:host-port - hosts-ports-users c:host-port-user - ignored-suffixes c: + users-hosts-ports c:user-host-port + ignore-parents c:ignorepar + ignored-patterns c: insert-unambiguous c:bool last-prompt c:bool list c:listwhen @@ -36,21 +41,26 @@ styles=( list-packed c:bool list-rows-first c:bool local c: + matcher-list c: max-errors c: menu c:boolauto numbers c:bool original c:bool - path 'c:_path_files -/' + packageset c:packageset + path 'c:_wanted directories expl directory _path_files -/' ports c:_ports prefix-hidden c:bool prefix-needed c:bool prompt c: remove-all-dups c:bool + single-ignored c:single-ignored sort c:bool - tag-order c:tag special-dirs c:sdirs + squeeze-slashes c:bool stop c:stop + subst-glob-only c: substitute c: + tag-order c:tag users c:_users users-hosts c:user-host verbose c:bool @@ -83,9 +93,20 @@ while [[ -n $state ]]; do case "$ostate" in contexts) - if [[ $PREFIX != :*: ]]; then - _wanted contexts expl context && - compadd -P : -S : "$expl[@]" completion zftp + if _wanted contexts; then + if [[ $PREFIX != :*: ]]; then + _all_labels contexts expl context compadd -P : -S : completion zftp + elif [[ $PREFIX = :completion:* ]]; then + mesg='' + case "$PREFIX" in + :completion:[^:]#) mesg=function ;; + :completion:[^:]#:[^:]#) mesg=completer ;; + :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;; + :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;; + :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;; + esac + [[ -n "$mesg" ]] && _message "$mesg" + fi fi ;; @@ -96,8 +117,8 @@ while [[ -n $state ]]; do else ctop=cz fi - _wanted styles expl style && - compadd "$expl[@]" - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]} + _wanted styles expl style \ + compadd -M 'r:|-=* r:|=*' - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]} ;; style-arg) @@ -105,66 +126,116 @@ while [[ -n $state ]]; do ;; bool) - _wanted values expl boolean && - compadd "$expl[@]" true false + _wanted values expl boolean compadd true false ;; boolauto) - _wanted values expl boolean && - compadd "$expl[@]" true false auto select + _wanted values expl boolean compadd true false auto select + ;; + + cursor) + if [[ "$words[2]" = *:completion:inc* ]]; then + _wanted values expl 'cursor positioning' compadd complete key default + elif [[ "$words[2]" = *:completion::* ]]; then + _wanted values expl 'cursor positioning' compadd true false + else + _wanted values expl 'cursor positioning' \ + compadd complete key default true false + fi ;; completer) - _wanted values expl completer && - compadd "$expl[@]" _complete _approximate _correct _match \ - _expand _list _menu _oldlist + _wanted values expl completer \ + compadd _complete _approximate _correct _match \ + _expand _list _menu _oldlist _next_tags ;; - host-port*) + user-host-port) + if [[ $PREFIX != *[@:]* ]]; then + _users -S @ + elif [[ $PREFIX = *[@:]*[[@:]* ]]; then + compset -P 2 '*[:@]' + _ports + else + compset -P 1 '*[:@]' + _hosts -S : + fi + ;; + + host-port) if [[ $PREFIX != *:* ]]; then _hosts -S : - elif [[ $ostate != *user || $PREFIX != *:*:* ]]; then + else compset -P 1 '*:' _ports - else - compset -P 2 '*:' - _users fi ;; listwhen) - _wanted values expl 'when to list completions' && - compadd "$expl[@]" always never sometimes + _wanted values expl 'when to list completions' \ + compadd always never sometimes + ;; + + packageset) + _wanted values expl 'default package set' \ + compadd available installed uninstalled ;; progress) - _wanted values expl 'progress meter style' && - compadd "$expl[@]" none bar percent + _wanted values expl 'progress meter style' \ + compadd none bar percent ;; sdirs) - _wanted values expl 'whether to complete . or ..' && - compadd "$expl[@]" true false .. + _wanted values expl 'whether to complete . or ..' \ + compadd true false .. ;; stop) - _wanted values expl 'when to insert matches' && - compadd "$expl[@]" true false verbose + _wanted values expl 'when to insert matches' \ + compadd true false verbose ;; tag) - _wanted tags expl tag && compadd "$expl[@]" - $taglist + compset -q + if compset -P '*:*:'; then + _message description + elif compset -P '*:'; then + _message 'tag alias' + else + _wanted tags expl tag compadd - $taglist + fi + ;; + + filepat) + if compset -P '*:*:'; then + _message description + elif compset -P '*:'; then + _message tag + else + _message 'glob patterns' + fi ;; user-host) - if [[ $PREFIX = *:* ]]; then - compset -P '*:' + if [[ $PREFIX = *[@:]* ]]; then + compset -P '*[@:]' _hosts else - _users + _users -S @ fi ;; + ignorepar) + _wanted values expl 'which parents to ignore' \ + compadd parent pwd .. directory + ;; + + single-ignored) + _wanted values expl 'how to handle a single ignored match' \ + compadd - show menu + ;; + _*) ${=ostate} ;; diff --git a/Completion/Commands/_complete_help b/Completion/Commands/_complete_help index cfefdcf90..cfc922df5 100644 --- a/Completion/Commands/_complete_help +++ b/Completion/Commands/_complete_help @@ -1,35 +1,80 @@ #compdef -k complete-word \C-xh _complete_help() { - local _sort_tags=_help_sort_tags text i - typeset -A help_tags - typeset -U help_contexts - - help_contexts=() + local _sort_tags=_help_sort_tags text i j k + typeset -A help_funcs help_tags help_sfuncs help_styles compadd() { return 1 } + zstyle() { + local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}% *}" + + [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}" + + if [[ "$help_sfuncs[$2]" != *${_f}* || + "$help_styles[${2}${_f}]" != *${3}* ]]; then + [[ "$help_sfuncs[$2]" != *${_f}* ]] && + help_sfuncs[$2]="${help_sfuncs[$2]}:${_f}" + local _t + + case "$1" in + -s) _t='[string] ';; + -a) _t='[array] ';; + -h) _t='[assoc] ';; + *) _t='[boolean]';; + esac + help_styles[${2}${_f}]="${help_styles[${2}${_f}]},${_t} ${3}:${_f}" + fi + builtin zstyle "$@" + } _main_complete - unfunction compadd + unfunction compadd zstyle - for i in "$help_contexts[@]"; do + for i in "${(@ok)help_funcs}"; do text="${text} -tags in context \`${i}': ${help_tags[$i]}" +tags in context :completion:${i}:" + tmp=() + for j in "${(@s.:.)help_funcs[$i][2,-1]}"; do + tmp=( "$tmp[@]" "${(@s.,.)help_tags[${i}${j}][2,-1]}" ) + done + zformat -a tmp ' (' "$tmp[@]" + tmp=( ' + '${^tmp}')' ) + text="${text}${tmp}" done - compstate[list]=list - compstate[force_list]=yes + text="$text +" + for i in "${(@ok)help_sfuncs}"; do + text="${text} +styles in context ${i}" + tmp=() + for j in "${(@s.:.)help_sfuncs[$i][2,-1]}"; do + tmp=( "$tmp[@]" "${(@s.,.)help_styles[${i}${j}][2,-1]}" ) + done + zformat -a tmp ' (' "$tmp[@]" + tmp=( ' + '${^tmp}')' ) + text="${text}${tmp}" + done + + compstate[list]='list force' compstate[insert]='' compadd -UX "$text[2,-1]" -n '' } _help_sort_tags() { - help_contexts=( "$help_contexts[@]" "$curcontext" ) - help_tags[$curcontext]="${help_tags[$curcontext]} - ${argv}" - comptry "$@" + local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}% *}" + + if [[ "$help_funcs[$curcontext]" != *${f}* || + "$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then + [[ "$help_funcs[$curcontext]" != *${f}* ]] && + help_funcs[$curcontext]="${help_funcs[$curcontext]}:${f}" + help_tags[${curcontext}${f}]="${help_tags[${curcontext}${f}]},${argv}:${f}" + comptry "$@" + fi } _complete_help "$@" diff --git a/Completion/Commands/_history_complete_word b/Completion/Commands/_history_complete_word index fc67c0f14..d904e01f1 100644 --- a/Completion/Commands/_history_complete_word +++ b/Completion/Commands/_history_complete_word @@ -1,2 +1,105 @@ -#compdef -k complete-word \e/ -compgen -Q -H 0 '' +#compdef -K _history-complete-older complete-word \e/ _history-complete-newer complete-word \e, +# +# Complete words from the history +# +# by Adam Spiers, with help gratefully received from +# Sven Wischnowsky and Bart Schaefer +# +# Available styles: +# +# :history-words:list -- display lists of available matches +# :history-words:stop -- prevent looping at beginning and end of matches +# during menu-completion +# :history-words:sort -- sort matches lexically (default is to sort by age) +# :history-words:remove-all-dups -- +# remove /all/ duplicate matches rather than just +# consecutives +# + +_history_complete_word () { + local expl direction stop + + if [[ $WIDGET = *newer ]]; then + direction=newer + else + direction=older + fi + + zstyle -s ":completion:${curcontext}:history-words" stop stop + + zstyle -t ":completion:${curcontext}:history-words" list || compstate[list]='' + + if [[ -n "$compstate[old_list]" && + ( -n "$stop" || "$compstate[insert]" = menu ) ]] ; then + # array of matches is newest -> oldest (reverse of history order) + if [[ "$direction" == 'older' ]]; then + if [[ compstate[old_insert] -eq $_hist_menu_length || + "$_hist_stop" == 'oldest' ]]; then + _hist_stop='oldest' + [[ "$stop" = verbose ]] && + _message 'beginning of history reached' + elif [[ "$_hist_stop" == 'newest' ]]; then + zle -Rc + _history_complete_word_gen_matches + else + compstate[old_list]=keep + (( compstate[insert] = compstate[old_insert] + 1 )) + fi + elif [[ "$direction" == 'newer' ]]; then + if [[ compstate[old_insert] -eq 1 || "$_hist_stop" == 'newest' ]]; then + _hist_stop='newest' + [[ "$stop" = verbose ]] && _message 'end of history reached' + elif [[ "$_hist_stop" == 'oldest' ]]; then + zle -Rc + _history_complete_word_gen_matches + else + compstate[old_list]=keep + (( compstate[insert] = compstate[old_insert] - 1 )) + fi + fi + else + _hist_stop='' + _hist_old_prefix="$PREFIX" + _history_complete_word_gen_matches + fi + + [[ -n "$compstate[nmatches]" ]] +} + +_history_complete_word_gen_matches () { + local opt + + [[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix" + + if zstyle -t ":completion:${curcontext}:history-words" remove-all-dups; then + opt=- + else + opt=-1 + fi + if zstyle -t ":completion:${curcontext}:history-words" sort; then + opt="${opt}J" + else + opt="${opt}V" + fi + + _wanted "$opt" history-words expl 'history word' \ + compadd -Q - "$historywords[@]" + + zstyle -t ":completion:${curcontext}:history-words" list || + compstate[list]= + + _hist_menu_length="$compstate[nmatches]" + + case "$direction" in + newer) compstate[insert]=$_hist_menu_length + [[ -n "$_hist_stop" ]] && (( compstate[insert]-- )) + ;; + older) compstate[insert]=1 + [[ -n "$_hist_stop" ]] && (( compstate[insert]++ )) + ;; + esac + + [[ -n "$_hist_stop" ]] && _hist_stop='' +} + +_history_complete_word "$@" diff --git a/Completion/Commands/_next_tags b/Completion/Commands/_next_tags index 8bd3f5921..4861d1adf 100644 --- a/Completion/Commands/_next_tags +++ b/Completion/Commands/_next_tags @@ -1,70 +1,92 @@ #compdef -k complete-word \C-xn -# Main widget/completer. +# Main widget. _next_tags() { + local comp - if [[ $#funcstack -gt 1 ]]; then + if [[ -z $compstate[old_list] ]]; then + comp=() + else + comp=(_complete) + fi - # Called as completer, probably `remove' our helper function. A better - # test would be nice, but I think one should still be able to edit the - # current word between attempts to complete it. + (( $+_sort_tags )) || _next_tags_not= - [[ $_next_tags_pre != ${LBUFFER%${PREFIX}} ]] && unset _sort_tags + _sort_tags=_next_tags_sort + _next_tags_pre="${LBUFFER%${PREFIX}}" + _next_tags_not="$_next_tags_not $_lastcomp[tags]" - return 1 - else - local comp + _main_complete "$comp[@]" - if [[ -z $compstate[old_list] ]]; then - comp=() - else - comp=(_next_tags _complete) - fi + [[ $compstate[insert] = automenu ]] && + compstate[insert]=automenu-unambiguous + + compstate[insert]='' + compstate[list]='list force' - (( $+_sort_tags )) || _next_tags_not= + compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) +} - _sort_tags=_next_tags_sort - _next_tags_pre="${LBUFFER%${PREFIX}}" - _next_tags_not="$_next_tags_not $_lastcomp[tags]" +# Pre-completion function. - _main_complete "$comp[@]" +_next_tags_pre() { - [[ $compstate[insert] = automenu ]] && - compstate[insert]=automenu-unambiguous + # Probably `remove' our sort function. A better test would be nice, but + # I think one should still be able to edit the current word between + # attempts to complete it. - compstate[insert]='' - compstate[list]='list force' + if [[ $_next_tags_pre != ${LBUFFER%${PREFIX}} ]]; then + unset _sort_tags + else + compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) fi } # Helper function for sorting tags. Most of this is copied from _tags. _next_tags_sort() { - local order tags tag nodef + local order tags tag nodef tmp zstyle -a ":completion:${curcontext}:" tag-order order || - order=( 'arguments values' options globbed-files directories all-files ) + order=('arguments values' options) # But we also remove the tags we've already tried... - tags=( "${(@)order:#(${(j:|:)~${=_next_tags_not}})}" ) + tags=( "${(@)order:#(${(j:|:)~${=_next_tags_not}})(|:*)}" ) # ... unless that would remove all offered tags. - [[ $#tags -ne $#order && "$tags" != *(${(j:|:)~argv})* ]] && - tags=( $order ) _next_tags_not= - + if [[ $funcstack[4] = _files ]]; then + if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then + [[ "$tags" = *${${tmp[-1]##[^\\]:}%:*}* ]] && + tags=( $order ) _next_tags_not= + else + [[ "$tags" = *all-files* ]] && tags=( $order ) _next_tags_not= + fi + else + [[ $#tags -ne $#order && "$tags" != *(${(j:|:)~argv})* ]] && + tags=( $order ) _next_tags_not= + fi for tag in $tags; do case $tag in -) nodef=yes;; *\(\)) "${${tag%%[ ]#\(\)}##[ ]#}" "$@";; - \!*) comptry "${(@)argv:#(${(j:|:)~${=tag[2,-1]}})}";; - ?*) comptry ${=tag};; + \!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";; + ?*) comptry -m "$tag";; esac done - [[ -z "$nodef" ]] && comptry "$@" + if [[ -z "$nodef" ]]; then + if [[ $funcstack[4] = _files ]]; then + if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then + [[ "$argv" = *${${tmp[-1]##[^\\]:}%:*}* ]] && _next_tags_not= + else + [[ "$argv" = *all-files* ]] && _next_tags_not= + fi + fi + comptry "${(@)argv:#(${(j:|:)~${=_next_tags_not}})(|:*)}" + fi } [[ -o kshautoload ]] || _next_tags "$@" diff --git a/Completion/Core/_all_labels b/Completion/Core/_all_labels new file mode 100644 index 000000000..fa7118ec4 --- /dev/null +++ b/Completion/Core/_all_labels @@ -0,0 +1,44 @@ +#autoload + +local gopt=-J len tmp pre suf tloop ret=1 descr + +if [[ "$1" = -t ]]; then + tloop=yes + shift +fi +if [[ "$1" = -([12]|)[VJ] ]]; then + gopt="$1" + shift +fi + +tmp=${argv[(ib:4:)-]} +len=$# +if [[ tmp -lt len ]]; then + pre=$(( tmp-1 )) + suf=$tmp +elif [[ tmp -eq $# ]]; then + pre=-2 + suf=$(( len+1 )) +else + pre=4 + suf=5 +fi + +while [[ -z "$tloop" ]] || comptags -N; do + while comptags -A "$1" curtag; do + if [[ "$curtag" = *:* ]]; then + zformat -f descr "${curtag#*:}" "d:$3" + _description "$gopt" "${curtag%:*}" "$2" "$descr" + curtag="${curtag%:*}" + + "$4" "${(P@)2}" "${(@)argv[5,-1]}" + else + _description "$gopt" "$curtag" "$2" "$3" + + "${(@)argv[4,pre]}" "${(P@)2}" "${(@)argv[suf,-1]}" && ret=0 + fi + done + [[ -z "$tloop" || ret -eq 0 ]] && break +done + +return ret diff --git a/Completion/Core/_alternative b/Completion/Core/_alternative index 158f3a07a..b038aa8a4 100644 --- a/Completion/Core/_alternative +++ b/Completion/Core/_alternative @@ -1,19 +1,23 @@ #autoload -local tags def expl descr action mesgs nm="$compstack[nmatches]" -local context +local tags def expl descr action mesgs nm="$compstate[nmatches]" subopts +local opt curcontext="$curcontext" + +subopts=() +while getopts 'O:C:' opt; do + case "$opt" in + O) subopts=( "${(@P)OPTARG}" ) ;; + C) curcontext="${curcontext%:*}:$OPTARG" ;; + esac +done + +shift OPTIND-1 -if [[ "$1" = -C?* ]]; then - context="${1[3,-1]}" - shift -elif [[ "$1" = -C ]]; then - context="$2" - shift 2 -fi +[[ "$1" = -(|-) ]] && shift mesgs=() -_tags -C "$context" "${(@)argv%%:*}" +_tags "${(@)argv%%:*}" while _tags; do for def; do @@ -21,7 +25,7 @@ while _tags; do descr="${${def#*:}%%:*}" action="${def#*:*:}" - _description expl "$descr" + _description "${def%%:*}" expl "$descr" if [[ "$action" = \ # ]]; then @@ -35,28 +39,35 @@ while _tags; do eval ws\=\( "${action[3,-3]}" \) - _describe "$descr" ws -M 'r:|[_-]=* r:|=*' + _describe "$descr" ws -M 'r:|[_-]=* r:|=*' "$subopts[@]" elif [[ "$action" = \(*\) ]]; then # Anything inside `(...)' is added directly. - compadd "$expl[@]" - ${=action[2,-2]} + _all_labels "${def%%:*}" expl "$descr" \ + compadd "$subopts[@]" - ${=action[2,-2]} elif [[ "$action" = \{*\} ]]; then # A string in braces is evaluated. - eval "$action[2,-2]" + while _next_label "${def%%:*}" expl "$descr"; do + eval "$action[2,-2]" + done elif [[ "$action" = \ * ]]; then # If the action starts with a space, we just call it. - ${(e)=~action} + eval "action=( $action )" + while _next_label "${def%%:*}" expl "$descr"; do + "$action[@]" + done else # Otherwise we call it with the description-arguments built above. - action=( $=action ) - ${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]} + eval "action=( $action )" + _all_labels "${def%%:*}" expl "$descr" \ + "$action[1]" "$subopts[@]" "${(@)action[2,-1]}" fi fi done diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate index 1b40f7cbf..0815a308e 100644 --- a/Completion/Core/_approximate +++ b/Completion/Core/_approximate @@ -1,102 +1,30 @@ #autoload # This code will try to correct the string on the line based on the -# strings generated for the context if `compconfig[correct]' is set. -# These corrected strings will be shown in a list and one can -# cycle through them as in a menucompletion or get the corrected prefix. -# -# Supported configuration keys: -# -# approximate_accept -# This should be set to a number, specifying the maximum number -# of errors that should be accepted. If the string also contains -# a `n' or `N', the code will use the numeric argument as the -# maximum number of errors if a numeric argument was given. If no -# numeric argument was given, the number from the value of this -# key will be used. E.g. with `compconf approximate_accept=2n' two -# errors will be accepted, but if the user gives another number -# with the numeric argument, this will be prefered. Also, with -# `compconf approximate_accept=0n', normally no correction will be -# tried, but if a numeric argument is given, automatic correction -# will be used. On the other hand, if the string contains an `!' -# and a `n' or `N', correction is not attempted if a numeric -# argument is given. Once the number of errors to accept is -# determined, the code will repeatedly try to generate matches by -# allowing one error, two errors, and so on. Independent of the -# number of errors the user wants to accept, the code will allow -# only fewer errors than there are characters in the string from -# the line. -# -# approximate_original -# This value is used to determine if the original string should -# be included in the list (and thus be presented to the user when -# cycling through the corrections). If it is set to any non-empty -# value, the original string will be offered. If it contains the -# sub-string `last', the original string will appear as the last -# string when cycling through the corrections, otherwise it will -# appear as the first one (so that the command line does not -# change immediately). Also, if the value contains the sub-string -# `always', the original string will always be included, whereas -# normally it is included only if more than one possible -# correction was generated. -# -# approximate_prompt -# This can be set to a string that should be printed before the -# list of corrected strings when cycling through them. This string -# may contain the control sequences `%n', `%B', etc. known from -# the `-X' option of `compctl'. Also, the sequence `%e' will be -# replaced by the number of errors accepted to generate the -# corrected strings. -# -# approximate_insert -# If this is set to a string starting with `unambig', the code -# will try to insert a usable unambiguous string in the command -# line instead of always cycling through the corrected strings. -# If such a unambiguous string could be found, the original -# string is not used, independent of the setting of -# `approximate_original'. If no sensible string could be found, -# one can cycle through the corrected strings as usual. -# -# If any of these keys is not set, but the the same key with the -# prefix `correct' instead of `approximate' is set, that value will -# be used. - -local _comp_correct _correct_prompt comax -local cfgacc cfgorig cfgps cfgins - -# Only if all global matchers hav been tried. - -[[ compstate[matcher] -ne compstate[total_matchers] ]] && return 1 - -# We don't try correction if the string is too short. - -[[ "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1 - -# Get the configuration values, using either the prefix `correct' or -# `approximate'. - -if [[ "$compstate[pattern_match]" = (|\**) ]]; then - cfgacc="${compconfig[approximate_accept]:-$compconfig[correct_accept]}" - cfgorig="${compconfig[approximate_original]:-$compconfig[correct_original]}" - cfgps="${compconfig[approximate_prompt]:-$compconfig[correct_prompt]}" - cfgins="${compconfig[approximate_insert]:-$compconfig[correct_insert]}" -else - cfgacc="$compconfig[correct_accept]" - cfgorig="$compconfig[correct_original]" - cfgps="$compconfig[correct_prompt]" - cfgins="$compconfig[correct_insert]" -fi +# strings generated for the context. These corrected strings will be +# shown in a list and one can cycle through them as in a menucompletion +# or get the corrected prefix. + +# We don't try correction if the string is too short or we have tried it +# already. + +[[ _matcher_num -gt 1 || "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1 + +local _comp_correct _correct_expl comax cfgacc +local oldcontext="${curcontext}" opm="$compstate[pattern_match]" + +zstyle -s ":completion:${curcontext}:" max-errors cfgacc || cfgacc='2 numeric' # Get the number of errors to accept. -if [[ "$cfgacc" = *[nN]* && NUMERIC -ne 1 ]]; then - # Stop if we also have a `!'. +if [[ "$cfgacc" = *numeric* && ${NUMERIC:-1} -ne 1 ]]; then + # A numeric argument may mean that we should not try correction. - [[ "$cfgacc" = *\!* ]] && return 1 + [[ "$cfgacc" = *not-numeric* ]] && return 1 # Prefer the numeric argument if that has a sensible value. - comax="$NUMERIC" + comax="${NUMERIC:-1}" else comax="${cfgacc//[^0-9]}" fi @@ -105,13 +33,15 @@ fi [[ "$comax" -lt 1 ]] && return 1 -# Otherwise temporarily define functions to use instead of -# the builtins that add matches. This is used to be able -# to stick the `(#a...)' into the right place (after an +_tags corrections original + +# Otherwise temporarily define a function to use instead of +# the builtin that adds matches. This is used to be able +# to stick the `(#a...)' in the right place (after an # ignored prefix). compadd() { - [[ "$*" != *-([a-zA-Z/]#|)U* && + [[ ${argv[(I)-[a-zA-Z]#U[a-zA-Z]#]} -eq 0 && "${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return if [[ "$PREFIX" = \~*/* ]]; then @@ -119,79 +49,49 @@ compadd() { else PREFIX="(#a${_comp_correct})$PREFIX" fi - if [[ -n "$_correct_prompt" ]]; then - builtin compadd -X "$_correct_prompt" -J _correct "$@" - else - builtin compadd -J _correct "$@" - fi + builtin compadd "$_correct_expl[@]" "$@" } -compgen() { - [[ "$*" != *-([a-zA-Z/]#|)U* && - "${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return - - if [[ "$PREFIX" = \~*/* ]]; then - PREFIX="${PREFIX%%/*}/(#a${_comp_correct})${PREFIX#*/}" - else - PREFIX="(#a${_comp_correct})$PREFIX" - fi - if [[ -n "$_correct_prompt" ]]; then - builtin compgen "$@" -X "$_correct_prompt" -J _correct - else - builtin compgen "$@" -J _correct - fi -} - -# Now initialise our counter. We also set `compstate[matcher]' -# to `-1'. This allows completion functions to use the simple -# `[[ compstate[matcher] -gt 1 ]] && return' to avoid being -# called for multiple global match specs and still be called -# again when correction is done. Also, this makes it easy to -# test if correction is attempted since `compstate[matcher]' -# will never be set to a negative value by the completion code. - _comp_correct=1 -compstate[matcher]=-1 - -_correct_prompt="${cfgps//\%e/1}" - -# We also need to set `extendedglob' and make the completion -# code behave as if globcomplete were set. - -setopt extendedglob [[ -z "$compstate[pattern_match]" ]] && compstate[pattern_match]='*' while [[ _comp_correct -le comax ]]; do + curcontext="${oldcontext/(#b)([^:]#:[^:]#:)/${match[1][1,-2]}-${_comp_correct}:}" + + _description corrections _correct_expl corrections \ + "e:$_comp_correct" "o:$PREFIX$SUFFIX" + if _complete; then - if [[ "$cfgins" = unambig* && - "${#compstate[unambiguous]}" -ge "${#:-$PREFIX$SUFFIX}" ]]; then + if zstyle -t ":completion:${curcontext}:" insert-unambiguous && + [[ "${#compstate[unambiguous]}" -ge "${#:-$PREFIX$SUFFIX}" ]]; then compstate[pattern_insert]=unambiguous - elif [[ compstate[nmatches] -gt 1 || "$cfgorig" = *always* ]]; then - if [[ "$cfgorig" = *last* ]]; then - builtin compadd -U -V _correct_original -nQ - "$PREFIX$SUFFIX" - elif [[ -n "$cfgorig" ]]; then - builtin compadd -U -nQ - "$PREFIX$SUFFIX" - fi + elif _requested original && + { [[ compstate[nmatches] -gt 1 ]] || + zstyle -t ":completion:${curcontext}:" original }; then + local expl + + _description -V original expl original + + builtin compadd "$expl[@]" -U -Q - "$PREFIX$SUFFIX" # If you always want to see the list of possible corrections, - # set `compstate[list]=list' here. + # set `compstate[list]=list force' here. - compstate[force_list]=list + [[ "$compstate[list]" != list* ]] && + compstate[list]="$compstate[list] force" fi - compstate[matcher]="$compstate[total_matchers]" - unfunction compadd compgen + unfunction compadd + compstate[pattern_match]="$opm" return 0 fi [[ "${#:-$PREFIX$SUFFIX}" -le _comp_correct+1 ]] && break (( _comp_correct++ )) - - _correct_prompt="${cfgps//\%e/$_comp_correct}" done -compstate[matcher]="$compstate[total_matchers]" -unfunction compadd compgen +unfunction compadd +compstate[pattern_match]="$opm" return 1 diff --git a/Completion/Core/_call b/Completion/Core/_call index 345dae50d..b038a80bc 100644 --- a/Completion/Core/_call +++ b/Completion/Core/_call @@ -1,4 +1,4 @@ -#autoload +#autoload +X local tmp diff --git a/Completion/Core/_complete b/Completion/Core/_complete index 0f4d5ff4b..c2679dcb8 100644 --- a/Completion/Core/_complete +++ b/Completion/Core/_complete @@ -2,51 +2,65 @@ # Generate all possible completions. Note that this is not intended as # a normal completion function, but as one possible value for the -# compconfig[completer] parameter. +# completer style. -local comp name +local comp name oldcontext +typeset -T curcontext="$curcontext" ccarray + +oldcontext="$curcontext" + +# If we have a user-supplied context name, use only that. + +if [[ -n "$compcontext" ]]; then + ccarray[3]="$compcontext" + + comp="$_comps[$compcontext]" + [[ -z "$comp" ]] || "$comp" + + return +fi # An entry for `-first-' is the replacement for `compctl -T' -# Completion functions may set `_compskip' to any value to make the -# main loops stop calling other completion functions. comp="$_comps[-first-]" if [[ ! -z "$comp" ]]; then + ccarray[3]=-first- "$comp" - if (( $+_compskip )); then - unset _compskip + if [[ "$_compskip" = all ]]; then + _compskip='' (( compstate[nmatches] )) return fi fi + # For arguments and command names we use the `_normal' function. if [[ "$compstate[context]" = command ]]; then - _normal + curcontext="$oldcontext" + _normal -s else # Let's see if we have a special completion definition for the other # possible contexts. - comp='' - - case $compstate[context] in - equal) comp="$_comps[-equal-]";; - tilde) comp="$_comps[-tilde-]";; - redirect) comp="$_comps[-redirect-]";; - math) comp="$_comps[-math-]";; - subscript) comp="$_comps[-subscript-]";; - value) comp="$_comps[-value-]";; - array_value) comp="$_comps[-array-value-]";; - condition) comp="$_comps[-condition-]";; - parameter) comp="$_comps[-parameter-]";; - brace_parameter) comp="$_comps[-brace-parameter-]";; - esac + local cname="-${compstate[context]:s/_/-/}-" + + ccarray[3]="$cname" + + comp="$_comps[$cname]" # If not, we use default completion, if any. - [[ -z "$comp" ]] && comp="$_comps[-default-]" + if [[ -z "$comp" ]]; then + if [[ "$_compskip" = *default* ]]; then + _compskip='' + return 1 + fi + comp="$_comps[-default-]" + fi [[ -z "$comp" ]] || "$comp" fi +_compskip='' + (( compstate[nmatches] )) diff --git a/Completion/Core/_correct b/Completion/Core/_correct index 35ab01cf1..c9c3d999c 100644 --- a/Completion/Core/_correct +++ b/Completion/Core/_correct @@ -1,8 +1,8 @@ #autoload -# This is mainly a wrapper around the more general `_approximate. +# This is mainly a wrapper around the more general `_approximate'. # By setting `compstate[pattern_match]' to something unequal to `*' and -# then calling `_approximate, we get only corrections, not all strings +# then calling `_approximate', we get only corrections, not all strings # with the corrected prefix and something after it. # # Supported configuration keys are the same as for `_approximate', only diff --git a/Completion/Core/_description b/Completion/Core/_description index 874ba8a96..7db47228b 100644 --- a/Completion/Core/_description +++ b/Completion/Core/_description @@ -1,22 +1,56 @@ #autoload -local gropt=-J +local name gropt=-J format gname hidden hide match opts -if [[ "$1" = -V ]]; then - gropt=-V +opts=() + +if [[ "$1" = -([12]|)[VJ] ]]; then + gropt="$1" shift fi -if [[ -n "$compconfig[group_matches]" ]]; then - if [[ -n "$compconfig[description_format]" ]]; then - eval "$1=($gropt ${(q)2} -X ${(q)compconfig[description_format]//\\%d/$2})" +_lastdescr=( "$_lastdescr[@]" "$3" ) + +_setup "$1" + +name="$2" + +zstyle -s ":completion:${curcontext}:$1" format format || + zstyle -s ":completion:${curcontext}:descriptions" format format + +zstyle -s ":completion:${curcontext}:$1" hidden hidden +if [[ "$hidden" = (all|yes|true|1|on) ]]; then + [[ "$hidden" = all ]] && format='' + opts=(-n) +fi +zstyle -s ":completion:${curcontext}:$1" group-name gname && + [[ -z "$gname" ]] && gname="$1" +zstyle -s ":completion:${curcontext}:$1" matcher match && + opts=($opts -M "${(q)match}") +[[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}") + +if [[ -z "$_comp_no_ignore" ]] && + zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then + opts=( $opts -F _comp_ignore ) +else + _comp_ignore=() +fi + +shift 2 +[[ -n "$format" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}" + +if [[ -n "$gname" ]]; then + if [[ -n "$format" ]]; then + eval "${name}=($opts $gropt ${(q)gname} -X \"${format}\")" else - eval "$1=($gropt ${(q)2})" + eval "${name}=($opts $gropt ${(q)gname})" fi else - if [[ -n "$compconfig[description_format]" ]]; then - eval "$1=(-X ${(q)compconfig[description_format]//\\%d/$2})" + if [[ -n "$format" ]]; then + eval "${name}=($opts $gropt -default- -X \"${format}\")" else - eval "$1=()" + eval "${name}=($opts $gropt -default-)" fi fi + +return 0 diff --git a/Completion/Core/_expand b/Completion/Core/_expand index 9172b6cbf..eff8d8601 100644 --- a/Completion/Core/_expand +++ b/Completion/Core/_expand @@ -6,61 +6,20 @@ # This function will allow other completer functions to be called if # the expansions done produce no result or do not change the original # word from the line. -# -# Configuration keys: -# -# expand_substitute -# If this is unset or set to the empty string, the code will first -# try to expand all substitutions in the string (such as $(...) and -# ${...}). If this is set to an non-empty string it should be -# an expression usable inside a $[...] arithmetical expression. -# In this case, expansion of substitutions will be done if the -# expression evaluates to `1'. For example, with -# -# compconf expand_substitute='NUMERIC != 1' -# -# substitution will be performed only if given an explicit numeric -# argument other than `1', as by typing ESC 2 TAB. -# -# expand_glob -# If this is unset or set to an empty string, globbing will be -# attempted on the word resulting from substitution or the -# original string. The values accepted for this key are the same -# as for expand_substitute. -# -# expand_menu -# If this is unset or set to the empty string, the words resulting -# from expansion (if any) will simply be inserted in the ommand line, -# replacing the original string. However, if this key is set to an -# non-empty string, the user can cycle through the expansion as in -# a menucompletion. Unless the value contains the sub-string `only', -# the user will still be offered all expansions at once as one of -# the strings to insert in the command line. Also, if the value -# contains the sub-string `last', the string with all expansion will -# be offered first, whereas normally it is offered as the last string -# to insert. Finally, if the value contains the sub-string `sort', -# the expansions will be sorted alphabetically, normally they are -# kept in the order the expansion produced them in. -# -# expand_original -# If this is set to an non-empty string, the original string from the -# line will be included in the list of strings the user can cycle -# through as in a menucompletion. If the value contains the sub-string -# `last', the original string will appear as the last string, with -# other values it is inserted as the first one (so that the command -# line does not change immediatly). -# -# expand_prompt -# This may be set to a string that should be displayed before the -# possible expansions. This is given to the -X option and thus may -# contain the control sequences `%n', `%B', etc. Also, the sequence -# `%o' in this string will be replaced by the original string. - -local exp word="$PREFIX$SUFFIX" group=-V - -# Do this only for the first global matcher. - -[[ "$compstate[matcher]" -le 1 ]] || return 1 + +setopt localoptions nullglob + +[[ _matcher_num -gt 1 ]] && return 1 + +local exp word="$PREFIX$SUFFIX" sort expr expl subd suf=" " + +# First, see if we should insert all *completions*. + +if zstyle -s ":completion:${curcontext}:" completions expr && + [[ "${(e):-\$[$expr]}" -eq 1 ]]; then + compstate[insert]=all + return 1 +fi # In exp we will collect the expansion. @@ -69,79 +28,68 @@ exp=("$word") # First try substitution. That weird thing spanning multiple lines # changes quoted spaces, tabs, and newlines into spaces. -[[ -z "$compconfig[expand_substitute]" || - "${(e):-\$[$compconfig[expand_substitute]]}" -eq 1 ]] && +zstyle -s ":completion:${curcontext}:" substitute expr && + [[ "${(e):-\$[$expr]}" -eq 1 ]] && exp=( "${(e)exp//\\[ ]/ }" ) # If the array is empty, store the original string again. -[[ -z "$exp" ]] && exp=("$word") +(( $#exp )) || exp=("$word") + +subd=("$exp[@]") # Now try globbing. -[[ -z "$compconfig[expand_glob]" || - "${(e):-\$[$compconfig[expand_glob]]}" -eq 1 ]] && - exp=( ${~exp}(N) ) +zstyle -s ":completion:${curcontext}:" glob expr && + [[ "${(e):-\$[$expr]}" -eq 1 ]] && + exp=( ${~exp} ) # If we don't have any expansions or only one and that is the same # as the original string, we let other completers run. -[[ $#exp -eq 0 || - ( $#exp -eq 1 && "$exp[1]" = "$word" ) ]] && return 1 +(( $#exp )) || exp=("$subd[@]") -# We have expansions, should we menucomplete them? +[[ $#exp -eq 1 && "$exp[1]" = "$word"(|\(N\)) ]] && return 1 -if [[ -z "$compconfig[expand_menu]" ]]; then +# With subst-globs-only we bail out if there were no glob expansions, +# regardless of any substitutions - # No, so if the user only wants a list, we add the strings - # separately. Otherwise we add the whole array as one string, - # probably also adding the original string. +zstyle -s ":completion:${curcontext}:" subst-globs-only expr && + [[ "${(e):-\$[$expr]}" -eq 1 && "$subd" = "$exp"(|\(N\)) ]] && return 1 - if [[ -z "$compstate[insert]" ]]; then - compadd -U -V _expand -Q - "$exp[@]" - else - [[ -n "$compconfig[expand_original]" && - "$compconfig[expand_original]" != *last* ]] && - compadd -UnQ -V _expand_original - "$word" +# Now add as matches whatever the user requested. - compadd -UQ -V _expand - "$exp" +zstyle -s ":completion:${curcontext}:" sort sort - [[ -n "$compconfig[expand_original]" && - "$compconfig[expand_original]" = *last* ]] && - compadd -UnQ -V _expand_original - "$word" +[[ "$sort" = (yes|true|1|on) ]] && exp=( "${(@o)exp}" ) - compstate[insert]=menu - fi -else - # Sorting? We just use a different group type then. +# If there is only one expansion, add a suitable suffix +(($#exp == 1)) && suf='' && [[ -d $exp && "$exp[1]" != */ ]] && suf='/' - [[ "$compconfig[expand_menu]" = *sort* ]] && group=-J +if [[ -z "$compstate[insert]" ]] ;then + _description all-expansions expl 'all expansions' "o:$word" - # Now add the expansion string, probably also adding the original - # and/or the string containing all expanded string. + compadd "$expl[@]" -UQ -qS "$suf" - "$exp" +else + _tags all-expansions expansions original - [[ -n "$compconfig[expand_original]" && - "$compconfig[expand_original]" != *last* ]] && - compadd -UnQ -V _expand_original - "$word" - [[ "$compconfig[expand_menu]" = *last* && - "$compconfig[expand_menu]" != *only* ]] && - compadd -UnQ -V _expand_all - "$exp" + if _requested all-expansions; then + _description all-expansions expl 'all expansions' + compadd "$expl[@]" -UQ -qS "$suf" - "$exp" + fi - if [[ -z "$compconfig[expand_prompt]" ]]; then - compadd -UQ $group _expand - "$exp[@]" - else - compadd -UQ -X "${compconfig[expand_prompt]//\%o/$word}" \ - $group _expand - "$exp[@]" + if [[ $#exp -gt 1 ]] && _requested expansions; then + if [[ "$sort" = menu ]]; then + _description expansions expl expansions "o:$word" + else + _description -V expansions expl expansions "o:$word" + fi + compadd "$expl[@]" -UQ - "$exp[@]" fi - [[ "$compconfig[expand_menu]" != *last* && - "$compconfig[expand_menu]" != *only* ]] && - compadd -UnQ -V _expand_all - "$exp" - [[ -n "$compconfig[expand_original]" && - "$compconfig[expand_original]" = *last* ]] && - compadd -UnQ -V _expand_original - "$word" + _requested original expl original && compadd "$expl[@]" -UQ - "$word" compstate[insert]=menu fi diff --git a/Completion/Core/_files b/Completion/Core/_files index d2cce35e7..1755abebd 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -1,26 +1,49 @@ #autoload -# Utility function for completing files of a given type or any file. -# In many cases you will want to call this one instead of _path_files(). +local opts tmp glob pats expl tag i pat descr minus -local nm=$NMATCHES +zparseopts -a opts \ + '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+: -_path_files "$@" +type="${(@j::M)${(@)tmp#-}#?}" +(( $tmp[(I)-g*] )) && glob="${(j: :)${(M)tmp:#-g*}#-g}" -if [[ $# -ne 0 && -nmatches nm ]]; then - local opt opts +if zstyle -a ":completion:${curcontext}:" file-patterns pats; then + [[ "$type" = */* ]] && glob="$glob *(-/)" + pats=( \ ${(M)^${pats//\\%p/ ${glob:-\*} }:#*[^\\]:*} ) +else + if [[ "$type" = *g* ]]; then + if [[ "$type" = */* ]]; then + pats=( " ${glob//:/\\:} *(-/):globbed-files" '*:all-files' ) + else + pats=( " ${glob//:/\\:}:globbed-files" + '*(-/):directories' '*:all-files' ) + fi + elif [[ "$type" = */* ]]; then + pats=( '*(-/):directories' '*:all-files' ) + else + pats=( '*:all-files' ) + fi +fi - # We didn't get any matches for those types of files described by - # the `-g' or `-/' option. Now we try it again accepting all files. - # First we get those options that we have to use even if then. If - # we find out that the `-f' option was given, we already accepted - # all files and give up immediatly. +for tag in "${(@)${(@)pats#*[^\\]:}%%:*}"; do - opts=() - while getopts "P:S:W:F:J:V:X:f/g:" opt; do - [[ "$opt" = f ]] && return - [[ "$opt" = [PSWFJVX] ]] && opts=("$opts[@]" "-$opt" "$OPTARG") - done + i="$pats[(I)*[^\\\\]:${tag}(|:*)]" + pat="${${pats[i]%%:${tag}*}//\\\\:/:}" - _path_files "$opts[@]" -fi + if [[ i -gt 0 && "$pat" != \ # ]]; then + if [[ "$pats[i]" = *:${tag}:* ]]; then + descr="${pats[i]#*:${tag}:}" + minus=() + else + descr=file + minus=(-) + fi + fi + + _wanted "$tag" expl "$descr" \ + _path_files -g "$pat" "$opts[@]" "$minus[@]" && return 0 + +done + +return 1 diff --git a/Completion/Core/_ignored b/Completion/Core/_ignored index 69a5244cc..4046f4c2d 100644 --- a/Completion/Core/_ignored +++ b/Completion/Core/_ignored @@ -4,11 +4,10 @@ (( $compstate[ignored] )) || return 1 -local curcontext="${curcontext/:[^:]#:/:ignored-${(M)#_completers[1,_completer_num]:#_ignored}:}" local comp i _comp_no_ignore=yes tmp expl zstyle -a ":completion:${curcontext}:" completer comp || - comp=( "${(@)_completers[1,_completer_num-1][(R)_ignored,-1]}" ) + comp=( "${(@)_completers[1,_completer_num-1][(R)_ignored(|:*),-1]}" ) for i in "$comp[@]"; do if [[ "$i" != _ignored ]] && "$i"; then diff --git a/Completion/Core/_list b/Completion/Core/_list index 099c6bc7b..37167726c 100644 --- a/Completion/Core/_list +++ b/Completion/Core/_list @@ -1,38 +1,16 @@ #autoload # This completer function makes the other completer functions used -# insert possible completions only after once the list has been -# shown. -# -# Configuration keys: -# -# list_condition -# If this key is unset or set to the empty string, this completer -# will delay the insertion of matches unconditionally. However, -# if this value is set, it should be set to an expression usable -# inside a $[...] arithmetical expression. In this case, delaying -# will be done if the expression evaluates to `1'. -# For example, with -# -# compconf list_condition='NUMERIC != 1' -# -# delaying will be done only if given an explicit numeric argument -# other than `1'. -# -# list_word -# To find out if only listing should be done, the code normally -# compares the contents of the line with the contents the line -# had at the time of the last invocation. If this key is set to -# an non-empty string comparison is done using only the current -# word. So if it is set, attempting completion on a word equal -# to the one completion was called on the last time will not -# delay the generation of matches. - -local pre suf +# insert possible completions only after the list has been shown at +# least once. + +[[ _matcher_num -gt 1 ]] && return 1 + +local pre suf expr # Get the strings to compare. -if [[ -z "$compconfig[list_word]" ]]; then +if zstyle -t ":completion:${curcontext}:" word; then pre="$HISTNO$LBUFFER" suf="$RBUFFER" else @@ -42,16 +20,15 @@ fi # Should we only show a list now? -if [[ ( -z "$compconfig[list_condition]" || - "${(e):-\$[$compconfig[expand_glob]]}" -eq 1 ) && +zstyle -s ":completion:${curcontext}:" condition expr +if [[ ( -z "$expr" || "${(e):-\$[$expr]}" -eq 1 ) && ( "$pre" != "$_list_prefix" || "$suf" != "$_list_suffix" ) ]]; then # Yes. Tell the completion code about it and save the new values # to compare the next time. compstate[insert]='' - compstate[list]=list - compstate[force_list]=yes + compstate[list]='list force' _list_prefix="$pre" _list_suffix="$suf" fi diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index c7f5a5a96..d9278f435 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -2,47 +2,206 @@ # The main loop of the completion code. This is what is called when # completion is attempted from the command line. -# The completion code gives us the special variables and the arguments -# from the command line are given as positional parameters. -local comp name -setopt localoptions nullglob rcexpandparam globdots -unsetopt markdirs globsubst shwordsplit nounset +# If you want to complete only set or unset options for the unsetopt +# and setopt builtin, un-comment these lines: +# +# local _set_options _unset_options +# +# _set_options=(${(k)options[(R)on]}) +# _unset_options=(${(k)options[(R)off]}) +# +# This is needed because completion functions may set options locally +# which makes the output of setopt and unsetopt reflect a different +# state than the global one for which you are completing. -# An entry for `-first-' is the replacement for `compctl -T' -# Completion functions may set `_compskip' to any value to make the -# main loops stop calling other completion functions. +setopt localoptions nullglob rcexpandparam extendedglob +unsetopt markdirs globsubst shwordsplit nounset ksharrays -comp="$_comps[-first-]" -if [[ ! -z "$comp" ]]; then - "$comp" "$@" - if (( $+_compskip )); then - unset _compskip - return - fi +local func funcs ret=1 tmp _compskip format _comp_ignore \ + _completers _completer _completer_num curtag \ + _matchers _matcher _matcher_num _comp_tags \ + context state line opt_args val_args curcontext="$curcontext" \ + _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \ + _saved_exact="${compstate[exact]}" \ + _saved_lastprompt="${compstate[last_prompt]}" \ + _saved_list="${compstate[list]}" \ + _saved_insert="${compstate[insert]}" + +typeset -U _lastdescr + +[[ -z "$curcontext" ]] && curcontext=::: + +# Special completion contexts after `~' and `='. + +if compset -P 1 '='; then + compstate[context]=equal +elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then + compset -p 1 + compstate[context]=tilde fi -# For arguments we use the `_normal function. +# Initial setup. + +_setup default +_def_menu_style=( "$_last_menu_style[@]" + +# We can't really do that because the current value of $SELECTMIN +# may be the one set by this function. +# There is a similar problem with $ZLS_COLORS in _setup. + +# ${SELECTMIN+select${SELECTMIN:+\=$SELECTMIN}} + + ) +_last_menu_style=() -if [[ $CONTEXT == argument || $CONTEXT == command ]]; then - _normal "$@" +# Get the names of the completers to use in the positional parameters. + +if (( $# )); then + _completers=( "$@" ) else - # Let's see if we have a special completion definition for the other - # possible contexts. + zstyle -a ":completion:${curcontext}:" completer _completers || + _completers=( _complete ) +fi + +# And now just call the completer functions defined. + +_completer_num=1 + +# Call the pre-functions. + +funcs=( "$compprefuncs[@]" ) +compprefuncs=() +for func in "$funcs[@]"; do + "$func" +done + +for tmp in "$_completers[@]"; do + + if [[ "$tmp" = *:-* ]]; then + _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}" + tmp="${tmp%:*}" + elif [[ $tmp = *:* ]]; then + _completer="${tmp#*:}" + tmp="${tmp%:*}" + else + _completer="${tmp[2,-1]//_/-}" + fi + curcontext="${curcontext/:[^:]#:/:${_completer}:}" - comp='' + zstyle -a ":completion:${curcontext}:" matcher-list _matchers || + _matchers=( '' ) - case $CONTEXT in - redirect) comp="$_comps[-redirect-]";; - math) comp="$_comps[-math-]";; - subscript) comp="$_comps[-subscript-]";; - value) comp="$_comps[-value-]";; - condition) comp="$_comps[-condition-]";; - esac + _matcher_num=1 + for _matcher in "$_matchers[@]"; do + if "$tmp"; then + ret=0 + break 2 + fi + (( _matcher_num++ )) + done + (( _completer_num++ )) +done - # If not, we use default completion, if any. +curcontext="${curcontext/:[^:]#:/::}" - [[ -z "$comp" ]] && comp="$_comps[-default-]" - [[ -z "$comp" ]] || "$comp" "$@" +if [[ $compstate[old_list] = keep || $compstate[nmatches] -gt 1 ]]; then + [[ _last_nmatches -ge 0 && _last_nmatches -ne $compstate[nmatches] ]] && + _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" ) + + if [[ "$compstate[insert]" = "$_saved_insert" ]]; then + if [[ -n "$_menu_style[(r)(yes|true|1|on)]" || + ( -n "$_menu_style[(r)auto*]" && + "$compstate[insert]" = automenu ) ]]; then + compstate[insert]=menu + elif [[ -n "$_menu_style[(r)auto*]" && + "$compstate[insert]" != automenu ]]; then + compstate[insert]=automenu-unambiguous + elif [[ -n "$_menu_style[(r)(no|false|0|off)]" ]]; then + compstate[insert]=unambiguous + elif [[ -n "$_def_menu_style[(r)(yes|true|1|on)]" || + ( -n "$_def_menu_style[(r)auto*]" && + "$compstate[insert]" = automenu ) ]]; then + compstate[insert]=menu + elif [[ -n "$_def_menu_style[(r)auto*]" && + "$compstate[insert]" != automenu ]]; then + compstate[insert]=automenu-unambiguous + elif [[ -n "$_def_menu_style[(r)(no|false|0|off)]" ]]; then + compstate[insert]=unambiguous + fi + fi + + _menu_style=( "$_menu_style[@]" "$_def_menu_style[@]" ) + + if [[ "$compstate[insert]" = *menu* ]]; then + if [[ -n "$_menu_style[(r)no-select*]" ]]; then + unset SELECTMIN + else + sel=( "${(@M)_menu_style:#select*}" ) + + if (( $# )); then + local min=9999999 i num + + for i in "$sel[@]"; do + if [[ "$i" = *\=* ]]; then + num="${i#*\=}" + [[ num -lt 0 ]] && num=0 + else + num=0 + fi + [[ num -lt min ]] && min="$num" + + (( min )) || break + done + + zmodload -i zsh/complist + SELECTMIN="$min" + fi + fi + fi +elif [[ $compstate[nmatches] -eq 0 && + $#_lastdescr -ne 0 && $compstate[old_list] != keep ]] && + zstyle -s ":completion:${curcontext}:warnings" format format; then + + compstate[list]='list force' + compstate[insert]='' + + if [[ "$format" = *%d* ]]; then + local str mesg + + _lastdescr=( "\`${(@)^_lastdescr:#}'" ) + + case $#_lastdescr in + 1) str="$_lastdescr[1]";; + 2) str="$_lastdescr[1] or $_lastdescr[2]";; + *) str="${(j:, :)_lastdescr[1,-2]}, or $_lastdescr[-1]";; + esac + + zformat -f mesg "$format" "d:$str" + compadd -UX "$mesg" -n - '' + else + _setup warnings + compadd -UQX "$format" -V warnings - "${(@)_lastdescr:#}" + fi fi + +# Now call the post-functions. + +funcs=( "$comppostfuncs[@]" ) +comppostfuncs=() +for func in "$funcs[@]"; do + "$func" +done + +_lastcomp=( "${(@kv)compstate}" ) +_lastcomp[completer]="$_completer" +_lastcomp[prefix]="$PREFIX" +_lastcomp[suffix]="$SUFFIX" +_lastcomp[iprefix]="$IPREFIX" +_lastcomp[isuffix]="$ISUFFIX" +_lastcomp[qiprefix]="$QIPREFIX" +_lastcomp[qisuffix]="$QISUFFIX" +_lastcomp[tags]="$_comp_tags" + +return ret diff --git a/Completion/Core/_match b/Completion/Core/_match index 3c639935c..18dab7423 100644 --- a/Completion/Core/_match +++ b/Completion/Core/_match @@ -1,53 +1,51 @@ #autoload # This is intended to be used as a completer function after the normal -# completer as in: `compconf completer=_complete:_match'. +# completer as in: `zstyle ":completion:::::" completer _complete _match'. # It temporarily switches on pattern matching, allowing you to try # completion on patterns without having to setopt glob_complete. # # Note, however, that this is only really useful if you don't use the # expand-or-complete function because otherwise the pattern will # be expanded using globbing. -# -# Configuration key used: -# -# match_original -# If this is set to a `only', pattern matching will only be tried -# with the string from the line. If it is set to any other non-empty -# string, the original pattern will be tried first and if that yields -# no completions, matching will be tried again with a `*' inserted -# at the cursor position. If this key is not set or set to an empty -# string, matching will only be attempted with the `*' inserted. -local tmp opm="$compstate[pattern_match]" ret=0 +[[ _matcher_num -gt 1 ]] && return 1 + +local tmp opm="$compstate[pattern_match]" ret=0 orig ins -# Do nothing if we don't have a pattern or there are still global -# match specifications to try. +# Do nothing if we don't have a pattern. tmp="${${:-$PREFIX$SUFFIX}#[~=]}" -[[ "$tmp:q" = "$tmp" || - compstate[matcher] -ne compstate[total_matchers] ]] && return 1 +[[ "$tmp:q" = "$tmp" ]] && return 1 + +zstyle -s ":completion:${curcontext}:" match-original orig +zstyle -b ":completion:${curcontext}:" insert-unambiguous ins # Try completion without inserting a `*'? -if [[ -n "$compconfig[match_original]" ]]; then - compstate[matcher]=-1 +if [[ -n "$orig" ]]; then compstate[pattern_match]='-' _complete && ret=1 compstate[pattern_match]="$opm" - compstate[matcher]="$compstate[total_matchers]" - (( ret )) && return 0 + if (( ret )); then + [[ "$ins" = yes && + $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && + compstate[pattern_insert]=unambiguous + return 0 + fi fi # No completion with inserting `*'? -[[ "$compconfig[match_original]" = only ]] && return 1 +[[ "$orig" = only ]] && return 1 -compstate[matcher]=-1 compstate[pattern_match]='*' _complete && ret=1 compstate[pattern_match]="$opm" -compstate[matcher]="$compstate[total_matchers]" + +[[ ret -eq 1 && "$ins" = yes && + $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && + compstate[pattern_insert]=unambiguous return 1-ret diff --git a/Completion/Core/_menu b/Completion/Core/_menu index 4cbda4e14..41fc178ba 100644 --- a/Completion/Core/_menu +++ b/Completion/Core/_menu @@ -1,10 +1,12 @@ #autoload +[[ _matcher_num -gt 1 ]] && return 1 + # This completer is an example showing how menucompletion can be # implemented with the new completion system. # Use this one before the normal _complete completer, as in: # -# compconf completer=_menu:_complete +# zstyle ":completion:::::" completer _menu _complete if [[ -n "$compstate[old_list]" ]]; then diff --git a/Completion/Core/_next_label b/Completion/Core/_next_label new file mode 100644 index 000000000..e309e53ea --- /dev/null +++ b/Completion/Core/_next_label @@ -0,0 +1,24 @@ +#autoload + +local gopt=-J descr + +if [[ "$1" = -([12]|)[VJ] ]]; then + gopt="$1" + shift +fi + +if comptags -A "$1" curtag; then + if [[ "$curtag" = *:* ]]; then + zformat -f descr "${curtag#*:}" "d:$3" + _description "$gopt" "${curtag%:*}" "$2" "$descr" + curtag="${curtag%:*}" + eval "${2}=( \${(P)2} \$argv[4,-1] )" + else + _description "$gopt" "$curtag" "$2" "$3" + eval "${2}=( \$argv[4,-1] \${(P)2} )" + fi + + return 0 +fi + +return 1 diff --git a/Completion/Core/_oldlist b/Completion/Core/_oldlist new file mode 100644 index 000000000..bcb3e148a --- /dev/null +++ b/Completion/Core/_oldlist @@ -0,0 +1,53 @@ +#autoload + +[[ _matcher_num -gt 1 ]] && return 1 + +local list + +zstyle -s ":completion:${curcontext}:" old-list list + +# If this is a listing widget and there is already an old list, +# and either the style :oldlist:old-list is `always', or it is not `never' +# and the list is not already shown, then use the existing list for listing +# (even if it was generated by another widget). +# Do this also if there is an old list and it was generated by the +# completer named by the oldlist_list key. + +if [[ -n $compstate[old_list] && $list != never ]]; then + if [[ $WIDGET = *list* && ( $list = always || $list != shown ) ]]; then + compstate[old_list]=keep + return 0 + elif [[ $list = *${_lastcomp[completer]}* ]]; then + [[ "$_lastcomp[insert]" = unambig* ]] && compstate[to_end]=single + compstate[old_list]=keep + if [[ -o automenu ]]; then + compstate[insert]=menu + else + compadd -Qs "$SUFFIX" - "$PREFIX" + fi + return 0 + fi +fi + +# If this is a completion widget, and we have a completion inserted already, +# and the style :oldlist:old-menu is `true', then we cycle through the +# existing list (even if it was generated by another widget). + +if [[ -z $compstate[old_insert] && -n $compstate[old_list] ]]; then + compstate[old_list]=keep +elif [[ $WIDGET = *complete(|-prefix|-word) ]] && + zstyle -t ":completion:${curcontext}:" old-menu; then + if [[ -n $compstate[old_insert] ]]; then + compstate[old_list]=keep + if [[ $WIDGET = *reverse* ]]; then + compstate[insert]=$(( compstate[old_insert] - 1 )) + else + compstate[insert]=$(( compstate[old_insert] + 1 )) + fi + else + return 1 + fi + return 0 +fi + +return 1 diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 83b6e8a09..ac4614dd8 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -1,85 +1,64 @@ #autoload -# Utility function for in-path completion. -# Supported arguments are: `-f', `-/', `-g <patterns>', `-J <group>', -# `-V <group>', `-W paths', `-X explanation', and `-F <ignore>'. All but -# the last have the same syntax and meaning as for `complist'. The -# `-F <ignore>' option may be used to give a list of suffixes either by -# giving the name of an array or literally by giving them in a string -# surrounded by parentheses. Files with one of the suffixes thus given -# are treated like files with one of the suffixes in the `fignore' array -# in normal completion. -# -# This function uses the helper functions `_match_test' and `_match_pattern'. +# Utility function for in-path completion. This allows `/u/l/b<TAB>' +# to complete to `/usr/local/bin'. -# First see if we should generate matches for the global matcher in use. +local linepath realpath donepath prepath testpath exppath skips skipped +local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre +local pats haspats=no ignore pfxsfx rem remt sopt gopt opt +local nm=$compstate[nmatches] menu matcher mopts atmp sort match -_match_test _path_files || return +typeset -U prepaths exppaths -# Yes, so... - -local nm prepaths str linepath realpath donepath patstr prepath testpath rest -local tmp1 collect tmp2 suffixes i ignore matchflags opt group sopt pats gopt -local addpfx addsfx expl - -setopt localoptions nullglob rcexpandparam globdots extendedglob +setopt localoptions nullglob rcexpandparam unsetopt markdirs globsubst shwordsplit nounset -prepaths=('') -ignore=() -group=() -sopt='-' -gopt='' -pats=() -addpfx=() -addsfx=() -expl=() +exppaths=() # Get the options. -while getopts "P:S:W:F:J:V:X:f/g:" opt; do - case "$opt" in - P) addpfx=(-P "$OPTARG") - ;; - S) addsfx=(-S "$OPTARG") - ;; - W) tmp1="$OPTARG" - if [[ "$tmp1[1]" = '(' ]]; then - prepaths=( ${^=tmp1[2,-2]}/ ) - else - prepaths=( ${(P)=${tmp1}} ) - (( ! $#prepaths )) && prepaths=( ${tmp1}/ ) - fi - (( ! $#prepaths )) && prepaths=( '' ) - ;; - F) tmp1="$OPTARG" - if [[ "$tmp1[1]" = '(' ]]; then - ignore=( ${^=tmp1[2,-2]}/ ) - else - ignore=( ${(P)${tmp1}} ) - fi - (( $#ignore )) && ignore=(-F "( $ignore )") - ;; - [JV]) group=("-$opt" "$OPTARG") - ;; - X) expl=(-X "$OPTARG") - ;; - f) sopt="${sopt}f" - pats=("$pats[@]" '*') - ;; - /) sopt="${sopt}/" - pats=("$pats[@]" '*(-/)') - ;; - g) gopt='-g' - pats=("$pats[@]" ${=OPTARG}) - ;; - esac -done +zparseopts -a mopts \ + 'P:=pfxsfx' 'S:=pfxsfx' 'q=pfxsfx' 'r:=pfxsfx' 'R:=pfxsfx' \ + 'W:=prepaths' 'F:=ignore' 'M+:=matcher' \ + J+: V+: X+: 1: 2: n: 'f=tmp1' '/=tmp1' 'g+:-=tmp1' + +sopt="-${(@j::M)${(@)tmp1#-}#?}" +(( $tmp1[(I)-[/g]*] )) && haspats=yes +(( $tmp1[(I)-g*] )) && gopt=yes +if (( $tmp1[(I)-/] )); then + pats=( '*(-/)' ${=${(M)tmp1:#-g*}#-g} ) +else + pats=( "${(@)=${(@M)tmp1:#-g*}#-g}" ) +fi +pats=( "${(@)pats:# #}" ) + +if (( $#prepaths )); then + tmp1="${prepaths[2]}" + if [[ "$tmp1[1]" = '(' ]]; then + prepaths=( ${^=tmp1[2,-2]%/}/ ) + elif [[ "$tmp1[1]" = '/' ]]; then + prepaths=( "${tmp1%/}/" ) + else + prepaths=( ${(P)^tmp1%/}/ ) + (( ! $#prepaths )) && prepaths=( ${tmp1%/}/ ) + fi + (( ! $#prepaths )) && prepaths=( '' ) +else + prepaths=( '' ) +fi + +if (( $#ignore )); then + if [[ "${ignore[2]}" = \(* ]]; then + ignore=( ${=ignore[2][2,-2]} ) + else + ignore=( ${(P)ignore[2]} ) + fi +fi # If we were given no file selection option, we behave as if we were given # a `-f'. -if [[ "$sopt" = - ]]; then +if [[ "$sopt" = -(f|) ]]; then if [[ -z "$gopt" ]]; then sopt='-f' pats=('*') @@ -88,224 +67,472 @@ if [[ "$sopt" = - ]]; then fi fi -# str holds the whole string from the command line with a `*' between -# the prefix and the suffix. - -str="${PREFIX:q}*${SUFFIX:q}" - -# If the string began with a `~', the quoting turned this into `\~', -# remove the slash. +if (( ! $mopts[(I)-[JVX]] )); then + local expl -[[ "$str" = \\\~* ]] && str="$str[2,-1]" - -# We will first try normal completion called with `complist', but only if we -# weren't given a `-F' option. - -if (( ! $#ignore )); then - # First build an array containing the `-W' option, if there is any and we - # want to use it. We don't want to use it if the string from the command line - # is a absolute path or relative to the current directory. - - if [[ -z "$tmp1[1]" || "$str[1]" = [~/] || "$str" = (.|..)/* ]]; then - tmp1=() + if [[ -z "$gopt" && "$sopt" = -/ ]]; then + _description directories expl directory else - tmp1=(-W "( $prepaths )") + _description files expl file + fi + tmp1=$expl[(I)-M*] + if (( tmp1 )); then + if (( $#matcher )); then + matcher[2]="$matcher[2] $expl[1+tmp1]" + else + matcher=(-M "$expl[1+tmp1]") + fi fi + mopts=( "$mopts[@]" "$expl[@]" ) +fi - # Now call complist. +if zstyle -s ":completion:${curcontext}:files" sort tmp1; then + case "$tmp1" in + *size*) sort=oL;; + *links*) sort=ol;; + *(time|date|modi)*) sort=om;; + *access*) sort=oa;; + *(inode|change)*) sort=oc;; + *) sort=on;; + esac + [[ "$tmp1" = *rev* ]] && sort[1]=O - nm=$NMATCHES - if [[ -z "$gopt" ]]; then - complist "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" "$tmp1[@]" $sopt + if [[ "$sort" = on ]]; then + sort='' else - complist "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" "$tmp1[@]" $sopt -g "$pats" + mopts=( "${(@)mopts/#-J/-V}" ) + + tmp2=() + for tmp1 in "$pats[@]"; do + if [[ "$tmp1" = (#b)(?*)(\(\([^\|~]##\)\)) ]]; then + tmp2=( "$tmp2[@]" "${match[1]}((${sort}${match[2][3,-1]}" ) + elif [[ "$tmp1" = (#b)(?*)(\([^\|~]##\)) ]]; then + tmp2=( "$tmp2[@]" "${match[1]}(${sort}${match[2][2,-1]}" ) + else + tmp2=( "$tmp2[@]" "${tmp1}(${sort})" ) + fi + done + pats=( "$tmp2[@]" ) fi +fi + +# Check if we have to skip over sequences of slashes. The value of $skips +# is used below to match the pathname components we always have to accept +# immediatly. + +if zstyle -t ":completion:${curcontext}:paths" squeeze-slashes; then + skips='((.|..|)/)##' +else + skips='((.|..)/)##' +fi + +# We get the prefix and the suffix from the line and save the whole +# original string. Then we see if we will do menucompletion. + +pre="$PREFIX" +suf="$SUFFIX" +opre="$PREFIX" +osuf="$SUFFIX" +orig="${PREFIX}${SUFFIX}" +eorig="$orig" - # If this generated any matches, we don't want to do in-path completion. +[[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" || + ( -n "$compstate[pattern_match]" && + "${orig#\~}" != "${${orig#\~}:q}" ) ]] && menu=yes - [[ -nmatches nm ]] || return +# If given no `-F' option, we may want to use $fignore, turned into patterns. - # No `-F' option, so we want to use `fignore'. +[[ -z "$_comp_no_ignore" && $#ignore -eq 0 && + ( -z $gopt || "$pats" = \ #\*\ # ) && -n $FIGNORE ]] && + ignore=( "?*${^fignore[@]}" ) - ignore=(-F fignore) +if (( $#ignore )); then + _comp_ignore=( "$_comp_ignore[@]" "$ignore[@]" ) + (( $mopts[(I)-F] )) || mopts=( "$mopts[@]" -F _comp_ignore ) fi +(( $#matcher )) && mopts=( "$mopts[@]" "$matcher[@]" ) + # Now let's have a closer look at the string to complete. -if [[ "$str[1]" = \~ ]]; then +if [[ "$pre[1]" = \~ ]]; then # It begins with `~', so remember anything before the first slash to be able # to report it to the completion code. Also get an expanded version of it # (in `realpath'), so that we can generate the matches. Then remove that # prefix from the string to complete, set `donepath' to build the correct # paths and make sure that the loop below is run only once with an empty # prefix path by setting `prepaths'. - - linepath="${str%%/*}/" - eval realpath\=$linepath - str="${str#*/}" + + linepath="${pre[2,-1]%%/*}" + if [[ -z "$linepath" ]]; then + realpath="${HOME%/}/" + elif (( $+userdirs[$linepath] )); then + realpath="${userdirs[$linepath]%/}/" + elif (( $+nameddirs[$linepath] )); then + realpath="${nameddirs[$linepath]%/}/" + else + _message "unknown user \`$linepath'" + return 1 + fi + linepath="~${linepath}/" + [[ "$realpath" = "$linepath" ]] && return 1 + pre="${pre#*/}" + orig="${orig#*/}" + donepath='' + prepaths=( '' ) +elif [[ "$pre" = *\$*/* ]]; then + + # If there is a parameter expansion in the word from the line, we try + # to complete the beast by expanding the prefix and completing anything + # after the first slash after the parameter expansion. + # This fails for things like `f/$foo/b/<TAB>' where the first `f' is + # meant as a partial path. + + linepath="${(M)pre##*\$[^/]##/}" + realpath=${(e)~linepath} + [[ "$realpath" = "$linepath" ]] && return 1 + pre="${pre#${linepath}}" + i="${#linepath//[^\\/]}" + orig="${orig[1,(in:i:)/][1,-2]}" donepath='' prepaths=( '' ) else # If the string does not start with a `~' we don't remove a prefix from the # string. - liniepath='' + linepath='' realpath='' - if [[ "$str[1]" = / ]]; then + if [[ "$pre[1]" = / ]]; then # If it is a absolut path name, we remove the first slash and put it in # `donepath' meaning that we treat it as the path that was already handled. # Also, we don't use the paths from `-W'. - str="$str[2,-1]" + pre="$pre[2,-1]" + orig="$orig[2,-1]" donepath='/' prepaths=( '' ) else # The common case, we just use the string as it is, unless it begins with # `./' or `../' in which case we don't use the paths from `-W'. - [[ "$str" = (.|..)/* ]] && prepaths=( '' ) + [[ "$pre" = (.|..)/* ]] && prepaths=( '' ) donepath='' fi fi -# First we skip over all pathname components in `str' which really exist in -# the file-system, so that `/usr/lib/l<TAB>' doesn't offer you `lib' and -# `lib5'. Pathname components skipped this way are taken from `str' and added -# to `donepath'. +# Now we generate the matches. First we loop over all prefix paths given +# with the `-W' option. -while [[ "$str" = */* ]] do - [[ -e "$realpath$donepath${str%%/*}" ]] || break - donepath="$donepath${str%%/*}/" - str="${str#*/}" -done +for prepath in "$prepaths[@]"; do -# Now build the glob pattern by calling `_match_pattern'. -patstr="$str" -matchflags="" -_match_pattern _path_files patstr matchflags + # Get local copies of the prefix, suffix, and the prefix path to use + # in the following loop, which walks through the pathname components + # in the string from the line. -# We almost expect the pattern to have changed `..' into `*.*.', `/.' into -# `/*.', and probably to contain two or more consecutive `*'s. Since these -# have special meaning for globbing, we remove them. But before that, we -# add the pattern for matching any characters before a slash. + tpre="$pre" + tsuf="$suf" + testpath="$donepath" -patstr="$patstr:gs-/-*/-:gs/*.*.//:gs-/*.-/.-:gs/**/*/" + tmp2="${(M)tpre##${~skips}}" + tpre="${tpre#$tmp2}" -# Finally, generate the matches. First we loop over all the paths from `-W'. -# Note that in this loop `str' is used as a modifyable version of `patstr' -# and `testpath' is a modifyable version of `donepath'. + tmp1=( "$prepath$realpath$donepath$tmp2" ) -for prepath in "$prepaths[@]"; do - str="$patstr" - testpath="$donepath" + while true; do - # The second loop tests the components of the path in `str' to get the - # possible matches. + # Get the prefix and suffix for matching. - while [[ "$str" = */* ]] do - # `rest' is the pathname after the first slash that is left. In `tmp1' - # we get the globbing matches for the pathname component currently - # handled. + if [[ "$tpre" = */* ]]; then + PREFIX="${tpre%%/*}" + SUFFIX="" + else + PREFIX="${tpre}" + SUFFIX="${tsuf%%/*}" + fi - rest="${str#*/}" - tmp1="${prepath}${realpath}${testpath}${~matchflags}${str%%/*}(-/)" - tmp1=( $~tmp1 ) + # Get the matching files by globbing. - if [[ $#tmp1 -eq 0 ]]; then - # If this didn't produce any matches, we don't need to test this path - # any further, so continue with the next `-W' path, if any. + tmp2=( "$tmp1[@]" ) + if [[ "$tpre$tsuf" = */* ]]; then + if [[ ! -o globdots && "$PREFIX" = .* ]]; then + tmp1=( ${^tmp1}${skipped}*(-/) ${^tmp1}${skipped}.*(-/) ) + else + tmp1=( ${^tmp1}${skipped}*(-/) ) + fi + if [[ -o globdots || "$PREFIX" = .* ]] && + zstyle -s ":completion:${curcontext}:paths" special-dirs atmp; then + if [[ "$atmp" = (yes|true|1|on) ]]; then + tmp1=( "$tmp1[@]" . .. ) + elif [[ "$atmp" = .. ]]; then + tmp1=( "$tmp1[@]" .. ) + fi + fi + else + if [[ ! -o globdots && "$PREFIX" = .* ]]; then + tmp1=( ${^tmp1}${skipped}${^~pats} ${^tmp1}${skipped}.${^~pats:#.*} ) + else + tmp1=( ${^tmp1}${skipped}${^~pats} ) + fi + if [[ "$sopt" = *[/f]* && ( -o globdots || "$PREFIX" = .* ) ]] && + zstyle -s ":completion:${curcontext}:paths" special-dirs atmp; then + if [[ "$atmp" = (yes|true|1|on) ]]; then + tmp1=( "$tmp1[@]" . .. ) + elif [[ "$atmp" = .. ]]; then + tmp1=( "$tmp1[@]" .. ) + fi + fi + fi - continue 2 - elif [[ $#tmp1 -gt 1 ]]; then - # If it produced more than one match, we want to remove those which - # don't have possible following pathname components matching the - # rest of the string we are completing. (The case with only one - # match is handled below.) - # In `collect' we will collect those of the produced pathnames that - # have a matching possible path-suffix. In `suffixes' we build an - # array containing strings build from the rest of the string to - # complete and the glob patterns we were given as arguments. - - collect=() - suffixes=( $rest$^pats ) - suffixes=( "${(@)suffixes:gs.**.*.}" ) - - # In the loop the prefixes from the `tmp1' array produced above and - # the suffixes we just built are used to produce possible matches - # via globbing. - - for i in $tmp1; do - tmp2=( ${~i}/${~matchflags}${~suffixes} ) - [[ $#tmp2 -ne 0 ]] && collect=( $collect $i ) - done - - # If this test showed that none of the matches from the glob in `tmp1' - # has a possible sub-path matching what's on the line, we give up and - # continue with the next `-W' path. - - if [[ $#collect -eq 0 ]]; then + if [[ -n "$PREFIX$SUFFIX" ]]; then + # See which of them match what's on the line. + + if [[ -n "$_comp_correct" ]]; then + tmp2=( "$tmp1[@]" ) + builtin compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp1:t}" + + if [[ $#tmp1 -eq 0 ]]; then + tmp1=( "$tmp2[@]" ) + compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp2:t}" + fi + else + [[ "$tmp1[1]" = */* ]] && tmp2=( "$tmp1[@]" ) + + builtin compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp1:t}" + fi + + # If no file matches, save the expanded path and continue with + # the outer loop. + + if (( ! $#tmp1 )); then + if [[ "$tmp2[1]" = */* ]]; then + tmp2=( "${(@)tmp2#${prepath}${realpath}}" ) + if [[ "$tmp2[1]" = */* ]]; then + tmp2=( "${(@)tmp2:h}" ) + compquote tmp2 + if [[ "$tmp2" = */ ]]; then + exppaths=( "$exppaths[@]" ${^tmp2}${tpre}${tsuf} ) + else + exppaths=( "$exppaths[@]" ${^tmp2}/${tpre}${tsuf} ) + fi + else + exppaths=( "$exppaths[@]" ${tpre}${tsuf} ) + fi + fi continue 2 - elif [[ $#collect -ne 1 ]]; then - # If we have more than one possible match, this means that the - # pathname component currently handled is ambiguous, so we give - # it to the completion code. - # First we build the full path prefix in `tmp1'. + fi + elif (( ! $#tmp1 )); then + # A little extra hack: if we were completing `foo/<TAB>' and `foo' + # contains no files, this will normally produce no matches and other + # completers might think that's it's their time now. But if the next + # completer is _correct or something like that, this will result in + # an attempt to correct a valid directory name. So we just add the + # original string in such a case so that the command line doesn't + # change but other completers still think there are matches. + # We do this only if we weren't given a `-g' or `-/' option because + # otherwise this would keep `_files' from completing all filenames + # if none of the patterns match. + + if [[ -z "$tpre$tsuf" && -n "$pre$suf" ]]; then + pfxsfx=(-S '' "$pfxsfx[@]") + ### Don't remember what the break was good for. We explicitly + ### execute this only when there are no matches in the directory, + ### so why continue? + ### + ### tmp1=( "$tmp2[@]" ) + ### break + elif [[ "$haspats" = no && -z "$tpre$tsuf" && + "$pre" = */ && -z "$suf" ]]; then + PREFIX="${opre}" + SUFFIX="${osuf}" + compadd -nQS '' - "$linepath$donepath$orig" + tmp4=- + fi + continue 2 + fi - tmp1="$prepath$realpath$testpath" + if [[ -z "$_comp_no_ignore" && "$tpre$tsuf" != */* && $#tmp1 -ne 0 ]] && + zstyle -s ":completion:${curcontext}:files" ignore-parents rem && + [[ ( "$rem" != *dir* || "$pats" = '*(-/)' ) && + ( "$rem" != *..* || "$tmp1" = *../* ) ]]; then + if [[ "$rem" = *parent* ]]; then + for i in ${(M)^tmp1:#*/*}(-/); do + remt="${${i#$prepath$realpath$donepath}%/*}" + while [[ "$remt" = */* && + ! "$prepath$realpath$donepath$remt" -ef "$i" ]]; do + remt="${remt%/*}" + done + [[ "$remt" = */* || "$remt" -ef "$i" ]] && + _comp_ignore=( "$_comp_ignore[@]" "${(q)i}" ) + done + fi + if [[ "$rem" = *pwd* ]]; then + for i in ${^tmp1}(-/); do + [[ "$i" -ef "$PWD" ]] && _comp_ignore=( "$_comp_ignore[@]" "${(q)i}" ) + done + fi + (( $#_comp_ignore && $mopts[(I)-F] )) || mopts=( "$mopts[@]" -F _comp_ignore ) + fi - # Now produce all matching pathnames in `collect'. + # Step over to the next component, if any. - collect=( ${~collect}/${~matchflags}${~suffixes} ) + if [[ "$tpre" = */* ]]; then + tpre="${tpre#*/}" + elif [[ "$tsuf" = */* ]]; then + tpre="${tsuf#*/}" + tsuf="" + else + break + fi - # And then remove the common path prefix from all these matches. + # There are more components, so skip over the next components and make a + # slash be added. - collect=( ${collect#$tmp1} ) + tmp2="${(M)tpre##((.|..|)/)##}" + if [[ -n "$tmp2" ]]; then + skipped="/$tmp2" + tpre="${tpre#$tmp2}" + else + skipped=/ + fi + done + + # The next loop searches the first ambiguous component. + + tmp3="$pre$suf" + tpre="$pre" + tsuf="$suf" + tmp1=( "${(@)tmp1#${prepath}${realpath}${testpath}}" ) - # Finally, we add all these matches with the common (unexpanded) - # pathprefix (the `-p' option), the path-prefix (the `-W' option) - # to allow the completion code to test file type, and the path- - # suffix (the `-s' option). We also tell the completion code that - # these are file names and that `fignore' should be used as usual - # (the `-f' and `-F' options). + while true; do - for i in $collect; do - compadd "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" -p "$linepath$testpath" -W "$tmp1" -s "/${i#*/}" -f "$ignore[@]" - "${i%%/*}" - done + # First we check if some of the files match the original string + # for this component. If there are some we remove all other + # names. This avoids having `foo' complete to `foo' and `foobar'. - # We have just finished handling all the matches from above, so we - # can continue with the next `-W' path. + if [[ "$tmp3" = */* ]]; then + tmp4=( "${(@M)tmp1:#${tmp3%%/*}/*}" ) + (( $#tmp4 )) && tmp1=( "$tmp4[@]" ) + fi + + # Next we see if this component is ambiguous. - continue 2 + if [[ "$tmp3" = */* ]]; then + tmp4=$tmp1[(I)^${(q)tmp1[1]%%/*}/*] + else + tmp4=$tmp1[(I)^${(q)tmp1[1]}] + fi + + if [[ "$tpre" = */* ]]; then + tmp2="${cpre}${tpre%%/*}" + PREFIX="${donepath}${linepath}${tmp2}" + SUFFIX="/${tpre#*/}${tsuf#*/}" + else + tmp2="${cpre}${tpre}" + PREFIX="${donepath}${linepath}${tmp2}" + SUFFIX="${tsuf}" + fi + + if (( tmp4 )) || + [[ -n "$compstate[pattern_match]" && "$tmp2" != "${(q)tmp2}" ]]; then + # It is. For menucompletion we now add the possible completions + # for this component with the unambigous prefix we have built + # and the rest of the string from the line as the suffix. + # For normal completion we add the rests of the filenames + # collected as the suffixes to make the completion code expand + # it as far as possible. + + tmp2="$testpath" + compquote tmp1 tmp2 + + if [[ -n $menu || -z "$compstate[insert]" ]] || + ! zstyle -t ":completion:${curcontext}:paths" expand suffix; then + (( tmp4 )) && zstyle -t ":completion:${curcontext}:paths" cursor && + compstate[to_end]='' + if [[ "$tmp3" = */* ]]; then + compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \ + -W "$prepath$realpath$testpath" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ + - "${(@)tmp1%%/*}" + else + compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ + -W "$prepath$realpath$testpath" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ + - "$tmp1[@]" + fi + else + if [[ "$tmp3" = */* ]]; then + atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2" + -W "$prepath$realpath$testpath" + "$pfxsfx[@]" -M "r:|/=* r:|=*" ) + for i in "$tmp1[@]"; do + compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}" + done + else + compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ + -W "$prepath$realpath$testpath" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ + - "$tmp1[@]" + fi fi - # We reach this point if only one of the path prefixes in `tmp1' - # has a existing path-suffix matching the string from the line. - # In this case we accept this match and continue with the next - # path-name component. + tmp4=- + break + fi + + # If we have checked all components, we stop now and add the + # strings collected after the loop. - tmp1=( "$collect[1]" ) + if [[ "$tmp3" != */* ]]; then + tmp4="" + break fi - # This is also reached if the first globbing produced only one match - # in this case we just continue with the next pathname component, too. - tmp1="$tmp1[1]" - testpath="$testpath${tmp1##*/}/" - str="$rest" + # Otherwise we add the unambiguous component to `testpath' and + # take it from the filenames. + + testpath="${testpath}${tmp1[1]%%/*}/" + tmp1=( "${(@)tmp1#*/}" ) + + tmp3="${tmp3#*/}" + + if [[ "$tpre" = */* ]]; then + cpre="${cpre}${tpre%%/*}/" + tpre="${tpre#*/}" + elif [[ "$tsuf" = */* ]]; then + cpre="${cpre}${tpre}/" + tpre="${tsuf#*/}" + tsuf="" + else + tpre="" + tsuf="" + fi done - # We are here if all pathname components except the last one (which is still - # not tested) are unambiguous. So we add matches with the full path prefix, - # no path suffix, the `-W' we are currently handling, all the matches we - # can produce in this directory, if any. - - tmp1="$prepath$realpath$testpath" - suffixes=( $str$^pats ) - suffixes=( "${(@)suffixes:gs.**.*.}" ) - tmp2=( ${~tmp1}${~matchflags}${~suffixes} ) - if [[ $#tmp2 -eq 0 && "$sopt" = */* ]]; then - [[ "$testpath[-1]" = / ]] && testpath="$testpath[1,-2]" - compadd "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" -f - "$linepath$testpath" - else - compadd "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" -p "$linepath$testpath" -W "$prepath$realpath$testpath" -f "$ignore[@]" - ${(@)tmp2#$tmp1} + if [[ -z "$tmp4" ]]; then + if [[ "$osuf" = */* ]]; then + PREFIX="${opre}${osuf}" + SUFFIX="" + else + PREFIX="${opre}" + SUFFIX="${osuf}" + fi + tmp4="$testpath" + compquote tmp4 tmp1 + compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]" fi done + +# If we are configured to expand paths as far as possible and we collected +# expanded paths that are different from the string on the line, we add +# them as possible matches. + +if zstyle -t ":completion:${curcontext}:paths" expand prefix && + [[ nm -eq compstate[nmatches] && $#exppaths -ne 0 && + "$exppaths" != "$eorig" ]]; then + PREFIX="${opre}" + SUFFIX="${osuf}" + compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" +fi + +[[ nm -ne compstate[nmatches] ]] diff --git a/Completion/Core/_prefix b/Completion/Core/_prefix index 6306b4aa0..f6e3b0831 100644 --- a/Completion/Core/_prefix +++ b/Completion/Core/_prefix @@ -4,10 +4,10 @@ [[ -n "$SUFFIX" ]] || return 1 -local curcontext="${curcontext/:[^:]#:/:prefix:}" comp i +local comp i zstyle -a ":completion:${curcontext}:" completer comp || - comp=( "${(@)_completers[1,-${#_completers_left}-1][(R)_prefix,-1]}" ) + comp=( "${(@)_completers[1,_completer_num-1][(R)_prefix(|:*),-1]}" ) if zstyle -t ":completion:${curcontext}:" add-space; then ISUFFIX=" $SUFFIX" diff --git a/Completion/Core/_requested b/Completion/Core/_requested index 082c45820..bd838a28e 100644 --- a/Completion/Core/_requested +++ b/Completion/Core/_requested @@ -1,9 +1,20 @@ #autoload -local tag tname="$funcstack[2,-1]" +local gopt=-J -for tag; do - [[ "${_cur_tags[${tname}]}" = *:${tag}(:|\[*\]:)* ]] && return 0 -done +if [[ "$1" = -([12]|)[VJ] ]]; then + gopt="$1" + shift +fi -return 1 +if comptags -R "$1"; then + _comp_tags="$_comp_tags $1" + if [[ $# -gt 3 ]]; then + _all_labels "$gopt" "$@" + elif [[ $# -gt 1 ]]; then + _description "$gopt" "$@" + fi + return 0 +else + return 1 +fi diff --git a/Completion/Core/_setup b/Completion/Core/_setup index f12c34b34..ed7307e69 100644 --- a/Completion/Core/_setup +++ b/Completion/Core/_setup @@ -1,13 +1,61 @@ #autoload -local colors i - -for i; do - if _style -a "$i" list-colors colors; then - if [[ "$1" = default ]]; then - ZLS_COLORS="${(j.:.)${(@)colors:gs/:/\\\:}}" - else - eval "ZLS_COLORS=\"(${i})\${(j.:(${i}).)\${(@)colors:gs/:/\\\:}}:\${ZLS_COLORS}\"" - fi +local val nm="$compstate[nmatches]" + +if zstyle -a ":completion:${curcontext}:$1" list-colors val; then + zmodload -i zsh/complist + if [[ "$1" = default ]]; then + ZLS_COLORS="${(j.:.)${(@)val:gs/:/\\\:}}" + else + eval "ZLS_COLORS=\"(${1})\${(j.:(${1}).)\${(@)val:gs/:/\\\:}}:\${ZLS_COLORS}\"" fi -done + +# Here is the problem mentioned in _main_complete. + +# elif [[ "$1" = default && -n "$ZLS_COLORS$ZLS_COLOURS" ]]; then +# zmodload -i zsh/complist +# ZLS_COLORS="$ZLS_COLORS$ZLS_COLOURS" + +fi + +if zstyle -t ":completion:${curcontext}:$1" list-packed; then + compstate[list]="${compstate[list]} packed" +elif [[ $? -eq 1 ]]; then + compstate[list]="${compstate[list]:gs/packed//}" +else + compstate[list]="$_saved_list" +fi + +if zstyle -t ":completion:${curcontext}:$1" list-rows-first; then + compstate[list]="${compstate[list]} rows" +elif [[ $? -eq 1 ]]; then + compstate[list]="${compstate[list]:gs/rows//}" +else + compstate[list]="$_saved_list" +fi + +if zstyle -t ":completion:${curcontext}:$1" last-prompt; then + compstate[last_prompt]=yes +elif [[ $? -eq 1 ]]; then + compstate[last_prompt]='' +else + compstate[last_prompt]="$_saved_lastprompt" +fi + +if zstyle -t ":completion:${curcontext}:$1" accept-exact; then + compstate[exact]=accept +elif [[ $? -eq 1 ]]; then + compstate[exact]='' +else + compstate[exact]="$_saved_exact" +fi + +[[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] && + _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" ) + +if zstyle -a ":completion:${curcontext}:$1" menu val; then + _last_nmatches=$nm + _last_menu_style=( "$val[@]" ) +else + _last_nmatches=-1 +fi diff --git a/Completion/Core/_tags b/Completion/Core/_tags index af8dc21dd..496f5b7e0 100644 --- a/Completion/Core/_tags +++ b/Completion/Core/_tags @@ -1,81 +1,83 @@ #autoload -if (( $# )); then - local cmd="$words[1]" func="$funcstack[2]" defs i tags tag pat style prio - - while getopts 'c:f:' i; do - if [[ "$i" = c ]]; then - cmd="$OPTARG" - else - func="$OPTARG" - fi - done - - shift OPTIND-1 - - defs=( "${(@M)argv:#${(kj:|:)~override_tags[(R)(|+*)]}}" ) - (( $#defs )) && set -- "$defs[@]" - - _offered_tags=( "$_offered_tags[@]" "$@" ) - _last_tags=() - - defs=() - for i; do - if [[ -n ${override_tags[$i]} && ${override_tags[$i]} != (\[|+\[)* ]]; then - if [[ ${override_tags[$i]} = *\[* ]]; then - prio=( "${i}:*=${override_tags[$i]#+}" ) - else - prio=( "${i}:${(@v)^comptags[(I)(|*:)${i}(|:*)]}" ) - (( $#prio )) || prio=( "${i}:${comptags[any]}" ) - prio="${${${prio[(r)(|*:)\*=[^:]#\[*\](|:*)]}##(|*:)\*}%%:*}" - prio=( "${i}:*=${override_tags[$i]#+}${(M)prio%%\[*\]}" ) - fi - else - prio=( "${i}:${(@v)^comptags[(I)(|*:)${i}(|:*)]}" ) - (( $#prio )) || prio=( "${i}:${comptags[any]}" ) - fi - defs=( "$defs[@]" "$prio[@]" ) - done - - tags=() - for i in "$defs[@]"; do - tag="${i%%:*}" - for pat in "${(s.:.)i#*:}"; do - if [[ ( "$pat" = _* && "$func" = ${~pat%%\=*} ) || - "$cmd" = ${~pat%%\=*} ]]; then - prio="${pat#*\=}" - [[ "$prio" = -* ]] && continue 2 - - if [[ "$prio" = *\[*\] ]]; then - style="${(M)prio%%\[*}" - prio="${prio%%\[*}" - else - style='' - fi - [[ ${override_tags[$tag]} = (|+)\[* ]] && - style="${override_tags[$tag]#+}" - - (( prio++ )) - - tags[$prio]="${tags[$prio]}:${tag}${style}" - break - fi - done - done +local prev - prios=( "${(@)tags:#}" ) +# A `--' as the first argument says that we should tell comptags to use +# the preceding function nesting level. This is only documented here because +# if everythings goes well, users won't have to worry about it and should +# not mess with it. - return 0 +if [[ "$1" = -- ]]; then + prev=- + shift fi -_failed_tags=( "$_failed_tags[@]" "$_last_tags[@]" ) +if (( $# )); then + + # We have arguments: the tags supported in this context. + + local curcontext="$curcontext" order tag nodef tmp + + if [[ "$1" = -C?* ]]; then + curcontext="${curcontext%:*}:${1[3,-1]}" + shift + elif [[ "$1" = -C ]]; then + curcontext="${curcontext%:*}:${2}" + shift 2 + else + targs=() + fi + + [[ "$1" = -(|-) ]] && shift -(( $#prios )) || return 1 + if zstyle -a ":completion:${curcontext}:" group-order order; then + local name -tags="${prios[1]}:" -shift 1 prios + for name in "$order[@]"; do + compadd -J "$name" + compadd -V "$name" + compadd -J "$name" -1 + compadd -V "$name" -1 + compadd -J "$name" -2 + compadd -V "$name" -2 + done + fi + + # Set and remember offered tags. + + comptags "-i$prev" "$curcontext" "$@" + + # Sort the tags. + + if [[ -n "$_sort_tags" ]]; then + "$_sort_tags" "$@" + else + zstyle -a ":completion:${curcontext}:" tag-order order || + order=('arguments values' options) + + for tag in $order; do + case $tag in + -) nodef=yes;; + *\(\)) if ! "${${tag%%[ ]#\(\)}##[ ]#}" "$@"; then + nodef=yes + break + fi + ;; + \!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";; + ?*) comptry -m "$tag";; + esac + done + + [[ -z "$nodef" ]] && comptry "$@" + fi + + # Return non-zero if at least one set of tags should be used. + + comptags "-T$prev" + + return +fi -_last_tags=( "${(@s.:.)${${tags#:}%:}}" ) -_tried_tags=( "$_tried_tags[@]" "$_last_tags[@]" ) +# The other mode: switch to the next set of tags. -return 0 +comptags "-N$prev" diff --git a/Completion/Core/_wanted b/Completion/Core/_wanted index 7baa3e724..32875ec57 100644 --- a/Completion/Core/_wanted +++ b/Completion/Core/_wanted @@ -1,6 +1,6 @@ #autoload -local targs +local targs gopt=-J if [[ "$1" = -C?* ]]; then targs=( -C "${1[3,-1]}" ) @@ -12,10 +12,22 @@ else targs=() fi -[[ "$1" = -(|-) ]] && shift +if [[ "$1" = -([12]|)[VJ] ]]; then + gopt="$1" + shift +fi + +if [[ $# -gt 3 ]]; then + if _tags "$targs[@]" "$1"; then + _comp_tags="$_comp_tags $1" -if [[ $# -gt 1 ]]; then - _tags "$targs[@]" "$1" && _description "${(@)argv[2,-1]}" + _all_labels -t "$gopt" "$@" + else + return 1 + fi +elif [[ $# -gt 1 ]]; then + _tags -- "$targs[@]" "$1" && _comp_tags="$_comp_tags $1" && + _description "$gopt" "$@" else - _tags "$targs[@]" "$1" + _tags -- "$targs[@]" "$1" && _comp_tags="$_comp_tags $1" fi diff --git a/Completion/Core/compdump b/Completion/Core/compdump index 8be096f50..3cccbd06e 100644 --- a/Completion/Core/compdump +++ b/Completion/Core/compdump @@ -1,4 +1,4 @@ -# This is a file to be sourced to dump the definitions for new-style +# This is a function to dump the definitions for new-style # 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 @@ -9,33 +9,46 @@ # 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. -# -# It relies on KSH_ARRAYS not being set. # Print the number of files used for completion. This is used in compinit # to see if auto-dump should re-dump the dump-file. -_d_file=${COMPDUMP-${0:h}/compinit.dump} +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.$$ typeset -U _d_files -_d_files=( ${^~fpath}/_*~*~(N:t) ) +_d_files=( ${^~fpath:/.}/^([^_]*|*~|*.zwc)(N:t) ) print "#files: $#_d_files" > $_d_file -unset _d_files - # 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 - print -r - "'${_d_f//\'/'\\''}'" "'${_comps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_comps[$_d_f]}" done >> $_d_file print ")" >> $_d_file print "\n_patcomps=(" >> $_d_file -for _d_f in "$_patcomps[@]"; do - print -r - "'${_d_f//\'/'\\''}'" +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]}" done >> $_d_file print ")" >> $_d_file @@ -44,11 +57,13 @@ 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. +# We can ignore any zle -C which rebinds a standard widget (second +# argument to zle does not begin with a `_'). _d_bks=() zle -lL | while read -rA _d_line; do - if [[ ${_d_line[5]} = _* ]]; then + if [[ ${_d_line[3]} = _* && ${_d_line[5]} = _* ]]; then print -r - ${_d_line} _d_bks=($_d_bks ${_d_line[3]}) fi @@ -73,17 +88,26 @@ done)) # print them out: about five to a line looks neat +_i=5 +print -n autoload -U >> $_d_file while (( $#_d_als )); do - print -n autoload - for (( _i = 0; _i < 5; _i++ )); do - if (( $#_d_als )); then - print -n " $_d_als[1]" - shift _d_als + if (( ! $+_compautos[$_d_als[1]] )); then + print -n " $_d_als[1]" + if (( _i-- && $#_d_als > 1 )); then + _i=5 + print -n '\nautoload -U' fi - done - print + fi + shift _d_als done >> $_d_file print >> $_d_file -unset _d_line _d_zle _d_bks _d_als _d_f _f_file +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 diff --git a/Completion/Core/compinit b/Completion/Core/compinit index ec5867838..6a35d17a7 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -1,25 +1,23 @@ # Initialisation for new style completion. This mainly contains some helper -# function and aliases. Everything else is split into different files in this -# directory that will automatically be made autoloaded (see the end of this -# file). +# functions and aliases. Everything else is split into different files that +# will automatically be made autoloaded (see the end of this file). # The names of the files that will be considered for autoloading have to -# start with a underscores (like `_setopt). +# start with an underscores (like `_setopt'). # The first line of these files will be read and has to say what should be # done with its contents: # -# `#defcomp <names ...>' -# if the first line looks like this, the file is -# autoloaded as a function and that function will -# be called to generate the matches when completing -# for one of the commands whose <name> is given +# `#compdef <names ...>' +# If the first line looks like this, the file is autoloaded as a +# function and that function will be called to generate the matches +# when completing for one of the commands whose <names> are given. # -# `#defpatcomp <pattern>' -# this defines a function that should be called to generate -# matches for commands whose name matches <pattern>; note -# that only one pattern may be given +# `#compdef -p <pattern>' +# This defines a function that should be called to generate matches +# for commands whose name matches <pattern>. Note that only one pattern +# may be given. # -# `#defkeycomp <style> [ <key-sequence> ... ] -# this is used to bind special completions to all the given +# `#compdef -k <style> [ <key-sequence> ... ]' +# This is used to bind special completions to all the given # <key-sequence>(s). The <style> is the name of one of the built-in # completion widgets (complete-word, delete-char-or-list, # expand-or-complete, expand-or-complete-prefix, list-choices, @@ -29,35 +27,89 @@ # rather than by the context. The widget has the same name as # the autoload file and can be bound using bindkey in the normal way. # -# `#autoload' -# this is for helper functions that are not used to +# `#compdef -K <widget-name> <style> <key-sequence> [ ... ]' +# This is similar to -k, except it takes any number of sets of +# three arguments. In each set, the widget <widget-name> will +# be defined, which will behave as <style>, as with -k, and will +# be bound to <key-sequence>, exactly one of which must be defined. +# <widget-name> must be different for each: this must begin with an +# underscore, else one will be added, and should not clash with other +# completion widgets (names based on the name of the function are the +# clearest), but is otherwise arbitrary. It can be tested in the +# function by the parameter $WIDGET. +# +# `#autoload [ <options> ]' +# This is for helper functions that are not used to # generate matches, but should automatically be loaded -# when they are called +# when they are called. The <options> will be given to the +# autoload builtin when making the function autoloaded. Note +# that this need not include `-U'. # # Note that no white space is allowed between the `#' and the rest of # the string. # -# See the file `compdump' for how to speed up initialiation. -# -# If you are using global matching specifications with `compctl -M ...' -# have a look at the files `_match_test' and `_match_pattern'. To make -# all the example functions use matching as specified with `-M' these -# need some editing. +# Functions that are used to generate matches should return zero if they +# were able to add matches and non-zero otherwise. # +# See the file `compdump' for how to speed up initialisation. + # If we got the `-d'-flag, we will automatically dump the new state (at -# the end). +# the end). This takes the dumpfile as an argument. -d (with the +# default dumpfile) is now the default; to turn off dumping use -D. + +emulate -L zsh +setopt extendedglob + +typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1 +typeset _i_tag _i_file _i_addfiles + +while [[ $# -gt 0 && $1 = -[dDf] ]]; do + if [[ "$1" = -d ]]; then + _i_autodump=1 + shift + if [[ $# -gt 0 && "$1" != -[df] ]]; then + _i_dumpfile="$1" + shift + fi + elif [[ "$1" = -D ]]; then + _i_autodump=0 + shift + elif [[ "$1" = -f ]]; then + # Not used any more; use _compdir + shift + shift + fi +done -if [[ "$1" = -d ]]; then - _i_autodump=1 +# The associative array containing the definitions for the commands. +# Definitions for patterns will be stored in the associations `_patcomps' +# and `_postpatcomps'. `_compautos' contains the names and options +# for autoloaded functions that get options. + +typeset -gA _comps _patcomps _postpatcomps _compautos + +# The associative array use to report information about the last +# cmpletion to the outside. + +typeset -gA _lastcomp + +# Remember dumpfile. +if [[ -n $_i_dumpfile ]]; then + # Explicitly supplied dumpfile. + _comp_dumpfile="$_i_dumpfile" else - _i_autodump=0 + _comp_dumpfile="${ZDOTDIR:-$HOME}/.zcompdump" fi -# The associative array containing the definitions for the commands. -# Definitions for patterns will be stored in the normal array `_patcomps'. +# These can hold names of functions that are to be called before/after all +# matches have been generated. -typeset -A _comps -_patcomps=() +compprefuncs=() +comppostfuncs=() + +# Loading it now ensures that the `funcstack' parameter is always correct. + +: $funcstack # This function is used to register or delete completion functions. For # registering completion functions, it is invoked with the name of the @@ -70,6 +122,9 @@ _patcomps=() # function will be invoked when completing for a command whose name # matches the pattern given as argument after the function name (in this # case only one argument is accepted). +# The option `-P' is like `-p', but the function will be called after +# trying to find a function defined for the command on the line if no +# such function could be found. # With the `-k' option a function for a special completion keys is # defined and immediatly bound to those keys. Here, the extra arguments # are the name of one of the builtin completion widgets and any number @@ -78,7 +133,8 @@ _patcomps=() # whose name is given as the first argument be autoloaded. When defining # a function for command names the `-n' option may be given and keeps # the definitions from overriding any previous definitions for the -# commands. +# commands; with `-k', the `-n' option prevents compdef from rebinding +# a key sequence which is already bound. # For deleting definitions, the `-d' option must be given. Without the # `-p' option, this deletes definitions for functions for the commands # whose names are given as arguments. If combined with the `-p' option @@ -110,11 +166,16 @@ compdef() { # Get the options. - while getopts "anpkd" opt; do + if [[ $#* -eq 0 ]]; then + echo "compdef needs parameters" + return 1 + fi + + while getopts "anpPkKd" opt; do case "$opt" in a) autol=yes;; n) new=yes;; - [pk]) if [[ -n "$type" ]]; then + [pPkK]) if [[ -n "$type" ]]; then # Error if both `-p' and `-k' are given (or one of them # twice). echo "$0: type already set to $type" @@ -122,6 +183,10 @@ compdef() { fi if [[ "$opt" = p ]]; then type=pattern + elif [[ "$opt" = P ]]; then + type=postpattern + elif [[ "$opt" = K ]]; then + type=widgetkey else type=key fi @@ -131,12 +196,17 @@ compdef() { done shift OPTIND-1 + if [[ $#* -eq 0 ]]; then + echo "compdef needs parameters" + return 1 + fi + if [[ -z "$delete" ]]; then # Adding definitions, first get the name of the function name # and probably do autoloading. func="$1" - [[ -n "$autol" ]] && autoload "$func" + [[ -n "$autol" ]] && autoload -U "$func" shift case "$type" in @@ -145,11 +215,33 @@ compdef() { echo "$0: only one pattern allowed" return 1 fi - # Patterns are stored in strings like `c* foo', with a space - # between the pattern and the function name. - - _patcomps=("$_patcomps[@]" "$1 $func") + _patcomps[$1]="$func" ;; + postpattern) + if [[ $# -gt 1 ]]; then + echo "$0: only one pattern allowed" + return 1 + fi + _postpatcomps[$1]="$func" + ;; + widgetkey) + while [[ -n $1 ]]; do + if [[ $# -lt 3 ]]; then + echo "$0: compdef -K requires <widget> <comp-widget> <key>" + return 1 + fi + [[ $1 = _* ]] || 1="_$1" + [[ $2 = .* ]] || 2=".$2" + zle -C "$1" "$2" "$func" + if [[ -n $new ]]; then + bindkey "$3" | read -A opt + [[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1" + else + bindkey "$3" "$1" + fi + shift 3 + done + ;; key) if [[ $# -lt 2 ]]; then echo "$0: missing keys" @@ -157,30 +249,44 @@ compdef() { fi # Define the widget. - zle -C "$func" "$1" "$func" + if [[ $1 = .* ]]; then + zle -C "$func" "$1" "$func" + else + zle -C "$func" ".$1" "$func" + fi shift # And bind the keys... for i; do + if [[ -n $new ]]; then + bindkey "$i" | read -A opt + [[ $opt[-1] = undefined-key ]] || continue + fi bindkey "$i" "$func" done ;; *) # For commands store the function name in the `_comps' # associative array, command names as keys. - for i; do - [[ -z "$new" || "${+_comps[$i]}" -eq 0 ]] && _comps[$i]="$func" - done + if [[ -z "$new" ]]; then + for i; do + _comps[$i]="$func" + done + else + for i; do + [[ "${+_comps[$i]}" -eq 0 ]] && _comps[$i]="$func" + done + fi ;; esac else # Handle the `-d' option, deleting. case "$type" in pattern) - # Note the space. - for i; do - _patcomps=("${(@)patcomps:#$i *}") - done + unset "_patcomps[$^@]" + ;; + postpattern) + unset "_postpatcomps[$^@]" ;; key) # Oops, cannot do that yet. @@ -189,81 +295,210 @@ compdef() { return 1 ;; *) - # Deleting definitons for command is even simpler. - for i; do - unset "_comps[$i]" - done + unset "_comps[$^@]" esac fi } -# Now we automatically make the definition files autoloaded. +# Do *not* use this... -# First we get the name of a dump file if this will be used. +compconf() { -: ${COMPDUMP:=$0.dump} + local style name val i tmp cmt -if [[ ! -o extendedglob ]]; then - _i_noextglob=yes - setopt extendedglob -fi + if [[ -z "$_compconf_warn" ]]; then + _compconf_warn=yep + + print " + +Hello + +\`compconf' will be removed in the near future, we now use a more +general (and powerful) mechanism using the \`zstyle' builtin. An +approximation to your old setup using \`zstyle' should be available +in the file: + + \`${HOME}/.zsh-styles' + +Note that the values for the styles may be partly incorrect. Please +read the manual to find out how to configure the completion system +with styles. + +Have fun + + Sven +" 1>&2 + command rm -f ${HOME}/.zsh-styles + fi + + for i; do + name="${i%%\=*}" + val="${i#*\=}" + + tmp='' + cmt='' + + case "$name" in + urls_path) + tmp="'*:urls' path ${(qq)val}" + ;; + urls_localhttp) + tmp="'*:urls' local ${${(qqs.:.)val}}" + ;; + describe_options) + tmp="'*:options' verbose 'yes'" + ;; + describe_values) + tmp="'*:values' verbose 'yes'" + ;; + autodescribe_options) + tmp="'*:options' auto-description ${(qq)val}" + ;; + description_format) + tmp="'*:descriptions' format ${(qq)val}" + ;; + message_format) + tmp="'*:messages' format ${(qq)val}" + ;; + warning_format) + tmp="'*:warnings' format ${(qq)val}" + ;; + option_prefix) + tmp="'*:options' prefix-needed yes" + [[ "$val" = hide* ]] && + tmp="$tmp +zstyle ':completion:*:options' prefix-hidden yes" + ;; + group_matches) + tmp="'*' group-name ''" + ;; + colors_path) + tmp="'*:colors' path ${(qq)val}" + ;; + path_expand) + tmp="'*:paths' expand ${(qq)val}" + ;; + path_cursor) + tmp="'*:paths' cursor ${(qq)val}" + ;; + (approximate|incremental|predict|list|oldlist|match)_*) + tmp="'*${name%%_*}:*' ${${name#*_}//_/-} ${(qq)val}" + ;; + correct_*) + cmt="# This one is a bit ugly. You may want to use only \`*:correct' +# if you also have the \`correctword_*' or \`approximate_*' keys. +" + tmp="'*(correct(|-word)|approximate):*' ${name#*_} ${(qq)val}" + ;; + correctword_*) + tmp="'*:correct-word' ${name#correctword_} ${(qq)val}" + ;; + expand_*) + cmt="# This one is a bit ugly. You may want to use only \`*:expand' +# if you also have the \`expandword_*' keys. +" + tmp="'*expand(|expand-word):*' ${name#*_} ${(qq)val}" + ;; + expandword_*) + tmp="'expand-word:*' ${name#expandword_} ${(qq)val}" + ;; + history_*) + tmp="'history-words:*' ${name#history_} ${(qq)val}" + ;; + completer) + tmp="'*' completer ${${(qqs.:.)val}}" + ;; + last_prompt) + tmp="'*' last-prompt 'yes'" + ;; + esac + [[ -n "$tmp" ]] && style="${style}${cmt}zstyle :completion:${tmp} +" + done + + eval "${style}" + + print "$style" >>! ${HOME}/.zsh-styles +} + +# Now we automatically make the definition files autoloaded. typeset -U _i_files -_i_files=( ${^~fpath}/_*~*~(N:t) ) -_i_initname=$0 +_i_files=( ${^~fpath:/.}/^([^_]*|*~|*.zwc)(N:t) ) +if [[ $#_i_files -lt 20 || $_compdir = */Core || -d $_compdir/Core ]]; then + # Too few files: we need some more directories, + # or we need to check that all directories (not just Core) are present. + if [[ -n $_compdir ]]; then + _i_addfiles=() + if [[ $_compdir = */Core ]]; then + # Add all the Completion subdirectories + _i_addfiles=(${_compdir:h}/*(/)) + elif [[ -d $_compdir/Core ]]; then + # Likewise + _i_addfiles=(${_compdir}/*(/)) + fi + for _i_line in {1..$#i_addfiles}; do + _i_file=${_i_addfiles[$_i_line]} + [[ -d $_i_file && -z ${fpath[(r)$_i_file]} ]] || + _i_addfiles[$_i_line]= + done + fpath=($fpath $_i_addfiles) + _i_files=( ${^~fpath:/.}/^([^_]*|*~|*.zwc)(N:t) ) + fi +fi + + +# Rebind the standard widgets +for _i_line in complete-word delete-char-or-list expand-or-complete \ + expand-or-complete-prefix list-choices menu-complete \ + menu-expand-or-complete reverse-menu-complete; do + zle -C $_i_line .$_i_line _main_complete +done +zle -la menu-select && zle -C menu-select .menu-select _main_complete + _i_done='' +# Make sure compdump is available, even if we aren't going to use it. +autoload -U compdump compinstall + # If we have a dump file, load it. -if [[ -f "$COMPDUMP" ]]; then - read -rA _i_line < "$COMPDUMP" +if [[ -f "$_comp_dumpfile" ]]; then + read -rA _i_line < "$_comp_dumpfile" if [[ _i_autodump -eq 1 && $_i_line[2] -eq $#_i_files ]]; then - builtin . "$COMPDUMP" + builtin . "$_comp_dumpfile" _i_done=yes fi - unset _i_line fi if [[ -z "$_i_done" ]]; then for _i_dir in $fpath; do [[ $_i_dir = . ]] && continue - for _i_file in $_i_dir/_*~*~(N); do + for _i_file in $_i_dir/^([^_]*|*~|*.zwc)(N); do read -rA _i_line < $_i_file _i_tag=$_i_line[1] shift _i_line - if [[ $_i_tag = '#defcomp' ]]; then - compdef -na "${_i_file:t}" "${_i_line[@]}" - elif [[ $_i_tag = '#defpatcomp' ]]; then - compdef -pa "${_i_file:t}" "${_i_line[@]}" - elif [[ $_i_tag = '#defkeycomp' ]]; then - compdef -ka "${_i_file:t}" "${_i_line[@]}" - elif [[ $_i_tag = '#autoload' ]]; then - autoload ${_i_file:t} - fi + case $_i_tag in + (\#compdef) + if [[ $_i_line[1] = -[pPkK](n|) ]]; then + compdef ${_i_line[1]}na "${_i_file:t}" "${(@)_i_line[2,-1]}" + else + compdef -na "${_i_file:t}" "${_i_line[@]}" + fi + ;; + (\#autoload) + autoload -U "$_i_line[@]" ${_i_file:t} + [[ "$_i_line" != \ # ]] && _compautos[${_i_file:t}]="$_i_line" + ;; + esac done done - bindkey | - while read -rA _i_line; do - if [[ "$_i_line[2]" = complete-word || - "$_i_line[2]" = delete-char-or-list || - "$_i_line[2]" = expand-or-complete || - "$_i_line[2]" = expand-or-complete-prefix || - "$_i_line[2]" = list-choices || - "$_i_line[2]" = menu-complete || - "$_i_line[2]" = menu-expand-or-complete || - "$_i_line[2]" = reverse-menu-complete ]]; then - zle -C _complete_$_i_line[2] $_i_line[2] _main_complete - bindkey "${_i_line[1][2,-2]}" _complete_$_i_line[2] - fi - done - - unset _i_dir _i_line _i_file _i_tag - # If autodumping was requested, do it now. - (( _i_autodump )) && builtin . ${_i_initname:h}/compdump + if [[ $_i_autodump = 1 ]]; then + compdump + fi fi -[[ -z "$_i_noextglob" ]] || unsetopt extendedglob - -unset _i_files _i_initname _i_done _i_autodump _i_noextglob +unfunction compinit +autoload -U compinit diff --git a/Completion/Core/compinstall b/Completion/Core/compinstall index d96121cf2..ad05cb5a1 100644 --- a/Completion/Core/compinstall +++ b/Completion/Core/compinstall @@ -1,72 +1,149 @@ -# This script is to be run by a user to setup the new function based +# This script is to be run by a user to set up the new function based # completion system. The functions themselves are assumed to be already # available in some directory; they should have been installed with the -# the shell (except we haven't written that yet). +# the shell. If they have been, the commands `autoload -U compinit; compinit' +# in the shell startup file should be enough, although you can run +# compinstall for more configuration choices. # -# Run it as a script under zsh and answer the questions. -# You can run it as `zsh compinstall $FPATH' and it will be able to check -# your function path for the completion functions. -# -# Normally, this will alter ~/.zshrc (or wherever ZDOTDIR puts it), -# but you can make that unwritable and it will leave the lines in a -# temporary file instead. -# -# You can use this script to modify what compinstall previously -# added to ~/.zshrc. +# Simply run this script as a function and answer the questions. +# Normally it will alter ~/.zshrc (or wherever ZDOTDIR puts it), but you +# can make that unwritable and it will leave the lines in a temporary file +# instead. It doesn't matter if .zshrc didn't exist before. If your +# .zshrc usually exits before the end, then you should take the code added +# by compinstall and put it (including the comment lines at the start and +# end) at the point you want it to be executed. If you run compinstall +# again it will find and replace those lines, so you can use this script to +# modify what compinstall previously added to ~/.zshrc. # # It is safe to abort with ^C any time you are being prompted for # information; your .zshrc will not be altered. # # To do: -# - Maybe this should be sourced, then it can check the user's current -# setup better. But then there is a potentially horrendous option -# setting/resetting problem. (Maybe we need another way of doing that.) # - Should probably offer to set different options for _approximate than # for _complete if both are used. # - Could add code for setting other completers and options. # - Could add keys for context-sensitive help. -# - Probably should allow a set of directories to be added to $fpath, -# like Core, Base, etc. -# In case a startup script changed options -emulate zsh -[[ -n $1 ]] && FPATH=$1 +emulate -L zsh -for f in $fpath; do - if [[ $f != . && -f $f/compinit && -f $f/compdump ]]; then - fdir=$f - break - fi -done +typeset _ci_options _ci_f _ci_fdir _ci_files _ci_dumpfile _ci_lines +typeset _ci_type _ci_completer _ci_accept _ci_cprompt _ci_startline +typeset _ci_endline _ci_ifile _ci_tmpf _ci_compstyle _ci_warn +typeset _ci_dtype _ci_existing _ci_line _ci_end -if [[ -z $fdir ]]; then - print "Trying to find where the completion functions are..." - if [[ $0 = */* && -f $0:h/compinit && -f $0:h/compdump ]]; then - fdir=$0:h - else - # more guesses? - print \ +# Look for the defaults. +_ci_startline='# The following lines were added by compinstall' +_ci_endline='# End of lines added by compinstall' + +_ci_ifile=${ZDOTDIR:-~}/.zshrc +_ci_lines='' +_ci_existing='' + +typeset -A _ci_defaults + +if [[ -f $_ci_ifile ]]; then + # This assumes the lines haven't been altered by the user too much + # after they were added. + _ci_compstyle=0 + sed -n "/^$_ci_startline/,/^$_ci_endline/p" $_ci_ifile | + while read -rA _ci_line; do + if (( $_ci_compstyle )); then + # parse a compstyle component as first argument + if [[ $_ci_line[-1] != \\ ]]; then + _ci_end=-1 + _ci_compstyle=0 + else + _ci_end=-2 + fi + if [[ $_ci_line[1] = *=* ]]; then + _ci_f="${${_ci_line[1,$_ci_end]}#*=}" + if [[ $_ci_f = \'*\' ]]; then + # strip quotes + _ci_f=${_ci_f[2,-2]//\'\\\'\'/\'} + fi + _ci_defaults[${_ci_line[1]%%\=*}]=$_ci_f + fi + _ci_existing="${_ci_existing} $_ci_line +" + elif [[ $_ci_line[1] = compinit ]]; then + # parse the line running compinit + [[ $_ci_line[2] = -f ]] && _ci_fdir=$_ci_line[3] + [[ $_ci_line[-2] = -d ]] && _ci_dumpfile=$_ci_line[-1] + elif [[ $_ci_line[1] = _compdir=* ]]; then + _ci_fdir=${_ci_line[1]##_compdir=} + elif [[ $_ci_line[1] = compstyle ]]; then + # parse a compstyle component as second argument (should be completer) + [[ $_ci_line[3] = completer ]] && + _ci_completer=${_ci_line[3,-1]} + [[ $_ci_line[-1] == \\ ]] && _ci_compstyle=1 + _ci_existing="${_ci_existing}$_ci_line +" + elif [[ $_ci_line[1] != \#* && $_ci_line[1] != (autoload|\[\[) ]]; then + if [[ -z $_ci_warn ]]; then + _ci_warn=1 + print "Warning: existing lines in compinstall setup not understood:" + fi + print - $_ci_line + _ci_existing="${_ci_existing}$_ci_line +" + fi + done +fi + + +# Find out where the completion functions are kept. + +if [[ -z $_ci_fdir || ! -f ${~_ci_fdir}/compinit || + ! -f ${~_ci_fdir}/compdump ]]; then + for _ci_f in $fpath; do + if [[ $_ci_f != . && -f $_ci_f/compinit && -f $_ci_f/compdump ]]; then + _ci_fdir=$_ci_f + break + elif [[ $_ci_f != . && -f $_ci_f/Core/compinit && + -f $_ci_f/Core/compdump ]] + then + _ci_fdir=$_ci_f/Core + break + fi + done +fi + +if [[ -z $_ci_fdir || ! -d ${~_ci_fdir} ]]; then + print \ "Please edit the name of the directory where the completion functions are installed. If they are not installed, you will need to find them in the Completion/* directories of the zsh distribution and install them yourself, or insult your system manager for incompetence." - vared -c fdir - while [[ ! -d ${~fdir} || ! -f ${~fdir}/compinit || - ! -f ${~fdir}/compdump ]]; do - print "I can't find them in that directory. Try again or abort." - vared fdir - done + vared -c _ci_fdir + while [[ ! -d ${~_ci_fdir} || + ((! -f ${~_ci_fdir}/compinit || ! -f ${~_ci_fdir}/compdump) && + (! -f ${~_ci_fdir}/Core/compinit || ! -f ${~_ci_fdir}/Core/compdump)) ]] + do + print "I can't find them in that directory. Try again or abort." + vared _ci_fdir + done + if [[ -f ${~_ci_fdir}/Core/compinit && ! -f ${~_ci_fdir}/compinit ]]; then + _ci_fdir=$_ci_fdir/Core fi - eval "fpath=($fdir \$fpath)" - fdir=${fdir/#$HOME/\~} - lines="fpath=($fdir \$fpath)\n" else - print "Found completion functions in your fpath, will not alter it." + print "Keeping existing completion directiory $_ci_fdir" +fi + +if [[ ${~_ci_fdir} != /* ]]; then + _ci_fdir=$(cd $_ci_fdir;builtin pwd) fi -files=( ${^~fpath:/.}/_(|*[^~])(N:t) ) -if [[ $#files -lt 20 ]]; then +# Check if this is in fpath already, else put it there (with ~'s expanded). +_ci_f=${~_ci_fdir} +[[ -z ${fpath[(r)$_ci_f]} ]] && fpath=($fpath $_ci_f) + +# Contract $HOME to ~ in the parameter to be used for writing. +_ci_fdir=${_ci_fdir/#$HOME/\~} + +# Now check the fpath, ignoring the directory . +_ci_files=( ${^~fpath:/.}/_(|*[^~])(N:t) ) +if [[ $#_ci_files -lt 20 ]]; then print " Hmmm, completion functions seem a bit thin on the ground. There should be lots of files with names beginning with an underscore (_). You should @@ -75,12 +152,20 @@ look and see what's happened to these. read fi -if [[ -w ${~fdir} && ( ! -f ${~fdir}/compinit.dump || - -w ${~fdir}/compinit.dump ) ]] + +# Set up the dumpfile +_ci_dtype=existing +if [[ -z $_ci_dumpfile ]]; then + _ci_dumpfile="${ZDOTDIR:-$HOME}/.zcompdump" + _ci_dtype=standard +fi + +if [[ -w ${~_ci_dumpfile:h} && ( ! -f ${~_ci_dumpfile} || + -w ${~_ci_dumpfile} ) ]] then print " -Using standard dumpfile - ${~fdir}/compinit.dump +Using $_ci_dtype dumpfile + ${_ci_dumpfile} to speed up initialisation. [Hit return to continue]" read @@ -88,23 +173,32 @@ else print " I will force completion to dump its status, which will speed up the shell's start-up considerably. However, I can't write the file I'd like to, namely -$fdir/compinit.dump. Please edit a replacement." - dumpfile='~/.compinit.dump' - vared dumpfile - while ! touch ${~dumpfile} >& /dev/null; do +${_ci_dumpfile}. Please edit a replacement." + vared _ci_dumpfile + while ! touch ${~_ci_dumpfile} >& /dev/null; do print "Sorry, I can't write that either. Try again." - vared dumpfile + vared _ci_dumpfile done - [[ -s $dumpfile ]] || rm -f $dumpfile - dumpfile=" $dumpfile" + [[ -s $_ci_dumpfile ]] || rm -f $_ci_dumpfile fi -fdir=${fdir/#$HOME/\~} - -lines="${lines}. $fdir/compinit -d$dumpfile\n" +_ci_lines="${_ci_lines}_compdir=$_ci_fdir +[[ -z \$fpath[(r)\$_compdir] ]] && fpath=(\$fpath \$_compdir) +autoload -U compinit +compinit" +[[ $_ci_dtype != standard ]] && _ci_lines="${_ci_lines} $_ci_dumpfile" +_ci_lines="${_ci_lines} +" print " +Would you like to set some more advanced options? Otherwise, you +can re-run compinstall later to set these. [n]" + +# The whole of the next part should be indented, but I can't be bothered. +if read -q; then + + print " In addition to completion, zsh can also perform correction of the current word, or approximate completion, i.e. completion where the part of the word typed so far can be corrected; or it can try correction, then @@ -112,105 +206,156 @@ approximate completion if that fails. Would you like: 0: Just ordinary completion C: Correction A: Approximate completion - B: Both? -Please type one of the keys above:" -while read -k type; do - print - case $type in - 0*) completer=_complete - break - ;; - [cC]*) completer=_complete:_correct - break - ;; - [aA]*) completer=_complete:_approximate - break; - ;; - [bB]*) completer=_complete:_correct:_approximate - break - ;; - *) print Try again - ;; - esac -done - -lines="${lines}compconf completer=$completer" - - -if [[ $completer = *(correct|approx)* ]]; then - print " -Correction and approximation will normally allow up to two errors, -and you will be able to use a numeric prefix (e.g. <Esc>4) to allow -more. The standard prompt is \`correct to:'. Do you want to change -any of this? [n]" - if read -q; then - print "Number of errors to accept normally (0 is OK):" - read accept - while [[ $accept != <-> ]]; do - read accept"?Please enter a number: " - done - print \ + B: Both" + if [[ -n $_ci_completer ]]; then + print " Default: use the current completers:\n$_ci_completer" + else + print "Please type one of the keys above." + fi + while read -k _ci_type; do + print + case $_ci_type in + 0*) _ci_completer=_complete + break + ;; + [cC]*) _ci_completer='_complete _correct' + break + ;; + [aA]*) _ci_completer='_complete _approximate' + break; + ;; + [bB]*) _ci_completer='_complete _correct _approximate' + break + ;; + *) [[ -n $_ci_completer ]] && break + print Try again + ;; + esac + done + + _ci_lines="${_ci_lines}zstyle ':completion*' completer $_ci_completer" + + + if [[ $_ci_completer = *(correct|approx)* ]]; then + _ci_accept=${_ci_defaults[correct_accept]} + _ci_cprompt=${_ci_defaults[correct_prompt]} + print " +Correction and approximation will allow up to ${${_ci_accept:-2}%%[^0-9]*} \ +errors. " + case $_ci_accept in + *n*!*|*!*n) print "A numeric prefix, if not 1, will cause correction \ +not to be done." + ;; + *n*) print "A numeric prefix gives the maximum number of errors which \ +will be accepted." + ;; + *) print "The numeric prefix will not be used." + esac +print "The correction prompt is \`${_ci_cprompt:-correct to:}'. +Do you want to change any of this? [n]" + if read -q; then + print "Number of errors to accept normally (0 is OK):" + _ci_accept=${_ci_accept%%[^0-9]*} + vared _ci_accept + while [[ $_ci_accept != <-> ]]; do + print "Please enter a number:" + vared _ci_accept + done + print \ "How would you like the numeric prefix to be treated: 0: Not used by correction - U: Used to given the number of errors + U: The number gives the largest number of errors which will be + accepted when correcting I: If present, and not 1, do not perform correction? Please type one of the keys above:" - while read -k type; do - print - case $type in - 0*) break - ;; - [uU]*) accept="${accept}n" - break - ;; - [Ii]*) accept="${accept}!n" - break - ;; - *) print Try again - ;; - esac - done - lines="$lines \\\\ - correct_accept='$accept'" - print " + while read -k _ci_type; do + print + case $_ci_type in + 0*) break + ;; + [uU]*) _ci_accept="${_ci_accept}n" + break + ;; + [Ii]*) _ci_accept="${_ci_accept}!n" + break + ;; + *) print Try again + ;; + esac + done + print " Instead of the prompt \`correct to:', you can have no prompt, or a prompt of your choosing which can display the number of errors found by containing the string \`%e'. Do you wish to change the correction prompt? [n]" - if read -q; then - cprompt='' - print "Edit a new prompt (may be empty):" - vared cprompt - lines="$lines \\\\ - correct_prompt='${cprompt//\'/\'\\\'\'}'" + if read -q; then + print "Edit a new prompt (may be empty):" + vared _ci_cprompt + [[ -z $_ci_cprompt ]] && _ci_cprompt=':empty:' + fi + fi + if [[ -n $_ci_accept ]]; then + _ci_lines="$_ci_lines \\ + correct_accept='$_ci_accept'" + unset '_ci_defaults[correct_accept]' + fi + if [[ -n $_ci_cprompt ]]; then + _ci_cprompt=${_ci_cprompt##:empty:} + _ci_lines="$_ci_lines \\ + correct_prompt='${_ci_cprompt//\'/\'\\\'\'}'" + unset '_ci_defaults[correct_prompt]' fi fi -fi -lines="$lines\n" + _ci_warn='' + for _ci_f in ${(k)_ci_defaults}; do + if [[ -z $_ci_warn ]]; then + print " +(Keeping other existing configuration settings...)" + _ci_warn=1 + fi + _ci_lines="$_ci_lines \\ + ${_ci_f}='${_ci_defaults[$_ci_f]//\'/\'\\\'\'}'" + done + _ci_lines="$_ci_lines +" -startline='# The following lines were added by compinstall' -endline='# End of lines added by compinstall' +else -ifile=${ZDOTDIR:-~}/.zshrc -[[ -f $ifile ]] || touch $ifile -tmpf=${TMPPPREFIX:-/tmp/zsh}compinstall$$ + if [[ -n $_ci_existing ]]; then + print -nr " +I will retain the following lines from the existing completion setup: +$_ci_existing" + _ci_lines="$_ci_lines${_ci_existing}" + fi + +fi # End of advanced options -if [[ ! -w $ifile ]]; then - print "\nI can't write to $ifile. I will leave the lines to add in -\`$tmpf' and you must add them by hand." - print "\n$startline\n$lines\n$endline" >$tmpf - return 0 -fi -if grep $endline $ifile >& /dev/null; then - print -- "$startline\n$lines$endline" >$tmpf - sed -e "/^$endline/r $tmpf -/^$startline/,/^$endline/d" $ifile >${tmpf}2 && mv ${tmpf}2 $ifile && - print "\nSuccesfully modified old compinstall lines in $ifile." - rm -f $tmpf ${tmpf}2 +[[ -f $_ci_ifile ]] || touch $_ci_ifile +_ci_tmpf=${TMPPPREFIX:-/tmp/zsh}compinstall$$ + +if [[ ! -w $_ci_ifile ]]; then + print "\nI can't write to $_ci_ifile. I will leave the lines to add in +\`$_ci_tmpf' and you must add them by hand." + print -r - "$_ci_startline +$_ci_lines$_ci_endline" >$_ci_tmpf +elif grep $_ci_endline $_ci_ifile >& /dev/null; then + print -r - "$_ci_startline +$_ci_lines$_ci_endline" >$_ci_tmpf + sed -e "/^$_ci_endline/r $_ci_tmpf +/^$_ci_startline/,/^$_ci_endline/d" $_ci_ifile >${_ci_tmpf}2 && + mv ${_ci_tmpf}2 $_ci_ifile && + print "\nSuccesfully modified old compinstall lines in $_ci_ifile." + rm -f $_ci_tmpf ${_ci_tmpf}2 else - print "\n$startline\n$lines\n$endline" >>$ifile && - print "\nSuccessfully appended lines to $ifile." + print -r - "$_ci_startline +$_ci_lines$_ci_endline" >>$_ci_ifile && + print "\nSuccessfully appended lines to $_ci_ifile." fi + +unfunction compinstall +autoload -U compinstall + +return 0 diff --git a/Completion/Linux/_rpm b/Completion/Linux/_rpm index 7fdc80ab0..9ef2d57d9 100644 --- a/Completion/Linux/_rpm +++ b/Completion/Linux/_rpm @@ -3,7 +3,7 @@ # This uses `_arguments' in a state-machine kind of way. These states # have names and before executing the default action for such a state # we try to call a function with the name `_rpm_<state>'. If such a -# function exists, we return with it's return status immediatly. This +# function exists, we return with its return status immediately. This # allows users to override the default completions by simply defining # these functions. # The states (and possible values for the `<state>' above) are: @@ -43,28 +43,36 @@ local ret=1 tmp expl # Used by `_arguments', made local here. -local state lstate line -tyeset -A options +local curcontext="$curcontext" state lstate line +typeset -A opt_args state='' # Do simple completions or get the first state. -_arguments \ +_arguments -C -s \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ - '-q:*:query:->query' \ - -{V,v,vv,y,-{setperms,setugids,querytags,initdb,showrc}} \ - '-pipe:*:pipe command:_command_names -e' \ - '--verify:*:verify:->verify' \ - -{i,-install}':*:install:->install' \ - -{U,-upgrade}':*:upgrade:->upgrade' \ - -{e,-erase}':*:uninstall:->uninstall' \ - -'b+:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_b' \ - -'t+:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_t' \ + '-q+[query mode]:*:query:->query' \ + '*-v[verbose mode]' \ + --{setperms,setugids,querytags,initdb,showrc} \ + '--pipe:pipe command:_command_names -e' \ + -{V,y}'[verify mode]:*:verify:->verify' \ + '--verify[verify mode]:*:verify:->verify' \ + '-i+[install mode]:*:install:->install' \ + '--install:*:install:->install' \ + '-U+[upgrade mode]:*:upgrade:->upgrade' \ + '--upgrade:*:upgrade:->upgrade' \ + '-F+[freshen mode]:*:upgrade:->upgrade' \ + '--freshen:*:upgrade:->upgrade' \ + '-e+[uninstall mode]:*:uninstall:->uninstall' \ + '--erase:*:uninstall:->uninstall' \ + -'b+[build mode (spec file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_b' \ + -'t+[build mode (tar file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_t' \ --{rebuild,rmsource,recompile,resign,addsign}':*:RPM package:->package' \ - -{K,-checksig}':*:sigcheck:->sigcheck' \ + '-K+[signature check mode]:*:sigcheck:->sigcheck' \ + '--checksig:*:sigcheck:->sigcheck' \ '--rebuilddb:*:rebuild:->rebuild' && ret=0 # As long as we have a state name... @@ -73,7 +81,7 @@ while [[ -n "$state" ]]; do # First try to call a user-defined function. - funcall ret _rpm_$state && return ret + _funcall ret _rpm_$state && return ret # Copy the state and reset `state', to simplify the test above. @@ -85,24 +93,24 @@ while [[ -n "$state" ]]; do case "$lstate" in query) - _arguments \ - -{v,vv} \ + _arguments -s \ + '*-v[verbose mode]' -q \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ '--root:RPM root directory:_files -/' \ '--dbpath:RPM database path:_files -/' \ '--queryformat:RPM query format:->tags' \ - '-f:file:_files' \ - '-p:RPM package file:->package_file' \ + '-f[specify file to query owner of]:file:_files' \ + '-p+[specify uninstalled package file to query]:*:RPM package file:->package_file' \ '--triggeredby:RPM package:->package' \ '--whatprovides:RPM capability:->capability' \ '--whatrequires:RPM capability:->capability' \ '*:RPM package:->package_or_file' && ret=0 ;; verify) - _arguments \ - -{v,vv} \ + _arguments -s \ + '*-v[verbose mode]' '(-y)-V' '(-V)-y' \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ @@ -112,15 +120,18 @@ while [[ -n "$state" ]]; do '*:RPM package:->package' && ret=0 ;; upgrade) - tmp=( --oldpackage ) + tmp=( -U --oldpackage ) ;& install) - _arguments "$tmp[@]" \ - -{v,vv} \ + (( $#tmp )) || tmp=(-i) + _arguments -s "$tmp[@]" \ + '*-v[verbose mode]' \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ - -{-{badreloc,excludedocs,force,hash,allfiles,ignorearch,ignoreos,includedocs,justdb,nodeps,noorder,noscripts,notriggers,percent,replacefiles,replacepkgs,test},h} \ + '(-h)--hash' '(--hash)-h' \ + '(--replacepkgs --replacefiles --oldpackage)--force' \ + --{badreloc,excludedocs,allfiles,ignorearch,ignoreos,includedocs,justdb,nodeps,noorder,noscripts,notriggers,percent,replacefiles,replacepkgs,test} \ '--relocate:relocate:->relocate' \ '--prefix:package prefix directory:_files -/' \ '--root:RPM root directory:_files -/' \ @@ -128,8 +139,8 @@ while [[ -n "$state" ]]; do '*:pkg file:->package_file' && ret=0 ;; uninstall) - _arguments \ - -{v,vv} \ + _arguments -s \ + '*-v[verbose mode]' -e \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ @@ -139,13 +150,13 @@ while [[ -n "$state" ]]; do '*:RPM package:->package' && ret=0 ;; build_b) - tmp=( '*:RPM package:->package' ) + tmp=( '*:spec file:_files -g \*.spec' ) ;& build_t) (( $#tmp )) || tmp=( '*:tar file:_files -g \*.\(\#i\)tar\(.\*\|\)' ) - _arguments \ - -{v,vv} \ + _arguments -s \ + '*-v[verbose mode]' \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ @@ -156,8 +167,8 @@ while [[ -n "$state" ]]; do '--timecheck:time check (seconds):' "$tmp[1]" && ret=0 ;; sigcheck) - _arguments \ - -{v,vv} \ + _arguments -s \ + '*-v[verbose mode]' -K \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ @@ -165,8 +176,8 @@ while [[ -n "$state" ]]; do '*:RPM package file:->package_or_file' && ret=0 ;; rebuild) - _arguments \ - -{v,vv} \ + _arguments -s \ + '*-v[verbose mode]' \ '--rcfile:resource file:_files' \ '--ftpproxy:FTP proxy server:_hosts' \ '--ftpport:FTP port number:' \ @@ -178,21 +189,23 @@ while [[ -n "$state" ]]; do state=package_file ;& package) - _description expl 'RPM package' - compadd "$expl[@]" -M 'r:|-=* r:|=*' - $(rpm -qa) && ret=0 + _wanted packages expl 'RPM package' \ + compadd -M 'r:|-=* r:|=*' - $(_call packages rpm -qa) && ret=0 ;; package_file) - if compset -P ftp:; then + if compset -P ftp://; then _hosts -S/ && ret=0 else - _files -g '*.(#i)rpm' && ret=0 + _alternative \ + 'files:RPM package file:_files -g \*.\(\#i\)rpm' \ + 'prefixes:ftp URL prefix:compadd ftp://' && ret=0 fi ;; tags) if compset -P '*\{'; then - _description expl 'RPM tag' - compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '}' - \ - "${(@)${(@f)$(rpm --querytags)}#RPMTAG_}" && ret=0 + _wanted tags expl 'RPM tag' \ + compadd -M 'm:{a-z}={A-Z}' -S '\}' - \ + "${(@)${(@f)$(_call tags rpm --querytags)}#RPMTAG_}" && ret=0 else _message 'RPM format' fi @@ -201,10 +214,10 @@ while [[ -n "$state" ]]; do _message 'RPM capability' ;; relocate) - if compset -P '*\='; then - _description expl 'new path' + if compset -P '*='; then + _description directories expl 'new path' else - _description expl 'old path' + _description directories expl 'old path' fi _files "$expl[@]" -/ && ret=0 diff --git a/Completion/User/_gdb b/Completion/User/_gdb index ff54e6a07..55e149bb7 100644 --- a/Completion/User/_gdb +++ b/Completion/User/_gdb @@ -1,36 +1,44 @@ #compdef gdb -# This uses the configuration keys `ps_args' and `ps_listargs' -# described in the `_wait' function. +local cur="$words[CURRENT]" prev w list ret=1 expl -local cur="$words[CURRENT]" prev w list ret=1 - -_long_options -t '*=(CORE|SYM)FILE' '_files' \ - '*=EXECFILE' '_files *(*)' \ - '*=TTY' 'compadd /dev/tty*' && return 0 +[[ "$PREFIX" = --* ]] && + _arguments -- '*=(CORE|SYM)FILE:core file:_files' \ + '*=EXECFILE:executable:_files \*\(-\*\)' \ + '*=TTY:terminal device:compadd /dev/tty\*' && return 0 if compset -P '-(cd|directory)='; then _files -/ elif compset -P '-tty='; then - compadd - /dev/tty* + _wanted devices expl 'terminal device' compadd - /dev/tty* elif compset -P '-(exec|se)='; then - _files -/g '*(*)' + _description files expl executable + _files "$expl[@]" -g '*(-*)' elif compset -P '-(symbols|core|command)='; then _files -elif compset -P -; then - compadd -QS '' - symbols\= exec\= se\= core\= command\= directory\= \ - cd\= tty\= - compadd - help h s e c x d nx n quiet q batch fullname f b +elif [[ "$PREFIX" = -* ]]; then + if _wanted options; then + while _next_label options expl option; do + compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \ + -directory\= -cd\= -tty\= && ret=0 + compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q \ + -batch -fullname -f -b && ret=0 + (( ret )) || return 0 + done + fi else prev="$words[CURRENT-1]" case "$prev" in - (-d) _files -/ && return 0 ;; - (-e) _files -/g '*(*)' && return 0 ;; + (-d) _files -/ && return 0 ;; (-[csx]) _files && return 0 ;; - (-b) compadd -V baud 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \ - 9600 19200 38400 57600 115200 230400 && return 0 ;; + (-e) _description files expl executable + _files "$expl[@]" -g '*(-*)' && return 0 ;; + (-b) _wanted -V values expl 'baud rate' \ + compadd 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \ + 9600 19200 38400 57600 115200 230400 && return 0 ;; esac + w=( "${(@)words[2,-1]}" ) while [[ "$w[1]" = -* ]]; do [[ "$w[1]" = -[decsxb] ]] && shift 1 w @@ -38,13 +46,9 @@ else done if [[ $#w -gt 1 ]]; then - _files && ret=0 - list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${w[1]:t}}} -") - compadd -y list - ${${${(M)${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0 - - return ret + _alternative 'files:: _files' "processes:: _pids -m ${w[1]:t}" else - _files -/g '*(*)' + _description files expl executable + _files "$expl[@]" -g '*(-*)' fi fi diff --git a/Completion/User/_getconf b/Completion/User/_getconf index 7ce709588..59e9a83bc 100644 --- a/Completion/User/_getconf +++ b/Completion/User/_getconf @@ -1,20 +1,19 @@ #compdef getconf -local expl +local expl ret=1 if [[ CURRENT -eq 2 ]]; then _tags syswideconfig pathconfig standardsconfig while _tags; do - if _requested -V syswideconfig expl 'systemwide configuration variables' - then - compadd "$expl[@]" -S '' ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX \ + _requested -V syswideconfig expl 'systemwide configuration variables' \ + compadd -S '' ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX \ BC_STRING_MAX CHILD_MAX COLL_WEIGHTS_MAX EXPR_NEST_MAX LINE_MAX \ - NGROUPS_MAX OPEN_MAX RE_DUP_MAX STREAM_MAX TZNAME_MAX - fi - if _requested -V standardsconfig \ - expl 'system-standards configuration variables'; then - compadd "$expl[@]" -S '' _POSIX_CHILD_MAX _POSIX_LINK_MAX \ + NGROUPS_MAX OPEN_MAX RE_DUP_MAX STREAM_MAX TZNAME_MAX && ret=0 + + _requested -V standardsconfig \ + expl 'system-standards configuration variables' \ + compadd -S '' _POSIX_CHILD_MAX _POSIX_LINK_MAX \ _POSIX_MAX_CANON _POSIX_MAX_INPUT _POSIX_NAME_MAX _POSIX_NGROUPS_MAX \ _POSIX_OPEN_MAX _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX \ _POSIX_STREAM_MAX _POSIX_TZNAME_MAX _POSIX_VERSION \ @@ -22,15 +21,17 @@ if [[ CURRENT -eq 2 ]]; then POSIX2_BC_STRING_MAX POSIX2_COLL_WEIGHTS_MAX POSIX2_EXPR_NEST_MAX \ POSIX2_LINE_MAX POSIX2_RE_DUP_MAX POSIX2_VERSION POSIX2_C_BIND \ POSIX2_C_DEV POSIX2_FORT_DEV POSIX2_FORT_RUN POSIX2_LOCALEDEF \ - POSIX2_SW_DEV _XOPEN_VERSION - fi - if _requested -V pathconfig expl 'system path configuration variables' - then - compadd "$expl[@]" -S '' PIPE_BUF _POSIX_CHOWN_RESTRICTED \ - _POSIX_NO_TRUNC _POSIX_VDISABLE - compadd "$expl[@]" -S ' ' LINK_MAX MAX_CANON MAX_INPUT NAME_MAX PATH_MAX \ - PIPE_BUF - fi + POSIX2_SW_DEV _XOPEN_VERSION && ret=0 + + _requested pathconfig && + while _next_label -V pathconfig expl 'system path configuration variables'; do + compadd "$expl[@]" -S '' PIPE_BUF _POSIX_CHOWN_RESTRICTED \ + _POSIX_NO_TRUNC _POSIX_VDISABLE && ret=0 + compadd "$expl[@]" -S ' ' LINK_MAX MAX_CANON MAX_INPUT NAME_MAX \ + PATH_MAX PIPE_BUF && ret=0 + (( ret )) || break + done + (( ret )) || return 0 done else _files -/ diff --git a/Completion/User/_groups b/Completion/User/_groups index 975189174..27444d26d 100644 --- a/Completion/User/_groups +++ b/Completion/User/_groups @@ -1,6 +1,19 @@ #compdef newgrp -: ${(A)groups:=${${(s: :)$(</etc/group)}%%:*}} -# : ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use NIS +local expl groups tmp -compadd $groups +_wanted groups || return 1 + +if ! zstyle -a ":completion:${curcontext}:" groups groups; then + (( $+_cache_groups )) || + if (( ${+commands[ypcat]} )) && + tmp=$(_call groups ypcat group.byname); then + : ${(A)_cache_groups:=${${(f)tmp}%%:*}} # If you use YP + else + : ${(A)_cache_groups:=${${(s: :)$(</etc/group)}%%:*}} + fi + + groups=( "$_cache_groups[@]" ) +fi + +_all_labels groups expl group compadd "$@" - "$groups[@]" diff --git a/Completion/User/_lp b/Completion/User/_lp index f37c62a14..cfa2a147c 100644 --- a/Completion/User/_lp +++ b/Completion/User/_lp @@ -1,50 +1,98 @@ #compdef lp lpr lpq lprm -local file expl ret=1 list disp strs shown +local expl ret=1 printer list disp strs shown if (( ! $+_lp_cache )); then + local file entry names i + file=( /etc/(printcap|printers.conf)(N) ) - if (( $#file )); then - _lp_cache=( "${(@)${(@s:|:)${(@)${(@f)$(< $file[1])}:#[ \#]*}%%:*}%%[ ]*}" ) - else - # Default value. Could probably be improved + _lp_cache=() + _lp_alias_cache=() - _lp_cache=( lp0 ) + if (( $#file )); then + while read entry; do + if [[ "$entry" = [^[:blank:]\#\*_]*:* ]]; then + names=( "${(s:|:)entry%%:*}" ) + if [[ "$entry" = *:description=* ]]; then + disp="${${entry##*:description=}%%:*}" + elif [[ $#names -gt 1 && "$names[-1]" = *\ * ]] ;then + disp="$names[-1]" + else + disp='' + fi + if [[ -n "$disp" ]]; then + _lp_cache=( "$_lp_cache[@]" "${names[1]}:${disp}" ) + _lp_alias_cache=( "$_lp_alias_cache[@]" "${(@)^names[2,-1]:#*\ *}:${disp}" ) + else + _lp_cache=( "$_lp_cache[@]" "${names[1]}" ) + _lp_alias_cache=( "$_lp_alias_cache[@]" "${(@)names[2,-1]:#*\ *}" ) + fi + fi + done < $file[1] fi + (( $#_lp_cache )) || _lp_cache=( 'lp0:Guessed default printer' ) + (( $#_lp_alias_cache )) || unset _lp_alias_cache fi if compset -P -P || [[ "$words[CURRENT-1]" = -P ]]; then - _wanted printers expl printer && compadd "$expl" - "$_lp_cache[@]" + if _wanted printers; then + if zstyle -T ":completion:${curcontext}:printers" verbose; then + zformat -a list ' -- ' "$_lp_cache[@]" + disp=(-ld list) + else + disp=() + fi + _all_labels printers expl printer \ + compadd "$disp[@]" - "${(@)_lp_cache%%:*}" && return 0 + + (( $+_lp_alias_cache )) || return 1 + + if zstyle -T ":completion:${curcontext}:printers" verbose; then + zformat -a list ' -- ' "$_lp_alias_cache[@]" + disp=(-ld list) + else + disp=() + fi + compadd "$expl[@]" "$disp[@]" - "${(@)_lp_alias_cache%%:*}" + else + return 1 + fi else if [[ "$words[1]" = (lpq|lprm) ]]; then - list=( "${(@M)${(f@)$(lpq)}:#[0-9]*}" ) + if [[ "$words" = *-P* ]]; then + printer=(-P "${${words##*-P( |)}%% *}") + else + printer=() + fi + list=( ${(M)"${(f@)$(_call jobs lpq $printer 2> /dev/null)}":#[0-9]*} ) if (( $#list )); then _tags users jobs while _tags; do - if _requested users expl user; then + if _requested users; then strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" ) if [[ -z "$shown" ]] && - zstyle -t ":completion:${curcontext}:users" verbose; then + zstyle -T ":completion:${curcontext}:users" verbose; then disp=(-ld list) shown=yes else disp=() fi - compadd "$expl[@]" "$disp[@]" - "$strs[@]" || _users && ret=0 + _all_labels users expl user compadd "$disp[@]" - "$strs[@]" || + _users && ret=0 fi - if _requested jobs expl job; then + if _requested jobs; then strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" ) if [[ -z "$shown" ]] && - zstyle -t ":completion:${curcontext}:jobs" verbose; then + zstyle -T ":completion:${curcontext}:jobs" verbose; then disp=(-ld list) shown=yes else disp=() fi - compadd "$expl[@]" "$disp[@]" - "$strs[@]" && ret=0 + _all_labels jobs expl job compadd "$disp[@]" - "$strs[@]" && ret=0 fi (( ret )) || return 0 done diff --git a/Completion/User/_make b/Completion/User/_make index d576b0308..741cbb7dc 100644 --- a/Completion/User/_make +++ b/Completion/User/_make @@ -1,3 +1,32 @@ -#defcomp make gmake pmake +#compdef make gmake pmake -complist -s "\$(awk '/^[a-zA-Z0-9][^/ ]+:/ {print \$1}' FS=: [mM]akefile)" +local prev="$words[CURRENT-1]" file expl tmp + +if [[ "$prev" = -[CI] ]]; then + _files -/ +elif [[ "$prev" = -[foW] ]]; then + _files +else + file="$words[(I)-f]" + if (( file )); then + file="$words[file+1]" + elif [[ -e Makefile ]]; then + file=Makefile + elif [[ -e makefile ]]; then + file=makefile + else + file='' + fi + + if [[ -n "$file" ]] && _wanted targets; then + tmp=( + $(awk '/^[a-zA-Z0-9][^\/ \t]+:/ {print $1} + /^\.include *<bsd\.port\.(subdir\.|pre\.)?mk>/ || /^\.include *".*mk\/bsd\.pkg\.(subdir\.)?mk"/ { + print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum" }' \ + FS=: $file) + ) + _all_labels targets expl 'make target' compadd "$tmp[@]" && return 0 + fi + compset -P 1 '*=' + _files +fi diff --git a/Completion/User/_mh b/Completion/User/_mh index 67ce49fd2..c1f397744 100644 --- a/Completion/User/_mh +++ b/Completion/User/_mh @@ -1,28 +1,36 @@ -#defcomp folder comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath mhpatch +#compdef folder folders comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath # Completion for all possible MH commands. # Alter the following two to your own mh directory and the directory # where standard mh library files live. (It works anyway, but this # will save a little time.) + local mymhdir=~/Mail local mhlib=/usr/lib/mh +local prev="$words[CURRENT-1]" expl + # To be on the safe side, check this exists and if not, get it anyway. [[ -d $mymhdir ]] || mymhdir=$(mhpath +) -if [[ -iprefix - ]]; then +if compset -P 1 -; then # get list of options, which MH commands can generate themselves # awk is just too icky to use for this, sorry. send me one if # you come up with it. - compadd -m $($COMMAND -help | perl -ne 'if (/^\s*-\(?(\S+)/) { - $n = $1; - $n =~ s/\)//g; - print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n"; - }') - return -elif [[ -iprefix '+' || -iprefix '@' || -current -1 -draftfolder ]]; then + if _wanted options; then + _all_labels options expl option \ + compadd - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) { + $n = $1; + $n =~ s/\)//g; + print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n"; + }') + return + fi + return 1 +elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then # Complete folder names. local mhpath + if [[ $IPREFIX != '@' ]]; then [[ $IPREFIX = '+' ]] || IPREFIX=+ mhpath=$mymhdir @@ -30,13 +38,12 @@ elif [[ -iprefix '+' || -iprefix '@' || -current -1 -draftfolder ]]; then mhpath=$(mhpath) fi - # painless, or what? - complist -W mhpath -/ -elif [[ -mcurrent -1 -(editor|(whatnow|rmm|show|more)proc) ]]; then - complist -c -elif [[ -current -1 -file ]]; then - complist -f -elif [[ -mcurrent -1 -(form|audit|filter) ]]; then + _wanted files expl 'MH folder' _path_files -W mhpath -/ +elif [[ "$prev" = -(editor|(whatnow|rmm|show|more)proc) ]]; then + _command_names -e +elif [[ "$prev" = -file ]]; then + _files +elif [[ "$prev" = -(form|audit|filter) ]]; then # Need some MH template file, which may be in our own MH directory # or with the standard library. local mhfpath @@ -44,15 +51,16 @@ elif [[ -mcurrent -1 -(form|audit|filter) ]]; then [[ -d $mhlib ]] || { mhlib=$(mhparam mhlproc); mhlib=$mhlib:h; } mhfpath=($mymhdir $mhlib) - complist -W mhfpath -g '*(.)' -elif [[ -mcurrent -1 -(no|)cc ]]; then - compadd -m all to cc me -elif [[ -mcurrent -1 -[rw]cache ]]; then - compadd -m public private never ask + _wanted files expl 'MH template file' _files -W mhfpath -g '*(.)' +elif [[ "$prev" = -(no|)cc ]]; then + _wanted -C "$prev" values expl 'CC address' compadd all to cc me +elif [[ "$prev" = -[rw]cache ]]; then + _wanted -C "$prev" values expl cache compadd public private never ask else # Generate sequences. - local foldnam folddir f - for f in $argv; do + local foldnam folddir f ret + + for f in $words; do [[ $f = [@+]* ]] && foldnam=$f done if [[ $foldnam = '+'* ]]; then @@ -64,7 +72,14 @@ else # leaving foldnam empty works here fi - complist -s '$(mark $foldnam | awk -F: '\''{ print $1 }'\'')' - compadd -m reply next cur prev first last all unseen - complist -W folddir -g '<->' + if _wanted sequences; then + while _next_label sequences expl sequence; do + compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') && + ret=0 + compadd "$expl[@]" reply next cur prev first last all unseen && ret=0 + _files "$expl[@]" -W folddir -g '<->' && ret=0 + (( ret )) || return 0 + done + fi + return ret fi diff --git a/Completion/User/_nedit b/Completion/User/_nedit index 1f030e369..a3fcd9785 100644 --- a/Completion/User/_nedit +++ b/Completion/User/_nedit @@ -40,10 +40,11 @@ else '(-background)-bg[specify background color]:background color:_x_color' \ '(-fg)-foreground:foreground color:_x_color' \ '(-foreground)-fg[specify foreground color]:foreground color:_x_color' \ - '-import[load additional preferences file]:nedit preferences file:_files' \ + '*-import[load additional preferences file]:nedit preferences file:_files' \ "$nedit_common[@]" fi -[[ $state = lang ]] && _wanted neditlanguages expl 'language mode' && - compadd "$expl[@]" - ${(f)"$(sed -n \ - '/^nedit.languageMode/,/^nedit/ s/.* \([^:]*\).*/\1/p' < ~/.nedit)"} +[[ $state = lang ]] && + _wanted neditlanguages expl 'language mode' \ + compadd - ${(f)"$(sed -n \ + '/^nedit.languageMode/,/^nedit/ s/.* \([^:]*\).*/\1/p' < ~/.nedit)"} diff --git a/Completion/User/_netscape b/Completion/User/_netscape index f176083d2..b29c27c6c 100644 --- a/Completion/User/_netscape +++ b/Completion/User/_netscape @@ -1,8 +1,9 @@ #compdef netscape -local state +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args -_x_arguments \ +_x_arguments -C \ '-xrm:resource:_x_resource' \ '-help[show usage message]' \ '-version[show the version number and build date]' \ @@ -21,55 +22,70 @@ _x_arguments \ -{,no-}{,irix-}session-management \ -{done-save,ignore}-geometry-prefs \ -{component-bar,composer,edit,messenger,mail,discussions,news} \ - '*:location:->urls' + '*:location:->urls' && ret=0 + +[[ "$state" = "urls" ]] && + _files "$@" && return 0 -[ "$state" = "urls" ] && _files "$@" && return # Handle netscape remote commands -if [ "$state" = "remote" ]; then +if [[ "$state" = "remote" ]]; then local -a remote_commands remote_commands=(openURL openFile saveAs mailto addBookmark) [[ $compstate[quoting] = (double|single) ]] && compset -q compset -P '*\(' case $IPREFIX in - openURL*|addBookmark* ) state=urls;; - openFile* ) _files -W ~;; - saveAs* ) + openURL*|addBookmark*) state=urls;; + openFile*) _files -W ~;; + saveAs*) if compset -P "*,"; then - compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript + _wanted types expl 'data type' \ + compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && + ret=0 else - _path_files -W ~ + _files -W ~ && ret=0 fi ;; - mailto* ) + mailto*) compset -P "*," if compset -P '*@'; then - _description expl 'remote host name' - _hosts "$expl[@]" -q -S, + _wanted hosts expl 'remote host name' _hosts -q -S, && ret=0 else - _description expl 'login name' - _users "$expl[@]" -q -S@ + _wanted users expl 'login name' _users -q -S@ && ret=0 fi ;; - * ) - if [ "$QIPREFIX" ]; then - compadd -q -S '(' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands - else - compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands + *) + if _wanted commands; then + if [[ -z "$QIPREFIX" ]]; then + _all_labels commands expl 'remote commands' \ + compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' - \ + $remote_commands && ret=0 + else + _all_labels commands expl 'remote commands' \ + compadd -qS '(' -M 'm:{a-zA-Z}={A-Za-z}' - \ + $remote_commands && ret=0 + fi fi ;; esac fi -if [ "$state" = "urls" ]; then +if [[ "$state" = "urls" ]]; then # Complete netscape urls - if [[ -prefix about: ]]; then - compset -P about: - compadd authors blank cache document fonts global hype image-cache \ - license logo memory-cache mozilla plugins + if compset -P about: ; then + _wanted values expl 'about what' \ + compadd authors blank cache document fonts global hype image-cache \ + license logo memory-cache mozilla plugins && ret=0 else - compadd -S '' about: mocha: javascript: - _urls "$@" + if _wanted prefixes; then + while _next_label prefixes expl 'URL prefix'; do + compadd "$expl[@]" -S '' about: mocha: javascript: && ret=0 + _urls "$@" && ret=0 + (( ret )) || return 0 + done + fi fi fi + +return ret diff --git a/Completion/User/_tiff b/Completion/User/_tiff index bbc331442..8fd008f0f 100644 --- a/Completion/User/_tiff +++ b/Completion/User/_tiff @@ -10,21 +10,22 @@ fi if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then if (( ! $# )); then - _description expl 'picture file' + _description files expl 'picture file' set -- "$expl[@]" fi - _path_files "$@" -g "$pat" || _files "$@" -g '*.(#i)tiff' + _wanted files expl 'picture file' _path_files "$@" -g "$pat" - || + _files "$@" "$expl[@]" -g '*.(#i)tiff' return fi local _in_tiff=yes -local state line ret=1 -typeset -A options +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args case "$words[1]" in tiff2bw) - _arguments \ + _arguments -C \ '-c[specify compression scheme]:compression scheme:->compress' \ '-r[specify rows per strip]:rows per strip:' \ '-R[specify percentage of red channel]:percentage of red channel:' \ @@ -59,7 +60,7 @@ tiffcmp) ':second input TIFF file:_files -g \*.\(\#i\)' && ret=0 ;; tiffcp) - _arguments \ + _arguments -C \ '-B[write output in bin-endian byte order]' \ '-c[specify compression scheme]:compression scheme:->compress' \ '-o[set initial TIFF directory (file offset)]:file offset:' \ @@ -74,7 +75,7 @@ tiffcp) '*:input TIFF file:_files -g \*.\(\#i\)' && ret=0 ;; tiffdither) - _arguments \ + _arguments -C \ '-c[specify compression scheme]:compression scheme:->compress' \ '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ '-r[specify rows per strip]:rows per strip:' \ @@ -102,7 +103,7 @@ tiffinfo) '*:input TIFF file:_files -g \*.\(\#i\)' && ret=0 ;; tiffmedian) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-C[specify number of colormap entries]:number of colormap entries:' \ '-c[specify compression scheme]:compression scheme:->compress' \ @@ -135,14 +136,14 @@ fax2tiff) ':FAX input file:_files -g \*.\(\#i\)\(g\[34\]\|fax\)' && ret=0 ;; gif2tiff) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-c[specify compression scheme]:compression scheme:->compress' \ ':input GIF file:_files -g \*.\(\#i\)gif' \ ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; ppm2tiff) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-c[specify compression scheme]:compression scheme:->compress' \ '-R[specify resolution]:resolution:' \ @@ -150,14 +151,14 @@ ppm2tiff) ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; ras2tiff) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-c[specify compression scheme]:compression scheme:->compress' \ ':input raster image file:_files -g \*.\(\#i\)ras\(\|t\)' \ ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; pal2rgb) - _arguments \ + _arguments -C \ '-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ '-p[set sample packing]:sample packing:(contig separate)' \ '-c[specify compression scheme]:compression scheme:->compress' \ @@ -166,7 +167,7 @@ pal2rgb) ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; *) - _description expl 'picture file' + _description files expl 'picture file' _files "$expl[@]" -g "$pat" && ret=0 esac @@ -194,9 +195,13 @@ if [[ -n "$state" ]]; then ;; esac else - _description expl 'compression scheme' - compadd "$expl[@]" - none g4 packbits && ret=0 - compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 + if _wanted values; then + while _next_label values expl 'compression scheme'; do + compadd "$expl[@]" - none g4 packbits && ret=0 + compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 + (( ret )) || return 0 + done + fi fi fi diff --git a/Completion/User/_urls b/Completion/User/_urls index 19f7eea3a..03e8902cb 100644 --- a/Completion/User/_urls +++ b/Completion/User/_urls @@ -1,65 +1,155 @@ -#autoload +#compdef curl # Usage: _urls [-f] # Options: -# -f : complete files. - -# To complete URLs, you must make a URL database locally such as: +# -f : complete files first. +# +# Configuration styles used: +# +# path +# The path to a directory containing a URL database, such as: +# +# % cd ~/.zsh/urls +# % find . -ls +# ... drwxr-xr-x ... 512 Sep 3 02:46 . +# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http +# ... drwxr-xr-x ... 512 Sep 3 02:52 ./http/www.zsh.org +# ... drwxr-xr-x ... 512 Sep 3 03:01 ./http/www.zsh.org/mla +# ... drwxr-xr-x ... 512 Sep 3 03:01 ./http/www.zsh.org/mla/workers +# ... drwxr-xr-x ... 512 Sep 3 03:01 ./http/www.zsh.org/mla/workers/1999 +# ... -rw-r--r-- ... 0 Sep 3 03:01 ./http/www.zsh.org/mla/workers/1999/index.html +# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http/sunsite.auc.dk +# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http/sunsite.auc.dk/zsh +# ... drwxr-xr-x ... 512 Sep 3 02:47 ./bookmark +# ... drwxr-xr-x ... 512 Sep 3 02:48 ./bookmark/zsh +# ... -rw-r--r-- ... 27 Sep 3 02:47 ./bookmark/zsh/home +# ... -rw-r--r-- ... 20 Sep 3 02:48 ./bookmark/zsh/meta +# % cat bookmark/zsh/home +# http://sunsite.auc.dk/zsh/ +# % cat bookmark/zsh/meta +# http://www.zsh.org/ # -# % cd ~/.zsh/urls -# % find . -ls -# ... drwxr-xr-x ... 512 Sep 3 02:46 . -# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http -# ... drwxr-xr-x ... 512 Sep 3 02:52 ./http/www.zsh.org -# ... drwxr-xr-x ... 512 Sep 3 03:01 ./http/www.zsh.org/mla -# ... drwxr-xr-x ... 512 Sep 3 03:01 ./http/www.zsh.org/mla/workers -# ... drwxr-xr-x ... 512 Sep 3 03:01 ./http/www.zsh.org/mla/workers/1999 -# ... -rw-r--r-- ... 0 Sep 3 03:01 ./http/www.zsh.org/mla/workers/1999/index.html -# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http/sunsite.auc.dk -# ... drwxr-xr-x ... 512 Sep 3 02:48 ./http/sunsite.auc.dk/zsh -# ... drwxr-xr-x ... 512 Sep 3 02:47 ./bookmark -# ... drwxr-xr-x ... 512 Sep 3 02:48 ./bookmark/zsh -# ... -rw-r--r-- ... 27 Sep 3 02:47 ./bookmark/zsh/home -# ... -rw-r--r-- ... 20 Sep 3 02:48 ./bookmark/zsh/meta +# local +# Specify a local web server as an array with three elements: +# <hostname> <doc root> <user area> +# where hostname is the name of the web server, doc root is the path to +# the default web pages for the server and user area is the directory +# name used by a user placing web pages within their home area. +# E.g.: +# zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html -local ipre scheme dirs files +local ipre scheme host user uhosts ret=1 expl +local urls_path localhttp +zstyle -s ":completion:${curcontext}:urls" path urls_path || + urls_path="${ZDOTDIR:-$HOME}/.zsh/urls" +zstyle -a ":completion:${curcontext}:urls" local localhttp +local localhttp_servername="$localhttp[1]" +local localhttp_documentroot="$localhttp[2]" +local localhttp_userdir="$localhttp[3]" if [[ "$1" = -f ]]; then shift - _files "$@" && return -fi - -if [[ -z "$compconfig[_urls_dir]" ]]; then - compconfig[_urls_dir]=${ZDOTDIR:-$HOME}/.zsh/urls + _wanted -C -f files && _files "$@" && return fi ipre="$IPREFIX" -if [[ -prefix [-+.a-z0-9]#: ]]; then - scheme="${PREFIX%%:*}" - compset -P "[-+.a-z0-9]#:" -else - compadd -S '' http:// ftp:// bookmark: - return +if ! compset -P '(#b)([-+.a-z0-9]#):' && _wanted -C argument prefixes; then + while _next_label prefixes expl 'URL prefix' "$@"; do + [[ -d $urls_path/bookmark ]] && + compadd "$expl[@]" -S '' bookmark: && ret=0 + compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0 + (( ret )) || return 0 + done + return ret fi +scheme="$match[1]" case "$scheme" in - http) compset -P // || { compadd "$@" -S '' //; return };; - ftp) compset -P // || { compadd "$@" -S '' //; return };; + http|ftp|gopher) + if ! compset -P //; then + _wanted -C "$scheme" prefixes expl 'end of prefix' compadd "$@" -S '' // + return + fi + ;; + file) + if ! compset -P //; then + _wanted -C file files || return 1 + + while _next_label files expl 'local file' "$@"; do + if [[ -prefix / ]]; then + _path_files "$expl[@]" -S '' -g '*(^/)' && ret=0 + _path_files "$expl[@]" -S/ -r '/' -/ && ret=0 + elif [[ -z "$PREFIX" ]]; then + compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0 + fi + (( ret )) || return 0 + done + return ret + fi + ;; + bookmark) + if [[ -f "$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" && + -s "$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" ]]; then + _wanted -C bookmark bookmarks expl bookmarks \ + compadd "$@" -U - \ + "$ipre$(<"$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0 + else + if _wanted -C bookmark files; then + while _next_label files expl 'bookmark'; do + _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && + ret=0 + _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0 + (( ret )) || return 0 + done + fi + fi + return ret + ;; esac -if [[ "$scheme" = bookmark && - -f "$compconfig[_urls_dir]/$scheme/$PREFIX$SUFFIX" && - -s "$compconfig[_urls_dir]/$scheme/$PREFIX$SUFFIX" ]]; then - compadd "$@" -QU -- "$ipre$(<"$compconfig[_urls_dir]/$scheme/$PREFIX$SUFFIX")" -else - dirs=($compconfig[_urls_dir]/$scheme/$PREFIX*$SUFFIX(/:t)) - files=($compconfig[_urls_dir]/$scheme/$PREFIX*$SUFFIX(.:t)) - compset -P '*/' - compadd "$@" -Q -S '/' - $dirs - if [[ "$scheme" = bookmark ]]; then - compadd "$@" -QS '' - $files +# Complete hosts +if ! compset -P '(#b)([^/]#)/' && _wanted hosts; then + uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t)) + + while _next_label hosts expl host "$@"; do + (( $#uhosts )) || _hosts -S/ && ret=0 + [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername) + compadd "$expl[@]" -S/ - $uhosts && ret=0 + (( ret )) || return 0 + done + return ret +fi +host="$match[1]" + +# Complete part after hostname + +_wanted -C local files || return 1 + +if [[ "$localhttp_servername" = "$host" ]]; then + if compset -P \~; then + if ! compset -P '(#b)([^/]#)/'; then + _users -S/ + return + fi + user="$match[1]" + while _next_label files expl 'local file'; do + _path_files "$expl[@]" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0 + (( ret )) || return 0 + done else - compadd "$@" -Q - $files + while _next_label files expl 'local file'; do + _path_files "$expl[@]" -W $localhttp_documentroot -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0 + (( ret )) || return 0 + done fi +else + while _next_label files expl 'local file'; do + _path_files "$expl[@]" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0 + (( ret )) || return 0 + done fi +return $ret diff --git a/Completion/User/_users b/Completion/User/_users index fc1e87e52..d04731af9 100644 --- a/Completion/User/_users +++ b/Completion/User/_users @@ -1,6 +1,10 @@ -#autoload +#compdef last passwd groups -local expl +local expl users -_description expl user -compgen "$@" "$expl[@]" -u +_wanted users || return 1 + +zstyle -a ":completion:${curcontext}:" users users && + _all_labels users expl user compadd "$@" - "$users[@]" && return 0 + +_all_labels users expl user compadd "$@" - "${(@k)userdirs}" diff --git a/Completion/User/_users_on b/Completion/User/_users_on index 920688089..b19cff6e7 100644 --- a/Completion/User/_users_on +++ b/Completion/User/_users_on @@ -1,10 +1,12 @@ -#autoload write +#compdef write local expl +_wanted users || return 1 + if which users >/dev/null; then - _description expl users logged on - compadd "$@" "$expl[@]" - $(users) && return 0 + _all_labels users expl 'users logged on' \ + compadd "$@" - $(_call users users) && return 0 else # Other methods of finding out users logged on should be added here return 1 diff --git a/Completion/X/_x_colormapid b/Completion/X/_x_colormapid index 4fe6aac42..3c637c1d9 100644 --- a/Completion/X/_x_colormapid +++ b/Completion/X/_x_colormapid @@ -2,7 +2,7 @@ local expl list desc -_wanted colormapids expl 'colormap id' || return 1 +_wanted colormapids || return 1 list=(${(f)"$(xprop -root -f RGB_COLOR_MAP 32xcccccccxx ': $0\n'|awk -F'[ ():]' '/^[a-zA-Z_]+\(RGB_COLOR_MAP\)/ {print $5, "--", $1}')"}) @@ -12,4 +12,5 @@ else desc=() fi -compadd "$expl[@]" "$@" "$desc[@]" - "${(@)list%% *}" +_all_labels colormapids expl 'colormap id' \ + compadd "$@" "$desc[@]" - "${(@)list%% *}" diff --git a/Completion/X/_x_extension b/Completion/X/_x_extension index 967938e28..11e53fa6c 100644 --- a/Completion/X/_x_extension +++ b/Completion/X/_x_extension @@ -2,16 +2,18 @@ local expl -(( $+_xe_cache )) || _xe_cache=( "${(@)${(@f)$(xdpyinfo)}[(r)number of extensions:*,-1][2,(r)default screen number:*][1,-2]//[ ]}" ) +_wanted extensions || return 1 -_description expl 'X extension' +(( $+_xe_cache )) || _xe_cache=( "${(@)${(@f)$(xdpyinfo)}[(r)number of extensions:*,-1][2,(r)default screen number:*][1,-2]//[ ]}" ) if [[ "$1" = -a ]]; then shift - compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - all "$_xe_cache[@]" + _all_labels extensions expl 'X extensions' \ + compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - all "$_xe_cache[@]" else [[ "$1" = - ]] && shift - compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - "$_xe_cache[@]" + _all_labels extensions expl 'X extensions' \ + compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - "$_xe_cache[@]" fi diff --git a/Completion/X/_x_font b/Completion/X/_x_font index e0acb4014..43a713b34 100644 --- a/Completion/X/_x_font +++ b/Completion/X/_x_font @@ -1,3 +1,16 @@ #autoload -_message 'font' +local expl + +_wanted fonts || return 1 + +# This *has* to be improved some day... + +if (( ! $+_font_cache )); then + typeset -gU _font_cache + + _font_cache=( "${(@)^${(@f)$(_call fonts xlsfonts)}%%--*}--" ) +fi + +_all_labels fonts expl font \ + compadd -M 'r:|-=* r:|=*' "$@" -S '' - "$_font_cache[@]" diff --git a/Completion/X/_x_keysym b/Completion/X/_x_keysym index 6b031014a..f50762f7e 100644 --- a/Completion/X/_x_keysym +++ b/Completion/X/_x_keysym @@ -2,6 +2,8 @@ local expl +_wanted keysyms || return 1 + if (( ! $+_keysym_cache )); then local file @@ -16,5 +18,5 @@ if (( ! $+_keysym_cache )); then fi fi -_description expl 'key symbol' -compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - $_keysym_cache +_all_labels keysyms expl 'key symbol' \ + compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - $_keysym_cache diff --git a/Completion/X/_x_window b/Completion/X/_x_window index 118c7f131..1862db9a7 100644 --- a/Completion/X/_x_window +++ b/Completion/X/_x_window @@ -1,19 +1,18 @@ #autoload -setopt localoptions extendedglob - local list expl -list=( "${(@)${(M@)${(@f)$(xwininfo -root -tree)}:#[ ]#0x[0-9a-f]# \"*}##[ ]#}" ) +_wanted windows || return 1 + +list=( "${(@)${(M@)${(@f)$(_call windows xwininfo -root -tree)}:#[ ]#0x[0-9a-f]# \"*}##[ ]#}" ) if [[ "$1" = -n ]]; then shift - _description expl 'window name' - compadd "$@" "$expl[@]" -d list - "${(@)${(@)list#*\"}%%\"*}" + _all_labels windows expl 'window name' \ + compadd "$@" -d list - "${(@)${(@)list#*\"}%%\"*}" else [[ "$1" = - ]] && shift - _description expl 'window ID' - compadd "$@" "$expl[@]" -d list - "${(@)list%% *}" + _all_labels windows expl 'window ID' compadd "$@" -d list - "${(@)list%% *}" fi diff --git a/Completion/X/_xmodmap b/Completion/X/_xmodmap index 0f6514eb6..1cd461d4c 100644 --- a/Completion/X/_xmodmap +++ b/Completion/X/_xmodmap @@ -1,11 +1,9 @@ #compdef xmodmap -setopt localoptions extendedglob +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args -local state line ret=1 -typeset -A options - -_x_arguments \ +_x_arguments -C \ -{help,grammar,verbose,quiet} \ '-n[only show what would be done]' \ '*-e[specify expression]:expression:->expr' \ @@ -57,7 +55,7 @@ if [[ -n "$state" ]]; then pointer*) if compset -P '*=[ ]#'; then compset -P '*[ ]' - _description expl 'button code' + _description values expl 'button code' compadd "$expl[@]" -qS ' ' 1 2 3 4 5 default return else @@ -84,9 +82,13 @@ if [[ -n "$state" ]]; then [[ "$what" = *ksym* ]] && _x_keysym "$suf[@]" && ret=0 else - _description expl command - compadd "$expl[@]" -S ' ' keycode keysym clear add remove && ret=0 - compadd "$expl[@]" -S ' = ' pointer && ret=0 + if _wanted commands; then + while _next_label commands expl command; do + compadd "$expl[@]" -S ' ' keycode keysym clear add remove && ret=0 + compadd "$expl[@]" -S ' = ' pointer && ret=0 + (( ret )) || return 0 + done + fi fi fi diff --git a/Completion/X/_xutils b/Completion/X/_xutils index 1818b447f..4eea8ded1 100644 --- a/Completion/X/_xutils +++ b/Completion/X/_xutils @@ -8,7 +8,7 @@ xdpyinfo) ;; xwininfo) _x_arguments \ - -{help,int,stats,bits,events,size,wm,shape,frame,all,english,metric} \ + -{help,int,children,tree,stats,bits,events,size,wm,shape,frame,all,english,metric} \ '(-id -name)-root' \ '(-id -root)-name:name: _x_window -n' \ '(-name -root)-id:id: _x_window' @@ -46,12 +46,33 @@ xev) '-rv' ;; xhost) - local expl type ret=1 + local expl type ret=1 tmp if compset -P '-'; then - _description expl 'disallow access' - compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - \ - "${${(@M)${(@f)$(xhost)}[2,-1]:#LOCAL:*}#INET:}" + tmp=(${(f)"$(xhost)"}) + shift tmp + tmp=(${tmp:#LOCAL:|<*>}) + if [[ "$tmp" = *:* ]]; then + if compset -P '(#b)(*):'; then + type="$match[1]" + _wanted displays && + while _next_label displays expl 'disallow access'; do + { compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - \ + ${${(M)tmp:#(#i)$type:*}#(#i)$type:} || + _hosts "$expl[@]" } && return 0 + done + else + _alternative \ + 'types:name family:compadd -S: ${(L)tmp%%:*}' \ + 'hosts:host:compadd ${(@)tmp#*:}' && ret=0 + fi + else + _wanted displays && + while _next_label displays expl 'disallow access'; do + { compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - $tmp || + _hosts "$expl[@]" } && return 0 + done + fi else compset -P + @@ -66,9 +87,9 @@ xhost) krb) _message 'Kerberos V5 principal';; esac else - _description expl 'name family' - compadd -S: - inet dnet nis krb && ret=0 - _hosts && ret=0 + _alternative \ + 'types:name family:compadd -S: - inet dnet nis krb' \ + 'hosts:: _hosts' && ret=0 fi return ret fi @@ -120,7 +141,7 @@ xrdb) '(-global -all -screens)-screen' \ '(-global -all -screen)-screens' \ '-n[only display on stdout]' \ - '(-nocpp)-cpp:preprocessor program:_files -g \*\(\*\)' \ + '(-nocpp)-cpp:preprocessor program:_files -g \*\(-\*\)' \ '(-cpp)-nocpp' \ '(-load -override -merge -remove)-query' \ '(-query -override -merge -remove)-load' \ @@ -131,6 +152,7 @@ xrdb) '-backup:backup extension:' \ '*-D-:symbol to define:' \ '*-U-:symbol to undefine:' \ - '*-I-:include directory:_files -/' + '*-I-:include directory:_files -/' \ + '*:defaults file:_files' ;; esac diff --git a/Completion/X/_xwit b/Completion/X/_xwit index e86443a32..998627869 100644 --- a/Completion/X/_xwit +++ b/Completion/X/_xwit @@ -16,8 +16,8 @@ _xwit_guard () { _xwit_compopts () { local expl - _description options expl option - compadd "$expl[@]" - ${(k)no[(R)*~0]} || compadd "$expl[@]" - ${(k)no} + _wanted options expl option compadd - ${(k)no[(R)*~0]} || + _all_labels options expl option compadd - ${(k)no} } _regex_arguments _xwit_parse \ @@ -39,8 +39,8 @@ _regex_arguments _xwit_parse \ \| "/iconmove$nul/" "$guard" "/$word/" ":_message x" "/$word/" ":_message y" \ \| "/id$nul/" "$guard" "/$word/" ":_x_window" \ \| "/(no|)keyrepeat$nul/" "$guard" \ - \( "/[0-9]##$nul/" ":_message keycode" \ - \( "/-$nul/" "/[0-9]##$nul/" ":_message 'last keycode'" \| \) \) \# \ + \( "/[0-9]##$nul/" ":[[ -prefix [0-9]# ]] && _message keycode" \ + \( "/-$nul/" "/[0-9]##$nul/" ":[[ -prefix [0-9]# ]] && _message 'last keycode'" \| \) \) \# \ \| "/names$nul/" "$guard" "/$word/" ":_x_window -n" \# \ \| "/[]/" ':_xwit_compopts' \ \) \ diff --git a/Config/version.mk b/Config/version.mk index 5ed093b1b..c328c8dce 100644 --- a/Config/version.mk +++ b/Config/version.mk @@ -27,5 +27,5 @@ # This must also serve as a shell script, so do not add spaces around the # `=' signs. -VERSION=3.1.5 -VERSION_DATE='October 29, 1998' +VERSION=3.1.6-dev-21 +VERSION_DATE='April 1, 2000' diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 8959543c5..cb7372cc5 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -17,17 +17,26 @@ item(tt(ARG1))( Same as tt(ARG2). )\ )\ +def(module)(2)(\ +item(tt(ARG1))( +See ifzman(the section `The ARG2 Module' in zmanref(zshmodules))\ +ifnzman(noderef(The ARG2 Module)). +)\ +)\ startitem() prefix(-) findex(.) item(tt(.) var(file) [ var(arg) ... ])( Read commands from var(file) and execute them in the current shell environment. -If var(file) does not contain a slash, or if tt(PATH_DIRS) -is set, the shell looks in the components of tt($path) to find the -directory containing var(file). -Files in the current directory are not read unless `tt(.)' appears -somewhere in tt($path). + +If var(file) does not contain a slash, or if tt(PATH_DIRS) is set, +the shell looks in the components of tt($path) to find the directory +containing var(file). Files in the current directory are not read +unless `tt(.)' appears somewhere in tt($path). If a file named +`var(file)tt(.zwc)' is found, is newer than var(file), and is the +compiled form (created with the tt(zcompile) builtin) of var(file), +then commands are read from that file instead of var(file). If any arguments var(arg) are given, they become the positional parameters; the old positional @@ -39,15 +48,16 @@ cindex(expanding parameters) cindex(parameters, expanding) cindex(doing nothing) item(tt(:) [ var(arg) ... ])( -This command only expands parameters. A zero exit code is returned. +This command does nothing, although normal argument expansions is performed +which may have effects on shell parameters. A zero exit code is returned. ) findex(alias) cindex(aliases, defining) cindex(aliases, listing) -item(tt(alias) [ tt(-gmrL) ] [ var(name)[tt(=)var(value)] ... ])( +item(tt(alias) [ {tt(PLUS()|tt(-))}tt(gmrL) ] [ var(name)[tt(=)var(value)] ... ])( For each var(name) with a corresponding var(value), define an alias with that value. A trailing space in var(value) causes the next word -to be checked for alias substitution. If the tt(-g) flag is present, +to be checked for alias expansion. If the tt(-g) flag is present, define a global alias; global aliases are expanded even if they do not occur in command position. @@ -58,7 +68,9 @@ are taken as patterns (they should be quoted to preserve them from being interpreted as glob patterns), and the aliases matching these patterns are printed. When printing aliases and the tt(-g) or tt(-r) flags are present, then restrict the printing to global or regular -aliases, respectively. +aliases, respectively. Using `tt(PLUS())' instead of `tt(-)', or ending +the option list with a single `tt(PLUS())', prevents the values of the +aliases from being printed. If the tt(-L) flag is present, then print each alias in a manner suitable for putting in a startup script. The exit @@ -68,7 +80,38 @@ which no alias has been defined. findex(autoload) cindex(functions, autoloading) cindex(autoloading functions) -alias(autoload)(functions -u) +item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXmt) ] [ tt(-wkz) ] [ var(name) ... ])( +Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X), +tt(-w), tt(-k) and tt(-z). + +The flag tt(-X) may be used only inside a shell function, and may not be +followed by a var(name). It causes the calling function to be marked for +autoloading and then immediately loaded and executed, with the current +array of positional parameters as arguments. This replaces the previous +definition of the function. If no function definition is found, an error +is printed and the function remains undefined and marked for autoloading. + +The flag tt(+X) attempts to load each var(name) as an autoloaded function, +but does em(not) execute it. The exit status is zero (success) if the +function was not previously defined em(and) a definition for it was found. +This does em(not) replace any existing definition of the function. The +exit status is nonzero (failure) if the function was already defined or +when no definition was found. In the latter case the function remains +undefined and marked for autoloading. + +The flag tt(+X) may be combined with either tt(-k) or tt(-z) to make +the function be loaded using ksh-style or zsh-style autoloading, +respectively. If neither is given, the current setting of the +tt(KSH_AUTOLOAD) options determines how the function is loaded. With +ksh-style autoloading, the contents of the file will not be executed +immediatly. Instead, the function created will contain the contents of +the file plus a call to the function itself appended to it, thus given +normal ksh autoloading behaviour on the first call to the function. + +With the tt(-w) flag, the var(name)s are taken as names of files compiled +with the tt(zcompile) builtin, and all functions defined in them are +marked for autoloading. +) findex(bg) cindex(jobs, backgrounding) xitem(tt(bg) [ var(job) ... ]) @@ -76,6 +119,7 @@ item(var(job) ... tt(&))( Put each specified var(job) in the background, or the current job if none is specified. ) +module(bindkey)(zsh/zle) findex(break) cindex(exiting loops) cindex(loops, exiting) @@ -89,6 +133,7 @@ item(tt(builtin) var(name) [ var(args) ... ])( Executes the builtin var(name), with the given var(args). ) alias(bye)(exit) +module(cap)(zsh/cap) findex(cd) cindex(directories, changing) xitem(tt(cd) [ tt(-sLP) ] [ var(arg) ]) @@ -98,12 +143,13 @@ Change the current directory. In the first form, change the current directory to var(arg), or to the value of tt($HOME) if var(arg) is not specified. If var(arg) is `tt(-)', change to the value of tt($OLDPWD), the previous directory. -If a directory named var(arg) is not found in the current directory -and var(arg) does not begin with a slash, -search each component of the shell parameter tt(cdpath). -If the option tt(CDABLE_VARS) is set, and a parameter named var(arg) -exists whose value begins with a slash, treat its value as -the directory. +Otherwise, if a directory named var(arg) is not found in the current +directory and var(arg) does not begin with a slash, search each +component of the shell parameter tt(cdpath). If no directory is found +and the option tt(CDABLE_VARS) is set, and a parameter named var(arg) +exists whose value begins with a slash, treat its value as the +directory. In that case, the parameter is added to the named +directory hash table. The second form of tt(cd) substitutes the string var(new) for the string var(old) in the name of the current directory, @@ -124,7 +170,16 @@ to their true values. If the tt(-L) option is given symbolic links are followed regardless of the state of the tt(CHASE_LINKS) option. ) alias(chdir)(cd) +module(clone)(zsh/clone) prefix(command) +module(comparguments)(zsh/computil) +module(compcall)(zsh/compctl) +module(compctl)(zsh/compctl) +module(compdescribe)(zsh/computil) +module(compquote)(zsh/computil) +module(comptags)(zsh/computil) +module(comptry)(zsh/computil) +module(compvalues)(zsh/computil) findex(continue) cindex(loops, continuing) cindex(continuing loops) @@ -158,8 +213,8 @@ causes tt(disable) to act on aliases. The tt(-f) option causes tt(disable) to act on shell functions. The tt(-r) options causes tt(disable) to act on reserved words. Without arguments all disabled hash table elements from the corresponding hash table are printed. -With the tt(-m) flag the arguments are taken as patterns (should be -quoted to preserve them from being taken as glob patterns), and all hash +With the tt(-m) flag the arguments are taken as patterns (which should be +quoted to prevent them from undergoing filename expansion), and all hash table elements from the corresponding hash table matching these patterns are disabled. Disabled objects can be enabled with the tt(enable) command. @@ -214,13 +269,29 @@ cindex(compatibility, csh) cindex(sh, compatibility) cindex(ksh, compatibility) cindex(csh, compatibility) -item(tt(emulate) [ tt(-R) ] {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)})( +item(tt(emulate) [ tt(-LR) ] {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)})( Set up zsh options to emulate the specified shell as much as possible. bf(csh) will never be fully emulated. If the argument is not one of the shells listed above, tt(zsh) -will be used as a default. If the tt(-R) option is given, all options +will be used as a default; more precisely, the tests performed on the +argument are the same as those used to determine the emulation at startup +based on the shell name, see +ifzman(\ +the section `Compatibility' in zmanref(zshmisc) +)\ +ifnzman(\ +noderef(Compatibility) +)\ +. If the tt(-R) option is given, all options are reset to their default value corresponding to the specified emulation -mode. +mode, except for certain options describing the interactive +environment; otherwise, only those options likely to cause portability +problems in scripts and functions are altered. If the tt(-L) option +is given, the options tt(LOCAL_OPTIONS) and tt(LOCAL_TRAPS) will be set as +well, causing the effects of the tt(emulate) command and any tt(setopt) and +tt(trap) commands to be local to the immediately surrounding shell +function, if any; normally these options are turned off in all emulation +modes except tt(ksh). ) findex(enable) cindex(enabling commands) @@ -256,8 +327,7 @@ findex(export) item(tt(export) [ var(name)[tt(=)var(value)] ... ])( The specified var(name)s are marked for automatic export to the environment of subsequently executed commands. -Equivalent to tt(typeset -x), except that no parameter will be created -to hide an existing one in an outer scope. +Equivalent to tt(typeset -gx). If a parameter specified does not already exist, it is created in the global scope. ) @@ -308,13 +378,16 @@ With the tt(-D) flag, tt(fc) prints elapsed times. cindex(history, file) cindex(file, history) -tt(fc -R) reads the history from the given file, -tt(fc -W) writes the history out to the given file, -and tt(fc -A) appends the history out to the given file. -If the tt(-I) option is added, only those -events that are new since last incremental append (write) to -the history file are appended (written). -In any case the file will have no more than tt($SAVEHIST) +`tt(fc -R)' reads the history from the given file, +`tt(fc -W)' writes the history out to the given file, +and `tt(fc -A)' appends the history out to the given file. +If no filename is specified, the tt($HISTFILE) is assumed. +If the tt(-I) option is added to tt(-R), only those events that are +not already contained within the internal history list are added. +If the tt(-I) option is added to tt(-A) or tt(-W), only those +events that are new since last incremental append/write to +the history file are appended/written. +In any case, the created file will have no more than tt($SAVEHIST) entries. ) findex(fg) @@ -325,10 +398,16 @@ item(var(job) ...)( Bring each specified var(job) in turn to the foreground. If no var(job) is specified, resume the current job. ) +findex(float) +item(tt(float) [ {tt(PLUS())|tt(-)}tt(EFghlrtux) ] [ var(name)[tt(=)var(value)] ... ])( +Equivalent to tt(typeset -E), except that options irrelevant to floating +point numbers are not permitted. +) findex(functions) -item(tt(functions) [ {tt(PLUS())|tt(-)}tt(tum) ] [ var(name) ... ])( +item(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXmtu) ] [ var(name) ... ])( Equivalent to tt(typeset -f). ) +module(getcap)(zsh/cap) findex(getln) cindex(line, reading) cindex(reading a line) @@ -357,11 +436,20 @@ is stored in tt(OPTARG). vindex(OPTIND, use of) vindex(OPTARG, use of) +The first option to be examined may be changed by explicitly assigning +to tt(OPTIND). tt(OPTIND) has an initial value of tt(1), and is +normally reset to tt(1) upon exit from a shell function. tt(OPTARG) +is not reset and retains its value from the most recent call to +tt(getopts). If either of tt(OPTIND) or tt(OPTARG) is explicitly +unset, it remains unset, and the index or option argument is not +stored. The option itself is still stored in var(name) in this case. + A leading `tt(:)' in var(optstring) causes tt(getopts) to store the -letter of the invalid option in tt(OPTARG), and to set var(name) -to `tt(?)' for an unknown option and to `tt(:)' when a required option -is missing. Otherwise, tt(getopts) prints an error -message. The exit status is nonzero when there are no more options. +letter of any invalid option in tt(OPTARG), and to set var(name) to +`tt(?)' for an unknown option and to `tt(:)' when a required option is +missing. Otherwise, tt(getopts) sets var(name) to `tt(?)' and prints +an error message when an option is invalid. The exit status is +nonzero when there are no more options. ) findex(hash) item(tt(hash) [ tt(-dfmrv) ] [ var(name)[tt(=)var(value)] ] ...)( @@ -386,7 +474,7 @@ and for the named directory hash table this adds all users' home directories. These two options cannot be used with any arguments. The tt(-m) option causes the arguments to be taken as patterns -(they should be quoted) and the elements of the hash table +(which should be quoted) and the elements of the hash table matching those patterns are printed. This is the only way to display a limited selection of hash table elements. @@ -409,7 +497,7 @@ added by explicit specification. If has no effect if used with tt(-f). ) alias(history)(fc -l) findex(integer) -item(tt(integer) [ {tt(PLUS())|tt(-)}tt(lrtux) ] [ var(name)[tt(=)var(value)] ... ])( +item(tt(integer) [ {tt(PLUS())|tt(-)}tt(ghlrtux) ] [ var(name)[tt(=)var(value)] ... ])( Equivalent to tt(typeset -i), except that options irrelevant to integers are not permitted. ) @@ -475,18 +563,23 @@ If no var(resource) is given, print all limits. var(resource) can be one of: startsitem() -sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.) -sitem(tt(resident))(Maximum resident set size.) -sitem(tt(vmemorysize))(Maximum amount of virtual memory.) -sitem(tt(descriptors))(Maximum value for a file descriptor.) +sitem(tt(addressspace))(Maximum amount of address space used.) +sitem(tt(aiomemorylocked))(Maximum amount of memory locked in RAM for AIO operations.) +sitem(tt(aiooperations))(Maximum number of AIO operations.) +sitem(tt(cachedthreads))(Maximum number of cached threads.) sitem(tt(coredumpsize))(Maximum size of a core dump.) -sitem(tt(stacksize))(Maximum stack size for each process.) +sitem(tt(cputime))(Maximum CPU seconds per process.) sitem(tt(datasize))(Maximum data size (including stack) for each process.) +sitem(tt(descriptors))(Maximum value for a file descriptor.) sitem(tt(filesize))(Largest single file allowed.) -sitem(tt(cputime))(Maximum CPU seconds per process.) sitem(tt(maxproc))(Maximum number of processes.) -sitem(tt(addressspace))(Maximum amount of address space used.) -sitem(tt(cachedthreads))(Maximum number of cached threads.) +sitem(tt(maxpthreads))(Maximum number of threads per process.) +sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.) +sitem(tt(memoryuse))(Maximum resident set size.) +sitem(tt(resident))(Maximum resident set size.) +sitem(tt(sockbufsize))(Maximum size of all socket buffers.) +sitem(tt(stacksize))(Maximum stack size for each process.) +sitem(tt(vmemorysize))(Maximum amount of virtual memory.) endsitem() Which of these resource limits are available depends on the system. @@ -502,8 +595,8 @@ sitem([var(mm)tt(:)]var(ss))(minutes and seconds) endsitem() ) findex(local) -item(tt(local) [ {tt(PLUS())|tt(-)}tt(LRZilrtu) [var(n)]] [ var(name)[tt(=)var(value)] ] ...)( -Same as tt(typeset), except that the options tt(-x) and +item(tt(local) [ {tt(PLUS())|tt(-)}tt(AEFLRUZahilrtu) [var(n)]] [ var(name)[tt(=)var(value)] ] ...)( +Same as tt(typeset), except that the options tt(-g), tt(-x) and tt(-f) are not permitted. ) findex(log) @@ -521,8 +614,8 @@ Same as tt(exit), except that it only works in a login shell. prefix(noglob) findex(popd) item(tt(popd) [ {tt(PLUS())|tt(-)}var(n) ])( -Removes a entry from the directory stack, and perform a tt(cd) to -the new top directory. With no argument, the current top entry is +Remove an entry from the directory stack, and perform a tt(cd) to +the new top directory. With no argument, the current top entry is removed. An argument of the form `tt(PLUS())var(n)' identifies a stack entry by counting from the left of the list shown by the tt(dirs) command, starting with zero. An argument of the form tt(-n) counts from the right. @@ -531,7 +624,7 @@ If the tt(PUSHD_MINUS) option is set, the meanings of `tt(PLUS())' and `tt(-)' in this context are swapped. ) findex(print) -item(tt(print) [ tt(-nrslzpNDPoOicm) ] [ tt(-u)var(n) ] [ tt(-R) [ tt(-en) ]] [ var(arg) ... ])( +item(tt(print) [ tt(-bnrslzpNDPoOicm) ] [ tt(-u)var(n) ] [ tt(-R) [ tt(-en) ]] [ var(arg) ... ])( With no flags or with flag `tt(-)', the arguments are printed on the standard output as described by tt(echo), with the following differences: the escape sequence `tt(\M-)var(x)' metafies the character @@ -551,6 +644,13 @@ unless the tt(-e) flag is given. The tt(-n) flag suppresses the trailing newline. Only the tt(-e) and tt(-n) flags are recognized after tt(-R); all other arguments and options are printed. ) +item(tt(-b))( +Recognize all the escape sequences defined for the tt(bindkey) command, +see +ifzman(zmanref(zshmodules))\ +ifnzman(noderef(The zsh/zle Module))\ +. +) item(tt(-m))( Take the first argument as a pattern (should be quoted), and remove it from the argument list together with subsequent arguments that @@ -575,8 +675,8 @@ item(tt(-O))( Print the arguments sorted in descending order. ) item(tt(-i))( -If given together with tt(-o) or tt(-O), makes them work case -independently. +If given together with tt(-o) or tt(-O), sorting is performed +case-independently. ) item(tt(-c))( Print the arguments in columns. @@ -615,21 +715,9 @@ If var(arg) is not specified, change to the second directory on the stack (that is, exchange the top two entries), or change to tt($HOME) if the tt(PUSHD_TO_HOME) option is set or if there is only one entry on the stack. - -If var(arg) is `tt(-)', change to tt($OLDPWD), the previous directory. -If a directory named var(arg) is not found in the current directory -and var(arg) does not contain a slash, -search each component of the shell parameter tt(cdpath). -If the option tt(CDABLE_VARS) is set, and a parameter named var(arg) -exists whose value begins with a slash, treat its value as -the directory. - -If the option tt(PUSHD_SILENT) is not set, the directory -stack will be printed after a tt(pushd) is performed. - -The second form of tt(pushd) substitutes the string var(new) -for the string var(old) in the name of the current directory, -and tries to change to this new directory. +Otherwise, var(arg) is interpreted as it would be by tt(cd). +The meaning of var(old) and var(new) in the second form is also +the same as for tt(cd). The third form of tt(pushd) changes directory by rotating the directory list. An argument of the form `tt(PLUS())var(n)' identifies a stack @@ -637,6 +725,9 @@ entry by counting from the left of the list shown by the tt(dirs) command, starting with zero. An argument of the form `tt(-)var(n)' counts from the right. If the tt(PUSHD_MINUS) option is set, the meanings of `tt(PLUS())' and `tt(-)' in this context are swapped. + +If the option tt(PUSHD_SILENT) is not set, the directory +stack will be printed after a tt(pushd) is performed. ) findex(pushln) item(tt(pushln) [ var(arg) ... ])( @@ -672,12 +763,16 @@ Read only one character from the terminal and set var(name) to With this flag set the return value is zero only if the character was `tt(y)' or `tt(Y)'. Note that this always reads from the terminal, even if used with the tt(-p) or tt(-u) or tt(-z) flags or with redirected input. +This option may also be used within zle widgets. ) item(tt(-k) [ var(num) ])( Read only one (or var(num)) characters. All are assigned to the first var(name), without word splitting. This flag is ignored when tt(-q) is present. Input is read from the terminal unless one of tt(-u) or tt(-p) -is present. +is present. This option may also be used within zle widgets. + +Note that var(num) must be in the argument word that follows tt(-k), not +in the same word. See tt(-u). ) item(tt(-z))( Read one entry from the editor buffer stack and assign it to the first @@ -714,7 +809,8 @@ and that when the cursor is at the end of the line, its character index is the length of the line plus one. ) item(tt(-u)var(n))( -Input is read from file descriptor var(n). +Input is read from file descriptor var(n), where var(n) is a single +digit and must em(not) be separated from tt(-u) by any whitespace. ) item(tt(-p))( Input is read from the coprocess. @@ -727,7 +823,8 @@ is interactive. The value (exit status) of tt(read) is 1 when an end-of-file is encountered, or when tt(-c) or tt(-l) is present and the command is -not called from a tt(compctl) function. Otherwise the value is 0. +not called from a tt(compctl) function, or as described for tt(-q). +Otherwise the value is 0. The behavior of some combinations of the tt(-k), tt(-p), tt(-q), tt(-u) and tt(-z) flags is undefined. Presently tt(-q) cancels all the others, @@ -757,6 +854,7 @@ trap is passed as the first argument, so the statement `tt(return $((128PLUS()$1)))' will return the same status as if the signal had not been trapped. ) +module(sched)(zsh/sched) findex(set) cindex(parameters, listing) cindex(parameters, positional) @@ -781,6 +879,7 @@ given, then the names and values of all parameters are printed on the standard output. If the only argument is `tt(PLUS())', the names of all parameters are printed. ) +module(setcap)(zsh/cap) findex(setopt) cindex(options, setting) item(tt(setopt) [ {tt(PLUS())|tt(-)}var(options) | \ @@ -789,8 +888,8 @@ Set the options for the shell. All options specified either with flags or by name are set. If no arguments are supplied, the names of all options currently set are printed. If the tt(-m) flag is given the arguments are taken as patterns -(which should be quoted to preserve them from being interpreted as glob -patterns), and all options with names matching these patterns are set. +(which should be quoted to protect them from filename expansion), and all +options with names matching these patterns are set. ) findex(shift) cindex(parameters, positional) @@ -806,6 +905,7 @@ item(tt(source) var(file) [ var(arg) ... ])( Same as tt(.), except that the current directory is always searched and is always searched first, before directories in tt($path). ) +module(stat)(zsh/stat) findex(suspend) cindex(shell, suspending) cindex(suspending the shell) @@ -831,11 +931,12 @@ findex(trap) cindex(signals, trapping) cindex(trapping signals) item(tt(trap) [ var(arg) [ var(sig) ... ] ])( -var(arg) is a command to be read and executed when the shell +var(arg) is a series of commands (usually quoted to protect it from +immediate evaluation by the shell) to be read and executed when the shell receives var(sig). Each var(sig) can be given as a number or as the name of a signal. If var(arg) is `tt(-)', then all traps var(sig) are reset to their -default values. If var(arg) is the null string, then this signal +default values. If var(arg) is the empty string, then this signal is ignored by the shell and by the commands it invokes. If var(sig) is tt(ZERR) then var(arg) will be executed @@ -851,6 +952,20 @@ then the command var(arg) is executed when the shell terminates. The tt(trap) command with no arguments prints a list of commands associated with each signal. + +Note that traps defined with the tt(trap) builtin are slightly different +from those defined as `tt(TRAP)var(NAL) () { ... }', as the latter have +their own function environment (line numbers, local variables, etc.) while +the former use the environment of the command in which they were called. +For example, + +example(trap 'print $LINENO' DEBUG) + +will print the line number of a command executed after it has run, while + +example(TRAPDEBUG() { print $LINENO; }) + +will always print the number zero. ) findex(true) cindex(doing nothing, successfully) @@ -876,21 +991,83 @@ Equivalent to tt(whence -v). findex(typeset) cindex(parameters, setting) cindex(parameters, declaring) -item(tt(typeset) [ {tt(PLUS())|tt(-)}tt(LRUZfilrtuxm) [var(n)]] [ var(name)[tt(=)var(value)] ... ])( -Set attributes and values for shell parameters. -When invoked inside a function a new parameter is created which will be -unset when the function completes. The new parameter will not be -exported unless tt(ALL_EXPORT) is set, in which case the parameter will be -exported provided no parameter of that name already exists. -The following attributes are valid: +xitem(tt(typeset) [ {tt(PLUS())|tt(-)}tt(AEFLRUZafghilrtuxm) [var(n)]] [ \ +var(name)[tt(=)var(value)] ... ]) +item(tt(typeset) -T [ {tt(PLUS()|tt(-))}tt(LRUZrux) ] \ + var(SCALAR)[tt(=)var(value)] var(array))( +Set or display attributes and values for shell parameters. + +A parameter is created for each var(name) that does not already refer +to one. When inside a function, a new parameter is created for every +var(name) (even those that already exist), and is unset again when the +function completes. See +ifzman(`Local Parameters' in zmanref(zshparam))\ +ifnzman(noderef(Local Parameters))\ +. Local parameters are not exported unless tt(ALL_EXPORT) is set, in +which case the parameter is exported em(only) when var(name) does not +already exist. The same rules apply to special shell parameters, which +retain their special attributes when made local. + +For each var(name)tt(=)var(value) assignment, the parameter +var(name) set to var(value). Note that arrays currently cannot be +assigned in tt(typeset) expressions, only scalars and integers. + +For each remaining var(name) that refers to a parameter that is set, the +name and value of the parameter are printed in the form of an assignment. +Nothing is printed for newly-created parameters, or if any attribute flags +listed below are given. Using `tt(PLUS())' instead of minus to introduce +an attribute turns it off. + +If the tt(-T) option is given, exactly two (or zero) var(name) +arguments must be present. They represent a scalar and an array (in +that order) that will be tied together in the manner of tt($PATH) and +tt($path). In other words, an array present in the latter variable +appears as a scalar with the elements of the array joined by colons in +the former. Only the scalar may have an initial value. Both the +scalar and the array may otherwise be manipulated as normal. If one +is unset, the other will automatically be unset too. There is no way +of untying the variables without unsetting them, or converting the +type of one them with another tt(typeset) command; tt(+T) does not work, +assigning an array to var(SCALAR) is an error, and assigning a scalar +to var(array) sets it to be a single-element array. Note that +both tt(typeset -xT ...) and tt(export -T ...) work, but only the +scalar will be marked for export. + +The flag tt(-g) (global) flag is treated specially: it means that any +resulting parameter will not be restricted to local scope. Note that this +does not necessarily mean that the parameter will be global, as the flag +will apply to any existing parameter (even if unset) from an enclosing +function. This flag does not affect the parameter after creation, hence it +has no effect when listing existing parameters, nor does the flag tt(+g) +have any effect. + +If no var(name) is present, the names and values of all parameters are +printed. In this case the attribute flags restrict the display to only +those parameters that have the specified attributes, and using `tt(PLUS())' +rather than `tt(-)' to introduce the flag suppresses printing of the values +of parameters when there is no parameter name. Also, if the option list +ends with `tt(PLUS())', values will not be printed. If only the tt(-m) +flag is given the arguments are taken as patterns (which should be quoted) +and all parameters (or functions with the tt(-f) flag) with matching names +are printed. If no attribute flags and no tt(-m) flag is present, the +parameter names will be preceded by a list of any attributes (tt(array), +tt(association), tt(exported), tt(integer), tt(readonly)). + +The following attribute flags may be specified: startitem() +item(tt(-A))( +The names refer to associative array parameters; see +ifzman(`Array Parameters' in zmanref(zshparam))\ +ifnzman(noderef(Array Parameters))\ +. +) item(tt(-L))( Left justify and remove leading blanks from var(value). If var(n) is nonzero, it defines the width of the field; otherwise it is determined by the width of the value of the first assignment. -When the parameter is printed, it is filled on the right with +When the parameter is expanded, it is filled on the right with blanks or truncated if necessary to fit the field. Leading zeros are removed if the tt(-Z) flag is also set. ) @@ -899,13 +1076,14 @@ Right justify and fill with leading blanks. If var(n) is nonzero if defines the width of the field; otherwise it is determined by the width of the value of the first assignment. -When the parameter is printed, the field is left filled with +When the parameter is expanded, the field is left filled with blanks or truncated from the end. ) item(tt(-U))( -For arrays keep only the first element of each duplications. It can also be -set for colon separated special parameters like tt(PATH) or tt(FIGNORE), -etc. +For arrays (but not for associative arrays), keep only the first +occurrence of each duplicated value. This may also be set for +colon-separated special parameters like tt(PATH) or tt(FIGNORE), etc. +This flag has a different meaning when used with tt(-f); see below. ) item(tt(-Z))( Right justify and fill with leading zeros if the first non-blank @@ -914,51 +1092,83 @@ If var(n) is nonzero it defines the width of the field; otherwise it is determined by the width of the value of the first assignment. ) +item(tt(-a))( +The names refer to array parameters. An array parameter may be +created this way, but it may not be assigned to in the tt(typeset) +statement. When displaying, both normal and associative arrays are +shown. +) 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(-h))( +Hide: only useful for special parameters (those marked `<S>' in the table in +ifzman(zmanref(zshparams))\ +ifnzman(noderef(Parameters))\ +), and for local parameters with the same name as a special parameter, +though harmless for others. A special parameter with this attribute will +not retain its special effect when made local. Thus after `tt(typeset -h +PATH)', a function containing `tt(typeset PATH)' will create an ordinary +local parameter without the usual behaviour of tt(PATH). Alternatively, +the local parameter may itself be given this attribute; hence inside a +function `tt(typeset -h PATH)' creates an ordinary local parameter and the +special tt(PATH) parameter is not altered in any way. It is also possible +to create a local parameter using `tt(typeset +h )var(special)', where the +local copy of var(special) will retain its special properties regardless of +having the tt(-h) attribute. Global special parameters loaded from shell +modules (currently those in tt(mapfile) and tt(parameter)) are +automatically given the tt(-h) attribute to avoid name clashes. ) item(tt(-i))( -Use an internal integer representation. If var(n) is nonzero -it defines the output arithmetic base, otherwise it is determined by the first -assignment. +Use an internal integer representation. If var(n) is nonzero it +defines the output arithmetic base, otherwise it is determined by the +first assignment. +) +item(tt(-E))( +Use an internal double-precision floating point representation. On output +the variable will be converted to scientific notation. If var(n) is +nonzero it defines the number of significant figures to display; the +default is ten. +) +item(tt(-F))( +Use an internal double-precision floating point representation. On output +the variable will be converted to fixed-point decimal notation. If var(n) +is nonzero it defines the number of digits to display after the decimal +point; the default is ten. ) item(tt(-l))( -Convert to lower case. +Convert the result to lower case whenever the parameter is expanded. +The value is em(not) converted when assigned. ) item(tt(-r))( The given var(name)s are marked readonly. ) item(tt(-t))( Tags the named parameters. Tags have no special meaning to the shell. +This flag has a different meaning when used with tt(-f); see above. ) item(tt(-u))( -Convert to upper case. +Convert the result to upper case whenever the parameter is expanded. +The value is em(not) converted when assigned. +This flag has a different meaning when used with tt(-f); see above. ) item(tt(-x))( Mark for automatic export to the environment of subsequently executed commands. ) enditem() - -Using `tt(PLUS())' rather than `tt(-)' causes these flags to be turned off. -If no arguments are given but flags are specified, -a list of named parameters which have these flags set is printed. -Using `tt(PLUS())' instead of `tt(-)' keeps their values from being printed. -If no arguments or options are given, the names and attributes -of all parameters are printed. If only the tt(-m) flag is given the -arguments are taken as patterns (should be quoted) and all parameters -or functions (with the tt(-f) flag) with matching names are printed. ) findex(ulimit) cindex(resource limits) cindex(limits, resource) -item(tt(ulimit) [ tt(-SHacdflmnpstv) [ tt(limit) ] ... ])( +item(tt(ulimit) [ tt(-SHacdflmnpstv) [ var(limit) ] ... ])( Set or display resource limits of the shell and the processes started by the shell. The value of var(limit) can be a number in the unit specified below or the value `tt(unlimited)'. If the tt(-H) flag is given use @@ -1025,10 +1235,16 @@ Each named parameter is unset. Local parameters remain local even if unset; they appear unset within scope, but the previous value will still reappear when the scope ends. -If the tt(-m) flag is specified the -arguments are taken as patterns (should be quoted) and all parameters -with matching names are unset. tt(unset -f) is equivalent to -tt(unfunction). +Individual elements of associative array parameters may be unset by using +subscript syntax on var(name), which should be quoted (or the entire command +prefixed with tt(noglob)) to protect the subscript from filename generation. + +If the tt(-m) flag is specified the arguments are taken as patterns (should +be quoted) and all parameters with matching names are unset. Note that this +cannot be used when unsetting associative array elements, as the subscript +will be treated as part of the pattern. + +tt(unset -f) is equivalent to tt(unfunction). ) findex(unsetopt) cindex(options, unsetting) @@ -1041,6 +1257,7 @@ If the tt(-m) flag is given the arguments are taken as patterns (which should be quoted to preserve them from being interpreted as glob patterns), and all options with names matching these patterns are unset. ) +module(vared)(zsh/zle) findex(wait) cindex(waiting for jobs) cindex(jobs, waiting for) @@ -1105,33 +1322,153 @@ findex(which) item(tt(which) [ tt(-wpams) ] var(name) ...)( Equivalent to tt(whence -c). ) +findex(zcompile) +cindex(.zwc files, creation) +cindex(compilation) +xitem(tt(zcompile) [ tt(-U) ] [ tt(-z) | tt(-k) ] [ tt(-R) | tt(-M) ] var(file) [ var(name) ... ]) +xitem(tt(zcompile) tt(-ca) [ tt(-m) ] [ tt(-R) | tt(-M) ] var(file) [ var(name) ... ]) +item(tt(zcompile -t) var(file) [ var(name) ... ])( +This builtin command can be used to compile functions or scripts and +store the compiled form in a file, and to examine files containing +the compiled form. This allows faster autoloading of functions and +execution of scripts by avoiding parsing of the text when the files +are read. + +The first form (without the tt(-c), tt(-a) or tt(-t) options) creates a +compiled file. If only the var(file) argument is provided, the +output file has the name `var(file)tt(.zwc)' and will be placed in +the same directory as the var(file). This will make the compiled +file be loaded instead of the normal function file when the function +is autoloaded (see +ifzman(\ +the section `Autoloading Functions' in zmanref(zshfunc) +)\ +ifnzman(\ +noderef(Functions) +)\ +for a description of how autoloaded functions are searched). The +extension tt(.zwc) stands for `zsh word codes'. + +If there is at least one var(name) argument, all those named files +are compiled into one output var(file). If var(file) does not end +in tt(.zwc), this extension is automatically appended. Files +containing multiple compiled functions are called `digest' files, +and are intended to be used as elements of the tt(FPATH)/tt(fpath) +special array. + +The second form, with the tt(-c) or tt(-a) options, writes the compiled +definitions for all the named functions into var(file). For tt(-c), the +names must be functions currently defined in the shell, not those marked +for autoloading. Undefined functions that are marked for autoloading +may be written by using the tt(-a) option, in which case the tt(fpath) +is searched and the contents of the definition files for those +functions, if found, are compiled into var(file). If both tt(-c) and +tt(-a) are given, names of both defined functions and functions marked +for autoloading may be given. In either case, the functions in files +written with the tt(-c) or tt(-a) option will be autoloaded as if the +tt(KSH_AUTOLOAD) option were unset. + +The reason for handling loaded and not-yet-loaded functions with +different options is that some definition files for autoloading define +multiple functions, including the function with the same name as the +file, and, at the end, call that function. In such cases the output of +`tt(zcompile -c)' does not include the additional functions defined in +the file, and any other initialization code in the file is lost. Using +`tt(zcompile -a)' captures all this extra information. + +If the tt(-m) option is combined with tt(-c) or tt(-a), +the var(name)s are used as patterns and all functions whose names +match one of these patterns will be written. If no var(name) is given, +the definitions of all functions currently defined or marked as +autoloaded will be written. + +The third form, with the tt(-t) option, examines an existing +compiled file. Without further arguments, the names of the original +files compiled into it are listed. The first line of output tells +the version of the shell which compiled the file and how the file +will be used (mapping or reading the file). With arguments, nothing +is output and the return value is set to zero if em(all) var(name)s +name files contained in the wordcode file, and non-zero if at least +one var(name) is not contained in it. + +Other options: + +startitem() +item(tt(-U))( +Aliases are not expanded when compiling the var(name)d files. +) +item(tt(-R))( +When the compiled file is read, its contents are copied into the +shell's memory, rather than memory-mapped (see tt(-M)). This +happens automatically on systems that do not support memory mapping. + +When compiling scripts instead of autoloadable functions, it is +often desirable to use this option. Otherwise the whole file will +remain mapped if the script has defined one or more functions, even +if the rest of the file will not be used again. +) +item(tt(-M))( +The compiled file is mapped into the shell's memory when read. This +is done in such a way that multiple instances of the shell running +on the same host will share this mapped file. If neither tt(-R) nor +tt(-M) is given, the tt(zcompile) builtin decides what to do based +on the size of the compiled file. +) +xitem(tt(-k)) +item(tt(-z))( +These options are used when the compiled file contains functions and +those functions are to be autoloaded. If tt(-z) is given, the +function will be autoloaded as if the tt(KSH_AUTOLOAD) option is +em(not) set, even if it is set at the time the compiled file is +read. The tt(-k) makes the function be loaded as if tt(KSH_AUTOLOAD) +em(is) set. If neither of these options is given, the function will +be loaded as determined by the setting of the tt(KSH_AUTOLOAD) option +at the time the compiled file is read. + +These options may also be repeated among the listed var(name)s to +specify the loading style of all following functions, up to the next +tt(-k) or tt(-z). +) +enditem() + +The created file always contains two versions of the compiled +format, one for big-endian machines and one for small-endian +machines. The upshot of this is that the compiled file is machine +independent and if it is read or mapped, only one half of the file +is actually used (and mapped). +) +module(zformat)(zsh/zutil) +module(zftp)(zsh/zftp) +module(zle)(zsh/zle) findex(zmodload) cindex(modules, loading) cindex(loading modules) -xitem(tt(zmodload) [ tt(-iL) ] [ var(name) ... ]) -xitem(tt(zmodload) tt(-u) [ tt(-i) ] var(name) ...) -xitem(tt(zmodload) tt(-d) [ tt(-L) ] [ var(name) [ var(dep) ... ] ]) -xitem(tt(zmodload) tt(-du) var(name) [ var(dep) ... ]) -xitem(tt(zmodload) tt(-a) [ tt(-iL) ] [ var(name) [ var(builtin) ... ] ]) -item(tt(zmodload) tt(-au) [ tt(-i) ] var(builtin) ...)( -tt(zmodload) performs operations relating to zsh's loadable modules. +xitem(tt(zmodload) [ tt(-dL) ] [ ... ]) +xitem(tt(zmodload -e) [ ... ]) +xitem(tt(zmodload) [ tt(-a) [ tt(-bcpf) [ tt(-I) ] ] ] [ tt(-iL) ] ...) +item(tt(zmodload) tt(-u) [ tt(-abcdpf) [ tt(-I) ] ] [ tt(-iL) ] ...)( +Performs operations relating to zsh's loadable modules. This feature is not available on all operating systems, or on all installations on a particular operating system. -In the simplest case, -tt(zmodload) loads a binary module. The module must be in a file with a -name consisting of the specified var(name) followed by a standard suffix, -usually `tt(.so)'. If this can't be found, the var(name) is tried without -the suffix. -If the module to be loaded is already loaded and the tt(-i) -option is given, the duplicate module is ignored. Otherwise -tt(zmodload) prints an error message. +Without arguments the names of all currently loaded binary modules are +printed. The tt(-L) option causes this list to be in the form of a +series of tt(zmodload) commands. Forms with arguments are: + +startitem() +xitem(tt(zmodload) [ tt(-i) ] var(name) ... ) +item(tt(zmodload) tt(-u) [ tt(-i) ] var(name) ...)( +In the simplest case, tt(zmodload) loads a binary module. The module must +be in a file with a name consisting of the specified var(name) followed by +a standard suffix, usually `tt(.so)'. +If the module to be loaded is +already loaded and the tt(-i) option is given, the duplicate module is +ignored. Otherwise tt(zmodload) prints an error message. The var(name)d module is searched for in the same way a command is, using -tt($module_path) instead of tt($path). If var(name) contains a `tt(/)', -it will be used as-is, and a path search will be performed otherwise. -This behaviour can be modified by the tt(PATH_DIRS) option. -cindex(PATH_DIRS, use of) +tt($module_path) instead of tt($path). However, the path search is +performed even when the module name contains a `tt(/)', which it usually does. +There is no way to prevent the path search. With tt(-u), tt(zmodload) unloads modules. The same var(name) must be given that was given when the module was loaded, but it is not @@ -1142,43 +1479,92 @@ unloaded (or was never loaded). Each module has a boot and a cleanup function. The module will not be loaded if its boot function fails. Similarly a module can only be unloaded if its cleanup function runs successfully. +) +xitem(tt(zmodload) tt(-d) [ tt(-L) ] [ var(name) ]) +xitem(tt(zmodload) tt(-d) var(name) var(dep) ...) +item(tt(zmodload) tt(-ud) var(name) [ var(dep) ... ])( +The tt(-d) option can be used to specify module dependencies. The modules +named in the second and subsequent arguments will be loaded before the +module named in the first argument. + +With tt(-d) and one argument, all dependencies for that module are listed. +With tt(-d) and no arguments, all module dependencies are listed. This +listing is by default in a Makefile-like format. The tt(-L) option +changes this format to a list of tt(zmodload -d) commands. + +If tt(-d) and tt(-u) are both used, dependencies are removed. If only one +argument is given, all dependencies for that module are removed. +) +xitem(tt(zmodload) tt(-ab) [ tt(-L) ]) +xitem(tt(zmodload) tt(-ab) [ tt(-i) ] var(name) [ var(builtin) ... ]) +item(tt(zmodload) tt(-ub) [ tt(-i) ] var(builtin) ...)( +The tt(-ab) option defines autoloaded builtins. It defines the specified +var(builtin)s. When any of those builtins is called, the module specified +in the first argument is loaded. If only the var(name) is given, one +builtin is defined, with the same name as the module. tt(-i) suppresses +the error if the builtin is already defined or autoloaded, regardless of +which module it came from. -Without arguments all currently loaded binary modules are printed. -The tt(-L) option causes this list to be in the form of a series of -tt(zmodload) commands. - -The tt(-d) option can be used to specify module dependencies. -This operation is idempotent regardless of the tt(-i) option. -The modules named in the second and subsequent arguments will be -loaded before the module named in the first argument. - -With tt(-d) and one -argument, all dependencies for that module are listed. With tt(-d) and no -arguments, all module dependencies are listed. -This listing is by default in a Makefile-like format. -The tt(-L) option changes this format to a list of -tt(zmodload -d) commands. - -If tt(-d) and tt(-u) are both used, dependencies are removed. -This operation is idempotent regardless of the tt(-i) option. -If only one argument is given, all dependencies for that module are removed. - -The tt(-a) option defines autoloaded builtins. It defines the -specified var(builtin)s. When any of those builtins is called, the module -specified in the first argument is loaded. If only one argument is given, -one builtin is defined, with the same name as the module. -tt(-i) suppresses the error if the builtin is already defined or -autoloaded, regardless of which module it came from. - -With tt(-a) and no arguments, all -autoloaded builtins are listed, with the module name (if different) -shown in parentheses after the builtin name. The tt(-L) option changes -this format to a list of tt(zmodload -a) commands. - -If tt(-a) is used -together with the tt(-u) option it removes builtins defined with -tt(zmodload -a). This is only possible if the builtin is not yet -loaded. tt(-i) suppresses the error if the builtin is already +With tt(-ab) and no arguments, all autoloaded builtins are listed, with the +module name (if different) shown in parentheses after the builtin name. +The tt(-L) option changes this format to a list of tt(zmodload -a) +commands. + +If tt(-b) is used together with the tt(-u) option, it removes builtins +previously defined with tt(-ab). This is only possible if the builtin is +not yet loaded. tt(-i) suppresses the error if the builtin is already removed (or never existed). ) +xitem(tt(zmodload) tt(-ac) [ tt(-IL) ]) +xitem(tt(zmodload) tt(-ac) [ tt(-iI) ] var(name) [ var(cond) ... ]) +item(tt(zmodload) tt(-uc) [ tt(-iI) ] var(cond) ...)( +The tt(-ac) option is used to define autoloaded condition codes. The +var(cond) strings give the names of the conditions defined by the +module. The optional tt(-I) option is used to define infix condition +names. Without this option prefix condition names are defined. + +If given no condition names, all defined names are listed (as a series of +tt(zmodload) commands if the tt(-L) option is given). + +The tt(-uc) option removes definitions for autoloaded conditions. +) +xitem(tt(zmodload) tt(-ap) [ tt(-L) ]) +xitem(tt(zmodload) tt(-ap) [ tt(-i) ] var(name) [ var(parameter) ... ]) +item(tt(zmodload) tt(-up) [ tt(-i) ] var(parameter) ...)( +The tt(-p) option is like the tt(-b) and tt(-c) options, but makes +tt(zmodload) work on autoloaded parameters instead. +) +xitem(tt(zmodload) tt(-af) [ tt(-L) ]) +xitem(tt(zmodload) tt(-af) [ tt(-i) ] var(name) [ var(function) ... ]) +item(tt(zmodload) tt(-uf) [ tt(-i) ] var(function) ...)( +The tt(-f) option is like the tt(-b), tt(-p), and tt(-c) options, but +makes tt(zmodload) work on autoloaded math functions instead. +) +xitem(tt(zmodload) tt(-a) [ tt(-L) ]) +xitem(tt(zmodload) tt(-a) [ tt(-i) ] var(name) [ var(builtin) ... ]) +item(tt(zmodload) tt(-ua) [ tt(-i) ] var(builtin) ...)( +Equivalent to tt(-ab) and tt(-ub). +) +item(tt(zmodload -e) [ var(string) ... ])( +The tt(-e) option without arguments lists all loaded modules. +With arguments only the return status is set to zero +if all var(string)s given as arguments are names of loaded modules +and to one if at least on var(string) is not the name of a +loaded module. This can be used to test for the availability +of things implemented by modules. +) +enditem() + +Note that tt(zsh) makes no distinction between modules that were linked +into the shell and modules that are loaded dynamically. In both cases +this builtin command has to be used to make available the builtins and +other things defined by modules (unless the module is autoloaded on +these definitions). This is true even for systems that don't support +dynamic loading of modules. +) +module(zparseopts)(zsh/zutil) +module(zprof)(zsh/zprof) +module(zpty)(zsh/zpty) +module(zregexparse)(zsh/zutil) +module(zstyle)(zsh/zutil) enditem() diff --git a/Doc/Zsh/compctl.yo b/Doc/Zsh/compctl.yo index a78a18fa9..f25ddda98 100644 --- a/Doc/Zsh/compctl.yo +++ b/Doc/Zsh/compctl.yo @@ -1,7 +1,25 @@ -texinode(Programmable Completion)(Zsh Modules)(Zsh Line Editor)(Top) -chapter(Programmable Completion) +texinode(Completion Using compctl)(Completion Widgets)(Zsh Line Editor)(Top) +chapter(Completion Using compctl) cindex(completion, programmable) cindex(completion, controlling) +ifzman(\ +sect(Synopsis) +This version of zsh has two ways of performing completion of words on the +command line. New users of the shell may prefer to use the newer +and more powerful system based on shell functions; this is described in +zmanref(zshcompsys), and the basic shell mechanisms which support it are +described in zmanref(zshcompwid). This manual entry describes the older +tt(compctl) command. +)\ +ifnzman(\ +sect(Types of completion) +This version of zsh has two ways of performing completion of words on the +command line. New users of the shell may prefer to use the newer +and more powerful system based on shell functions; this is described +in noderef(Completion System), and the basic shell mechanisms which support +it are described in noderef(Completion Widgets). This chapter describes +the older tt(compctl) command. +)\ findex(compctl) sect(Description) startlist() @@ -10,7 +28,8 @@ list(tt(compctl) [ tt(-CDT) ] var(options) \ [ tt(-x) var(pattern) var(options) tt(-) ... tt(--) ] \ [ tt(PLUS()) var(options) [ tt(-x) ... tt(--) ] ... [tt(PLUS())] ] \ [ var(command) ... ]) -list(tt(compctl) tt(-L) [ tt(-CDT) ] [ var(command) ... ]) +list(tt(compctl) tt(-M) var(match-specs) ...) +list(tt(compctl) tt(-L) [ tt(-CDTM) ] [ var(command) ... ]) list(tt(compctl) tt(PLUS()) var(command) ...) endlist() @@ -30,7 +49,8 @@ menu(Alternative Completion) menu(Extended Completion) menu(Example) endmenu() -texinode(Command Flags)(Option Flags)()(Programmable Completion) + +texinode(Command Flags)(Option Flags)()(Completion Using compctl) sect(Command Flags) Completion of the arguments of a command may be different for each command or may use the default. The behavior when completing the @@ -44,9 +64,23 @@ item(var(command) ...)( controls completion for the named commands, which must be listed last on the command line. If completion is attempted for a command with a pathname containing slashes and no completion definition is found, the -search is retried with the last pathname component. Note that aliases +search is retried with the last pathname component. If the command starts +with a tt(=), completion is tried with the pathname of the command. + +Any of the var(command) strings may be patterns of the form normally +used for filename generation. These should be be quoted to protect them +from immediate expansion; for example the command string tt('foo*') +arranges for completion of the words of any command beginning with +tt(foo). When completion is attempted, all pattern completions are +tried in the reverse order of their definition until one matches. By +default, completion then proceeds as normal, i.e. the shell will try to +generate more matches for the specific command on the command line; this +can be overridden by including tt(-tn) in the flags for the pattern +completion. + +Note that aliases are expanded before the command name is determined unless the -tt(COMPLETE_ALIASES) option is set. Commands should not be combined +tt(COMPLETE_ALIASES) option is set. Commands may not be combined with the tt(-C), tt(-D) or tt(-T) flags. ) item(tt(-C))( @@ -62,8 +96,8 @@ been issued, filenames are completed. ) item(tt(-T))( supplies completion flags to be used before any other processing is -done, even those given to specific commands with other compctl -definitions. This is only useful when combined with extended +done, even before processing for tt(compctl)s defined for specific +commands. This is especially useful when combined with extended completion (the tt(-x) flag, see noderef(Extended Completion) below). Using this flag you can define default behavior which will apply to all commands without exception, or you can alter @@ -71,41 +105,59 @@ the standard behavior for all commands. For example, if your access to the user database is too slow and/or it contains too many users (so that completion after `tt(~)' is too slow to be usable), you can use -nofill(tt(compctl -Tx 'C[0,*/*]' -f - 's[~]' -k friends -S/)) +example(compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn) to complete the strings in the array tt(friends) after a `tt(~)'. -The first argument is necessary so that this form of ~-completion is +The tt(C[...]) argument is necessary so that this form of ~-completion is not tried after the directory name is finished. ) item(tt(-L))( lists the existing completion behavior in a manner suitable for putting into a start-up script; the existing behavior is not changed. -Any combination of the above forms may be specified, otherwise all -defined completions are listed. Any other flags supplied -are ignored. +Any combination of the above forms, or the tt(-M) flag (which must +follow the tt(-L) flag), may be specified, otherwise all defined +completions are listed. Any other flags supplied are ignored. ) item(em(no argument))( If no argument is given, tt(compctl) lists all defined completions in an abbreviated form; with a list of var(options), all completions with those flags set (not counting extended completion) are listed. ) -endlist() +enditem() If the tt(PLUS()) flag is alone and followed immediately by the var(command) list, the completion behavior for all the commands in the list is reset to the default. In other words, completion will subsequently use the options specified by the tt(-D) flag. -texinode(Option Flags)(Alternative Completion)(Command Flags)(Programmable Completion) + +The form with tt(-M) as the first and only option defines global +matching specifications (see +ifzman(zshcompwid)\ +ifnzman(noderef(Matching Control))\ +). The match specifications given will be used for every completion +attempt (only when using tt(compctl), not with the new completion +system) and are tried in the order in which they are defined until one +generates at least one match. E.g.: + +example(compctl -M '' 'm:{a-zA-Z}={A-Za-z}') + +This will first try completion without any global match specifications +(the empty string) and, if that generates no matches, will try case +insensitive completion. + +texinode(Option Flags)(Alternative Completion)(Command Flags)(Completion Using compctl) sect(Option Flags) startlist() -list([ tt(-fcFBdeaRGovNAIOPZEnbjrzu/) ]) +list([ tt(-fcFBdeaRGovNAIOPZEnbjrzu/12) ]) list([ tt(-k) var(array) ] [ tt(-g) var(globstring) ] \ [ tt(-s) var(subststring) ]) -list([ tt(-K) var(function) ] [ tt(-H) var(num pattern) ]) +list([ tt(-K) var(function) ]) list([ tt(-Q) ] [ tt(-P) var(prefix) ] [ tt(-S) var(suffix) ]) -list([ tt(-W) var(file-prefix) ]) +list([ tt(-W) var(file-prefix) ] [ tt(-H) var(num pattern) ]) list([ tt(-q) ] [ tt(-X) var(explanation) ] [ tt(-Y) var(explanation) ]) -list([ tt(-y) var(func-or-var) ] [ tt(-l) var(cmd) ] [ tt(-U) ]) +list([ tt(-y) var(func-or-var) ] [ tt(-l) var(cmd) ] [ tt(-h) var(cmd) ] [ tt(-U) ]) +list([ tt(-t) var(continue) ] [ tt(-J) var(name) ] [ tt(-V) var(name) ]) +list([ tt(-M) var(match-spec) ]) endlist() The remaining var(options) specify the type of command arguments @@ -117,6 +169,7 @@ menu(Simple Flags) menu(Flags with Arguments) menu(Control Flags) endmenu() + texinode(Simple Flags)(Flags with Arguments)()(Option Flags) subsect(Simple Flags) These produce completion lists made up by the shell itself: @@ -215,6 +268,7 @@ item(tt(-u))( User names. ) enditem() + texinode(Flags with Arguments)(Control Flags)(Simple Flags)(Option Flags) subsect(Flags with Arguments) These have user supplied arguments to determine how the list of @@ -229,8 +283,8 @@ of space- or comma-separated values in parentheses, in which any delimiter may be escaped with a backslash; in this case the argument should be quoted. For example, -nofill(tt(compctl -k "(cputime filesize datasize stacksize - coredumpsize resident descriptors)" limit)) +example(compctl -k "(cputime filesize datasize stacksize + coredumpsize resident descriptors)" limit) ) item(tt(-g) var(globstring))( The var(globstring) is expanded using filename globbing; it should be @@ -251,20 +305,21 @@ completions. The tt(fignore) special parameter is not applied to the resulting files. Note that tt(-g) is faster for filenames. ) item(tt(-K) var(function))( -Call the given function to get the completions. The function is +Call the given function to get the completions. Unless the name +starts with an underscore, the function is passed two arguments: the prefix and the suffix of the word on which completion is to be attempted, in other words those characters before the cursor position, and those from the cursor position onwards. The whole command line can be accessed with the tt(-c) and tt(-l) flags -of the tt(read) builtin. The +of the tt(read) builtin. The function should set the variable tt(reply) to an array containing the completions (one completion per element); note that tt(reply) should not be made local to the function. From such a function the command line can be accessed with the tt(-c) and tt(-l) flags to the tt(read) builtin. For example, -nofill(tt(function whoson { reply=(`users`); } -compctl -K whoson talk)) +example(function whoson { reply=(`users`); } +compctl -K whoson talk) completes only logged-on users after `tt(talk)'. Note that `tt(whoson)' must return an array, so `tt(reply=`users`)' would be incorrect. @@ -276,12 +331,13 @@ zero or negative the whole history is searched and if var(pattern) is the empty string all words are taken (as with `tt(*)'). A typical use is -nofill(tt(compctl -D -f PLUS() -H 0 '')) +example(compctl -D -f PLUS() -H 0 '') which forces completion to look back in the history list for a word if no filename matches. ) enditem() + texinode(Control Flags)()(Flags with Arguments)(Option Flags) subsect(Control Flags) These do not directly specify types of name to be completed, but @@ -303,7 +359,7 @@ The var(prefix) is inserted just before the completed string; any initial part already typed will be completed and the whole var(prefix) ignored for completion purposes. For example, -nofill(tt(compctl -j -P "%" kill)) +example(compctl -j -P "%" kill) inserts a `%' after the kill command and then completes job names. ) @@ -318,20 +374,25 @@ With directory var(file-prefix): for command, file, directory and globbing completion (options tt(-c), tt(-f), tt(-/), tt(-g)), the file prefix is implicitly added in front of the completion. For example, -nofill(tt(compctl -/ -W ~/Mail maildirs)) +example(compctl -/ -W ~/Mail maildirs) completes any subdirectories to any depth beneath the directory tt(~/Mail), although that prefix does not appear on the command line. +The var(file-prefix) may also be of the form accepted by the tt(-k) +flag, i.e. the name of an array or a literal list in parenthesis. In +this case all the directories in the list will be searched for +possible completions. ) item(tt(-q))( If used with a suffix as specified by the tt(-S) option, this causes the suffix to be removed if the next character typed is a blank -or does not insert anything (the same rule as used for the -tt(AUTO_REMOVE_SLASH) option). The option is most useful for list +or does not insert anything or if the suffix consists of only one character +and the next character typed is the same character; this the same rule used +for the tt(AUTO_REMOVE_SLASH) option. The option is most useful for list separators (comma, colon, etc.). ) item(tt(-l) var(cmd))( -This option cannot be combined with any other. It restricts the range +This option restricts the range of command line words that are considered to be arguments. If combined with one of the extended completion patterns `tt(p[)...tt(])', `tt(r[)...tt(])', or `tt(R[)...tt(])' (see noderef(Extended Completion) @@ -342,12 +403,21 @@ option. If the var(cmd) string is empty the first word in the range is instead taken as the command name, and command name completion performed on the first word in the range. For example, -nofill(tt(compctl -x 'r[-exec,;]' -l '' -- find)) +example(compctl -x 'r[-exec,;]' -l '' -- find) completes arguments between `tt(-exec)' and the following `tt(;)' (or the end of the command line if there is no such string) as if they were a separate command line. ) +item(tt(-h) var(cmd))( +Normally zsh completes quoted strings as a whole. With this option, +completion can be done separately on different parts of such +strings. It works like the tt(-l) option but makes the completion code +work on the parts of the current word that are separated by +spaces. These parts are completed as if they were arguments to the +given var(cmd). If var(cmd) is the empty string, the first part is +completed as a command name, as with tt(-l). +) item(tt(-U))( Use the whole list of possible completions, whether or not they actually match the word on the command line. The word typed so far @@ -355,7 +425,10 @@ will be deleted. This is most useful with a function (given by the tt(-K) option) which can examine the word components passed to it (or via the tt(read) builtin's tt(-c) and tt(-l) flags) and use its own criteria to decide what matches. If there is no -completion, the original word is retained. +completion, the original word is retained. Since the produced +possible completions seldom have interesting common prefixes +and suffixes, menucompletion is started immediately if tt(AUTO_MENU) is +set and this flag is used. ) item(tt(-y) var(func-or-var))( The list provided by var(func-or-var) is displayed instead of the list @@ -379,9 +452,22 @@ printed literally and if they appear output in columns is suppressed. ) item(tt(-X) var(explanation))( Print var(explanation) when trying completion on the current set of -options. A `tt(%n)' in this string is replaced by the number of matches. +options. A `tt(%n)' in this string is replaced by the number of +matches that were added for this explanation string. The explanation only appears if completion was tried and there was -no unique match, or when listing completions. +no unique match, or when listing completions. Explanation strings +will be listed together with the matches of the group specified +together with the tt(-X) option (using the tt(-J) or tt(-V) +option). If the same explanation string is given to multiple tt(-X) +options, the string appears only once (for each group) and the number +of matches shown for the `tt(%n)' is the total number of all matches +for each of these uses. In any case, the explanation string will only +be shown if there was at least one match added for the explanation +string. + +The sequences tt(%B), tt(%b), tt(%S), tt(%s), tt(%U), and tt(%u) specify +output attributes (bold, standout, and underline) and tt(%{...%}) can +be used to include literal escape sequences as in prompts. ) item(tt(-Y) var(explanation))( Identical to tt(-X), except that the var(explanation) first undergoes @@ -389,8 +475,72 @@ expansion following the usual rules for strings in double quotes. The expansion will be carried out after any functions are called for the tt(-K) or tt(-y) options, allowing them to set variables. ) +item(tt(-t) var(continue))( +The var(continue)-string contains a character that specifies which set +of completion flags should be used next. It is useful: + +(i) With tt(-T), or when trying a list of pattern completions, when +tt(compctl) would usually continue with ordinary processing after +finding matches; this can be suppressed with `tt(-tn)'. + +(ii) With a list of alternatives separated by tt(+), when tt(compctl) +would normally stop when one of the alternatives generates matches. It +can be forced to consider the next set of completions by adding `tt(-t+)' +to the flags of the alternative before the `tt(+)'. + +(iii) In an extended completion list (see below), when tt(compctl) would +normally continue until a set of conditions succeeded, then use only +the immediately following flags. With `tt(-t-)', tt(compctl) will +continue trying extended completions after the next `tt(-)'; with +`tt(-tx)' it will attempt completion with the default flags, in other +words those before the `tt(-x)'. +) +item(tt(-J) var(name))( +This gives the name of the group the matches should be placed in. Groups +are listed and sorted separately; likewise, menucompletion will offer +the matches in the groups in the order in which the groups were +defined. If no group name is explicitly given, the matches are stored in +a group named var(default). The first time a group name is encountered, +a group with that name is created. After that all matches with the same +group name are stored in that group. + +This can be useful with non-exclusive alternative completions. For +example, in + +example(compctl -f -J files -t+ + -v -J variables foo) + +both files and variables are possible completions, as the tt(-t+) forces +both sets of alternatives before and after the tt(+) to be considered at +once. Because of the tt(-J) options, however, all files are listed +before all variables. +) +item(tt(-V) var(name))( +Like tt(-J), but matches within the group will not be sorted in listings +nor in menucompletion. These unsorted groups are in a different name +space from the sorted ones, so groups defined as tt(-J files) and tt(-V +files) are distinct. +) +item(tt(-1))( +If given together with the tt(-V) option, makes +only consecutive duplicates in the group be removed. Note that groups +with and without this flag are in different name spaces. +) +item(tt(-2))( +If given together with the tt(-J) or tt(-V) option, makes all +duplicates be kept. Again, groups with and without this flag are in +different name spaces. +) +item(tt(-M) var(match-spec))( +This defines additional matching control specifications that should be used +only when testing words for the list of flags this flag appears in. The format +of the var(match-spec) string is described in +ifzman(zshcompwid)\ +ifnzman(noderef(Matching Control))\ +. +) enditem() -texinode(Alternative Completion)(Extended Completion)(Option Flags)(Programmable Completion) + +texinode(Alternative Completion)(Extended Completion)(Option Flags)(Completion Using compctl) sect(Alternative Completion) startlist() list(tt(compctl) [ tt(-CDT) ] var(options) tt(PLUS()) var(options) [ tt(PLUS()) ... ] \ @@ -402,16 +552,19 @@ tried with the options before the first `tt(PLUS())'. If this produces no matches completion is tried with the flags after the `tt(PLUS())' and so on. If there are no flags after the last `tt(PLUS())' and a match has not been found up to that point, default completion is tried. -texinode(Extended Completion)(Example)(Alternative Completion)(Programmable Completion) +If the list of flags contains a tt(-t) with a tt(PLUS()) character, the next +list of flags is used even if the current list produced matches. + +texinode(Extended Completion)(Example)(Alternative Completion)(Completion Using compctl) sect(Extended Completion) startlist() -list(tt(compctl) [ tt(-CDT) ] var(options) \ -tt(-x) var(pattern) var(options) tt(-) ... tt(--) \ -[ var(command) ... ]) -list(tt(compctl) [ tt(-CDT) ] var(options) \ -[ tt(-x) var(pattern) var(options) tt(-) ... tt(--) ] \ -[ tt(PLUS()) var(options) [ tt(-x) ... tt(--) ] ... [tt(PLUS())] ] \ -[ var(command) ... ]) +list(nofill(tt(compctl) [ tt(-CDT) ] var(options) \ +tt(-x) var(pattern) var(options) tt(-) ... tt(--) + [ var(command) ... ])) +list(nofill(tt(compctl) [ tt(-CDT) ] var(options) \ +[ tt(-x) var(pattern) var(options) tt(-) ... tt(--) ] + [ tt(PLUS()) var(options) [ tt(-x) ... tt(--) ] ... [tt(PLUS())] ] \ +[ var(command) ... ])) endlist() The form with `tt(-x)' specifies extended completion for the @@ -478,7 +631,7 @@ considered part of the completion, but the rest will. var(index) may be negative to count from the end: in most cases, var(index) will be 1 or -1. For example, -nofill(tt(compctl -s '`users`' -x 'n[1,@]' -k hosts -- talk)) +example(compctl -s '`users`' -x 'n[1,@]' -k hosts -- talk) will usually complete usernames, but if you insert an tt(@) after the name, names from the array var(hosts) (assumed to contain hostnames, @@ -497,17 +650,27 @@ var(max) inclusive. ) item(tt(r[)var(str1)tt(,)var(str2)tt(])...)( Matches if the cursor is after a word with prefix var(str1). If there -is also a word with prefix var(str2) on the command line it matches -only if the cursor is before this word. +is also a word with prefix var(str2) on the command line after the one +matched by var(str1) it matches +only if the cursor is before this word. If the comma and var(str2) are +omitted, it matches if the cursor is after a word with prefix var(str1). ) item(tt(R[)var(str1)tt(,)var(str2)tt(])...)( Like tt(r) but using pattern matching instead. ) +item(tt(q[)var(str)tt(])...)( +Matches the word currently being completed is in single quotes and the +var(str) begins with the letter `s', or if completion is done in +double quotes and var(str) starts with the letter `d', or if +completion is done in backticks and var(str) starts with a `b'. +) enditem() -texinode(Example)()(Extended Completion)(Programmable Completion) + +texinode(Example)()(Extended Completion)(Completion Using compctl) sect(Example) -nofill(tt(compctl -u -x 's[tt(PLUS())] c[-1,-f],s[-f+PLUS()]' -g '~/Mail/*(:t)' \ - - 's[-f],c[-1,-f]' -f -- mail)) + +example(compctl -u -x 's[tt(PLUS())] c[-1,-f],s[-f+PLUS()]' \ + -g '~/Mail/*(:t)' - 's[-f],c[-1,-f]' -f -- mail) This is to be interpreted as follows: diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 632cb3195..35204a217 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -1,87 +1,130 @@ -texinode(Completion System)()(Zsh Modules)(Top) +texinode(Completion System)(Zsh Modules)(Completion Widgets)(Top) chapter(Completion System) -cindex(completion, system) +cindex(completion system) cindex(completion, programmable) cindex(completion, controlling) sect(Description) This describes the shell code for the new completion system. It consists -of two scripts and a few other files that define shell functions. -The shell functions which implement completion behaviour and which may -be bound to keystrokes, are referred to as `widgets'. All are contained -in the following subdirectories of the tt(Completion) directory of the main -distribution directory. - -startitem() -item(tt(Core))( -The core scripts and functions. You will certainly need these, though will -probably not need to alter them. The contents of this directory is -described in more detail below. -) -item(tt(Base))( -Other functions you will almost certainly want if you are going to use -any of the standard completion functions. You may want to edit some of -these files. -) -item(tt(Builtins))( -Functions for completing arguments of shell builtin commands. -) -item(tt(User))( -Functions for completing arguments of external commands and suites of -commands. They may need modifying for your system. -) -item(tt(Commands))( -Functions which implement special types of completion to be bound to -keystrokes rather than called by context. -) -enditem() - -You should decide which files you will be using and copy them to a -directory (or multiple directories) of your own which should appear in your -tt($fpath) variable so that the functions can be autoloaded. +of various shell functions; those beginning `tt(comp)' are to be called +directly by the user, while those beginning `tt(_)' are called by the +completion code. The shell functions of the second set which implement +completion behaviour and which may be bound to keystrokes, are referred to +as `widgets'. startmenu() -menu(Initialisation) +menu(Initialization) +menu(Completion System Configuration) menu(Control Functions) +menu(Bindable Commands) menu(Completion Functions) +menu(Completion Directories) endmenu() -texinode(Initialisation)(Control Functions)()(Completion System) -sect(Initialisation) - -To initialise the system, the script tt(compinit) should be sourced with -`tt(source )var(<path>)tt(/compinit)' or -`tt(. )var(<path>)tt(/compinit)'. This will define a few utility functions, -arrange for all the necessary shell functions to be autoloaded, and will -then re-bind all keys that do completion to use the new system. - -subsect(Arguments) +texinode(Initialization)(Completion System Configuration)()(Completion System) +sect(Initialization) +findex(compinstall) +cindex(completion system, installing) + +The function tt(compinstall) can be run by a user to set up the completion +system for use, which also provides options for more advanced usage. +However, if the system was installed completely, it should be enough to +call the shell function tt(compinit) from your initialization file; see the +next section. + +Usually, tt(compinstall) will insert code into tt(.zshrc), although if +that is not writable it will save it in another file and tell you that +file's location. Note that it is up to you to make sure that the lines +added to tt(.zshrc) are actually run; you may, for example, need to move +them to an earlier place in the file if tt(.zshrc) usually returns early. +So long as you keep them all together (including the comment lines at the +start and finish), you can rerun tt(compinstall) and it will correctly +locate and modify these lines. Note, however, that any code you add to +this section by hand is likely to be lost if you rerun tt(compinstall). +The new code will take effect next time you start the shell, or run +tt(.zshrc) by hand. + +To run it, you will need to make sure it is in a directory mentioned in your +tt($fpath) parameter, and that it is autoloaded (`tt(autoload -U +compinstall)' is recommended). It will ask you various questions about how +you would like completion set up. It is in two parts; the basic part +locates the completion files and decides where to put your personal +dumpfile, used to speed up initialization after the first time. After +that, you will be asked if you wish to go on to the advanced set-up; if you +answer tt(n), you can rerun tt(compinstall) later without having to +re-enter any of the basic settings. + +You can abort the installation any time you are being prompted for +information, and your tt(.zshrc) will not be altered at all. + +After initialization all the builtin completion widgets such as +tt(expand-or-complete) will be redefined to use the new completion system. +Should you need to, you can still bind keys to the old functions by putting +a `tt(.)' in front, e.g. `tt(.expand-or-complete)'. + +subsect(Use of compinit) +findex(compinit) +cindex(completion system, initializing) + +This section describes the use of tt(compinit) to initialize completion for +the current session when run directly by the user; if you have run +tt(compinstall) it will be called automatically from your tt(.zshrc). + +To initialize the system, the function tt(compinit) should be in a +directory mentioned in the tt($fpath) variable, and should be autoloaded +(`tt(autoload -U compinit)' is recommended). When run, it will define a +few utility functions, arrange for all the necessary shell functions to be +autoloaded, and will then re-bind all keys that do completion to use the +new system. Note that this means that the tt(zsh/complist) module has +to be loaded before the completion system is initialized (i.e. the +tt(compinit) function is called) to make sure that the tt(menu-select) +widget defined by it will be redefined, too. To speed up the running of tt(compinit), it can be made to produce a dumped -configuration which will be read in on future invocations. The easiest way -to do this is by adding the option tt(-d) whenever tt(compinit) is sourced. -In this case the dumped file will have the same name as the sourced file, -but with tt(.dump) appended to the end; alternatively, an explicit file -name can be given following the tt(-d). On the next call to tt(compinit --d), the dumped file will be read instead. +configuration which will be read in on future invocations; this is the +default, although it can be turned off by calling tt(compinit) with the +option tt(-D). The dumped file is tt(.zcompdump) in the same +directory as the startup files (i.e. tt($ZDOTDIR) or tt($HOME)); +alternatively, an explicit file name can be given by `tt(compinit -d) +var(dumpfile)'. On the next call to tt(compinit), the dumped file will be +read instead of a full initialization. If the number of completion files changes, tt(compinit) will recognise this and produce a new dump file. However, if the name of a function or the -arguments in the first line of a tt(#compdef) funcion (as described below) +arguments in the first line of a tt(#compdef) function (as described below) change, it is easiest to delete the dump file by hand so that the next time tt(compinit) will re-create it. -The dumping is actually done by another script, tt(compdump), but you will -only need to source this yourself if you change the configuration +The dumping is actually done by another function, tt(compdump), but you +will only need to run this yourself if you change the configuration (e.g. using tt(compdef)) and then want to dump the new one. The name of -the old dumped file will be remembered for this. +the old dumped file will be remembered for this purpose. + +If the parameter tt(_compdir) is set, tt(compinit) uses it as a directory +where completion functions can be found; this is only necessary if they are +not already in the function search path. subsect(Autoloaded files) +cindex(completion system, autoloaded functions) The convention for autoloaded functions used in completion is that they start with an underscore; as already mentioned, the tt(fpath/FPATH) -parameter must contain the directory in which they are stored. When -tt(compinit) is sourced, it searches all such files accessible via +parameter must contain the directory in which they are stored. If tt(zsh) +was properly installed on your system, then tt(fpath/FPATH) automatically +contains the required directories. + +For incomplete installations, if tt(compinit) does not find enough files +beginning with an underscore (fewer than twenty) in the search path, it +will try to find more by adding the directory tt(_compdir) to the search +path; if you have run tt(compinstall), this will be set automatically. +Furthermore, if the directory in question ends in the path segment +tt(Core), or has a subdirectory named tt(Core), tt(compinit) will add all +subdirectories of the directory where tt(Core) is to the path: this allows +the functions to be in the same format as in the tt(zsh) source +distribution. + +cindex(compdef, use of by compinit) +When tt(compinit) is run, it searches all such files accessible via tt(fpath/FPATH) and reads the first line of each of them. This line should contain one of the tags described below. Files whose first line does not start with one of these tags are not considered to be part of the @@ -103,13 +146,23 @@ called when completing for a command whose name matches the given var(pattern) (a standard globbing pattern). Note that only one var(pattern) may be given. ) +item(tt(#compdef -P) var(pattern))( +Like the previous one, but the function will be called only if no +completion function for the command on the line could be found. +) item(tt(#compdef -k) var(style key-sequences...))( -This can be used bind special completion functions to the +This can be used to bind special completion functions to the var(key-sequences). It creates a widget behaving like the builtin widget var(style), which must be one of those that perform completion, namely tt(complete-word), tt(delete-char-or-list), tt(expand-or-complete), tt(expand-or-complete-prefix), tt(list-choices), tt(menu-complete), -tt(menu-expand-or-complete), or tt(reverse-menu-complete). +tt(menu-expand-or-complete), or tt(reverse-menu-complete). If the +tt(complist) module is loaded (see +ifzman(zmanref(zshmodules))\ +ifnzman(noderef(The zsh/complist Module))\ +), the tt(menu-select) widget can be used, too. Note that the +bindings will not be used if the key is already bound (that +is, is bound to something other than tt(undefined-key)). The widget is then bound to all the var(key-sequences) given, if any: when one of the var(key-sequences) is typed, the function in the file will @@ -117,29 +170,54 @@ be invoked to generate the matches. The widget created has the same name as the file and can also be bound to other keys using tt(bindkey) as usual. ) -item(tt(#autoload))( +item(tt(#compdef -K) var(widget-name) var(style) var(key-sequences) ...)( +This is similar to tt(-k), with the same var(style) and var(key-sequences) +arguments arguments, preceeded by a string giving the name of a widget. +In this case only one var(key-sequences) argument may be given, but the +entire set of three arguments may be repeated with a different set of +arguments. In particular, the var(widget-name) must be distinct in each +set. It should begin with `tt(_)', else one will be added, and should not +clash with the name of any existing widget: names based on the name of the +function are most useful. For example, + +example(#compdef -K _foo_complete complete-word "^X^C" \ + _foo_list list-choices "^X^D") + +(all on one line) defines a widget tt(_foo_complete) for completion, bound +to `tt(^X^C)', and a widget tt(_foo_list) for listing, bound to `tt(^X^D)'. +) +item(tt(#autoload) [ var(options) ])( This is used for files defining utility function that are not to be called directly as completion functions but should be loaded automatically when invoked. Typically they are to be called from within one of the completion functions. + +The var(options) will be given to the tt(autoload) builtin command +when making the function autoloaded. Note that the tt(-U) flag is +always used. Most often, this will be tt(+X) to force the function +being loaded immediately. ) enditem() Note that the tt(#) is part of the tag name and no white space is allowed -after it. The tt(#compdef) tags use the tt(compdef) function defined +after it. The tt(#compdef) tags use the tt(compdef) function described below; the main difference is that the name of the function is supplied implicitly. subsect(Functions) -The tt(compinit) file defines the following functions, which may +The tt(compinit) file defines the following function, which may also be called directly by the user. +findex(compdef) +cindex(completion system, adding definitions) startitem() xitem(tt(compdef) [ tt(-an) ] var(function names...)) xitem(tt(compdef -d) var(names...)) xitem(tt(compdef -p) [ tt(-a) ] var(function pattern)) -item(tt(compdef -k) [ tt(-a) ] var(function style key-sequences...))( +xitem(tt(compdef -P) [ tt(-a) ] var(function pattern)) +xitem(tt(compdef -k) [ tt(-an) ] var(function style key-sequences...)) +item(tt(compdef -K) [ tt(-an) ] var(function name style key-sequences ...))( The first form tells the completion system to call the given var(function) when completing for the contexts or commands whose var(names) are given: this is like the tt(#compdef) tag. If the @@ -147,78 +225,1588 @@ tt(-n) option is given, any existing completion behaviour for particular contexts or commands will not be altered. These definitions can be deleted by giving the tt(-d) option as in the second form. -The third form is similar to the first, but var(function) will be called -for all commands whose name matches the var(pattern); this is like the -tt(#compdef -p) function tag. +The form with tt(-p) is similar to the first, but var(function) will be +called for all commands whose name matches the var(pattern); this is like +the tt(#compdef -p) function tag. + +The form with tt(-P) is like the third, but the var(function) will be +called only if no function for the command itself was found or if one +was found and it set the tt(_compskip) parameter to a value em(not) +containing the substring tt(patterns). -The fourth form defines a widget with the same name as the var(function) +The form with tt(-k) defines a widget with the same name as the var(function) which will be called for each of the var(key-sequences); this is like the tt(#compdef -k) tag. The function should generate the completions needed and will otherwise behave like the builtin widget whose name is given as the var(style) argument. The widgets usable for this are: tt(complete-word), tt(delete-char-or-list), tt(expand-or-complete), tt(expand-or-complete-prefix), tt(list-choices), tt(menu-complete), -tt(menu-expand-or-complete), and tt(reverse-menu-complete). +tt(menu-expand-or-complete), and tt(reverse-menu-complete), as well as +tt(menu-select) if the tt(zsh/complist) module is loaded. The option tt(-n) +prevents the key being bound if it is already to bound to something other +than tt(undefined-key). + +The form with tt(-K) is similar and defines multiple widgets based on the +same var(function), each of which requires the set of three arguments +var(name), var(style) and var(key-sequences), where the latter two are as +for tt(-k) and the first must be a unique widget name beginning with an +underscore. In each of the forms supporting it the tt(-a) option makes the var(function) autoloadable (exactly equivalent to -tt(autoload )var(function)). +tt(autoload -U )var(function)). ) -xitem(tt(compconf) var(definitions...)) -xitem(tt(compconf)) -item(tt(compconf) [ tt(-l) ] var(keys...))( -Several aspects of the completion system can be configured by the -user. The configuration values are stored under the keys described -below in the associative array `tt(compconfig)'. After sourcing -tt(compinit), configuration values can either be set directly as in -`tt(compconfig[completer]=_complete)' or by calling this utility function. +enditem() + +texinode(Completion System Configuration)(Control Functions)(Initialization)(Completion System) +sect(Completion System Configuration) +cindex(completion system, configuration) -Each var(definition) may be either a simple `var(key)', which sets this -key in the tt(compconfig) array to an empty string, or of the form -`var(key=value)' which stores the `var(value)' under key `var(key)'. +This section gives a short overview of how the completion system works, +and then more detail on how users can configure how and when matches are +generated. -Since the completion system also uses the array for internal purposes, -you should not set all values at once by doing `tt(compconfig=(...))'. +subsect(Overview) + +When completion is attempted somewhere on a command line the +completion system first tries to find out the context where completion +was tried. The context depends on such things as the name of the +command when completing an argument, and possibily also +the name of an option when completing an argument to that option. + +For the context a name consisting of multiple fields is built. This +name is then used to look up styles that can be used to configure the +completion system. Since it is not possible to build the whole context +name in advance, completion function may modify some of the fields and +hence the context name used for lookup may vary during the same call +to the completion system. + +The context name always consists of the following fields, separated +by colons: + +startitemize() +itemiz(\ +The literal string tt(completion), saying that this style is used by +the completion system. +) +itemiz(\ +The var(function); in many cases this field will be blank, but when +the completion system is called from other functions, like +tt(predict-on) or one of the functions in the tt(Command) directory of +the distribution, this field contains the (probably abbreviated) name +of that function. +) +itemiz(\ +The var(completer) currently active, i.e. the name of the completer +function without the leading underscore. Such a completer is in +overall control of how completion is to be performed; `tt(complete)' +is the basic one for ordinary completion, but completers may perform +various related tasks such as correction, or modify the behaviour of a +later completer (see +ifzman(the section `Control Functions' below)\ +ifnzman(noderef(Control Functions)) +for more information). +) +itemiz(\ +The var(context) or var(command). This is either one of the special +context names such as tt(-condition-) as explained for the +tt(_complete) completer below, or the name of the command we are +completing arguments for. Completion functions for commands that have +sub-commands usually modify this field to contain the name of the +command followed by a minus sign and the sub-command (e.g. the +completion function for the tt(cvs) command sets this field to strings +such as tt(cvs-add) when completing for the tt(add) sub-command). +) +itemiz(\ +The var(argument), describing which argument we are +completing. Normally this is either a string of the form +tt(argument-)var(n), where var(n) is the number of the argument or it +is a string of the form tt(-)var(opt)tt(-)var(n) when completing the +var(n)'th argument of the option var(opt). +) +itemiz(\ +The var(tag). Tags are used for two purposes: to describe the types +of matches a completion function can generate for a certain context +and to simplify the definition of styles that are tested. +) +enditemize() + +As an example, the context name + +example(tt(:completion::complete:dvips:-o-1:files)) + +says that normal completion was attempted on an argument of the tt(dvips) +command (more precisely: completion was attempted on the first argument +after the tt(-o) option) and the completion function will generate +filenames for this context. + +In many of the possible contexts the completion system can generate +matches, often multiple types of matches. These types are represented as +simple names called `tags'. The completion system will decide internally +what sort of tags are allowed; a list of the standard possibilities is given +below. To determine in which order the tags are to be used by the +completion function, the `tt(tag-order)' style for the appropriate +context may be set, as described in the list of standard styles below. +Only those types of matches whose tags were selected by this style +will be produced, and in the order given. + +The tt(_complete_help) bindable command described in +ifzman(the section `Bindable Commands' below)\ +ifnzman(noderef(Bindable Commands)) +can be invoked to find out the context and tag names and styles used at a particular +point in completion. It shows a list of context names and the +tag names used in those contexts and then a list of context names and +the styles used in those contexts if completion were tried at the +current cursor position. Hence one can easily find out all the +information needed to change the behaviour of the tt(tag-order) style +for a particular context. + +Completion behaviour can be modified by various other +styles defined with the tt(zstyle) builtin command (\ +ifzman(see zmanref(zshmodules))\ +ifnzman(noderef(The zsh/zutil Module))). +When looking up styles the completion system uses full context names, +including the tag. + +Styles determine such things as how the matches are generated; some of them +correspond to shell options (for example, the use of menu completion), but +styles provide more specific control. They can have any number of strings as +their value. Looking up the value of a style therefore consists of two +things: the context, which may be matched as a pattern, and the name of +the style itself, which must be given exactly. + +For example, many completion functions can generate matches in a +simple and a verbose form and use the tt(verbose) style to decide +which form should be used. To make all such functions always use the +verbose form one can simply call + +example(zstyle ':completion:*' verbose yes) + +in one of the startup files like tt(.zshrc). This definition simply +means that the tt(verbose) style has tt(yes) as its value in every +context inside the completion system. If the pattern were `tt(*)', it +would mean that the verbose style had this value anywhere the style +mechanism is used. + +As a more specific example, the completion function for the tt(kill) +builtin command uses the tt(verbose) style to decide if jobs and processes +are listed only as job numbers and process identifiers or if they are +listed with the full job texts and the command lines of the processes (the +latter is achieved by calling the tt(ps) command). To make this builtin +list the matches only as numbers one could call: + +example(zstyle ':completion:*:*:kill:*' verbose no) + +Furthermore, if one wanted to see the command lines for processes but not the +job texts one could use the fact that the context name contains the tag name +when styles are looked up. As the function for the tt(kill) +builtin command uses the tags tt(jobs) and tt(processes), we can use: + +example(zstyle ':completion:*:*:kill:*:jobs' verbose no) + +Note that the order in which styles are em(defined) does not matter; the +style mechanism uses the most specific possible match for a particular +style to determine the set of values. More precisely, strings are +preferred over patterns (for example, `tt(:completion:complete:foo)' is +more specific than `tt(:completion:complete:*')), and longer patterns are +preferred over shorter patterns. + +As for tags, completion functions can use any number of styles, so +there can't be a complete list. However, the following two sections +list those tags and styles that are used in many places of the +completion system. + +subsect(Standard Tags) +cindex(completion system, tags) + +Here are the tags currently used by the completion system. Note that +some of these tags are not actually used while generating matches, +but are only used by some completion functions when looking up +styles. -In the second form (without arguments), this function lists all keys -and their values. If given the tt(-l) option as its first argument, as -in the last form, the other arguments are taken as names of keys and -the values of these keys are printed one per line. +startitem() +kindex(accounts, completion tag) +item(tt(accounts))( +used to look up the tt(users-hosts) style +) +kindex(all-files, completion tag) +item(tt(all-files))( +for the names of all files +) +kindex(all-expansions, completion tag) +item(tt(all-expansions))( +used by the tt(_expand) completer when adding the string containing +all expansions +) +kindex(arguments, completion tag) +item(tt(arguments))( +when an argument of a command may be completed +) +kindex(arrays, completion tag) +item(tt(arrays))( +for names of array parameters +) +kindex(association-keys, completion tag) +item(tt(association-keys))( +for keys of associative arrays (e.g. when completing inside a +subscript of such a parameter) +) +kindex(bookmarks, completion tag) +item(tt(bookmarks))( +when completing bookmarks (e.g. for URLs and the tt(zftp) function suite) +) +kindex(builtins, completion tag) +item(tt(builtins))( +for names of builtin commands +) +kindex(characters, completion tag) +item(tt(characters))( +used for commands like tt(stty) when completing characters; also used +when completing character classes after a opening bracket +) +kindex(colors, completion tag) +item(tt(colors))( +for color names +) +kindex(commands, completion tag) +item(tt(commands))( +for names of external commands and names of sub-commands (used by some +commands like tt(cvs)) +) +kindex(corrections, completion tag) +item(tt(corrections))( +used by the tt(_approximate) and tt(_correct) completers for the possible +corrections +) +kindex(cursors, completion tag) +item(tt(cursors))( +for cursor names used by X programs +) +kindex(default, completion tag) +item(tt(default))( +used to look up default values for various styles that may also be set +for tags that are used when generating matches +) +kindex(descriptions, completion tag) +item(tt(descriptions))( +used when looking up the value of the tt(format) style for +descriptions +) +kindex(devices, completion tag) +item(tt(devices))( +for names of device special files +) +kindex(directories, completion tag) +item(tt(directories))( +for names of directories +) +kindex(directory-stack, completion tag) +item(tt(directory-stack))( +for entries in the directory stack +) +kindex(displays, completion tag) +item(tt(displays))( +for X display names +) +kindex(domains, completion tag) +item(tt(domains))( +for network domains +) +kindex(expansions, completion tag) +item(tt(expansions))( +used by the tt(_expand) completer for possible expansions +) +kindex(extensions, completion tag) +item(tt(extensions))( +for X server extensions +) +kindex(files, completion tag) +item(tt(files))( +used by completion functions that can complete some kind of filenames +and different types of matches +) +kindex(fonts, completion tag) +item(tt(fonts))( +used for X font names +) +kindex(functions, completion tag) +item(tt(functions))( +names of functions (shell functions or other kinds of functions for +some commands) +) +kindex(globbed-files, completion tag) +item(tt(globbed-files))( +for names of files matching the glob pattern used by completion +functions that expect a certain type of file +) +kindex(groups, completion tag) +item(tt(groups))( +used when completing names of user groups +) +kindex(history-words, completion tag) +item(tt(history-words))( +for words from the history +) +kindex(hosts, completion tag) +item(tt(hosts))( +for hostnames +) +kindex(indexes, completion tag) +item(tt(indexes))( +used for array indexes +) +kindex(jobs, completion tag) +item(tt(jobs))( +used for jobs +) +kindex(keymaps, completion tag) +item(tt(keymaps))( +for names of zsh keymaps +) +kindex(keysyms, completion tag) +item(tt(keysyms))( +for names of X keysyms +) +kindex(local-directories, completion tag) +item(tt(local-directories))( +for names of directories in the current working directory when +completing for the tt(cd) builtin command +) +kindex(libraries, completion tag) +item(tt(libraries))( +for names of system libraries +) +kindex(limits, completion tag) +item(tt(limits))( +for system limits +) +kindex(manuals, completion tag) +item(tt(manuals))( +for names of manual pages +) +kindex(maps, completion tag) +item(tt(maps))( +for map names (e.g. YP maps) +) +kindex(messages, completion tag) +item(tt(messages))( +used to look up the tt(format) style for messages +) +kindex(modifiers, completion tag) +item(tt(modifiers))( +for names of X modifiers +) +kindex(modules, completion tag) +item(tt(modules))( +for modules (e.g. tt(zsh) modules) +) +kindex(my-accounts, completion tag) +item(tt(my-accounts))( +used to look up the tt(users-hosts) style +) +kindex(named-directories, completion tag) +item(tt(named-directories))( +for named directories (you wouldn't have guessed that, would you?) +) +kindex(names, completion tag) +item(tt(names))( +for all kinds of names +) +kindex(nicknames, completion tag) +item(tt(nicknames))( +for nicknames of YP maps +) +kindex(options, completion tag) +item(tt(options))( +for command options +) +kindex(original, completion tag) +item(tt(original))( +used by the tt(_approximate), tt(_correct) and tt(_expand) completers when +adding the original string +) +kindex(other-accounts, completion tag) +item(tt(other-accounts))( +used to look up the tt(users-hosts) style +) +kindex(packages, completion tag) +item(tt(packages))( +for packages (e.g. tt(rpm) or installed tt(Debian) packages) +) +kindex(parameters, completion tag) +item(tt(parameters))( +for names of parameters +) +kindex(path-directories, completion tag) +item(tt(path-directories))( +for names of directories in directories from the tt(cdpath) array when +completing for the tt(cd) builtin command +) +kindex(paths, completion tag) +item(tt(paths))( +used to look up the values of the tt(expand), tt(cursor) and +tt(special-dirs) styles +) +kindex(pids, completion tag) +item(tt(pids))( +for process identifiers +) +kindex(pids-list, completion tag) +item(tt(pids-list))( +used to look up the tt(command) style when generating the list to +display for process identifiers +) +kindex(pods, completion tag) +item(tt(pods))( +for perl pods +) +kindex(ports, completion tag) +item(tt(ports))( +for communication ports +) +kindex(prefixes, completion tag) +item(tt(prefixes))( +for prefixes (like those of an URL) +) +kindex(printers, completion tag) +item(tt(printers))( +for printer names +) +kindex(processes, completion tag) +item(tt(processes))( +for process identifiers +) +kindex(sequences, completion tag) +item(tt(sequences))( +for sequences (e.g. tt(mh) sequences) +) +kindex(sessions, completion tag) +item(tt(sessions))( +for sessions in the tt(zftp) function suite +) +kindex(signals, completion tag) +item(tt(signals))( +for signal names +) +kindex(strings, completion tag) +item(tt(strings))( +for strings (e.g. the replacement strings for the tt(cd) builtin +command) +) +kindex(tags, completion tag) +item(tt(tags))( +for tags (e.g. tt(rpm) tags) +) +kindex(targets, completion tag) +item(tt(targets))( +for makefile targets +) +kindex(types, completion tag) +item(tt(types))( +for types of whatever (e.g. adress types for the tt(xhost) command) +) +kindex(urls, completion tag) +item(tt(urls))( +used to look up the tt(path) and tt(local) styles when completing URLs +) +kindex(users, completion tag) +item(tt(users))( +for usernames +) +kindex(values, completion tag) +item(tt(values))( +when completing a value out of a set of values (or a list of such +values) +) +kindex(warnings, completion tag) +item(tt(warnings))( +used to look up the tt(format) style for warnings +) +kindex(widgets, completion tag) +item(tt(widgets))( +for zsh widget names +) +kindex(windows, completion tag) +item(tt(windows))( +for IDs of X windows +) +kindex(zsh-options, completion tag) +item(tt(zsh-options))( +for shell options ) enditem() -texinode(Control Functions)(Completion Functions)(Initialisation)(Completion System) -sect(Control Functions) +subsect(Standard Styles) +cindex(completion system, styles) + +Here are the names of the styles used by the completion system. Note +that the values of several of these styles represent boolean +values. In all these cases any of the strings `tt(true)', `tt(on)', +`tt(yes)', and `tt(1)' can be used for the truth value `true' and +the strings `tt(false)', `tt(off)', `tt(no)', and `tt(0)' are +interpreted as `false'. The behavior for any other value is undefined +unless the description for the particular style mentions other +possible values. + +startitem() +kindex(accept-exact, completion style) +item(tt(accept-exact))( +This is tested for the default tag and the tags used when generating +matches. If it is set to `true' for at least one match which is the +same as the string on the line, this match will immediately be +accepted. +) +kindex(add-space, completion style) +item(tt(add-space))( +This style is used by the tt(_prefix) completer to decide if a space +should be inserted before the suffix. +) +kindex(auto-description, completion style) +item(tt(auto-description))( +If set, this style's value will be used as the description for options which +are not described by the completion functions, but that have exactly +one argument. The sequence `tt(%d)' in the value will be replaced by +the description for this argument. Depending on personal preferences, +it may be useful to set this style to something like `tt(specify: %d)'. +Note that this may not work for some commands. +) +kindex(break, completion style) +item(tt(break))( +This style is used by the tt(incremental-complete-word) widget (found +in the tt(Functions/Zle) directory of the distribution). Its value +should be a pattern and all keys matching this pattern will cause the +widget to stop incremental completion without the key having any +further effect. +) +kindex(command, completion style) +item(tt(command))( +This style can be used to override the defaults in several completion +functions for how commands are called to generate information about +possible matches. The strings in the value are joined with spaces +between them to build the command line to execute. If the value starts +with a hyphen the string built will be prepended to the default +supplied by the completion function. This allows one to easily stick a +tt(builtin) or tt(command) in front of the default in case one has, +for example, a shell function with the same name as the command +called, but for completion purposes one needs to ensure that the real +command is called. + +For example, the function generating process IDs as matches uses this +style with the tt(pids) tag to generate the IDs to complete and iwhen +the tt(verbose) style is `true', it uses this style with the +tt(pids-list) tag to generate the strings to display. When using +different values for these two tags one should ensure that the process +IDs appear in the same order in both lists. +) +kindex(completer, completion style) +item(tt(completer))( +The strings given as the value of this style give the names of the +completer functions to use. The available completer functions are +described in +ifzman(the section `Control Functions' below)\ +ifnzman(noderef(Control Functions))\ +. + +Each string may be the name of a completer function or a string of the +form `var(function)tt(:)var(name)'. In the first case the +var(completer) field of the context will contain the name of the +completer without the leading underscore and with all other +underscores replaced with hyphens. In the second case the +var(function) is the name of the completer to call, but the context +will contain the var(name) in the var(completer) field of the +context. If the var(name) starts with a hyphen, the string for the +context will be build from the name of the completer function as in +the first case with the var(name) will be appended to it. For example: + +example(zstyle ':completion:*' completer _complete _complete:-foo) + +Here, completion will call the tt(_complete) completer twice, once +using `tt(complete)' and once using `tt(complete-foo)' in the +var(completer) field of the context. Normally, using the same +completer more than once makes only sense when used with the +`var(functions)tt(:)var(name)' form, because otherwise the context +name will be the same in all calls to the completer (possible +exception to this rule are the tt(_ignored) and tt(_prefix) +completers). + +Note that the widget functions from the distribution that call the +completion code (namely, the tt(incremental-complete-word) and the +tt(predict-on) widgets) set up their top-level context name before +calling completion. This allows one to define different sets of +completer functions for normal completion and for these widgets. For +example, to use completion, approximation and correction for normal +completion, completion and correction for incremental completion and +only completion for prediction one could use: + +example(zstyle ':completion:*' completer _complete _correct _approximate +zstyle ':completion:incremental:*' completer _complete _correct +zstyle ':completion:predict:*' completer _complete) + +The default value for this style is tt(_complete), i.e. normally only +completion will be done. +) +kindex(completions, completion style) +item(tt(completions))( +This style is used by the tt(_expand) completer function. + +If this is set to an non-empty string it should be an expression +usable inside a `tt($((...)))' arithmetical expression. The completer +function evaluates this expression and if the result is `tt(1)', no +expansions will be generated, but instead the completions will be +generated as normal and all of them will be inserted into the command +line. +) +kindex(condition, completion style) +item(tt(condition))( +This style is used by the tt(_list) completer function. + +If it is not set or set to the empty string, the insertion of +matches will be delayed unconditionally. If it is set, the value +should be an expression usable inside a `tt($((...)))' +arithmetical expression. In this case, delaying will be done if the +expression evaluates to `tt(1)'. For example, with + +example(zstyle ':completion:*:list:::' condition 'NUMERIC != 1') + +delaying will be done only if given an explicit numeric argument +other than `tt(1)'. +) +kindex(cursor, completion style) +item(tt(cursor))( +This is used together with the tt(paths) tag by the function +generating filenames as matches to find out if the cursor should be left +after the first ambiguous pathname component even when menucompletion +is used. + +The tt(predict-on) widget uses this style to decide where to place the +cursor after completion has been tried. If it is set to tt(complete), +the cursor is left at the place where completion left it, but only if +it is after a character equal to the one just inserted by the user. If +it is after another character, the value is treated as if it where the +string tt(key). If the value is set to tt(key), the cursor is left +after the var(n)th occurrence of the character just inserted, where +var(n) is the number of times that character appeared in the word +before completion was attempted. In short, this has the effect of +leaving the cursor after the character just typed even if the +completion code found out that no other characters need to be inserted +at that position. Finally, any other value for this style +unconditionally leaves the cursor at the position where the completion +code left it. +) +kindex(disable-stat, completion style) +item(tt(disable-stat))( +This is used with the an empty tag by the function completing for the +tt(cvs) command to decide if the tt(zsh/stat) module should be used to +generate only names of modified files in the appropriate places. +) +kindex(domains, completion style) +item(tt(domains))( +If set, gives the names of network domains that should be +completed. If this is not set by the user domain names mentioned in +tt(/etc/resolv.conf) will be used. +) +kindex(expand, completion style) +item(tt(expand))( +This style is used when completing strings consisting of multiple +parts, such as path names. If its +value contains the string tt(prefix), the partially typed word from +the line will be expanded as far as possible even if trailing parts +can not be completed. If it contains the string tt(suffix) +and normal (non-menu-) completion is used, matching names for +components after the first ambiguous one will be added, too. This +means that the resulting string is the longest unambiguous string +possible, but if menucompletion is started on the list of matches +generated this way (e.g. due to the option tt(AUTO_MENU) being set), +this will also cycle through the names of the files in pathname +components after the first ambiguous one. +) +kindex(file-patterns, completion style) +item(tt(file-patterns))( +In most places where filenames are completed, the function tt(_files) +is used which can be configured with this style. If the style is +unset, tt(_files) offers, one after another, up to three tags: +tt(globbed-files), +tt(directories) and tt(all-files), depending on the types of files +expected by the caller of tt(_files). + +If the tt(file-patterns) style is set, the default tags are not +used. Instead, the value of the style says which tags and which +patterns are to be offered. The strings in the value are of the form +`var(patterns)tt(:)var(tag)'. The var(patterns) gives one or more glob +patterns separated by spaces that are to be used to generate +filenames. If it contains the sequence `tt(%p)', that is replaced by +the pattern(s) given by the calling function. +Colons in the pattern have to be preceded by a backslash to +make them distinguishable from the colon before the var(tag). The +var(tag)s of all strings in the value will be offered by tt(_files) +(again, one after another) and used when looking up other styles. The +var(tag) may also be +followed by an optional second colon and a description. If that is +given, this description will be used for the `tt(%d)' in the value of +the tt(format) style (if that is set) instead of the default +description supplied by the completion function. If the description +given here contains itself a `tt(%d)', that is replaced with the +description supplied by the completion function. + +For example, to make the tt(rm) command first complete only names of +object files and the names of all files if no object file matches +the string on the line, one would do: + +example(zstyle ':completion:*:*:rm:*' file-patterns \ + '*.o:object-files' '%p:all-files') + +Another interesting example is to change the default behaviour that +makes completion first offer files matching the patterns given by the +calling function, then the directories and then all files. Many people +prefer to get both the files matching the given patterns and the +directories in the first try and all files as the second try. To +achieve this, one could do: + +example(zstyle ':completion:*' file-patterns \ + '%p *(-/):globbed-files' '*:all-files') + +Note also that during the execution of completion functions, the +tt(EXTENDED_GLOB) option is in effect, so the characters `tt(#)', +`tt(~)' and `tt(^)' have special meanings in the patterns. +) +kindex(format, completion style) +item(tt(format))( +If this is set for the tt(descriptions) tag, its value is used as a +string to display above matches in completion lists. The sequence +`tt(%d)' in this string will be replaced with a short description of +what these matches are. This string may also contain the sequences to +specify output attributes, such as `tt(%b)' and `tt(%s)'. + +For the same purpose, this style is also tested with the tags used +when matches are generated before it is tested for the +tt(descriptions) tag. This gives the possibility to define different +format strings for different types of matches. + +Note also that some completer functions define additional +`tt(%)'-sequences. These are described for the completer functions that +make use of them. + +For the tt(messages) tag, this defines a string used by some +completion functions to display messages. Here, the `tt(%d)' is +replaced with the message given by the completion function. + +Finally, for the tt(warnings) tag, it is printed when no matches could +be generated at all. In this case the `tt(%d)' is replaced with the +descriptions for the matches that were expected. If the value does not +contain a `tt(%d)', then those descriptions are added in the same way +as matches are added, i.e. they appear below the value for the +tt(format) style laid out in columns. The descriptions are added as if +for the tag tt(warnings) so that you can use the tt(list-colors) style +for that tag to highlight them. + +Here and in all other cases where the completion system uses `tt(%)' +sequences, the `tt(%)' may be followed by field width specifications as +described for the tt(zformat) builtin command from the tt(zutil) +module, see +ifzman(zmanref(zshmodules))\ +ifnzman(noderef(The zsh/zutil Module))\ +. +) +kindex(glob, completion style) +item(tt(glob))( +Like tt(completions), this is used by the tt(_expand) completer. + +The value is used like the one for tt(completions) and if it evaluates to +`tt(1)', globbing will be attempted on the words resulting from +substitution (see the tt(substitute) style) or the original string +from the line. +) +kindex(group-name, completion style) +item(tt(group-name))( +The completion system can put different types of matches in different +groups which are then displayed separately in the list of possible +completions. This style can be use to give the names for these groups +for particular tags. For example, in command position the completion +system generates names of builtin and external commands, names of +aliases and shell functions and reserved words as possible +completions. To have the external commands and shell functions listed +separately, one can set: + +example(zstyle ':completion:*:*:-command-:*:commands' group-name commands +zstyle ':completion:*:*:-command-:*:functions' group-name functions) + +This also means that if the same name is used for different types of +matches, then those matches will be displayed together in the same +group. + +If the name given is the empty string, then the name of the tag for +the matches will be used as the name of the group. So, to have all +different types of matches displayed separately, one can just set: + +example(zstyle ':completion:*' group-name '') + +All matches for which no group name is defined will be put in a group +named tt(-default-). +) +kindex(group-order, completion style) +item(tt(group-order))( +This style is to be used together with the tt(group-name) style. Once +different types of matches are put into different groups, this style +can be used to define in which order these groups should appear in the +list. The strings in the value are taken as group names and the named +groups will be shown in the order in which their names appear in the +value. All groups whose names are not given in the value of this style +will appear in the order defined by the function generating the +matches. + +For example, to have names of builtin commands, shell functions and +external commands appear in this order when completing in command +position one would set: + +example(zstyle ':completion:*:*:-command-:*' group-order \ + builtins functions commands) +) +kindex(groups, completion style) +item(tt(groups))( +A style holding the names of the groups that should be completed. If +this is not set by the user, the group names from the YP database or +the file `tt(/etc/group)' will be used. +) +kindex(hidden, completion style) +item(tt(hidden))( +If this is set to one of the `true' values, the matches for the tags +for which this is set will not appear in the list; only the +description for the matches as set with the tt(format) style will be +shown. If this is set to tt(all), not even the description will be +displayed. + +Note that the matches will still be completed, they are just not shown +in the list. To avoid having matches considered as possible +completions at all the tt(tag-order) style can be modified as described +below. +) +kindex(hosts, completion style) +item(tt(hosts))( +A style holding the names of hosts that should be completed. If this +is not set by the user the hostnames in `tt(/etc/hosts)' will be used. +) +kindex(hosts-ports, completion style) +item(tt(hosts-ports))( +This style is used by commands that need or accept hostnames and +ports. The strings in the value should be of the form +`var(host)tt(:)var(port)'. These hostnames and ports are completed +depending on the information already on the line, so that if, for +example, the hostname is already typed, only those ports will be +completed for which pairs with the hostname from the line exist. +) +kindex(ignore-parents, completion style) +item(tt(ignore-parents))( +When completing files it is possible to make names of directories +already mentioned on the line or the current working directory be +ignored. The style is tested for the tt(files) tag and if its value +contains the string tt(parent), then the name of any directory whose +path is already contained in the word on the line is ignored. For +example, when completing after tt(foo/../), the directory tt(foo) will +not be considered a valid completion. + +If the style contains the string tt(pwd), then the name of the current +working directory will not be completed, so that, for example, +completion after tt(../) will not use the name of the current +directory. + +If the style contains the string tt(..) both tests will only be +performed if the word on the line contains the substring tt(../) and +if the value contains the string tt(directory), then the tests will +only be performed if only names of directories are completed. + +Note that names of directories ignored because of one of the tests +will be ignored in the same way as the matches ignored because of the +tt(ignored-patterns) style. I.e. by using the tt(_ignored) completer +it is possible to complete these directories nonetheless. +) +kindex(ignored-patterns, completion style) +item(tt(ignored-patterns))( +This style is used with the tags used when adding matches and defines a +couple of patterns. All matches that are matched by any of these +patterns will be ignored as long as there are other matches not +matched by any of the patterns. It is a more configurable version +of the shell parameter tt($fignore). + +Note that during the execution of completion functions, the +tt(EXTENDED_GLOB) option is in effect, so the characters `tt(#)', +`tt(~)' and `tt(^)' have special meanings in the patterns. +) +kindex(insert-unambiguous, completion style) +item(tt(insert-unambiguous))( +This is used by the tt(_match) and tt(_approximate) completer +functions. If it is set to `true', the completer will start menu +completion only if no unambiguous string could be generated that is at +least as long as the original string from the line. Note that the +tt(_approximate) completer uses it after setting the completer field +in the context name to one of tt(correct-)var(num) or +tt(approximate-)var(num), where var(num) is the number of errors that +were accepted. +) +kindex(last-prompt, completion style) +item(tt(last-prompt))( +This is used to determine if the completion code should try to put the +cursor back onto the previous command line after showing a completion +listing (as for the tt(ALWAYS_LAST_PROMPT) option). Like several other +styles it is tested for the tt(default) tag and all tags used when +generating matches. The cursor will be moved back to the previous line +if this style is `true' for all types of matches added. Note also that +this is independent of the numeric argument -- unlike the +tt(ALWAYS_LAST_PROMPT) option. +) +kindex(list, completion style) +item(tt(list))( +This is used by the tt(_history_complete_word) bindable command +(context `tt(:completion:history-words)') and by the +tt(incremental-complete-word) widget (context `tt(:completion:incremental)). + +The tt(_history_complete_word) bindable command uses this style to +decide if the available matches should be shown. + +When using the tt(incremental-complete-word) widget, this style says +if the matches should be listed on every key press (if they fit on the +screen). + +The tt(predict-on) widget uses this style to decide if the completion +should be shown even if there is only one possible completion. This is +done if the value of this style is the string tt(always). +) +kindex(list-colors, completion style) +item(tt(list-colors))( +If the tt(zsh/complist) module is used, this style can be used to set +color specifications as with the tt(ZLS_COLORS) and tt(ZLS_COLOURS) +parameters (see +ifzman(the section `The zsh/complist Module' in zmanref(zshmodules))\ +ifnzman(noderef(The zsh/complist Module))\ +). + +If this style is set for the tt(default) tag, the strings in the value +are taken as specifications that are to be used everywhere. If it is +set for other tags, the specifications are used only for matches of +the type described by the tag. For this to work, the tt(group-name) +style has to be set to an empty string. If the tt(group-name) tag +specifies other names for the groups the matches in these groups can +be colored by using these names together with the `tt((group)...)' +syntax described for the tt(ZLS_COLORS) and tt(ZLS_COLOURS) parameters +and adding the specifications to the value for this style with the +tt(default) tag. + +To be able to share the same specifications one has set up for the GNU +version of the tt(ls) command one can use: + +example(zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}) + +And to get the default colors (which are the same as for the GNU +tt(ls) command) one should set the style to an empty value. +) +kindex(list-packed, completion style) +item(tt(list-packed))( +Like the tt(list-colors) style, this is tested with the tt(default) +tag and all tags used when generating matches. If it is set to `true' +for a tag, the matches added for it will be listed as if the +tt(LIST_PACKED) option were set for them. If it is set to `false', +they are listed normally. +) +kindex(list-rows-first, completion style) +item(tt(list-rows-first))( +This style is tested like the tt(list-packed) style and determines if +matches are to be listed in a rows-first fashion, as for the +tt(LIST_ROWS_FIRST) option. +) +kindex(local, completion style) +item(tt(local))( +This style is used by completion functions which generate URLs as +possible matches to add suitable matches when a URL points to a +local web server. Its value should consist of three strings: a +hostname, the path to the default web pages for the server and the +directory name used by a user placing web pages within their home +area. +) +kindex(match-original, completion style) +item(tt(match-original))( +This is used by the tt(_match) completer. If it is set to +tt(only), tt(_match) will try to generate matches without inserting a +`tt(*)' at the cursor position. If set to any other non-empty value, +it will first try to generate matches without inserting the `tt(*)' +and if that yields no matches, it will try again with the `tt(*)' +inserted. +) +kindex(matcher, completion style) +item(tt(matcher))( +This style is tested for tags used when generating matches. Its value +is used as an additional match specification to use when adding the +matches as described in +ifzman(the section `Matching Control' in zmanref(zshcompwid))\ +ifnzman(noderef(Matching Control))\ +. +) +kindex(matcher-list, completion style) +item(tt(matcher-list))( +This style is used by the main completion function to retrieve match +specifications that are to be used everywhere. Its value should be a +list of such specifications. The completion system will try them one +after another for each completer selected. For example, to first try +simple completion and, if that generates no matches, case-insensitive +completion one would do: + +example(zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}') + +But the style allows even finer control: the style is looked up for +every completer tried with the name of the completer (without the +leading underscore) in the context name. For example, if one uses the +completers tt(_complete) and tt(_prefix) and wants to try +case-insensitive completion only when using the tt(_complete) +completer, one would do: + +example(zstyle ':completion:*' completer _complete _prefix +zstyle ':completion:*:complete:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}') + +Note that the tt(completer) style allows to give user-defined names to +use in the context instead of the name of the completer. +This is useful if, for example, one wants to try +normal completion without a match specification and with +case-insensitive matching first, correction if that doesn't generate +any matches and partial-word completion if that doesn't yield any +matches either. In such a case one can give the tt(_complete) +completer more than once in the tt(completer) style and define different +match specifications for them, as in: + +example(zstyle ':completion:*' completer _complete _correct _complete:foo +zstyle ':completion:*:complete:*' matcher-list \ + '' 'm:{a-zA-Z}={A-Za-z}' +zstyle ':completion:*:foo:*' matcher-list \ + 'm:{a-zA-Z}={A-Za-z} r:|[-_./]=* r:|=*') + +Note that in any case an unset style makes the completion code use no +global match specification. Also, some completers (like tt(_correct) +and tt(_approximate)) do not use the match specifications. But even if +such completers are used one can use the simple form to set this style +(as in the first example above) because such completers will make sure +that they are executed only once even if multiple match specifications +have been given. +) +kindex(max-errors, completion style) +item(tt(max-errors))( +This is used by the tt(_approximate) and tt(_correct) completer functions +to determine the maximum number of errors to accept. The completer will try +to generate completions by first allowing one error, then two errors, and +so on, until either a match was found or the maximum number of errors +given by this style has been reached. + +If the value for this style contains the string tt(numeric), the +completer function will take any numeric argument as the +maximum number of errors allowed. For example, with + +example(zstyle ':completion:*:approximate:::' max-errors 2 numeric) + +two errors will be allowed if no numeric argument is given. However, +with a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six +errors are accepted. Hence with a value of `tt(0 numeric)', no correcting +completion will be attempted unless a numeric argument is given. + +If the value contains the string tt(not-numeric), the completer +will em(not) try to generate corrected +completions when given a numeric argument, so in this case the number given +should be greater than zero. For example, `tt(2 not-numeric)' specifies that +correcting completion with two errors will usually be performed, but if a +numeric argument is given, correcting completion will not be +performed. + +The default value for this style is `tt(2 numeric)'. +) +kindex(menu, completion style) +item(tt(menu))( +This style is tested for the tt(default) tag and the tags used when +adding matches. The value should be one of the `true' values (tt(yes), +tt(true), tt(1), or tt(on)) if menu completion should be started when +matches for the given tag (or always in case of the tt(default) tag) +are generated. If none of these values is defined for any of the tags +used, but for at least one of these tags the value is the string +tt(auto), this says that the same behavior as for the tt(AUTO_MENU) +option should be used. Finally, if menucompletion is started by some +other means (e.g. by setting the tt(MENU_COMPLETE) option) and the +value for one of the tags used is `false' (i.e. tt(no), tt(false), +tt(0), or tt(off)), then menucompletion will em(not) be started for +this completion. Note that the values defined for normal tags +override the value set for the tt(default) tag. + +Either instead of or in addition to one of the values above, the value +for this style may also contain the string tt(select), optionally +followed by an equal sign and a number. In this case menuselection +(as defined by the tt(zsh/computil) module) will be started. Without the +optional number, it will be started unconditionally and with a number +it will be started only if at least that many matches are generated +(if the values for more than one tag define such a number, the +smallest one is taken). Starting menuselection can explicitly be +turned off by defining a value containing the string +tt(no-select). +) +kindex(numbers, completion style) +item(tt(numbers))( +This is used with the tt(jobs) tag. If it is `true', the completions +will use the job numbers instead of the shortest unambiguous strings +of the jobs' command lines. If the value is a number, job numbers will +only be used if for at least one of the jobs that many (or more) words +from the command line string have to be used to make the strings +unambiguous. E.g. if it is set to `tt(1)', strings will only be used +if all jobs differ in the first word on their command lines. +) +kindex(old-list, completion style) +item(tt(old-list))( +This is used by the tt(_oldlist) completer. If this is set to tt(always), +then standard widgets which perform listing will retain the current list of +matches, however they were generated. If it is set to tt(never), this will +not be done (the behaviour without the tt(_oldlist) completer). If it is +unset, or any other value, then the existing list of completions will +be displayed if it is not already; otherwise, the standard completion +list will be generated: this is the default behaviour of +tt(_oldlist). However, if there is an old list and this style contains +the name of the completer function that generated the list, then the +old list will be used even if it was generated by a widget which does +not do listing. + +For example, suppose you type tt(^Xc) to use the tt(_correct_word) +widget, which generates a list of corrections for the word under the +cursor. Usually, typing tt(^D) would generate a standard list of +completions for the word on the command line, and show that. With +tt(_oldlist), it will instead show the list of corrections already +generated. + +As another example consider the tt(_match) completer: with the +tt(insert-unambiguous) style set to `true' it inserts only an +unambiguous prefix string if there is any. But since this may remove +parts of the original pattern, attempting completion again may result +in more matches than on the first attempt. But by using the +tt(_oldlist) completer and setting this style to tt(_match), the list of +matches generated on the first attempt will be used again. +) +kindex(old-menu, completion style) +item(tt(old-menu))( +This is used by the tt(_oldlist) completer. Here it controls how menu +completion behaves when a completion has already been inserted and the +user types a standard completion key type such as tt(TAB). The default +behaviour of tt(_oldlist) is that menu completion always continues +with the existing list of completions. If this style is set to +`false', however, a new completion is started if the old list was +generated by a different completion command (the behaviour without the +tt(_oldlist) completer). + +For example, suppose you type tt(^Xc) to generate a list of corrections, +and menu completion is started in one of the usual ways. Usually, typing +tt(TAB) at this point would start trying to complete the line as it now +appears. With tt(_oldlist), it will instead continue to cycle through the +list of completions. +) +kindex(original, completion style) +item(tt(original))( +This is used by the tt(_approximate) and tt(_correct) +completers to decide if the original string should be added as +one possible completion. Normally, this is done only if there are +at least two possible corrections, but if this style is set to `true', it +will always be added. Note that these completers use this style after +setting the completer field in the context name to +tt(correct-)var(num) or tt(approximate-)var(num), where var(num) is +the number of errors that were accepted. +) +kindex(packageset, completion style) +item(tt(packageset))( +A style containing an override for the default package set +for that context. For example, + +example(zstyle ':completion:*:complete:dpkg:--status-1:' packageset avail) + +will cause available packages, rather than only installed packages, +to be completed for `dpkg --status'. +) +kindex(path, completion style) +item(tt(path))( +This is used together with the the tt(urls) tag by completion +functions that generate URLs as possible matches. It should be set to +the path of a directory containing sub-directories named like +`tt(http)', `tt(ftp)', `tt(bookmark)', and so on. These +sub-directories should contain files and other sub-directories whose +pathnames are possible completions after the initial `tt(http://)', +`tt(ftp://)', etc. See the description in the file tt(_urls) in the +tt(User) sub-directory of the completion system for more information. + +Also, the function that completes color names uses this style with the +tt(colors) tag. Here, the value should be the pathname of a file +containing color names in the format of an X11 tt(rgb.txt) file. That +file (if it can be found) will be used as the default if the style is +not set. +) +kindex(ports, completion style) +item(tt(ports))( +A style holding the service names of ports to complete. If this is +not set by the user, the service names from `tt(/etc/services)' will +be used. +) +kindex(prefix-hidden, completion style) +item(tt(prefix-hidden))( +This is used when matches with a common prefix are added (e.g. option +names). If it is `true', this prefix will not be shown in the list of +matches. + +The default value for this style is `false'. +) +kindex(prefix-needed, completion style) +item(tt(prefix-needed))( +This, too, is used for matches with a common prefix. If it is set to +`true' this common prefix has to be typed by the user to generate the +matches. E.g. for options this means that the `tt(-)', `tt(+)', or +`tt(-)tt(-)' has to be on the line to make option names be completed at +all. + +The default style for this style is `true'. +) +kindex(prompt, completion style) +item(tt(prompt))( +The tt(incremental-complete-word) widget shows the value of this +style in the status line during incremental completion. The sequence +`tt(%u)' is replaced by the unambiguous part of all matches if there +is any and it is different from the word on the line. A `tt(%s)' is +replaced with `tt(-no match-)', `tt(-no prefix-)', or an empty string +if there is no completion matching the word on the line, if the +matches have no common prefix different from the word on the line or +if there is such a common prefix, respectively. The sequence `tt(%c)' +is replaced by the name of the completer function that generated the +matches (without the leading underscore). Finally, `tt(%n)' is +replaced by the number of matches generated +and if the tt(list) style is set, `tt(%l)' is +replaced by `tt(...)' if the list of matches is too long to fit on the +screen and with an empty string otherwise. If the tt(list) style is +`false', `tt(%l)' will always be removed. +) +kindex(remove-all-dups, completion style) +item(tt(remove-all-dups))( +The tt(_history_complete_word) bindable command uses this to decide if +all duplicate matches should be removed, rather than just consecutive +duplicates. +) +kindex(single-ignored, completion style) +item(tt(single-ignored))( +This is used by the tt(_ignored) completer. It allows to specify what +should be done if it can generate only one match, which is often a +special case. If its value is tt(show), the single match will only be shown, +not inserted. If the value is tt(menu), then the single match and the +original string are both added as matches and menucompletion is +started so that one can easily select either of them. +) +kindex(sort, completion style) +item(tt(sort))( +If set to `true', completion functions that generate words from the +history as possible matches sort these words alphabetically instead of +keeping them in the order in which they appear in the history (from +youngest to oldest). + +The completion function that generates filenames as possible matches +uses this style with the tt(files) tag to determine in which order the +names should be listed and completed when using menucompletion. The +value may be one of tt(size) to sort them by the size of the file, +tt(links) to sort them by the number of links to the file, +tt(modification) (or tt(time) or tt(date)) to sort them by the last +modification time, tt(access) to sort them by the last access time, or +tt(inode) (or tt(change)) to sort them by the last inode change +time. Any other value (or not setting this style at all) makes them be +sorted alphabetically by name. If the value contains the string +tt(reverse), sorting is done in decreasing order. + +This is also used by the tt(_expand) completer. Here, if it is set to +`true', the expansions generated will always be sorted. If it is set +to tt(menu), then the expansions are only sorted when they are offered +as single strings (not in the string containing all possible +expansions). +) +kindex(special-dirs, completion style) +item(tt(special-dirs))( +Normally, the completion code will not produce the directory names +tt(.) and tt(..) as possible completions. If this style is set to +`true', it will add both `tt(.)' and `tt(..)' as possible completions, +if it is set to tt(..), only `tt(..)' will be added. +) +kindex(squeeze-slashes, completion style) +item(tt(squeeze-slashes))( +If set to `true', sequences of slashes (like in `tt(foo//bar)') will be +treated as if they were only one slash when completing pathnames. +) +kindex(stop, completion style) +item(tt(stop))( +If set to `true', the tt(_history_complete_word) bindable +command will always insert matches as if menucompletion were started +and it will stop when the last match is inserted. If this style is set +to tt(verbose) a message will be displayed when the last match is reached. + +This style is also used by the tt(incremental-complete-word) +widget. Here its value is used like the one for the tt(break) +style. But all keys matching the pattern given as its value will stop +incremental completion and will then execute their usual function. +) +kindex(subst-globs-only, completion style) +item(tt(subst-globs-only))( +This is used by the tt(_expand) completer. As for the tt(glob) style, +the value should be a value usable in a `tt($((...)))' arithmetical +expression. If it evaluates to `tt(1)', the expansion will only be +used if they resulted from globbing. If only the expansions described +for the tt(substitute) style described below resulted in expanded +strings and globbing did not change the set of expanded strings, the +tt(_expand) completer will do nothing. +) +kindex(substitute, completion style) +item(tt(substitute))( +If this is unset or set to the empty string, the tt(_expand) completer +will first try to expand all substitutions in the string (such as +`tt($LPAR()...RPAR())' and `tt(${...})'). If this is set to an +non-empty string it should be an expression usable inside a `tt($((...)))' +arithmetical expression. In this case, expansion of substitutions will +be done if the expression evaluates to `tt(1)'. For example, with + +example(zstyle ':completion:*:expand:::' substitute '${NUMERIC:-1} != 1') + +substitution will be performed only if given an explicit numeric +argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'. +) +kindex(tag-order, completion style) +kindex(tag-order, completion style) +item(tt(tag-order))( +This provides a mechanism for sorting how the tags available in a +particular context will be used. + +The values for the style are sets of space-separated lists of tags. +The tags in each value will be tried at the same time; if no match is +found, the next value is used. + +For example: + +example(zstyle ':completion:*:complete:gunzip:*' tag-order \ + arguments options) + +specifies that, many completion functions offer both completions for +arguments and options immediately instead of offering first arguments +and then option as usual. + +A string starting with an exclamation mark (`tt(!)') +specifies names of tags that are not to be used -- the effect will be +the same as if all other possible tags for the context had been +listed. If any string in the value consists of only a hyphen +(`tt(-)'), then only the tags selected by the other strings will be +generated. Normally all tags not explicitly selected will be tried at +the end if the selected tags did not generate any matches. This means +that a value of only one hyphen turns off completion in a particular +context. + +In strings not starting with an exclamation mark, it is also possible +to specify tag labels instead of only tags. These are of the form +`var(tag)tt(:)var(label)', where var(tag) is one of the tags offered +by the completion function for the current context and var(label) is a +name. For this, the completion function will generate matches in the +same way as for the var(tag) but it will use the var(label) in place +of the tag in the context names used to look up styles. If the +var(label) starts with a hyphen, the var(tag) is prepended to the +var(label) to form the name used for lookup. This can be +used to make the completion system try a certain tag more than once, +supplying different style settings for each attempt. For example, + +example(zstyle ':completion:*:*:-command-:*' tag-order 'functions:-non-comp' +zstyle ':completion:*:functions-non-comp' ignored-patterns '_*') + +Makes completion in command position first try only names of shell +functions that don't match the pattern `tt(_*)'. If that generates no +matches, the default of trying all the other things that can be +completed in command position is used, including the names of all +shell functions. + +The var(label) may optionally be followed by a second colon and a +description. This description will then be used for the `tt(%d)' in +the value of the tt(format) style instead of the default description +supplied by the completion function. Spaces in the description have to +be quoted by preceding them with a backslash and a `tt(%d)' appearing +in the description is replaced with the description given by the +completion function. + +In each of the cases above, the tag may also be a pattern. In this +case all of the offered tags matching this pattern will be used except +for those that are given explicitly in the same string. There are +probably two main uses of this. One is the case where one wants to try +one of the tags more than once, setting other styles differently for +each try, but still wants to use all the other tags without having to +bother to repeat them all. For example, to make completion of function +names in command position first ignore all the completion functions +starting with an underscore one could do: + +example(zstyle ':completion:*:*:-command-:*' tag-order \ + 'functions:-non-comp *' functions +zstyle ':completion:*:functions-non-comp' ignored-patterns '_*') + +Here, the completion system will first try all tags offered, but will +use the tag label tt(functions-non-comp) when looking up styles for +the function names completed. For this, the tt(ignored-patterns) style +is set to make functions starting with an underscore be not considered +as possible matches. If none of the generated matches match the string +on the line, the completion system will use the second value of the +tt(tag-order) style and complete functions names again, but this time +using so name tt(functions) to look up styles, so that the +tt(ignored-patterns) style will not be used and all function names +will be considered. + +Of course, this can also be used to split the matches for one tag into +different groups. For example: + +example(zstyle ':completion:*:options' tag-order \ + 'options:-long:long options + options:-short:short options + options:-single-letter:single letter options' + +zstyle ':completion:*:options-long' ignored-patterns '[-+](|-|[^-]*)' +zstyle ':completion:*:options-short' ignored-patterns '--*' '[-+]?' +zstyle ':completion:*:options-single-letter' ignored-patterns '???*') + +With the tt(group-names) style set, this makes options beginning with +`tt(-)tt(-)', options beginning with a single `tt(-)' or `tt(+)' but +containing multiple characters and single-letter options be displayed +in separate groups with different descriptions. + +The second interesting use of patterns is the case where one wants to +try multiple match specifications one after another. The +tt(matcher-list) style offers something similar, but it is tested very +early in the completion system and hence can't be set for single +commands or even more specific contexts. So, to make completion for +the arguments of the command tt(foo) and only for this command first +try normal completion with out any match specification and, if that +generates no matches, try again with case-insensitive matching, one +could do: + +example(zstyle ':completion:*:*:foo:*' tag-order '*' '*:-case' +zstyle ':completion:*-case' matcher 'm:{a-z}={A-Z}') + +This will make the completion system first try all the tags offered +when completing after tt(foo) and use the tags to do the lookup. If +that generates no matches, the second value of tt(tag-order) is +used. This will make all tags be tried again, but this time using the +names of the tags with the tt(-case) appended to them for lookup of +styles. I.e. in this second attempt, the value for the tt(matcher) +style from the second call to tt(zstyle) in the example will be used +to make completion case-insensitive. + +Strings in the value may also be of the form `var(func)tt(())'. In +this case the function var(func) will be called which can then define +in which order tags are to be used based on additional context +information. See the tt(_sort_tags) function below for a description +of how such functions can be implemented. The return value of the +function is used to decide if the following values for the style +should be used. If it is zero, they are used and if it is non-zero, +they are not used. For example: + +example(non-empty() { [[ -n $PREFIX ]] } +zstyle ':completion:*:*:-command-:*' tag-order 'non-empty()') + +Makes completion in command position happen only if the string on the +line is not empty (this is tested using the tt(PREFIX) +parameter which is special in completion widgets, see +ifzman(zshcompwid)\ +ifnzman(the section noderef(Completion System))\ +)\ +for a description of these special parameters). + +If no style has been defined for a context, the strings tt(arguments +values) and tt(options) plus all tags offered by the completion +function will be used to provide a sensible default behavior. +) +kindex(use-compctl, completion style) +item(tt(use-compctl))( +If this style is set to a string not equal to tt(false), tt(0), +tt(no), and tt(off), the completion system will use any completion +specifications defined with the tt(compctl) builtin command. If the +style is unset, this will only be done if the tt(zsh/compctl) module +is loaded. The string may also contain the substring tt(first) to make +the definition for tt(compctl -T) be used and the substring +tt(default) to make the one for tt(compctl -D) be used. + +Note that this is only intended to smooth the transition from +tt(compctl) to the new completion system and may disappear in the +future. + +Note also that the definitions from tt(compctl) will only be used if +there is no special completion function for the command completion is +done upon. +) +kindex(users, completion style) +item(tt(users))( +This may be set to a list of names that should be completed whenever +a username is needed. If it is not set or the string on the line +doesn't match any of the strings in this list, all usernames will be +completed. +) +kindex(users-hosts, completion style) +item(tt(users-hosts))( +The values of this style should be of the form +`var(user)tt(@)var(host)' or `var(user)tt(:)var(host)'. It is used for +commands that need pairs of +user- and hostnames. For such commands, only the pairs from this style +are used and if, for example, the username is already typed, then only +the hostnames for which there is a pair with that username is defined. + +If set for the tt(my-accounts) tag, this is used for commands such as +tt(rlogin) and tt(ssh). I.e. the style should contain the names of the +user's own accounts. With the tt(other-accounts) tag this is used for +commands such as tt(talk) and tt(finger) and should contain other +people's accounts. Finally, this may also be used by some commands with +the tt(accounts) tag. +) +kindex(users-hosts-ports, completion style) +item(tt(users-hosts-ports))( +Like tt(users-hosts) but used for commands like tt(telnet) and +containing strings of the form `var(user)tt(@)var(host)tt(:)var(port)'. +) +kindex(verbose, completion style) +item(tt(verbose))( +This is used in several contexts to decide if only a simple or a +verbose list of matches should be generated. For example some commands +show descriptions for option names if this style is `true'. + +The default value for this style is `true'. +) +kindex(word, completion style) +item(tt(word))( +To find out if listing should be performed on its own, the tt(_list) +completer normally compares the contents of the line with the contents +the line had at the time of the last invocation. If this style is set to +`true', comparison is done using only the current word. In this case, +attempting completion on a word equal to the one when completion was called +the last time will not delay the generation of matches. +) +enditem() -The initialisation script tt(compinit) re-binds all the keys which perform -completion to newly created widgets that all call the supplied widget -function tt(_main_complete). This function acts as a wrapper calling -the so-called `completer' functions that generate matches. If -tt(_main_complete) is -called with arguments, these are taken as the names of completer -functions to be called in the order given. If no arguments are given, the -set of functions to try is taken from the colon-separated list in the -configuration key tt(completer). For example, to use normal -completion and correction if that doesn't generate any matches: - -indent( -nofill(tt(compconf completer=_complete:_correct)) -) - -after sourcing tt(compinit). The default value for this configuration key -set up in tt(compinit) is `tt(_complete)', i.e. normally only ordinary -completion is tried. The tt(_main_complete) function uses the return value -of the completer functions to decide if other completers should be +texinode(Control Functions)(Bindable Commands)(Completion System Configuration)(Completion System) +sect(Control Functions) +cindex(completion system, choosing completers) + +The initialization script tt(compinit) redefines all the widgets +which perform completion to call the supplied widget function +tt(_main_complete). This function acts as a wrapper calling the +so-called `completer' functions that generate matches. If +tt(_main_complete) is called with arguments, these are taken as the +names of completer functions to be called in the order given. If no +arguments are given, the set of functions to try is taken from the +tt(completer) style. For example, to use normal completion and +correction if that doesn't generate any matches: + +example(zstyle ':completion:*' completer _complete _correct) + +after calling tt(compinit). The default value for this style +is `tt(_complete)', i.e. normally only ordinary +completion is tried. The tt(_main_complete) function uses the return +value of the completer functions to decide if other completers should be called. If the return value is zero, no other completers are tried and the tt(_main_complete) function returns. The following completer functions are contained in the distribution (users may write their own): +cindex(completion system, completers) startitem() +findex(_complete) item(tt(_complete))( This completer generates all possible completions in a context-sensitive -manner, i.e. using the tt(compdef) function +manner, i.e. using the settings defined with the tt(compdef) function explained above and the current settings of all special parameters. To complete arguments of commands, tt(_complete) uses the utility function @@ -228,53 +1816,68 @@ tt(-)var(context)tt(-), as mentioned above for the tt(#compdef) tag, are handled specially. These are: startitem() +kindex(-equal-, completion context) item(tt(-equal-))( for completion after an equal sign, other than one occurring in a shell-variable assignment. ) +kindex(-tilde-, completion context) item(tt(-tilde-))( for completion after a tilde (`tt(~)') character, but before a slash. ) +kindex(-redirect-, completion context) item(tt(-redirect-))( for completion after a redirection operator. ) +kindex(-math-, completion context) item(tt(-math-))( for completion inside mathematical contexts, such as `tt(LPAR()LPAR())...tt(RPAR()RPAR())'. ) +kindex(-subscript-, completion context) item(tt(-subscript-))( for completion inside subscripts. ) +kindex(-value-, completion context) item(tt(-value-))( for completion on the right hand side of an assignment. ) +kindex(-array-value-, completion context) item(tt(-array-value-))( for completion on the right hand side of an array-assignment (`tt(foo=LPAR()...RPAR())'). ) +kindex(-condition-, completion context) item(tt(-condition-))( for completion inside conditions (`tt([[...]])'). ) +kindex(-parameter-, completion context) item(tt(-parameter-))( for completing the name of a parameter expansion (`tt($...)'). ) +kindex(-brace-parameter-, completion context) item(tt(-brace-parameter-))( for completing the name of a parameter expansion within braces (`tt(${...})'). ) +kindex(-first-, completion context) item(tt(-first-))( -for adding completions before any other other completion functions are -tried (similar to the `tt(-T)' flag of tt(compctl)); if this -function sets the tt(_compskip) parameter to any value, the completion -system will not call any other function to generate matches. +for adding completions before any other completion functions are +tried; if this +function sets the tt(_compskip) parameter to tt(all), no other +completion functions will be called, if it is set to a string +containing the substring tt(patterns), no pattern completion functions +will be called, and if it is set to a string containing tt(default) +the function for the `tt(-default-)' context will not be called, but +functions defined for commands will. ) +kindex(-default-, completion context) item(tt(-default-))( -for generating completions when no special completion function is used -(similar to the `tt(-D)' option of tt(compctl)). +for generating completions when no special completion function is used. ) +kindex(-command-, completion context) item(tt(-command-))( -for completing in a command position (as with the `tt(-C)' option of -tt(compctl)). +for completing in a command position. ) enditem() @@ -282,7 +1885,13 @@ Default implementations are supplied for each of these contexts, in most cases named after the context itself (e.g. completion for the `tt(-tilde-)' context is done by the function named `tt(_tilde)'). + +Before trying to find a function for a specific context, tt(_complete) +checks if the parameter `tt(compcontext)' is set to a non-empty +value. If it is, the value is taken as the name of the context to use +and the function defined for that context will be called. ) +findex(_approximate) item(tt(_approximate))( This completer function uses the tt(_complete) completer to generate a list of strings for the context the cursor is currently in, allowing @@ -299,105 +1908,45 @@ counted. The resulting list of corrected and completed strings is then presented to the user. The intended use of this completer function is to try after the normal tt(_complete) completer by setting: -indent( -nofill(tt(compconf completer=_complete:_approximate)) -) +example(zstyle ':completion:*' completer _complete _approximate) This will give correcting completion if and only if normal completion doesn't yield any possible completions. When corrected completions are found, the completer will normally start menucompletion allowing you to cycle through these strings. -The exact behavior of this completer can be changed by using the -following configuration keys: - -startitem() -item(tt(approximate_accept))( -This should be set to the number of errors the correction code should -accept. The completer will try to generate completions by first allowing -one error, then two errors, and so on, until either a match -was found or the maximum number of errors given by this key has -been reached. - -If the value for this key contains a lower- or upper-case `tt(n)', the -completer function will take any numeric argument as the -maximum number of errors allowed. For example, with - -indent( -nofill(tt(compconf approximate_accept=2n)) -) - -two errors will be allowed if no numeric argument is given. However, -with a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six -errors are accepted. Hence with a value of `tt(0n)', no correcting -completion will be attempted unless a numeric argument is given. - -If the value contains `tt(n)' or `tt(N)' and a exclamation mark -(`tt(!)'), tt(_approximate) will var(not) try to generate corrected -completions when given a numeric argument, so in this case the number given -should be greater than zero. For example, `tt(2n!)' specifies that -correcting completion with two errors will usually be performed, but if a -numeric argument is given, correcting completion will not be performed. -) -item(tt(approximate_original))( -This key is used to specify whether the original string on which correcting -completion was attempted is to be included in the list of possible -corrections. If it is set to any non-empty string, the original string -will be offered when cycling through the completions. Normally it will -appear as the first string, so that the command line does not change -immediately; consecutive completion attempts will cycle through the -corrected strings. If the value for this key contains the substring -`tt(last)', the original string will be the last one in the list, so -that it appears just before wrapping around to the first corrected -string again. Also, if the value contains the substring `tt(always)', -the original string will always be included; normally it is -included only if more than one possible correction was generated. -) -item(tt(approximate_prompt))( -This can be set to a string to be displayed on top of the -corrected strings generated when cycling through them. This string -may contain the control sequences `tt(%n)', `tt(%B)', etc. known from -the `tt(-X)' option of tt(compctl). Also, the sequence `tt(%e)' will -be replaced by the number of errors accepted to generate the corrected -strings. -) -item(tt(approximate_insert))( -If this is set to a string starting with `tt(unambig)', the code will try -to insert a usable unambiguous string in the command line instead of -always cycling through the corrected strings. If such a unambiguous -string could be found, the original string is not used, independent of -the setting of tt(approximate_original). If no sensible string could be -found, one can cycle through the corrected strings as usual. -) -enditem() - -If any of these keys is not set, but the the same key with the prefix -`tt(correct)' instead of `tt(approximate)' is set, that value will be -used. The forms beginning with `tt(correct)' are also used by the -tt(_correct) completer function. - -The keys with the `tt(approximate)' prefix have no default values, but -tt(compinit) defines default values for tt(correct_accept) (which -is set to `tt(2n)'), and tt(correct_prompt). +This completer uses the tags tt(corrections) and tt(original) when +generating the possible coprrections and the original string. The +tt(format) style for the former may contain the additional sequences +`tt(%e)' and `tt(%o)' which will be replaced by the number of errors +accepted to generate the corrections and the original string, +respectively. + +Like all completers tt(_approximate) uses its name without the +undersccore in the var(completer) field of the context name. Once it +has started trying to generate matches, it will append a minus sign +and the number of errors accepted in this attempt to its name. So on the +first try the field contains `tt(approximate-1)', on the +second try `tt(approximate-2)', and so on. ) +findex(_correct) item(tt(_correct))( Generate corrections (but not completions) for the current word; this is -similar to spell-checking. This calls tt(_approximate), but only the -configuration parameters beginning tt(correct_) are used. +similar to spell-checking. This calls tt(_approximate) but uses a +different var(completer) field in the context name. For example, with: -indent(tt( -nofill(compconf completer=_complete:_correct:_approximate) -nofill(compconf correct_accept='2n!' approximate_accept=3n)) -) +example(zstyle ':completion:::::' completer _complete _correct _approximate +zstyle ':completion:*:correct:::' accept 2 not-numeric +zstyle ':completion:*:approximate:::' accept 3 numeric) correction will accept up to two errors. If a numeric argument is -given, correction will not be performed, but correcting completion will be, -and will accept as many errors as given by the numeric argument. -Without a numeric argument, first correction and then correcting -completion will be tried, with the first one accepting two errors -and the second one accepting three errors. +given, correction will not be performed, but correcting completion +will be, and will accept as many errors as given by the numeric +argument. Without a numeric argument, first correction and then +correcting completion will be tried, with the first one accepting two +errors and the second one accepting three errors. This completer function is intended to be used without the tt(_approximate) completer or, as in the example, just before @@ -405,21 +1954,31 @@ it. Using it after the tt(_approximate) completer is useless since tt(_approximate) will at least generate the corrected strings generated by the tt(_correct) completer -- and probably more. ) +findex(_match) item(tt(_match))( This completer is intended to be used after the tt(_complete) completer. It allows one to give patterns on the command line and -to complete all strings metching these patterns from the set of possible -completions for the context the cursor is in, without having to set -the tt(GLOB_COMPLETE) option. +to complete all strings matching these patterns from the set of +possible completions for the context the cursor is in, without having +to set the tt(GLOB_COMPLETE) option. Normally this will be done by taking the pattern from the line, inserting a `tt(*)' at the cursor position and comparing the resulting pattern with the possible completions generated. However, if the -configuration key tt(match_original) has a value of `tt(only)', no -`tt(*)' will be inserted. If tt(match_original) has any other non-empty -string as its value, this completer will first try to generate matches -without, then with a `tt(*)' inserted at the cursor position. +tt(match-original) style has a value of tt(only), no `tt(*)' will be +inserted. If tt(match-original) has any other non-empty string as its +value, this completer will first try to generate matches without, then +with a `tt(*)' inserted at the cursor position. + +The generated matches will be offered in a menucompletion unless the +tt(insert-unambiguous) style is set to `true'. In +this case menucompletion will only be started if no unambiguous string +could be generated that is at least as long as the original string. + +Note that the matcher specifications defined globally or used by the +completion functions will not be used. ) +findex(_expand) item(tt(_expand))( This completer function does not really do completion, but instead checks if the word on the command line is eligible for expansion and, @@ -430,93 +1989,98 @@ will expand the string on the line before the completion widget is called. Also, this completer should be called before the tt(_complete) completer function. -Control over how the expanded string will be treated is possible with the -following configuration keys: - -startitem() -item(tt(expand_substitute))( -If this is unset or set to the empty string, the code will first try -to expand all substitutions in the string (such as -`tt($LPAR()...RPAR())' and `tt(${...})'). If this is set to an -non-empty string it should be an expression usable inside a `tt($((...)))' -arithmetical expression. In this case, expansion of substitutions will -be done if the expression evaluates to `tt(1)'. For example, with - -indent( -nofill(tt(compconf expand_substitute='NUMERIC != 1')) -) - -substitution will be performed only if given an explicit numeric -argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'. -) -item(tt(expand_glob))( -If this is unset or set to an empty string, globbing will be attempted -on the word resulting from substitution or the original string. The -values accepted for this key are the same as for tt(expand_substitute). -) -item(tt(expand_menu))( -If this is unset or set to the empty string, the words resulting from -expansion (if any) will simply be inserted in the command line, -replacing the original string. However, if this key is set to a -non-empty string, the user can cycle through the expansion as in -menucompletion. Unless the value contains the substring `tt(only)', -the user will still be offered all expansions at once as one of the -strings to insert in the command line; normally, this possibility is -offered first, but if the value contains the -substring `tt(last)', it is offered last. Finally, if the value contains -the substring `tt(sort)', the expansions will be sorted alphabetically, -normally they are kept in the order the expansion produced them in. -) -item(tt(expand_original))( -If this is set to an non-empty string, the original string from the -line will be included in the list of strings the user can cycle -through as in a menucompletion. If the value contains the substring -`tt(last)', the original string will appear as the last string, with -other values it is inserted as the first one (so that the command line -does not change immediately). -) -item(tt(expand_prompt))( -This may be set to a string that should be displayed before the -possible expansions. This is passed to the `tt(-X)' option of -tt(compadd) and thus may contain the control sequences `tt(%n)', -`tt(%B)', etc. Also, the sequence `tt(%o)' in this string will be -replaced by the original string. -) -enditem() - -None of these configuration keys has a default value. +The tags used when generating expansions are tt(all-expansions) for +the string containing all possible expansions, tt(expansions) when +adding the possible expansions as single matches and tt(original) when +adding the original string from the line. In which order these strings +are generated and which of these strings are generated at all can be +controlled by using the tt(group-order) style and by modifying the +tt(tag-order) style, as usual. + +The format string for tt(all-expansions) and for tt(expansions) may +contain the sequence `tt(%o)' which will be replaced by the original +string from the line. + +Which kind of expansion is tried is controlled by the tt(substitute) +and tt(glob) styles. Note that neither of these has a default value so +that they have to be set to make tt(_expand) generate any expansions +at all. + +In a different mode selected by the tt(completions) style, all +em(completions) generated for the string on the line are inserted. ) +findex(_list) item(tt(_list))( This completer allows one to delay the insertion of matches until completion is attempted a second time without the word on the line being changed. On the first attempt, only the list of matches will be -shown. Configuration keys understood are: - -startitem() -item(tt(list_condition))( -If this key is unset or set to the empty string, the insertion of -matches will be delayed unconditionally. If this value is set, it -should be set to an expression usable inside a `tt($((...)))' -arithmetical expression. In this case, delaying will be done if the -expression evaluates to `tt(1)'. For example, with - -indent( -nofill(tt(compconf list_condition='NUMERIC != 1')) +shown. Styles used are tt(condition) and tt(word), see +ifzman(the section `Completion System Configuration' above)\ +ifnzman(noderef(Completion System Configuration)). ) - -delaying will be done only if given an explicit numeric argument -other than `tt(1)'. +findex(_oldlist) +item(tt(_oldlist))( +This completer controls how the standard completion widgets behave +when there is an existing list of completions which may have been +generated by a special completion (i.e. a separately-bound completion +command). It should appear in the list of completers before any of +the widgets which generate matches. It uses two styles: tt(old-list) and +tt(old-menu), see +ifzman(the section `Completion System Configuration' above)\ +ifnzman(noderef(Completion System Configuration)). ) -item(tt(list_word))( -To find out if listing should be performed on its own, the code normally -compares the contents of the line with the contents the line had at the -time of the last invocation. If this key is set to an non-empty string, -comparison is done using only the current word. So if it is set, -attempting completion on a word equal to the one when completion was called -the last time will not delay the generation of matches. +findex(_prefix) +item(tt(_prefix))( +This completer can be used to try completion with the suffix after the +cursor ignored. I.e. the suffix will not be considered to be part of +the word to complete and hence does not need to be matched. It uses +the tt(completer) style to decide which other completers to call to +try to generate matches. If this style is unset, the completers +currently used by the whole completion are used -- except, of course, +the tt(_prefix) completer itself. Also, if this completer appears more +than once in the list of completers only those completers not +already tried by the last invocation of tt(_prefix) will be +called. + +For example, consider this global tt(completer) style: + +example(zstyle ':completion:*' completer \ + _complete _prefix _correct _prefix:foo) + +This makes the tt(_prefix) completer try normal completion with the +suffix ignored. If that doesn't generate any matches and neither does +the call to the tt(_correct) completer after it, then tt(_prefix) will +be called a second time and will now only try correction with the +suffix ignored. If you want to use tt(_prefix) as the last resort and +want it to try only normal completion, you need to call: + +example(zstyle ':completion:*' completer _complete ... _prefix +zstyle ':completion::prefix:*' completer _complete) + +The tt(add-space) style is used, too. If it is set to `true' then +tt(_prefix) will insert a space between the matches generated (if any) +and the suffix. + +Note that using this completer will only work if the +tt(COMPLETE_IN_WORD) option is set. Because otherwise the cursor will +be set after the word before the completion code is called and hence +there will be no suffix. ) -enditem() +findex(_ignored) +item(tt(_ignored))( +Using the tt(ignored-patterns) style it is possible to make some +matches be ignored. This completer allows to complete these matches as +if no tt(ignored-patterns) style were set. Which completers are called +for this is determined in the same way as for the tt(_prefix) +completer. + +Finally, tt(_ignored) uses the tt(single-ignored) style if only one +match could be generated. It can be set to tt(show) to make that match +be only displayed, not inserted into the line or it can be set to +tt(menu) to make the single match and the original string from the +line be offered in a menucompletion. ) +findex(_menu) item(tt(_menu))( This completer is a simple example function implemented to show how menucompletion can be done in shell code. It should be used as the @@ -528,8 +2092,128 @@ tt(accept-and-menu-complete). ) enditem() -texinode(Completion Functions)()(Control Functions)(Completion System) +texinode(Bindable Commands)(Completion Functions)(Control Functions)(Completion System) +sect(Bindable Commands) +cindex(completion system, bindable commands) + +In addition to the context-dependent completions provided, which are +expected to work in an intuitively obvious way, there are a few widgets +implementing special behaviour which can be bound separately to keys. The +following is a list of these and their default bindings. + +startitem() +findex(_bash_completions) +item(tt(_bash_completions))( +This function is used by two widgets, tt(_bash_complete-word) and +tt(_bash_list-choices). It exists to provide compatibility with +completion bindings in bash. The last character of the binding determines +what is completed: `tt(!)', command names; `tt($)', environment variables; +`tt(@)', host names; `tt(/)', file names; `tt(~)' user names. In bash, the +binding preceeded by `tt(\e)' gives completion, and preceeded by `tt(^X)' +lists options. As some of these bindings clash with standard zsh +bindings, only `tt(\e~)' and `tt(^X~)' are bound by default. To add the +rest, the following should be added to tt(.zshrc) after tt(compinit) has +been run: + +example(for key in '!' '$' '@' '/' '~'; do + bindkey "\e$key" _bash_complete-word + bindkey "^X$key" _bash_list-choices +done) + +This includes the bindings for `tt(~)' in case they were already bound to +something else; the completion code does not override user bindings. +) +findex(_correct_filename (^XC)) +item(tt(_correct_filename (^XC)))( +Correct the filename path at the cursor position. Allows up to six errors +in the name. Can also be called with an argument to correct +a filename path, independently of zle; the correction is printed on +standard output. +) +findex(_correct_word) (^Xc) +item(tt(_correct_word) (^Xc))( +Performs correction of the current argument using the usual contextual +completions as possible choices. This stores the string +`tt(correct-word)' in the var(function) field of the context name and +then calls the tt(_correct) completer. +) +findex(_expand_word (^Xe)) +item(tt(_expand_word (^Xe)))( +Performs expansion on the current word: equivalent to the standard +tt(expand-word) command, but using the tt(_expand) completer. Before +calling it, the var(function) field is set to `tt(expand-word)'. +) +findex(_history_complete_word) (\e/) +item(tt(_history_complete_word) (\e/))( +Complete words from the shell's command history. This uses the +tt(list), tt(remove-all-dups), tt(sort), and tt(stop) styles. +) +findex(_most_recent_file (^Xm)) +item(tt(_most_recent_file (^Xm)))( +Complete the name of the most recently modified file matching the pattern +on the command line (which may be blank). If given a numeric argument +var(N), complete the var(N)th most recently modified file. Note the +completion, if any, is always unique. +) +findex(_next_tags) +item(tt(_next_tags))( +This allows to complete types of matches that are not immediately +offered because of the setting of the tt(tag-order) style. After a +normal completion was tried, invoking this command makes the matches +for the next tag (or set of tags) be used. Repeatedly invoking this +command makes the following tags be used. To be able to complete the +matches selected by tt(_next_tags), the tt(completer) style should +contain tt(_next_tags) as its first string. With that, the normal key +binding (normally tt(TAB)) can be used to complete the matches shown +after the call to tt(_next_tags). + +Normally, this command is not bound to a key. To invoke it with, say +`tt(^Xn)', one would use: + +example(zle -C _next_tags complete-word _next_tags +bindkey '^Xn' _next_tags) +) +findex(_read_comp (^X^R)) +item(tt(_read_comp (^X^R)))( +Prompt the user for a string, and use that to perform completion on the +current word. There are two possibilities for the string. First, it can +be a set of words beginning `tt(_)', for example `tt(_files -/)', in which +case the function with any arguments will be called to generate the +completions. Unambiguous parts of the function name will be completed +automatically (normal completion is not available at this point) until a +space is typed. + +Any other string will be passed as a set of arguments to +tt(compadd) and should hence be an expression specifying what should +be completed. + +A very restricted set of editing commands is available when reading the +string: `tt(DEL)' and `tt(^H)' delete the last character; `tt(^U)' deletes +the line, and `tt(^C)' and `tt(^G)' abort the function, while `tt(RET)' +accepts the completion. Note the string is used verbatim as a command +line, so arguments must be quoted in accordance with standard shell rules. + +Once a string has been read, the next call to tt(_read_comp) will use the +existing string instead of reading a new one. To force a new string to be +read, call tt(_read_comp) with a numeric argument. +) +findex(_complete_help (^Xh)) +item(tt(_complete_help (^Xh)))( +This widget displays information about the context names, +the tags, the styles, and the completion functions used +when completing at the current cursor position. + +Note that, depending on the control flow in the completion functions +called, the information about the styles may be +incomplete. I.e. depending on the settings for some styles other +styles may be used, and, depending on the user's settings, only the +first sort of styles may be detected by tt(_complete_help). +) +enditem() + +texinode(Completion Functions)(Completion Directories)(Bindable Commands)(Completion System) sect(Utility Functions) +cindex(completion system, utility functions) Descriptions follow for utility functions that may be useful when writing completion functions. Most of these reside in the @@ -539,8 +2223,26 @@ generating matches all follow the convention of returning zero if they generated completions and non-zero if no matching completions could be added. +When writing completion functions or other ZLE widgets that call +completion, it might be interesting to know about two more features +offered by the tt(_main_complete) function. The arrays +tt(compprefuncs) and tt(comppostfuncs) may be set to contain names of +functions that are to be called immediately before or after completion +has been tried. The functions will only be called once, unless they +put themselves into the array again. + startitem() -item(tt(_compalso))( +findex(_funcall) +item(tt(_funcall) var(return) var(name) [ var(args) ... ])( +If a function var(name) exists, it is called with the arguments +var(args). Unless it is the empty string or a single hyphen, +var(return) is taken as the name of a parameter and the return status +from the called function is stored in it. +The return value of tt(_funcall) itself is zero if the function +var(name) exists and was called and non-zero otherwise. +) +findex(_compalso) +item(tt(_compalso) var(names) ...)( This function looks up the definitions for the context and command names given as arguments and calls the handler functions for them if there is a definition (given with the tt(compdef) function). For @@ -548,6 +2250,20 @@ example, the function completing inside subscripts might use `tt(_compalso -math-)' to include the completions generated for mathematical environments. ) +findex(_call) +item(tt(_call) var(tag) var(string) ...)( +This function is used in places where a command is called and the user +should have the possibility to override the default for calling this +command. It looks up the tt(command) style with the supplied +var(tag). If the style is set, its value is used as the command to +execute. + +In any case, the var(strings) from the call to tt(_call) or from the +style are concatenated with spaces between them and the resulting +string is evaluated. The return value is the return value of the +command called. +) +findex(_normal) item(tt(_normal))( This function is used for normal command completion. If completion is attempted on the first word, command names are @@ -561,14 +2277,271 @@ the tt(words) array, decrements the tt(CURRENT) parameter, then calls this function. When calling a function defined for a pattern, this function also -checks if the parameter tt(_compskip) is set. If it was set by the -function called, no further completion functions are called. With this +checks if the parameter tt(_compskip) is set and uses the value in the +same way it is used after calling the completion function for the +tt(-first-) context. With this one can write a pattern completion function that keeps other functions from being tried simply by setting this parameter to any value. ) -item(tt(_multi_parts))( -This functions gets two arguments: a separator character and an -array. As usual, the array may be either the +findex(_description) +item(tt(_description) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(specs) ... ])( +This function tests some styles for the var(tag) and and stores +options usable for tt(compadd) in the array with the given var(name) +which guarantee that the matches are generated as requested by the +user. The styles tested are: tt(format) (which is first tested for the +given tag and then for the tt(descriptions) tag if that isn't +defined), tt(hidden) and tt(group-name) (the last two are tested only +for the tag given as the first argument). This function also calls the +tt(_setup) function which tests some more styles. + +The format string from the style (if any) will be modified so that the +sequence `tt(%d)' is replaced by the var(descr) given as the third +argument. If tt(_description) is called with more than three +arguments, these var(specs) should be of the form +`var(char)tt(:)var(str)' and every appearance of `tt(%)var(char)' in +the format string will be replaced by var(string). + +The options placed in the array will also make sure that the matches +are placed in a separate group, depending on the value of the +tt(group-name) style. Normally a sorted group will be used for this +(with the `tt(-J)' option), but if a option starting with `tt(-V)', +`tt(-J)', `tt(-1)', or `tt(-2)' is given, that option will be included +in the array, so that it is possible to make the group unsorted by +giving the option `tt(-V)', `tt(-1V)', or `tt(-2V)'. + +In most cases, this function will be used like this: + +example(local expl +_description expl files file +compadd "$expl[@]" - "$files[@]") +) +findex(_message) +item(tt(_message) [ -r ] var(descr))( +The var(descr) is used like the third +argument to the tt(_description) function. However, the resulting +string will always be shown whether or not matches were +generated. This is useful to display help texts in places where no +completions can be generated automatically. + +This function also uses the tt(format) style for the tt(messages) tag in +preference to the tt(format) style for the tt(descriptions) tag. The +latter is used only if the former is unset. + +If the tt(-r) option is given, no style is used and the var(descr) is +used literally as the string to display. This is only used in cases +where that string is taken from some pre-processed argument list +containing an expanded description. +) +findex(_setup) +item(tt(_setup) var(tag))( +This function expects a tag as its argument and sets up the special +parameters used by the completion system appropriately for the tag, +using styles such as tt(list-colors) and tt(last-prompt). + +Note that this function is called automatically from tt(_description) +so that one normally doesn't have to call it explicitly. +) +findex(_tags) +item(tt(_tags) [ tt(-C) var(name) [ var(tags) ... ] ])( +If called with arguments, these are taken as the names of the tags for +the types of matches the calling completion function can generate in +the current context. These tags are stored internally and sorted by +using the tt(tag-order) style. Following calls to this function +without arguments from the same function will then select the first, +second, etc. set of tags requested by the user. To test if a certain +tag should be tried, the tt(_requested) function has to be called (see +below). + +The return value is zero if at least one of the tags is requested and +non-zero otherwise. + +This function also accepts the tt(-C) option followed by a +var(name). This name is temporarily (i.e. not visible outside +tt(_tags)) stored in the argument field of the context name in the +tt(curcontext) parameter. This allows to make tt(_tags) use a more +specific context name without having to change and reset the +tt(curcontext) parameter (which would otherwise have the same effect). +) +findex(_next_label) +item(tt(_next_label) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(options) ... ])( +This function should be called repeatedly to generate the tag +labels. On each call it will check if another tag label is to be used +and, if there is at least one, zero is returned. If no more tag +labels are to be used, a non-zero status is returned. + +The tt(-12JV) options and the first three arguments are given to the +tt(_desciption) function using the tag label instead of the first +argument is appropriate. The var(options) given after the var(descr) +should be other options to be used for tt(compadd) or whatever +function is to be called to add the matches. tt(_next_label) will store these +var(options) in the parameter whose var(name) is given as the second +argument. This is done in such a way that the description given by the +user to the tt(tag-order) style is prefered over the one given to +tt(_next_label). + +Note that this function must not be called without a previous call to +tt(_tags), tt(_wanted) or tt(_requested) because it uses the tag label +for the current tag found by these functions. + +A normal use of this function for the tag labels for the tag tt(foo) +looks like this: + +example(local expl ret=1 +... +_wanted foo || return 1 +... +while _next_label foo expl '...'; do + compadd "$expl[@]" ... && ret=0 +done +... +return ret +) +) +findex(_all_labels) +item(tt(_all_labels) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(args) ... ])( +This is a convenient interface to the tt(_next_label) function, implementing +the loop shown in the example above. The var(command) is the one that +should be called to generate the matches. The options stored in the +parameter var(name) will automatically be inserted into the var(args) +given to the var(command). Normally, they are put directly after the +var(command), but if one of the var(args) is a single hyphen, they are +inserted directly before that. If the hyphen is the last argument, +that will be removed from the argument list before the var(command) is +called. This allows to use tt(_all_labels) in almost all cases where the +matches can be generated by a single call to the tt(compadd) builtin +command or by a call to one of the utility functions. + +For example: + +example(local expl +... +_wanted foo || return 1 +... +_all_labels foo expl '...' compadd ... - $matches) + +Will complete the strings from the tt(matches) parameter, using +tt(compadd) with additional options which will take precedence over +those generated by tt(_all_labels). +) +findex(_requested) +item(tt(_requested) [ tt(-12VJ) ] var(tag) [ var(name) var(descr) [ var(command) var(args) ... ] ])( +A function that uses tt(_tags) to register tags and then calls it to +loop over the requested sets of tags should call this function to +check if a certain tag is currently requested. This normally has to be +done in a loop such as: + +example(_tags foo bar baz +while _tags; do + if _requested foo; then + ... + fi + ... # test other tags + ... # exit loop if matches were generated +done) + +So, the first argument for tt(_requested) is used as the name of a tag +and if that tag is currently requested, the return value is zero (and +non-zero otherwise). + +If the var(name) and the var(descr) are given, tt(_requested) calls the +tt(_description) function with these arguments, including the options. + +If the var(command) is given, the tt(_all_labels) function will be called +immediatly with the same arguments. + +This is often useful to do both the testing of the tag, +getting the description for the matches and adding the matches at +once. E.g.: + +example(local expl ret=1 +_tags foo bar baz +while _tags; do + _requested foo expl 'description' \ + compadd foobar foobaz && ret=0 + ... + (( ret )) || break +done) +) +findex(_wanted) +item(tt(_wanted) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(specs) ... ])( +In many contexts only one type of matches can be generated but even +then it should be tested if the tag representing those matches is +requested by the user. This function makes that easier. + +Like tt(_requested) it gets arguments as for tt(_description). +With the var(tag) it calls tt(_tags) and if that returns zero +(i.e. the var(tag) is requested by the user) it calls tt(_description). So, +if you want to offer only one tag and immediatly want to use the +description built, you can just do: + +example(_wanted tag expl 'description' \ + compadd matches...) +) +findex(_alternative) +item(tt(_alternative) [ tt(-C) var(name) ] var(specs) ...)( +This function is useful if you offer multiple tags and building the +matches for them is easy enough. It basically implements a loop like +the one described for the tt(_tags) function above above. + +The tags to use and what to do if the tags are requested are described +using the var(specs) which are of the form: +`var(tag)tt(:)var(descr)tt(:)var(action)'. The var(tag)s are offered +using tt(_tags) and if the tag is requested, the var(action) is +executed with the given var(descr) (description). The var(action)s +supported are those used by the tt(_arguments) function (described +below), without the `tt(->)var(state)' form. + +For example, the var(action) may be a simple function call. With that +one could do: + +example(_alternative \ + 'users:user:_users' \ + 'hosts:host:_hosts') + +to offer usernames and hostnames as possible matches (which are +generated by the tt(_users) and tt(_hosts) functions respectively). + +Note that, like tt(_arguments) this will also use tt(_all_labels) to execute +the actions, so one doesn't need to call that explicitly unless +another tag is to be used, for example in a function called from +tt(_alternative). + +Like tt(_tags) this function supports the tt(-C) option to give a +different name for the argument context field. +) +findex(_describe) +item(tt(_describe) var(descr) var(name1) [ var(name2) ] var(opts) ... tt(-)tt(-) ...)( +This function can be used to add options or values with descriptions +as matches. The var(descr) is taken as a string to display above +the matches if the tt(format) style for the tt(descriptions) tag is set. + +After this one or two names of arrays followed by options to give +to tt(compadd) must be given. The first array contains the possible +completions with their descriptions (with the description separated +by a colon from the completion string). If the second array is given, +it should have the same number of elements as the first one and these +elements are added as possible completions instead of the strings from +the first array. In any case, however, the completion list will show +the strings from the first array. + +Any number of array/option sequences may be given separated by +`tt(-)tt(-)'. This allows one to display matches together that need +to be added with different options for tt(compadd). + +Before the first argument, the option `tt(-o)' may be given. It says +that the matches added are option names. This will make tt(_describe) +use the tt(prefix-hidden), tt(prefix-needed) and tt(verbose) styles +to find out if the strings should be added at all and if the +descriptions should be shown. Without the `tt(-o)' option, only the +tt(verbose) style is used. + +tt(_describe) uses the tt(_all_labels) function to generate the matches, so +that one doesn't need to put it into a loop over the tag labels. +) +findex(_multi_parts) +item(tt(_multi_parts) var(sep) var(array))( +This function gets two arguments: a separator character and an +array. As usual, the var(array) may be either the name of an array parameter or a literal array in the form `tt(LPAR()foo bar)tt(RPAR())' (i.e. a list of words separated by white space in parentheses). With these arguments, this function will @@ -579,10 +2552,19 @@ tar file in an array and then calls this function to complete these names in the way normal filenames are completed by the tt(_path_files) function. +If given the tt(-i) option a single match left will be accepted +immediatly even if that means that additional parts for which no +separators were on the line are to be inserted. When completing from a +fixed set of possible completions which are really words, this is +often the expected behaviour. But if tt(_multi_parts) should behave +like completing pathnames, the tt(-i) option should not be used. + Like other utility functions, this function accepts the `tt(-V)', -`tt(-J)', and `tt(-X)' options with an argument and passes them to the -tt(compadd) builtin. +`tt(-J)', `tt(-1)', `tt(-2)', `tt(-n)', `tt(-f)', `tt(-X)', `tt(-M)', `tt(-P)', +`tt(-S)', `tt(-r)', `tt(-R)', and `tt(-q)' options and passes them to +the tt(compadd) builtin. ) +findex(_sep_parts) item(tt(_sep_parts))( This function gets as arguments alternating arrays and separators. The arrays specify completions for parts of strings to be separated by the @@ -592,47 +2574,59 @@ a quoted list of words in parentheses. For example, with the array complete the string `tt(f)' to `tt(foo)' and the string `tt(b@n)' to `tt(bar@news)'. -This function passes the `tt(-V)', `tt(-J)', and `tt(-X)' options and -their arguments to the tt(compadd) builtin used to add the matches. +This function passes the `tt(-V)', `tt(-J)', `tt(-1)', `tt(-2)', +`tt(-n)', `tt(-X)', `tt(-M)', `tt(-P)', `tt(-S)', `tt(-r)', `tt(-R)', +and `tt(-q)' options and their arguments to the tt(compadd) builtin +used to add the matches. ) +findex(_path_files) +findex(_files) item(tt(_path_files) and tt(_files))( The function tt(_path_files) is used throughout the shell code -to complete filenames. The advantage over the builtin -completion functions is that it allows completion of partial paths. For +to complete filenames. It allows completion of partial paths. For example, the string `tt(/u/i/s/sig)' may be completed to -`tt(/usr/include/sys/signal.h)'. The options `tt(-/)', `tt(-f)', `tt(-g)', -and `tt(-W)' are available as for the tt(compctl) -and tt(compgen) builtins; tt(-f) is the default. Additionally, the `tt(-F)' +`tt(/usr/include/sys/signal.h)'. The option `tt(-/)' specifies that +only directories should be completed. The option `tt(-g) var(pattern)' +says that only files matching the var(pattern) should be completed, +and the `tt(-f)' option, which is the default, completes all +filenames. The option `tt(-W) var(paths)' may be used to specify path +prefixes that are to be prepended to the string from the line to +generate the filenames but that should not be inserted in the line or +shown in a completion listing. The var(paths) may be the name of an +array parameter, a literal list of paths enclosed in parentheses or +an absolute pathname. +Additionally, the `tt(-F)' option from the tt(compadd) builtin is supported, giving direct control -over which filenames should be ignored as done by the tt(fignore) -parameter in normal completion. +over which filenames should be ignored. If no such option is given, +the tt(ignored-suffixes) style is used. -The function tt(_files) calls tt(_path_files) with all the arguments -it was passed and, if that generated no matches, call tt(_path_files) again -without any tt(-g) or tt(-/) option, thus generating all filenames. +The function tt(_files) uses the tt(file-patterns) style and calls +tt(_path_files) with all the arguments it was passed except for tt(-g) +and tt(-/). These two options are used depending on the setting of the +tt(file-patterns) style. -These functions also accept the `tt(-J)', `tt(-V)', `tt(-X)', `tt(-P)', -`tt(-S)', `tt(-q)', `tt(-r)', and `tt(-R)' options from the -tt(compadd) builtin. +These functions also accept the `tt(-J)', `tt(-V)', `tt(-1)', +`tt(-2)', `tt(-n)', `tt(-X)', `tt(-M)', `tt(-P)', `tt(-S)', `tt(-q)', +`tt(-r)', and `tt(-R)' options from the tt(compadd) builtin. -Finally, the tt(_path_files) function supports one configuration key: -tt(path_expand). If this is set to any non-empty string, the partially -typed path from the line will be expanded as far as possible even if -trailing pathname components can not be completed. +Finally, the tt(_path_files) function uses the styles tt(expand), +tt(cursor) and tt(special-dirs) with the tt(paths) tag. ) +findex(_parameters) item(tt(_parameters))( -This should be used to complete parameter names if you need some of the -extra options of tt(compadd). It first tries to complete only non-local -parameters. All arguments are passed unchanged to the tt(compadd) builtin. +This should be used to complete parameter names. All arguments are +passed unchanged to the tt(compadd) builtin. ) +findex(_options) item(tt(_options))( -This can be used to complete option names. The difference to the -`tt(-o)' option of tt(compgen) is that this function uses a matching +This can be used to complete option names. It uses a matching specification that ignores a leading `tt(no)', ignores underscores and allows the user to type upper-case letters, making them match their lower-case counterparts. All arguments passed to this function are -propagated unchanged to the tt(compgen) builtin. +propagated unchanged to the tt(compadd) builtin. ) +findex(_set_options) +findex(_unset_options) item(tt(_set_options) and tt(_unset_options))( These functions complete only set or unset options, with the same matching specification used in the tt(_options) function. @@ -642,37 +2636,248 @@ function for these functions to work properly. The lines in question are used to store the option settings in effect before the completion widget locally sets the options it needs. ) -item(tt(_long_options))( +findex(_arguments) +item(tt(_arguments) var(specs) ...)( This function resides in the tt(Base) subdirectory of the example completion system because it is not used by the core system. -This function is used to complete long options for commands that -support the `tt(--help)' option as, for example, most of the GNU -commands do. For this it invokes the command from the line with the -`tt(--help)' option and then parses the output to find possible option -names. Note that this means that you should be careful to make sure -that this function is not called for a command that does not support -this option. +This function can be used to complete words on the line by simply +describing the arguments the command on the line gets. The description +is given as arguments to this function, with each var(spec) describing +one option or normal argument of the command. The descriptions +understood are: -For options that get an argument after a `tt(=)', the function also -automatically tries to find out what should be completed as the argument. -The possible completions for option-arguments can be described with -the arguments to this function. This is done by giving pairs of -patterns and actions as consecutive arguments. The actions specify -what should be done to complete arguments of those options whose -description match the pattern. The action may be a list of words in -brackets or in parentheses, separated by spaces. A list in square brackets -denotes possible values for an optional argument, a list in parentheses -gives words to complete for mandatory arguments. If the action does -not start with a square bracket or parenthesis, it should be the name of a -command (probably with arguments) that should be invoked to complete -after the equal sign. Example: - -indent( -nofill(tt(_long_options '*\*' '(yes no)' \)) -nofill(tt( '*=FILE*' '_files' \)) -nofill(tt( '*=DIR*' '_files -/')) +startitem() +item(var(n)tt(:)var(message)tt(:)var(action))( +This describes the var(n)'th normal argument. The var(message) will be +printed above the matches generated and the var(action) says what can +be completed in this position (see below). If there are two colons +before the var(message), this describes an optional argument. +) +item(tt(:)var(message)tt(:)var(action))( +Like the previous one, but describing the em(next) argument. I.e. if +you want to describe all arguments a command can get, you can leave +out the numbers in the description and just use this form to describe +them one after another in the order they have to appear on the line. +) +item(tt(*:)var(message)tt(:)var(action))( +This describes how arguments are to be completed for which no +description with one of the first two forms was given. This also means +that any number of arguments can be completed. + +If there are two colons before the var(message) (as in +`tt(*::)var(message)tt(:)var(action)') the tt(words) special array and +the tt(CURRENT) special parameter will be restricted to only the +normal arguments when the var(action) is executed or evaluated. With +three colons before the var(message) they will be restricted to only +the normal arguments covered by this description. ) +item(var(opt-spec)[var(description) ...])( +This describes an option and (if at least one var(description) is +given) the arguments that have to come after the option. If no +var(description) is given, this will only be used to offer the option +name as a possible completion in the right places. Each +var(description) has to be of the form +`tt(:)var(message)tt(:)var(action)' or +`tt(::)var(message)tt(:)var(action)', where the second form describes +an optional argument and the first one describes a mandatory argument. +The last description may also be of the form +`tt(:*:)var(message)tt(:)var(action)' or +`tt(:*)var(pattern)tt(:)var(message)tt(:)var(action)'. These describe +multiple arguments. In the first form all following words on the line +are to be completed as described by the var(action), in the second +form all words up to a word matching the given var(pattern) are to be +completed using the var(action). The `tt(*)' or the var(pattern) may +also be separated from the var(message) by two or three colons. With +two colons the tt(words) special array and the tt(CURRENT) special +parameter are modified to refer only to the words after the option +(with two colons) or to the words covered by this description (with +three colons) during the execution or evaluation of the +var(action). Note that only one such `tt(:*)'-specification is useful +and no other argument specification may be given after it. + +In the simplest form the var(opt-spec) is just the option name +beginning with a minus or a plus sign, such as `tt(-foo)'. If the +command accepts the option both with a leading minus and a plus sign, +one can use either tt(-+foo) or tt(+-foo) to define both options at +once. In this +case, the first argument for the option (if any) has to come as a +separate word directly after the option and the option may appear only +once on the line (and if it is already on the line, the option name +will not be offered as a possible completion again). If the first +argument for the option has to come directly after the option name +em(in the same word), a minus sign should be added to the end of the +var(opt-spec), as in `tt(-foo-)'. If the first argument may be given +in one string with the option name, but may also be given as a +separate argument after the option, a plus sign should be used +instead. If the argument may be given as the next string or in same +string as the option name but separated from it by an equal sign, a +`tt(=)' should be used instead of the minus or plus sign. + +Note that this and the shortcut syntax with a leading tt(-+) or tt(+-) +means that for options like tt(-+) the second character has to be +quoted with a backslash. + +If the option may be given more than once, a star +(`tt(*)') has to be added in front of the var(opt-spec). + +Finally, the var(opt-spec) may contain a explanation string. This is +given in brackets at the end, as in `tt(-q[query operation])'. The +tt(verbose) style is used to decide if these +explanation strings should be printed when options are listed. If no +explanation string is given but the tt(auto-describe) style is +set and only one argument is described for this var(opt-spec), the +option will be described by the value of the style with any appearance +of the sequence `tt(%d)' in it replaced by the description for the +first argument. +) +enditem() + +Every var(spec) may also contain a list of option names and argument +numbers with which the option or argument described is mutually +exclusive. Such a list is given in parentheses at the beginning, as in +`tt((-two -three 1)-one:...)' or `tt((-foo):...)'. In the first +example, the options `tt(-two)' and `tt(-three)' and the first +argument will not be offered as possible completions if the option +`tt(-one)' is on the line. Also, the list may contain a single star as +one of its elements to specify that the description for the rest +arguments should not be used and it may contain a colon to specify +that the descriptions for all normal (non-option-) arguments should +not be used. + +In each of the cases above, the var(action) says how the possible +completions should be generated. In cases where only one of a fixed +set of strings can be completed, these strings can directly be given as +a list in parentheses, as in `tt(:foo:(foo bar baz))'. Such a list in +doubled parentheses, as in `tt(:foo:((a\:bar b\:baz)))' should contain +strings consisting of the string to complete followed by a colon +(which needs to be preceded by a backslash) and a description. The +matches will be listed together with their descriptions if the +tt(description) style for the tt(values) tag is set. + +An var(action) of the form `tt(->)var(string)' is used by functions +that implement a state machine. In this case, the `var(string)' (with +all leading and trailing spaces and tabs removed) will be stored in +the global parameter tt(state) and the function returns with a return +value of 300 (to make it distinguishable from other return values) +after setting the global `tt(context)', `tt(line)' and `tt(opt_args)' +parameters as described below and without resetting any changes made +to the special parameters such as tt(PREFIX) and tt(words). Note that +this means that a function calling tt(_arguments) with at least one +action containing such a `tt(->)var(string)' has to declare +appropriate local parameters as in: + +example(local context state line +typeset -A opt_args) + +This will ensure that tt(_arguments) does not create unused global +parameters. + +A string in +braces will be evaluated to generate the matches and if the +var(action) does not begin with an opening parentheses or brace, it +will be split into separate words and executed. If the var(action) +starts with a space, this list of words will be invoked unchanged, +otherwise it will be invoked with some extra strings placed after the +first word which can be given as arguments to the tt(compadd) builtin +command and which make sure that the var(message) given +in the description will be shown above the matches. These arguments +are taken from the array parameter tt(expl) which will be set up +before executing the var(action) and hence may be used in it (normally +in an expansion like `tt($expl[@])'). + +Except for the `tt(->)var(string)' form, the var(action) will be +executed by calling the tt(_all_labels) function to process all tag labels, +so one doesn't need to call that explicitly unless another tag is to +be used, for example in a function called in the var(action). + +In places where no sensible matches can be generated, the action +should consist of only a space. This will make the var(message) be +displayed but no possible completions listed. Note that even in this +case the colon at the end of the var(message) is needed. The only case +where it can be left is when neither a var(message), nor a var(action) +is given. + +To include a colon in the option name, the var(message) or the +var(action), it has to be preceded by a backslash. + +During the evaluation or execution of the action the array `tt(line)' +will be set to the command name and normal arguments from the command +line, i.e. to the words from the command line excluding all options +and their arguments. These are stored in the associative array +`tt(opt_args)', using the option names as keys and their arguments as +the values. For options that have more than one argument these are +given as one string, separated by colons. All colons in the original +arguments are preceded with backslashes. The parameter `tt(context)' +will be set to the automatically created context name. This is either +a string of the form `var(-opt)tt(-)var(n)' for the var(n)'th argument +of the option var(-opt), or a string of the form `tt(argument-)var(n)' +for the var(n)'th argument (for rest arguments the var(n) is the +string `tt(rest)'). For example, when completing the argument of the tt(-o) +option, the name is `tt(-o-1)' and for the second normal (non-option-) +argument it is `tt(argument-2)'. + +Also, during the evaluation of the var(action), the context name in +the tt(curcontext) parameter will be changed by appending the same +string that is stored in the tt(context) parameter. + +Normally the option names are taken as multi-character names and a +word from the line is considered to contain only one option (or +none). By giving the tt(-s) option to this function (before the first +description), options are considered to be one-character options and the +strings from the line may contain more than one such option +letter. However, strings beginning with two hyphens (like +`tt(-)tt(-prefix)') are still considered to contain only one option +name. This allows the use of the `tt(-s)' option to describe +single-letter options together with such long option names. + +Another option supported is `tt(-O) var(name)'. The var(name) will be +taken as the name of an array and its elements will be given to +functions called to generate matches when executing the +var(actions). For example, this allows one to give options for the +tt(compadd) builtin that should be used for all var(action)s. + +Also, the tt(-M) option followed by a string may be given before the +first description. The string will be used as the match specification +when completing option names and values instead of the default +`tt(r:|[_-]=* r:|=*)'. + +Finally, the option tt(-C) can be given to make tt(_arguments) modify +the tt(curcontext) parameter when a action of the form +`tt(->)var(state)' is used. This parameter is used to keep track of +the current context and in this case it (and not the parameter +tt(context) as explained above) has to be made local to make sure that +calling functions don't use the modified value. Also, the local +version of tt(curcontext) has to be initialised with the old value as +in: + +example(local curcontext="$curcontext") + +The function can also be made to automatically complete long options +for commands that support the `tt(-)tt(-help)' option as, for example, +most of the GNU commands do. For this, the string `tt(-)tt(-)' must be +given as one argument and if it is, the command from the line is +invoked with the `tt(-)tt(-help)' option and its output is parsed to find +possible option names. Note that this means that you should be careful +to make sure that this feature is not used for a command that does not +support this option. + +For such automatically found options that get an argument after a +`tt(=)', the function also tries +to automatically find out what should be completed as the argument. +The possible completions for option-arguments can be described with +the arguments after the `tt(-)tt(-)' (which are not used as described +above). Each argument contains one description of the form +`var(pattern)tt(:)var(message)tt(:)var(action)'. The var(message) and +the var(action) have the same format as for the normal option +descriptions described above. The var(action) will be executed to +complete arguments of options whose description in the output of the +command from the line with the `tt(-)tt(-help)' option matches the +var(pattern). For example: + +example(_arguments -- '*\*:toggle:(yes no)' \ + '*=FILE*:file:_files' \ + '*=DIR*:directory:_files -/') Here, `tt(yes)' and `tt(no)' will be completed as the argument of options whose description ends in a star, file names for options that @@ -683,9 +2888,374 @@ for option descriptions containing `tt(=FILE)' and paths for option descriptions that contain `tt(=DIR)' or `tt(=PATH)'. These builtin patterns can be overridden by patterns given as arguments, however. -This function also accepts the `tt(-X)', `tt(-J)', and `tt(-V)' -options which are passed unchanged to `tt(compadd)'. Finally, it -accepts the option `tt(-t)'; if this is given, completion is only done -on words starting with two hyphens. +Note also that tt(_arguments) tries to find out automatically if the +argument for an option is optional. If it fails to automatically +detect this, the colon before the var(message) can be doubled to tell +it about this as described for the normal option descriptions above. + +The option `tt(-i) var(patterns)' (which must be given after the +`tt(-)tt(-)') can be used to give patterns for options which should not be +completed. The patterns can be given as the name of an array parameter +or as a literal list in parentheses. E.g. `tt(-i +"LPAR()-)tt(-(en|dis)able-FEATURE*RPAR()")' will make the options +`tt(-)tt(-enable-FEATURE)' and `tt(-)tt(-disable-FEATURE)' be ignored. The +option `tt(-s) var(pairs)' (again, after the `tt(-)tt(-)') can be used to +describe option aliases. Each var(pair) consists of a pattern and a +replacement. E.g. some tt(configure)-scripts describe options only as +`tt(-)tt(-enable-foo)', but also accept `tt(-)tt(-disable-foo)'. To allow +completion of the second form, one would use `tt(-s "LPAR()#-)tt(-enable- +-)tt(-disable-RPAR()")'. + +Example: + +example(_arguments '-l+:left border:' \ + '-format:paper size:(letter A4)' \ + '*-copy:output file:_files::resolution:(300 600)' \ + ':postscript file:_files -g *.(ps|eps)' \ + '*:page number:') + +This describes three options: `tt(-l)', `tt(-format)', and +`tt(-copy)'. The first one gets one argument described as `var(left +border)' for which no completion will be offered because of the empty +action. The argument may come directly after the `tt(-l)' or it may be +given as the next word on the line. The `tt(-format)' option gets one +argument (in the next word) described as `var(paper size)' for which +only the strings `tt(letter)' and `tt(A4)' will be completed. The +`tt(-copy)' option differs from the first two in that it may appear +more than once on the command line and in that it accepts two +arguments. The first one is mandatory and will be completed as a +filename. The second one is optional (because of the second colon +before the description `var(resolution)') and will be completed from +the strings `tt(300)' and `tt(600)'. + +The last two descriptions say what should be completed as +arguments. The first one describes the first argument as a +`var(postscript file)' and makes files ending in `tt(ps)' or `tt(eps)' +be completed. The last description says that all other arguments are +`var(page numbers)' but does not give possible completions. +) +findex(_values) +item(tt(_values) var(specs) ...)( +This is used to complete values (strings) and their arguments or +lists of such values. + +If the first argument is the option `tt(-O) var(name)', this will be +used in the same way as by the tt(_arguments) function. I.e. the +elements of the var(name) array will be given to calls to tt(compadd) +and when executing an action. + +Otherwise, if the first argument (or the first argument after the +`tt(-O) var(name)' option if that is used) is the option `tt(-s)', the +next argument is used as the character that separates multiple values. + +The first argument (after the options and separator character if they +are given) is used as a string to print as a description before +listing the values. + +All other arguments describe the possible values and their +arguments in the same format used for the description of options by +the tt(_arguments) function (see above). The only difference is that +there is no required minus or plus sign at the beginning and that +values can have only one argument. + +Example: + +example(_values -s , 'description' \ + '*foo[bar]' \ + '(two)*one[number]:first count:' \ + 'two[another number]::second count:(1 2 3)') + +This describes three possible values: `tt(foo)', `tt(one)', and +`tt(two)'. The first one is described as `tt(bar)', gets no argument +and may appear more than once. The second one is described as +`tt(number)', may appear more than once, and gets one mandatory +argument described as `tt(first count)' for which no action is +specified so that it will not be completed automatically. The +`tt((two))' at the beginning says that if the value `tt(one)' is on +the line, the value `tt(two)' will not be considered to be a possible +completion anymore. Finally, the last value (`tt(two)') is described +as `tt(another number)' and gets an optional argument decribed as +`tt(second count)' which will be completed from the strings `tt(1)', +`tt(2)', and `tt(3)'. The tt(_values) function will complete lists of +these values separated by commas. + +Like tt(_arguments) this function temporarily adds another context +name component to the current context name while executing the +var(action). Here this name is just the name of the value for which +the argument is completed. + +To decide if the descriptions for the values (not those for the +arguments) should be printed, the tt(verbose) is used. + +One last difference to tt(_arguments) is that this function uses the +associative array +tt(val_args) to report values and their arguments (but otherwise this +is the same as the tt(opt_args) association used by +tt(_arguments)). This also means that the function calling tt(_values) +should declare the tt(state), tt(line), tt(context) and tt(val_args) +parameters as in: + +example(local context state line +typeset -A val_args) + +when using an action of the form `tt(->)var(string)'. With this +function the tt(context) parameter will be set to the name of the +value whose argument is to be completed. + +Like tt(_arguments), tt(_values) also supports the tt(-C) option in +which case you have to make the parameter tt(curcontext) local instead +of tt(context) (as described above). +) +findex(_regex_arguments) +item(tt(_regex_arguments) var(name) var(specs) ...)( +This function is a compiler to generate a completion function. The +first argument specifies the name of a generated function while the +remaining arguments specify a completion as a set of regular +expressions with actions. The generated function has the structure of a +finite-state machine whose state corresponds to the state (i.e. the +context) of the completion. This state machine uses a command line, +which comes from concatentating the tt(words) array up to the current +cursor position using null characters as a separator with no extra +quotation. This is analysed and at the end the appropriate action is +executed. + +Specification arguments take one of following forms, in which +metacharacters such as `tt(LPAR())', `tt(RPAR())', `tt(#)' and `tt(|)' +should be quoted. + +startitem() +item(tt(/)var(pattern)tt(/) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(action)])( +This is a primitive element, corresponding to one +state of the compiled state machine. The state is entered if the pattern +`tt((#b)LPAR()(#B))var(pattern)tt(RPAR()(#B))var(lookahead)tt(*)' matches +the command line string. If it is matched, `var(guard)' is evaluated and +its return status is examined; if this is successful, the state is entered, +else the test fails and other candidates are tried. The var(pattern) +string `tt([])' is guaranteed never to match. + +If the test succeeds and the state is entered, the left part of the +command line string matched as `var(pattern)' is removed and the +next state is tried, proceeding from inside to outside and from left to +right. + +If no test succeeds and the remaining command line string contains no null +character, the completion target is restricted to the remainder of the +command line string and `var(action)'s for the target are evaluated. +In this case, nothing is actually removed from the command line string +so that any previous or neighbouring state may also have `var(actions)'s. +) +item(tt(/)var(pattern)tt(/+) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(action)])( +This is similar to `tt(/)var(pattern)tt(/) ...' but the left part of +command line string is also considered as part of the completion target. +) +item(tt(/)var(pattern)tt(/-) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(action)])( +This is similar to `tt(/)var(pattern)tt(/) ...' but `var(action)'s of the +current and previous states are ignored even if the following state's +`var(pattern)' matches the empty string. +) +item(tt(LPAR()) var(spec) tt(RPAR()))( +This groups `var(spec)'. +) +item(var(spec) tt(#))( +This allows any number of repetitions of `var(spec)'. +) +item(var(spec) var(spec))( +This represents the concatenation of two `var(spec)'s. +) +item(var(spec) tt(|) var(spec))( +Either of two `var(spec)'s can be matched. +) +enditem() +) +findex(_combination) +item(tt(_combination) [ tt(-s) var(pattern) ] var(tag) var(style) var(specs) ... var(field) var(opts) ...)( +This function is used to complete combinations of values such as pairs +of hostnames and usernames. The possible values will be taken from the +var(style) whose name is given as the second argument. The first argument +is the var(tag) to use to do the lookup. + +The style name should consist of multiple parts separated by +hyphens which are then used as fieldnames. Known values for such +fields can be given after the second argument in arguments of the form +`var(field)tt(=)var(pattern)'. The first argument without a equal sign +is taken as the name of the field for which completions should be +generated. + +The matches generated will be taken from the value of the style. These +values should contain the possible values for the combinations where +the values for the different fields are separated by colons or +characters matching the pattern given after the tt(-s) option to +tt(_combination) (normally this is used to define character classes +like the `tt(-s "[:@]")' used for the tt(users-hosts) style). + +Only the values for the requested fields for which the patterns given +in the `var(field)tt(=)var(pattern)' match the respective fields in +the strings from the style value are generated as possible matches. + +If no style with the given name is defined for the given tag but a +function named with the name of the requested field preceded by an +underscore is defined, that function will be called to generate the +matches. This is also done if none of the strings in the value of the +style match all the patterns given as arguments. + +If the same name is used for more than one field, in both the +`var(field)tt(=)var(pattern)' and the argument that gives the field +name to complete for, the number of the field (starting with one) may +be given after the fieldname, separated from it by a colon. + +All arguments after the requested fieldname are given to the +tt(compadd) used (when generating matches from the style value) and to +the functions for the fields if they are called. +) +findex(_sort_tags) +item(tt(_sort_tags) var(tag) ...)( +As described above for the tt(tag-order) style, this is only provided +to show how functions that sort tags can be implemented. + +Inside such functions the name of the current context can +be accessed using the tt(curcontext) parameter. For example, the +function generating file names (called tt(_files)) in the completion +system is often called to generate only filenames matching a given +glob pattern, in which case it uses the tags tt(globbed-files), +tt(directories), and tt(all-files). This means that the function +offers to generate filenames matching the pattern, names of +directories or all filenames as possible matches. Example: + +example(_sort_tags() { + case $curcontext in + (*::dvips:*) + comptry globbed-files directories + comptry all-files + ;; + (*) + comptry globbed-files + comptry directories + comptry all-files + ;; + esac +}) + +Every call to the tt(comptry) function (actually a builtin +command defined by the tt(zsh/computil) module) gives a +set of tags to use; as soon as one of the completion system produces +some matches for one set, +subsequent sets have no effect. Hence in the example +this means that for the tt(dvips) command on the first attempt the +names of DVI files and directories will be generated (first call to +tt(comptry)). If none of those names match the string from the command +line the completion function will generate all filenames as +possible matches (second call to tt(comptry)). + +For all other context names the second case-pattern matches, so that +normally the completion functions will only try the filenames matching +the glob pattern (if any glob pattern is used). If that doesn't yield +any matches, names of directories are generated, and if that doesn't +yield any matching names either, all filenames will be generated. + +In every context the function may call tt(comptry) as +often as it wants. Also, every string may be given as argument, even +if no tag with such a name was offered by the completion +function. This allows one to give a preferred ordering for some common +tag sets without having to worry about sensible patterns for context +names. For example, many completion functions can generate both +arguments and option names for commands. These functions normally use +the tags tt(arguments) and tt(options). Depending on your preference +you may write in your sorting function: + +example(_sort_tags() { + comptry arguments options + case $curcontext in + ... + esac +}) + +or + +example(_sort_tags() { + comptry arguments + comptry options + case $curcontext in + ... + esac +}) + +The former always adds both the matches for the argument and the +option names as possible matches. The latter forces matches for the +arguments to be preferred. In this case option names are only generated +as matches if the string on the line matches no possible completion +for the argument, which normally means that you have to type the +hyphen the option names start with yourself to see the list of option +names that can be completed. + +Since the completion functions are free to choose the tag names they +use, there can't be a complete list. So to make sure that all types of +matches are eventually tried as completions, one should use a call to +tt(comptry) with all arguments at the end of the sorting function. For +those contexts where one really wants to make sure that certain tags are +never used one can then use a call to tt(return) to circumvent that +last tt(comptry). For example: + +example(_sort_tags() { + ... + case $curcontext in + (*::kill:*) + comptry processes + return + ;; + esac + comptry "$@" +}) + +The completion function for the tt(kill) builtin command offers the +tags tt(jobs) and tt(processes) which represent job references +(e.g. `tt(%1)') and process identifiers respectively. The function +above makes sure that for this builtin command only process +identifiers are generated as possible matches by using only the +tt(processes) tag in a call to tt(comptry). The immediate call to +tt(return) then makes sure that the default tt(comptry) at the end is +not executed. + +With the tt(-s) option, each tag given to tt(comptry) will be put in a +separate set. With the tt(-m) option, the arguments are treated in the +same way as the the values for the tt(tag-order) style (except for the +`tt(!...)', `tt(-)' and `tt(foo())' forms). +) + +enditem() + +texinode(Completion Directories)()(Completion Functions)(Completion System) +sect(Completion Directories) +cindex(completion system, directory structure) + +In the source distribution, the files are contained in various +subdirectories of the tt(Completion) directory. They may have been +installed in the same structure, or into one single function directory. +The following is a description of the files found in the original directory +structure. If you wish to alter an installed file, you will need to copy +it to some directory which appears earlier in your tt(fpath) than the +standard directory where it appears. + +startitem() +item(tt(Core))( +The core scripts and functions. You will certainly need these, though will +probably not need to alter them. Many of these are documented above. +) +item(tt(Base))( +Other functions you will almost certainly want if you are going to use +any of the standard completion functions. You may want to edit some of +these files. +) +item(tt(Builtins))( +Functions for completing arguments of shell builtin commands and +utility functions for this (which are also used by functions from the +tt(User) directory). +) +item(tt(User))( +Functions for completing arguments of external commands and suites of +commands. They may need modifying for your system. +) +item(tt(Commands))( +Functions which implement special types of completion to be bound to +keystrokes rather than called by context. ) enditem() diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo index 2cb12e2c2..775ead546 100644 --- a/Doc/Zsh/compwid.yo +++ b/Doc/Zsh/compwid.yo @@ -1,304 +1,595 @@ -texinode(Completion Widgets)(Zsh Modules)(Programmable Completion)(Top) +texinode(Completion Widgets)(Completion System)(Completion Using compctl)(Top) chapter(Completion Widgets) cindex(completion, widgets) cindex(completion, programmable) cindex(completion, controlling) sect(Description) -Completion widgets are defined using the tt(-C) option to the tt(zle) -builtin command provided by the tt(zle) module (see +Completion widgets are defined by the tt(-C) option to the tt(zle) +builtin command provided by the tt(zsh/zle) module (see ifzman(zmanref(zshzle))\ -ifnzman(noderef(The zle Module))\ -). For example, the invocation: +ifnzman(noderef(The zsh/zle Module))\ +). For example, -indent(nofill( -tt(zle -C complete expand-or-complete completer))) +example(zle -C complete expand-or-complete completer) -defines a widget named tt(complete). If this widget is bound to a key -using the tt(bindkey) builtin command defined in the tt(zle) module +defines a widget named tt(complete). When this widget is bound to a key +using the tt(bindkey) builtin command defined in the tt(zsh/zle) module (see ifzman(zmanref(zshzle))\ ifnzman(noderef(Zsh Line Editor))\ -) typing that key will make the completion code call the shell -function tt(completer). This function is responsible for generating -the possible matches using the builtins described below. Once the -function returns, the completion code takes over control again and -treats the matches the way the builtin widget tt(expand-or-complete) -would do it. For this second argument, the name of any of the builtin -widgets that handle completions can be given, i.e. it may be any of +), typing that key will call the shell function tt(completer). This +function is responsible for generating the possible matches using the +builtins described below. Once the function returns, the completion code +takes over control again and treats the matches as the builtin widget +tt(expand-or-complete) would do. For this second argument, the name of any +of the builtin widgets that handle completions can be given: tt(complete-word), tt(expand-or-complete), tt(expand-or-complete-prefix), tt(menu-complete), tt(menu-expand-or-complete), tt(reverse-menu-complete), -tt(list-choices), or tt(delete-char-or-list). +tt(list-choices), or tt(delete-char-or-list). Note that this will still +work even if the widget in question has been rebound. startmenu() menu(Special Parameters) menu(Builtin Commands) menu(Condition Codes) +menu(Matching Control) menu(Examples) endmenu() texinode(Special Parameters)(Builtin Commands)()(Completion Widgets) sect(Special Parameters) -Inside completion widgets some parameters have special meaning. They -will be used inside the widget function and other shell functions -called from it. Outside of these function they are not special to the -shell in any way. - -The parameters are used to give information about the internal state -from the completion code to the completion widget and can be set to -give information to the completion code from the completion -widget. Some of the builtin commands and the condition codes use or -change the current values of these parameters. While the completion -widget is active, these parameters are reseton each function exit to -the values they had when the function was entered. +Inside completion widgets, and any functions called from those, some +parameters have special meaning; outside these function they are not +special to the shell in any way. These parameters are used to pass +information between the completion code and the completion widget. Some of +the builtin commands and the condition codes use or change the current +values of these parameters. Any existing values will be hidden during +execution of completion widgets; except for tt(compstate), the parameters +are reset on each function exit (including nested function calls from +within the completion widget) to the values they had when the function was +entered. startitem() -item(tt(argv))( -The positional parameters are set to the arguments on the command line -when the widget function is invoked from the completion code. +vindex(words) +item(tt(words))( +This array contains the words present on the command line currently being +edited. ) +vindex(CURRENT) item(tt(CURRENT))( This is the number of the current word, i.e. the word the cursor is -currently on in the tt(argv) array. +currently on in the tt(words) array. Note that this value is only +correct if the tt(ksharrays) options is not set. +) +vindex(PREFIX) +item(tt(PREFIX))( +Initially this will be set to the part of the current word from the +beginning of the word up to the position of the cursor; it may be altered +to give a common prefix for all matches. ) -item(tt(CONTEXT))( +vindex(IPREFIX) +item(tt(IPREFIX))( +Initially this will be set to the empty string. It functions like +tt(PREFIX), and gives a string which precedes the one in tt(PREFIX) and is +not considered part of the list of matches. Typically, a string is +transferred from the beginning of tt(PREFIX) to the end of tt(IPREFIX), for +example: + +example(IPREFIX=${PREFIX%%\=*}= +PREFIX=${PREFIX#*=}) + +causes the part of the prefix up to and including the first equal sign not +to be treated as part of a matched string. This can be done automatically +by the tt(compset) builtin, see below. +) +vindex(QIPREFIX) +item(tt(QIPREFIX))( +This parameter is read-only and contains the quoted string up to the +word being completed. E.g. when completing `tt("foo)', this parameter +contains the double quote. If the tt(-q) option of tt(compset) is used +(see below), and the original string was `tt("foo bar)' with the +cursor on the `tt(bar)', this parameter contains `tt("foo )'. +) +vindex(SUFFIX) +item(tt(SUFFIX))( +Initially this will be set to the part of the current word from the +cursor position to the end; it may be altered to give a common suffix for +all matches. It is most useful when the option tt(COMPLETE_IN_WORD) is +set, as otherwise the whole word on the command line is treated as a +prefix. +) +vindex(ISUFFIX) +item(tt(ISUFFIX))( +As tt(IPREFIX), but for a suffix that should not be considered part +of the matches; note that the tt(ISUFFIX) string follows the tt(SUFFIX) +string. +) +vindex(QISUFFIX) +item(tt(QISUFFIX))( +Like tt(QIPREFIX), but containing the suffix. +) +vindex(compstate) +cindex(completion widgets, examining and setting state in) +item(tt(compstate))( +This is an associative array with various keys and values that the +completion code uses to exchange information with the completion widget. +The keys are: + +startitem() +vindex(context, compstate) +item(tt(context))( This will be set by the completion code to the overall context -completion is attempted in. Possible values are: +in which completion is attempted. Possible values are: startitem() item(tt(command))( -when completing in a command position, e.g. in the first word on the -command line -) -item(tt(argument))( -when completing an argument for a command +when completing for a normal command (either in a command position or for +an argument of the command). ) item(tt(redirect))( -when completing after a redirection operator; in this case the -positional parameters contain not only the arguments but also the -command name itself as the first element +when completing after a redirection operator. ) item(tt(condition))( -when completing inside a `tt([[)...tt(]])' conditional expressing; in -this case the positional parameters are set to the words inside the -conditional expressions +when completing inside a `tt([[)...tt(]])' conditional expression; in +this case the tt(words) array contains the words inside the +conditional expression. ) item(tt(math))( when completing in a mathematical environment such as a -`tt(LPAR()LPAR())...tt(RPAR()RPAR())' construct +`tt(LPAR()LPAR())...tt(RPAR()RPAR())' construct. ) item(tt(value))( -when completing the value of a parameter assignment; in case of an -array value the positional parameters are set to the words in -parentheses +when completing the value of a parameter assignment. +) +item(tt(array_value))( +when completing inside the value of an array parameter assignment; in +this case the tt(words) array contains the words inside the parentheses. ) item(tt(subscript))( -when completing inside a parameter expansion subscript +when completing inside a parameter subscript. ) -enditem() +item(tt(parameter))( +when completing the name of a parameter in a parameter expansion beginning +with tt($) but not tt(${). ) -item(tt(COMMAND))( -In most cases this is set to name of the command for which completion -is tried. When completing after a redirection operator it contains the -string forming that operator. Also, when completing in the value of a -parameter assignment or in a parameter subscript it is set to the name -of the parameter. +item(tt(brace_parameter))( +when completing the name of a parameter in a parameter expansion beginning +with tt(${). ) -item(tt(PREFIX))( -This should be set to that part of the current word that should be -taken as the string every possible match has to begin with. Initially -this will be set to the part of the current word from the beginning of -the word up to the position of the cursor. When +enditem() ) -item(tt(IPREFIX))( -When a part of the current word should not be considered part of the -matches, this part should be taken from the tt(PREFIX) parameter and -appended to this parameter. This will initially be set to the empty -string when called from the completion code. +vindex(vared, compstate) +item(tt(vared))( +If completion is called while editing a line using the tt(vared) +builtin, the value of this key is set to the name of the parameter +given as argument to tt(vared). If tt(vared) is not currently used, +this key is unset. ) -item(tt(SUFFIX))( -This should be set to that part of the current word that should be -taken as the string every possible match has to end with. The -completion code sets this to the part of the current word from the -cursor position to the end. +vindex(parameter, compstate) +item(tt(parameter))( +The name of the parameter when completing in a subscript or in the +value of a parameter assignment. ) -item(tt(NMATCHES))( -This is always set to the number of matches generated and accepted by -the completion code so far. +vindex(redirect, compstate) +item(tt(redirect))( +The redirection operator when completing in a redirection position, +i.e. one of tt(<), tt(>), etc. +) +vindex(quoting, compstate) +item(tt(quoting))( +When completing inside single quotes, this is set to the string +tt(single); inside double quotes, the string +tt(double); inside backticks, the string tt(backtick). +Otherwise it is unset. +) +vindex(quote, compstate) +item(tt(quote))( +When completing inside quotes, this contains the quotation character +(i.e. either a single quote, a double quote, or a backtick). Otherwise it +is unset. +) +vindex(all_quotes, compstate) +item(tt(all_quotes))( +The tt(-q) option of the tt(compset) builtin command (see below) +allows breaking a quoted string into separate words and completing one +of these words. This key allows to test which types of quoted strings +are currently broken into parts this way. Its value contains one +character for each quoting level. The characters are a single quote or +a double quote for strings quoted with these characters and a +backslash for strings not starting with a quote character. The first +character in the value always corresponds to the innermost quoting +level. +) +vindex(nmatches, compstate) +item(tt(nmatches))( +The number of matches generated and accepted by the completion code so +far. +) +vindex(ignored, compstate) +item(tt(ignored))( +The number of words that were ignored because they matched one of the +patterns given with the tt(-F) option to the tt(compadd) builtin +command. ) -item(tt(MATCHER))( -When completion is used with a global match specification (i.e. a -tt(compctl) with only a tt(-M) option), this parameter is set to the -number of the specification string which is currently used. +vindex(restore, compstate) +item(tt(restore))( +This is set to tt(auto) before a function is entered, which forces the +special parameters mentioned above (tt(words), tt(CURRENT), tt(PREFIX), +tt(IPREFIX), tt(SUFFIX), and tt(ISUFFIX)) to be restored to their +previous values when the function exits. If a function unsets it or +sets it to any other string, they will not be restored. +) +vindex(list, compstate) +item(tt(list))( +This controls whether or how the list of matches will be displayed. If it +is unset or empty they will never be listed; if its value begins with +tt(list), they will always be listed; if it begins with tt(autolist) +or tt(ambiguous), they will be listed when the tt(AUTO_LIST) or +tt(LIST_AMBIGUOUS) options respectively would normally cause them to +be. + +If the substring tt(force) appears in the value, this makes the +list be shown even if there is only one match. Normally, the list +would be shown only if there are at least two matches. + +The value contains the substring tt(packed) if the tt(LIST_PACKED) +option is set. If this substring is given for all matches added of a +group, this group will show the tt(LIST_PACKED) behavior. The same is +done for the tt(LIST_ROWS_FIRST) option with the substring tt(rows). + +Finally, if the value contains the string tt(explanations), only the +explanation strings, if any, will be listed. It will be set +appropriately on entry to a completion widget and may be changed +there. +) +vindex(list_max, compstate) +item(tt(list_max))( +Initially this is set to the value of the tt(LISTMAX) parameter. +It may be set to any other numeric value; when the widget exits this value +will be used in the same way as the value of tt(LISTMAX). +) +vindex(list_lines, compstate) +item(tt(list_lines))( +This gives the number of lines that are needed to display the full +list of completions. Note that to calculate the total number of lines +to display you need to add the number of lines needed for the command +line to this value, this is available as the value of the tt(BLINES) +special parameter. +) +vindex(last_prompt, compstate) +item(tt(last_prompt))( +If this is set to an non-empty string for every match added, the +completion code will move the cursor back to the previous prompt after +the list of completions has been displayed. Initially this is set or +unset according to the tt(ALWAYS_LAST_PROMPT) option. +) +vindex(insert, compstate) +item(tt(insert))( +This controls the manner in which a match is inserted into the command +line. On entry to the widget function, if it is unset the command line is +not to be changed; if set to tt(unambiguous), any prefix common to all +matches is to be inserted; if set to tt(automenu-unambiguous), the +common prefix is to be inserted and the next invocation of the +completion code may start menu-completion (due to the tt(AUTO_MENU) +option being set); if set to tt(menu) or tt(automenu) menu-completion +will be started for the matches currently generated due to (in the +latter case this will happen because the tt(AUTO_MENU) is set). + +On exit it may be set to any of the values above (where setting it to +the empty string is the same as unsetting it), or to a number, in which +case the match whose number is given will be inserted into the command line. +It may also be set to a string of the form `var(group):var(match)' which +specifies a match from a group of matches to be inserted, counting from 1 +upwards (e.g. `tt(2:4)' specifies the fourth match of the second group). +Negative numbers count backward from the last match or group (with `tt(-1)' +selecting the last match or group) and out-of-range values are wrapped +around, so that a value of zero selects the last match or group and a value +one more than the maximum selects the first. Unless the value of this +key ends in a space, the match is inserted as in a menu-completion, +i.e. without automatically appending a space. + +It may also be set to tt(all), which makes all matches generated be +inserted into the line. +) +vindex(to_end, compstate) +item(tt(to_end))( +Specifies the occasions on which the cursor is moved to the end of a string +when a match is inserted. On entry to a widget function, it may be +tt(single) if this will happen when a single unambiguous match was inserted +or tt(match) if it will happen any time a match is inserted (for example, +by menucompletion; this is likely to be the effect of the tt(ALWAYS_TO_END) +option). + +On exit, it may be set to tt(single) as above. It may also be set to +tt(always), or to the empty string or unset; in those cases the cursor will +be moved to the end of the string always or never respectively. Any +other string is treated as tt(match). +) +vindex(old_list, compstate) +item(tt(old_list))( +This is set to tt(yes) if there is still a valid list of completions +from a previous completion at the time the widget is invoked. This will +usually be the case if and only if the previous editing operation was a +completion widget or one of the builtin completion functions. If there is a +valid list and it is also currently shown on the screen, the value of this +key is tt(shown). + +After the widget has exited the value of this key is only used if it +was set to tt(keep). In this case the completion code will continue +to use this old list. If the widget generated new matches, they will +not be used. +) +vindex(old_insert, compstate) +item(tt(old_insert))( +On entry to the widget this will be set to the number of the match of +an old list of completions that is currently inserted into the command +line. If no match has been inserted, this is unset. + +As with tt(old_list), the value of this key will only be used if it is the +string tt(keep). If it was set to this value by the widget and there was an +old match inserted into the command line, this match will be kept and if +the value of the tt(insert) key specifies that another match should be +inserted, this will be inserted after the old one. +) +vindex(exact, compstate) +item(tt(exact))( +Controls the behaviour when the tt(REC_EXACT) option is set. It will be +set to tt(accept) if an exact match would be accepted, and will be unset +otherwise. +) +vindex(exact_string, compstate) +item(tt(exact_string))( +The string of an exact match if one was found, otherwise unset. +) +vindex(pattern_match, compstate) +item(tt(pattern_match))( +Locally controls the behaviour given by the tt(GLOB_COMPLETE) option. +Initially it is set to `tt(*)' if and only if the option is set. +The completion widget may set it to either of these two values, or to any +other non-empty string. If it is non-empty, unquoted metacharacters on the +command line will be treated as patterns; if it is `tt(*)', then +additionally a wildcard `tt(*)' is assumed at the cursor position; if +it is empty or unset, metacharacters will be treated literally. + +Note that the matcher specifications given globally or to one of the +builtin commands adding matches are not used if this is set to a +non-empty string. +) +vindex(pattern_insert, compstate) +item(tt(pattern_insert))( +Normally this is set to tt(menu), which specifies that menu-completion will +be used whenever the matches were generated using pattern matching. If it +is set to any other non-empty string by the user and menu-completion is +not selected by other option settings, the code will insert an +unambiguous string for the generated matches as with normal completion. +) +vindex(unambiguous, compstate) +item(tt(unambiguous))( +This key is read-only and will always be set to the unambiguous string +the completion code has generated for all matches added so far. +) +vindex(unambiguous_cursor, compstate) +item(tt(unambiguous_cursor))( +This gives the position the cursor would be placed at if the +unambiguous string in the tt(unambiguous) key were inserted, relative to +the value of that key. The cursor would be placed before the character +whose index is given by this key. +) +enditem() ) enditem() texinode(Builtin Commands)(Condition Codes)(Special Parameters)(Completion Widgets) sect(Builtin Commands) startitem() -findex(complist) -item(tt(complist) var(flags ...))( - -Generate matches according to the given var(flags) which can be any of -the option flags supported by the tt(compctl) builtin command (see -ifzman(zmanref(zshcompctl))\ -ifnzman(noderef(Programmable Completion))\ -) except for the tt(-t) and tt(-l) flags. Also, when using the tt(-K) -flag, the function given as argument to it can not access the command -line with the tt(read) builtin command. - -The matches will be generated in the same way as if the completion code -generated them directly from a tt(compctl)-definition with the same -flags. The completion code will consider only those matches as -possible completions that match the prefix and suffix from the special -parameters desribed above. These strings will be compared with the -generated matches using the normal matching rules and any matching -specifications given with the tt(-M) flag to tt(complist) and the -global matching specifications given to the tt(compctl) builtin -command. -) -xitem(tt(compadd) [ tt(-qQfnUam) ] [ tt(-F) var(array) ]) +findex(compadd) +cindex(completion widgets, adding specified matches) +xitem(tt(compadd) [ tt(-qQfenUal12) ] [ tt(-F) var(array) ]) xitem([ tt(-P) var(prefix) ] [ tt(-S) var(suffix) ]) xitem([ tt(-p) var(hidden-prefix) ] [ tt(-s) var(hidden-suffix) ]) -xitem([ tt(-i) var(ignored-prefix) ] [ tt(-W) var(file-prefix) ]) -xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ]) +xitem([ tt(-i) var(ignored-prefix) ] [ tt(-I) var(ignored-suffix) ]) +xitem([ tt(-W) var(file-prefix) ] [ tt(-d) var(array) ]) +xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ]) xitem([ tt(-r) var(remove-chars) ] [ tt(-R) var(remove-func) ]) -item([ tt(-M) var(match-spec) ] [ tt(--) ] [ var(words) ... ])( +xitem([ tt(-M) var(match-spec) ] [ tt(-O) var(array) ] [ tt(-A) var(array) ]) +item([ tt(-D) var(array) ] [ tt(--) ] [ var(words) ... ])( -This builtin command can be used to add matches and directly control +This builtin command can be used to add matches directly and control all the information the completion code stores with each possible -match. +match. The return value is zero if at least one match was added and +non-zero if no matches were added. + +The completion code breaks the string to complete into seven fields in +the order: + +indent(var(<ipre><apre><hpre><word><hsuf><asuf><isuf>)) + +The first field +is an ignored prefix taken from the command line, the contents of the +tt(IPREFIX) parameter plus the string given with the tt(-i) +option. With the tt(-U) option, only the string from the tt(-i) +option is used. The field var(<apre>) is an optional prefix string +given with the tt(-P) option. The var(<hpre>) field is a string +that is considered part of the match but that should not be shown when +listing completions, given with the tt(-p) option; for example, +functions that do filename generation might specify +a common path prefix this way. var(<word>) is the part of the match that +should appear in the list of completions, one of the tt(words) given at the +end. The suffixes var(<hsuf>), var(<asuf>) and var(<isuf>) correspond to +the prefixes var(<hpre>), var(<apre>) and var(<ipre>) and are given by the +options tt(-s), tt(-S) and tt(-I), respectively. The supported flags are: startitem() item(tt(-P) var(prefix))( -The same as for tt(compctl) and tt(complist), it gives a string that -should be inserted before the given words when they are completed. The -string given is not considered to be part of the match. +This gives a string to be inserted before the given var(words). The +string given is not considered as part of the match and any shell +metacharacters in it will not be quoted when the string is inserted. ) item(tt(-S) var(suffix))( -Like tt(-P) but gives a string that has to be inserted after the match. +Like tt(-P) but gives a string to be inserted after the match. ) item(tt(-p) var(hidden-prefix))( -This gives a string that should be -... +This gives a string that should be inserted into the command line before the +match but that should not appear in the list of matches. Unless the +tt(-U) option is given, this string must be matched as part of the string +on the command line. ) item(tt(-s) var(hidden-suffix))( -... +Like `tt(-p)', but gives a string to insert after the match. ) item(tt(-i) var(ignored-prefix))( -... +This gives a string to insert into the command line just before any +string given with the `tt(-P)' option. Without `tt(-P)' the string is +inserted before the string given with `tt(-p)' or directly before the +match. +) +item(tt(-I) var(ignored-suffix))( +Like tt(-i), but gives an ignored suffix. +) +item(tt(-d) var(array))( +This adds per-match display strings. The var(array) should contain one +element per var(word) given. The completion code will then display the +first element instead of the first var(word), and so on. The +var(array) may be given as the name of a array parameter or directly +as a space-separated list of words in parentheses. + +If there are fewer display strings than var(words), the leftover +var(words) will be displayed unchanged and if there are more display +strings than var(words), the leftover display strings will be silently +ignored. +) +item(tt(-l))( +This option only has an effect if used together with the tt(-d) +option. If it is given, the display strings are listed one per line, +not arrayed in columns. ) item(tt(-J) var(name))( -As for tt(compctl) and tt(complist) this gives the name of the group -of matches the words should be stored in. +Gives the name of the group of matches the words should be stored in. ) item(tt(-V) var(name))( -Like tt(-J) but naming a unsorted group. +Like tt(-J) but naming a unsorted group. These are in a different name +space than groups created with the tt(-J) flag. +) +item(tt(-1))( +If given together with the tt(-V) option, makes +only consecutive duplicates in the group be removed. If combined with +the tt(-J) option, this has no visible effect. Note that groups +with and without this flag are in different name spaces. +) +item(tt(-2))( +If given together with the tt(-J) or tt(-V) option, makes all +duplicates be kept. Again, groups with and without this flag are in +different name spaces. +) +item(tt(-X) var(explanation))( +The var(explanation) string will be printed with the list of matches. ) item(tt(-q))( -This flag has the same meaning as for tt(compctl) and tt(complist), -too. It makes the suffix given with tt(-S) be automatically removed if -the next character typed is a blank or does not insert anything or if +The suffix given with tt(-S) will be automatically removed if +the next character typed is a blank or does not insert anything, or if the suffix consists of only one character and the next character typed is the same character. ) item(tt(-r) var(remove-chars))( -This makes the suffix given with tt(-S) be automatically removed if +This is a more versatile form of the tt(-q) option. +The suffix given with tt(-S) or the slash automatically added after +completing directories will be automatically removed if the next character typed inserts one of the characters given in the -var(remove-chars). This string is parsed as a characters class with -the usual backslash-sequences understood, e.g. using `tt(-r "a-z\t")' -removes the suffix if the next character typed inserts one of the -lower case letters or a TAB, and `tt(-r "^0-9")' removes the suffix if -the next character typed inserts anything but a digit. One extra +var(remove-chars). This string is parsed as a characters class and +understands the backslash sequences used by the tt(print) command. For +example, `tt(-r "a-z\t")' removes the suffix if the next character typed +inserts a lowercase character or a TAB, and `tt(-r "^0-9")' removes the +suffix if the next character typed inserts anything but a digit. One extra backslash sequence is understood in this string: `tt(\-)' stands for all characters that insert nothing. Thus `tt(-S "=" -q)' is the same as `tt(-S "=" -r "= \t\n\-")'. ) item(tt(-R) var(remove-func))( -For the cases where one wants to remove suffix and the tt(-r) option -does not give enough control, this option can be used. It stores the -name of the shell function var(remove-func) in the matches. If one of -the matches is finally accepted and the tt(-S)-suffix inserted, this -function will be called after the next character typed. It gets the -length of the suffix as its argument and can use the special -parameters available in zle widgets (see +This is another form of the tt(-r) option. When a suffix +has been inserted and the completion accepted, the function +var(remove-func) will be called after the next character typed. It is +passed the length of the suffix as an argument and can use the special +parameters available in ordinary (non-completion) zle widgets (see ifzman(zmanref(zshzle))\ ifnzman(noderef(Zsh Line Editor))\ ) to analyse and modify the command line. ) item(tt(-f))( -If this flag is given, the matches build are marked as being the names -of files. They need not be actual filenames, though. But if they are -and the option tt(LIST_TYPES) is set, the characters describing the -types of the files in the completion lists will be shown. This also -makes a slash automatically be added when the name of a directory is -completed. +If this flag is given, all of the matches built from var(words) are +marked as being the names of files. They are not required to be actual +filenames, but if they are, and the option tt(LIST_TYPES) is set, the +characters describing the types of the files in the completion lists will +be shown. This also forces a slash to be added when the name of a +directory is completed. +) +item(tt(-e))( +This flag can be used to tell the completion code that the matches +added are parameter names for a parameter expansion. This will make +the tt(AUTO_PARAM_SLASH) and tt(AUTO_PARAM_KEYS) options be used for +the matches. ) item(tt(-W) var(file-prefix))( -This option has the same meaning as for the tt(compctl) and -tt(complist) builtin commands. Here, however, only one string may be -given, not an array. This string is used as a pathname that will be -prepended to the given words and the prefix given with the tt(-p) -option to perform the file-tests when showing completion -listings. Hence it is only useful if combined with the tt(-f) flag, -since the tests will only be performed if that flag is given. -) -item(tt(-a))( -When used by tt(compctl) or tt(complist) the completion code normally -builds two sets of matches: the normal one where words with one of the -suffixes in the array parameter tt(fignore) are not considered -possible matches, and the alternate set where the words excluded -from the first set are stored. Normally only the matches in the first -set are used. But if this set is empty, the words from the alternate -set are used. - -The tt(compadd) builtin does not use tt(fignore) parameter and -normally stores all words in the first set. With the tt(-a)-flag -given, however, they are all stored in the alternate set unless this -flag is overridden by the tt(-F) option. +This string is a pathname that will be +prepended to each of the matches formed by the given var(words) together +with any prefix specified by the tt(-p) option to form a complete filename +for testing. Hence it is only useful if combined with the tt(-f) flag, as +the tests will not otherwise be performed. ) item(tt(-F) var(array))( -This can be used to give an array containing suffixes like the -tt(fignore) parameter. Words with one of these suffixes are stored in -the alternate set of matches and words without one of these suffixes -are stored in the normal set. +Specifies an array containing patterns. Words matching one of these +patterns are ignored, i.e. not considered to be possible matches. The var(array) may be the name of an array parameter or a list of -literal suffixes enclosed in parentheses as in `tt(-F "(.o .h)")'. If -the name of an array is given, the elements of the array are taken as -the suffixes. +literal patterns enclosed in parentheses and quoted, as in `tt(-F "(*?.o +*?.h)")'. If the name of an array is given, the elements of the array are +taken as the patterns. ) item(tt(-Q))( -As for tt(compctl) and tt(complist) this flag instructs the completion +This flag instructs the completion code not to quote any metacharacters in the words when inserting them -in the command line. -) -item(tt(-m))( -Normally the matches added by tt(compadd) will not be compared with -what is already on the line. If this flag is given, this comparison is -performed as usual and the match specifications given with the tt(-M) -option to tt(compadd) and the global match specifications defined with -tt(compctl) will be used. This means that probably not all the word -given will be stored as matches since some of them may not match the -string on the line. +into the command line. ) item(tt(-M) var(match-spec))( -This option allows one to give local match specifications with the -same meaning and format as for the tt(compctl) and tt(complist) -builtin commands. Note that they will only be used if the tt(-m) is -given, too. +This gives local match specifications as described below in +noderef(Matching Control). This option may be given more than once. In +this case all var(match-spec)s given are concatenated with spaces +between them to form the specification string to use. +Note that they will only be used if the tt(-U) option is not given. ) item(tt(-n))( -Words added with tt(compadd) with this flag will be used as possible -matches as usual but they not appear in the completion listing. +Specifies that the words added are to be used as possible +matches, but are not to appear in the completion listing. ) item(tt(-U))( -If this flag is given to one of the calls to tt(compadd) and the -option tt(AUTO_MENU) is set, the completion code will immediatly -switch to menucompletion. +If this flag is given, all words given will be accepted and no matching +will be done by the completion code. Normally this is used in +functions that do the matching themselves. +) +item(tt(-O) var(array))( +If this option is given, the var(words) are em(not) added to the set of +possible completions. Instead, matching is done as usual and all of the +var(words) given as arguments that match the string on the command line +will be stored in the array parameter whose name is given as var(array). +) +item(tt(-A) var(array))( +As the tt(-O) option, except that instead of those of the var(words) which +match being stored in var(array), the strings generated internally by the +completion code are stored. For example, +with a matching specification of `tt(-M "L:|no=")', the string `tt(nof)' +on the command line and the string `tt(foo)' as one of the var(words), this +option stores the string `tt(nofoo)' in the array, whereas the tt(-O) +option stores the `tt(foo)' originally given. +) +item(tt(-D) var(array))( +As with tt(-O), the var(words) are not added to the set of possible +completions. Instead, the completion code tests every var(word) if +it matches what is on the line. If the var(n)'th var(word) does not +match, the var(n)'th element of the var(array) is removed. Elements +for which the corresponding var(word) is matched are retained. ) item(tt(-), tt(--))( This flag ends the list of flags and options. All arguments after it @@ -306,123 +597,344 @@ will be taken as the words to use as matches even if they begin with hyphens. ) enditem() + +Except for the tt(-M) flag, if any of these flags is given more than +once, the first one (and its argument) will be used. +) +findex(compset) +cindex(completion widgets, modifying special parameters) +xitem(tt(compset -p) var(number)) +xitem(tt(compset -P) [ var(number) ] var(pattern)) +xitem(tt(compset -s) var(number)) +xitem(tt(compset -S) [ var(number) ] var(pattern)) +xitem(tt(compset -n) var(begin) [ var(end) ]) +xitem(tt(compset -N) var(beg-pat) [ var(end-pat) ]) +item(tt(compset -q))( +This command simplifies modification of the special parameters, +while its return value allows tests on them to be carried out. + +The options are: + +startitem() +item(tt(-p) var(number))( +If the contents of the tt(PREFIX) parameter is longer than var(number) +characters, the first var(number) characters are removed from it and +appended to the contents of the tt(IPREFIX) parameter. +) +item(tt(-P) [ var(number) ] var(pattern))( +If the value of the tt(PREFIX) parameter begins with anything that +matches the var(pattern), the matched portion is removed from +tt(PREFIX) and appended to tt(IPREFIX). + +Without the optional var(number), the longest match is taken, but +if var(number) is given, anything up to the var(number)'th match is +moved. If the var(number) is negative, the var(number)'th longest +match is moved. For example, if tt(PREFIX) contains the string +`tt(a=b=c)', then tt(compset -P '*\=') will move the string `tt(a=b=)' +into the tt(IPREFIX) parameter, but tt(compset -P 1 '*\=') will move only +the string `tt(a=)'. +) +item(tt(-s) var(number))( +As tt(-p), but transfer the last var(number) characters from the +value of tt(SUFFIX) to the front of the value of tt(ISUFFIX). +) +item(tt(-S) [ var(number) ] var(pattern))( +As tt(-P), but match the last portion of tt(SUFFIX) and transfer the +matched portion to the front of the value of tt(ISUFFIX). +) +item(tt(-n) var(begin) [ var(end) ])( +If the current word position as specified by the parameter tt(CURRENT) +is greater than or equal to var(begin), anything up to the +var(begin)'th word is removed from the tt(words) array and the value +of the parameter tt(CURRENT) is decremented by var(begin). + +If the optional var(end) is given, the modification is done only if +the current word position is also less than or equal to var(end). In +this case, the words from position var(end) onwards are also removed from +the tt(words) array. + +Both var(begin) and var(end) may be negative to count backwards +from the last element of the tt(words) array. +) +item(tt(-N) var(beg-pat) [ var(end-pat) ])( +If one of the elements of the tt(words) array before the one at the +index given by the value of the parameter tt(CURRENT) matches the +pattern var(beg-pat), all elements up to and including the matching one are +removed from the tt(words) array and the value of tt(CURRENT) is changed to +point to the same word in the changed array. + +If the optional pattern var(end-pat) is also given, and there is an +element in the tt(words) array matching this pattern, the parameters +are modified only if the index of this word is higher than the one +given by the tt(CURRENT) parameter (so that the matching word has +to be after the cursor). In this case, the words starting with the one +matching tt(end-pat) are also removed from the tt(words) +array. If tt(words) contains no word matching var(end-pat), the +testing and modification is performed as if it were not given. +) +item(tt(-q))( +The word +currently being completed is split in separate words at the spaces. The +resulting words are stored in the tt(words) array, and tt(CURRENT), +tt(PREFIX), tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to +reflect the word part that is completed. +) +enditem() + +In all the above cases the return value is zero if the test succeeded +and the parameters were modified and non-zero otherwise. This allows +one to use this builtin in tests such as: + +example(if compset -P '*\='; then ...) + +This forces anything up to and including the last equal sign to be +ignored by the completion code. ) item(tt(compcall) [ tt(-TD) ])( +This allows the use of completions defined with the tt(compctl) builtin +from within completion widgets. The list of matches will be generated as +if one of the non-widget completion function (tt(complete-word), etc.) +had been called, except that only tt(compctl)s given for specific commands +are used. To force the code to try completions defined with the tt(-T) +option of tt(compctl) and/or the default completion (whether defined by +tt(compctl -D) or the builtin default) in the appropriate places, the +tt(-T) and/or tt(-D) flags can be passed to tt(compcall). + +The return value can be used to test if a matching tt(compctl) +definition was found. It is non-zero if a tt(compctl) was found and +zero otherwise. -This allows one to use completion definitions given with the -tt(compctl) builtin from within completion widgets. It makes -completion code complete the current word according to the -tt(compctl)s defined. Normally only tt(compctl)s given for specific -commands are used. To make the code use the completion flags given to -the tt(-T) option of tt(compctl), one can give the tt(-T) flag to -tt(compctl). Likewise, the tt(-D) flag to tt(compcall) makes the -default completion flags given to tt(compctl) with the tt(-D) option -be used. +Note that this builtin is defined by the tt(zsh/compctl) module. ) enditem() -texinode(Condition Codes)(Examples)(Builtin Commands)(Completion Widgets) +texinode(Condition Codes)(Matching Control)(Builtin Commands)(Completion Widgets) sect(Condition Codes) +cindex(completion widgets, condition codes) -Inside completion widgets not only the builtin commands described -above can be used, but also some additional condition codes. These -work on the special parameters and can be used to easily build -completion functions that generate different matches depending on the -strings on the line. - -The following condition codes are made available inside completion -widgets: +The following additional condition codes for use within the tt([[ ... ]]) +construct are available in completion widgets. These work on the special +parameters. All of these tests can also be performed by the tt(compset) +builtin, but in the case of the condition codes the contents of the special +parameters are not modified. startitem() -item(tt(-prefix) var(string))( -true if the content of tt(PREFIX) starts with var(string) -) -item(tt(-iprefix) var(string))( -like tt(-prefix), but the var(string) is removed from tt(PREFIX) and -added to tt(IPREFIX) -) -item(tt(-position) var(beg) [ var(end) ])( -true if tt(CURRENT) is equal to var(beg) or, if var(end) is given, -equal to or greater than var(beg) and equal to or less than var(end); -both of var(beg) and var(end) may be arithmetic expressions, if they -are less than zero the number of words in tt(argv) are added to them -before comparing them to tt(CURRENT); thus, tt(-1) is the last word, -tt(-2) is the word before that and so on -) -item(tt(-word) var(index) var(string))( -true if the word number var(index) in tt(argv) is equal to -var(string); again, var(index) may be negative, counting backwards +item(tt(-prefix) [ var(number) ] var(pattern))( +true if the test for the tt(-P) option of tt(compset) would succeed. ) -item(tt(-mword) var(index) var(pattern))( -like tt(-word) but using pattern matching +item(tt(-suffix) [ var(number) ] var(pattern))( +true if the test for the tt(-S) option of tt(compset) would succeed. ) -item(tt(-current) var(offset) var(string))( -like tt(-word) but var(offset) is relative to the value of -tt(CURRENT) +item(tt(-after) var(beg-pat))( +true if the test of the tt(-N) option with only the var(beg-pat) given +would succeed. ) -item(tt(-mcurrent) var(offset) var(pattern))( -like tt(-current) but using pattern matching +item(tt(-between) var(beg-pat end-pat))( +true if the test for the tt(-N) option with both patterns would succeed. ) -item(tt(-string) [ var(number) ] var(string))( -true if the current word contains var(string); anything up to the last -occurrence of this string will be ingnored by removing it from -tt(PREFIX) and adding it to tt(IPREFIX); if var(number) is given, -anything up to the var(number)'th occurrence of the var(string) will -be ignored; again, var(nmuber) may be any arithmetic expression and -negative values count backward -) -item(tt(-class) [ var(number) ] var(class))( -like tt(-string) but the var(class) is used as a character class so -that anything up to and including the last or the var(number)'th -occurrence of any character from the string var(class) is ignored -) -item(tt(-words) var(min) [ var(max) ])( -true if the number of words is equal to var(min); if var(max) is -given, it is true if the number of words is equal to or greater than -var(min) and equal to or less than var(max) -) -item(tt(-after) var(string))( -true if the cursor is after a word that is equal to var(string) -) -item(tt(-mafter) var(pattern))( -like tt(-after) but using pattern matching -) -item(tt(-between) var(string1) var(string2))( -true if the cursor is after a word that is equal to var(string1), if -there is also a word that is equal to va(string2), this is true only -if the cursor is before it -) -item(tt(-mbetween) var(pattern1) var(pattern2))( -like tt(-between) but using pattern matching -) -item(tt(-nmatches) var(number))( -true if the the value of tt(NMATCHES) is equal to var(number) -) -item(tt(-matcher) var(number))( -true if the value of tt(MATCHER) is equal to var(number) +enditem() + +texinode(Matching Control)(Examples)(Condition Codes)(Completion Widgets) +sect(Matching Control) + +It is possible by use of the +tt(-M) option of the tt(compadd) builtin command to specify how the +characters in the string to be completed (referred to here as the +command line) map onto the characters in the list of matches produced by +the completion code (referred to here as the trial completions). Note +that this is not used if the command line contains a glob pattern and +the tt(GLOB_COMPLETE) option is set. + +The var(spec) consists of one or more matching descriptions separated by +whitespace. Each description consists of a letter followed by a colon, +then the patterns describing which character sequences on the line match +which character sequences in the trial completion. Any sequence of characters not +handled in this fashion must match exactly, as usual. + +The forms of var(spec) understood are as follows. In each case, the +form with an uppercase initial character retains the string already +typed on the command line as the final result of completion, while with +a lowercase initial character the string on the command line is changed +into the corresponding part of the trial completion. + +startitem() +xitem(tt(m:)var(lpat)tt(=)var(tpat)) +item(tt(M:)var(lpat)tt(=)var(tpat))( +Here, var(lpat) is a pattern that matches on the command line, +corresponding to var(tpat) which matches in the trial completion. +) +xitem(tt(l:)var(anchor)tt(|)var(lpat)tt(=)var(tpat)) +item(tt(L:)var(anchor)tt(|)var(lpat)tt(=)var(tpat))( +These letters are for patterns that are anchored by another pattern on +the left side. Matching for var(lpat) and var(tpat) is as for tt(m) and +tt(M), but the pattern var(lpat) matched on the command line must be +preceeded by the pattern var(anchor). The var(anchor) can be blank to +anchor the match to the start of the command line string; otherwise the +anchor can occur anywhere, but must match in both the command line and +trial completion strings. +) +xitem(tt(r:)var(lpat)tt(|)var(anchor)tt(=)var(tpat)) +item(tt(R:)var(lpat)tt(|)var(anchor)tt(=)var(tpat))( +As tt(l) and tt(L) with the difference that the command line and trial +completion patterns are anchored on the right side. Here an empty +var(anchor) forces the match to the end of the command line string. ) enditem() -texinode(Examples)()(Condition Codes)(Completion Widgets) +Each var(lpat), var(tpat) or var(anchor) is either an empty string or +consists of a sequence of literal characters (which may be quoted with a +backslash), question marks, character classes, and correspondence +classes; ordinary shell patterns are not used. Literal characters match +only themselves, question marks match any character, and character +classes are formed as for globbing and match any character in the given +set. + +Correspondence classes are defined like character classes, but with two +differences: they are delimited by a pair of braces, and negated classes +are not allowed, so the characters tt(!) and tt(^) have no special +meaning directly after the opening brace. They indicate that a range of +characters on the line match a range of characters in the trial +completion, but (unlike ordinary character classes) paired according to +the corresponding position in the sequence. For example, to make any +lowercase letter on the line match the corresponding uppercase letter in +the trial completion, you can use `tt(m:{a-z}={A-Z})'. More than one +pair of classes can occur, in which case the first class before the +tt(=) corresponds to the first after it, and so on. If one side has +more such classes than the other side, the superfluous classes behave +like normal character classes. In anchor patterns correspondence classes +also behave like normal character classes. + +The pattern var(tpat) may also be one or two stars, `tt(*)' or +`tt(**)'. This means that the pattern on the command line can match +any number of characters in the trial completion. In this case the +pattern must be anchored (on either side); in the case of a single +star, the var(anchor) then determines how much of the trial completion +is to be included --- only the characters up to the next appearance of +the anchor will be matched. With two stars, substrings matched by the +anchor can be matched, too. + +Examples: + +The keys of the tt(options) association defined by the tt(parameter) +module are the option names in all-lowercase form, without +underscores, and without the optional tt(no) at the beginning even +though the builtins tt(setopt) and tt(unsetopt) understand option names +with uppercase letters, underscores, and the optional tt(no). The +following alters the matching rules so that the prefix tt(no) and any +underscore are ignored when trying to match the trial completions +generated and uppercase letters on the line match the corresponding +lowercase letters in the words: + +example(compadd -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - \ + ${(k)options} ) + +The first part says that the pattern `tt([nN][oO])' at the beginning +(the empty anchor before the pipe symbol) of the string on the +line matches the empty string in the list of words generated by +completion, so it will be ignored if present. The second part does the +same for an underscore anywhere in the command line string, and the +third part uses correspondence classes so that any +uppercase letter on the line matches the corresponding lowercase +letter in the word. The use of the uppercase forms of the +specification characters (tt(L) and tt(M)) guarantees that what has +already been typed on the command line (in particular the prefix +tt(no)) will not be deleted. + +The second example makes completion case insensitive. This is just +the same as in the option example, except here we wish to retain the +characters in the list of completions: + +example(compadd -M 'm:{a-z}={A-Z}' ... ) + +This makes lowercase letters match their uppercase counterparts. +To make uppercase letters match the lowercase forms as well: + +example(compadd -M 'm:{a-zA-Z}={A-Za-z}' ... ) + +A nice example for the use of tt(*) patterns is partial word +completion. Sometimes you would like to make strings like tt(c.s.u) +complete to strings like tt(comp.source.unix), i.e. the word on the +command line consists of multiple parts, separated by a dot in this +example, where each part should be completed separately --- note, +however, that the case where each part of the word, i.e. tt(comp), +tt(source) and tt(unix) in this example, is to be completed separately +is a different problem to be solved by extended completion. The +example can be handled by: + +example(compadd -M 'r:|.=* r:|=*' \ + - comp.sources.unix comp.sources.misc ...) + +The first specification says that tt(lpat) is the empty string, while +tt(anchor) is a dot; tt(tpat) is tt(*), so this can match anything +except for the `tt(.)' from the anchor in +the trial completion word. So in tt(c.s.u), the matcher sees tt(c), +followed by the empty string, followed by the anchor `tt(.)', and +likewise for the second dot, and replaces the empty strings before the +anchors, giving tt(c)[tt(omp)]tt(.s)[tt(ources)]tt(.u)[tt(nix)], where +the last part of the completion is just as normal. + +With the pattern shown above, the string `tt(c.u)' could not be +completed to `tt(comp.sources.unix)' because the single star means +that no dot (matched by the anchor) can be skipped. By using two stars +as in `tt(r:|.=**)', however, `tt(c.u)' could be completed to +`tt(comp.sources.unix)'. This also shows that in some cases, +especially if the anchor is a real pattern, like a character class, +the form with two stars may result in more matches than one would like. + +The second specification is needed to make this work when the cursor is +in the middle of the string on the command line and the option +tt(COMPLETE_IN_WORD) is set. In this case the completion code would +normally try to match trial completions that end with the string as +typed so far, i.e. it will only insert new characters at the cursor +position rather then at the end. However in our example we would like +the code to recognise matches which contain extra characters after the +string on the line (the tt(nix) in the example). Hence we say that the +empty string at the end of the string on the line matches any characters +at the end of the trial completion. + +More generally, the specification + +example(compadd -M 'r:|[.,_-]=* r:|=*' ... ) + +allows one to complete words with abbreviations before any of the +characters in the square brackets. For example, to +complete tt(veryverylongfile.c) rather than tt(veryverylongheader.h) +with the above in effect, you can just type tt(very.c) before attempting +completion. + +When using the completion system (see +ifzman(zmanref(zshcompsys))\ +ifnzman(noderef(Completion System))\ +), users can define match specifications that are to be used for +specific contexts by using the tt(matcher) style and match +specifications that are to be used everywhere can be defined by the +use of the tt(_matcher) completer. + +texinode(Examples)()(Matching Control)(Completion Widgets) sect(Examples) +cindex(completion widgets, examples) The first step is to define the widget: -indent(nofill( -tt(zle -C complete complete-word complete-history))) +example(zle -C complete complete-word complete-files) Then the widget can be bound to a key using the tt(bindkey) builtin command: -indent(nofill( -tt(bindkey '^X\t' complete))) +example(bindkey '^X\t' complete) -After that the shell function tt(complete-history) will be invoked -after typing control-X and TAB. The function should then generte the +After that the shell function tt(complete-files) will be invoked +after typing control-X and TAB. The function should then generate the matches, e.g.: -indent(nofill( -tt(complete-history LPAR()RPAR() { complist -H 0 '' }))) +example(complete-files LPAR()RPAR() { compadd - * }) -In this the function will complete words from the history matching the +This function will complete files in the current directory matching the current word. + +For a description of the widget-based completion system provided with the +source code distribution, see +ifzman(zmanref(zshcompsys))\ +ifnzman(noderef(Completion System))\ +. + diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 99844b42a..7198df703 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -5,15 +5,15 @@ sect(Description) The types of expansions performed are startlist() -list(em(history expansion)) -list(em(alias expansion)) -list(em(process substitution)) -list(em(parameter expansion)) -list(em(command substitution)) -list(em(arithmetic expansion)) -list(em(brace expansion)) -list(em(filename expansion)) -list(em(filename generation)) +list(em(History Expansion)) +list(em(Alias Expansion)) +list(em(Process Substitution)) +list(em(Parameter Expansion)) +list(em(Command Substitution)) +list(em(Arithmetic Expansion)) +list(em(Brace Expansion)) +list(em(Filename Expansion)) +list(em(Filename Generation)) endlist() Expansion is done in the above specified order in five steps. The @@ -29,8 +29,8 @@ em(filename expansion) followed by em(filename generation). If the tt(SH_FILE_EXPANSION) option is set, the order of expansion is modified for compatibility with bf(sh) and bf(ksh). em(Filename expansion) -is performed immediately after em(alias substitution), -preceding the set of five substitutions mentioned above. +is performed immediately after em(alias expansion), +preceding the set of five expansions mentioned above. startmenu() menu(History Expansion) menu(Process Substitution) @@ -52,7 +52,7 @@ corrections and the repetition of complicated commands or arguments. Command lines are saved in the history list, the size of which is controlled by the tt(HISTSIZE) vindex(HISTSIZE, use of) -variable. The most recent command is retained in any case. +parameter. The most recent command is retained in any case. A history expansion begins with the first character of the tt(histchars) parameter which is `tt(!)' by default and may occur anywhere on the command line; history @@ -161,11 +161,17 @@ Print the new command but do not execute it. Only works with history expansion. ) item(tt(q))( -Quote the substituted words, escaping further substitutions. Only -works with history expansion. +Quote the substituted words, escaping further substitutions. Works +with history expansion and parameter expansion, though for parameters +it is only useful if the resulting text is to be re-evaluated such as +by tt(eval). +) +item(tt(Q))( +Remove one level of quotes from the substituted words. ) item(tt(x))( -Like tt(q), but break into words at each blank. +Like tt(q), but break into words at each blank. Does not work with +parameter expansion. ) item(tt(l))( Convert the words to all lowercase. @@ -175,17 +181,18 @@ Convert the words to all uppercase. ) item(tt(f))( (This and the following -tt(F), tt(w) and tt(W) modifier only work with parameter and -filename expansion.) +tt(F), tt(w) and tt(W) modifier only work with parameter expansion and +filename generation.) Repeats the immediately (without a colon) following modifier until the resulting word doesn't change any more. ) item(tt(F:)var(expr)tt(:))( Like tt(f), but repeats only var(n) times if the expression var(expr) evaluates to var(n). Any character can be used instead of -the `tt(:)', if any of `tt(LPAR())', `tt([)', or `tt({)' -is used as the opening delimiter -the second one has to be 'tt(RPAR())', `tt(])', or `tt(})' respectively. +the `tt(:)'; if `tt(LPAR())', `tt([)', or `tt({)' +is used as the opening delimiter, +the closing delimiter should be 'tt(RPAR())', `tt(])', or `tt(})', +respectively. ) item(tt(w))( Makes the immediately following modifier work on each word in the @@ -200,13 +207,13 @@ item(tt(s/)var(l)tt(/)var(r)[tt(/)])( Substitute var(r) for var(l) as described below. Unless preceded immediately by a tt(g), with no colon between, the substitution is done only for the -first string that matches var(l). For arrays and filename -expansion, this applies to each word of the expanded text. +first string that matches var(l). For arrays and for filename +generation, this applies to each word of the expanded text. ) item(tt(&))( Repeat the previous tt(s) substitution. Like tt(s), may be preceded -immediately by a tt(g). In variable expansion the tt(&) must appear -inside braces, and in filename expansion it must be quoted with a +immediately by a tt(g). In parameter expansion the tt(&) must appear +inside braces, and in filename generation it must be quoted with a backslash. ) enditem() @@ -225,7 +232,7 @@ Note the same record of the last var(l) and var(r) is maintained across all forms of expansion. By default, a history reference with no event specification refers to the same -line as the last history reference on that command line, unless it is the +line as the previous history reference on that command line, unless it is the first history reference in a command. In that case, a history reference with no event specification always refers to the previous command. However, if the option tt(CSH_JUNKIE_HISTORY) is set, @@ -244,8 +251,12 @@ will refer to the first and last words respectively, of the last command referenced on the current command line. However, if they are the first history reference on the command line, then they refer to the previous command. -The character sequence `tt(^)var(foo)tt(^)var(bar)' +The character sequence `tt(^)var(foo)tt(^)var(bar)' (where `tt(^)' is +actually the second charcter of the tt(histchars) parameter) repeats the last command, replacing the string var(foo) with var(bar). +More precisely, the sequence `tt(^)var(foo)tt(^)var(bar)tt(^)' is +synonymous with `tt(!!:s)tt(^)var(foo)tt(^)var(bar)tt(^)', hence other +modifiers may follow the final `tt(^)'. If the shell encounters the character sequence `tt(!")' in the input, the history mechanism is temporarily disabled until @@ -275,7 +286,8 @@ If tt(<) is used, then the file passed as an argument will be a named pipe connected to the output of the var(list) process. For example, -nofill(tt(paste <LPAR()cut -f1) var(file1)tt(RPAR() <LPAR()cut -f3) var(file2)tt(RPAR() | tee >LPAR())var(process1)tt(RPAR() >LPAR())var(process2)tt(RPAR() >/dev/null)) +nofill(tt(paste <LPAR()cut -f1) var(file1)tt(RPAR() <LPAR()cut -f3) var(file2)tt(RPAR() | +tee >LPAR())var(process1)tt(RPAR() >LPAR())var(process2)tt(RPAR() >/dev/null)) cuts fields 1 and 3 from the files var(file1) and var(file2) respectively, pastes the results together, and sends it to the processes @@ -284,7 +296,7 @@ Note that the file, which is passed as an argument to the command, is a system pipe, so programs that expect to lseek (see manref(lseek)(2)) on the file will not work. Also note that the previous example can be more compactly and -efficiently written as: +efficiently written (provided the tt(MULTIOS) option is set) as: nofill(tt(paste <LPAR()cut -f1) var(file1)tt(RPAR() <LPAR()cut -f3) var(file2)tt(RPAR() > >LPAR())var(process1)tt(RPAR() > >LPAR())var(process2)tt(RPAR())) @@ -309,27 +321,37 @@ zmanref(zshparam) ifnzman(\ noderef(Parameters) )\ -for a description of parameters. +for a description of parameters, including arrays, associative arrays, +and subscript notation to access individual array elements. + In the expansions discussed below that require a pattern, the form of the pattern is the same as that used for filename generation; -see noderef(Filename Generation). In addition to the following -operations, the file modifiers described in +see noderef(Filename Generation). Note that these patterns, along with +the replacement text of any substitutions, are themselves subject to +parameter expansion, command substitution, and arithmetic expansion. +In addition to the following operations, the file modifiers described in noderef(Modifiers) in noderef(History Expansion) can be applied: for example, tt(${i:s/foo/bar/}) performs string -substitution on the value of parameter tt($i). +substitution on the expansion of parameter tt($i). startitem() item(tt(${)var(name)tt(}))( The value, if any, of the parameter var(name) is substituted. -The braces are required if var(name) is followed by +The braces are required if the expansion is to be followed by a letter, digit, or underscore that is not to be interpreted -as part of its name. +as part of var(name). In addition, more complicated forms of substitution +usually require the braces to be present; exceptions, which only apply if +the option tt(KSH_ARRAYS) is not set, are a single subscript or any colon +modifiers appearing after the name, or any of the characters `tt(^)', +`tt(=)', `tt(~)', `tt(#)' or `tt(+)' appearing before the name, all of +which work with or without braces. -If var(name) is an array parameter, then the values of each -element of var(name) is substituted, one element per word. -Otherwise, the expansion results in one word only; no field -splitting is done on the result unless the tt(SH_WORD_SPLIT) -option is set. +If var(name) is an array parameter, and the tt(KSH_ARRAYS) option is not +set, then the value of each +element of var(name) is substituted, one element per word. Otherwise, the +expansion results in one word only; with tt(KSH_ARRAYS), this is the first +element of an array. No field splitting is done on the result unless the +tt(SH_WORD_SPLIT) option is set. ) item(tt(${PLUS())var(name)tt(}))( If var(name) is the name of a set parameter `tt(1)' is substituted, @@ -340,14 +362,17 @@ If var(name) is set and is non-null then substitute its value; otherwise substitute var(word). If var(name) is missing, substitute var(word). ) -item(tt(${)var(name)tt(:=)var(word)tt(}))( -If var(name) is unset or is null then -set it to var(word); the value of the parameter is then -substituted. +xitem(tt(${)var(name)tt(:=)var(word)tt(})) +item(tt(${)var(name)tt(::=)var(word)tt(}))( +In the first form, if var(name) is unset or is null then +set it to var(word); in the second form, unconditionally +set var(name) to var(word). In both forms, the value of +the parameter is then substituted. ) item(tt(${)var(name)tt(:?)var(word)tt(}))( -If var(name) is set and is non-null, then substitute +If var(name) is set and is non-null then substitute its value; otherwise, print var(word) and exit from the shell. +Interactive shells instead return to the prompt. If var(word) is omitted, then a standard message is printed. ) item(tt(${)var(name)tt(:PLUS())var(word)tt(}))( @@ -358,13 +383,14 @@ enditem() If the colon is omitted from one of the above expressions containing a colon, then the shell only checks whether -var(name) is set or not, not whether it is null. +var(name) is set, not whether its value is null. + +In the following expressions, when var(name) is an array and +the substitution is not quoted, or if the `tt((@))' flag or the +var(name)tt([@]) syntax is used, matching and replacement is +performed on each array element separately. startitem() -item(tt(${)var(name)tt(::=)var(word)tt(}))( -Set var(name) to var(word); the value of the parameter is then -substituted. -) xitem(tt(${)var(name)tt(#)var(pattern)tt(})) item(tt(${)var(name)tt(##)var(pattern)tt(}))( If the var(pattern) matches the beginning of the value of @@ -373,9 +399,7 @@ the matched portion deleted; otherwise, just substitute the value of var(name). In the first form, the smallest matching pattern is preferred; in the second form, the largest matching pattern is -preferred. If var(name) is an array and the substitution -is not quoted or the tt((@)) flag or the `var(name)tt([@])' syntax -is used, matching is performed on each array elements separately. +preferred. ) xitem(tt(${)var(name)tt(%)var(pattern)tt(})) item(tt(${)var(name)tt(%%)var(pattern)tt(}))( @@ -385,24 +409,52 @@ the matched portion deleted; otherwise, just substitute the value of var(name). In the first form, the smallest matching pattern is preferred; in the second form, the largest matching pattern is -preferred. If var(name) is an array and the substitution -is not quoted or the tt((@)) flag or the `var(name)tt([@])' syntax -is used, matching is performed on each array elements separately. +preferred. ) item(tt(${)var(name)tt(:#)var(pattern)tt(}))( If the var(pattern) matches the value of var(name), then substitute the empty string; otherwise, just substitute the value of var(name). -If var(name) is an array and the substitution -is not quoted or the tt((@)) flag or the `var(name)tt([@])' syntax -is used, matching is performed on each array elements separately, and -the matched array elements are removed (use the tt((M)) flag to +If var(name) is an array +the matching array elements are removed (use the `tt((M))' flag to remove the non-matched elements). ) +xitem(tt(${)var(name)tt(/)var(pattern)tt(/)var(repl)tt(})) +item(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))( +Replace the longest possible match of var(pattern) in the expansion of +parameter var(name) by string var(repl). The first form +replaces just the first occurrence, the second form all occurrences. +The var(pattern) may begin with a `tt(#)', in which case the +var(pattern) must match at the start of the string, or `tt(%)', in +which case it must match at the end of the string. The var(repl) may +be an empty string, in which case the final `tt(/)' may also be omitted. +To quote the final `tt(/)' in other cases it should be preceded by two +backslashes (i.e., a quoted backslash); this is not necessary if the +`tt(/)' occurs inside a substituted parameter. + +The first `tt(/)' may be preceded by a `tt(:)', in which case the match +will only succeed if it matches the entire word. Note also the +effect of the tt(I) and tt(S) parameter expansion flags below; however, +the flags tt(M), tt(R), tt(B), tt(E) and tt(N) are not useful. + +For example, + +example(foo="twinkle twinkle little star" sub="t*e" rep="spy" +print ${foo//${~sub}/$rep} +print ${(S)foo//${~sub}/$rep}) + +Here, the `tt(~)' ensures that the text of tt($sub) is treated as a +pattern rather than a plain string. In the first case, the longest +match for tt(t*e) is substituted and the result is `tt(spy star)', +while in the second case, the shortest matches are taken and the +result is `tt(spy spy lispy star)'. +) item(tt(${#)var(spec)tt(}))( If var(spec) is one of the above substitutions, substitute the length in characters of the result instead of the result itself. If var(spec) is an array expression, substitute the number of elements of the result. +Note that `tt(^)', `tt(=)', and `tt(~)', below, must appear +to the left of `tt(#)' when these forms are combined. ) item(tt(${^)var(spec)tt(}))( pindex(RC_EXPAND_PARAM, use of) @@ -411,7 +463,7 @@ cindex(rc, array expansion style) Turn on the tt(RC_EXPAND_PARAM) option for the evaluation of var(spec); if the `tt(^)' is doubled, turn it off. When this option is set, array expansions of the form -`var(foo)tt(${)var(xx)tt(})var(bar)', +var(foo)tt(${)var(xx)tt(})var(bar), where the parameter var(xx) is set to tt(LPAR())var(a b c)tt(RPAR()), are substituted with `var(fooabar foobbar foocbar)' instead of the default @@ -420,7 +472,7 @@ is set to tt(LPAR())var(a b c)tt(RPAR()), are substituted with Internally, each such expansion is converted into the equivalent list for brace expansion. E.g., tt(${^var}) becomes tt({$var[1],$var[2],)...tt(}), and is processed as described in -noderef(Brace Expansion) above. +noderef(Brace Expansion) below. If word splitting is also in effect the tt($var[)var(N)tt(]) may themselves be split into different list elements. @@ -429,36 +481,51 @@ item(tt(${=)var(spec)tt(}))( pindex(SH_WORD_SPLIT, use of) cindex(field splitting, sh style) cindex(sh, field splitting style) -Turn on the tt(SH_WORD_SPLIT) option for the -evaluation of var(spec); if the `tt(=)' is doubled, turn it off. +Perform word splitting using the rules for tt(SH_WORD_SPLIT) during the +evaluation of var(spec), but regardless of whether the parameter appears in +double quotes; if the `tt(=)' is doubled, turn it off. vindex(IFS, use of) -When this option is set, parameter values are split into -separate words using tt(IFS) as a delimiter -before substitution. +This forces parameter expansions to be split into +separate words before substitution, using tt(IFS) as a delimiter. This is done by default in most other shells. + +Note that splitting is applied to var(word) in the assignment forms +of var(spec) em(before) the assignment to var(name) is performed. +This affects the result of array assignments with the tt(A) flag. ) item(tt(${~)var(spec)tt(}))( pindex(GLOB_SUBST) Turn on the tt(GLOB_SUBST) option for the evaluation of var(spec); if the `tt(~)' is doubled, turn it off. When this option is -set, any pattern characters resulting -from the substitution become eligible for file expansion and filename -generation. +set, the string resulting from the expansion will be interpreted as a +pattern anywhere that is possible, such as in filename expansion and +filename generation and pattern-matching contexts like the right +hand side of the `tt(=)' and `tt(!=)' operators in conditions. ) enditem() If a tt(${)...tt(}) type parameter expression or a tt($LPAR())...tt(RPAR()) type command substitution is used in place of -var(name) above, it is substituted first and the result is used as if +var(name) above, it is expanded first and the result is used as if it were the value of var(name). Thus it is possible to perform nested operations: tt(${${foo#head}%tail}) -substitues the value of tt($foo) with both tt(head) and tt(tail) +substitutes the value of tt($foo) with both `tt(head)' and `tt(tail)' deleted. The form with tt($LPAR())...tt(RPAR()) is often useful in -combination with the flags described next; see the example below. +combination with the flags described next; see the examples below. + +Note that double quotes may appear around nested substitutions, in which +case only the part inside is treated as quoted; for example, +tt(${(f)"$(foo)"}) quotes the result of tt($(foo)), but the flag `tt((f))' +(see below) is applied using the rules for unquoted substitutions. Note +further that quotes are themselves nested in this context; for example, in +tt("${(@f)"$(foo)"}"), there are two sets of quotes, one surrounding the +whole expression, the other (redundant) surrounding the tt($(foo)) as +before. + subsect(Parameter Expansion Flags) cindex(parameter expansion flags) cindex(flags, parameter expansion) -cindex(expansion, parameter, flags) +cindex(substitution, parameter, flags) If the opening brace is directly followed by an opening parenthesis, the string up to the matching closing parenthesis will be taken as a list of flags. Where arguments are valid, any character, or the @@ -468,20 +535,33 @@ in place of the colon as delimiters. The following flags are supported: startitem() item(tt(A))( -Create an array parameter with +Create an array parameter with tt(${)...tt(=)...tt(}), tt(${)...tt(:=)...tt(}) or tt(${)...tt(::=)...tt(}). -Assignment is made before sorting or padding. +If this flag is repeated (as in tt(AA)), create an associative +array parameter. Assignment is made before sorting or padding. +The var(name) part may be a subscripted range for ordinary +arrays; the var(word) part em(must) be converted to an array, for +example by using tt(${(AA)=)var(name)tt(=)...tt(}) to activate word +splitting, when creating an associative array. ) item(tt(@))( In double quotes, array elements are put into separate words. -E.g., `tt("${(@)foo}")' is equivalent to `tt("${foo[@]}")' and -`tt("${(@)foo[1,2]}")' is the same as `tt("$foo[1]" "$foo[2]")'. +E.g., tt("${(@)foo}") is equivalent to tt("${foo[@]}") and +tt("${(@)foo[1,2]}") is the same as tt("$foo[1]" "$foo[2]"). ) item(tt(e))( Perform em(parameter expansion), em(command substitution) and em(arithmetic expansion) on the result. Such expansions can be nested but too deep recursion may have unpredictable effects. ) +item(tt(P))( +This forces the value of the parameter var(name) to be interpreted as a +further parameter name, whose value will be used where appropriate. If used +with a nested parameter or command substitution, the result of that will be +taken as a parameter name in the same way. For example, if you have +`tt(foo=bar)' and `tt(bar=baz)', the strings tt(${(P)foo}), +tt(${(P)${foo}}), and tt(${(P)$(echo bar)}) will be expanded to `tt(baz)'. +) item(tt(o))( Sort the resulting words in ascending order. ) @@ -498,7 +578,33 @@ item(tt(U))( Convert all letters in the result to upper case. ) item(tt(C))( -Capitalize the resulting words. +Capitalize the resulting words. `Words' in this case refers to sequences +of alphanumeric characters separated by non-alphanumerics, em(not) to words +that result from field splitting. +) +item(tt(V))( +Make any special characters in the resulting words visible. +) +item(tt(q))( +Quote the resulting words with backslashes. If this flag is given +twice, the resulting words are quoted in single quotes and if it is +given three times, the words are quoted in double quotes. If it is +given four times, the words are quoted in single quotes preceded a tt($). +) +item(tt(Q))( +Remove one level of quotes from the resulting words. +) +item(tt(%))( +Expand all tt(%) escapes in the resulting words in the same way as in +prompts (see noderef(Prompt Expansion)). If this flag is given twice, +full prompt expansion is done on the resulting words, depending on the +setting of the tt(PROMPT_PERCENT), tt(PROMPT_SUBST) and +tt(PROMPT_BANG) options. +) +item(tt(X))( +With this flag parsing errors occuring with the tt(Q) flag or the +pattern matching forms such as `tt(${)var(name)tt(#)var(pattern)tt(})' +are reported. Without the flag they are silently ignored. ) item(tt(c))( With tt(${#)var(name)tt(}), count the total number of characters in an array, @@ -512,20 +618,34 @@ item(tt(W))( Similar to tt(w) with the difference that empty words between repeated delimiters are also counted. ) +item(tt(k))( +If var(name) refers to an associative array, substitute the em(keys) +(element names) rather than the values of the elements. Used with +subscripts (including ordinary arrays), force indices or keys to be +substituted even if the subscript form refers to values. However, +this flag may not be combined with subscript ranges. +) +item(tt(v))( +Used with tt(k), substitute (as two consecutive words) both the key +and the value of each associative array element. Used with subscripts, +force values to be substituted even if the subscript form refers to +indices or keys. +) item(tt(p))( Recognize the same escape sequences as the tt(print) builtin -in string arguments to subsequent flags. +in string arguments to any of the flags described below. ) item(tt(l:)var(expr)tt(::)var(string1)tt(::)var(string2)tt(:))( Pad the resulting words on the left. Each word will be truncated if required and placed in a field var(expr) characters wide. The space to the left will be filled with var(string1) (concatenated as often as needed) or spaces if var(string1) is not given. If both -var(string1) and var(string2) are given, this string will be placed -exactly once directly to the left of the resulting word. +var(string1) and var(string2) are given, this string is inserted +once directly to the left of each word, before padding. ) item(tt(r:)var(expr)tt(::)var(string1)tt(::)var(string2)tt(:))( -As tt(l), but pad the words on the right. +As tt(l), but pad the words on the right and insert var(string2) +on the right. ) item(tt(j:)var(string)tt(:))( Join the words of arrays together using var(string) as a separator. @@ -546,13 +666,78 @@ item(tt(f))( Split the result of the expansion to lines. This is a shorthand for `tt(ps:\n:)'. ) +item(tt(t))( +Use a string describing the type of the parameter where the value +of the parameter would usually appear. This string consists of keywords +separated by hyphens (`tt(-)'). The first keyword in the string describes +the main type, it can be one of `tt(scalar)', `tt(array)', `tt(integer)', +or `tt(association)'. The other keywords describe the type in more +detail: + +startitem() +item(tt(local))( +for local parameters +) +item(tt(left))( +for left justified parameters +) +item(tt(right_blanks))( +for right justified parameters with leading blanks +) +item(tt(right_zeros))( +for right justified parameters with leading zeros +) +item(tt(lower))( +for parameters whose value is converted to all lower case when it is +expanded +) +item(tt(upper))( +for parameters whose value is converted to all upper case when it is +expanded +) +item(tt(readonly))( +for readonly parameters +) +item(tt(tag))( +for tagged parameters +) +item(tt(export))( +for exported parameters +) +item(tt(unique))( +for arrays which keep only the first occurrence of duplicated values +) +item(tt(hide))( +for parameters with the `hide' flag +) +item(tt(special))( +for special parameters defined by the shell +) +enditem() +) +enditem() + +The following flags are meaningful with the tt(${)...tt(#)...tt(}) or +tt(${)...tt(%)...tt(}) forms. The tt(S) and tt(I) flags may also be +used with the tt(${)...tt(/)...tt(}) forms. + +startitem() item(tt(S))( -(This and all remaining flags are used with the tt(${)...tt(#)...tt(}) or -tt(${)...tt(%)...tt(}) forms.) -Search substrings as well as beginnings or ends. +Search substrings as well as beginnings or ends; with tt(#) start +from the beginning and with tt(%) start from the end of the string. +With substitution via tt(${)...tt(/)...tt(}) or +tt(${)...tt(//)...tt(}), specifies that the shortest instead of the +longest match should be replaced. ) item(tt(I:)var(expr)tt(:))( Search the var(expr)th match (where var(expr) evaluates to a number). +This only applies when searching for substrings, either with the tt(S) +flag, or with tt(${)...tt(/)...tt(}) (only the var(expr)th match is +substituted) or tt(${)...tt(//)...tt(}) (all matches from the +var(expr)th on are substituted). The var(expr)th match is counted +such that there is either one or zero matches from each starting +position in the string, although for global substitution matches +overlapping previous replacements are ignored. ) item(tt(M))( Include the matched portion in the result. @@ -570,22 +755,153 @@ item(tt(N))( Include the length of the match in the result. ) enditem() -subsect(Example) + +subsect(Rules) + +Here is a summary of the rules for substitution; this assumes that braces +are present around the substitution, i.e. tt(${...}). Some particular +examples are given below. Note that the Zsh Development Group accepts +em(no responsibility) for any brain damage which may occur during the +reading of the following rules. + +startitem() +item(tt(1.) em(Nested Substitution))( +If multiple nested tt(${...}) forms are present, substitution is +performed from the inside outwards. At each level, the substitution takes +account of whether the current value is a scalar or an array, whether the +whole substitution is in double quotes, and what flags are supplied to the +current level of substitution, just as if the nested substitution were the +outermost. The flags are not propagated up to enclosing +substitutions; the nested substitution will return either a scalar or an +array as determined by the flags, possibly adjusted for quoting. All the +following steps take place where applicable at all levels of substitution. +Note that, unless the `tt((P))' flag is present, the flags and any subscripts +apply directly to the value of the nested substitution; for example, the +expansion tt(${${foo}}) behaves exactly the same as tt(${foo}). +) +item(tt(2.) em(Parameter Subscripting))( +If the value is a raw parameter reference with a subscript, such as +tt(${)var(var)tt([3]}), the effect of subscripting is applied directly to +the parameter. Subscripts are evaluated left to right; subsequent +subscripts apply to the scalar or array value yielded by the previous +subscript. Thus if tt(var) is an array, tt(${var[1][2]}) is the second +character of the first word, but tt(${var[2,4][2]}) is the entire third +word (the second word of the range of words two through four of the +original array). Any number of subscripts may appear. +) +item(tt(3.) em(Parameter Name Replacement))( +The effect of any tt((P)) flag, which treats the value so far as a +parameter name and replaces it with the corresponding value, is applied. +) +item(tt(4.) em(Double-Quoted Joining))( +If the value after this process is an array, and the substitution +appears in double quotes, and no tt((@)) flag is present at the current +level, the words of the value are joined with the first character of the +parameter tt($IFS), by default a space, between each word (single word +arrays are not modified). If the tt((j)) flag is present, that is used for +joining instead of tt($IFS). +) +item(tt(5.) em(Nested Subscripting))( +Any remaining subscripts (i.e. of a nested substitution) are evaluated at +this point, based on whether the value is an array or a scalar. As with +tt(2.), multiple subscripts can appear. Note that tt(${foo[2,4][2]}) is +thus equivalent to tt(${${foo[2,4]}[2]}) and also to +tt("${${(@)foo[2,4]}[2]}") (the nested substitution returns an array in +both cases), but not to tt("${${foo[2,4]}[2]}") (the nested substitution +returns a scalar because of the quotes). +) +item(tt(6.) em(Modifiers))( +Any modifiers, as specified by a trailing `tt(#)', `tt(%)', `tt(/)' +(possibly doubled) or by a set of modifiers of the form tt(:...) (see +noderef(Modifiers) in noderef(History Expansion)), are applied to the words +of the value at this level. +) +item(tt(7.) em(Forced Joining))( +If the `tt((j))' flag is present, or no `tt((j))' flag is present but +the string is to be split as given by rules tt(8.) or tt(9.), and joining +did not take place at step tt(4.), any words in the value are joined +together using the given string or the first character of tt($IFS) if none. +Note that the `tt((F))' flag implicitly supplies a string for joining in this +manner. +) +item(tt(8.) em(Forced Splitting))( +If one of the `tt((s))' or `tt((f))' flags are present, or the `tt(=)' +specifier was present (e.g. tt(${=)var(var)tt(})), the word is split on +occurrences of the specified string, or (for tt(=) with neither of the two +flags present) any of the characters in tt($IFS). +) +item(tt(9.) em(Shell Word Splitting))( +If no `tt((s))', `tt((f))' or `tt(=)' was given, but the word is not +quoted and the option tt(SH_WORD_SPLIT) is set, the word is split on +occurrences of any of the characters in tt($IFS). Note this step, too, +take place at all levels of a nested substitution. +) +item(tt(10.) em(Re-Evaluation))( +Any `tt((e))' flag is applied to the value, forcing it to be re-examined +for new parameter substitutions, but also for command and arithmetic +substitutions. +) +item(tt(11.) em(Padding))( +Any padding of the value by the `tt(LPAR()l.)var(fill)tt(.RPAR())' or +`tt(LPAR()r.)var(fill)tt(.RPAR())' flags is applied. +) +enditem() + +subsect(Examples) The flag tt(f) is useful to split a double-quoted substitution line by -line. For example, `tt("${(f)$LPAR()<)var(file)tt(RPAR()}")' -will substitue the contents of var(file) divided so that one line is -supplied per argument to var(cmd). Compare this with the effect of -`tt($)tt(LPAR()<)var(file)tt(RPAR())' alone, which divides the file -up by words, or the same inside double quotes, where the entire -contents of the file are passed as a single argument. +line. For example, tt(${(f)"$LPAR()<)var(file)tt(RPAR()"}) +substitutes the contents of var(file) divided so that each line is +an element of the resulting array. Compare this with the effect of +tt($)tt(LPAR()<)var(file)tt(RPAR()) alone, which divides the file +up by words, or the same inside double quotes, which makes the entire +content of the file a single string. + +The following illustrates the rules for nested parameter expansions. +Suppose that tt($foo) contains the array tt(LPAR()bar baz)tt(RPAR()): + +startitem() +item(tt("${(@)${foo}[1]}"))( +This produces the result tt(b). First, the inner substitution +tt("${foo}"), which has no array (tt(@)) flag, produces a single word +result tt("bar baz"). The outer substitution tt("${(@)...[1]}") detects +that this is a scalar, so that (despite the `tt((@))' flag) the subscript +picks the first character. +) +item(tt("${${(@)foo}[1]}"))( +The produces the result `tt(bar)'. In this case, the inner substitution +tt("${(@)foo}") produces the array `tt(LPAR()bar baz)tt(RPAR())'. The outer +substitution tt("${...[1]}") detects that this is an array and picks the +first word. This is similar to the simple case tt("${foo[1]}"). +) +enditem() + +As an example of the rules for word splitting and joining, suppose tt($foo) +contains the array `tt(LPAR()ax1 bx1)tt(RPAR())'. Then + +startitem() +item(tt(${(s/x/)foo}))( +produces the words `tt(a)', `tt(1 b)' and `tt(1)'. +) +item(tt(${(j/x/s/x/)foo}))( +produces `tt(a)', `tt(1)', `tt(b)' and `tt(1)'. +) +item(tt(${(s/x/)foo%%1*}))( +produces `tt(a)' and `tt( b)' (note the extra space). As substitution +occurs before either joining or splitting, the operation first generates +the modified array tt(LPAR()ax bx)tt(RPAR()), which is joined to give +tt("ax bx"), and then split to give `tt(a)', `tt( b)' and `'. The final +empty string will then be elided, as it is not in double quotes. +) +enditem() + texinode(Command Substitution)(Arithmetic Expansion)(Parameter Expansion)(Expansion) sect(Command Substitution) cindex(command substitution) cindex(substitution, command) -A command enclosed in parentheses -preceded by a dollar sign, like `tt($LPAR())...tt(RPAR())', or quoted with grave -accents, like `tt(`)...tt(`)', is replaced with its standard output, with any -trailing newlines deleted. +A command enclosed in parentheses preceded by a dollar sign, like +`tt($LPAR())...tt(RPAR())', or quoted with grave +accents, like `tt(`)...tt(`)', is replaced with its standard output, with +any trailing newlines deleted. If the substitution is not enclosed in double quotes, the output is broken into words using the tt(IFS) parameter. vindex(IFS, use of) @@ -630,6 +946,14 @@ In that case, it is expanded to a sorted list of the individual characters between the braces, in the manner of a search set. `tt(-)' is treated specially as in a search set, but `tt(^)' or `tt(!)' as the first character is treated normally. + +Note that brace expansion is not part of filename generation (globbing); an +expression such as tt(*/{foo,bar}) is split into two separate words +tt(*/foo) and tt(*/bar) before filename generation takes place. In +particular, note that this is liable to produce a `no match' error if +em(either) of the two expressions does not match; this is to be contrasted +with tt(*/(foo|bar)), which is treated as a single pattern but otherwise +has similar effects. texinode(Filename Expansion)(Filename Generation)(Brace Expansion)(Expansion) sect(Filename Expansion) cindex(filename expansion) @@ -677,7 +1001,8 @@ directory as its prefix. If so, then the prefix portion is replaced with a `tt(~)' followed by the name of the directory. The shortest way of referring to the directory is used, with ties broken in favour of using a named directory, -except when the directory is tt(/) itself. +except when the directory is tt(/) itself. The parameters tt($PWD) and +tt($OLDPWD) are never abbreviated in this fashion. If a word begins with an unquoted `tt(=)' and the tt(EQUALS) option is set, @@ -745,7 +1070,7 @@ can be specified by separating two characters by a `tt(-)'. A `tt(-)' or `tt(])' may be matched by including it as the first character in the list. There are also several named classes of characters, in the form -`tt([:)var(name)(tt:])' with the following meanings: `tt([:alnum:])' +`tt([:)var(name)tt(:])' with the following meanings: `tt([:alnum:])' alphanumeric, `tt([:alpha:])' alphabetic, `tt([:blank:])' space or tab, `tt([:cntrl:])' control character, `tt([:digit:])' decimal @@ -770,13 +1095,23 @@ not in the given set. item(tt(<)[var(x)]tt(-)[var(y)]tt(>))( Matches any number in the range var(x) to var(y), inclusive. Either of the numbers may be omitted to make the range open-ended; -hence `tt(<->)' matches any number. +hence `tt(<->)' matches any number. To match individual digits, the +tt([)...tt(]) form is more efficient. ) item(tt(LPAR())...tt(RPAR()))( Matches the enclosed pattern. This is used for grouping. If the tt(KSH_GLOB) option is set, then a `tt(@)', `tt(*)', `tt(+)', `tt(?)' or `tt(!)' immediately preceding -the `tt(LPAR())' is treated specially, as detailed below. +the `tt(LPAR())' is treated specially, as detailed below. The option +tt(SH_GLOB) prevents bare parentheses from being used in this way, though +the tt(KSH_GLOB) option is still available. + +Note that grouping cannot extend over multiple directories: it is an error +to have a `tt(/)' within a group (this only applies for patterns used in +filename generation). There is one exception: a group of the form +tt(LPAR())var(pat)tt(/RPAR()#) appearing as a complete path segment can +match a sequence of directories. For example, tt(foo/(a*/)#bar) matches +tt(foo/bar), tt(foo/any/bar), tt(foo/any/anyother/bar), and so on. ) item(var(x)tt(|)var(y))( Matches either var(x) or var(y). @@ -797,7 +1132,7 @@ Match anything that matches the pattern var(x) but does not match var(y). This has lower precedence than any operator except `tt(|)', so `tt(*/*~foo/bar)' will search for all files in all directories in `tt(.)' and then exclude `tt(foo/bar)' if there was such a match. -It groups left-to-right, so multiple patterns can be excluded by +Multiple patterns can be excluded by `var(foo)tt(~)var(bar)tt(~)var(baz)'. In the exclusion pattern (var(y)), `tt(/)' and `tt(.)' are not treated specially the way they usually are in globbing. @@ -806,13 +1141,19 @@ item(var(x)tt(#))( (Requires tt(EXTENDED_GLOB) to be set.) Matches zero or more occurrences of the pattern var(x). This operator has high precedence; `tt(12#)' is equivalent to `tt(1(2#))', -rather than `tt((12)#)'. +rather than `tt((12)#)'. It is an error for an unquoted `tt(#)' to follow +something which cannot be repeated; this includes an empty string, a +pattern already followed by `tt(##)', or parentheses when part of a +tt(KSH_GLOB) pattern (for example, `tt(!LPAR())var(foo)tt(RPAR()#)' is +invalid and must be replaced by +`tt(*LPAR()!LPAR())var(foo)tt(RPAR()RPAR())'). ) item(var(x)tt(##))( (Requires tt(EXTENDED_GLOB) to be set.) Matches one or more occurrences of the pattern var(x). This operator has high precedence; `tt(12##)' is equivalent to `tt(1(2##))', -rather than `tt((12)##)'. +rather than `tt((12)##)'. No more than two active `tt(#)' characters may +appear together. ) enditem() subsect(ksh-like Glob Operators) @@ -840,21 +1181,221 @@ Match anything but the expression in parentheses. (Like `tt(LPAR()^LPAR())...tt(RPAR()RPAR())'.) ) enditem() +subsect(Precedence) +cindex(precedence of glob operators) +The precedence of the operators given above is (highest) `tt(^)', `tt(/)', +`tt(~)', `tt(|)' (lowest); the +remaining operators are simply treated from left to right as part of a +string, with `tt(#)' and `tt(##)' applying to the shortest possible +preceeding unit (i.e. a character, `tt(?)', `tt([)...tt(])', +`tt(<)...tt(>)', or a parenthesised expression). As mentioned +above, a `tt(/)' used as a directory separator may not appear inside +parentheses, while a `tt(|)' must do so; in patterns used in other contexts +than filename generation (for example, in tt(case) statements and tests +within `tt([[)...tt(]])'), a `tt(/)' is not special; and `tt(/)' is also +not special after a `tt(~)' appearing outside parentheses in a filename +pattern. +subsect(Globbing Flags) +There are various flags which affect any text to their right up to the +end of the enclosing group or to the end of the pattern; they require +the tt(EXTENDED_GLOB) option. All take the form +tt(LPAR()#)var(X)tt(RPAR()) where var(X) may have one of the following +forms: + +startitem() +item(i)( +Case insensitive: upper or lower case characters in the pattern match +upper or lower case characters. +) +item(l)( +Lower case characters in the pattern match upper or lower case +characters; upper case characters in the pattern still only match +upper case characters. +) +item(I)( +Case sensitive: locally negates the effect of tt(i) or tt(l) from +that point on. +) +item(b)( +Activate backreferences for parenthesised groups in the pattern; +this does not work in filename generation. When a pattern with a set of +active parentheses is matched, the strings matched by the groups are +stored in the array tt($match), the indices of the beginning of the matched +parentheses in the array tt($mbegin), and the indices of the end in the array +tt($mend), with the first element of each array corresponding to the first +parenthesised group, and so on. These arrays are not otherwise special to +the shell. The indices use the same convention as does parameter +substitution, so that elements of tt($mend) and tt($mbegin) may be used in +subscripts; the tt(KSH_ARRAYS) option is respected. Sets of globbing flags +are not considered parenthesised groups; only the first nine active +parentheses can be referenced. + +For example, + +example(foo="a string with a message" +if [[ $foo = (a|an)' '(#b)(*)' '* ]]; then + print ${foo[$mbegin[1],$mend[1]]} +fi) + +prints `tt(string with a)'. Note that the first parenthesis is before the +tt((#b)) and does not create a backreference. + +Backreferences work with all forms of pattern matching other than filename +generation, but note that when performing matches on an entire array, such +as tt(${)var(array)tt(#)var(pattern)tt(}), or a global substitution, such +as tt(${)var(param)tt(//)var(pat)tt(/)var(repl)tt(}), only the data for the +last match remains available. In the case of global replacements this may +still be useful. See the example for the tt(m) flag below. + +The numbering of backreferences strictly follows the order of the opening +parentheses from left to right in the pattern string, although sets of +parentheses may be nested. There are special rules for parentheses followed +by `tt(#)' or `tt(##)'. Only the last match of the parenthesis is +remembered: for example, in `tt([[ abab = (#b)([ab])# ]])', only the final +`tt(b)' is stored in tt(match[1]). Thus extra parentheses may be necessary +to match the complete segment: for example, use `tt(X((ab|cd)#)Y)' to match +a whole string of either `tt(ab)' or `tt(cd)' between `tt(X)' and `tt(Y)', +using the value of tt($match[1]) rather than tt($match[2]). + +If the match fails none of the parameters is altered, so in some cases it +may be necessary to initialise them beforehand. If some of the +backreferences fail to match --- which happens if they are in an alternate +branch which fails to match, or if they are followed by tt(#) and matched +zero times --- then the matched string is set to the empty string, and the +start and end indices are set to -1. + +Pattern matching with backreferences is slightly slower than without. +) +item(B)( +Deactivate backreferences, negating the effect of the tt(b) flag from that +point on. +) +item(m)( +Set references to the match data for the entire string matched; this is +similar to backreferencing and does not work in filename generation. The +flag must be in effect at the end of the pattern, i.e. not local to a +group. The parameters tt($MATCH), tt($MBEGIN) and tt($MEND) will be set to +the string matched and to the indices of the beginning and end of the +string, respectively. This is most useful in parameter substitutions, as +otherwise the string matched is obvious. + +For example, + +example(arr=(veldt jynx grimps waqf zho buck) +print ${arr//(#m)[aeiou]/${(U)MATCH}}) + +forces all the matches (i.e. all vowels) into uppercase, printing +`tt(vEldt jynx grImps wAqf zhO bUck)'. + +Unlike backreferences, there is no speed penalty for using match +references, other than the extra substitutions required for the +replacement strings in cases such as the example shown. +) +item(M)( +Deactivate the tt(m) flag, hence no references to match data will be +created. +) +item(tt(a)var(num))( +Approximate matching: var(num) errors are allowed in the string matched by +the pattern. The rules for this are described in the next subsection. +) +enditem() + +For example, the test string tt(fooxx) can be matched by the pattern +tt(LPAR()#i)tt(RPAR()FOOXX), but not by tt(LPAR()#l)tt(RPAR()FOOXX), +tt(LPAR()#i)tt(RPAR()FOO)tt(LPAR()#I)tt(RPAR()XX) or +tt(LPAR()LPAR()#i)tt(RPAR()FOOX)tt(RPAR()X). The string +tt(LPAR()#ia2)tt(RPAR()readme) specifies case-insensitive matching of +tt(readme) with up to two errors. + +When using the ksh syntax for grouping both tt(KSH_GLOB) and +tt(EXTENDED_GLOB) must be set and the left parenthesis should be +preceded by tt(@). Note also that the flags do not affect letters +inside tt([...]) groups, in other words tt(LPAR()#i)tt(RPAR()[a-z]) +still matches only lowercase letters. Finally, note that when +examining whole paths case-insensitively every directory must be +searched for all files which match, so that a pattern of the form +tt(LPAR()#i)tt(RPAR()/foo/bar/...) is potentially slow. + +subsect(Approximate Matching) +When matching approximately, the shell keeps a count of the errors found, +which cannot exceed the number specified in the +tt(LPAR()#a)var(num)tt(RPAR()) flags. Four types of error are recognised: + +startitem() +item(1.)( +Different characters, as in tt(fooxbar) and tt(fooybar). +) +item(2.)( +Transposition of characters, as in tt(banana) and tt(abnana). +) +item(3.)( +A character missing in the target string, as with the pattern tt(road) and +target string tt(rod). +) +item(4.)( +An extra character appearing in the target string, as with tt(stove) +and tt(strove). +) +enditem() + +Thus, the pattern tt(LPAR()#a3)tt(RPAR()abcd) matches tt(dcba), with the +errors occurring by using the first rule twice and the second once, +grouping the string as tt([d][cb][a]) and tt([a][bc][d]). + +Non-literal parts of the pattern must match exactly, including characters +in character ranges: hence tt(LPAR()#a1)tt(RPAR()???) matches strings of +length four, by applying rule 4 to an empty part of the pattern, but not +strings of length two, since all the tt(?) must match. Other characters +which must match exactly are initial dots in filenames (unless the +tt(GLOB_DOTS) option is set), and all slashes in filenames, so that +tt(a/bc) is two errors from tt(ab/c) (the slash cannot be transposed with +another character). Similarly, errors are counted separately for +non-contiguous strings in the pattern, so that tt(LPAR()ab|cd)tt(RPAR()ef) +is two errors from tt(aebf). + +When using exclusion via the tt(~) operator, approximate matching is +treated entirely separately for the excluded part and must be activated +separately. Thus, tt(LPAR()#a1)tt(RPAR()README~READ_ME) matches +tt(READ.ME) but not tt(READ_ME), as the trailing tt(READ_ME) is matched +without approximation. However, +tt(LPAR()#a1)tt(RPAR()README~LPAR()#a1)tt(RPAR()READ_ME) +does not match any pattern of the form tt(READ)var(?)tt(ME) as all +such forms are now excluded. + +Apart from exclusions, there is only one overall error count; however, the +maximum errors allowed may be altered locally, and this can be delimited by +grouping. For example, +tt(LPAR()#a1)tt(RPAR()cat)tt(LPAR()LPAR()#a0)tt(RPAR()dog)tt(RPAR()fox) +allows one error in total, which may not occur in the tt(dog) section, and +the pattern +tt(LPAR()#a1)tt(RPAR()cat)tt(LPAR()#a0)tt(RPAR()dog)tt(LPAR()#a1)tt(RPAR()fox) +is equivalent. Note that the point at which an error is first found is the +crucial one for establishing whether to use approximation; for example, +tt((#a1)abc(#a0)xyz) will not match tt(abcdxyz), because the error occurs +at the `tt(x)', where approximation is turned off. + subsect(Recursive Globbing) A pathname component of the form `tt(LPAR())var(foo)tt(/RPAR()#)' matches a path consisting of zero or more directories matching the pattern var(foo). -As a shorthand, `tt(**/)' is equivalent to `tt((*/)#)'. + +As a shorthand, `tt(**/)' is equivalent to `tt((*/)#)'; note that this +therefore matches files in the current directory as well as +subdirectories. Thus: -nofill(tt(ls (*/)#bar)) +example(ls (*/)#bar) or -nofill(tt(ls **/bar)) +example(ls **/bar) -does a recursive directory search for files named `tt(bar)', not following -symbolic links. To follow links, use `tt(***/)'. +does a recursive directory search for files named `tt(bar)' (potentially +including the file `tt(bar)' in the current directory), not following +symbolic links. To follow links, use `tt(***/)'. Neither of these can be +combined with other forms of globbing within the same filename segment; in +that case, the `tt(*)' operators revert to their usual effect. subsect(Glob Qualifiers) cindex(globbing, qualifiers) cindex(qualifiers, globbing) @@ -937,6 +1478,67 @@ setgid files (02000) item(tt(t))( files with the sticky bit (01000) ) +item(tt(f)var(spec))( +files with access rights matching var(spec). This var(spec) may be a +octal number optionally preceded by a `tt(=)', a `tt(PLUS())', or a +`tt(-)'. If none of these characters is given, the behavior is the +same as for `tt(=)'. The octal number describes the mode bits to be +expected, if combined with a `tt(=)', the value given must match the +file-modes exactly, with a `tt(PLUS())', at least the bits in the +given number must be set in the file-modes, and with a `tt(-)', the +bits in the number must not be set. Giving a `tt(?)' instead of a +octal digit anywhere in the number ensures that the corresponding bits +in the file-modes are not checked, this is only useful in combination +with `tt(=)'. + +If the qualifier `tt(f)' is followed by any other character anything +up to the next matching character (`tt([)', `tt({)', and `tt(<)' match +`tt(])', `tt(})', and `tt(>)' respectively, any other character +matches itself) is taken as a list of comma-separated +var(sub-spec)s. Each var(sub-spec) may be either a octal number as +described above or a list of any of the characters `tt(u)', `tt(g)', +`tt(o)', and `tt(a)', followed by a `tt(=)', a `tt(PLUS())', or a +`tt(-)', followed by a list of any of the characters `tt(r)', `tt(w)', +`tt(x)', `tt(s)', and `tt(t)', or a octal digit. The first list of +characters specify which access rights are to be checked. If a `tt(u)' +is given, those for the owner of the file are used, if a `tt(g)' is +given, those of the group are checked, a `tt(o)' means to test those +of other users, and the `tt(a)' says to test all three groups. The +`tt(=)', `tt(PLUS())', and `tt(-)' again says how the modes are to be +checked and have the same meaning as described for the first form +above. The second list of characters finally says which access rights +are to be expected: `tt(r)' for read access, `tt(w)' for write access, +`tt(x)' for the right to execute the file (or to search a directory), +`tt(s)' for the setuid and setgid bits, and `tt(t)' for the sticky +bit. + +Thus, `tt(*(f70?))' gives the files for which the owner has read, +write, and execute permission, and for which other group members have +no rights, independent of the permissions for other users. The pattern +`tt(*(f-100))' gives all files for which the owner does not have +execute permission, and `tt(*(f:gu+w,o-rx:))' gives the files for which +the owner and the other members of the group have at least write +permission, and for which other users don't have read or execute +permission. +) +item(tt(e)var(string))( +The var(string) will be executed and the return value determines if the +filename should be included in the list (if it is zero) or not (if it +is non-zero). The first character after the `tt(e)' will be used as a +separator and anything up to the next matching separator will be taken +as the var(string) (`tt([)', `tt({)', and `tt(<)' match `tt(])', +`tt(})', and `tt(>)' respectively, any other character matches +itself). Note that expansions have to be quoted in the var(string) to +prevent them from being expanded before globbing is done. + +During the execution of var(string) the parameter tt(REPLY) is set to +the filename currently being tested. It may also be set to any string +to make this string be inserted into the list instead of the original +filename. Also, the parameter tt(reply) may be set to an array or a +string and if it is, these strings will be inserted instead of the +value of the tt(REPLY) parameter. For security reasons, tt(reply) +will be unset by the shell before the var(string) is executed. +) item(tt(d)var(dev))( files on the device var(dev) ) @@ -954,8 +1556,8 @@ item(tt(u)var(id))( files owned by user ID var(id) if it is a number, if not, than the character after the `tt(u)' will be used as a separator and the string between it and the next matching separator -(`tt(LPAR())', `tt([)', `tt({)', and `tt(<)' -match `tt(RPAR())', `tt(])', `tt(})', and `tt(>)' respectively, +(`tt([)', `tt({)', and `tt(<)' +match `tt(])', `tt(})', and `tt(>)' respectively, any other character matches itself) will be taken as a user name, and the user ID of this user will be taken (e.g. `tt(u:foo:)' or `tt(u[foo])' for user `tt(foo)') @@ -963,21 +1565,21 @@ be taken (e.g. `tt(u:foo:)' or `tt(u[foo])' for user `tt(foo)') item(tt(g)var(id))( like tt(u)var(id) but with group IDs or names ) -item(tt(a)[tt(Mwhm)][tt(-)|tt(PLUS())]var(n))( -files accessed exactly var(n) days ago. Files accessed within the -last var(n) days are selected using a negative value for var(n) -(tt(-)var(n)). Files accessed more than var(n) days ago are selected by a -positive var(n) value (tt(PLUS())var(n)). Optional unit specifiers `tt(M)', -`tt(w)', `tt(h)' or `tt(m)' (e.g. `tt(ah5)') cause the check to be -performed with months (of 30 days), weeks, hours, or minutes instead of -days, respectively. For instance, `tt(echo *(ah-5))' would echo files -accessed within the last five hours. -) -item(tt(m)[tt(Mwhm)][tt(-)|tt(PLUS())]var(n))( +item(tt(a)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))( +files accessed exactly var(n) days ago. Files accessed within the last +var(n) days are selected using a negative value for var(n) (tt(-)var(n)). +Files accessed more than var(n) days ago are selected by a positive var(n) +value (tt(PLUS())var(n)). Optional unit specifiers `tt(M)', `tt(w)', +`tt(h)', `tt(m)' or `tt(s)' (e.g. `tt(ah5)') cause the check to be +performed with months (of 30 days), weeks, hours, minutes or seconds +instead of days, respectively. For instance, `tt(echo *(ah-5))' would +echo files accessed within the last five hours. +) +item(tt(m)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))( like the file access qualifier, except that it uses the file modification time. ) -item(tt(c)[tt(Mwhm)][tt(-)|tt(PLUS())]var(n))( +item(tt(c)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))( like the file access qualifier, except that it uses the file inode change time. ) @@ -1000,7 +1602,7 @@ sets the tt(MARK_DIRS) option for the current pattern pindex(MARK_DIRS, setting in pattern) ) item(tt(T))( -appends a trailing qualifier mark to the file names, analogous to the +appends a trailing qualifier mark to the filenames, analogous to the tt(LIST_TYPES) option, for the current pattern (overrides tt(M)) ) item(tt(N))( @@ -1011,6 +1613,34 @@ item(tt(D))( sets the tt(GLOB_DOTS) option for the current pattern pindex(GLOB_DOTS, setting in pattern) ) +item(tt(n))( +sets the tt(NUMERIC_GLOB_SORT) option for the current pattern +pindex(NUMERIC_GLOB_SORT, setting in pattern) +) +item(tt(o)var(c))( +specifies how the names of the files should be sorted. If var(c) is +tt(n) they are sorted by name (the default), if it is tt(L) they +are sorted depending on the size (length) of the files, if tt(l) +they are sorted by the number of links, and if tt(a), tt(m), and tt(c) +they are sorted by the time of the last access, modification, or +inode change respectively. Note that tt(a), tt(m), and tt(c) compare +the age against the current time, hence the first name in the list is the +the youngest file. Also note that the modifiers tt(^) and tt(-) are +used, so `tt(*(^-oL))' gives a list of all files sorted by file size in +descending order, following any symbolic links. +) +item(tt(O)var(c))( +like `tt(o)', but sorts in descending order; i.e. `tt(*(^oc))' is the +same as `tt(*(Oc))' and `tt(*(^Oc))' is the same as `tt(*(oc))' +) +item(tt([)var(beg)[tt(,)var(end)]tt(]))( +specifies which of the matched filenames should be included in the +returned list. The syntax is the same as for array +subscripts. var(beg) and the optional var(end) may be mathematical +expressions. As in parameter subscripting they may be negative to make +them count from the last match backward. E.g.: `tt(*(-OL[1,3]))' +gives a list of the names of the three largest files. +) enditem() More than one of these lists can be combined, separated by commas. The @@ -1026,26 +1656,26 @@ name of any existing file can be followed by a modifier of the form `tt((:..))' even if no actual filename generation is performed. Thus: -nofill(tt(ls *(-/))) +example(ls *(-/)) lists all directories and symbolic links that point to directories, and -nofill(tt(ls *(%W))) +example(ls *(%W)) lists all world-writable device files in the current directory, and -nofill(tt(ls *(W,X))) +example(ls *(W,X)) lists all files in the current directory that are world-writable or world-executable, and -nofill(tt(echo /tmp/foo*(u0^@:t))) +example(echo /tmp/foo*(u0^@:t)) outputs the basename of all root-owned files beginning with the string `tt(foo)' in tt(/tmp), ignoring symlinks, and -nofill(tt(ls *.*~(lex|parse).[ch](^D^l1))) +example(ls *.*~(lex|parse).[ch](^D^l1)) lists all files having a link count of one whose names contain a dot (but not those starting with a dot, since tt(GLOB_DOTS) is explicitly diff --git a/Doc/Zsh/filelist.yo b/Doc/Zsh/filelist.yo index 298eff074..f6e3d9dda 100644 --- a/Doc/Zsh/filelist.yo +++ b/Doc/Zsh/filelist.yo @@ -11,5 +11,5 @@ list(tt(/etc/zshenv)) list(tt(/etc/zprofile)) list(tt(/etc/zshrc)) list(tt(/etc/zlogin)) -list(tt(/etc/zlogout) (installation-specific - tt(/etc) is the default)) +list(tt(/etc/zlogout) (installation-specific - tt(/etc) is the default)) endlist() diff --git a/Doc/Zsh/files.yo b/Doc/Zsh/files.yo index 0d775a14f..aeb4ae885 100644 --- a/Doc/Zsh/files.yo +++ b/Doc/Zsh/files.yo @@ -6,12 +6,17 @@ cindex(startup files) cindex(files, shutdown) cindex(shutdown files) pindex(NO_RCS, use of) -Commands are first read from tt(/etc/zshenv). -If the tt(RCS) option is unset -within tt(/etc/zshenv), all other -initialization files are skipped. -Otherwise, commands are read -from tt($ZDOTDIR/.zshenv). +pindex(NO_GLOBAL_RCS, use of) +Commands are first read from tt(/etc/zshenv); this cannot be overridden. +Subsequent behaviour is modified by the tt(RCS) and +tt(GLOBAL_RCS) options; the former affects all startup files, while the +second only affects those in the tt(/etc) directory. If one of the options +is unset at any point, any subsequent startup file(s) of the corresponding +type will not be read. It is also possible for a file in tt($ZDOTDIR) to +re-enable tt(GLOBAL_RCS). Both tt(RCS) and tt(GLOBAL_RCS) are set by +default. + +Commands are then read from tt($ZDOTDIR/.zshenv). pindex(LOGIN, use of) If the shell is a login shell, commands are read from tt(/etc/zprofile) and then tt($ZDOTDIR/.zprofile). @@ -20,7 +25,35 @@ commands are read from tt(/etc/zshrc) and then tt($ZDOTDIR/.zshrc). Finally, if the shell is a login shell, tt(/etc/zlogin) and tt($ZDOTDIR/.zlogin) are read. +When a login shell exits, the files tt($ZDOTDIR/.zlogout) and then +tt(/etc/zlogout) are read. This happens with either an explicit exit +via the tt(exit) or tt(logout) commands, or an implicit exit by reading +end-of-file from the terminal. However, if the shell terminates due +to tt(exec)'ing another process, the logout files are not read. +These are also affected by the tt(RCS) and tt(GLOBAL_RCS) options. +Note also that the tt(RCS) option affects the saving of history files, +i.e. if tt(RCS) is unset when the shell exits, no history file will be +saved. + If tt(ZDOTDIR) is unset, tt(HOME) is used instead. Those files listed above as being in tt(/etc) may be in another directory, depending on the installation. + +As tt(/etc/zshenv) is run for all instances of zsh, it is important that +it be kept as small as possible. In particular, it is a good idea to +put code that does not need to be run for every single shell behind +a test of the form `tt(if [[ -o rcs ]]; then ...)' so that it will not +be executed when zsh is invoked with the `tt(-f)' option. ifnzman(includefile(Zsh/filelist.yo)) + +Any of these files may be pre-compiled with the tt(zcompile) builtin +command (\ +ifzman(\ +see zmanref(zshbuiltins)\ +)\ +ifnzman(\ +noderef(Shell Builtin Commands)\ +)\ +). If a compiled file exists (named for the original file plus the +tt(.zwc) extension) and it is newer than the original file, the compiled +file will be used instead. diff --git a/Doc/Zsh/index.yo b/Doc/Zsh/index.yo index 7afa14d07..99cf8558b 100644 --- a/Doc/Zsh/index.yo +++ b/Doc/Zsh/index.yo @@ -16,9 +16,9 @@ printindex(Options Index)(pg) texinode(Functions Index)(Editor Functions Index)(Options Index)(Top) printindex(Functions Index)(fn) -texinode(Editor Functions Index)(Keystroke Index)(Functions Index)(Top) +texinode(Editor Functions Index)(Style and Tag Index)(Functions Index)(Top) printindex(Editor Functions Index)(tp) -texinode(Keystroke Index)()(Editor Functions Index)(Top) -printindex(Keystroke Index)(ky) +texinode(Style and Tag Index)()(Editor Functions Index)(Top) +printindex(Style and Tag Index)(ky) )\ diff --git a/Doc/Zsh/manual.yo b/Doc/Zsh/manual.yo index c4691b89d..a19161038 100644 --- a/Doc/Zsh/manual.yo +++ b/Doc/Zsh/manual.yo @@ -28,10 +28,10 @@ menu(Parameters) menu(Options) menu(Shell Builtin Commands) menu(Zsh Line Editor) -menu(Programmable Completion Using compctl) +menu(Completion Using compctl) menu(Completion Widgets) -menu(Zsh Modules) menu(Completion System) +menu(Zsh Modules) menu(Zftp Function System) --- Indices --- @@ -41,7 +41,7 @@ menu(Variables Index) menu(Options Index) menu(Functions Index) menu(Editor Functions Index) -menu(Keystroke Index) +menu(Style and Tag Index) --- The Detailed Node Listing --- @@ -98,7 +98,7 @@ menu(Arguments) menu(Completion) menu(Miscellaneous) -Programmable Completion Using compctl +Completion Using compctl menu(Command Flags) menu(Option Flags) @@ -113,23 +113,18 @@ menu(Builtin Commands) menu(Condition Codes) menu(Examples) +Completion System + +menu(Initialization) +menu(Completion System Configuration) +menu(Control Functions) +menu(Bindable Commands) +menu(Completion Functions) +menu(Completion Directories) + Zsh Modules -menu(The cap Module) -menu(The clone Module) -menu(The comp1 Module) -menu(The compctl Module) -menu(The complist Module) -menu(The deltochar Module) -menu(The example Module) -menu(The files Module) -menu(The mapfile Module) -menu(The mathfunc Module) -menu(The parameter Module) -menu(The sched Module) -menu(The stat Module) -menu(The zftp Module) -menu(The zle Module) +includefile(Zsh/manmodmenu.yo) endmenu() texinode(The Z Shell Manual)(Introduction)(Top)(Top) chapter(The Z Shell Manual) diff --git a/Doc/Zsh/mod_compctl.yo b/Doc/Zsh/mod_compctl.yo index b7adf8fa6..c4a254bb0 100644 --- a/Doc/Zsh/mod_compctl.yo +++ b/Doc/Zsh/mod_compctl.yo @@ -1,7 +1,13 @@ -texinode(The compctl Module)(The deltochar Module)(The comp1 Module)(Zsh Modules) -sect(The compctl Module) -The tt(compctl) module makes available one builtin command, tt(compctl), -which is the standard way to control completions for ZLE. See +COMMENT(!MOD!zsh/compctl +The tt(compctl) builtin for controlling completion. +!MOD!) +The tt(zsh/compctl) module makes available two builtin commands. tt(compctl), +is the old, deprecated way to control completions for ZLE. See ifzman(zmanref(zshcompctl))\ -ifnzman(noderef(Programmable Completion))\ +ifnzman(noderef(Completion Using compctl))\ +. +The other builtin command, tt(compcall) can be used in user-defined +completion widgets, see +ifzman(zmanref(zshcompwid))\ +ifnzman(noderef(Completion Widgets))\ . diff --git a/Doc/Zsh/mod_zle.yo b/Doc/Zsh/mod_zle.yo index 9aa03f7f8..a677ad0b1 100644 --- a/Doc/Zsh/mod_zle.yo +++ b/Doc/Zsh/mod_zle.yo @@ -1,6 +1,7 @@ -texinode(The zle Module)()(The stat Module)(Zsh Modules) -sect(The zle Module) -The tt(zle) module contains the Zsh Line Editor. See +COMMENT(!MOD!zsh/zle +The Zsh Line Editor, including the tt(bindkey) and tt(vared) builtins. +!MOD!) +The tt(zsh/zle) module contains the Zsh Line Editor. See ifzman(zmanref(zshzle))\ ifnzman(noderef(Zsh Line Editor))\ . It also contains three related builtin commands: @@ -41,15 +42,14 @@ and does not otherwise count as an argument. ) enditem() -Some operations do not permit a keymap to be selected. If a keymap selection is required and none of the options above are used, the -`tt(main)' keymap is used. These operations do not permit a keymap to be -selected: +`tt(main)' keymap is used. Some operations do not permit a keymap to be +selected, namely: startitem() item(tt(-l))( List all existing keymap names. If the tt(-L) -option is used, list in the form of tt(bindkey) +option is also used, list in the form of tt(bindkey) commands to create the keymaps. ) item(tt(-d))( @@ -67,12 +67,24 @@ with the var(new-keymap) name, it is deleted. item(tt(-N) var(new-keymap) [ var(old-keymap) ])( Create a new keymap, named var(new-keymap). If a keymap already has that name, it is deleted. If an var(old-keymap) name is given, the new keymap -is initialised to be a duplicate of it, otherwise the new keymap will +is initialized to be a duplicate of it, otherwise the new keymap will be empty. ) enditem() -The following operations require a keymap to be selected: +To use a newly created keymamp, it should be linked to tt(main). Hence +the sequence of commands to create and use a new keymap `tt(mymap)' +initialized from the tt(emacs) keymap (which remains unchanged) is: + +example(bindkey -N mymap emacs +bindkey -A mymap main) + +Note that while `tt(bindkey -A) var(newmap) tt(main)' will work when +var(newmap) is tt(emacs) or tt(viins), it will not work for tt(vicmd), as +switching from vi insert to command mode becomes impossible. + +The following operations act on the `tt(main)' keymap if no keymap +selection option was given: startitem() item(tt(-m))( @@ -82,29 +94,34 @@ Only keys that are unbound or bound to tt(self-insert) are affected. item(tt(-r) var(in-string) ...)( Unbind the specified var(in-string)s in the selected keymap. This is exactly equivalent to binding the strings to tt(undefined-key). +When tt(-R) is also used, interpret the var(in-string)s as ranges. ) item(tt(-s) var(in-string out-string) ...)( Bind each var(in-string) to each var(out-string). When var(in-string) is typed, var(out-string) will be pushed back and treated as input to the line editor. +When tt(-R) is also used, interpret the var(in-string)s as ranges. ) item(var(in-string command) ...)( Bind each var(in-string) to each var(command). +When tt(-R) is used, interpret the var(in-string)s as ranges. ) item([ var(in-string) ])( List key bindings. If an var(in-string) is specified, the binding of that string in the selected keymap is displayed. Otherwise, all key -bindings in the selected keymap are displayed. As an exception, -if the tt(-e) or tt(-v) options are used alone, the keymap is em(not) -displayed - the implicit linking of keymaps is the only thing that happens. +bindings in the selected keymap are displayed. (As a special case, +if the tt(-e) or tt(-v) option is used alone, the keymap is em(not) +displayed - the implicit linking of keymaps is the only thing that +happens.) + +When the tt(-L) option is used, the list is in the form of tt(bindkey) +commands to create the key bindings. ) enditem() -In the binding operations, if the tt(-R) option is used, the var(in-string)s -are interpreted as ranges, instead of plain strings. A valid range -consists of two characters, with an optional `tt(-)' -between them. All characters between the two specified, inclusive, -are bound as specified. +When the tt(-R) option is used as noted above, a valid range consists of +two characters, with an optional `tt(-)' between them. All characters +between the two specified, inclusive, are bound as specified. For either var(in-string) or var(out-string), the following escape sequences are recognised: @@ -126,21 +143,34 @@ sitem(tt(^)var(X))(control character) endsitem() In all other cases, `tt(\)' escapes the following character. Delete is -written as `tt(^?)'. Note that `tt(\M^?)' and `tt(^\M?)' are not the same. +written as `tt(^?)'. Note that `tt(\M^?)' and `tt(^\M?)' are not the same, +and that (unlike emacs), the bindings `tt(\M-)var(X)' and `tt(\e)var(X)' +are entirely distinct, although they are initialized to the same bindings +by `tt(bindkey -m)'. ) findex(vared) cindex(parameters, editing) cindex(editing parameters) -item(tt(vared) [ tt(-ch) ] [ tt(-p) var(prompt) ] [ tt(-r) var(rprompt) ] var(name))( +item(tt(vared) [ tt(-Aache) ] [ tt(-p) var(prompt) ] [ tt(-r) var(rprompt) ] var(name))( The value of the parameter var(name) is loaded into the edit buffer, and the line editor is invoked. When the editor exits, var(name) is set to the string value returned by the editor. -If the tt(-c) flag is given, the parameter is created if it doesn't -already exist. +When the tt(-c) flag is given, the parameter is created if it doesn't +already exist. The tt(-a) flag may be given with tt(-c) to create +an array parameter, or the tt(-A) flag to create an associative array. +If the type of an existing parameter does not match the type to be +created, the parameter is unset and recreated. + +Individual elements of existing array or associative array parameters +may be edited by using subscript syntax on var(name). New elements are +created automatically, even without tt(-c). + If the tt(-p) flag is given, the following string will be taken as the prompt to display at the left. If the tt(-r) flag is given, the following string gives the prompt to display at the right. If the -tt(-h) flag is specified, the history can be accessed from ZLE. +tt(-h) flag is specified, the history can be accessed from ZLE. If the +tt(-e) flag is given, typing tt(^D) (Control-D) on an empty line +causes tt(vared) to exit immediatly with a non-zero return value. ) findex(zle) cindex(widgets, rebinding) @@ -153,11 +183,16 @@ cindex(widgets, calling) cindex(calling widgets) cindex(widgets, defining) cindex(defining widgets) -xitem(tt(zle) tt(-l) [ tt(-L) ]) +xitem(tt(zle) tt(-l) [ tt(-L) ] [ tt(-a) ] [ var(string) ... ]) xitem(tt(zle) tt(-D) var(widget) ...) xitem(tt(zle) tt(-A) var(old-widget) var(new-widget)) xitem(tt(zle) tt(-N) var(widget) [ var(function) ]) -item(tt(zle) var(widget))( +xitem(tt(zle) tt(-C) var(widget) var(completion-widget) var(function)) +xitem(tt(zle) tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ]) +xitem(tt(zle) tt(-M) var(string)) +xitem(tt(zle) tt(-U) var(string)) +xitem(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...) +item(tt(zle))( The tt(zle) builtin performs a number of different actions concerning ZLE. Which operation it performs depends on its options: @@ -166,7 +201,15 @@ item(tt(-l) [ tt(-L) ])( List all existing user-defined widgets. If the tt(-L) option is used, list in the form of tt(zle) commands to create the widgets. -Built-in widgets are not listed. + +When combined with the tt(-a) option, all widget names are listed, +including the builtin ones. In this case the tt(-L) option is ignored. + +If at least one var(string) is given, nothing will be printed but the +return status will be zero if all var(string)s are names of existing +widgets (or of user-defined widgets if the tt(-a) flag is not given) +and non-zero if at least one var(string) is not a name of an defined +widget. ) item(tt(-D) var(widget) ...)( Delete the named var(widget)s. @@ -182,12 +225,86 @@ Create a user-defined widget. If there is already a widget with the specified name, it is overwritten. When the new widget is invoked from within the editor, the specified shell var(function) is called. If no function name is specified, it defaults to -the same name as the widget. +the same name as the widget. For further information, see the section +em(Widgets) in +ifzman(zmanref(zshzle))\ +ifnzman(noderef(Zsh Line Editor))\ +. +) +citem(completion widgets, creating) +item(tt(-C) var(widget) var(completion-widget) var(function))( +Create a user-defined completion widget named var(widget). The +completion widget will behave like the built-in completion-widget +whose name is given as var(completion-widget). To generate the +completions, the shell function var(function) will be called. +For further information, see +ifzman(zmanref(zshcompwid))\ +ifnzman(noderef(Completion Widgets))\ +. ) -item(var(widget))( +item(tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ])( +Redisplay the command line; this is to be called from within a user-defined +widget to allow changes to become visible. If a var(display-string) is +given and not empty, this is shown in the status line (immediately +below the line being edited). + +If the optional var(string)s are given they are listed below the +prompt in the same way as completion lists are printed. If no +var(string)s are given but the tt(-c) option is used such a list is +cleared. + +Note that this option is only useful for widgets that do not exit +immediatly after using it because the strings displayed will be erased +immediatly after return from the widget. +) +item(tt(-M) var(string))( +As with the tt(-R) option, the var(string) will be displayed below the +command line. But unlike the tt(-R) option the string not be put into +the status line but will instead be printed normally below the +prompt. This means that the var(string) will still be displayed after +the widget returns (until it is overwritten by subsequent commands). +) +item(tt(-U) var(string))( +This pushes the characters in the var(string) onto the input stack of +ZLE. After the widget currently executed finishes ZLE will behave as +if the characters in the var(string) were typed by the user. + +Note that since ZLE uses a stack, using tt(zle) with this option more +than once will make the last string pushed be used first. The +characters in each var(string) will be used in the order in which they +appear in the string, though. +) +item(var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)( Invoke the specified widget. This can only be done when ZLE is active; normally this will be within a user-defined widget. + +With the options tt(-n) and tt(-N), the current numerical argument will be +saved and then restored after the call to tt(widget); `tt(-n) var(num)' +sets the numerical argument temporarily to var(num), while `tt(-N)' sets it +to the default, i.e. as if there were none. + +Any further arguments will be passed to the widget. If it is a shell +function, these are passed down as positional parameters; for builtin +widgets it is up to the widget in question what it does with them. +Currently arguments are only handled by the incremental-search commands, +the tt(history-search-forward) and tt(-backward) and the corresponding +functions prefixed by tt(vi-), and by tt(universal-argument). No error is +flagged if the command does not use the arguments, or only uses some of +them. + +The return status reflects the success or failure of the operation carried +out by the widget, or if it is a user-defined widget the return status of +the shell function. + +A non-zero return status causes the shell to beep when the widget exits, +unless the tt(BEEP) options was unset or the widget was called via the +tt(zle) command. Thus if a user defined widget requires an immediate beep, +it should call the tt(beep) widget directly. ) enditem() + +With no options and no arguments, only the returns status will be +set. It is zero if ZLE is currently active and widgets could be +invoked using this builtin command and non-zero if ZLE is not active. ) enditem() diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index 477f955eb..891ebef11 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -1,9 +1,12 @@ -texinode(The zutil Module)(The complete Module)(The clone Module)(Zsh Modules) -sect(The zutil Module) +COMMENT(!MOD!zsh/zutil +Some utility builtins, e.g. the one for supporting configuration via +styles. +!MOD!) cindex(builtins, utility) -The tt(zutil) module only adds some builtins: +The tt(zsh/zutil) module only adds some builtins: startitem() +findex(zstyle) xitem(tt(zstyle) [ tt(-L) ]) xitem(tt(zstyle) [ tt(-) | tt(-)tt(-) ] var(pattern) var(style) var(strings) ...) xitem(tt(zstyle -d) [ var(pattern) [ var(styles) ... ] ]) @@ -13,6 +16,7 @@ xitem(tt(zstyle -b) var(context) var(style) var(name)) xitem(tt(zstyle -a) var(context) var(style) var(name)) xitem(tt(zstyle -h) var(context) var(style) var(name)) xitem(tt(zstyle -t) var(context) var(style) [ var(strings) ...]) +xitem(tt(zstyle -T) var(context) var(style) [ var(strings) ...]) item(tt(zstyle -m) var(context) var(style) var(pattern))( This builtin command is used to define and lookup styles. Styles are pairs of names and values, where the values consist of any number of @@ -61,17 +65,22 @@ makes it be returned as an associative array (with the first, third, etc. string being used as the keys and the other strings being used as the values). -The tt(-t) option can be used to test the value of a style, i.e. it +The tt(-t) options can be used to test the value of a style, i.e. it only sets the return value. Without any var(strings) arguments it is zero if the style is defined for at least one matching pattern, has only one string in its value and that is equal to one of tt(true), tt(yes), tt(on) or tt(1). If any var(strings) are given the return zero if and only if at least one of the var(strings) is equal to at -least one of the strings in the value. +least one of the strings in the value. If the style is not defined, +the return value is tt(2). + +The tt(-T) option is like tt(-t) but returns zero if the style is not +set for any matching pattern. The tt(-m) option can be used to match a value. It returns zero if the var(pattern) matches at least one of the strings in the value. ) +findex(zformat) xitem(tt(zformat -f) var(param) var(format) var(specs) ...) item(tt(zformat -a) var(array) var(sep) var(specs) ...)( This builtin provides to different forms of formatting. The first form @@ -106,4 +115,52 @@ trailing colon removed. In both cases the lengths of the strings are not used to determine how the other strings have to be aligned. The resulting strings are stored in the var(array). ) +findex(zregexparse) +item(tt(zregexparse))( +This implements the internals of the `tt(_regex_arguments)'. +) +findex(zparseopts) +item(tt(zparseopts) [ tt(-D) ] [ tt(-a) var(array) ] [ tt(-A) var(assoc) ] var(specs))( +This builtin simplifies the parsing of options in the positional +parameters. Each var(spec) describes one option and should be of the +form `var(name)[tt(+)][tt(:)[tt(:)][tt(-)]][tt(=)var(array)]'. The var(name) +is the name of the option (without the leading `tt(-)'). If only that +is given, the option takes no argument and if it is found in the +positional parameters it will be placed in the var(array) given with +the tt(-a) option. If the optional `tt(=)var(array)' is given, it will +be put into that array instead. If one or two colons are given, the +option takes an argument. With one colon, this argument is mandatory +and with two colons it is optional. The argument will be inserted into +the var(array), too. For mandatory arguments it is added as a separate +string and for optional arguments it is put into one string together +with the option name unless the `tt(-)' option is given. In this case +the argument will be put into the same word even for mandatory +arguments (note that this makes empty strings as arguments +indistinguishable). Finally, if the `tt(+)' is given and the option +appears more than once in the positional parameters, it will be +inserted more than once in the var(array), too. Without the `tt(+)' +the option will be inserted only once in the var(array) with arguments +of later options overwriting earlier once. If any of the special +character needs to appear in the option name it must be preceded by a +backslash. + +If the tt(-A) option is given, the options and their values will also +be put into an associative array with the option names as keys and the +arguments (if any) as the values. Note that it is an error to give +var(specs) without a `tt(=)var(array)' and not use either the tt(-a) +or tt(-A) option. + +If the tt(-D) option is given, all options found are removed from the +positional parameters leaving only the strings from the first one that +was not described by any of the var(specs) to the last (note that this +is the usual rule used by tt(zparseopts) to find out when to stop +processing options). + +For example, calling `tt(zparseopts a=foo b:=bar c+:=bar)' with the +strings `tt(-a)', `tt(-bx)', `tt(-c)', `tt(y)', `tt(-cz)', `tt(baz)' +and `tt(-cend)' as positional arguments will set the array tt(foo) to +contain the element `tt(-a)' and the array tt(bar) to the strings +`tt(-b)', `tt(x)', `tt(-c)', `tt(y)', `tt(-c)', and `tt(z)'. The +`tt(baz)' and all strings after it will not be used. +) enditem() diff --git a/Doc/Zsh/modules.yo b/Doc/Zsh/modules.yo index b44b00e6b..e74a94aed 100644 --- a/Doc/Zsh/modules.yo +++ b/Doc/Zsh/modules.yo @@ -1,4 +1,4 @@ -texinode(Zsh Modules)()(Programmable Completion)(Top) +texinode(Zsh Modules)(Zftp Function System)(Completion System)(Top) chapter(Zsh Modules) cindex(modules) sect(Description) @@ -6,59 +6,7 @@ Some optional parts of zsh are in modules, separate from the core of the shell. Each of these modules may be linked in to the shell at build time, or can be dynamically linked while the shell is running -if the installation supports this feature. The modules available are: +if the installation supports this feature. The modules that +are bundled with the zsh distribution are: -startitem() -item(tt(cap))( -Builtins for manipulating POSIX.1e (POSIX.6) capability (privilege) sets. -) -item(tt(clone))( -A builtin that can clone a running shell onto another terminal. -) -item(tt(comp1))( -Base of the completion system. Used by the tt(compctl) and tt(zle) modules. -) -item(tt(compctl))( -The tt(compctl) builtin for controlling completion. -) -item(tt(deltochar))( -A ZLE function duplicating EMACS' tt(zap-to-char). -) -item(tt(example))( -An example of how to write a module. -) -item(tt(files))( -Some basic file manipulation commands as builtins. -) -item(tt(sched))( -A builtin that provides a timed execution facility within the shell. -) -item(tt(stat))( -A builtin command interface to the tt(stat) system call. -) -item(tt(zle))( -The Zsh Line Editor, including the tt(bindkey) and tt(vared) builtins. -) -enditem() -startmenu() -menu(The cap Module) -menu(The clone Module) -menu(The comp1 Module) -menu(The compctl Module) -menu(The deltochar Module) -menu(The example Module) -menu(The files Module) -menu(The sched Module) -menu(The stat Module) -menu(The zle Module) -endmenu() -includefile(Zsh/mod_cap.yo) -includefile(Zsh/mod_clone.yo) -includefile(Zsh/mod_comp1.yo) -includefile(Zsh/mod_compctl.yo) -includefile(Zsh/mod_deltochar.yo) -includefile(Zsh/mod_example.yo) -includefile(Zsh/mod_files.yo) -includefile(Zsh/mod_sched.yo) -includefile(Zsh/mod_stat.yo) -includefile(Zsh/mod_zle.yo) +includefile(Zsh/modlist.yo) diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 4c25a18ef..c6571f38f 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -7,7 +7,8 @@ A name may be any sequence of alphanumeric characters and underscores, or the single characters `tt(*)', `tt(@)', `tt(#)', `tt(?)', `tt(-)', `tt($)', or `tt(!)'. The value may be a em(scalar) (a string), -an integer, or an array. +an integer, an array (indexed numerically), or an em(associative) +array (an unordered set of name-value pairs, indexed by name). To assign a scalar or integer value to a parameter, use the tt(typeset) builtin. findex(typeset, use of) @@ -15,45 +16,41 @@ To assign an array value, use `tt(set -A) var(name) var(value) ...'. findex(set, use of) The value of a parameter may also be assigned by writing: -nofill(var(name)tt(=)var(value)) +indent(var(name)tt(=)var(value)) -If the integer attribute, tt(-i), is set for var(name), -the var(value) is subject to arithmetic evaluation. +If the integer attribute, tt(-i), is set for var(name), the var(value) +is subject to arithmetic evaluation. See noderef(Array Parameters) +for additional forms of assignment. -In the parameter lists, the mark `<S>' indicates that the parameter is special. +In the parameter lists that follow, the mark `<S>' indicates that the +parameter is special. Special parameters cannot have their type changed, and they stay special even if unset. `<Z>' indicates that the parameter does not exist when the shell -initialises in tt(sh) or tt(ksh) emulation mode. +initializes in tt(sh) or tt(ksh) emulation mode. startmenu() -menu(Local Parameters) menu(Array Parameters) menu(Positional Parameters) +menu(Local Parameters) menu(Parameters Set By The Shell) menu(Parameters Used By The Shell) endmenu() -texinode(Local Parameters)(Array Parameters)()(Parameters) -sect(Local Parameters) -Shell function executions delimit scopes for shell parameters. -(Parameters are dynamically scoped.) The tt(typeset) builtin, and its -alternative forms tt(declare), tt(integer), tt(local) and tt(readonly) -(but not tt(export)), can be used to declare a parameter as being local -to the innermost scope. - -When a parameter is read or assigned to, the -innermost existing parameter of that name is used. (That is, the -local parameter hides any less-local parameter.) However, assigning -to a non-existent parameter, or declaring a new parameter with tt(export), -causes it to be created in the em(outer)most scope. - -Local parameters disappear when their scope ends. -tt(unset) can be used to delete a parameter while it is still in scope; this -will reveal the next outer parameter of the same name. However, em(special) -parameters are still special when unset. -texinode(Array Parameters)(Positional Parameters)(Local Parameters)(Parameters) +texinode(Array Parameters)(Positional Parameters)()(Parameters) sect(Array Parameters) The value of an array parameter may be assigned by writing: -nofill(var(name)tt(=LPAR())var(value) ...tt(RPAR())) +indent(var(name)tt(=LPAR())var(value) ...tt(RPAR())) + +If no parameter var(name) exists, an ordinary array parameter is created. +Associative arrays must be declared first, by `tt(typeset -A) var(name)'. +When var(name) refers to an associative array, the parenthesized list is +interpreted as alternating keys and values: + +indent(var(name)tt(=LPAR())var(key) var(value) ...tt(RPAR())) + +Every var(key) must have a var(value) in this case. To create an empty +array or associative array, use: + +indent(var(name)tt(=LPAR()RPAR())) Individual elements of an array may be selected using a subscript. A subscript of the form `tt([)var(exp)tt(])' @@ -62,8 +59,12 @@ an arithmetic expression which will be subject to arithmetic expansion as if it were surrounded by `tt($LPAR()LPAR())...tt(RPAR()RPAR())'. The elements are numbered beginning with 1 unless the tt(KSH_ARRAYS) option is set when they are numbered from zero. +cindex(subscripts) pindex(KSH_ARRAYS, use of) +The same subscripting syntax is used for associative arrays, +except that no arithmetic expansion is applied to var(exp). + A subscript of the form `tt([*])' or `tt([@])' evaluates to all elements of an array; there is no difference between the two except when they appear within double quotes. @@ -72,8 +73,8 @@ except when they appear within double quotes. A subscript of the form `tt([)var(exp1)tt(,)var(exp2)tt(])' selects all elements in the range var(exp1) to var(exp2), -inclusive. -If one of the subscripts evaluates to a negative number, +inclusive. (Associative arrays are unordered, and so do not support +ranges.) If one of the subscripts evaluates to a negative number, say tt(-)var(n), then the var(n)th element from the end of the array is used. Thus `tt($foo[-3])' is the third element from the end of the array tt(foo), and @@ -90,22 +91,29 @@ option is set, the braced form is the only one that will work, the subscript otherwise not being treated specially. If a subscript is used on the left side of an assignment the selected -range is replaced by the expression on the right side. +element or range is replaced by the expression on the right side. An +array (but not an associative array) may be created by assignment to a +range or element. Arrays do not nest, so assigning a parenthesized list +of values to an element or range changes the number of elements in the +array, shifting the other elements to accommodate the new values. (This +is not supported for associative arrays.) + +To delete an element of an ordinary array, assign `tt(LPAR()RPAR())' to +that element. +To delete an element of an associative array, use the tt(unset) command. If the opening bracket or the comma is directly followed by an opening parentheses the string up to the matching closing one is considered to be a list of flags. The flags currently understood are: startitem() -item(tt(e))( -this option has no effect and retained for backward compatibility only. -) item(tt(w))( -if the parameter subscripted is a scalar than this flag makes -subscription work on a per-word basis instead of characters. +If the parameter subscripted is a scalar than this flag makes +subscripting work on words instead of characters. The default word +separator is whitespace. ) item(tt(s:)var(string)tt(:))( -this gives the var(string) that separates words (for use with the +This gives the var(string) that separates words (for use with the tt(w) flag). ) item(tt(p))( @@ -113,44 +121,117 @@ Recognize the same escape sequences as the tt(print) builtin in the string argument of a subsequent `tt(s)' flag. ) item(tt(f))( -if the parameter subscripted is a scalar than this flag makes -subscription work on a per-line basis instead of characters. -This is a shorthand for `tt(pws:\n:)'. +If the parameter subscripted is a scalar than this flag makes +subscripting work on lines instead of characters, i.e. with elements +separated by newlines. This is a shorthand for `tt(pws:\n:)'. ) item(tt(r))( -if this flag is given the var(exp) is taken as a pattern and the -result is the first matching array element, substring or word (if the -parameter is an array, if it is a scalar, or if it is a scalar and the -`tt(w)' flag is given, respectively); note that this is like giving a -number: `tt($foo[(r))var(??)tt(,3])' and `tt($foo[(r))var(??)tt(,(r)f*])' work. +Reverse subscripting: if this flag is given, the var(exp) is taken as a +pattern and the result is the first matching array element, substring or +word (if the parameter is an array, if it is a scalar, or if it is a scalar +and the `tt(w)' flag is given, respectively). The subscript used is the +number of the matching element, so that pairs of subscripts such as +`tt($foo[(r))var(??)tt(,3])' and `tt($foo[(r))var(??)tt(,(r)f*])' +are possible. If the parameter is an associative array, only the value part +of each pair is compared to the pattern. ) item(tt(R))( -like `tt(r)', but gives the last match. +Like `tt(r)', but gives the last match. For associative arrays, gives +all possible matches. +) +item(tt(k))( +If used in a subscript on a parameter that is not an associative +array, this behaves like `tt(r)', but if used on an association, it +makes the keys be interpreted as patterns and returns the first value +whose key matches the var(exp). +) +item(tt(K))( +On an associtation this is like `tt(k)' but returns all values whose +keys match the var(exp). On other types of parameters this has the +same effect as `tt(R)'. ) item(tt(i))( like `tt(r)', but gives the index of the match instead; this may not -be combined with a second argument. +be combined with a second argument. For associative arrays, the key +part of each pair is compared to the pattern, and the first matching +key found is used. ) item(tt(I))( -like `tt(i), but gives the index of the last match. +like `tt(i)', but gives the index of the last match, or all possible +matching keys in an associative array. ) item(tt(n:)var(expr)tt(:))( if combined with `tt(r)', `tt(R)', `tt(i)' or `tt(I)', makes them give the var(n)th or var(n)th last match (if var(expr) evaluates to -var(n)). +var(n)). This flag is ignored when the array is associative. +) +item(tt(b:)var(expr)tt(:))( +if combined with `tt(r)', `tt(R)', `tt(i)' or `tt(I)', makes them begin +at the var(n)th or var(n)th last element, word, or character (if var(expr) +evaluates to var(n)). This flag is ignored when the array is associative. +) +item(tt(e))( +This option has no effect and retained for backward compatibility only. ) enditem() -texinode(Positional Parameters)(Parameters Set By The Shell)(Array Parameters)(Parameters) +texinode(Positional Parameters)(Local Parameters)(Array Parameters)(Parameters) sect(Positional Parameters) -Positional parameters are set by the shell on invocation, -by the tt(set) builtin, or by direct assignment. +The positional parameters provide access to the command-line arguments +of a shell function, shell script, or the shell itself; see +noderef(Invocation), and also noderef(Functions). The parameter var(n), where var(n) is a number, is the var(n)th positional parameter. The parameters tt(*), tt(@) and tt(argv) are arrays containing all the positional parameters; thus `tt($argv[)var(n)tt(])', etc., is equivalent to simply `tt($)var(n)'. -texinode(Parameters Set By The Shell)(Parameters Used By The Shell)(Positional Parameters)(Parameters) +Positional parameters may be changed after the shell or function starts by +using the tt(set) builtin, by assigning to the tt(argv) array, or by direct +assignment of the form `var(n)tt(=)var(value)' where var(n) is the number of +the positional parameter to be changed. This also creates (with empty +values) any of the positions from 1 to var(n) that do not already have +values. Note that, because the positional parameters form an array, an +array assignment of the form `var(n)tt(=LPAR())var(value) ...tt(RPAR())' is +allowed, and has the effect of shifting all the values at positions greater +than var(n) by as many positions as necessary to accommodate the new values. + +texinode(Local Parameters)(Parameters Set By The Shell)(Positional Parameters)(Parameters) +sect(Local Parameters) +Shell function executions delimit scopes for shell parameters. +(Parameters are dynamically scoped.) The tt(typeset) builtin, and its +alternative forms tt(declare), tt(integer), tt(local) and tt(readonly) +(but not tt(export)), can be used to declare a parameter as being local +to the innermost scope. + +When a parameter is read or assigned to, the +innermost existing parameter of that name is used. (That is, the +local parameter hides any less-local parameter.) However, assigning +to a non-existent parameter, or declaring a new parameter with tt(export), +causes it to be created in the em(outer)most scope. + +Local parameters disappear when their scope ends. +tt(unset) can be used to delete a parameter while it is still in scope; +any outer parameter of the same name remains hidden. + +Special parameters may also be made local; they retain their special +attributes unless either the existing or the newly-created parameter +has the tt(-h) (hide) attribute. This may have unexpected effects. +Firstly, there is no default value, so if there is no assigment at the +point the variable is made local, it will be set to an empty value (or zero +in the case of integers). Secondly, special parameters which are made +local will not be exported (as with other parameters), so that the global +value of the parameter remains present in the environment if it is already +there. This should be particularly noted in the case of tt(PATH): the +shell will use the local version of tt(PATH) for finding programmes, but +programmes using the shell's environment will inherit the global version. +The following: + +example(typeset PATH=/new/directory:$PATH) + +is valid for temporarily allowing the shell to find the programs in +tt(/new/directory) inside a function. + +texinode(Parameters Set By The Shell)(Parameters Used By The Shell)(Local Parameters)(Parameters) sect(Parameters Set By The Shell) The following parameters are automatically set by the shell: @@ -182,11 +263,15 @@ An array containing the positional parameters. ) vindex(argv) item(tt(argv) <S> <Z>)( -Same as tt(*). +Same as tt(*). Assigning to tt(argv) changes the local positional +parameters, but tt(argv) is em(not) itself a local parameter. +Deleting tt(argv) with tt(unset) in any function deletes it everywhere, +although only the innermost positional parameter array is deleted (so +tt(*) and tt(@) in other scopes are not affected). ) vindex(@) item(tt(@) <S>)( -Same as tt(argv[@]). +Same as tt(argv[@]), even when tt(argv) is not set. ) vindex(?) item(tt(?) <S>)( @@ -202,12 +287,22 @@ vindex(status) item(tt(status) <S> <Z>)( Same as tt(?). ) +vindex(pipestatus) +item(tt(pipestatus) <S> <Z>)( +An array containing the exit values returned by all commands in the +last pipeline. +) vindex(_) item(tt(_) <S>)( The last argument of the previous command. Also, this parameter is set in the environment of every command executed to the full pathname of the command. ) +vindex(CPUTYPE) +item(tt(CPUTYPE))( +The machine type (microprocessor class or machine model), +as determined at run time. +) vindex(EGID) item(tt(EGID) <S>)( The effective group ID of the shell process. If you have sufficient @@ -245,8 +340,11 @@ The current hostname. ) vindex(LINENO) item(tt(LINENO) <S>)( -The line number of the current line within the current script -being executed. +The line number of the current line within the current script, sourced +file, or shell function being executed, whichever was started most +recently. Note that in the case of shell functions the line +number refers to the function as it appeared in the original definition, +not necesarily as displayed by the tt(functions) builtin. ) vindex(LOGNAME) item(tt(LOGNAME))( @@ -262,7 +360,7 @@ as determined at compile time. ) vindex(OLDPWD) item(tt(OLDPWD))( -The previous working directory. This is set when the shell initialises +The previous working directory. This is set when the shell initializes and whenever the directory changes. ) vindex(OPTARG) @@ -285,7 +383,7 @@ The process ID of the parent of the shell. ) vindex(PWD) item(tt(PWD))( -The present working directory. This is set when the shell initialises +The present working directory. This is set when the shell initializes and whenever the directory changes. ) vindex(RANDOM) @@ -356,7 +454,7 @@ The following parameters are used by the shell: startitem() vindex(ARGV0) item(tt(ARGV0))( -If exported, its value is used as tt(argv[0]) of external commands. +If exported, its value is used as the tt(argv[0]) of external commands. Usually used in constructs like `tt(ARGV0=emacs nethack)'. ) vindex(BAUD) @@ -417,7 +515,7 @@ vindex(histchars) item(tt(histchars) <S>)( Three characters used by the shell's history and lexical analysis mechanism. The first character signals the start of a history -substitution (default `tt(!)'). The second character signals the +expansion (default `tt(!)'). The second character signals the start of a quick history substitution (default `tt(^)'). The third character is the comment character (default `tt(#)'). ) @@ -432,7 +530,10 @@ If unset, the history is not saved. ) vindex(HISTSIZE) item(tt(HISTSIZE) <S>)( -The maximum size of the history list. +The maximum number of events stored in the internal history list. +If you use the tt(HIST_EXPIRE_DUPS_FIRST) option, setting this value +larger than the tt(SAVEHIST) size will give you the difference as a +cushion for saving duplicated history events. ) vindex(HOME) item(tt(HOME) <S>)( @@ -442,7 +543,7 @@ vindex(IFS) item(tt(IFS) <S>)( Internal field separators (by default space, tab, newline and NUL), that are used to separate words which result from -command or parameter substitution and words read by +command or parameter expansion and words read by the tt(read) builtin. Any characters from the set space, tab and newline that appear in the IFS are called em(IFS white space). One or more IFS white space characters or one non-IFS white space @@ -481,6 +582,13 @@ item(tt(LC_MESSAGES) <S>)( This variable determines the language in which messages should be written. Note that zsh does not use message catalogs. ) +vindex(LC_NUMERIC) +item(tt(LC_NUMERIC) <S>)( +This variable affects the decimal point character and thousands +separator character for the formatted input/output functions +and string conversion functions. Note that zsh ignores this +setting when parsing floating point mathematical expressions. +) vindex(LC_TIME) item(tt(LC_TIME) <S>)( This variable determines the locale category for date and time @@ -493,7 +601,9 @@ Used for printing select lists and for the line editor. ) vindex(LISTMAX) item(tt(LISTMAX))( -In the line editor, the number of filenames to list without asking first. +In the line editor, the number of matches to list without asking +first. If the value is negative, the list will be shown if it spans at +most as many lines as given by the absolute value. If set to zero, the shell asks only if the top of the listing would scroll off the screen. ) @@ -518,7 +628,7 @@ An array (colon-separated list) of filenames to check for new mail. Each filename can be followed by a `tt(?)' and a message that will be printed. The message will undergo parameter expansion, command substitution and arithmetic -substitution with the variable tt($_) defined as the name +expansion with the variable tt($_) defined as the name of the file that has changed. The default message is `tt(You have new mail)'. If an element is a directory instead of a file the shell will recursively check every @@ -538,7 +648,7 @@ item(tt(module_path) <S> <Z> (tt(MODULE_PATH) <S>))( An array (colon-separated list) of directories that tt(zmodload) searches for dynamically loadable modules. -This is initialised to a standard pathname, +This is initialized to a standard pathname, usually `tt(/usr/local/lib/zsh/$ZSH_VERSION)'. (The `tt(/usr/local/lib)' part varies from installation to installation.) For security reasons, any value set in the environment when the shell @@ -593,7 +703,9 @@ The default is `tt(?# )'. ) vindex(PS4) item(tt(PS4) <S>)( -The execution trace prompt. Default is `tt(PLUS() )'. +The execution trace prompt. Default is `tt(PLUS()%N:%i> )', which displays +the name of the current shell structure and the line number within it. +In sh or ksh emulation, the default is `tt(PLUS() )'. ) vindex(PROMPT) xitem(tt(PROMPT) <S> <Z>) @@ -656,12 +768,12 @@ set up the terminal before executing the command. The modes apply only to the command, and are reset when it finishes or is suspended. If the command is suspended and continued later with the tt(fg) or tt(wait) builtins it will see the modes specified by tt(STTY), as if it were not suspended. This -(intentionally) does not apply if the command is continued via `tt(kill -CONT)'. -tt(STTY) is ignored if the command is run in the background, or if it is in the -environment of the shell but not explicitly assigned to in the input line. This -avoids running stty at every external command by accidentally exporting it. -Also note that tt(STTY) should not be used for window size specifications; these -will not be local to the command. +(intentionally) does not apply if the command is continued via `tt(kill +-CONT)'. tt(STTY) is ignored if the command is run in the background, or +if it is in the environment of the shell but not explicitly assigned to in +the input line. This avoids running stty at every external command by +accidentally exporting it. Also note that tt(STTY) should not be used for +window size specifications; these will not be local to the command. ) vindex(TERM) item(tt(TERM) <S>)( @@ -804,6 +916,19 @@ item(tt(WORDCHARS) <S>)( A list of non-alphanumeric characters considered part of a word by the line editor. ) +vindex(ZBEEP) +item(tt(ZBEEP))( +If set, this gives a string of characters, which can use all the same codes +as the tt(bindkey) command as described in +ifzman(the zsh/zle module entry in zmanref(zshmodules))\ +ifnzman(noderef(The zsh/zle Module))\ +, that will be output to the terminal +instead of beeping. This may have a visible instead of an audible effect; +for example, the string `tt(\e[?5h\e[?5l)' on a vt100 or xterm will have +the effect of flashing reverse video on and off (if you usually use reverse +video, you should use the string `tt(\e[?5l\e[?5h)' instead). This takes +precedence over the tt(NOBEEP) option. +) vindex(ZDOTDIR) item(tt(ZDOTDIR))( The directory to search for shell startup files (.zshrc, etc), diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo index 8955e67ac..70085a5d2 100644 --- a/Doc/Zsh/redirect.yo +++ b/Doc/Zsh/redirect.yo @@ -16,7 +16,7 @@ input/output specifications. The following may appear anywhere in a simple command or may precede or follow a complex command. -Substitution occurs before var(word) or var(digit) +Expansion occurs before var(word) or var(digit) is used except as noted below. If the result of substitution on var(word) produces more than one filename, @@ -57,7 +57,7 @@ exist, even if tt(CLOBBER) is unset. item(tt(<<)[tt(-)] var(word))( The shell input is read up to a line that is the same as var(word), or to an end-of-file. -No parameter substitution, command substitution or +No parameter expansion, command substitution or filename generation is performed on var(word). The resulting document, called a em(here-document), becomes the standard input. @@ -77,10 +77,10 @@ item(tt(<<<) var(word))( Perform shell expansion on var(word) and pass the result to standard input. This is known as a em(here-string). ) -xitem(tt(<&) var(digit)) -item(tt(>&) var(digit))( +xitem(tt(<&) var(number)) +item(tt(>&) var(number))( The standard input/output is duplicated from file descriptor -var(digit) (see manref(dup)(2)). +var(number) (see manref(dup2)(2)). ) xitem(tt(<& -)) item(tt(>& -))( @@ -90,11 +90,33 @@ xitem(tt(<& p)) item(tt(>& p))( The input/output from/to the coprocess is moved to the standard input/output. ) -item(tt(>&) var(word))( -Same as `tt(>) var(word) tt(2>&1)'. +xitem(tt(>&) var(word)) +item(tt(&>) var(word))( +(Except where `tt(>&) var(word)' matches one of the above syntaxes; +`tt(&>)' can always be used to avoid this ambiguity.) +Redirects both standard output and standard error (file descriptor 2) +in the manner of `tt(>) var(word)'. +Note that this does em(not) have the same effect as `tt(>) var(word) tt(2>&1)' +in the presence of multios (see the section below). ) -item(tt(>>&) var(word))( -Same as `tt(>>) var(word) tt(2>&1)'. +xitem(tt(>&|) var(word)) +xitem(tt(>&!) var(word)) +xitem(tt(&>|) var(word)) +item(tt(&>!) var(word))( +Redirects both standard output and standard error (file descriptor 2) +in the manner of `tt(>|) var(word)'. +) +xitem(tt(>>&) var(word)) +item(tt(&>>) var(word))( +Redirects both standard output and standard error (file descriptor 2) +in the manner of `tt(>>) var(word)'. +) +xitem(tt(>>&|) var(word)) +xitem(tt(>>&!) var(word)) +xitem(tt(&>>|) var(word)) +item(tt(&>>!) var(word))( +Redirects both standard output and standard error (file descriptor 2) +in the manner of `tt(>>|) var(word)'. ) enditem() @@ -107,7 +129,7 @@ The shell evaluates each redirection in terms of the association at the time of evaluation. For example: -nofill(... tt(1>)var(fname) tt(2>&1)) +indent(... tt(1>)var(fname) tt(2>&1)) first associates file descriptor 1 with file var(fname). It then associates file descriptor 2 with the file associated with file @@ -123,12 +145,12 @@ the shell opens the file descriptor as a pipe to a process that copies its input to all the specified outputs, similar to bf(tee), provided the tt(MULTIOS) option is set. Thus: -nofill(tt(date >foo >bar)) +example(date >foo >bar) writes the date to two files, named `tt(foo)' and `tt(bar)'. Note that a pipe is an implicit redirection; thus -nofill(tt(date >foo | cat)) +example(date >foo | cat) writes the date to the file `tt(foo)', and also pipes it to cat. @@ -136,14 +158,14 @@ If the tt(MULTIOS) option is set, the word after a redirection operator is also subjected to filename generation (globbing). Thus -nofill(tt(: > *)) +example(: > *) will truncate all files in the current directory, assuming there's at least one. (Without the tt(MULTIOS) option, it would create an empty file called `tt(*)'.) Similarly, you can do -nofill(tt(echo exit 0 >> *.sh)) +example(echo exit 0 >> *.sh) If the user tries to open a file descriptor for reading more than once, the shell opens the file descriptor as a pipe to a process that copies @@ -151,17 +173,17 @@ all the specified inputs to its output in the order specified, similar to bf(cat), provided the tt(MULTIOS) option is set. Thus -nofill(tt(sort <foo <fubar)) +example(sort <foo <fubar) or even -nofill(tt(sort <f{oo,ubar})) +example(sort <f{oo,ubar}) is equivalent to `tt(cat foo fubar | sort)'. Note that a pipe is an implicit redirection; thus -nofill(tt(cat bar | sort <foo)) +example(cat bar | sort <foo) is equivalent to `tt(cat bar foo | sort)' (note the order of the inputs). @@ -169,15 +191,35 @@ If the tt(MULTIOS) option is em(un)set, each redirection replaces the previous redirection for that file descriptor. However, all files redirected to are actually opened, so -nofill(tt(echo foo > bar > baz)) +example(echo foo > bar > baz) when tt(MULTIOS) is unset will truncate bar, and write `tt(foo)' into baz. -If a simple command consists of one or more redirection operators -and zero or more parameter assignments, but no command name, -the command named in the shell variable tt(READNULLCMD) is assumed. -(If tt(READNULLCMD) is empty or not set, `tt(cat)' is used.) Thus +sect(Redirections with no command) +vindex(NULLCMD, use of) +vindex(READNULLCMD, use of) +pindex(CSH_NULLCMD, use of) +pindex(SH_NULLCMD, use of) +When a simple command consists of one or more redirection operators +and zero or more parameter assignments, but no command name, zsh can +behave in several ways. + +If the parameter tt(NULLCMD) is not set or the option tt(CSH_NULLCMD) is +set, an error is caused. This is the bf(csh) behavior and tt(CSH_NULLCMD) +is set by default when emulating bf(csh). + +If the option tt(SH_NULLCMD) is set, the builtin `tt(:)' is inserted as a +command with the given redirections. This is the default when emulating +bf(sh) or bf(ksh). + +Otherwise, if the parameter tt(NULLCMD) is set, its value will be used as a +command with the given redirections. If both tt(NULLCMD) and +tt(READNULLCMD) are set, then the value of the latter will be used instead +of that of the former when the redirection is an input. The default for +tt(NULLCMD) is `tt(cat)' and for tt(READNULLCMD) is `tt(more)'. Thus + +example(< file) -nofill(tt(< file)) +shows the contents of tt(file) on standard output, with paging if that is a +terminal. tt(NULLCMD) and tt(READNULLCMD) may refer to shell functions. -prints the contents of tt(file). diff --git a/Doc/Zsh/zftpsys.yo b/Doc/Zsh/zftpsys.yo index f20a0a6c3..e5b980cef 100644 --- a/Doc/Zsh/zftpsys.yo +++ b/Doc/Zsh/zftpsys.yo @@ -1,30 +1,31 @@ -texinode(Zftp Function System)()(Completion System)(Top) +texinode(Zftp Function System)()(Zsh Modules)(Top) chapter(Zftp Function System) -cindex(zftp, function system) +cindex(zftp function system) +cindex(FTP, functions for using shell as client) sect(Description) This describes the set of shell functions supplied with the source distribution as an interface to the tt(zftp) builtin command, allowing you to perform FTP operations from the shell command line or within functions or scripts. The interface is similar to a traditional FTP client (e.g. the -manref(ftp)(1) command itself), but as it is entirely done within the shell -all the familar completion, editing and globbing features, and so on, are -present, and macros are particularly simple to write as they are just -ordinary shell functions. +tt(ftp) command itself, see manref(ftp)(1)), but as it is entirely done +within the shell all the familiar completion, editing and globbing features, +and so on, are present, and macros are particularly simple to write as they +are just ordinary shell functions. The prerequisite is that the tt(zftp) command, as described in ifzman(\ zmanref(zshmodules) )\ ifnzman(\ -noderef(The zftp Module) +noderef(The zsh/zftp Module) ), must be available in the version of tt(zsh) installed at your site. If the shell is configured to -load new commands at run time, it probably is: typing tt(zmodload zftp) +load new commands at run time, it probably is: typing `tt(zmodload zsh/zftp)' will make sure (if that runs silently, it has worked). If this is not the case, it is possible tt(zftp) was linked into the shell anyway: to test -this, type tt(which zftp) and if tt(zftp) is available you will get the -message tt(zftp: shell built-in command). +this, type `tt(which zftp)' and if tt(zftp) is available you will get the +message `tt(zftp: shell built-in command)'. Commands given directly with tt(zftp) builtin may be interspersed between the functions in this suite; in a few cases, using tt(zftp) directly may @@ -43,63 +44,85 @@ sect(Installation) You should make sure all the functions from the tt(Functions/Zftp) directory of the source distribution are available; they all begin with the -two letters tt(zf). They may already have been installed on your system; +two letters `tt(zf)'. They may already have been installed on your system; otherwise, you will need to find them and copy them. The directory should -appear as one of the elements of the tt($fpath) array, and the functions -should be autoloaded. Finally, to initialise the use of the system you -need to call the tt(zfinit) function. The following code in your -tt(.zshrc) will arrange for this; assume the functions are stored in the -directory tt(~/myfns): - -tt(indent( -nofill(fpath=(~/myfns $fpath)) -nofill(autoload ~/myfns/zf*(:t)) -nofill(zfinit) -)) +appear as one of the elements of the tt($fpath) array (this should already +be the case if they were installed), and at least the function tt(zfinit) +should be autoloaded; it will autoload the rest. Finally, to initialize +the use of the system you need to call the tt(zfinit) function. The +following code in your tt(.zshrc) will arrange for this; assume the +functions are stored in the directory tt(~/myfns): + +example(fpath=(~/myfns $fpath) +autoload -U zfinit +zfinit) Note that tt(zfinit) assumes you are using the tt(zmodload) method to load the tt(zftp) command. If it is already built into the shell, change -tt(zfinit) to tt(zfinit -n). +tt(zfinit) to tt(zfinit -n). It is helpful (though not essential) if the +call to tt(zfinit) appears after any code to initialize the new completion +system, else unnecessary tt(compctl) commands will be given. texinode(Zftp Functions)(Miscellaneous Features)(Installation)(Zftp Function System) sect(Functions) The sequence of operations in performing a file transfer is essentially the -same as that in a standard FTP client. +same as that in a standard FTP client. Note that, due to a quirk of the +shell's tt(getopts) builtin, for those functions that handle options you +must use `tt(-)tt(-)' rather than `tt(-)' to ensure the remaining arguments +are treated literally (a single `tt(-)' is treated as an argument). subsect(Opening a connection) startitem() +findex(zfparams) item(tt(zfparams [ var(host) [ var(user) [ var(password) ... ] ] ]))( Set or show the parameters for a future tt(zfopen) with no arguments. If no arguments are given, the current parameters are displayed (the password will be shown as a line of asterisks). If a host is given, and either the var(user) or var(password) is not, they will be prompted for; also, any -parameter given as `tt(?)' will be prompted for. - -As tt(zfopen) calls tt(zfparams) to store the parameters, this usually need -not be called directly. +parameter given as `tt(?)' will be prompted for, and if the `tt(?)' is +followed by a string, that will be used as the prompt. As tt(zfopen) calls +tt(zfparams) to store the parameters, this usually need not be called +directly. + +A single argument `tt(-)' will delete the stored parameters. This will +also cause the memory of the last directory (and so on) on the other host +to be deleted. ) +findex(zfopen) item(tt(zfopen [ -1 ] [ var(host) [ var(user) [ var(password) [ var(account) ] ] ] ]))( If var(host) is present, open a connection to that host under username var(user) with password var(password) (and, on the rare occasions when it -is necessary account var(account)). If a necessary parameter is missing or +is necessary, account var(account)). If a necessary parameter is missing or given as `tt(?)' it will be prompted for. If var(host) is not present, use a previously stored set of parameters. -If the command was successful, and the terminal is an tt(xterm), a summary -will appear in the title bar, giving the local tt(host:directory) and the -remote tt(host:directory); this is handled by the function tt(zftp_chpwd), -described below. +If the command was successful, and the terminal is compatible with +tt(xterm) or is tt(sun-cmd), a summary will appear in the title bar, +giving the local tt(host:directory) and the remote tt(host:directory); +this is handled by the function tt(zftp_chpwd), described below. Normally, the var(host), var(user) and var(password) are internally recorded for later re-opening, either by a tt(zfopen) with no arguments, or -automatically (see below). With the option tt(-1), no information is -stored. +automatically (see below). With the option `tt(-1)', no information is +stored. Also, if an open command with arguments failed, the parameters +will not be retained (and any previous parameters will also be deleted). +A tt(zfopen) on its own, or a tt(zfopen -1), never alters the stored +parameters. + +Both tt(zfopen) and tt(zfanon) (but not tt(zfparams)) understand URLs of +the form tt(ftp://)var(host)/var(path...) as meaning to connect to the +var(host), then change directory to var(path) (which must be a directory, +not a file). The `tt(ftp://)' can be omitted; the trailing `tt(/)' is enough +to trigger recognition of the var(path). Note prefixes other than +`tt(ftp:)' are not recognized, and that all characters after the first +slash beyond var(host) are significant in var(path). ) +findex(zfanon) item(tt(zfanon [ -1 ] var(host)))( Open a connection var(host) for anonymous FTP. The username used is -tt(anonymous). The password (which will be reported the first time) is -generated from var(user)tt(@)tt(host); this is then stored in the shell +`tt(anonymous)'. The password (which will be reported the first time) is +generated as var(user)tt(@)var(host); this is then stored in the shell parameter tt($EMAIL_ADDR) which can alternatively be set manually to a suitable string. ) @@ -107,6 +130,7 @@ enditem() subsect(Directory management) startitem() +findex(zfcd) xitem(tt(zfcd [ var(dir) ])) xitem(tt(zfcd -)) item(tt(zfcd var(old) var(new)))( @@ -114,9 +138,9 @@ Change the current directory on the remote server: this is implemented to have many of the features of the shell builtin tt(cd). In the first form with var(dir) present, change to the directory var(dir). -The command tt(zfcd ..) is treated specially, so is guaranteed to work on -non-UNIX servers (note this is handled internall by tt(zftp)). If var(dir) -is omitted, has the effect of tt(zfcd ~). +The command `tt(zfcd ..)' is treated specially, so is guaranteed to work on +non-UNIX servers (note this is handled internally by tt(zftp)). If var(dir) +is omitted, has the effect of `tt(zfcd ~)'. The second form changes to the directory previously current. @@ -125,56 +149,63 @@ first occurrence of the string var(old) with the string var(new) in the current directory. Note that in this command, and indeed anywhere a remote filename is -expected, the string which on the local host corresponds to tt(~) is -converted back to a tt(~) before being passed to the remote machine. +expected, the string which on the local host corresponds to `tt(~)' is +converted back to a `tt(~)' before being passed to the remote machine. This is convenient because of the way expansion is performed on the command line before tt(zfcd) receives a string. For example, suppose the command -is tt(zfcd ~/foo). The shell will expand this to a full path as in tt(zfcd -/home/user2/pws/foo). At this stage, tt(zfcd) recognises the initial path -as tt(~), and the directory sent to the remote host is tt(~/foo), so that -the tt(~) will be expanded by the server to the correct remote host -directory. Other named directories of the form tt(~name) are not treated -in this fashion. +is `tt(zfcd ~/foo)'. The shell will expand this to a full path such as +`tt(zfcd /home/user2/pws/foo)'. At this stage, tt(zfcd) recognises the +initial path as corresponding to `tt(~)' and will send the directory to +the remote host as tt(~/foo), so that the `tt(~)' will be expanded by the +server to the correct remote host directory. Other named directories of +the form `tt(~name)' are not treated in this fashion. ) +findex(zfhere) item(tt(zfhere))( Change directory on the remote server to the one corresponding to the -current local directory, with special handling of tt(~) as in tt(zfcd). +current local directory, with special handling of `tt(~)' as in tt(zfcd). For example, if the current local directory is tt(~/foo/bar), then -tt(zfhere) performs the effect of tt(zfcd ~/foo/bar). +tt(zfhere) performs the effect of `tt(zfcd ~/foo/bar)'. ) +findex(zfdir) item(tt(zfdir [ -rfd ] [ - ] [ var(dir-options) ] [ var(dir) ]))( Produce a long directory listing. The arguments var(dir-options) and var(dir) are passed directly to the server and their effect is implementation dependent, but specifying a particular remote directory -var(dir) is usually possible. The output is passed through pager. +var(dir) is usually possible. The output is passed through a pager +given by the environment variable tt($PAGER) or defaulting to `tt(more)'. The directory is usually cached for re-use. In fact, two caches are maintained. One is for use when there is no var(dir-options) or var(dir), i.e. a full listing of the current remote directory; it is flushed when the current remote directory changes. The other is kept for repeated use of tt(zfdir) with the same arguments; for example, -repeated use of tt(zfdir /pub/gnu) will only require the directory to be +repeated use of `tt(zfdir /pub/gnu)' will only require the directory to be retrieved on the first call. Alternatively, this cache can be re-viewed with the tt(-r) option. As relative directories will confuse -tt(zfdir), the tt(-f) option can be used to force the cache to be flushed. -Also, the option tt(-d) will delete both caches without showing a directory -listing. +tt(zfdir), the tt(-f) option can be used to force the cache to be flushed +before the directory is listed. The option tt(-d) will delete both +caches without showing a directory listing; it will also delete the cache +of file names in the current remote directory, if any. ) +findex(zfls) item(tt(zfls) [ var(ls-options) ] [ var(dir) ])( List files on the remote server. With no arguments, this will produce a simple list of file names for the current remote directory. Any arguments -are passed directory to the server. No pager and no caching is used. +are passed directly to the server. No pager and no caching is used. ) enditem() subsect(Status commands) startitem() +findex(zftype) item(tt(zftype) [ var(type) ])( With no arguments, show the type of data to be transferred, usually ASCII -or binary. With an argument, change the type: the types tt(A) or -tt(ASCII) for ASCII data and tt(B) or tt(BINARY), tt(I) or tt(IMAGE) for -binary data are understood case-insensitively. +or binary. With an argument, change the type: the types `tt(A)' or +`tt(ASCII)' for ASCII data and `tt(B)' or `tt(BINARY)', `tt(I)' or +`tt(IMAGE)' for binary data are understood case-insensitively. ) +findex(zfstat) item(tt(zfstat) [ -v ])( Show the status of the current or last connection, as well as the status of some of tt(zftp)'s status variables. With the tt(-v) option, a more @@ -192,12 +223,16 @@ this requires version 5 of tt(perl), see the description of the function tt(zfrtime) below for more information. startitem() -item(tt(zfget [ -Gt ] var(file1) ...))( +findex(zfget) +item(tt(zfget [ -Gtc ] var(file1) ...))( Retrieve all the listed files var(file1) ... one at a time from the remote server. If a file contains a `tt(/)', the full name is passed to the remote server, but the file is stored locally under the name given by the -part after the final `tt(/)'. +part after the final `tt(/)'. The option tt(-c) (cat) forces all files to +be sent as a single stream to standard output; in this case the tt(-t) +option has no effect. ) +findex(zfuget) item(tt(zfuget [ -Gvst ] var(file1) ...))( As tt(zfget), but only retrieve files where the version on the remote server is newer (has a later modification time), or where the local file @@ -208,6 +243,7 @@ and will always retrieve the file in either of those two cases. With the option tt(-v), the command prints more information about the files while it is working out whether or not to transfer them. ) +findex(zfcget) item(tt(zfcget [ -Gt ] var(file1) ...))( As tt(zfget), but if any of the local files exists, and is shorter than the corresponding remote file, the command assumes that it is the result of @@ -217,6 +253,7 @@ file. This is useful on a poor connection which keeps failing. Note that this requires a commonly implemented, but non-standard, version of the FTP protocol, so is not guaranteed to work on all servers. ) +findex(zfgcp) xitem(tt(zfgcp [ -Gt ] var(remote-file) var(local-file))) item(tt(zfgcp [ -Gt ] var(rfile1) ... var(ldir)))( This retrieves files from the remote server with arguments behaving @@ -233,16 +270,24 @@ enditem() subsect(Sending files) startitem() -item(tt(zfput var(file1) ...))( +findex(zfput) +item(tt(zfput [ -r ] var(file1) ...))( Send all the var(file1) ... given separately to the remote server. If a filename contains a `tt(/)', the full filename is used locally to find the file, but only the basename is used for the remote file name. + +With the option tt(-r), if any of the var(files) are directories they are +sent recursively with all their subdirectories, including files beginning +with `tt(.)'. This requires that the remote machine understand UNIX file +semantics. as `tt(/)' is used as a directory separator. ) +findex(zfuput) item(tt(zfuput [ -vs ] var(file1) ...))( As tt(zfput), but only send files which are newer than their local equivalents, or if the remote file does not exist. The logic is the same as for tt(zfuget), but reversed between local and remote files. ) +findex(zfcput) item(tt(zfcput var(file1) ...))( As tt(zfput), but if any remote file already exists and is shorter than the local equivalent, assume it is the result of an incomplete transfer and @@ -250,6 +295,7 @@ send the rest of the file to append to the existing part. As the FTP append command is part of the standard set, this is in principle more likely to work than tt(zfcget). ) +findex(zfpcp) xitem(tt(zfpcp var(local-file) var(remote-file))) item(tt(zfpcp var(lfile1) ... var(rdir)))( This sends files to the remote server with arguments behaving similarly to @@ -266,32 +312,117 @@ A problem arises if you attempt to use tt(zfpcp) var(lfile1) var(rdir), i.e. the second form of copying but with two arguments, as the command has no simple way of knowing if var(rdir) corresponds to a directory or a filename. It attempts to resolve this in various ways. First, if the -var(rdir) argument is tt(.) or tt(..) or ends in a slash, it is assumed to -be a directory. Secondly, if the operation of copying to a remote file in -the first form failed, and the remote server sends back the expected +var(rdir) argument is `tt(.)' or `tt(..)' or ends in a slash, it is assumed +to be a directory. Secondly, if the operation of copying to a remote file +in the first form failed, and the remote server sends back the expected failure code 553 and a reply including the string `tt(Is a directory)', then tt(zfpcp) will retry using the second form. ) enditem() -subsect(Closing the connectino) +subsect(Closing the connection) startitem() +findex(zfclose) item(tt(zfclose))( Close the connection. ) enditem() +subsect(Session management) +startitem() +findex(zfsession) +item(tt(zfsession) [ tt(-lvod) ] [ var(sessname) ])( +Allows you to manage multiple FTP sessions at once. By default, +connections take place in a session called `tt(default)'; by giving the +command `tt(zfsession) var(sessname)' you can change to a new or existing +session with a name of your choice. The new session remembers its own +connection, as well as associated shell parameters, and also the host/user +parameters set by tt(zfparams). Hence you can have different sessions set +up to connect to different hosts, each remembering the appropriate host, +user and password. + +With no arguments, tt(zfsession) prints the name of the current session; +with the option tt(-l) it lists all sessions which currently exist, and +with the option tt(-v) it gives a verbose list showing the host and +directory for each session, where the current session is marked with an +asterisk. With tt(-o), it will switch to the most recent previous session. + +With tt(-d), the given session (or else the current one) is removed; +everything to do with it is completely forgotten. If it was the only +session, a new session called `tt(default)' is created and made current. +It is safest not to delete sessions while background commands using +tt(zftp) are active. +) +findex(zftransfer) +item(tt(zftransfer) var(sess1)tt(:)var(file1) var(sess2)tt(:)var(file2))( +Transfer files between two sessions; no local copy is made. The file +is read from the session var(sess1) as var(file1) and written to session +var(sess1) as file var(file2); var(file1) and var(file2) may be relative to +the current directories of the sesssion. Either var(sess1) or var(sess2) +may be omitted (though the colon should be retained if there is a +possibility of a colon appearing in the file name) and defaults to the +current session; var(file2) may be omitted or may end with a slash, in +which case the basename of var(file1) will be added. The sessions +var(sess1) and var(sess2) must be distinct. + +The operation is performed using pipes, so it is required that the +connections still be valid in a subshell, which is not the case under some +operating systems. +) +enditem() + +subsect(Bookmarks) +The two functions tt(zfmark) and tt(zfgoto) allow you to `bookmark' the +present location (host, user and directory) of the current FTP connection +for later use. The file to be used for storing and retrieving bookmarks is +given by the parameter tt($ZFTP_BMFILE); if not set when one of the two +functions is called, it will be set to the file tt(.zfbfmarks) in the +directory where your zsh startup files live (usually tt(~)). + +startitem() +findex(zfmark) +item(tt(zfmark [ )var(bookmark)tt( ]))( +If given an argument, mark the current host, user and directory under the +name var(bookmark) for later use by tt(zfgoto). If there is no connection +open, use the values for the last connection immediately before it was +closed; it is an error if there is none. Any existing bookmark +under the same name will be silently replaced. + +If not given an argument, list the existing bookmarks and the points to +which they refer in the form var(user)tt(@)var(host)tt(:)var(directory); +this is the format in which they are stored, and the file may be edited +directly. +) +findex(zfgoto) +item(tt(zfgoto [ -n ] )var(bookmark))( +Return to the location given by var(bookmark), as previously set by +tt(zfmark). If the location has user `tt(ftp)' or `tt(anonymous)', open +the connection with tt(zfanon), so that no password is required. If the +user and host parameters match those stored for the current session, if +any, those will be used, and again no password is required. Otherwise a +password will be prompted for. + +With the option tt(-n), the bookmark is taken to be a nickname stored by +the tt(ncftp) program in its bookmark file, which is assumed to be +tt(~/.ncftp/bookmarks). The function works identically in other ways. +Note that there is no mechanism for adding or modifying tt(ncftp) bookmarks +from the zftp functions. +) +enditem() + subsect(Other functions) Mostly, these functions will not be called directly (apart from tt(zfinit)), but are described here for completeness. You may wish to alter tt(zftp_chpwd) and tt(zftp_progress), in particular. startitem() +findex(zfinit) item(tt(zfinit [ -n ]))( -As decribed above, this is used to initialise the zftp function system. +As described above, this is used to initialize the zftp function system. The tt(-n) option should be used if the zftp command is already built into the shell. ) +findex(zfautocheck) item(tt(zfautocheck [ -dn ]))( This function is called to implement automatic reopening behaviour, as described in more detail below. The options must appear in the first @@ -302,6 +433,7 @@ transfer. The host and directory for the last session are stored in the variable tt($zflastsession), but the internal host/user/password parameters must also be correctly set. ) +findex(zfcd_match) item(tt(zfcd_match var(prefix) var(suffix)))( This performs matching for completion of remote directory names. If the remote server is UNIX, it will attempt to persuade the server to list the @@ -310,6 +442,7 @@ guaranteed. On other hosts it simply calls tt(zfget_match) and hence completes all files, not just directories. On some systems, directories may not even look like filenames. ) +findex(zfget_match) item(tt(zfget_match var(prefix) var(suffix)))( This performs matching for completion of remote filenames. It caches files for the current directory (only) in the shell parameter tt($zftp_fcache). @@ -317,12 +450,14 @@ It is in the form to be called by the tt(-K) option of tt(compctl), but also works when called from a widget-style completion function with var(prefix) and var(suffix) set appropriately. ) +findex(zfrglob) item(tt(zfrglob var(varname)))( Perform remote globbing, as describes in more detail below. var(varname) is the name of a variable containing the pattern to be expanded; if there -were any matches, the same variable will be set to the exanded set of +were any matches, the same variable will be set to the expanded set of filenames on return. ) +findex(zfrtime) item(tt(zfrtime var(lfile) var(rfile) [ var(time) ]))( Set the local file var(lfile) to have the same modification time as the remote file var(rfile), or the explicit time var(time) in FTP format @@ -332,41 +467,129 @@ Currently this requires tt(perl) version 5 to perform the conversion from GMT to local time. This is unfortunately difficult to do using shell code alone. ) +findex(zftp_chpwd, supplied version) item(tt(zftp_chpwd))( This function is called every time a connection is opened, or closed, or the remote directory changes. This version alters the title bar of an -tt(xterm) or tt(sun-cmd) terminal emulator to reflect the local and remote -hostnames and current directories. It works best when combined with the -function tt(chpwd). In particular, a function of the form - -tt(indent( -nofill(chpwd() {) -nofill( if [[ -n $ZFTP_USER ]]; then) -nofill( zftp_chpwd) -nofill( else) -nofill( # usual chpwd e.g put host:directory in title bar) -nofill( fi) -nofill(}) -)) +tt(xterm) compatible or tt(sun-cmd) terminal emulator to reflect the +local and remote hostnames and current directories. It works best when +combined with the function tt(chpwd). In particular, a function of +the form + +example(chpwd() { + if [[ -n $ZFTP_USER ]]; then + zftp_chpwd + else + # usual chpwd e.g put host:directory in title bar + fi +}) fits in well. ) +findex(zftp_progress, supplied version) item(tt(zftp_progress))( -This function shows the status of the transfer as the percentage of the -total so far transferred. It will not write anything unless the output is -going to a terminal; however, if you transfer files in the background, you -should tt(unfunction) this first. (Background file transfers don't work on -all OSes.) Note also that if you alter it, any output em(must) be to -standard error, as standard output may be a file being received. +This function shows the status of the transfer. It will not write anything +unless the output is going to a terminal; however, if you transfer files in +the background, you should turn off progress reports by hand using +`tt(zstyle ':zftp:*' progress none)'. Note also that if you alter it, any +output em(must) be to standard error, as standard output may be a file +being received. The form of the progess meter, or whether it is used at +all, can be configured without altering the function, as described in the +next section. +) +findex(zffcache) +item(tt(zffcache))( +This is used to implement caching of files in the current directory for +each session separately. It is used by tt(zfget_match) and tt(zfrglob). ) enditem() texinode(Miscellaneous Features)()(Zftp Functions)(Zftp Function System) sect(Miscellaneous Features) +subsect(Configuration) +cindex(zftp function system, configuration) +cindex(zftp function system, styles) +cindex(styles in zftp functions) + +Various styles are available using the standard shell style mechanism, +described in +ifzman(zmanref(zshmodules))\ +ifnzman(noderef(The zsh/zutil Module)). Briefly, the +command `tt(zstyle ':zftp:*') var(style) var(value) ...'. +defines the var(style) to have value var(value) (more than one may be +given, although that is not useful in the cases described here). These +values will then be used throughout the zftp function system. For more +precise control, the first argument, which gives a context in which the +style applies, can be modified to include a particular function, as for +example `tt(:zftp:zfget:)': the style will then have the given value only +in the tt(zfget) function. Values for the same style in different contexts +may be set; the most specific function will be used, where +strings are held to be more specific than patterns, and longer patterns and +shorter patterns. Note that only the top level function name, as called by +the user, is used; calling of lower level functions is transparent to the +user. Hence modifications to the title bar in tt(zftp_chpwd) use the +contexts tt(:zftp:zfopen:), tt(:zftp:zfcd:), etc., depending where it was +called from. The following styles are understood: + +startitem() +kindex(progress, zftp style) +item(tt(progress))( +Controls the way that tt(zftp_progress) reports on the progress of a +transfer. If empty, unset, or `tt(none)', no progress report is made; if +`tt(bar)' a growing bar of inverse video is shown; if `tt(percent)' (or any +other string, though this may change in future), the percentage of the file +transferred is shown. The bar meter requires that the width of the +terminal be available via the tt($COLUMNS) parameter (normally this is set +automatically). If the size of the file being transferred is not +available, tt(bar) and tt(percent) meters will simply show the number of +bytes transferred so far. + +When tt(zfinit) is run, if this style is not defined for the context +tt(:zftp:*), it will be set to `bar'. +) +kindex(update, zftp style) +item(tt(update))( +Specifies the minimum time interval between updates of the progress meter +in seconds. No update is made unless new data has been received, so the +actual time interval is limited only by tt($ZFTP_TIMEOUT). + +As described for tt(progress), tt(zfinit) will force this to default to 1. +) +kindex(remote-glob, zftp style) +item(tt(remote-glob))( +If set to `1', `yes' or `true', filename generation (globbing) is +performed on the remote machine instead of by zsh itself; see below. +) +kindex(titlebar, zftp style) +item(tt(titlebar))( +If set to `1', `yes' or `true', tt(zftp_chpwd) will put the remote host and +remote directory into the titlebar of terminal emulators such as xterm or +sun-cmd that allow this. + +As described for tt(progress), tt(zfinit) will force this to default to 1. +) +kindex(chpwd, zftp style) +item(tt(chpwd))( +If set to `1' `yes' or `true', tt(zftp_chpwd) will call the function +tt(chpwd) when a connection is closed. This is useful if the remote host +details were put into the terminal title bar by tt(zftp_chpwd) and your +usual tt(chpwd) also modifies the title bar. + +When tt(zfinit) is run, it will determine whether tt(chpwd) exists and if +so it will set the default value for the style to 1 if none exists +already. +) +enditem() + +Note that there is also an associative array tt(zfconfig) which contains +values used by the function system. This should not be modified or +overwritten. + subsect(Remote globbing) +cindex(zftp function system, remote globbing) -The commands for retrieving files usually perform filename expansion +The commands for retrieving files usually perform filename generation (globbing) on their arguments; this can be turned off by passing the option tt(-G) to each of the commands. Normally this operates by retrieving a complete list of files for the directory in question, then matching these @@ -378,16 +601,17 @@ remote server does not support the UNIX directory semantics, directory handling is problematic and it is recommended that globbing only be used within the current directory. The list of files in the current directory, if retrieved, will be cached, so that subsequent globs in the same -directory without an interventing tt(zfcd) are fast. +directory without an intervening tt(zfcd) are much faster. -If the variable tt($zfrglob) is set to a non-zero length, globbing is -instead performed on the remote host: the server is asked for a list of -matching files. This is highly dependent on how the server is implemented, -though typically UNIX servers will provide support for basic glob -patterns. This may in some cases be faster, as it avoids retrieving the -entire list of directory contents. +If the tt(remote-glob) style (see above) is set, globbing is instead +performed on the remote host: the server is asked for a list of matching +files. This is highly dependent on how the server is implemented, though +typically UNIX servers will provide support for basic glob patterns. This +may in some cases be faster, as it avoids retrieving the entire list of +directory contents. subsect(Automatic and temporary reopening) +cindex(zftp function system, automatic reopening) As described for the tt(zfopen) command, a subsequent tt(zfopen) with no parameters will reopen the connection to the last host (this includes @@ -415,21 +639,24 @@ never close the connection automatically. Information about the previous connection is given by the tt(zfstat) function. So, for example, if that reports: -tt(indent( -nofill(Not connected.) -nofill(Last session: ftp.bar.com:/pub/textfiles) -)) +example(Session: default +Not connected. +Last session: ftp.bar.com:/pub/textfiles) then the command tt(zfget file.txt) will attempt to reopen a connection to tt(ftp.bar.com), retrieve the file tt(/pub/textfiles/file.txt), and immediately close the connection again. On the other hand, tt(zfcd ..) will open the connection in the directory tt(/pub) and leave it open. +Note that all the above is local to each session; if you return to a +previous session, the connection for that session is the one which will be +reopened. + subsect(Completion) -Completion of remote files and directories is supported. The older, -tt(compctl)-style completion is defined when tt(zfinit) is called; support -for the new widget-based completion system is provided in the function -tt(Completion/Builtins/_zftp), which should be installed with the other -functions of the completion system and hence should automatically be -available. +Completion of local and remote files, directories, sessions and bookmarks +is supported. The older, tt(compctl)-style completion is defined when +tt(zfinit) is called; support for the new widget-based completion system is +provided in the function tt(Completion/Builtins/_zftp), which should be +installed with the other functions of the completion system and hence +should automatically be available. diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index fccf538bd..9b5744c2c 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -1,12 +1,13 @@ -texinode(Zsh Line Editor)(Programmable Completion)(Shell Builtin Commands)(Top) +texinode(Zsh Line Editor)(Completion Using compctl)(Shell Builtin Commands)(Top) chapter(Zsh Line Editor) cindex(line editor) cindex(editor, line) +cindex(ZLE) sect(Description) pindex(ZLE, use of) -If the tt(ZLE) option is set (it is by default) +If the tt(ZLE) option is set (which it is by default in interactive shells) and the shell input is attached to the terminal, the user -is allowed to edit command lines. +is able to edit command lines. There are two display modes. The first, multiline mode, is the default. It only works if the tt(TERM) parameter is set to a valid @@ -67,7 +68,8 @@ that is bound to some command and is also a prefix of a longer bound string. In this case ZLE will wait a certain time to see if more characters are typed, and if not (or they don't match any longer string) it will execute the binding. This timeout is defined by the tt(KEYTIMEOUT) parameter; -its default is 0.4 sec. No timeout is done if the prefix string is not bound. +its default is 0.4 sec. There is no timeout if the prefix string is not +itself bound to a command. As well as ZLE commands, key sequences can be bound to other strings, by using `tt(bindkey -s)'. @@ -83,7 +85,7 @@ simply to perform some small action. The ZLE commands that key sequences in keymaps are bound to are in fact widgets. Widgets can be user-defined or built in. -There are 162 standard widgets built in to ZLE (see sectref(Standard Widgets)). +The standard widgets built in to ZLE are listed in Standard Widgets below. Other built-in widgets can be defined by other modules (see ifzman(zmanref(zshmodules))\ ifnzman(noderef(Zsh Modules))\ @@ -102,7 +104,8 @@ cindex(widgets, user-defined) User-defined widgets, being implemented as shell functions, can execute any normal shell command. They can also run other widgets (whether built-in or user-defined) using the tt(zle) builtin command. -Finally, they can examine and edit the ZLE buffer being edited by +They can use tt(read -k) or tt(read -q) to read characters from standard +input. Finally, they can examine and edit the ZLE buffer being edited by reading and setting the special parameters described below. cindex(parameters, editor) @@ -113,6 +116,9 @@ outside ZLE, that value is temporarily inaccessible, but will return when the widget function exits. These special parameters in fact have local scope, like parameters created in a function using tt(local). +Inside completion widgets and traps called while ZLE is active, these +parameters are available read-only. + startitem() vindex(BUFFER) item(tt(BUFFER) (scalar))( @@ -127,6 +133,10 @@ The offset of the cursor, within the edit buffer. This is in the range Attempts to move the cursor outside the buffer will result in the cursor being moved to the appropriate end of the buffer. ) +vindex(MARK) +item(tt(MARK) (integer))( +Like tt(CURSOR), but for the mark. +) vindex(LBUFFER) item(tt(LBUFFER) (scalar))( The part of the buffer that lies to the left of the cursor position. @@ -139,6 +149,42 @@ The part of the buffer that lies to the right of the cursor position. If it is assigned to, only that part of the buffer is replaced, and the cursor remains between the old tt($LBUFFER) and the new tt($RBUFFER). ) +vindex(BUFFERLINES) +item(tt(BUFFERLINES))( +The number of screen lines needed for the edit buffer currently +displayed on screen (i.e. without any changes to the preceding +parameters done after the last redisplay). +) +vindex(PREBUFFER) +item(tt(PREBUFFER) (scalar))( +In a multi-line input at the secondary prompt, this read-only parameter +contains the contents of the lines before the one the cursor is +currently in. +) +vindex(WIDGET) +item(tt(WIDGET) (scalar))( +The name of the widget currently being executed. +) +vindex(LASTWIDGET) +item(tt(LASTWIDGET) (scalar))( +The name of the last widget that was executed. +) +vindex(KEYS) +item(tt(KEYS) (scalar))( +The keys typed to invoke this widget, as a literal string. +) +vindex(NUMERIC) +item(tt(NUMERIC) (integer))( +The numeric argument. If no numeric argument was given, this parameter +is unset. When this is set inside a widget function, builtin widgets +called with the tt(zle) builtin command will use the value +assigned. If it is unset inside a widget function, builtin widgets +called behave as if no numeric argument was given. +) +vindex(HISTNO) +item(tt(HISTNO) (integer))( +The current history number. +) enditem() sect(Standard Widgets) cindex(widgets, standard) @@ -317,6 +363,10 @@ item(tt(down-line-or-search))( Move down a line in the buffer, or if already at the bottom line, search forward in the history for a line beginning with the first word in the buffer. + +If called from a function by the tt(zle) command with arguments, the first +argument is taken as the string for which to search, rather than the +first word in the buffer. ) tindex(down-history) item(tt(down-history) (unbound) (^N) (unbound))( @@ -385,6 +435,17 @@ search, leaving the last found line in the buffer. Any single character that is not bound to one of the above functions, or tt(self-insert) or tt(self-insert-unmeta), will have the same effect but the function will be executed. + +When called from a widget function by the tt(zle) command, the incremental +search commands can take a string argument. This will be treated as a +string of keys, as for arguments to the tt(bindkey) command, and used as +initial input for the command. Any characters in the string which are +unused by the incremental search will be silently ignored. For example, + +example(zle history-incremental-search-backward forceps) + +will search backwards for tt(forceps), leaving the minibuffer containing +the string `tt(forceps)'. ) tindex(history-incremental-search-forward) item(tt(history-incremental-search-forward) (^S ^Xs) (unbound) (unbound))( @@ -398,6 +459,10 @@ tindex(history-search-backward) item(tt(history-search-backward) (ESC-P ESC-p) (unbound) (unbound))( Search backward in the history for a line beginning with the first word in the buffer. + +If called from a function by the tt(zle) command with arguments, the first +argument is taken as the string for which to search, rather than the +first word in the buffer. ) tindex(vi-history-search-backward) item(tt(vi-history-search-backward) (unbound) (/) (unbound))( @@ -425,18 +490,27 @@ tt(magic-space) is treated as a space. Any other character that is not bound to self-insert or self-insert-unmeta will beep and be ignored. If the function is called from vi command mode, the bindings of the current insert mode will be used. + +If called from a function by the tt(zle) command with arguments, the first +argument is taken as the string for which to search, rather than the +first word in the buffer. ) tindex(history-search-forward) item(tt(history-search-forward) (ESC-N ESC-n) (unbound) (unbound))( Search forward in the history for a line beginning with the first word in the buffer. + +If called from a function by the tt(zle) command with arguments, the first +argument is taken as the string for which to search, rather than the +first word in the buffer. ) tindex(vi-history-search-forward) item(tt(vi-history-search-forward) (unbound) (?) (unbound))( Search forward in the history for a specified string. The string may begin with `tt(^)' to anchor the search to the beginning of the line. The functions available in the mini-buffer are the same -as for tt(vi-history-search-backward). +as for tt(vi-history-search-backward). Argument handling is also the same +as for that command. ) tindex(infer-next-history) item(tt(infer-next-history) (^X^N) (unbound) (unbound))( @@ -449,7 +523,10 @@ Insert the last word from the previous history event at the cursor position. If a positive numeric argument is given, insert that word from the end of the previous history event. If the argument is zero or negative insert that word from the -left (zero inserts the previous command word). +left (zero inserts the previous command word). Repeating this command +replaces the word just inserted with the last word from the +history event prior to the one just used; numeric arguments can be used in +the same way to pick a word from that event. ) tindex(vi-repeat-search) item(tt(vi-repeat-search) (unbound) (n) (unbound))( @@ -475,6 +552,10 @@ item(tt(up-line-or-search))( Move up a line in the buffer, or if already at the top line, search backward in the history for a line beginning with the first word in the buffer. + +If called from a function by the tt(zle) command with arguments, the first +argument is taken as the string for which to search, rather than the +first word in the buffer. ) tindex(up-history) item(tt(up-history) (unbound) (^P) (unbound))( @@ -771,7 +852,11 @@ startitem() tindex(digit-argument) item(tt(digit-argument) (ESC-0..ESC-9) (1-9) (unbound))( Start a new numeric argument, or add to the current one. -See also tt(vi-digit-or-beginning-of-line). +See also tt(vi-digit-or-beginning-of-line). This only works if bound to a +key sequence ending in a decimal digit. + +Inside a widget function, a call to this function treats the last key of +the key sequence which called the widget as the digit. ) tindex(neg-argument) item(tt(neg-argument) (ESC--) (unbound) (unbound))( @@ -786,6 +871,10 @@ repeated using this command. For example, if this command occurs twice, followed immediately by tt(forward-char), move forward sixteen spaces; if instead it is followed by tt(-2), then tt(forward-char), move backward two spaces. + +Inside a widget function, if passed an argument, i.e. `tt(zle +universal-argument) var(num)', the numerical argument will be set to +var(num); this is equivalent to `tt(NUMERIC=)var(num)'. ) enditem() texinode(Completion)(Miscellaneous)(Arguments)(Zsh Line Editor) @@ -857,6 +946,11 @@ Perform menu completion, like tt(menu-complete), except that if a menu completion is already in progress, move to the em(previous) completion rather than the next. ) +tindex(end-of-list) +item(tt(end-of-list))( +When a previous completion displayed a list below the prompt, this +widget can be used to move the prompt below the list. +) enditem() texinode(Miscellaneous)()(Completion)(Zsh Line Editor) subsect(Miscellaneous) @@ -882,6 +976,10 @@ item(tt(accept-line-and-down-history) (^O) (unbound) (unbound))( Execute the current line, and push the next history event on the the buffer stack. ) +tindex(beep) +item(tt(beep))( +Beep, unless the tt(BEEP) option is unset. +) tindex(vi-cmd-mode) item(tt(vi-cmd-mode) (^X^V) (unbound) (^[))( Enter command mode; that is, select the `tt(vicmd)' keymap. diff --git a/Doc/zsh.yo b/Doc/zsh.yo index c38313b4e..3d39a41c0 100644 --- a/Doc/zsh.yo +++ b/Doc/zsh.yo @@ -61,10 +61,10 @@ ifnzman(includefile(Zsh/params.yo)) ifnzman(includefile(Zsh/options.yo)) ifnzman(includefile(Zsh/builtins.yo)) ifnzman(includefile(Zsh/zle.yo)) -ifnzman(includefile(Zsh/compwid.yo)) ifnzman(includefile(Zsh/compctl.yo)) -ifnzman(includefile(Zsh/modules.yo)) +ifnzman(includefile(Zsh/compwid.yo)) ifnzman(includefile(Zsh/compsys.yo)) +ifnzman(includefile(Zsh/modules.yo)) ifnzman(includefile(Zsh/zftpsys.yo)) ifzshall(\ def(source)(1)(NOTRANS(.so )man1/ARG1NOTRANS(.)1)\ @@ -75,10 +75,10 @@ source(zshparam) source(zshoptions) source(zshbuiltins) source(zshzle) -source(zshcompwid) source(zshcompctl) -source(zshmodules) +source(zshcompwid) source(zshcompsys) +source(zshmodules) source(zshzftpsys) manpage(ZSHALL)(1)(date())(zsh version()) )\ diff --git a/Doc/ztexi.yo b/Doc/ztexi.yo index b8e115ec0..02fee37a6 100644 --- a/Doc/ztexi.yo +++ b/Doc/ztexi.yo @@ -11,7 +11,6 @@ def(CMT)(0)(NOTRANS(@c)) ATEXIT(\ NL()\ - NOTRANS(@setchapternewpage odd)NL()\ NOTRANS(@contents)NL()\ NOTRANS(@bye)NL()\ ) @@ -33,7 +32,7 @@ COMMENT(--- emphasised text ---) def(em)(1)(NOTRANS(@emph{)ARG1NOTRANS(})) def(bf)(1)(NOTRANS(@cite{)ARG1NOTRANS(})) -def(tt)(1)(NOTRANS(@code{)ARG1NOTRANS(})) +def(tt)(1)(NOTRANS(@t{)ARG1NOTRANS(})) def(var)(1)(NOTRANS(@var{)ARG1NOTRANS(})) COMMENT(--- man page headers ---) @@ -47,16 +46,26 @@ def(texinfo)(2)(\ STDPAR()\ NOTRANS(\input texinfo.tex)NL()\ NOTRANS(@c %**start of header)NL()\ + NOTRANS(@iftex)NL()\ + NOTRANS(@afourpaper)NL()\ + NOTRANS(@setchapternewpage off)NL()\ + NOTRANS(@end iftex)NL()\ NOTRANS(@setfilename )ARG1NL()\ NOTRANS(@settitle )ARG2NL()\ NOTRANS(@c %**end of header)NL()\ NL()\ NOTRANS(@ifinfo)NL()\ - NOTRANS(@set dsq @'@')NL()\ + NOTRANS(@set dsq '@:')NL()\ NOTRANS(@end ifinfo)NL()\ NOTRANS(@iftex)NL()\ NOTRANS(@set dsq '{}')NL()\ NOTRANS(@end iftex)NL()\ + NOTRANS(@ifinfo)NL()\ + NOTRANS(@dircategory Utilities)NL()\ + NOTRANS(@direntry)NL()\ + NOTRANS( * ZSH: (zsh). The Z Shell Manual.)NL()\ + NOTRANS(@end direntry)NL()\ + NOTRANS(@end ifinfo)NL()\ ) def(texiifinfo)(1)(\ @@ -171,6 +180,7 @@ def(startlist)(0)(\ startitem()\ ) def(endlist)(0)(\ + NOTRANS(@item)NL()\ enditem()\ ) def(list)(1)(\ @@ -201,8 +211,16 @@ def(nofill)(1)(\ USECHARTABLE(standard)\ ) +def(example)(1)(\ + NOTRANS(@example)NL()\ + ARG1\ + NL()NOTRANS(@end example)\ +) + def(indent)(1)(\ + NOTRANS(@quotation)NL()\ ARG1\ + NL()NOTRANS(@end quotation)\ ) COMMENT(--- hyperlink menus ---) diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index 3bb53de39..408cc5f5c 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -1,4 +1,4 @@ -mailto(pws@ifh.de)\ +mailto(pws@pwstephenson.fsnet.co.uk)\ whentxt(notableofcontents())\ COMMENT(-- mytt is like tt but adds quotes `like this' for plain text --)\ def(mytt)(1)(\ @@ -13,7 +13,7 @@ def(mybf)(1)(\ whenhtml(bf(ARG1))\ whenlatex(bf(ARG1))\ whenms(bf(ARG1))\ - whensgml(bf(ARG1))) + whensgml(bf(ARG1)))\ def(myem)(1)(\ whentxt(_ARG1_)\ whenhtml(em(ARG1))\ @@ -31,10 +31,10 @@ def(mydit)(1)(\ COMMENT(-- myeit is like eit but fancier text formatting --)\ def(myeit)(0)(\ whenlatex(eit())whenhtml(eit())whenman(eit())whenms(eit())whensgml(eit())\ - whentxt(USECOUNTER(XXenumcounter)CHAR(41)))\ + whentxt(eit()CHAR(41)))\ def(myeitd)(0)(\ whenlatex(eit())whenhtml(eit())whenman(eit())whenms(eit())whensgml(eit())\ - whentxt(USECOUNTER(XXenumcounter).))\ + whentxt(.))\ COMMENT(-- don't want headers for text, USENET headers must come first --)\ def(myreport)(3)(\ whentxt(report()()())\ @@ -43,22 +43,20 @@ whenlatex(report(ARG1)(ARG2)(ARG3))\ whenman(report(ARG1)(ARG2)(ARG3))\ whenms(report(ARG1)(ARG2)(ARG3))\ whensgml(report(ARG1)(ARG2)(ARG3))) -myreport(Z-Shell Frequently-Asked Questions)(Peter Stephenson)(1998/10/26) +myreport(Z-Shell Frequently-Asked Questions)(Peter Stephenson)(2000/1/25) COMMENT(-- the following are for Usenet and must appear first)\ -description( +description(\ mydit(Archive-Name:) unix-faq/shell/zsh -mydit(Last-Modified:) 1998/10/26 -mydit(Submitted-By:) email(pws@amtp.liv.ac.uk (Peter Stephenson)) -mydit(Version:) $Id: FAQ.yo,v 1.1 1999/04/15 18:05:37 akr Exp $ -mydit(Frequency:) Monthly -mydit(Copyright:) (C) P.W. Stephenson, 1995, 1996, 1997, 1998 \ -(see end of document) +mydit(Last-Modified:) 2000/11/25 +mydit(Submitted-By:) email(pws@ibmth.df.unipi.it (Peter Stephenson)) +mydit(Version:) $Id: FAQ.yo,v 1.2 2000/04/01 20:43:44 pws Exp $ +mydit(Posting-Frequency:) Monthly +mydit(Copyright:) (C) P.W. Stephenson, 1995--2000 (see end of document) ) -bf(Changes since issue posted September 1998:) +bf(Changes since issue posted December 1999:) description( -mydit(2.1) Another mytt(typeset) difference turned up. -mydit(5.4) Slight addition to Y2K item (prompt formatting) +mydit( ) None. Suggestions on a postcard. ) This document contains a list of frequently-asked (or otherwise @@ -99,25 +97,29 @@ Chapter 2: How does zsh differ from...? Chapter 3: How to get various things to work 3.1. Why does `$var' where `var="foo bar"' not do what I expect? -3.2. What is the difference between `export' and the ALL_EXPORT option? -3.3. How do I turn off spelling correction/globbing for a single command? -3.4. How do I get the meta key to work on my xterm? -3.5. How do I automatically display the directory in my xterm title bar? -3.6. How do I make the completion list use eight bit characters? -3.7. Why do the cursor (arrow) keys not work? -3.8. Why does my terminal act funny in some way? -3.9. Why does zsh not work in an Emacs shell mode any more? -3.10. Why do my autoloaded functions not autoload [the first time]? -3.11. How does base arithmetic work? -3.12. How do I get a newline in my prompt? -3.13. Why does `bindkey ^a command-name' or 'stty intr ^-' do something funny? -3.14. Why can't I bind \C-s and \C-q any more? -3.15. How do I execute command `foo' within function `foo'? -3.16. Why do history substitutions with single bangs do something funny? -3.17. Why does zsh kill off all my background jobs when I logout? -3.18. How do I list all my history entries? -3.19. How does the alternative loop syntax, e.g. mytt(while {...} {...}) work? -3.20. Why is my history not being saved? +3.2. In which startup file do I put...? +3.3. What is the difference between `export' and the ALL_EXPORT option? +3.4. How do I turn off spelling correction/globbing for a single command? +3.5. How do I get the meta key to work on my xterm? +3.6. How do I automatically display the directory in my xterm title bar? +3.7. How do I make the completion list use eight bit characters? +3.8. Why do the cursor (arrow) keys not work? +3.9. Why does my terminal act funny in some way? +3.10. Why does zsh not work in an Emacs shell mode any more? +3.11. Why do my autoloaded functions not autoload [the first time]? +3.12. How does base arithmetic work? +3.13. How do I get a newline in my prompt? +3.14. Why does `bindkey ^a command-name' or 'stty intr ^-' do something funny? +3.15. Why can't I bind \C-s and \C-q any more? +3.16. How do I execute command `foo' within function `foo'? +3.17. Why do history substitutions with single bangs do something funny? +3.18. Why does zsh kill off all my background jobs when I logout? +3.19. How do I list all my history entries? +3.20. How does the alternative loop syntax, e.g. mytt(while {...} {...}) work? +3.21. Why is my history not being saved? +3.22. How do I get a variable's value to be evaluated as another variable? +3.23. How do I prevent the prompt overwriting output when there is no newline? +3.24. What's wrong with cut and paste on my xterm? Chapter 4: The mysteries of completion 4.1. What is completion? @@ -155,29 +157,34 @@ url(http://sunsite.auc.dk/zsh/FAQ/)(http://sunsite.auc.dk/zsh/FAQ/) . The site also contains some contributed zsh scripts and functions; we are delighted to add more, or simply links to your own collection. - This document was originally written in YODL, allowing it to be - converted easily into various other formats. The master source - file lives at url(http://sunsite.auc.dk/zsh/FAQ/zshfaq.yo) -(http://sunsite.auc.dk/zsh/FAQ/zshfaq.yo) . + This document was originally written in YODL, allowing it to be converted + easily into various other formats. The master source file lives at + url(http://sunsite.auc.dk/zsh/FAQ/zshfaq.yo) +(http://sunsite.auc.dk/zsh/FAQ/zshfaq.yo) and the plain text version + can be found at url(http://sunsite.auc.dk/zsh/FAQ/zshfaq.txt) +(http://sunsite.auc.dk/zsh/FAQ/zshfaq.txt) . Another useful source of information is the collection of FAQ articles posted frequently to the Usenet news groups comp.unix.questions, comp.unix.shells and comp.answers with answers to general questions about UNIX. The fifth of the seven articles deals with shells, - including zsh, with a brief description of differences. (This article - also talks about shell startup files which would otherwise rate a - mention here.) There is also a separate FAQ on shell differences - and how to change your shell. Usenet FAQs are available via FTP - from rtfm.mit.edu and mirrors and also on the World Wide Web; see + including zsh, with a brief description of differences. There is + also a separate FAQ on shell differences and how to change your + shell. Usenet FAQs are available via FTP from rtfm.mit.edu and + mirrors and also on the World Wide Web; see description( mydit(USA) url(http://www.cis.ohio-state.edu/hypertext/faq/usenet/top.html) (http://www.cis.ohio-state.edu/hypertext/faq/usenet/top.html) mydit(UK) url(http://www.lib.ox.ac.uk/internet/news/faq/comp.unix.shell.html) (http://www.lib.ox.ac.uk/internet/news/faq/comp.unix.shell.html) - mydit(Netherlands) url(http://www.cs.ruu.nl/wais/html/na-dir/unix-faq/shell/.html) - (http://www.cs.ruu.nl/wais/html/na-dir/unix-faq/shell/.html) + mydit(Netherlands) url(http://www.cs.uu.nl/wais/html/na-dir/unix-faq/shell/.html) + (http://www.cs.uu.nl/wais/html/na-dir/unix-faq/shell/.html) ) + You can also get it via email by emailing \ +email(mail-server@rtfm.mit.edu) + with, in the body of the message, mytt(send faqs/unix-faq/shell/zsh). + The latest version of this FAQ is also available directly from any of the zsh archive sites listed in question link(1.6)(16). @@ -271,10 +278,9 @@ sect(On what machines will it run?) If you need to change something to support a new machine, it would be appreciated if you could add any necessary preprocessor code and - alter configure.in and config.h.in to configure zsh automatically, + alter configure.in and acconfig.h to configure zsh automatically, then send the required context diffs to the list (see question - link(5.2)(52)). Changes based on version 2.5 are very unlikely to - be useful. + link(5.2)(52)). Please make sure you have the latest version first. To get it to work, retrieve the source distribution (see question link(1.6)(16)), un-gzip it, un-tar it and read the INSTALL file in the top @@ -289,18 +295,21 @@ sect(On what machines will it run?) sect(What's the latest version?) - Zsh 3.0.5 is the latest production version. The new major number 3.0 - largely reflects the considerable internal changes in zsh to make it - more reliable, consistent and (where possible) compatible. Those - planning on upgrading their zsh installation should take a look at - the list of incompatibilities at the end of link(5.1)(51). This is - longer than usual due to enhanced sh, ksh and POSIX compatibility. - - The beta version 3.1.4 is also available. Development of zsh is - usually patch by patch, with each intermediate version publicly - available. Note that this `open' development system does mean bugs - are sometimes introduced into the most recent archived version. - These are usually fixed quickly. + Zsh 3.0.7 is the latest production version. The new major number 3.0 + largely reflects the considerable internal changes in zsh to make it more + reliable, consistent and (where possible) compatible. Those planning on + upgrading their zsh installation should take a look at the list of + incompatibilities at the end of link(5.1)(51). This is longer than usual + due to enhanced sh, ksh and POSIX compatibility. + + The beta version 3.1.6 is also available. Development of zsh is usually + patch by patch, with each intermediate version publicly available. Note + that this `open' development system does mean bugs are sometimes + introduced into the most recent archived version. These are usually + fixed quickly. If you are really interested in getting the latest + improvements, and less worried about providing a stable environment, + development versions are uploaded quite frequently to the archive in the + tt(development) subdirectory. Note also that as the shell changes, it may become incompatible with older versions; see the end of question link(5.1)(51) for a partial list. @@ -313,17 +322,20 @@ sect(What's the latest version?) sect(Where do I get it?) label(16) - The archive is now run by email(Andrew Main <zefram@tao.co.uk>). - The following are known mirrors (kept frequently up to date); the + The coordinator of development is currently me; the alias + email(coordinator@zsh.org) can be used to contact whoever is in the hot + seat. The following are known mirrors (kept frequently up to date); the first is the official archive site, currently in Australia. All are - available by anonymous FTP. The major sites keep test versions in - the 'testing' subdirectory: such up-to-the-minute development - versions should only be retrieved if you actually plan to help test - the latest version of the shell. The following list also appears - on the WWW at url(http://www.zsh.org)(http://www.zsh.org) . + available by anonymous FTP. The major sites keep test versions in the + `testing' subdirectory: such up-to-the-minute development versions should + only be retrieved if you actually plan to help test the latest version of + the shell. The following list also appears on the WWW at + url(http://www.zsh.org)(http://www.zsh.org) . description( mydit(Home site) url(ftp://ftp.zsh.org)(ftp://ftp.zsh.org) + mydit() url(http://www.zsh.org/pub/zsh/) +(http://www.zsh.org/pub/zsh/) mydit(Australia) url(ftp://ftp.ips.gov.au/mirror/zsh/) (ftp://ftp.ips.gov.au/mirror/zsh/) mydit(Denmark) url(ftp://sunsite.auc.dk/pub/unix/shells/zsh) @@ -334,45 +346,51 @@ label(16) (ftp://ftp.cenatls.cena.dgac.fr/pub/shells/zsh/) mydit(Germany) url(ftp://ftp.fu-berlin.de/pub/unix/shells/zsh/) (ftp://ftp.fu-berlin.de/pub/unix/shells/zsh/) - mydit() url(ftp://ftp.gmd.de/packages/zsh/) -(ftp://ftp.gmd.de/packages/zsh/) mydit() url(ftp://ftp.uni-trier.de/pub/unix/shell/zsh/) (ftp://ftp.uni-trier.de/pub/unix/shell/zsh/) mydit(Hungary) url(ftp://ftp.cs.elte.hu/pub/zsh/) (ftp://ftp.cs.elte.hu/pub/zsh/) mydit() (also url(http://www.cs.elte.hu/pub/zsh/) - (http://www.cs.elte.hu/pub/zsh/) ) +(http://www.cs.elte.hu/pub/zsh/) ) + mydit() url(ftp://ftp.kfki.hu/pub/packages/zsh/) +(ftp://ftp.kfki.hu/pub/packages/zsh/) mydit(Israel) \ url(ftp://ftp.math.technion.ac.il/mirror/ftp.zsh.org/pub/zsh/) (ftp://ftp.math.technion.ac.il/mirror/ftp.zsh.org/pub/zsh/) mydit() \ url(http://www.math.technion.ac.il/mirror/ftp.zsh.org/pub/zsh/) (http://www.math.technion.ac.il/mirror/ftp.zsh.org/pub/zsh/) - mydit(Japan) url(ftp://ftp.tohoku.ac.jp/mirror/zsh/) -(ftp://ftp.tohoku.ac.jp/mirror/zsh/) - mydit() url(ftp://ftp.nis.co.jp/pub/shells/zsh/) + mydit(Italy) url(ftp://ftp.unina.it/pub/Unix/pkgs/shell/zsh/) +(ftp://ftp.unina.it/pub/Unix/pkgs/shell/zsh/) + mydit(Japan) url(ftp://ftp.nisiq.net/pub/shells/zsh/) (ftp://ftp.nis.co.jp/pub/shells/zsh/) + mydit() url(ftp://ftp.win.ne.jp/pub/shell/zsh/) +(ftp://ftp.win.ne.jp/pub/shell/zsh/) mydit(Norway) url(ftp://ftp.uit.no/pub/unix/shells/zsh/) (ftp://ftp.uit.no/pub/unix/shells/zsh/) + mydit(Poland) url(ftp://sunsite.icm.edu.pl/pub/unix/shells/zsh/) +(ftp://sunsite.icm.edu.pl/pub/unix/shells/zsh/) mydit(Romania) url(ftp://ftp.roedu.net/pub/mirrors/ftp.zsh.org/pub/zsh/) (ftp://ftp.roedu.net/pub/mirrors/ftp.zsh.org/pub/zsh/) - mydit(Slovenia) url(ftp://ftp.siol.net/pub/unix/shells/zsh/) -(ftp://ftp.siol.net/pub/unix/shells/zsh/) + mydit() url(ftp://ftp.kappa.ro/pub/mirrors/ftp.zsh.org/pub/zsh/) +(ftp://ftp.kappa.ro/pub/mirrors/ftp.zsh.org/pub/zsh/) + mydit(Slovenia) url(ftp://ftp.siol.net/mirrors/zsh/) +(ftp://ftp.siol.net/mirrors/zsh/) mydit(Sweden) url(ftp://ftp.lysator.liu.se/pub/unix/zsh/) (ftp://ftp.lysator.liu.se/pub/unix/zsh/) mydit(UK) url(ftp://ftp.net.lut.ac.uk/zsh/) (ftp://ftp.net.lut.ac.uk/zsh/) mydit() (also by FSP at port 21) - mydit() url(ftp://src.doc.ic.ac.uk/packages/unix/shells/zsh/) -(ftp://src.doc.ic.ac.uk/packages/unix/shells/zsh/) - mydit(USA) url(ftp://ftp.math.gatech.edu/pub/zsh/) -(ftp://ftp.math.gatech.edu/pub/zsh/) - mydit() url(ftp://uiarchive.uiuc.edu/pub/packages/shells/zsh/) + mydit() url(ftp://sunsite.org.uk/packages/zsh/) +(ftp://sunsite.org.uk/packages/zsh/) + mydit(USA) url(ftp://uiarchive.uiuc.edu/pub/packages/shells/zsh/) (ftp://uiarchive.uiuc.edu/pub/packages/shells/zsh/) - mydit() url(ftp://ftp.sterling.com/zsh/) -(ftp://ftp.sterling.com/zsh/) mydit() url(ftp://ftp.rge.com/pub/shells/zsh/) (ftp://ftp.rge.com/pub/shells/zsh/) + mydit() url(ftp://foad.org/pub/zsh/) +(ftp://foad.org/pub/zsh/) + mydit() url(http://foad.org/zsh/) +(http://foad.org/zsh/) ) The Windows port mentioned above is maintained separately by email(Amol @@ -449,7 +467,6 @@ sect(I don't have root access: how do I make zsh my login shell?) endif ) - It's not a good idea to put this (even without the -l) into .cshrc, at least without some tests on what the csh is supposed to be doing, as that will cause _every_ instance of csh to turn into a zsh and @@ -513,18 +530,21 @@ label(21) The classic difference is word splitting, discussed in link(3.1)(31); this catches out very many beginning zsh users. As explained there, this is actually a bug in every other shell. The answer is to set - SH_WORD_SPLIT for backward compatibility. The next most classic + tt(SH_WORD_SPLIT) for backward compatibility. The next most classic difference is that unmatched glob patterns cause the command to - abort; set NO_NOMATCH for those. + abort; set tt(NO_NOMATCH) for those. Here is a list of various options which will increase ksh compatibility, though maybe decrease zsh's abilities: see the manual - entries for GLOB_SUBST, IGNORE_BRACES (though brace expansion occurs - in some versions of ksh), KSH_ARRAYS, KSH_GLOB, KSH_OPTION_PRINT, - LOCAL_OPTIONS, NO_BAD_PATTERN, NO_BANG_HIST, NO_EQUALS, NO_HUP, - NO_NOMATCH, NO_RCS, NO_SHORT_LOOPS, PROMPT_SUBST, RM_STAR_SILENT, - POSIX_BUILTINS, SH_FILE_EXPANSION, SH_GLOB, SH_OPTION_LETTERS, - SH_WORD_SPLIT (see question link(3.1)(31)) and SINGLE_LINE_ZLE. + entries for tt(GLOB_SUBST), tt(IGNORE_BRACES) (though brace expansion occurs + in some versions of ksh), tt(KSH_ARRAYS), tt(KSH_GLOB), tt(KSH_OPTION_PRINT), + tt(LOCAL_OPTIONS), tt(NO_BAD_PATTERN), tt(NO_BANG_HIST), tt(NO_EQUALS), \ +tt(NO_HUP,) + tt(NO_NOMATCH), tt(NO_RCS), tt(NO_SHORT_LOOPS), tt(PROMPT_SUBST), \ +tt(RM_STAR_SILENT), + tt(POSIX_BUILTINS), tt(SH_FILE_EXPANSION), tt(SH_GLOB), \ +tt(SH_OPTION_LETTERS), + tt(SH_WORD_SPLIT) (see question link(3.1)(31)) and tt(SINGLE_LINE_ZLE). Note that you can also disable any built-in commands which get in your way. If invoked as `ksh', the shell will try and set suitable options. @@ -545,7 +565,7 @@ label(21) subscripts start at 1, not 0; tt(array[0]) refers to tt(array[1]); mytt($array) refers to the whole array, not tt($array[0]); braces are unnecessary: tt($a[1] == ${a[1]}), etc. - The KSH_ARRAYS option is now available. + The tt(KSH_ARRAYS) option is now available. it() Coprocesses are established by mytt(coproc); mytt(|&) behaves like csh. Handling of coprocess file descriptors is also different. it() In mytt(cmd1 && cmd2 &), only mytt(cmd2) instead of the whole @@ -555,14 +575,10 @@ label(21) it() Command line substitutions, globbing etc.: itemize( it()* Failure to match a globbing pattern causes an error (use - NO_NOMATCH). + tt(NO_NOMATCH)). it()* The results of parameter substitutions are treated as plain text: - mytt(foo="*"; print $foo) prints all files in ksh but mytt(*) in zsh. - (GLOB_SUBST has been added to fix this.) - it() The backslash in tt($(echo '\$x')) is treated differently: in \ -ksh, it - is not stripped, in zsh it is. (The tt(`...`) form gives the same in - both shells.) + mytt(foo="*"; print $foo) prints all files in ksh but mytt(*) in zsh + (uset tt(GLOB_SUBST)). it()* tt($PSn) do not do parameter substitution by default (use \ PROMPT_SUBST). it()* Standard globbing does not allow ksh-style `pattern-lists'. @@ -580,9 +596,9 @@ PROMPT_SUBST). ---------------------------------------------------------------------- ) The mytt(^), mytt(~) and mytt(#) (but not mytt(|))forms require \ -EXTENDED_GLOB. +tt(EXTENDED_GLOB). From version 3.1.3, the ksh forms are fully supported when the - option KSH_GLOB is in effect; for previous versions you + option tt(KSH_GLOB) is in effect; for previous versions you must use the table above. [1] Note that mytt(~) is the only globbing operator to have a lower @@ -626,7 +642,8 @@ link(2.3)(23). ) it() Traps and signals: itemize( - it() Traps are not local to functions. + it()* Traps are not local to functions. The option LOCAL_TRAPS is + available from 3.1.6. it() TRAPERR has become TRAPZERR (this was forced by UNICOS which has SIGERR). ) @@ -641,6 +658,8 @@ link(2.3)(23). release either.) it() Management of histories in multiple shells is different: the history list is not saved and restored after each command. + The option tt(SHARE_HISTORY) appeared in 3.1.6 and is set in ksh + compatibility mode to remedy this. it() mytt(\) does not escape editing chars (use mytt(^V)). it() Not all ksh bindings are set (e.g. mytt(<ESC>#); try mytt(<ESC>q)). it()* mytt(#) in an interactive shell is not treated as a comment by @@ -677,7 +696,7 @@ sect(Similarities with csh) it() tt(*rc) file for interactive shells. it() Directory stacks. it() tt(cshjunkie*), tt(ignoreeof) options. - it() The CSH_NULL_GLOB option. + it() The tt(CSH_NULL_GLOB) option. it() tt(>&), tt(|&) etc. redirection. (Note that mytt(>file 2>&1) is the standard Bourne shell command for csh's mytt(>&file).) @@ -720,12 +739,12 @@ label(23) ) can be replaced by the zsh function, verb( - cd() { builtin cd $*; echo $PWD; } + cd() { builtin cd "$@"; echo $PWD; } ) (the `builtin' tells zsh to use its own `cd', avoiding an infinite loop) or, perhaps better, verb( - cd() { builtin cd $*; print -D $PWD; } + cd() { builtin cd "$@"; print -D $PWD; } ) (which converts your home directory to a tt(~)). In fact, this problem is better solved by defining the special function chpwd() (see the manual). @@ -734,7 +753,6 @@ label(23) Here is Bart Schaefer's guide to converting csh aliases for zsh. - SETCOUNTER(XXenumcounter)(0) enumerate( myeit() If the csh alias references "parameters" (tt(\!:1), tt(\!*) etc.), then in zsh you need a function (referencing tt($1), tt($*) etc.). @@ -746,7 +764,7 @@ label(23) myeit() If the csh alias references its own name (tt(alias rm "rm -i")), then in a zsh function you need the "command" keyword - (function tt(rm() { command rm -i $* })), but in a zsh alias + (function tt(rm() { command rm -i "$@" })), but in a zsh alias you don't (tt(alias rm="rm -i")). myeit() If you have aliases that refer to each other (tt(alias ls "ls -C"; @@ -761,7 +779,7 @@ label(23) heavy csh alias junkies: myeit() Mapping from csh alias "parameter referencing" into zsh function - (assuming shwordsplit and ksharrays are NOT set in zsh): + (assuming tt(SH_WORD_SPLIT) and tt(KSH_ARRAYS) are NOT set in zsh): verb( csh zsh ===== ========== @@ -773,7 +791,7 @@ label(23) \!:1-4 $*[1,4] \!:1- $*[1,$#-1] (or $*[1,-2]) \!^- $*[1,$#-1] - \!*:q "$@" ($*:q doesn't work (yet)) + \!*:q "$@" \!*:x $=* ($*:x doesn't work (yet)) ) @@ -799,7 +817,7 @@ label(23) There is one other serious problem with aliases: consider verb( alias l='/bin/ls -F' - l() { /bin/ls -la $* | more } + l() { /bin/ls -la "$@" | more } ) mytt(l) in the function definition is in command position and is expanded as an alias, defining mytt(/bin/ls) and mytt(-F) as functions which call @@ -844,7 +862,17 @@ sect(Similarities with tcsh) verb( bindkey '\eq' push-input ) - to save the entire buffer. + to save the entire buffer. In recent versions of zsh 3.1, you have + the following more sophisticated option, + verb( + run-fg-editor() { + zle push-input + BUFFER="fg %$EDITOR:t" + zle accept-line + } + zle -N run-fg-editor + ) + and can now bind tt(run-fg-editor) just like any other editor function. sect(Similarities with bash) @@ -868,7 +896,7 @@ sect(Shouldn't zsh be more/less like ksh/(t)csh?) would have features familiar to csh users. For a long time, csh was the preferred interactive shell and there is a strong resistance to changing to something unfamiliar, hence the additional syntax and - CSH_JUNKIE options. This argument still holds. On the other hand, + tt(CSH_JUNKIE) options. This argument still holds. On the other hand, the arguments for having what is close to a plug-in replacement for ksh are, if anything, even more powerful: the deficiencies of csh as a programming language are well known (look in any Usenet FAQ archive, e.g. @@ -896,8 +924,8 @@ label(31) ) are split into words when passed to a command or used in a mytt(for foo in $var) loop. By default, zsh does not have that behaviour: the - variable remains intact. (This is not a bug! See below.) An option - (SHWORDSPLIT) exists to provide compatibility. + variable remains intact. (This is not a bug! See below.) The option + tt(SH_WORD_SPLIT) exists to provide compatibility. For example, defining the function args to show the number of its arguments: @@ -931,7 +959,7 @@ label(31) verb( args $array ) - produces the output `4', regardless of the setting of SHWORDSPLIT. + produces the output `4', regardless of the setting of tt(SH_WORD_SPLIT). Arrays are also much more versatile than single strings. Probably if this mechanism had always been available there would never have been automatic word splitting in scalars, which is a sort of @@ -950,23 +978,78 @@ label(31) after which $words is an array with the words of $sentence (note characters special to the shell, such as the mytt(') in this example, must already be quoted), or, less standard but more reliable, - turning on SHWORDSPLIT for one variable only: + turning on tt(SH_WORD_SPLIT) for one variable only: verb( args ${=sentence} ) always returns 8 with the above definition of mytt(args). (In older - versions of zsh, tt(${=foo}) toggled SHWORDSPLIT; now it forces it on.) + versions of zsh, tt(${=foo}) toggled tt(SH_WORD_SPLIT); now it forces it on.) Note also the tt("$@") method of word splitting is always available in zsh functions and scripts (though strictly this does array splitting, not - word splitting). + word splitting). This is more portable than the tt($*), since it + will work regardless of the tt(SH_WORD_SPLIT) setting; the other + difference is that tt($*) removes empty arguments from the array. + You can fix the first half of that objection by using tt(${==*}), + which turns off tt(SH_WORD_SPLIT) for the duration of the expansion. - SHWORDSPLIT is set when zsh is invoked with the names `ksh' or `sh', + tt(SH_WORD_SPLIT) is set when zsh is invoked with the names `ksh' or `sh', or (entirely equivalent) when mytt(emulate ksh) or mytt(emulate sh) is in effect. -sect(What is the difference between `export' and the ALL_EXPORT option?) +sect(In which startup file do I put...?) + + When zsh starts up, there are four files you can change which it will + run under various circumstances: tt(.zshenv), tt(.zprofile), tt(.zshrc) + and tt(.zlogin). They are usually in your home directory, but the + variable tt($ZDOTDIR) may be set to alter that. Here are a few simple + hints about how to use them. There are also files which the system + administrator can set for all shells; you can avoid running all except + tt(/etc/zshenv) by starting zsh with the tt(-f) option --- for this + reason it is important for administrators to make sure tt(/etc/zshenv) + is as brief as possible. + + The order in which the four files are searched (none of them myem(need) + to exist) is the one just given. However, tt(.zprofile) and tt(.zlogin) + are only run when the shell is a login shell --- when you first login, + of course, and whenever you start zsh with the tt(-l) option. All + login shells are interactive. The order is the only difference + between those; you should decide whether you need things set before or + after tt(.zshrc). These files are a good place to set environment + variables (i.e. mytt(export) commands), since they are passed on to + all shells without you having to set them again, and also to check + that your terminal is set up properly (except that if you want to + change settings for terminal emulator windows like tt(xterm) you will + need to put those in tt(.zshrc), since usually you do not get a login + shell here). + + The only file you can alter which is started with every zsh (unless + you use the tt(-f) option) is tt(.zshenv), so this is a good place to \ + put + things you want even if the shell is non-interactive: options for + changing the the syntax, like tt(EXTENDED_GLOB), any changes to set with + mytt(limit), any more variables you want to make sure are set as for + example tt($fpath) to find functions. You almost certainly do not + want tt(.zshenv) to produce any output. Some people prefer not to + use tt(.zshenv) for setting options, as this affects scripts; but + making zsh scripts portable usually requires special handling anyway. + + Finally, tt(.zshrc) is run for every interactive shell; that includes + login shells, but also any other time you start up a shell, such as + simply by typing mytt(zsh) or opening a new terminal emulator window. + This file is the place to change the editing behaviour via options or + mytt(bindkey), control how your history is saved, set aliases unless + you want to use them in scripts too, and for any other clutter which + can't be exported but you only use when interacting directly with the + shell. You probably don't want tt(.zshrc) to produce output, either, + since there are occasions when this can be a problem, such as when + using mytt(rsh) from another host. See link(3.21)(321) for what to \ + put in tt(.zshrc) + to save your history. + + +sect(What is the difference between `export' and the tt(ALL_EXPORT) option?) Normally, you would put a variable into the environment by using mytt(export var). The command mytt(setopt allexport) causes all @@ -975,7 +1058,6 @@ sect(What is the difference between `export' and the ALL_EXPORT option?) This may seem a useful shorthand, but in practice it can have unhelpful side effects: - SETCOUNTER(XXenumcounter)(0) enumerate( myeit() Since every variable is in the environment as well as remembered by the shell, the memory for it needs to be allocated twice. @@ -986,7 +1068,7 @@ sect(What is the difference between `export' and the ALL_EXPORT option?) meaning to a command. Since all shell variables are visible to commands, there is no protection against this. ) - For these reasons it is usually best to avoid ALL_EXPORT unless you + For these reasons it is usually best to avoid tt(ALL_EXPORT) unless you have a specific use for it. One safe use is to set it before creating a list of variables in an initialisation file, then unset it immediately afterwards. Only those variables will be automatically @@ -1019,7 +1101,7 @@ sect(How do I turn off spelling correction/globbing for a single command?) sect(How do I get the meta key to work on my xterm?) -label(34) +label(35) As stated in the manual, zsh needs to be told about the meta key by using mytt(bindkey -me) or mytt(bindkey -mv) in your .zshrc or on the @@ -1046,7 +1128,7 @@ sect(How do I automatically display the directory in my xterm title bar?) You should use the special function mytt(chpwd), which is called when the directory changes. The following checks that standard output is a terminal, then puts the directory in the title bar if the terminal - is an tt(xterm) or a tt(sun-cmd). + is an tt(xterm) or some close relative, or a tt(sun-cmd). verb( chpwd() { @@ -1054,7 +1136,7 @@ sect(How do I automatically display the directory in my xterm title bar?) case $TERM in sun-cmd+CHAR(41) print -Pn "\e]l%~\e\\" ;; - xterm+CHAR(41) print -Pn "\e]2;%~\a" + *xterm*|rxvt|(dt|k|E)term+CHAR(41) print -Pn "\e]2;%~\a" ;; esac } @@ -1071,36 +1153,16 @@ sect(How do I automatically display the directory in my xterm title bar?) sect(How do I make the completion list use eight bit characters?) - A traditional UNIX environment (character terminal and ASCII - character sets) is not sufficient to be able to handle non-ASCII - characters, and there are so many possible enhancements that in - general this is hard. However, if you have something like an xterm - using a standard character set like ISO-8859-1 (which is often the - default for xterm), read on. You should also note question - link(3.4)(34) on the subject of eight bit characters. - - You are probably creating files with names including non-ASCII - accented characters, and find they show up in the completion list as - verb(\M-i) or something such. This is because the library routines - (not zsh itself) which test whether a character is printable have - replied that it is not; zsh has simply found a way to show them - anyway. - - The answer, under a modern POSIXy operating system, is to find a - locale where these are treated as printable characters. Zsh has - handling for locales built in and will recognise when you set a - relevant variable. You need to look in /usr/lib/locale to find one - which suits you; the subdirectories correspond to the locale names. - The simplest possibility is likely to be en_US, so that the simplest - answer to your problem is to set - - verb( - LC_CTYPE=en_US - ) - - when your terminal is capable of showing eight bit characters. If - you only have a default domain (called C), you may need to have some - additional files installed on your system. + If you are sure your terminal handles this, the easiest way from versions + 3.0.6 and 3.1 of the shell is to set the option tt(PRINT_EIGHT_BIT). In + principle, this will work automatically if your computer uses the + `locale' system and your locale variables are set properly, as zsh + understands this. However, it is quite complicated, so if it isn't + already set up, trying the option is a lot easier. For earlier versions + of zsh 3, you are stuck with trying to understand locales, see the + tt(setlocale(3)) and tt(zshparam(1)) manual pages: the simplest + possibility may be to set tt(LC_ALL=en_US). For older versions of the + shell, there is no easy way out. sect(Why do the cursor (arrow) keys not work?) @@ -1150,6 +1212,13 @@ sect(Why does my terminal act funny in some way?) from hiccups introduced by other programmes (kermit has been known to do this). + A problem I have experienced myself (on an AIX 3.2 workstation with + xterm) is that termcap deinitialization sequences sent by `less' + were causing automargins to be turned off --- not actually a shell + problem, but you might have thought it was. The fix is to put `tt(X)' + into the environment variable tt(LESS) to stop the sequences being sent. + Other programs (though not zsh) may also send that sequence. + If myem(that)'s not the problem, and you are having difficulties with external commands (not part of zsh), and you think some terminal setting is wrong (e.g. tt(^V) is getting interpreted as `literal next @@ -1163,12 +1232,6 @@ sect(Why does my terminal act funny in some way?) modes it uses itself and a number of special processing characters (see the tt(stty(1)) manual page). - At some point there may be an overhaul which allows the terminal - modes used by the shell to be modified separately from those seen by - external programmes. This is partially implemented already: from 2.5, - the shell is less susceptible to mode changes inherited from - programmes than it used to be. - sect(Why does zsh not work in an Emacs shell mode any more?) @@ -1205,7 +1268,6 @@ sect(Why do my autoloaded functions not autoload [the first time]?) The problem is that there are two possible ways of autoloading a function (see the AUTOLOADING FUNCTIONS section of the zsh manual page zshmisc for more detailed information): - SETCOUNTER(XXenumcounter)(0) enumerate( myeit() The file contains just the body of the function, i.e. there should be no line at the beginning saying mytt(function foo {) @@ -1232,7 +1294,7 @@ sect(Why do my autoloaded functions not autoload [the first time]?) incompatible with the old zsh behaviour which allowed you to redefine the function when you called it. - From version 3.1, there is an option KSHAUTOLOAD to allow full ksh + From version 3.1, there is an option tt(KSH_AUTOLOAD) to allow full ksh compatiblity, i.e. the function myem(must) be in the second form above. If that is not set, zsh tries to guess which form you are using: if the file contains only a complete definition of the @@ -1259,9 +1321,9 @@ sect(How does base arithmetic work?) ) or even verb( - foo=$[16#ff] + foo=$((16#ff)) ) - (note that `foo=$((16#ff))' is now supported). The original syntax was + The original syntax was verb( (( foo = [16]ff )) ) @@ -1288,6 +1350,7 @@ sect(How does base arithmetic work?) sect(How do I get a newline in my prompt?) +label(313) You can place a literal newline in quotes, i.e. verb( @@ -1299,13 +1362,14 @@ sect(How do I get a newline in my prompt?) mytt(unsetopt cshjunkiequotes) and mytt(setopt cshjunkiequotes), or put it in your tt(.zshrc) before the option is set. - Arguably the prompt code should handle `print'-like escapes. Feel - free to write this :-CHAR(41). Otherwise, you can use + In all recent versions of zsh, there is a form of quoting which will + interpret print sequences like `tt(\n)' but otherwise acts like single + quotes: surround the string with tt($'...'). Hence: verb( - PROMPT=$(print "Hi Joe,\nwhat now?%# ") + PROMPT=$'Hi Joe,\nwhat now?%# ' ) - in your initialisation file. - + is a neat way of doing what you want. Note that it is the quotes, not + the prompt expansion, which turns the `tt(\n)' into a newline. sect(Why does mytt(bindkey ^a command-name) or mytt(stty intr ^-) do something funny?) @@ -1324,7 +1388,7 @@ sect(Why can't I bind tt(\C-s) and tt(\C-q) any more?) settings.) In other words, tt(\C-s) stops all output to the terminal, while tt(\C-q) resumes it. - There is an option NO_FLOW_CONTROL to stop zsh from allowing flow + There is an option tt(NO_FLOW_CONTROL) to stop zsh from allowing flow control and hence restoring the use of the keys: put mytt(setopt noflowcontrol) in your tt(.zshrc) file. @@ -1346,7 +1410,7 @@ sect(Why do history substitutions with single bangs do something funny?) If you have a command like "tt(echo !-2:$ !$)", the first history substitution then sets a default to which later history substitutions with single unqualified bangs refer, so that !$ becomes equivalent to - tt(!-2:$). The option CSH_JUNKIE_HISTORY makes all single bangs refer + tt(!-2:$). The option tt(CSH_JUNKIE_HISTORY) makes all single bangs refer to the last command. @@ -1433,6 +1497,7 @@ work?) sect(Why is my history not being saved?) +label(321) In zsh, you need to set three variables to make sure your history is written out when the shell exits. For example, @@ -1449,6 +1514,94 @@ sect(Why is my history not being saved?) manual. +sect(How do I get a variable's value to be evaluated as another variable?) + + The problem is that you have a variable tt($E) containing the string + mytt(EDITOR), and a variable tt($EDITOR) containing the string mytt(emacs), + or something such. How do you get from tt($E) to emacs in one easy + stage? + + There is no standard single-stage way of doing this. However, there + is a zsh idiom (available in all versions of zsh since 3.0) for this: + verb( + print ${(e)E:+\$$E} + ) + Ignore the mytt((e)) for now. The mytt(:+) means: if the variable + tt($E) is set, substitute the following, i.e. mytt(\$$E). This is + expanded to mytt($EDITOR) by the normal rules. Finally, the mytt((e)) \ + means: + evaluate the expression you just made. This gives mytt(emacs). + + For a standard shell way of doing this, you are stuck with mytt(eval): + verb( + eval echo \$$E + ) + produces the same result. + + Versions 3.1.6 of allows you to do this directly with a new flag; + mytt(${(P)E}). + + As a slight aside, sometimes people note that the syntax mytt(${${E}}) + is valid and expect it to have this effect. It probably ought to, but + in the early days of zsh it was found convenient to have this way of + producing different substitutions on the same parameter; for example, + mytt(${${file##**/}%.*}) removes everything up to the last slash in + mytt($file), then everything from the last dot on, inclusive (try + it, this works). So in mytt(${${E}}), the internal mytt(${...}) + actually does nothing. + + +sect(How do I prevent the prompt overwriting output when there is no newline?) + + The problem is, for example, + verb( + % echo -n foo + % + ) + and the tt(foo) has been overwritten by the prompt tt(%). The answer is + simple: put tt(unsetopt promptcr) in your tt(.zshrc). The option \ + tt(PROMPT_CR), + to print a carriage return before a new prompt, is set by default because + a prompt at the right hand side (mytt($RPROMPT), mytt($RPS1)) will not appear + in the right place, and multi-line editing will be confused about the line + position, unless the line starts in the left hand column. Apart from + tt(PROMPT_CR), you can force this to happen by putting a newline in the + prompt (see question link(3.13)(313) for that). + + +sect(What's wrong with cut and paste on my xterm?) + + On the majority of modern UNIX systems, cutting text from one window and + pasting it into another should work fine. On a few, however, there are + problems due to issues about how the terminal is handled: most programs + expect the terminal to be in `canonical input mode', which means that the + program is passed a whole line of input at a time, while for editing + the shell needs a single character at a time and must be in + `non-canonical input mode'. On the systems in question, input can be + lost or re-ordered when the mode changes. There are actually two + slightly different problems: + enumerate( + myeit() When you paste something in while a programme is running, so that + the shell only retrieves it later. Traditionally, there was a test + which was used only on systems where the problem was known to exist, + so it is possible some other systems were not handled (for example, + certain versions of IRIX, it appears); also, continuation lines were + not handled properly. A more reliable approach appears from versions + 3.0.6 and 3.1.6. + myeit() When the shell is waiting for input, and you paste in a chunk of + text consisting of more than one complete set of commands. + Unfortunately, this is a much harder problem: the line editor is + already active, and needs to be turned off when the first command is + executed. The shell doesn't even know if the remaining text is input + to a command or for the shell, so there's simply nothing it can do. + However, if you have problems you can trick it: type `tt({)' on a line + by itself, then paste the input, then type `tt(})' on a line by + itself. The shell will not execute anything until the final brace is + read; all input is read as continuation lines (this may require the + fixes referred to above in order to be reliable). + ) + + chapter(The mysteries of completion) Programmable completion using the `compctl' command is one of the most @@ -1457,6 +1610,16 @@ a short introduction. There is a set of example completions supplied with the source in Misc/compctl-examples; completion definitions for many of the most obvious commands can be found there. +If this confuses you, you may like to know that there is a new, more +elegant completion system which appeared in version 3.1.6. This is based +on functions called automatically for completion in particular contexts +(for example, there is a function called tt(_cd) to handle completion for +the tt(cd) command) and is installed automatically with the shell, so all +you need to do, in principal, is to arrange for this to be loaded. Putting +`tt(autoload -U compinit; compinit)' in your tt(.zshrc) should be enough if +the system is installed properly. The rest of this section talks about the +old completion system. + sect(What is completion?) `Completion' is where you hit a particular command key (TAB is the @@ -1553,29 +1716,34 @@ sect(How does zsh deal with ambiguous completions?) flexibility for what it does here via its options. The default is for it to beep and completion to stop until you type another character. You can type tt(\C-D) to see all the possible completions. - (That's assuming your at the end of the line, otherwise tt(\C-D) will + (That's assuming you're at the end of the line, otherwise tt(\C-D) will delete the next character and you have to use tt(ESC-\C-D).) This can be changed by the following options, among others: itemize( - it() with nobeep set, that annoying beep goes away - it() with nolistbeep, beeping is only turned off for ambiguous completions - it() with autolist set, when the completion is ambiguous you get a + it() with tt(NO_BEEP) set, that annoying beep goes away + it() with tt(NO_LIST_BEEP), beeping is only turned off for ambiguous + completions + it() with tt(AUTO_LIST) set, when the completion is ambiguous you get a list without having to type tt(\C-D) - it() with listambigous, this is modified so that nothing is listed if - there is an unambiguous prefix or suffix to be inserted - it() with menucomplete set, one completion is always inserted + it() with tt(BASH_AUTO_LIST) set, the list only happens the second + time you hit tab on an ambiguous completion + it() with tt(LIST_AMBIGUOUS), this is modified so that nothing is listed if + there is an unambiguous prefix or suffix to be inserted --- this + can be combined with tt(BASH_AUTO_LIST), so that where both are + applicable you need to hit tab three times for a listing. + it() with tt(MENU_COMPLETE) set, one completion is always inserted completely, then when you hit TAB it changes to the next, and so on until you get back to where you started - it() with automenu, you only get the menu behaviour when you hit TAB + it() with tt(AUTO_MENU), you only get the menu behaviour when you hit TAB again on the ambiguous completion. it() Finally, although it affects all completion lists, including - those explicitly requested, note also alwayslastprompt, which + those explicitly requested, note also tt(ALWAYS_LAST_PROMPT), which causes the cursor to return to the line you were editing after printing the list, provided that is short enough. ) - Combinations of these are possible; for example, autolist and - automenu together give an intuitive combination. Note that - from version 3.1 listambiguous is set by default; if you use + Combinations of these are possible; for example, tt(AUTO_LIST) and + tt(AUTO_MENU) together give an intuitive combination. Note that + from version 3.1 tt(LIST_AMBIGUOUS) is set by default; if you use autolist, you may well want to `unsetopt listambiguous'. @@ -1608,7 +1776,7 @@ sect(How do I complete in the middle of words / just what's before the cursor?) ) then in the example you can move to just after mytt(/usr/loc), hit whatever key you've just bound, move to the end, and hit tab. - (Note that AUTO_REMOVE_SLASH behaviour applies here, see the manual.) + (Note that tt(AUTO_REMOVE_SLASH) behaviour applies here, see the manual.) Even that doesn't exhaust the possibilities. Included with the source distribution is the file tt(Functions/multicomp), a function @@ -1703,7 +1871,6 @@ label(45) Different conditions can also be combined. There are three levels of this (in decreasing order of precedence): - SETCOUNTER(XXenumcounter)(0) enumerate( myeit() multiple square brackets after a single condition give alternatives: for example, mytt(s[foo][bar]) says apply the @@ -1766,22 +1933,27 @@ this applies itemize( it() mytt(time) is ignored with builtins and can't be used with mytt({...}). - it() mytt(set -x) (mytt(setopt xtrace)) still has a few glitches. + it() When showing completion lists with exactly 80 columns, some + terminals print an extra newline which messes up zsh's logic. + it() mytt(set -x) (mytt(setopt xtrace)) still has a few glitches; these + are mostly fixed in 3.1.6. it() Zsh's notion of the current line number (via tt($LINENO)) is sometimes not well handled, particularly when using functions and traps. + This should also work reliably from 3.0.6 and 3.1.6. it() In vi mode, mytt(u) can go past the original modification point. it() The singlelinezle option has problems with prompts containing escapes. it() The mytt(r) command does not work inside mytt($(...)) or mytt(`...`) - expansions. (This is fixed in 3.1.) + expansions. This is fixed in 3.1. it() mytt(typeset) handling is non-optimal, particularly with regard to - flags, and is ksh-incompatible in unpredictable ways. + flags, and is ksh-incompatible in unpredictable ways. 3.1.6 has + been overhauled, but remaining glitches are to be expected. it() Nested closures in extended globbing and pattern matching, such as verb( [[ fofo = (fo#)# ]] ) were not correctly handled, and there were problems with - complicated exclusions using mytt(^) or mytt(~). (These - are fixed in version 3.1.3.) + complicated exclusions using mytt(^) or mytt(~). These + are fixed in version 3.1.3. ) Note that a few recent changes introduce incompatibilities (these @@ -1789,14 +1961,15 @@ this applies Changes after zsh 3.0 (3.1.x is still currently in beta): itemize( - it() The options ALWAYS_LAST_PROMPT (return to the line you were - editing after displaying completion lists) and LIST_AMBIGUOUS - (show matching files when there are several) are now set by - default. This is in response to complaints that too many zsh - features are never noticed by many users. To turn them off, + it() The options tt(ALWAYS_LAST_PROMPT) (return to the line you were + editing after displaying completion lists) and tt(LIST_AMBIGUOUS) + (don't do tt(AUTO_LIST) if there was an unambiguous prefix that could be + inserted, i.e. only list if it is ambiguous what to insert next) are + now set by default. This is in response to complaints that too many + zsh features are never noticed by many users. To turn them off, just put mytt(unsetopt alwayslastprompt listambiguous) in your tt(.zshrc) file. - it() tt(history-search-{forward,backward}) now only find previous + it() In 3.1.5, tt(history-search-{forward,backward}) only find previous lines where the first word is the same as the current one. For example, verb( @@ -1806,8 +1979,10 @@ this applies mytt(compress file) any more. For this reason, mytt(\M-n) and mytt(\M-p) use tt(history-beginning-search-{forward,backward}) which search for a line with the same prefix up to the cursor position. - It is possible to write functions which go a little closer to the - original behaviour; further changes are still possible. + From 3.1.6, there is a different implementation which makes this + closer (though not identical) to the old behaviour, and the + traditional bindings have been restored.. The story for the + tt({up,down}-line-or-search) commands is similar. it() In vi insert mode, the cursor keys no longer work. The following will bind them: COMMENT(-- note space after backslash --) @@ -1829,20 +2004,20 @@ this applies the environment of the caller, as in ksh, instead of as a new function level. Traps established as functions (e.g. mytt(TRAPINT() {...})) work as before. - it() The NO_CLOBBER option is now -C and PRINT_EXIT_VALUE -1; they used - to be the other way around. (Use of names rather than letters is + it() The tt(NO_CLOBBER) option is now -C and tt(PRINT_EXIT_VALUE) -1; they + used to be the other way around. (Use of names rather than letters is generally recommended.) it() mytt([[) is a reserved word, hence must be separated from other characters by whitespace; mytt({) and mytt(}) are also reserved - words if the IGNORE_BRACES option is set. - it() The option CSH_JUNKIE_PAREN has been removed: csh-like code now + words if the tt(IGNORE_BRACES) option is set. + it() The option tt(CSH_JUNKIE_PAREN) has been removed: csh-like code now always does what it looks like it does, so mytt(if ( ... ) ...) executes the code in parentheses in a subshell. To make this useful, the syntax expected after an mytt(if), etc., is less strict than in other shells. it() mytt(foo=*) does not perform globbing immediately on the right hand side of the assignment; the old behaviour now requires the - option GLOB_ASSIGN. (mytt(foo=(*)) is and has always been the + option tt(GLOB_ASSIGN). (mytt(foo=(*)) is and has always been the consistent way of doing this.) it() tt(<>) performs redirection of input and output to the specified file. For numeric globs, you now need tt(<->). @@ -1857,7 +2032,7 @@ this applies instead of tt(=)'s. This is for consistency: all other directory substitution (tt(~user), tt(~name), tt(~+), ...) used a tilde, while tt(=<number>) caused problems with tt(=program) substitution. - it() The `HISTLIT' option was broken in various ways and has been removed: + it() The tt(HISTLIT) option was broken in various ways and has been removed: the rewritten history mechanism doesn't alter history lines, making the option unnecessary. it() History expansion is disabled in single-quoted strings, like other @@ -1865,7 +2040,7 @@ this applies backslashed. it() The mytt($HISTCHARS) variable is now mytt($histchars). Currently both are tied together for compatibility. - it() The PROMPT_SUBST option now performs backquote expansion -- hence + it() The tt(PROMPT_SUBST) option now performs backquote expansion -- hence you should quote these in prompts. (SPROMPT has changed as a result.) it() Quoting in prompts has changed: close parentheses inside ternary expressions should be quoted with a tt(%); history is now tt(%!), not @@ -1879,13 +2054,18 @@ label(52) The shell is being maintained by various (entirely self-appointed) subscribers to the mailing list, verb( - zsh-workers@math.gatech.edu + zsh-workers@sunsite.auc.dk ) so mail on any issues (bug reports, suggestions, complaints...) related to the development of the shell should be sent there. If you want someone to mail you directly, say so. Most patches to zsh appear there first. + Note that this location has just changed (January 1999), and the + instructions to go with it are slightly different --- in particular, + if you are already subscribed, the instructions about how to + unsubscribe are different. + Please note when reporting bugs that many exist only on certain architectures, which the developers may not have access to. In this case debugging information, as detailed as possible, is @@ -1894,12 +2074,12 @@ label(52) Two progressively lower volume lists exist, one with messages concerning the use of zsh, verb( - zsh-users@math.gatech.edu + zsh-users@sunsite.auc.dk ) and one just containing announcements: about releases, about major changes in the shell, or this FAQ, for example, verb( - zsh-announce@math.gatech.edu + zsh-announce@sunsite.auc.dk ) (posting to the last one is currently restricted). @@ -1913,25 +2093,17 @@ label(52) To join zsh-workers, send email to verb( - zsh-workers-request@math.gatech.edu + zsh-workers-subscribe@sunsite.auc.dk ) - with the mybf(subject) line (this is a change from the old list) - verb( - subscribe <your-email-address> - ) - e.g. - verb( - Subject: subscribe P.Stephenson@swansea.ac.uk - ) - and you can unsubscribe in the same way. - The list maintainer, Richard Coleman, can be reached at - email(coleman@math.gatech.edu). - - The list from May 1992 to May 1995 is archived in - url(ftp://ftp.sterling.com/zsh/zsh-list/YY-MM) -(ftp://ftp.sterling.com/zsh/zsh-list/YY-MM) - where YY-MM are the year and month in digits. More recent - mailings up to date are to be found at + (the actual content is unimportant). Replace tt(subscribe) with + tt(unsubscribe) to unsubscribe. The mailing software (tt(ezlm)) has + various bells and whistles: you can retrieve archived messages. + Mail email(zsh-workers-help@sunsite.auc.dk) for detailed information. + Adminstrative matters are best sent to + email(zsh-workers-owner@sunsite.auc.dk). The list maintainer's + real name is email(Karsten Thygesen <karthy@kom.auc.dk>). + + An archive of mailings for the last few years can be found at url(http://www.zsh.org/mla/)(http://www.zsh.org/mla/) at the main zsh archive in Australia. @@ -1947,18 +2119,47 @@ sect(What's on the wish-list?) lexing/parsing/execution might also be an advantage. Volunteers are particularly welcome for these tasks. - An improved line editor, with user-definable functions and binding - of multiple functions to keystrokes, is being developed. - + Here are the latest changes, which appeared in zsh 3.1.6. + itemize( + it() Even more powerful new completion system, based on shell functions, + allowing much more detailed control both over generation of matches + for completion and how they are inserted and displayed. A set of + functions which work `out of the box' will be available, including + many functions for external commands: files in tar archives can + be listed for extraction as if they were real files; GNU commands + which accept the mytt(--help) option can generate completion lists for + themselves on the fly, etc., etc. + You can have old-style tt(compctl)-based completions for some commands, + and new-style ones for others; you can bind particular completion + commands of your own definition to key-strokes. + it() Other completion enhancements: matching control, allowing + case-insensitive matching and wild card anchors, e.g. mytt(z_t<TAB>) + can allow a wildcard before the mytt(_) so that this will expand + to mytt(zle_tricky.c) --- all under user control; completions can + be grouped; a new completion command, menu-select, allows real menu + selection --- you can move the cursor around to choose a completion. + it() Case-insensitive and approximate matching in the globbing code: + for example, mytt((#ia2)readme) matches the string mytt(readme) + case-insensitively with up to two errors, such as tt(README), + tt(READ.ME), tt(_README_), tt(Read!Me!). The new completion system + knows about these, allowing correcting completion, e.g. + mytt(mkaef<TAB>) can be made to complete to mytt(Makefile). + it() Associative arrays, declared with mytt(typeset -A aname); syntax + for creating, accessing and deleting elements of these. + it() Users can create their own tt(foopath)/tt(FOOPATH) array/path + combinations, just like tt(path) and tt(PATH). + it() A dynamically loadable library for FTP, complete with a suite of + functions to make it easy to use. This allows you to use the shell's + capabilities for scripting, line editing, completion, I/O redirection, + directory management etc. within an FTP session. + ) + + Other future possibilities which have been suggested: itemize( - it() Loadable module support (will be in 3.1 but much work still needs doing). + it() Further improvements in integrating the line editor with shell + functions. it() Ksh compatibility could be improved. it() Option for glob qualifiers to follow perl syntax (a traditional item). - it() Binding of shell functions to key strokes, accessing editing - buffer from functions, executing zle functions as a command: now - under development for 3.1. - it() Users should be able to create their own foopath/FOOPATH array/path - combinations. ) @@ -1996,17 +2197,18 @@ nsect(Acknowledgments:) Thanks to zsh-list, in particular Bart Schaefer, for suggestions regarding this document. Zsh has been in the hands of archivists Jim Mattson, Bas de Bakker, Richard Coleman, Zoltan Hidvegi and Andrew -Main, and the mailing list has been run by Peter Gray, Rick Ohnemus -and Richard Coleman, all of whom deserve thanks. The world is -eternally in the debt of Paul Falstad for inventing zsh in the first -place (though the wizzo extended completion is by Sven Wischnowsky). +Main, and the mailing list has been run by Peter Gray, Rick Ohnemus, +Richard Coleman and Karsten Thygesen, all of whom deserve thanks. The +world is eternally in the debt of Paul Falstad for inventing zsh in +the first place (though the wizzo extended completion is by Sven +Wischnowsky). nsect(Copyright Information:) This document is copyright (C) P.W. Stephenson, 1995, 1996, 1997, -1998. This text originates in the U.K. and the author asserts his -moral rights under the Copyrights, Designs and Patents Act, 1988. +1998, 1999, 2000. This text originates in the U.K. and the author asserts +his moral rights under the Copyrights, Designs and Patents Act, 1988. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this diff --git a/Etc/completion-style-guide b/Etc/completion-style-guide index 307954760..d57a1a7fb 100644 --- a/Etc/completion-style-guide +++ b/Etc/completion-style-guide @@ -1,44 +1,394 @@ -For now this is just a list of things one should or shouldn't do. - -1) Use the functions `_files' and `_path_files' instead of `compgen' - with the `-f', `-/', or `-g' options. -2) *Never* use `compgen' with the `-s' option. This can always be done - by a call to `compadd' which is faster. -3) Using `compgen' with the `-k' option should only be done if a) the - array is already existent or b) it is very large (several hundred - or thousend elements). In other cases using `compadd' is faster. -4) Supply match specifications to `compadd' and `compgen' if there are - sensible ones. -5) Use `_description' when adding matches with `compadd' or - `compgen'. Use `_message' in places where no matches can be - generated. If you want to add different types of matches, add them - with multiple calls to `compadd' or `compgen', supplying different - descriptions. -6) Use helper functions that do option completion for you (like - `_arguments' and `_long_options') -- it will make your life much +Contexts, tags and all that +--------------------------- + +The completion system keeps track of the current context in the +parameter `curcontext'. It's content is the hierarchical name for the +current context sans the `:completion:' and the last colon and the tag +currently tried. The tags represent different types of matches. So, +whenever you are about to add matches, you should use a tag for them +and test if the user wants this type of matches to be generated. +However, this only really needs to be done if no other function in the +call chain has tested that already or if you can offer different types +of matches or if you can handle tag aliases in some sophisticated way. + +Most of the utility functions do the testing themselves, so you don't +have to worry about that at all. For example if you are adding matches +with `_files', `_hosts' or functions like these, you can just call +them and they do the tests needed and the loops over the tag aliases. +The functions `_arguments' and `_values' do that too, but there is a +small difference. These functions effectively change the context +name and if you are using the `->state' form for actions, this changed +name component has to be reported back to the function calling +`_arguments' or `_values'. This is done with the parameter `context', +so you have to make that local in the calling function in the same way +as you have to make local `line', `state', and `{opt,val}_args'. This +parameter `context' should then be used when you start adding matches +by giving it to functions like `_tags' via the `-C' options, as in: + + local context ... + ... + _arguments ... '-foo:foo:->foo' + ... + if [[ "$state" = foo ]]; then + _tags -C "$context" ... + ... + fi + +This will put the context name given in the argument field of the +`curcontext' parameter and this context will then be used to look +up styles for the tags. + +But since this is often used, `_arguments' and `_values' have support +to make your life easier in such cases. With the `-C' option, these +functions set the parameter `curcontext', thus modifying the globally +used hierarchical context name. This means, that you have to make that +local, but then you don't have to worry about giving the context name +reported back to functions you call. E.g.: + + local curcontext="$curcontext" ... + ... + _arguments -C ... 'foo:foo:->foo' + ... + if [[ "$state" = foo ]]; then + _tags ... + ... + fi + +In this case the parameter `context' is not set, so you don't have to +make that local. But make sure that `curcontext' is local so that the +value changed by `_arguments' and `_values' is only used in your +function (and make sure to initialise it to its old value as in the +example). + +Then, before adding the matches, see if matches of that type are +requested by the user in the current context. If you will add only one +type of matches, this is very simple. You can use the function +`_wanted' for this. Its return value is zero only if the type of +matches is requested by the user, so you can just do: + + _wanted names || return 1 + + _all_labels names expl 'name' compadd - alice bob + +The `_all_labels' function implements the loop over the tag aliases and +handles the user-defined description, using (in the example) the +parameter `expl' to store options to give to the command. These option +are inserted into the command line either directly before a single +hyphen if there is such an argument or after the first word if there +is no single hyphen. Since using `_all_labels' is so much more conveient +than writing the loop with the `_next_label' function (see below), but +some function called to generate matches don't accept a single hyphen +as argument anywhere but want the options built as their last arguments, +`_all_labels' will *replace* the hyphen with the options if the hyphen is +the last argument. A good example for such a function is +`_combination' which can be called like: + + _all_labels foo expl 'descr...' _combination ... - + +And the `-' will be replaced by the options that are to be given to +`compadd'. + +Since the above sequence of command is used so often, the `_wanted' +function can also accept the same arguments as `_all_labels'. In this +case it will do the test for the requested tag and then just call +`_all_labels', so: + + _wanted names expl 'name' compadd - alice bob + +Note that you can also give the `-J' and `-V' options with the +optional `1' or `2' preceding them supported by `_description': + + _wanted -2V names expl 'name' compadd ... + +In some cases one needs to call multiple functions or call `compadd' +more than once to generate the matches. In such a case one needs to +implement the loop over the tag aliases directly. This is done with the +`_next_label' function. Like this: + + while _next_label names expl 'name'; do + compadd "$expl[@]" - alice bob && ret=0 + _other_names "$expl[@]" && ret=0 + done + return ret + +Simple enough, I hope. But `_next_label' can do some more: utility +functions normally accept options which are then given to `compadd'. +Since these may contain options for the description and `_next_label' may +generate such options, too, it isn't entirely trivial to decide which +of these options should take precedence. But `_next_label' can do the work +for you here. All you have to do is to give the options your utility +function gets to `_next_label', as in: + + while _next_label names expl 'name' "$@"; do + compadd "$expl[@]" - alice bob + ... + done + +That's all. Note that the positional argument "$@" are *not* given to +`compadd'. They will be stuffed into the `expl' array by `_next_label'. + +The most complicated case is where you can offer multiple types of +matches. In this case the user should be able to say which types he +wants to see at all and of those which he wants to see he should be +able to say which types should be tried first. The generic solution +for this uses `_tags' and `_requested': + + local expl ret=1 + + _tags friends users hosts + + while _tags; do + _requested friends expl friend compad alice bob && ret=0 + _requested users && _users && ret=0 + _requested hosts && _hosts && ret=0 + + (( ret )) || break # leave the loop if matches were added + done + +`_tags' with tags as arguments registers those tags and checks which +of them the user wants to see and in which order the tags are to be +tried. This means that internally these tags are stored in multiple +sets. The types of matches represented by the tags from the first set +should be tried first. If that generates no matches, the second set is +tried and so on. `_tags' without arguments just makes the next set be +tried (on the first call it makes the first set be used). The function +`_requested' then tests if the tag given as its first argument is in +the set currently used and returns zero if it is, i.e. if matches of +that type should be added now. The arguments accepted by `_requested' +are the same as for `_wanted'. I.e. you can call it with only the tag +to test, with the `tag array description' or with that plus the +command to execute. + +In some cases (like the `users' and `hosts' tags in the example) you +don't need do the loop over the tag aliases yourself, because the +utility functions like `_users' and `_hosts' do it automatically. + +This looks good already. But in many cases such as this one you can +also use the function `_alternative' which simply implements a loop +like the one above. It gets arguments of the form `tag:descr:action'. +E.g.: + + _alternative \ + 'friends:friend:(alice bob)' \ + 'users:: _users' \ + 'hosts:: _hosts' + +Which does the same as the previous example. (Note the empty +descriptions in the last two arguments -- the actions start with a +space so that they are executed without giving the description +build by `_alternative', i.e. we just use the description added by +`_users' and `_hosts'). + +In cases where you have to keep track of the context yourself, you can +give the sub-context you want to use to `_tags', `_wanted' and +`_alternative' with the `-C' option as described above. You don't need +to give it to `_requested' -- that function will work on the context +used by the corresponding call to `_tags' automatically. + +For the names of the tags: choose simple (short, if at all possible) +names in plural. Also, first have a look at the tag names already used +by other functions and if any of these names seem sensible for the +type of matches you are about to add, the use those names. This will +allow users to define styles for certain types of matches independent +of the place where they are added. + +One final comment about when to use your own argument-contexts: do +this when the command you are writing a completion function for has +different `modes'. E.g. if it accepts host names after a `-h' option +and users or hosts after `-u' and for some reason you can't use +`_arguments' to do the work for you, then use context names as in: + + case "$1" in + -h) + _tags -C -h hosts && _hosts && ret=0 + ;; + -u) + _alternative -C -u 'users:: _users' 'hosts:: _hosts' && ret=0 + ;; + esac + + +Styles +------ + +Users can associate patterns for hierarchical context names with +certain styles using the `zstyle' builtin. The completion code +should then use these styles to decide how matches should be added and +to get user-configured values. This, too, is done using the builtin +`zstyle'. + +Basically styles map names to a bunch of strings (the `value'). In +many cases you want to treat the value as a boolean, so let's start +with that. To test if, for example, the style `verbose' is set for +the tag `options' in the context you are currently in, you can just do: + + if zstyle -t ":completion:${curcontext}:options" verbose; then + # yes, it is set... + fi + +I.e. with the -t option and two arguments `zstyle' takes the first one +as a context and the second one as a style name and returns zero if that +style has the boolean value `true'. Internally it checks if the style +is set to one of `yes', `true', `on', or `1' and interprets that as +`true' and every other value as `false'. + +For more complicated styles for which you want to test if the value +matches a certain pattern, you can use `zstyle' with the -m option and +three arguments: + + if zstyle -m ":completion:${curcontext}:foo" bar '*baz*'; then + ... + fi + +This tests if the value of the style `bar' for the tag `foo' matches +the pattern `*baz*' and returns zero if it does. + +If you just want to see if one of the strings in the value is exactly +equal to any of a number of a strings, you can use the -t option and +give the strings after the style name: + + if zstyle -t ":completion:${curcontext}:foo" bar str1 str2; then + ... + fi + +But sometimes you want to actually get the value stored for a certain +style instead of just testing it. For this `zstyle' supports four +options: `-b', `-s', `-a', and `-h'. After these options, three +arguments are expected, the context, the style, and a parameter name. +The parameter will then be set to the value of the style and the option +says how the strings stored as a value will be stored in the +parameter: + + - `-b': the parameter will be set to a either `yes' or `no' + - `-s': the parameter will be set to all strings in the value + concatenated (separated by spaces) to one string + - `-a': the parameter will be set to an array containing the strings + from the value as elements + - `-h': the parameter will be set to an association with the strings + from the value being interpreted alternatingly as keys and + values + +Some random comments about style names. Use the ones already in use if +possible. Especially, use the `verbose' style if you can add +matches in a simple and a verbose way. Use the verbose form only if +the `verbose' style is `true' for the current context. Also, if +the matches you want to add have a common prefix which is somehow +special, use the `prefix-needed' and `prefix-hidden' styles. The first +one says if the user has to give the prefix on the line to make these +matches be added and the second one says if the prefix should be +visible in the list. + +And finally, if you need a style whose value can sensibly be +interpreted as a list of words, use array or association styles with +the `-a' or `-h' options to `zstyle'. Otherwise you should only make +sure that an empty value for a style is treated in the same way as if +the style wasn't set at all (this is used elsewhere and we want to +keep things consistent). + + +Descriptions +------------ + +Always use description. This is important. Really. *Always* use +descriptions. If you have just written down a `compadd' without a +"$expl[@]" (or equivalent), you have just made an error. Even in +helper functions where you use a "$@": if you can't be sure that there +is a description in the arguments, add one. You can (and, in most +cases, should) then give the description you generated after the +"$@". This makes sure that the, probably more specific, description +given by the calling function takes precedence over the generic one +you have just generated. + +And it really isn't that complicated, is it? Think about a string +people might want to see above the matches (in singular -- that's used +throughout the completion system) and do: + + local expl + + _description tag expl <descr> + compadd "$expl@]" - <matches ...> + +Note that this function also accepts `-V' und `-J', optionally (in the +same word) preceded by `1' or `2' to describe the type of group you +want to use. For example: + + _description tag expl '...' + compadd "$expl[@]" -1V foo - ... # THIS IS WRONG!!! + +is *not* the right way to use a unsorted group. Instead do: + + _description -1V tag expl '...' + compadd "$expl[@]" - ... + +and everything will work fine. + +Also, if you are about to add multiple different types of matches, use +multiple calls to `_description' and add them with multiple calls to +`compadd'. But in almost all cases you should then add them using +different tags anyway, so, see above. + +And since a tag directly corresponds to a group of matches, you'll +often be using the tags function that allows you to give the +explanation to the same function that is used to test if the tags are +requested (again: see above). Just as a reminder: + + _wanted [ -[1,2]V | -[1,2]J ] <tag> expl <descr> + +and + + _requested [ -[1,2]V | -[1,2]J ] <tag> expl <descr> + +is all you need to make your function work correctly with both tags +and description at the same time. + + +Misc. remarks +------------- + +1) Supply match specifications to `compadd' if there are sensible ones. +2) Use helper functions that do option completion for you (like + `_arguments' and `_values') -- it will make your life much easier. -7) Use helper functions like `_users' and `_groups' instead of direct - calls to `compgen -u' or some ad hoc mechanisms to generate such - information. This ensures that user can change the way these things - will be completed everywhere by just using their own implementations - for these functions. -8) Make sure that the return value of your functions is correct: zero +3) Use helper functions like `_users' and `_groups' instead of some ad hoc + mechanisms to generate such information. This ensures that users can + change the way these things will be completed everywhere by just using + their own implementations for these functions. +4) Make sure that the return value of your functions is correct: zero if matches where added and non-zero if no matches were found. In some cases you'll need to test the value of `$compstate[nmatches]' for this. This should always be done by first saving the old value (`local nm="$compstate[nmatches]"') and later comparing this with the current value after all matches have been added (e.g. by - writing `[[ nmm -ne compstate[nmatches] ]]' at the end of your - function). This guarantees that your functions will be re-usable - because calling functions may rely on the correct return value. -9) In places where different behaviors may be useful, add a - configuration key to allow users to select the behavior they - prefer. Names for configuration keys should look like `prefix_name', - where `prefix' is the (probably abbreviated) name of your function - and `name' describes what can be configured. - When testing the values of configuration keys, the empty string - should result in the same behavior as if the key were unset. This - can be achieved by the test `[[ -n "$compconfig[prefix_name]" ]]'. -10) When writing helper functions that generate matches, the arguments - of these should be given unchanged to `compadd' or `compgen' (if - they are not used by the helper function itself). + writing `[[ nm -ne compstate[nmatches] ]]' at the end of your + function). + This guarantees that your functions will be re-usable because calling + functions may rely on the correct return value. +5) When writing helper functions that generate matches, the arguments + of these should be given unchanged to `compadd' (if they are not + used by the helper function itself). +6) When matches with a common prefix such as option names are generated, + add them *with* the prefix (like `-', `+', or `--' for options). + Then check the `prefix-needed' style to see if the matches are to be + added when the prefix is on the line and use the `prefix-hidden' + style to see if the prefix should be listed or not. +7) If at all possible, completion code for a command or a suite of + commands should go into only one file. If a command has sub-commands, + implementing a state-machine might be a good idea. See the `_rpm' + and `_pbm' files for examples of different styles. Also see the + documentation for `_arguments' and `_values' for two functions + that may help you with this. +8) If a completion function generates completely different types of + completions (for example, because the comamnd has several + completely different modes), it should allow users to define + functions that separately override the behavior for these + different types. This can easily be achieved by using the + `_funcall' utility function, as in: + + _funcall ret _command_$subcommand && return ret + + This will try to call the function `_command_$subcommand' and if + it exists, it will be called and the completion function exits + with its exit status. After this call to `funcall' the completion + function would contain the code for the default way to generate + the matches. + See the `_rpm' and `_nslookup' files for examples. diff --git a/LICENCE b/LICENCE new file mode 100644 index 000000000..1121e06df --- /dev/null +++ b/LICENCE @@ -0,0 +1,25 @@ +The Z Shell is copyright (c) 1992-2000 Paul Falstad, Richard Coleman, +Zoltán Hidvégi, Andrew Main, Peter Stephenson, Sven Wischnowsky, and +others. All rights reserved. Individual authors, whether or not +specifically named, retain copyright in all changes; in what follows, they +are referred to as `the Zsh Development Group'. This is for convenience +only and this body has no legal status. The Z shell is distributed under +the following licence; any provisions made in individual files take +precedence. + +Permission is hereby granted, without written agreement and without +licence or royalty fees, to use, copy, modify, and distribute this +software and to distribute modified versions of this software for any +purpose, provided that the above copyright notice and the following +two paragraphs appear in all copies of this software. + +In no event shall the Zsh Development Group be liable to any party for +direct, indirect, special, incidental, or consequential damages arising out +of the use of this software and its documentation, even if and the Zsh +Development Group have been advised of the possibility of such damage. + +The Zsh Development Group specifically disclaim any warranties, including, +but not limited to, the implied warranties of merchantability and fitness +for a particular purpose. The software provided hereunder is on an "as is" +basis, and the Zsh Development Group have no obligation to provide +maintenance, support, updates, enhancements, or modifications. |