The keymap stores the mapping between key strokes—or events—and commands. Emacs uses lists for its representation of keymaps. Emacsy instead uses a class that stores entries in a hash table. Another difference for Emacsy is that it does not convert S-C-a to a different representation like [33554433]; it leaves it as a string that is expected to be turned into a canonical representation “C-A”.
Here is an example of the keymap representation in Emacs.
> (let ((k (make-sparse-keymap))) (define-key k "a" 'self-insert-command) (define-key k "<mouse-1>" 'mouse-drag-region) (define-key k "C-x C-f" 'find-file-at-point) k) (keymap (24 keymap (6 . find-file-at-point)) (mouse-1 . mouse-drag-region) (97 . self-insert-command))
When I initially implemented Emacsy, I replicated Emacs’ keymap representation, but I realized it wasn’t necessary. And it seems preferrable to make the representation more transparent to casual inspection. Also, Emacsy isn’t directly responsible for the conversion of keyboard events into [[key-event]]s—that’s a lower level detail that the embedding application must handle. Here is the same keymap as above but in Emacsy.
> (let ((k (make-keymap))) (define-key k "a" 'self-insert-command) (define-key k "mouse-1" 'mouse-drag-region) (define-key k "C-x C-f" 'find-file-at-point) k) #<keymap a self-insert-command C-x #<keymap C-f find-file-at-point> mouse-1 mouse-drag-region>
There are a few differences in how the keymap is produced, and the representation looks slightly different too. For one thing it’s not a list.
Our keymap class has a hashtable of entries and possibly a parent keymap.