diff options
| author | Richard M. Stallman | 2001-12-29 14:54:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-12-29 14:54:28 +0000 |
| commit | 15fff01d494352c1267473647599389dce7c24c2 (patch) | |
| tree | fa52c7a50a7c56dc5d60d739c08df38d57bdc87b /src | |
| parent | 71cf5fa051283be4de2aea9eb078493add766e1e (diff) | |
| download | emacs-15fff01d494352c1267473647599389dce7c24c2.tar.gz emacs-15fff01d494352c1267473647599389dce7c24c2.zip | |
(silly_event_symbol_error): New subrtn, from Fdefine_key.
Handle modifier bits. Correct typo in error message.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/keymap.c | 54 |
2 files changed, 54 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 116d8ec26e4..02e47483009 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2001-12-29 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * keymap.c (silly_event_symbol_error): New subrtn, from Fdefine_key. | ||
| 4 | Handle modifier bits. Correct typo in error message. | ||
| 5 | |||
| 1 | 2001-12-28 Richard M. Stallman <rms@gnu.org> | 6 | 2001-12-28 Richard M. Stallman <rms@gnu.org> |
| 2 | 7 | ||
| 3 | * abbrev.c: Use the plist of an abbrev for multiple params if nec. | 8 | * abbrev.c: Use the plist of an abbrev for multiple params if nec. |
diff --git a/src/keymap.c b/src/keymap.c index ecc17e4a957..a6867db32c0 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -115,6 +115,7 @@ static void describe_translation P_ ((Lisp_Object, Lisp_Object)); | |||
| 115 | static void describe_map P_ ((Lisp_Object, Lisp_Object, | 115 | static void describe_map P_ ((Lisp_Object, Lisp_Object, |
| 116 | void (*) P_ ((Lisp_Object, Lisp_Object)), | 116 | void (*) P_ ((Lisp_Object, Lisp_Object)), |
| 117 | int, Lisp_Object, Lisp_Object*, int)); | 117 | int, Lisp_Object, Lisp_Object*, int)); |
| 118 | static void silly_event_symbol_error P_ ((Lisp_Object)); | ||
| 118 | 119 | ||
| 119 | /* Keymap object support - constructors and predicates. */ | 120 | /* Keymap object support - constructors and predicates. */ |
| 120 | 121 | ||
| @@ -1011,11 +1012,8 @@ the front of KEYMAP. */) | |||
| 1011 | if (CONSP (c) && lucid_event_type_list_p (c)) | 1012 | if (CONSP (c) && lucid_event_type_list_p (c)) |
| 1012 | c = Fevent_convert_list (c); | 1013 | c = Fevent_convert_list (c); |
| 1013 | 1014 | ||
| 1014 | if (SYMBOLP (c) && ! NILP (Fassoc (Fsymbol_name (c), exclude_keys))) | 1015 | if (SYMBOLP (c)) |
| 1015 | error ("To bind the key %s, use; use \"%s\", not [%s]", | 1016 | silly_event_symbol_error (c); |
| 1016 | XSYMBOL (c)->name->data, | ||
| 1017 | XSTRING (XCDR (Fassoc (Fsymbol_name (c), exclude_keys)))->data, | ||
| 1018 | XSYMBOL (c)->name->data); | ||
| 1019 | 1017 | ||
| 1020 | if (INTEGERP (c) | 1018 | if (INTEGERP (c) |
| 1021 | && (XINT (c) & meta_bit) | 1019 | && (XINT (c) & meta_bit) |
| @@ -1156,6 +1154,52 @@ append_key (key_sequence, key) | |||
| 1156 | return Fvconcat (2, args); | 1154 | return Fvconcat (2, args); |
| 1157 | } | 1155 | } |
| 1158 | 1156 | ||
| 1157 | /* Given a event type C which is a symbol, | ||
| 1158 | signal an error if is a mistake such as RET or M-RET or C-DEL, etc. */ | ||
| 1159 | |||
| 1160 | static void | ||
| 1161 | silly_event_symbol_error (c) | ||
| 1162 | Lisp_Object c; | ||
| 1163 | { | ||
| 1164 | Lisp_Object parsed, base, name, assoc; | ||
| 1165 | int modifiers; | ||
| 1166 | |||
| 1167 | parsed = parse_modifiers (c); | ||
| 1168 | modifiers = (int) XUINT (XCAR (XCDR (parsed))); | ||
| 1169 | base = XCAR (parsed); | ||
| 1170 | name = Fsymbol_name (base); | ||
| 1171 | /* This alist includes elements such as ("RET" . "\\r"). */ | ||
| 1172 | assoc = Fassoc (name, exclude_keys); | ||
| 1173 | |||
| 1174 | if (! NILP (assoc)) | ||
| 1175 | { | ||
| 1176 | char new_mods[sizeof ("\\A-\\C-\\H-\\M-\\S-\\s-")]; | ||
| 1177 | char *p = new_mods; | ||
| 1178 | Lisp_Object keystring; | ||
| 1179 | if (modifiers & alt_modifier) | ||
| 1180 | { *p++ = '\\'; *p++ = 'A'; *p++ = '-'; } | ||
| 1181 | if (modifiers & ctrl_modifier) | ||
| 1182 | { *p++ = '\\'; *p++ = 'C'; *p++ = '-'; } | ||
| 1183 | if (modifiers & hyper_modifier) | ||
| 1184 | { *p++ = '\\'; *p++ = 'H'; *p++ = '-'; } | ||
| 1185 | if (modifiers & meta_modifier) | ||
| 1186 | { *p++ = '\\'; *p++ = 'M'; *p++ = '-'; } | ||
| 1187 | if (modifiers & shift_modifier) | ||
| 1188 | { *p++ = '\\'; *p++ = 'S'; *p++ = '-'; } | ||
| 1189 | if (modifiers & super_modifier) | ||
| 1190 | { *p++ = '\\'; *p++ = 's'; *p++ = '-'; } | ||
| 1191 | *p = 0; | ||
| 1192 | |||
| 1193 | c = reorder_modifiers (c); | ||
| 1194 | keystring = concat2 (build_string (new_mods), XCDR (assoc)); | ||
| 1195 | |||
| 1196 | error ((modifiers & ~meta_modifier | ||
| 1197 | ? "To bind the key %s, use [?%s], not [%s]" | ||
| 1198 | : "To bind the key %s, use \"%s\", not [%s]"), | ||
| 1199 | XSYMBOL (c)->name->data, XSTRING (keystring)->data, | ||
| 1200 | XSYMBOL (c)->name->data); | ||
| 1201 | } | ||
| 1202 | } | ||
| 1159 | 1203 | ||
| 1160 | /* Global, local, and minor mode keymap stuff. */ | 1204 | /* Global, local, and minor mode keymap stuff. */ |
| 1161 | 1205 | ||