From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20942 invoked by alias); 9 May 2011 13:09:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16009 Received: (qmail 6325 invoked from network); 9 May 2011 13:09:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_FONT_FACE_BAD,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=cDMAZWv2ipHvwee6u0VnWsehVlGgPUgZG9wEMr/0TVA=; b=BjBmFvjMkGQFrnkTnDwHtQreQdHQdsL3k1NqHbJmI6TBRgU/GoTpuX70+KzrqoXS0X rDqghv98ojj50CiZDXok8uUFFlIg1dP143ZW3Vp9Xr1GlLDiUeAoUyAvjiFCfC93l+vd NJVkA/nwx9Ox0hlMwCO6Wz1hDIBDWQn5F2ngc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=LPjb2zJphJi4LHlDsZL9IE581hn4N1osaMyQOe3licTWg/vwrOUkqAwYW0uri4TKY8 sPjgRowIUQrume8n1z1dttBm6+zgG5Wgi0b0US98iK6soVuJwMdhkoLHJyGWmyBg6khz yA1PDy3uXyOVKa7COMiOKNtQM+MPEMF/GgnBg= MIME-Version: 1.0 Date: Mon, 9 May 2011 09:09:32 -0400 Message-ID: Subject: custom command completion for a zshdb, a REPL From: Rocky Bernstein To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=0016e6d7dfbee1c34c04a2d78c95 --0016e6d7dfbee1c34c04a2d78c95 Content-Type: text/plain; charset=ISO-8859-1 I would like to add debugger command completion to the zsh debugger, zshdb. I have looked over the manual pages zshzle and zshcompsys and am still a bit confused. I would be grateful if someone could give a simple script as an example. Suppose the list of REPL (read, print, loop) commands is in a blank-delimited string variable "cmds", and that one of the commands is "foo" which has the list of subcommands for it in string variable "subcmd". For comparison here is the corresponding bash code: typeset cmds; cmds='foo food woot' # My RLE commands level0_complete_fn() { if (( COMP_POINT > 0)) ; then COMPREPLY=( $(compgen -W "$cmds" "$COMP_LINE") ) else COMPREPLY=( $cmds ) fi } typeset subcmds; foo_subcmds='bar baz' foo_subcmd_complete() { COMPREPLY=( $foo_subcmds ) } # Use a special version of bash read that handle's readline completion enable -f /src/external-vcs/bashdb/builtin/readc readc complete -D -F level0_complete_fn complete -F foo_subcmd_complete foo # Shell initialization shopt -s progcomp set -o emacs bind 'set show-all-if-ambiguous on' bind 'TAB:menu-complete' readc -e -p 'huh? ' line echo "you sez $line" I would not like to have completion files the available commands and sub-commands can be dynamic. For example, on the stack frame completion might be a positive integer up to the number of stack frames. And this changes in the course of execution. Thanks. --0016e6d7dfbee1c34c04a2d78c95--