From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Alternative design for keymap code
Date: Fri, 2 Jul 1999 08:56:35 +0200 (MET DST) [thread overview]
Message-ID: <199907020656.IAA15483@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Anthony J Heading"'s message of Thu, 1 Jul 1999 22:14:56 +0800
Anthony J Heading wrote:
> The current keymap code isn't optimally structured for that, and indeed
> struck me as a little simplistic - the only relationships on keymaps are
> deep copying and aliasing. And the structure of a fixed 256 key array for
> single keystrokes and a hash table for multistroke commands seemed an ugly
> optimisation.
Agreed. Wholeheartedly. Btw, I just wanted to keep the code-change as
small as possible when I wrote those local keymaps we currently
have. And was planning to come back to it later... I also never
understood why we have this aliasing thing instead of a bindkey-option
that just sets the keymap to use. If I remember correctly I wasn't
here when this (or at least parts of it) were implemented, so I missed
the discussion. Hm, time to read the archive, I guess.
> I replaced the keymap lookup code with an optimised hash table - basically
> something I learnt from perl 5.000alpha6, but which also keeps the chains
> ordered by key sequence length. Using a hash function h <- 33 * h +
> newchar means that by setting the hash table width to 256 the single
> keystrokes would be distributed one-per-bucket and always be the first
> element. Which is good for speed (if one thought that one could type
> faster than a CPU could read). So no need for the fixed array, but also
> no need for the width to be 256 if one wanted a small overlay map.
This sounds good, too.
> I then also implemented a distinction between unbound keys and keys bound
> to undefined-key. Finding the latter in a keymap means the key really
> does nothing, while the former case is 'transparent' - the search simply
> fall through to the next underlying keymap. When a final definition (or
> lack thereof) is found, it's cached in the top level map. Again good
> efficiency wise.
Yes, I like this, too. (Making undefined-key the hole in local keymaps
as it currently is is ugly.)
> After reflecting for a while, I believe there's still value in some of the
> design. And I'm thinking instead that maybe there should be a shell
> parameter KEYMAP/keymap pair, which specificies the prevailing set of
> keymaps. These are searched in order. Shell function are then able to
> push their own map onto the head the list if they need. And by allowing
> the KEYMAP parameter to be function-local, exit cleanup is automatic.
And this sounds good to me, too.
So, I'd vote for cleaning up the keymap structure and selection
mechanism a bit and to give users a simple way to modify the keymaps
to use (either with a special array or via bindkey-option).
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-07-02 6:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-02 6:56 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-07-01 14:14 Anthony J Heading
1999-07-02 16:06 ` 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=199907020656.IAA15483@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).