zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.4: (alternative) neg-argument fix
@ 1998-10-09 11:25 Peter Stephenson
  1998-10-09 15:44 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1998-10-09 11:25 UTC (permalink / raw)
  To: Zsh hackers list

There was a patch from Bart back in zsh-workers/4268 to fix a problem
with neg-argument (\e- in emacs mode), namely \e-\e1 gave you 11
instead of 1 and so on.  Now I come to look at this, I can't get it to
work, i.e. neg-argument won't function at all.  I can't think of
anything that might be clashing with the patch, thought it's not
impossible.

However, even if I've done something silly there is the following
point: \e- on its own should act as an argument -1 even if no further
digit is typed.  It's only when you get back to digitargument() for a
new digit, if any, that you need to know whether an existing -1 should
be treated as a real -1 (e.g you already typed \e-\e1) or not (you've
only just typed \e-).  I couldn't see a way of doing this without
adding a new flag, though that doesn't mean there isn't one.  This
therefore is my alternative version of 4268.

Is there any enthusiasm for upgrading universal-argument to do what
emacs does, that is to take any following digits as part of the
argument?

*** Src/Zle/zle.h.mult	Thu Jul  9 13:27:28 1998
--- Src/Zle/zle.h	Fri Oct  9 11:28:26 1998
***************
*** 90,95 ****
--- 90,96 ----
  #define MOD_TMULT (1<<1)   /* a repeat count is being entered */
  #define MOD_VIBUF (1<<2)   /* a vi cut buffer has been selected */
  #define MOD_VIAPP (1<<3)   /* appending to the vi cut buffer */
+ #define MOD_NEG   (1<<4)   /* last command was negate argument */
  
  /* current modifier status */
  
*** Src/Zle/zle_misc.c.mult	Thu Jul  9 12:04:41 1998
--- Src/Zle/zle_misc.c	Fri Oct  9 11:28:38 1998
***************
*** 442,448 ****
  
      if (!(zmod.flags & MOD_TMULT))
  	zmod.tmult = 0;
!     zmod.tmult = zmod.tmult * 10 + sign * (c & 0xf);
      zmod.flags |= MOD_TMULT;
      prefixflag = 1;
  }
--- 442,454 ----
  
      if (!(zmod.flags & MOD_TMULT))
  	zmod.tmult = 0;
!     if (zmod.flags & MOD_NEG) {
! 	/* If we just had a negative argument, this is the digit, *
! 	 * rather than the -1 assumed by negargument()            */
! 	zmod.tmult = sign * (c & 0xf);
! 	zmod.flags &= ~MOD_NEG;
!     } else
! 	zmod.tmult = zmod.tmult * 10 + sign * (c & 0xf);
      zmod.flags |= MOD_TMULT;
      prefixflag = 1;
  }
***************
*** 456,462 ****
  	return;
      }
      zmod.tmult = -1;
!     zmod.flags |= MOD_TMULT;
      prefixflag = 1;
  }
  
--- 462,468 ----
  	return;
      }
      zmod.tmult = -1;
!     zmod.flags |= MOD_TMULT|MOD_NEG;
      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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-10-12  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` PATCH: 3.1.4: alternative " Peter Stephenson

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).