aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorJim Blandy1992-01-28 17:14:13 +0000
committerJim Blandy1992-01-28 17:14:13 +0000
commit6bbbd9b0eeac2e41c7bce72e80e77dafe81e71b3 (patch)
tree3d11b06bcb0542ce662da74894fbe644c595e285 /src/keymap.c
parent760cbdd312c714899cf76f5ca39d8fd17a6a28e4 (diff)
downloademacs-6bbbd9b0eeac2e41c7bce72e80e77dafe81e71b3.tar.gz
emacs-6bbbd9b0eeac2e41c7bce72e80e77dafe81e71b3.zip
*** empty log message ***
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/src/keymap.c b/src/keymap.c
index ec45512837b..5fde6b20a74 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -24,6 +24,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24#include "lisp.h" 24#include "lisp.h"
25#include "commands.h" 25#include "commands.h"
26#include "buffer.h" 26#include "buffer.h"
27#include "keyboard.h"
27 28
28#define min(a, b) ((a) < (b) ? (a) : (b)) 29#define min(a, b) ((a) < (b) ? (a) : (b))
29 30
@@ -67,6 +68,11 @@ Lisp_Object Vminibuffer_local_must_match_map;
67/* Alist of minor mode variables and keymaps. */ 68/* Alist of minor mode variables and keymaps. */
68Lisp_Object Vminor_mode_map_alist; 69Lisp_Object Vminor_mode_map_alist;
69 70
71/* Keymap mapping ASCII function key sequences onto their preferred forms.
72 Initialized by the terminal-specific lisp files. See DEFVAR for more
73 documentation. */
74Lisp_Object Vfunction_key_map;
75
70Lisp_Object Qkeymapp, Qkeymap; 76Lisp_Object Qkeymapp, Qkeymap;
71 77
72/* A char over 0200 in a key sequence 78/* A char over 0200 in a key sequence
@@ -220,8 +226,8 @@ access_keymap (map, idx)
220 /* If idx is a list (some sort of mouse click, perhaps?), 226 /* If idx is a list (some sort of mouse click, perhaps?),
221 the index we want to use is the car of the list, which 227 the index we want to use is the car of the list, which
222 ought to be a symbol. */ 228 ought to be a symbol. */
223 if (XTYPE (idx) == Lisp_Cons) 229 if (EVENT_HAS_PARAMETERS (idx))
224 idx = XCONS (idx)->car; 230 idx = EVENT_HEAD (idx);
225 231
226 if (XTYPE (idx) == Lisp_Int 232 if (XTYPE (idx) == Lisp_Int
227 && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) 233 && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE))
@@ -295,8 +301,8 @@ store_in_keymap (keymap, idx, def)
295 /* If idx is a list (some sort of mouse click, perhaps?), 301 /* If idx is a list (some sort of mouse click, perhaps?),
296 the index we want to use is the car of the list, which 302 the index we want to use is the car of the list, which
297 ought to be a symbol. */ 303 ought to be a symbol. */
298 if (XTYPE (idx) == Lisp_Cons) 304 if (EVENT_HAS_PARAMETERS (idx))
299 idx = Fcar (idx); 305 idx = EVENT_HEAD (idx);
300 306
301 if (XTYPE (idx) == Lisp_Int 307 if (XTYPE (idx) == Lisp_Int
302 && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) 308 && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE))
@@ -569,7 +575,8 @@ append_key (key_sequence, key)
569/* Global, local, and minor mode keymap stuff. */ 575/* Global, local, and minor mode keymap stuff. */
570 576
571/* We can't put these variables inside current_minor_maps, since under 577/* We can't put these variables inside current_minor_maps, since under
572 DGUX they dump as pure. Bleah. */ 578 some systems, static gets macro-defined to be the empty string.
579 Ickypoo. */
573static Lisp_Object *cmm_modes, *cmm_maps; 580static Lisp_Object *cmm_modes, *cmm_maps;
574static int cmm_size; 581static int cmm_size;
575 582
@@ -594,15 +601,15 @@ current_minor_maps (modeptr, mapptr)
594 Lisp_Object **modeptr, **mapptr; 601 Lisp_Object **modeptr, **mapptr;
595{ 602{
596 int i = 0; 603 int i = 0;
597 Lisp_Object alist, assoc, var; 604 Lisp_Object alist, assoc, var, val;
598 605
599 for (alist = Vminor_mode_map_alist; 606 for (alist = Vminor_mode_map_alist;
600 CONSP (alist); 607 CONSP (alist);
601 alist = XCONS (alist)->cdr) 608 alist = XCONS (alist)->cdr)
602 if (CONSP (assoc = XCONS (alist)->car) 609 if (CONSP (assoc = XCONS (alist)->car)
603 && XTYPE (var = XCONS (assoc)->car) == Lisp_Symbol 610 && XTYPE (var = XCONS (assoc)->car) == Lisp_Symbol
604 && ! NILP (Fboundp (var)) 611 && ! EQ ((val = find_symbol_value (var)), Qunbound)
605 && ! NILP (Fsymbol_value (var))) 612 && ! NILP (val))
606 { 613 {
607 if (i >= cmm_size) 614 if (i >= cmm_size)
608 { 615 {
@@ -687,7 +694,9 @@ The binding is probably a symbol with a function definition.")
687DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 1, 0, 694DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 1, 0,
688 "Return the binding for command KEYS in current global keymap only.\n\ 695 "Return the binding for command KEYS in current global keymap only.\n\
689KEYS is a string, a sequence of keystrokes.\n\ 696KEYS is a string, a sequence of keystrokes.\n\
690The binding is probably a symbol with a function definition.") 697The binding is probably a symbol with a function definition.\n\
698This function's return values are the same as those of lookup-key\n\
699(which see).")
691 (keys) 700 (keys)
692 Lisp_Object keys; 701 Lisp_Object keys;
693{ 702{
@@ -1089,6 +1098,9 @@ Control characters turn into C-whatever, etc.")
1089 register unsigned char c; 1098 register unsigned char c;
1090 char tem[6]; 1099 char tem[6];
1091 1100
1101 if (EVENT_HAS_PARAMETERS (key))
1102 key = EVENT_HEAD (key);
1103
1092 switch (XTYPE (key)) 1104 switch (XTYPE (key))
1093 { 1105 {
1094 case Lisp_Int: /* Normal character */ 1106 case Lisp_Int: /* Normal character */
@@ -1099,13 +1111,6 @@ Control characters turn into C-whatever, etc.")
1099 case Lisp_Symbol: /* Function key or event-symbol */ 1111 case Lisp_Symbol: /* Function key or event-symbol */
1100 return Fsymbol_name (key); 1112 return Fsymbol_name (key);
1101 1113
1102 case Lisp_Cons: /* Mouse event */
1103 key = XCONS (key)->car;
1104 if (XTYPE (key) == Lisp_Symbol)
1105 return Fsymbol_name (key);
1106 /* Mouse events should have an identifying symbol as their car;
1107 fall through when this isn't the case. */
1108
1109 default: 1114 default:
1110 error ("KEY must be an integer, cons, or symbol."); 1115 error ("KEY must be an integer, cons, or symbol.");
1111 } 1116 }
@@ -1804,6 +1809,24 @@ If two active keymaps bind the same key, the keymap appearing earlier\n\
1804in the list takes precedence."); 1809in the list takes precedence.");
1805 Vminor_mode_map_alist = Qnil; 1810 Vminor_mode_map_alist = Qnil;
1806 1811
1812 DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
1813 "Keymap mapping ASCII function key sequences onto their preferred forms.\n\
1814This allows Emacs to recognize function keys sent from ASCII\n\
1815terminals at any point in a key sequence.\n\
1816\n\
1817The read-key-sequence function replaces subsequences bound by\n\
1818function-key-map with their bindings. When the current local and global\n\
1819keymaps have no binding for the current key sequence but\n\
1820function-key-map binds a suffix of the sequence to a vector,\n\
1821read-key-sequence replaces the matching suffix with its binding, and\n\
1822continues with the new sequence.\n\
1823\n\
1824For example, suppose function-key-map binds `ESC O P' to [pf1].\n\
1825Typing `ESC O P' to read-key-sequence would return [pf1]. Typing\n\
1826`C-x ESC O P' would return [?\C-x pf1]. If [pf1] were a prefix\n\
1827key, typing `ESC O P x' would return [pf1 x].");
1828 Vfunction_key_map = Fmake_sparse_keymap ();
1829
1807 Qsingle_key_description = intern ("single-key-description"); 1830 Qsingle_key_description = intern ("single-key-description");
1808 staticpro (&Qsingle_key_description); 1831 staticpro (&Qsingle_key_description);
1809 1832