Next: Keymap, Previous: Emacsy Facade, Up: Api [Contents][Index]
One of the idioms we want to capture from Emacs is this.
(define-key global-map "M-f" 'some-command)
They [[keymap]] and [[command]] module will deal with most of the above, except for the [[kbd]] procedure. That’s something events will be concerned with. One may define a converter for a [[kbd-entry]] to an event of the proper type. Note that a [[kbd-string]] is broken into multiple [[kbd-entries]] on whitespace boundaries, e.g., “C-x C-f” is a [[kbd-string]] that when parsed becomes two [[kbd-entries]] “C-x” and “C-f”.
Basic event class.
Event to capture key strokes, including the modifier keys.
Event to capture key strokes, including the modifier keys.
Event to capture mouse events.
Event to capture mouse drag events.
Now we have the function [[kbd-entry->key-event]]. [[kbd]] needs to know about this and any other converter function. So let’s register it.
Let’s write the converter for the [[<key-event>]] class that will accept the same kind of strings that Emacs does. If the [[kbd-entry]] does not match the event-type, we return false [[#f]].
For the modifier keys, we are going to emulate Emacs to a fault.
Now we convert the [[<key-event>]] back to a [[kbd-entry]].
Instead of using [[define-generic]] I’ve written a convenience macro [[define-generic-public]] that exports the symbol to the current module. This mimics the functionality of [[define-public]]. In general, any *-public macro will export the symbol or syntax to the
Display the <key-event> in a nice way.
The kbd-entry for mouse events is similar to key events. The regular expression is ^(([ACHMsS]-)*)((up-|down-|drag-)?mouse-([123]))\$.
Next: Keymap, Previous: Emacsy Facade, Up: Api [Contents][Index]