zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: PATCH: 3.1.4: alternative universal-argument upgrade
Date: Mon, 12 Oct 1998 10:37:54 +0200	[thread overview]
Message-ID: <9810120838.AA25456@ibmth.df.unipi.it> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Sat, 10 Oct 1998 18:33:13 DFT." <9810101633.AA27872@ibmth.df.unipi.it>

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 <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy


      reply	other threads:[~1998-10-12  8:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-09 11:25 PATCH: 3.1.4: (alternative) neg-argument fix Peter Stephenson
1998-10-09 15:44 ` Bart Schaefer
1998-10-10 16:33   ` PATCH: 3.1.4: universal-argument upgrade Peter Stephenson
1998-10-12  8:37     ` Peter Stephenson [this message]

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=9810120838.AA25456@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --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).