Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 5438:8d29f1c4bb98
Merge with 21.5 trunk.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Fri, 26 Nov 2010 06:43:36 +0100 |
parents | 308d34e9f07d c096d8051f89 |
children | ac37a5f7e5be |
comparison
equal
deleted
inserted
replaced
5437:002cb5224e4f | 5438:8d29f1c4bb98 |
---|---|
1234 /**** Lisp-level timeout functions. ****/ | 1234 /**** Lisp-level timeout functions. ****/ |
1235 | 1235 |
1236 static unsigned long | 1236 static unsigned long |
1237 lisp_number_to_milliseconds (Lisp_Object secs, int allow_0) | 1237 lisp_number_to_milliseconds (Lisp_Object secs, int allow_0) |
1238 { | 1238 { |
1239 double fsecs; | 1239 Lisp_Object args[] = { allow_0 ? Qzero : make_int (1), |
1240 CHECK_INT_OR_FLOAT (secs); | 1240 secs, |
1241 fsecs = XFLOATINT (secs); | 1241 /* (((unsigned int) 0xFFFFFFFF) / 1000) - 1 */ |
1242 if (fsecs < 0) | 1242 make_int (4294967 - 1) }; |
1243 invalid_argument ("timeout is negative", secs); | 1243 |
1244 if (!allow_0 && fsecs == 0) | 1244 if (!allow_0 && FLOATP (secs) && XFLOAT_DATA (secs) > 0) |
1245 invalid_argument ("timeout is non-positive", secs); | 1245 { |
1246 if (fsecs >= (((unsigned int) 0xFFFFFFFF) / 1000)) | 1246 args[0] = secs; |
1247 invalid_argument | 1247 } |
1248 ("timeout would exceed 32 bits when represented in milliseconds", secs); | 1248 |
1249 | 1249 if (NILP (Fleq (countof (args), args))) |
1250 return (unsigned long) (1000 * fsecs); | 1250 { |
1251 args_out_of_range_3 (secs, args[0], args[2]); | |
1252 } | |
1253 | |
1254 args[0] = make_int (1000); | |
1255 args[0] = Ftimes (2, args); | |
1256 | |
1257 if (INTP (args[0])) | |
1258 { | |
1259 return XINT (args[0]); | |
1260 } | |
1261 | |
1262 return (unsigned long) extract_float (args[0]); | |
1251 } | 1263 } |
1252 | 1264 |
1253 DEFUN ("add-timeout", Fadd_timeout, 3, 4, 0, /* | 1265 DEFUN ("add-timeout", Fadd_timeout, 3, 4, 0, /* |
1254 Add a timeout, to be signaled after the timeout period has elapsed. | 1266 Add a timeout, to be signaled after the timeout period has elapsed. |
1255 SECS is a number of seconds, expressed as an integer or a float. | 1267 SECS is a number of seconds, expressed as an integer or a float. |
2611 unsigned long msecs = 0; | 2623 unsigned long msecs = 0; |
2612 if (!NILP (timeout_secs)) | 2624 if (!NILP (timeout_secs)) |
2613 msecs = lisp_number_to_milliseconds (timeout_secs, 1); | 2625 msecs = lisp_number_to_milliseconds (timeout_secs, 1); |
2614 if (!NILP (timeout_msecs)) | 2626 if (!NILP (timeout_msecs)) |
2615 { | 2627 { |
2616 CHECK_NATNUM (timeout_msecs); | 2628 check_integer_range (timeout_msecs, Qzero, |
2629 make_integer (EMACS_INT_MAX)); | |
2617 msecs += XINT (timeout_msecs); | 2630 msecs += XINT (timeout_msecs); |
2618 } | 2631 } |
2619 if (msecs) | 2632 if (msecs) |
2620 { | 2633 { |
2621 timeout_id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); | 2634 timeout_id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); |
3700 | 3713 |
3701 if (NILP (number)) | 3714 if (NILP (number)) |
3702 nwanted = recent_keys_ring_size; | 3715 nwanted = recent_keys_ring_size; |
3703 else | 3716 else |
3704 { | 3717 { |
3705 CHECK_NATNUM (number); | 3718 check_integer_range (number, Qzero, |
3719 make_integer (ARRAY_DIMENSION_LIMIT)); | |
3706 nwanted = XINT (number); | 3720 nwanted = XINT (number); |
3707 } | 3721 } |
3708 | 3722 |
3709 /* Create the keys ring vector, if none present. */ | 3723 /* Create the keys ring vector, if none present. */ |
3710 if (NILP (Vrecent_keys_ring)) | 3724 if (NILP (Vrecent_keys_ring)) |
4515 reset_this_command_keys (console, 1); | 4529 reset_this_command_keys (console, 1); |
4516 } | 4530 } |
4517 else /* key sequence is bound to a command */ | 4531 else /* key sequence is bound to a command */ |
4518 { | 4532 { |
4519 int magic_undo = 0; | 4533 int magic_undo = 0; |
4520 int magic_undo_count = 20; | 4534 Elemcount magic_undo_count = 20; |
4521 | 4535 |
4522 Vthis_command = leaf; | 4536 Vthis_command = leaf; |
4523 | 4537 |
4524 /* Don't push an undo boundary if the command set the prefix arg, | 4538 /* Don't push an undo boundary if the command set the prefix arg, |
4525 or if we are executing a keyboard macro, or if in the | 4539 or if we are executing a keyboard macro, or if in the |
4535 | 4549 |
4536 if (SYMBOLP (leaf)) | 4550 if (SYMBOLP (leaf)) |
4537 { | 4551 { |
4538 Lisp_Object prop = Fget (leaf, Qself_insert_defer_undo, Qnil); | 4552 Lisp_Object prop = Fget (leaf, Qself_insert_defer_undo, Qnil); |
4539 if (NATNUMP (prop)) | 4553 if (NATNUMP (prop)) |
4540 magic_undo = 1, magic_undo_count = XINT (prop); | 4554 { |
4555 magic_undo = 1; | |
4556 if (INTP (prop)) | |
4557 { | |
4558 magic_undo_count = XINT (prop); | |
4559 } | |
4560 #ifdef HAVE_BIGNUM | |
4561 else if (BIGNUMP (prop) | |
4562 && bignum_fits_emacs_int_p (XBIGNUM_DATA (prop))) | |
4563 { | |
4564 magic_undo_count | |
4565 = bignum_to_emacs_int (XBIGNUM_DATA (prop)); | |
4566 } | |
4567 #endif | |
4568 } | |
4541 else if (!NILP (prop)) | 4569 else if (!NILP (prop)) |
4542 magic_undo = 1; | 4570 magic_undo = 1; |
4543 else if (EQ (leaf, Qself_insert_command)) | 4571 else if (EQ (leaf, Qself_insert_command)) |
4544 magic_undo = 1; | 4572 magic_undo = 1; |
4545 } | 4573 } |