[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Round-tripping key definitions

From: Lars Ingebrigtsen
Subject: Round-tripping key definitions
Date: Sat, 13 Nov 2021 05:58:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

It'd be nice if doing a `describe-keymap' would output the same bindings
that we put in.  I mean, on the same form.  If you define a key as
"C-i", that function will describe the key as "TAB", for instance.  (And
the person making that keymap may have meant C-i with "i" being a
mnemonic for something.)

To do this, we'd have to stash the "intended" syntax somewhere, but:

  "a" 'foo
  "b" 'bar)
=> (keymap (98 . bar) (97 . foo))

  :full t
  "a" 'foo
  "b" 'bar)
=> (keymap #^[nil nil keymap #^^[3 0...])

In the latter case, we could stash the data in the case table somewhere.
But the sparse syntax doesn't give us a lot of wriggle room.

We could, of course, change the keymap types (since we're already adding
new functions for all of this binding stuff), but it'd be a lot of work.
Anybody got any ideas?

Hm...  while typing this, it occurs to me that we could add an
"impossible" "binding".  I.e.:

(keymap (98 . bar) (97 . foo) (:bindings <hash table>))

`describe-keymap' could use the :bindings entry to look up the intended
syntax (and not output that element).

Yeah!  I think that should work?  (We'd only add this entry if there's
any "ambiguous" keys in the map, so the impact wouldn't be noticeable, I

Thank you for coming to my TED talk.

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]