Mercurial > emacs
comparison src/keyboard.c @ 39973:579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
with lisp system changes.
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Tue, 16 Oct 2001 09:09:51 +0000 |
parents | 61964d31a7a2 |
children | a8f1728d40c2 |
comparison
equal
deleted
inserted
replaced
39972:b2479b43184b | 39973:579177964efa |
---|---|
2356 #ifdef MULTI_KBOARD | 2356 #ifdef MULTI_KBOARD |
2357 { | 2357 { |
2358 KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame)); | 2358 KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame)); |
2359 if (kb != current_kboard) | 2359 if (kb != current_kboard) |
2360 { | 2360 { |
2361 Lisp_Object *tailp = &kb->kbd_queue; | 2361 Lisp_Object link = kb->kbd_queue; |
2362 /* We shouldn't get here if we were in single-kboard mode! */ | 2362 /* We shouldn't get here if we were in single-kboard mode! */ |
2363 if (single_kboard) | 2363 if (single_kboard) |
2364 abort (); | 2364 abort (); |
2365 while (CONSP (*tailp)) | 2365 if (CONSP (link)) |
2366 tailp = &XCDR (*tailp); | 2366 { |
2367 if (!NILP (*tailp)) | 2367 while (CONSP (XCDR (link))) |
2368 abort (); | 2368 link = XCDR (link); |
2369 *tailp = Fcons (c, Qnil); | 2369 if (!NILP (XCDR (link))) |
2370 abort (); | |
2371 } | |
2372 if (!CONSP (link)) | |
2373 kb->kbd_queue = Fcons (c, Qnil); | |
2374 else | |
2375 XSETCDR (link, Fcons (c, Qnil)); | |
2370 kb->kbd_queue_has_data = 1; | 2376 kb->kbd_queue_has_data = 1; |
2371 current_kboard = kb; | 2377 current_kboard = kb; |
2372 /* This is going to exit from read_char | 2378 /* This is going to exit from read_char |
2373 so we had better get rid of this frame's stuff. */ | 2379 so we had better get rid of this frame's stuff. */ |
2374 UNGCPRO; | 2380 UNGCPRO; |
2579 restore_getcjmp (save_jump); | 2585 restore_getcjmp (save_jump); |
2580 | 2586 |
2581 #ifdef MULTI_KBOARD | 2587 #ifdef MULTI_KBOARD |
2582 if (! NILP (c) && (kb != current_kboard)) | 2588 if (! NILP (c) && (kb != current_kboard)) |
2583 { | 2589 { |
2584 Lisp_Object *tailp = &kb->kbd_queue; | 2590 Lisp_Object link = kb->kbd_queue; |
2585 while (CONSP (*tailp)) | 2591 if (CONSP (link)) |
2586 tailp = &XCDR (*tailp); | 2592 { |
2587 if (!NILP (*tailp)) | 2593 while (CONSP (XCDR (link))) |
2588 abort (); | 2594 link = XCDR (link); |
2589 *tailp = Fcons (c, Qnil); | 2595 if (!NILP (XCDR (link))) |
2596 abort (); | |
2597 } | |
2598 if (!CONSP (link)) | |
2599 kb->kbd_queue = Fcons (c, Qnil); | |
2600 else | |
2601 XSETCDR (link, Fcons (c, Qnil)); | |
2590 kb->kbd_queue_has_data = 1; | 2602 kb->kbd_queue_has_data = 1; |
2591 c = Qnil; | 2603 c = Qnil; |
2592 if (single_kboard) | 2604 if (single_kboard) |
2593 goto wrong_kboard; | 2605 goto wrong_kboard; |
2594 current_kboard = kb; | 2606 current_kboard = kb; |
2700 /* Handle menu-bar events: | 2712 /* Handle menu-bar events: |
2701 insert the dummy prefix event `menu-bar'. */ | 2713 insert the dummy prefix event `menu-bar'. */ |
2702 if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) | 2714 if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) |
2703 { | 2715 { |
2704 /* Change menu-bar to (menu-bar) as the event "position". */ | 2716 /* Change menu-bar to (menu-bar) as the event "position". */ |
2705 POSN_BUFFER_POSN (EVENT_START (c)) = Fcons (posn, Qnil); | 2717 POSN_BUFFER_SET_POSN (EVENT_START (c), Fcons (posn, Qnil)); |
2706 | 2718 |
2707 also_record = c; | 2719 also_record = c; |
2708 Vunread_command_events = Fcons (c, Vunread_command_events); | 2720 Vunread_command_events = Fcons (c, Vunread_command_events); |
2709 c = posn; | 2721 c = posn; |
2710 } | 2722 } |
6852 /* This is a command. See if there is an equivalent key binding. */ | 6864 /* This is a command. See if there is an equivalent key binding. */ |
6853 if (NILP (cachelist)) | 6865 if (NILP (cachelist)) |
6854 { | 6866 { |
6855 /* We have to create a cachelist. */ | 6867 /* We have to create a cachelist. */ |
6856 CHECK_IMPURE (start); | 6868 CHECK_IMPURE (start); |
6857 XCDR (start) = Fcons (Fcons (Qnil, Qnil), XCDR (start)); | 6869 XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start))); |
6858 cachelist = XCAR (XCDR (start)); | 6870 cachelist = XCAR (XCDR (start)); |
6859 newcache = 1; | 6871 newcache = 1; |
6860 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ); | 6872 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ); |
6861 if (!NILP (keyhint)) | 6873 if (!NILP (keyhint)) |
6862 { | 6874 { |
6863 XCAR (cachelist) = XCAR (keyhint); | 6875 XSETCAR (cachelist, XCAR (keyhint)); |
6864 newcache = 0; | 6876 newcache = 0; |
6865 } | 6877 } |
6866 else if (STRINGP (tem)) | 6878 else if (STRINGP (tem)) |
6867 { | 6879 { |
6868 XCDR (cachelist) = Fsubstitute_command_keys (tem); | 6880 XSETCDR (cachelist, Fsubstitute_command_keys (tem)); |
6869 XCAR (cachelist) = Qt; | 6881 XSETCAR (cachelist, Qt); |
6870 } | 6882 } |
6871 } | 6883 } |
6872 | 6884 |
6873 tem = XCAR (cachelist); | 6885 tem = XCAR (cachelist); |
6874 if (!EQ (tem, Qt)) | 6886 if (!EQ (tem, Qt)) |
6922 if (SYMBOLP (def) | 6934 if (SYMBOLP (def) |
6923 && SYMBOLP (XSYMBOL (def)->function) | 6935 && SYMBOLP (XSYMBOL (def)->function) |
6924 && ! NILP (Fget (def, Qmenu_alias))) | 6936 && ! NILP (Fget (def, Qmenu_alias))) |
6925 def = XSYMBOL (def)->function; | 6937 def = XSYMBOL (def)->function; |
6926 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil); | 6938 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil); |
6927 XCAR (cachelist) = tem; | 6939 XSETCAR (cachelist, tem); |
6928 if (NILP (tem)) | 6940 if (NILP (tem)) |
6929 { | 6941 { |
6930 XCDR (cachelist) = Qnil; | 6942 XSETCDR (cachelist, Qnil); |
6931 chkcache = 0; | 6943 chkcache = 0; |
6932 } | 6944 } |
6933 } | 6945 } |
6934 else if (!NILP (keyhint) && !NILP (XCAR (cachelist))) | 6946 else if (!NILP (keyhint) && !NILP (XCAR (cachelist))) |
6935 { | 6947 { |
6946 if (STRINGP (XCAR (prefix))) | 6958 if (STRINGP (XCAR (prefix))) |
6947 tem = concat2 (XCAR (prefix), tem); | 6959 tem = concat2 (XCAR (prefix), tem); |
6948 if (STRINGP (XCDR (prefix))) | 6960 if (STRINGP (XCDR (prefix))) |
6949 tem = concat2 (tem, XCDR (prefix)); | 6961 tem = concat2 (tem, XCDR (prefix)); |
6950 } | 6962 } |
6951 XCDR (cachelist) = tem; | 6963 XSETCDR (cachelist, tem); |
6952 } | 6964 } |
6953 } | 6965 } |
6954 | 6966 |
6955 tem = XCDR (cachelist); | 6967 tem = XCDR (cachelist); |
6956 if (newcache && !NILP (tem)) | 6968 if (newcache && !NILP (tem)) |
6957 { | 6969 { |
6958 tem = concat3 (build_string (" ("), tem, build_string (")")); | 6970 tem = concat3 (build_string (" ("), tem, build_string (")")); |
6959 XCDR (cachelist) = tem; | 6971 XSETCDR (cachelist, tem); |
6960 } | 6972 } |
6961 | 6973 |
6962 /* If we only want to precompute equivalent key bindings, stop here. */ | 6974 /* If we only want to precompute equivalent key bindings, stop here. */ |
6963 if (notreal) | 6975 if (notreal) |
6964 return 1; | 6976 return 1; |
7472 for (tem = XCDR (value); !NILP (tem); tem = XCDR (tem)) | 7484 for (tem = XCDR (value); !NILP (tem); tem = XCDR (tem)) |
7473 { | 7485 { |
7474 record_menu_key (XCAR (tem)); | 7486 record_menu_key (XCAR (tem)); |
7475 if (SYMBOLP (XCAR (tem)) | 7487 if (SYMBOLP (XCAR (tem)) |
7476 || INTEGERP (XCAR (tem))) | 7488 || INTEGERP (XCAR (tem))) |
7477 XCAR (tem) = Fcons (XCAR (tem), Qdisabled); | 7489 XSETCAR (tem, Fcons (XCAR (tem), Qdisabled)); |
7478 } | 7490 } |
7479 | 7491 |
7480 /* If we got more than one event, put all but the first | 7492 /* If we got more than one event, put all but the first |
7481 onto this list to be read later. | 7493 onto this list to be read later. |
7482 Return just the first event now. */ | 7494 Return just the first event now. */ |
8464 keybuf[t] = posn; | 8476 keybuf[t] = posn; |
8465 keybuf[t+1] = key; | 8477 keybuf[t+1] = key; |
8466 | 8478 |
8467 /* Zap the position in key, so we know that we've | 8479 /* Zap the position in key, so we know that we've |
8468 expanded it, and don't try to do so again. */ | 8480 expanded it, and don't try to do so again. */ |
8469 POSN_BUFFER_POSN (EVENT_START (key)) | 8481 POSN_BUFFER_SET_POSN (EVENT_START (key), |
8470 = Fcons (posn, Qnil); | 8482 Fcons (posn, Qnil)); |
8471 | 8483 |
8472 mock_input = t + 2; | 8484 mock_input = t + 2; |
8473 goto replay_sequence; | 8485 goto replay_sequence; |
8474 } | 8486 } |
8475 else if (CONSP (posn)) | 8487 else if (CONSP (posn)) |
9201 /* Don't keep command history around forever. */ | 9213 /* Don't keep command history around forever. */ |
9202 if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0) | 9214 if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0) |
9203 { | 9215 { |
9204 tem = Fnthcdr (Vhistory_length, Vcommand_history); | 9216 tem = Fnthcdr (Vhistory_length, Vcommand_history); |
9205 if (CONSP (tem)) | 9217 if (CONSP (tem)) |
9206 XCDR (tem) = Qnil; | 9218 XSETCDR (tem, Qnil); |
9207 } | 9219 } |
9208 } | 9220 } |
9209 | 9221 |
9210 return Fexecute_kbd_macro (final, prefixarg); | 9222 return Fexecute_kbd_macro (final, prefixarg); |
9211 } | 9223 } |