diff options
| author | Richard M. Stallman | 2001-12-28 18:39:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-12-28 18:39:20 +0000 |
| commit | 2fae9111a4e782725fc1a38334bb14664efdd6e5 (patch) | |
| tree | 4c3c1b5e40c15963910a7229a1d4c15e87cd2e97 | |
| parent | 0cb8bb486accf3657e09c4892dd3554fa856578e (diff) | |
| download | emacs-2fae9111a4e782725fc1a38334bb14664efdd6e5.tar.gz emacs-2fae9111a4e782725fc1a38334bb14664efdd6e5.zip | |
(Flookup_key): Add error message for trying to bind [DEL], [RET], etc.
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/keymap.c | 23 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index aa598372946..8428636f6c8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2001-12-28 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * keymap.c (Flookup_key): | ||
| 4 | Add error message for trying to bind [DEL], [RET], etc. | ||
| 5 | |||
| 1 | 2001-12-28 Gerd Moellmann <gerd@gnu.org> | 6 | 2001-12-28 Gerd Moellmann <gerd@gnu.org> |
| 2 | 7 | ||
| 3 | * xterm.c (x_setup_relief_colors): Don't compute an image's | 8 | * xterm.c (x_setup_relief_colors): Don't compute an image's |
diff --git a/src/keymap.c b/src/keymap.c index cc70f6331c7..38cafb916b7 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -48,6 +48,9 @@ Lisp_Object meta_map; /* The keymap used for globally bound | |||
| 48 | Lisp_Object control_x_map; /* The keymap used for globally bound | 48 | Lisp_Object control_x_map; /* The keymap used for globally bound |
| 49 | C-x-prefixed default commands */ | 49 | C-x-prefixed default commands */ |
| 50 | 50 | ||
| 51 | /* Alist of elements like (DEL . "\d"). */ | ||
| 52 | Lisp_Object exclude_keys; | ||
| 53 | |||
| 51 | /* was MinibufLocalMap */ | 54 | /* was MinibufLocalMap */ |
| 52 | Lisp_Object Vminibuffer_local_map; | 55 | Lisp_Object Vminibuffer_local_map; |
| 53 | /* The keymap used by the minibuf for local | 56 | /* The keymap used by the minibuf for local |
| @@ -1008,6 +1011,12 @@ the front of KEYMAP. */) | |||
| 1008 | if (CONSP (c) && lucid_event_type_list_p (c)) | 1011 | if (CONSP (c) && lucid_event_type_list_p (c)) |
| 1009 | c = Fevent_convert_list (c); | 1012 | c = Fevent_convert_list (c); |
| 1010 | 1013 | ||
| 1014 | if (SYMBOLP (c) && ! NILP (Fassoc (Fsymbol_name (c), exclude_keys))) | ||
| 1015 | error ("To bind the key %s, use; use \"%s\", not [%s]", | ||
| 1016 | XSYMBOL (c)->name->data, | ||
| 1017 | XSTRING (XCDR (Fassoc (Fsymbol_name (c), exclude_keys)))->data, | ||
| 1018 | XSYMBOL (c)->name->data); | ||
| 1019 | |||
| 1011 | if (INTEGERP (c) | 1020 | if (INTEGERP (c) |
| 1012 | && (XINT (c) & meta_bit) | 1021 | && (XINT (c) & meta_bit) |
| 1013 | && !metized) | 1022 | && !metized) |
| @@ -1025,7 +1034,7 @@ the front of KEYMAP. */) | |||
| 1025 | } | 1034 | } |
| 1026 | 1035 | ||
| 1027 | if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c)) | 1036 | if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c)) |
| 1028 | error ("Key sequence contains invalid events"); | 1037 | error ("Key sequence contains invalid event"); |
| 1029 | 1038 | ||
| 1030 | if (idx == length) | 1039 | if (idx == length) |
| 1031 | RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); | 1040 | RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); |
| @@ -1098,6 +1107,9 @@ recognize the default bindings, just as `read-key-sequence' does. */) | |||
| 1098 | if (XINT (c) & 0x80 && STRINGP (key)) | 1107 | if (XINT (c) & 0x80 && STRINGP (key)) |
| 1099 | XSETINT (c, (XINT (c) | meta_modifier) & ~0x80); | 1108 | XSETINT (c, (XINT (c) | meta_modifier) & ~0x80); |
| 1100 | 1109 | ||
| 1110 | if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c)) | ||
| 1111 | error ("Key sequence contains invalid event"); | ||
| 1112 | |||
| 1101 | cmd = access_keymap (keymap, c, t_ok, 0, 1); | 1113 | cmd = access_keymap (keymap, c, t_ok, 0, 1); |
| 1102 | if (idx == length) | 1114 | if (idx == length) |
| 1103 | RETURN_UNGCPRO (cmd); | 1115 | RETURN_UNGCPRO (cmd); |
| @@ -3370,6 +3382,15 @@ syms_of_keymap () | |||
| 3370 | Fset (intern ("ctl-x-map"), control_x_map); | 3382 | Fset (intern ("ctl-x-map"), control_x_map); |
| 3371 | Ffset (intern ("Control-X-prefix"), control_x_map); | 3383 | Ffset (intern ("Control-X-prefix"), control_x_map); |
| 3372 | 3384 | ||
| 3385 | exclude_keys | ||
| 3386 | = Fcons (Fcons (build_string ("DEL"), build_string ("\\d")), | ||
| 3387 | Fcons (Fcons (build_string ("TAB"), build_string ("\\t")), | ||
| 3388 | Fcons (Fcons (build_string ("RET"), build_string ("\\r")), | ||
| 3389 | Fcons (Fcons (build_string ("ESC"), build_string ("\\e")), | ||
| 3390 | Fcons (Fcons (build_string ("SPC"), build_string (" ")), | ||
| 3391 | Qnil))))); | ||
| 3392 | staticpro (&exclude_keys); | ||
| 3393 | |||
| 3373 | DEFVAR_LISP ("define-key-rebound-commands", &Vdefine_key_rebound_commands, | 3394 | DEFVAR_LISP ("define-key-rebound-commands", &Vdefine_key_rebound_commands, |
| 3374 | doc: /* List of commands given new key bindings recently. | 3395 | doc: /* List of commands given new key bindings recently. |
| 3375 | This is used for internal purposes during Emacs startup; | 3396 | This is used for internal purposes during Emacs startup; |