zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@math.gatech.edu
Subject: PATCH: pass name ($0) and zmult ($1) to user-defined widgets
Date: Fri, 12 Jun 1998 01:38:04 -0700	[thread overview]
Message-ID: <980612013804.ZM20410@candle.brasslantern.com> (raw)

User-defined widgets should be able to change their behavior or repeat
their action when given a digit-argument.  They also ought to have a
usable $0 when FUNCTION_ARGZERO is set; I chose to pass the widget name,
so if you bind the same function to different widgets you can test for
$0 to tweak the behavior.

Index: Doc/Zsh/zle.yo
===================================================================
--- zle.yo	1998/06/01 17:08:43	1.1.1.1
+++ zle.yo	1998/06/12 08:33:25
@@ -102,6 +102,9 @@
 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.
+When tt(FUNCTION_ARGZERO) is set, they are passed their widget name
+(not their function name) as tt($0), and if tt(digit-argument) was
+used to enter a number prefix, that prefix is passed as tt($1).
 Finally, they can examine and edit the ZLE buffer being edited by
 reading and setting the special parameters described below.
 
Index: Src/Zle/zle_main.c
===================================================================
--- zle_main.c	1998/06/01 17:08:46	1.1.1.1
+++ zle_main.c	1998/06/12 08:25:14
@@ -591,10 +591,23 @@
 	    zsfree(msg);
 	    feep();
 	} else {
+	  char *name = 0, num[16];
+	  LinkList args;
 	  startparamscope();
 	  makezleparams();
-	  doshfunc(l, NULL, 0, 1);
+	  PERMALLOC {
+	    name = ztrdup(func->nam);
+	    args = newlinklist();
+	    addlinknode(args, name);
+	    if (zmod.flags & MOD_MULT) {
+	      sprintf(num, "%d", zmult);
+	      addlinknode(args, num);
+	    }
+	  } LASTALLOC;
+	  doshfunc(l, args, 0, 1);
 	  endparamscope();
+	  freelinklist(args, (FreeFunc) NULL);
+	  zsfree(name);
 	  lastcmd = 0;
 	}
     }

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


             reply	other threads:[~1998-06-12  8:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-12  8:38 Bart Schaefer [this message]
1998-06-12  9:37 ` Zefram
1998-06-12 15:54   ` Bart Schaefer

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=980612013804.ZM20410@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@math.gatech.edu \
    /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).