aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2002-05-10 07:03:20 +0000
committerKim F. Storm2002-05-10 07:03:20 +0000
commit99cbcacac3e0a731aeff5ef6e4b7bb32c9c1fe98 (patch)
tree3049bd4d892f9008552cbda2ab8cdbd61b9b870c
parent05b2c53f3ad0d7c5dbf5b8a5abd70c6715310196 (diff)
downloademacs-99cbcacac3e0a731aeff5ef6e4b7bb32c9c1fe98.tar.gz
emacs-99cbcacac3e0a731aeff5ef6e4b7bb32c9c1fe98.zip
(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.
-rw-r--r--src/keymap.c150
1 files changed, 88 insertions, 62 deletions
diff --git a/src/keymap.c b/src/keymap.c
index e56a21a735a..60d1b41d2c4 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -75,6 +75,9 @@ Lisp_Object Vminor_mode_map_alist;
75 minor mode variables and keymaps. */ 75 minor mode variables and keymaps. */
76Lisp_Object Vminor_mode_overriding_map_alist; 76Lisp_Object Vminor_mode_overriding_map_alist;
77 77
78/* List of emulation mode keymap alists. */
79Lisp_Object Vemulation_mode_map_alists;
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. */
@@ -1278,81 +1281,94 @@ current_minor_maps (modeptr, mapptr)
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))
1290 if ((assoc = XCAR (alist), CONSP (assoc))
1291 && (var = XCAR (assoc), SYMBOLP (var))
1292 && (val = find_symbol_value (var), !EQ (val, Qunbound))
1293 && !NILP (val))
1294 { 1294 {
1295 Lisp_Object temp; 1295 alist = XCAR (emulation_alists);
1296 emulation_alists = XCDR (emulation_alists);
1297 if (SYMBOLP (alist))
1298 alist = find_symbol_value (alist);
1299 list_number = -1;
1300 }
1301 else
1302 alist = lists[list_number];
1296 1303
1297 /* If a variable has an entry in Vminor_mode_overriding_map_alist, 1304 for ( ; CONSP (alist); alist = XCDR (alist))
1298 and also an entry in Vminor_mode_map_alist, 1305 if ((assoc = XCAR (alist), CONSP (assoc))
1299 ignore the latter. */ 1306 && (var = XCAR (assoc), SYMBOLP (var))
1300 if (list_number == 1) 1307 && (val = find_symbol_value (var), !EQ (val, Qunbound))
1301 { 1308 && !NILP (val))
1302 val = assq_no_quit (var, lists[0]); 1309 {
1303 if (!NILP (val)) 1310 Lisp_Object temp;
1304 continue;
1305 }
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. */
1315 if (list_number == 1)
1316 {
1317 val = assq_no_quit (var, lists[0]);
1318 if (!NILP (val))
1319 continue;
1320 }
1310 1321
1311 /* Use malloc/realloc here. See the comment above 1322 if (i >= cmm_size)
1312 this function. */ 1323 {
1313 if (cmm_maps) 1324 Lisp_Object *newmodes, *newmaps;
1314 {
1315 BLOCK_INPUT;
1316 cmm_size *= 2;
1317 newmodes
1318 = (Lisp_Object *) realloc (cmm_modes,
1319 cmm_size * sizeof *newmodes);
1320 newmaps
1321 = (Lisp_Object *) realloc (cmm_maps,
1322 cmm_size * sizeof *newmaps);
1323 UNBLOCK_INPUT;
1324 }
1325 else
1326 {
1327 BLOCK_INPUT;
1328 cmm_size = 30;
1329 newmodes
1330 = (Lisp_Object *) malloc (cmm_size * sizeof *newmodes);
1331 newmaps
1332 = (Lisp_Object *) malloc (cmm_size * sizeof *newmaps);
1333 UNBLOCK_INPUT;
1334 }
1335 1325
1336 if (newmodes) 1326 /* Use malloc/realloc here. See the comment above
1337 cmm_modes = newmodes; 1327 this function. */
1338 if (newmaps) 1328 if (cmm_maps)
1339 cmm_maps = newmaps; 1329 {
1330 BLOCK_INPUT;
1331 cmm_size *= 2;
1332 newmodes
1333 = (Lisp_Object *) realloc (cmm_modes,
1334 cmm_size * sizeof *newmodes);
1335 newmaps
1336 = (Lisp_Object *) realloc (cmm_maps,
1337 cmm_size * sizeof *newmaps);
1338 UNBLOCK_INPUT;
1339 }
1340 else
1341 {
1342 BLOCK_INPUT;
1343 cmm_size = 30;
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;
@@ -3579,6 +3595,16 @@ used the same way (and before `minor-mode-map-alist'); however,
3579it is provided for major modes to bind locally. */); 3595it is provided for major modes to bind locally. */);
3580 Vminor_mode_overriding_map_alist = Qnil; 3596 Vminor_mode_overriding_map_alist = Qnil;
3581 3597
3598 DEFVAR_LISP ("emulation-mode-map-alists", &Vemulation_mode_map_alists,
3599 doc: /* List of keymap alists to use for emulations modes.
3600It is intended for modes or packages using multiple minor-mode keymaps.
3601Each element is a keymap alist just like `minor-mode-map-alist', or a
3602symbol with a variable binding which is a keymap alist, and it is used
3603the 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
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.
3584This allows Emacs to recognize function keys sent from ASCII 3610This allows Emacs to recognize function keys sent from ASCII