# HG changeset patch # User Aidan Kehoe # Date 1426297249 0 # Node ID c87b776ab0e17984bc705dccebbf6207b13e5620 # Parent 916b48abd1c6959f81904ad159a2f49dbef3e038 Create a new error for when a char is needed but event-to-character gives nil lisp/ChangeLog addition: 2015-03-14 Aidan Kehoe * cmdloop.el (no-character-typed): New error, for those cases when a keystroke is to be treated as a character but has no character equivalent. * cmdloop.el (read-char-1): Use it. * keymap.el (synthesize-keysym): Use it. src/ChangeLog addition: 2015-03-14 Aidan Kehoe * general-slots.h (Qno_character_typed): New error symbol. * event-stream.c (syms_of_event_stream): Define it. New error, for those cases when a keystroke is to be treated as a character in some context but has no character equivalent. * cmds.c (Fself_insert_command): Use it. diff -r 916b48abd1c6 -r c87b776ab0e1 lisp/ChangeLog --- a/lisp/ChangeLog Sat Mar 14 01:16:45 2015 +0000 +++ b/lisp/ChangeLog Sat Mar 14 01:40:49 2015 +0000 @@ -1,3 +1,11 @@ +2015-03-14 Aidan Kehoe + + * cmdloop.el (no-character-typed): + New error, for those cases when a keystroke is to be treated as a + character but has no character equivalent. + * cmdloop.el (read-char-1): Use it. + * keymap.el (synthesize-keysym): Use it. + 2015-03-14 Aidan Kehoe * cus-start.el (all): Describe help-event-list for Custom. diff -r 916b48abd1c6 -r c87b776ab0e1 lisp/cmdloop.el --- a/lisp/cmdloop.el Sat Mar 14 01:16:45 2015 +0000 +++ b/lisp/cmdloop.el Sat Mar 14 01:40:49 2015 +0000 @@ -280,6 +280,10 @@ (princ (gettext " not defined.") stream) ; doo dah, doo dah. )) +(put 'no-character-typed 'display-error + #'(lambda (error-object stream) + (write-sequence "Not a character keystroke, " stream) + (write-sequence (key-description (cadr error-object)) stream))) (defcustom teach-extended-commands-p t "*If true, then `\\[execute-extended-command]' will teach you keybindings. @@ -593,8 +597,7 @@ (aref (cdr binding) (caar binding))))))) (return-from read-char-1 character))) (if errorp - (error 'invalid-key-binding "Not a character keystroke" - (aref events 0))) + (error 'no-character-typed (aref events 0))) ;; If we're not erroring, loop until we get a character (setq events [])) (if timeout (disable-timeout timeout)))))) diff -r 916b48abd1c6 -r c87b776ab0e1 lisp/keymap.el --- a/lisp/keymap.el Sat Mar 14 01:16:45 2015 +0000 +++ b/lisp/keymap.el Sat Mar 14 01:40:49 2015 +0000 @@ -512,7 +512,7 @@ (error "Illegal character in keysym: %c" char)) (t ;; Illegal event. - (error "Event has no character equivalent: %s" event)))) + (error 'no-character-typed event)))) (vector (intern (concat "" (nreverse list)))))) (defun synthesize-unicode-codepoint (ignore-prompt) diff -r 916b48abd1c6 -r c87b776ab0e1 src/ChangeLog --- a/src/ChangeLog Sat Mar 14 01:16:45 2015 +0000 +++ b/src/ChangeLog Sat Mar 14 01:40:49 2015 +0000 @@ -1,3 +1,12 @@ +2015-03-14 Aidan Kehoe + + * general-slots.h (Qno_character_typed): New error symbol. + * event-stream.c (syms_of_event_stream): Define it. + New error, for those cases when a keystroke is to be treated as a + character in some context but has no character equivalent. + * cmds.c (Fself_insert_command): + Use it. + 2015-03-14 Aidan Kehoe Add support for GNU's help-event-list here, useful for accepting diff -r 916b48abd1c6 -r c87b776ab0e1 src/cmds.c --- a/src/cmds.c Sat Mar 14 01:16:45 2015 +0000 +++ b/src/cmds.c Sat Mar 14 01:40:49 2015 +0000 @@ -346,9 +346,9 @@ c = Fevent_to_character (Vlast_command_event, Qnil, Qnil, Qnil); if (NILP (c)) - invalid_operation ( - "Last typed key has no character equivalent (that we know of)", - Fcopy_event (Vlast_command_event, Qnil)); + { + Fsignal (Qno_character_typed, Fcopy_event (Vlast_command_event, Qnil)); + } CHECK_CHAR_COERCE_INT (c); diff -r 916b48abd1c6 -r c87b776ab0e1 src/event-stream.c --- a/src/event-stream.c Sat Mar 14 01:16:45 2015 +0000 +++ b/src/event-stream.c Sat Mar 14 01:40:49 2015 +0000 @@ -4920,6 +4920,7 @@ DEFSYMBOL (Qcommand_event_p); DEFERROR_STANDARD (Qundefined_keystroke_sequence, Qsyntax_error); + DEFERROR_STANDARD (Qno_character_typed, Qundefined_keystroke_sequence); DEFERROR_STANDARD (Qinvalid_key_binding, Qinvalid_state); DEFSUBR (Frecent_keys); diff -r 916b48abd1c6 -r c87b776ab0e1 src/general-slots.h --- a/src/general-slots.h Sat Mar 14 01:16:45 2015 +0000 +++ b/src/general-slots.h Sat Mar 14 01:40:49 2015 +0000 @@ -213,6 +213,7 @@ SYMBOL_MODULE_API (Qnative); SYMBOL (Qnatnum); SYMBOL (Qno); +SYMBOL (Qno_character_typed); SYMBOL (Qnone); SYMBOL (Qnot); SYMBOL (Qnothing);