Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: the function to show a digit argument while it is being typed
- X-seq: zsh-users 14550
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: the function to show a digit argument while it is being typed
- Date: Wed, 11 Nov 2009 09:45:07 -0800
- In-reply-to: <m3eio56o4i.fsf@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <10081257897632@xxxxxxxxxxxxxxxxxxx> <237967ef0911101822g5bfcf4fao25fc33ba0a2e8604@xxxxxxxxxxxxxx> <091110204748.ZM28704@xxxxxxxxxxxxxxxxxxxxxx> <237967ef0911102217m1325dc59y8d7388e9f6f21c7b@xxxxxxxxxxxxxx> <091111001419.ZM28852@xxxxxxxxxxxxxxxxxxxxxx> <m3eio56o4i.fsf@xxxxxxxxxxxxxx>
On Nov 11, 11:07am, Greg Klanderman wrote:
}
} This is pretty nice.. is there any way to have the argument appear on
} the following line instead?
Here's a summarized version based on everything that's gone by so far.
function digit-argument-show {
emulate -R zsh
if [[ $LASTWIDGET == neg-argument && -n $NUMERIC ]]
then zle -M "arg: $((NUMERIC*$KEYS[-1]))"
else zle -M "arg: $NUMERIC$KEYS[-1]"
fi
zle -R
zle .digit-argument
if zle read-command
then [[ $REPLY != digit-argument ]] && zle -M ""
else zle send-break
fi
[[ -n $KEYS ]] && zle -U $KEYS
}
I'm not sure why the "zle -R" is needed; odd things happen [*] if it's
left out, probably because .digit-argument does not normally change
BUFFER or CURSOR and therefore doesn't cause a full refresh.
[*] cursor moves to status line but message is not printed, then all the
messages spew out when something does change BUFFER.
} I had to add 'setopt localoptions unset'
The "emulate" should take care of that -- things like shwordsplit also
needed to be handled.
} Also would be nice if this worked with universal-argument.
Hmm, that one is a lot trickier; universal-argument effectively is a
trap on the next self-insert, such that if a digit is typed it behaves
like digit-argument (and also discards any "pending" neg-argument,
which may be yet another bug). It handles that next keypress in a
way that makes it impossible to intercept in a wrapper widget, which
requires that the new widget not call .universal-argument.
For example, .universal-argument followed by the tty interrupt character
does not accomplish a send-break, which is another in the long line of
bugs that this exercise is uncovering.
Things get even hairier when argument-base is thrown in.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author