From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19329 invoked from network); 12 Oct 1998 08:56:27 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Oct 1998 08:56:27 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id EAA24495; Mon, 12 Oct 1998 04:47:38 -0400 (EDT) Resent-Date: Mon, 12 Oct 1998 04:47:38 -0400 (EDT) Message-Id: <9810120838.AA25456@ibmth.df.unipi.it> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: PATCH: 3.1.4: alternative universal-argument upgrade In-Reply-To: "Peter Stephenson"'s message of "Sat, 10 Oct 1998 18:33:13 DFT." <9810101633.AA27872@ibmth.df.unipi.it> Date: Mon, 12 Oct 1998 10:37:54 +0200 From: Peter Stephenson Resent-Message-ID: <"P2sY8.0.g-5.g8S8s"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4425 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I wrote: > Is it OK to assume 0..9 and - are bound to self-insert? It's a little > messier to test for them earlier One day I'm going to be able to fix things in a single patch, but until then... Zsh has a perfectly workable key-ungetting mechanism, so here's a different, self contained patch to make universal-argument take (positive or negative) integers after it, which doesn't rely on any special behaviour bound to the digit keys or minus. I'm not aware of any problems with this approach; it should work fine in any key-binding mode. As this version is self-contained, it does not include the neg-argument fix in 4420 this time, so that has to be applied as well (again, sorry). *** Doc/Zsh/zle.yo.mult2 Mon Oct 12 10:22:19 1998 --- Doc/Zsh/zle.yo Mon Oct 12 10:23:23 1998 *************** *** 779,785 **** ) tindex(universal-argument) item(tt(universal-argument))( ! Multiply the argument of the next command by 4. ) enditem() texinode(Completion)(Miscellaneous)(Arguments)(Zsh Line Editor) --- 779,791 ---- ) tindex(universal-argument) item(tt(universal-argument))( ! Multiply the argument of the next command by 4. Alternatively, if ! this command is followed by an integer (positive or negative), use ! that as the argument for the next command. Thus digits cannot be ! 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. ) enditem() texinode(Completion)(Miscellaneous)(Arguments)(Zsh Line Editor) *** Src/Zle/zle_misc.c.mult2 Mon Oct 12 10:20:27 1998 --- Src/Zle/zle_misc.c Mon Oct 12 10:32:03 1998 *************** *** 470,476 **** void universalargument(void) { ! zmod.tmult *= 4; zmod.flags |= MOD_TMULT; prefixflag = 1; } --- 470,494 ---- void universalargument(void) { ! int digcnt = 0, pref = 0, minus = 1, gotk; ! while ((gotk = getkey(0)) != EOF) { ! if (gotk == '-' && !digcnt) { ! minus = -1; ! digcnt++; ! } else if (gotk >= '0' && gotk <= '9') { ! pref = pref * 10 + (gotk & 0xf); ! digcnt++; ! } else { ! /* why is ungetkey() static? */ ! char kgot = gotk; ! ungetkeys(&kgot, 1); ! break; ! } ! } ! if (digcnt) ! zmod.tmult = minus * (pref ? pref : 1); ! else ! zmod.tmult *= 4; zmod.flags |= MOD_TMULT; prefixflag = 1; } -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy