From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1513 invoked from network); 9 Jun 1998 18:05:19 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Jun 1998 18:05:19 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id OAA14579; Tue, 9 Jun 1998 14:01:05 -0400 (EDT) Resent-Date: Tue, 9 Jun 1998 14:01:05 -0400 (EDT) From: Zefram Message-Id: <199806091801.TAA04656@taos.demon.co.uk> Subject: Re: User-defined zle widgets and built-in widget failure To: schaefer@brasslantern.com (Bart Schaefer) Date: Tue, 9 Jun 1998 19:01:58 +0100 (BST) Cc: zsh-workers@math.gatech.edu In-Reply-To: <980609100902.ZM6152@candle.brasslantern.com> from "Bart Schaefer" at Jun 9, 98 10:09:02 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"pJimF3.0.kZ3.WXNVr"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4065 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Bart Schaefer wrote: >I'd like to write a widget that modifies BUFFER, calls a built-in widget, >and then if that built-in widget fails, restores the previous BUFFER and >CURSOR. > >Unfortunately, failure of "zle whatever" isn't detectable; "zle" always >sets $? to zero. Failure internally is recorded by the feep flag. If that is set at the end of the main loop, a beep is emitted and the flag reset. All we need to do is make that flag visible to widgets. Like a lot of other ZLE things, this is one of the things I had a fairly concrete plan for when my spare time suddenly disappeared last year. The mechanism I planned is that each thingy will include a single-bit flag, which can be tested and modified using the zle builtin. Then all you do to test for error is "if zle -F feep; ...", where the value of "F" has yet to be determined. Other thingies would have flags attached similarly. Or a more general possibility would be thingy array variables accessible via thingy names, or possibly by more magic parameter names (though I'd want to do a proper namespace separation, e.g., ${zle.feep}). That reminds me, more generally I'd like to move the zsh-specific parameter names to completely separate names that can't conflict with POSIX parameter names. If we have ${zsh.module_path} instead of $module_path, then this can be available regardless of the name used to invoke zsh. What do people think? -zefram