From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: PATCH: 3.1.4: universal-argument upgrade
Date: Sat, 10 Oct 1998 18:33:13 +0200 [thread overview]
Message-ID: <9810101633.AA27872@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Fri, 09 Oct 1998 08:44:44 DFT." <981009084444.ZM24902@candle.brasslantern.com>
"Bart Schaefer" wrote:
> } I couldn't see a way of doing this without
> } adding a new flag, though that doesn't mean there isn't one.
>
> Has the whole multiplier thing become more complicated than necessary in
> 3.1.4? MOD_TMULT obviously does more than the `gotmult' global in 3.0.5
> did.
Looks like it, I have to admit I was confused to begin with.
> } 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?
>
> YES! That would be so much easier than having to clamp down Alt or hit
> ESC repeatedly to enter the digits. Just remember that it also needs
> to take a following `-' as part of the argument.
OK, here it is. This replaces the previous patch, since instead of
MOD_NEG I use MOD_REPL: a 4 from universal-argument becomes
replaceable in the same way as a -1 from neg-argument. It remains
unbound by default. It's annoying that ^U for backward-kill-line is
so engrained in the shell-user psyche.
The only compatibility issue is that you can't repeat digits with
universal-argument, i.e (after rebinding universal-argument to ^U)
^U2 doesn't give you four twos any more, for obvious reasons. I take
it this is entirely minor.
Is it OK to assume 0..9 and - are bound to self-insert? It's a little
messier to test for them earlier: the problem is that you can't tell
after you've retrieved the binding whether it was a real `0' etc. or a
multi-key sequence ending in `0' such as `^X0', since that information
is buried inside getkeymapcmd() --- which I don't want to hack about
--- and on the latter occasion you certainly don't want digit-argument
behaviour. It means it won't work in vi command mode, although the
digit handling is in any case different there. (Actually, that's a
partial lie: unless you attempt to enter a -, it looks like it works
OK because the normal vi digit behaviour comes into play after you
enter universal-argument, i.e. the latter is then ignored.)
*** Doc/Zsh/zle.yo.mult Sun May 11 13:24:01 1997
--- Doc/Zsh/zle.yo Sat Oct 10 18:06:25 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,792 ----
)
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. Note that this assumes the digits and dash
! are bound to tt(self-insert), as is usually the case.
)
enditem()
texinode(Completion)(Miscellaneous)(Arguments)(Zsh Line Editor)
*** Src/Zle/zle.h.mult Thu Jul 9 13:27:28 1998
--- Src/Zle/zle.h Sat Oct 10 18:04:44 1998
***************
*** 90,95 ****
--- 90,97 ----
#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_REPL (1<<4) /* current tmult is replaceable */
+ #define MOD_UNIV (1<<5) /* universal argument in progress */
/* current modifier status */
*** Src/Zle/zle_misc.c.mult Thu Jul 9 12:04:41 1998
--- Src/Zle/zle_misc.c Sat Oct 10 17:48:56 1998
***************
*** 62,67 ****
--- 62,76 ----
{
char s[3], *p = s;
+ if (zmod.flags & MOD_UNIV) {
+ if (c >= '0' && c <= '9') {
+ digitargument();
+ return;
+ } else if (c == '-' && (zmod.flags & MOD_REPL)) {
+ negargument();
+ return;
+ }
+ }
if(imeta(c)) {
*p++ = Meta;
c ^= 32;
***************
*** 442,448 ****
if (!(zmod.flags & MOD_TMULT))
zmod.tmult = 0;
! zmod.tmult = zmod.tmult * 10 + sign * (c & 0xf);
zmod.flags |= MOD_TMULT;
prefixflag = 1;
}
--- 451,463 ----
if (!(zmod.flags & MOD_TMULT))
zmod.tmult = 0;
! if (zmod.flags & MOD_REPL) {
! /* If we just had a negative or universal argument, this is *
! * the digit, rather than the -1 or 4 at first assumed. */
! zmod.tmult = sign * (c & 0xf);
! zmod.flags &= ~MOD_REPL;
! } else
! zmod.tmult = zmod.tmult * 10 + sign * (c & 0xf);
zmod.flags |= MOD_TMULT;
prefixflag = 1;
}
***************
*** 451,462 ****
void
negargument(void)
{
! if(zmod.flags & MOD_TMULT) {
feep();
return;
}
zmod.tmult = -1;
! zmod.flags |= MOD_TMULT;
prefixflag = 1;
}
--- 466,478 ----
void
negargument(void)
{
! if((zmod.flags & MOD_TMULT) &&
! (zmod.flags & (MOD_REPL|MOD_UNIV)) != (MOD_REPL|MOD_UNIV)) {
feep();
return;
}
zmod.tmult = -1;
! zmod.flags |= MOD_TMULT|MOD_REPL;
prefixflag = 1;
}
***************
*** 465,471 ****
universalargument(void)
{
zmod.tmult *= 4;
! zmod.flags |= MOD_TMULT;
prefixflag = 1;
}
--- 481,487 ----
universalargument(void)
{
zmod.tmult *= 4;
! zmod.flags |= MOD_TMULT|MOD_UNIV|MOD_REPL;
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
next prev parent reply other threads:[~1998-10-10 16:52 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 ` Peter Stephenson [this message]
1998-10-12 8:37 ` PATCH: 3.1.4: alternative universal-argument upgrade 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=9810101633.AA27872@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).