comparison src/keymap.c @ 45222:c525c7445e1b

(Vemulation_mode_map_alists): New variable. (syms_of_keymap): DEFVAR_LISP it. (current_minor_maps): Process keymap alists in that list before minor-mode-overriding-map-alist and minor-mode-map-alist.
author Kim F. Storm <storm@cua.dk>
date Fri, 10 May 2002 07:03:20 +0000
parents 20832766c3e1
children 66271fa0bf60
comparison
equal deleted inserted replaced
45221:c57fc4d56186 45222:c525c7445e1b
72 Lisp_Object Vminor_mode_map_alist; 72 Lisp_Object Vminor_mode_map_alist;
73 73
74 /* Alist of major-mode-specific overrides for 74 /* Alist of major-mode-specific overrides for
75 minor mode variables and keymaps. */ 75 minor mode variables and keymaps. */
76 Lisp_Object Vminor_mode_overriding_map_alist; 76 Lisp_Object Vminor_mode_overriding_map_alist;
77
78 /* List of emulation mode keymap alists. */
79 Lisp_Object Vemulation_mode_map_alists;
77 80
78 /* Keymap mapping ASCII function key sequences onto their preferred forms. 81 /* Keymap mapping ASCII function key sequences onto their preferred forms.
79 Initialized by the terminal-specific lisp files. See DEFVAR for more 82 Initialized by the terminal-specific lisp files. See DEFVAR for more
80 documentation. */ 83 documentation. */
81 Lisp_Object Vfunction_key_map; 84 Lisp_Object Vfunction_key_map;
1276 Lisp_Object **modeptr, **mapptr; 1279 Lisp_Object **modeptr, **mapptr;
1277 { 1280 {
1278 int i = 0; 1281 int i = 0;
1279 int list_number = 0; 1282 int list_number = 0;
1280 Lisp_Object alist, assoc, var, val; 1283 Lisp_Object alist, assoc, var, val;
1284 Lisp_Object emulation_alists;
1281 Lisp_Object lists[2]; 1285 Lisp_Object lists[2];
1282 1286
1287 emulation_alists = Vemulation_mode_map_alists;
1283 lists[0] = Vminor_mode_overriding_map_alist; 1288 lists[0] = Vminor_mode_overriding_map_alist;
1284 lists[1] = Vminor_mode_map_alist; 1289 lists[1] = Vminor_mode_map_alist;
1285 1290
1286 for (list_number = 0; list_number < 2; list_number++) 1291 for (list_number = 0; list_number < 2; list_number++)
1287 for (alist = lists[list_number]; 1292 {
1288 CONSP (alist); 1293 if (CONSP (emulation_alists))
1289 alist = XCDR (alist)) 1294 {
1290 if ((assoc = XCAR (alist), CONSP (assoc)) 1295 alist = XCAR (emulation_alists);
1291 && (var = XCAR (assoc), SYMBOLP (var)) 1296 emulation_alists = XCDR (emulation_alists);
1292 && (val = find_symbol_value (var), !EQ (val, Qunbound)) 1297 if (SYMBOLP (alist))
1293 && !NILP (val)) 1298 alist = find_symbol_value (alist);
1294 { 1299 list_number = -1;
1295 Lisp_Object temp; 1300 }
1296 1301 else
1297 /* If a variable has an entry in Vminor_mode_overriding_map_alist, 1302 alist = lists[list_number];
1298 and also an entry in Vminor_mode_map_alist, 1303
1299 ignore the latter. */ 1304 for ( ; CONSP (alist); alist = XCDR (alist))
1300 if (list_number == 1) 1305 if ((assoc = XCAR (alist), CONSP (assoc))
1301 { 1306 && (var = XCAR (assoc), SYMBOLP (var))
1302 val = assq_no_quit (var, lists[0]); 1307 && (val = find_symbol_value (var), !EQ (val, Qunbound))
1303 if (!NILP (val)) 1308 && !NILP (val))
1304 continue; 1309 {
1305 } 1310 Lisp_Object temp;
1306 1311
1307 if (i >= cmm_size) 1312 /* If a variable has an entry in Vminor_mode_overriding_map_alist,
1308 { 1313 and also an entry in Vminor_mode_map_alist,
1309 Lisp_Object *newmodes, *newmaps; 1314 ignore the latter. */
1310 1315 if (list_number == 1)
1311 /* Use malloc/realloc here. See the comment above 1316 {
1312 this function. */ 1317 val = assq_no_quit (var, lists[0]);
1313 if (cmm_maps) 1318 if (!NILP (val))
1314 { 1319 continue;
1315 BLOCK_INPUT; 1320 }
1316 cmm_size *= 2; 1321
1317 newmodes 1322 if (i >= cmm_size)
1318 = (Lisp_Object *) realloc (cmm_modes, 1323 {
1319 cmm_size * sizeof *newmodes); 1324 Lisp_Object *newmodes, *newmaps;
1320 newmaps 1325
1321 = (Lisp_Object *) realloc (cmm_maps, 1326 /* Use malloc/realloc here. See the comment above
1322 cmm_size * sizeof *newmaps); 1327 this function. */
1323 UNBLOCK_INPUT; 1328 if (cmm_maps)
1324 } 1329 {
1325 else 1330 BLOCK_INPUT;
1326 { 1331 cmm_size *= 2;
1327 BLOCK_INPUT; 1332 newmodes
1328 cmm_size = 30; 1333 = (Lisp_Object *) realloc (cmm_modes,
1329 newmodes 1334 cmm_size * sizeof *newmodes);
1330 = (Lisp_Object *) malloc (cmm_size * sizeof *newmodes); 1335 newmaps
1331 newmaps 1336 = (Lisp_Object *) realloc (cmm_maps,
1332 = (Lisp_Object *) malloc (cmm_size * sizeof *newmaps); 1337 cmm_size * sizeof *newmaps);
1333 UNBLOCK_INPUT; 1338 UNBLOCK_INPUT;
1334 } 1339 }
1335 1340 else
1336 if (newmodes) 1341 {
1337 cmm_modes = newmodes; 1342 BLOCK_INPUT;
1338 if (newmaps) 1343 cmm_size = 30;
1339 cmm_maps = newmaps; 1344 newmodes
1345 = (Lisp_Object *) malloc (cmm_size * sizeof *newmodes);
1346 newmaps
1347 = (Lisp_Object *) malloc (cmm_size * sizeof *newmaps);
1348 UNBLOCK_INPUT;
1349 }
1350
1351 if (newmodes)
1352 cmm_modes = newmodes;
1353 if (newmaps)
1354 cmm_maps = newmaps;
1340 1355
1341 if (newmodes == NULL || newmaps == NULL) 1356 if (newmodes == NULL || newmaps == NULL)
1342 break; 1357 break;
1343 } 1358 }
1344 1359
1345 /* Get the keymap definition--or nil if it is not defined. */ 1360 /* Get the keymap definition--or nil if it is not defined. */
1346 temp = internal_condition_case_1 (Findirect_function, 1361 temp = internal_condition_case_1 (Findirect_function,
1347 XCDR (assoc), 1362 XCDR (assoc),
1348 Qerror, current_minor_maps_error); 1363 Qerror, current_minor_maps_error);
1349 if (!NILP (temp)) 1364 if (!NILP (temp))
1350 { 1365 {
1351 cmm_modes[i] = var; 1366 cmm_modes[i] = var;
1352 cmm_maps [i] = temp; 1367 cmm_maps [i] = temp;
1353 i++; 1368 i++;
1354 } 1369 }
1355 } 1370 }
1371 }
1356 1372
1357 if (modeptr) *modeptr = cmm_modes; 1373 if (modeptr) *modeptr = cmm_modes;
1358 if (mapptr) *mapptr = cmm_maps; 1374 if (mapptr) *mapptr = cmm_maps;
1359 return i; 1375 return i;
1360 } 1376 }
3576 doc: /* Alist of keymaps to use for minor modes, in current major mode. 3592 doc: /* Alist of keymaps to use for minor modes, in current major mode.
3577 This variable is a alist just like `minor-mode-map-alist', and it is 3593 This variable is a alist just like `minor-mode-map-alist', and it is
3578 used the same way (and before `minor-mode-map-alist'); however, 3594 used the same way (and before `minor-mode-map-alist'); however,
3579 it is provided for major modes to bind locally. */); 3595 it is provided for major modes to bind locally. */);
3580 Vminor_mode_overriding_map_alist = Qnil; 3596 Vminor_mode_overriding_map_alist = Qnil;
3597
3598 DEFVAR_LISP ("emulation-mode-map-alists", &Vemulation_mode_map_alists,
3599 doc: /* List of keymap alists to use for emulations modes.
3600 It is intended for modes or packages using multiple minor-mode keymaps.
3601 Each element is a keymap alist just like `minor-mode-map-alist', or a
3602 symbol with a variable binding which is a keymap alist, and it is used
3603 the same way. The "active" keymaps in each alist are used before
3604 `minor-mode-map-alist' and `minor-mode-overriding-map-alist'. */);
3605 Vemulation_mode_map_alists = Qnil;
3606
3581 3607
3582 DEFVAR_LISP ("function-key-map", &Vfunction_key_map, 3608 DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
3583 doc: /* Keymap mapping ASCII function key sequences onto their preferred forms. 3609 doc: /* Keymap mapping ASCII function key sequences onto their preferred forms.
3584 This allows Emacs to recognize function keys sent from ASCII 3610 This allows Emacs to recognize function keys sent from ASCII
3585 terminals at any point in a key sequence. 3611 terminals at any point in a key sequence.