zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: zsh exits after delete-char-or-list and two ^Cs
Date: Thu, 02 Sep 2004 10:19:00 +0100	[thread overview]
Message-ID: <200409020919.i829J0eC012233@news01.csr.com> (raw)
In-Reply-To: "Bart Schaefer"'s message of "Wed, 01 Sep 2004 12:44:02 PDT." <Pine.LNX.4.61.0409011241500.16233@toltec.zanshin.com>

Bart Schaefer wrote:
> The effect of this is going to be that "zle -I" has no effect when called
> from completion widgets, where previously it could.  Is that really the
> intent?
>
> I'd think you wanted something more like:
> 
>   if (zleactive) {
>       if (!trashedzle)
>           trashzle();
>       return zle_usable()? 0 : 1;
>   }
> 
> (Though perhaps not precisely that either.)

Well, that would do, if suitably documented.

It looks like it would be more sensible to have the test for whether a
zle widget is callable separate from the return status for zle -I.
However, it's a bit late now.

Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.39
diff -u -r1.39 zle.yo
--- Doc/Zsh/zle.yo	29 Jul 2004 14:22:21 -0000	1.39
+++ Doc/Zsh/zle.yo	2 Sep 2004 09:15:35 -0000
@@ -505,9 +505,12 @@
 Note that there are normally better ways of manipulating the display from
 within zle widgets; see, for example, `tt(zle -R)' above.
 
-The status is zero if zle is active and the current zle display has
-been invalidated (even if this was by a previous call to `tt(zle -I)'),
-else one.
+The returned status is zero if a zle widget can be called immediately.
+Note this is independent of whether the display has been invalidated.
+For example, if a completion widget is active a zle widget cannot be used
+and the status is one even if the display was invalidated; on the other
+hand, the status may be zero if the display was invalidated by a previous
+call to `tt(zle -I)'.
 )
 item(var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)(
 Invoke the specified widget.  This can only be done when ZLE is
Index: Src/Zle/zle_thingy.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v
retrieving revision 1.13
diff -u -r1.13 zle_thingy.c
--- Src/Zle/zle_thingy.c	2 Jun 2004 22:15:02 -0000	1.13
+++ Src/Zle/zle_thingy.c	2 Sep 2004 09:15:36 -0000
@@ -619,6 +619,23 @@
 
 /**/
 static int
+zle_usable()
+{
+    return zleactive && !incompctlfunc && !incompfunc
+#if 0
+	/*
+	 * PWS experiment: commenting this out allows zle widgets
+	 * in signals, hooks etc.  I'm not sure if this has a down side;
+	 * it ought to be that zleactive is good enough to test whether
+	 * widgets are callable.
+	 */
+	&& sfcontext == SFC_WIDGET
+#endif
+	   ;
+}
+
+/**/
+static int
 bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 {
     Thingy t;
@@ -629,10 +646,9 @@
     if (!wname) {
 	if (saveflag)
 	    zmod = modsave;
-	return (!zleactive || incompctlfunc || incompfunc ||
-		sfcontext != SFC_WIDGET);
+	return !zle_usable();
     }
-    if(!zleactive || incompctlfunc || incompfunc || sfcontext != SFC_WIDGET) {
+    if(!zle_usable()) {
 	zwarnnam(name, "widgets can only be called when ZLE is active",
 	    NULL, 0);
 	return 1;
@@ -685,10 +701,15 @@
 static int
 bin_zle_invalidate(UNUSED(char *name), UNUSED(char **args), UNUSED(Options ops), UNUSED(char func))
 {
+    /*
+     * Trash zle if trashable, but only indicate that zle is usable
+     * if it's possible to call a zle widget next.  This is not
+     * true if a completion widget is active.
+     */
     if (zleactive) {
 	if (!trashedzle)
 	    trashzle();
-	return 0;
+	return !zle_usable();
     } else
 	return 1;
 }

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


  reply	other threads:[~2004-09-02  9:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25 17:04 Danek Duvall
2004-08-27  0:22 ` Bart Schaefer
2004-09-01 18:10   ` Peter Stephenson
2004-09-01 19:44     ` Bart Schaefer
2004-09-02  9:19       ` Peter Stephenson [this message]
2004-09-02 15:15         ` Bart Schaefer
2004-09-03  9:37           ` Peter Stephenson
2004-09-03 18:59             ` Bart Schaefer
2004-09-07 14:08               ` Peter Stephenson
2004-09-08 14:23               ` Peter Stephenson
2004-09-01 17:36 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200409020919.i829J0eC012233@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).