>> A suggestion: >> >> (kbd-valid-p "") >> (kbd-valid-p "") >> >> should return t, and > > Good point. This does make one of the syntax checks either less > effective, or the syntax is ambiguous. I went with the latter, but I'm > not sure that's the right thing to do here. > > The kbd syntax is > > "C-M-" > > but allowing dashes inside the brackets means that > > "" > > should be parsed as the key named "C-M-return" (which isn't really > possible). > > So I just added some special-casing to disallow the "" form > in kbd-valid-p. We'll see... > >> (kbd-valid-p "<123>") >> >> should (I think) return nil. IOW, kbd-valid-p should use: > > I'm not sure -- can there be keys named "123"? I don't know what the > rules are here -- is there an authoritative source for the syntax of > these names somewhere? > This is no different from "C-M-return" which you disallow. In theory there could be a key or event whose symbolic name is "C-M-return". In theory there could be a key or event whose symbolic name is "123" (or even "0", which is different from the key "0"). In theory there could also be a key or event whose symbolic name is "ü", IOW, <ü>. If the point is to introduce a strict syntax, I think it's up to you to decide which key and event names are okay from the point of view of Emacs. I think the following should be okay: - contains at least two characters - starts with an ASCII letter - is followed by ASCII letters, digits, - or _ - each - must be preceded by at least two letters or digits - ends with an ASCII letter or digit Of course this is rather complex to put in a regexp, which is one of the reasons I chose to use a C function to do that check.