aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2006-08-03 11:45:23 +0000
committerMiles Bader2006-08-03 11:45:23 +0000
commite2b97060142842813b657144787cef3e6e743967 (patch)
treed7f76853b585d08837d3321504a759919c5fbb42 /src
parenta8fa10a629c86144c90b8b0e58f99581c4e82aba (diff)
parent9b7fa2975f40b82e94dadd13c049ff67ef0ef449 (diff)
downloademacs-e2b97060142842813b657144787cef3e6e743967.tar.gz
emacs-e2b97060142842813b657144787cef3e6e743967.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 357-381) - Merge from gnus--rel--5.10 - Update from CVS - Merge from erc--emacs--21 * gnus--rel--5.10 (patch 116-122) - Update from CVS - Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-98
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog89
-rw-r--r--src/alloc.c167
-rw-r--r--src/callint.c6
-rw-r--r--src/coding.c5
-rw-r--r--src/editfns.c25
-rw-r--r--src/fns.c2
-rw-r--r--src/keyboard.c54
-rw-r--r--src/keyboard.h5
-rw-r--r--src/keymap.c14
-rw-r--r--src/lisp.h6
-rw-r--r--src/lread.c72
-rw-r--r--src/process.c16
-rw-r--r--src/puresize.h2
-rw-r--r--src/w32.c7
-rw-r--r--src/w32fns.c10
-rw-r--r--src/xdisp.c43
-rw-r--r--src/xfaces.c4
17 files changed, 413 insertions, 114 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1ea2005e0c4..474ead0cde6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,84 @@
12006-08-01 Kim F. Storm <storm@cua.dk>
2
3 * process.c (wait_reading_process_output_unwind): New function.
4 Restores waiting_for_user_input_p to saved value.
5 (wait_reading_process_output): Unwind protect waiting_for_user_input_p
6 instead of save/restore old value on stack.
7
82006-07-30 Thien-Thi Nguyen <ttn@gnu.org>
9
10 * editfns.c: Undo 2006-06-27 change.
11
122006-07-29 Eli Zaretskii <eliz@gnu.org>
13
14 * coding.c (Ffind_operation_coding_system): Revert the change from
15 2006-05-29.
16
17 * alloc.c [WINDOWSNT]: Include fcntl.h, to fix last change.
18
192006-07-28 Richard Stallman <rms@gnu.org>
20
21 * xfaces.c (lookup_named_face, Fdisplay_supports_face_attributes_p):
22 Add conditional aborts for clarity.
23
24 * xdisp.c (update_menu_bar): New arg HOOKS_RUN. Callers changed.
25 Used to avoid running the hooks over and over for each frame.
26 (prepare_menu_bars): Pass value from update_menu_bar
27 as HOOKS_RUN of next call.
28
29 * keyboard.c (safe_run_hooks_1): Don't crash if Vrun_hooks is nil.
30
312006-07-28 Kim F. Storm <storm@cua.dk>
32
33 * alloc.c (valid_pointer_p): New function (from valid_lisp_object_p).
34 (valid_lisp_object_p): Use it to check for valid SUBRP obj.
35
362006-07-26 Chong Yidong <cyd@stupidchicken.com>
37
38 * keyboard.c (read_char): New arg END_TIME specifying timeout.
39 All callers changed. Turn off echoing if END_TIME is non-NULL.
40 (kbd_buffer_get_event): New arg END_TIME.
41
42 * lread.c (read_filtered_event): New arg SECONDS to wait until.
43 (Fread_char, Fread_event, Fread_char_exclusive): New arg SECONDS.
44
45 * lisp.h: Update read-char, read-event, and read_filtered_event
46 prototypes.
47
48 * keyboard.h: Include systime.h. Update read_char prototype.
49
502006-07-25 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
51
52 * alloc.c (find_string_data_in_pure): New function.
53 (make_pure_string): Use it to reuse existing string data if possible.
54
55 * puresize.h (BASE_PURESIZE): Decrease to 1102000.
56
572006-07-22 Stefan Monnier <monnier@iro.umontreal.ca>
58
59 * keymap.c (Fdefine_key): If the key binding definition looks like an
60 XEmacs-style key sequence, convert it to Emacs's format.
61
622006-07-22 Ralf Angeli <angeli@caeruleus.net>
63
64 * w32fns.c (w32_createwindow): If `left' and/or `top' frame
65 parameters are bound to some values, use that instead of
66 CW_USEDEFAULT.
67
682006-07-21 Eli Zaretskii <eliz@gnu.org>
69
70 * w32.c (convert_time): Use explicit long double constants to
71 ensure long double arithmetics is used throughout.
72
732006-07-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
74
75 * alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
76 (init_alloc_once): Initialize them.
77 (pure_alloc): Allocate non-Lisp objects from the end of pure storage
78 without alignment.
79
80 * puresize.h (BASE_PURESIZE): Decrease to 1141000.
81
12006-07-18 Francis Litterio <franl@world.std.com> 822006-07-18 Francis Litterio <franl@world.std.com>
2 83
3 * w32term.c (x_calc_absolute_position): Fix frame positioning 84 * w32term.c (x_calc_absolute_position): Fix frame positioning
@@ -131,6 +212,14 @@
131 (mac_initialize_display_info) [MAC_OSX]: Use CGDisplaySamplesPerPixel. 212 (mac_initialize_display_info) [MAC_OSX]: Use CGDisplaySamplesPerPixel.
132 (x_delete_display): Apply 2006-07-04 change for xterm.c. 213 (x_delete_display): Apply 2006-07-04 change for xterm.c.
133 214
2152006-07-17 Richard Stallman <rms@gnu.org>
216
217 * keyboard.c (Vcommand_error_function): New variable.
218 (syms_of_keyboard): Defvar it.
219 (cmd_error_internal): Simplify, and handle Vcommand_error_function.
220
221 * dispnew.c (init_display): Mention DISPLAY as well as TERM in err msg.
222
1342006-07-17 Kim F. Storm <storm@cua.dk> 2232006-07-17 Kim F. Storm <storm@cua.dk>
135 224
136 * xdisp.c (handle_single_display_spec): Ensure the right value of 225 * xdisp.c (handle_single_display_spec): Ensure the right value of
diff --git a/src/alloc.c b/src/alloc.c
index 2cf3ff40e3b..9f93e62d2ed 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -78,6 +78,10 @@ extern POINTER_TYPE *sbrk ();
78#define O_WRONLY 1 78#define O_WRONLY 1
79#endif 79#endif
80 80
81#ifdef WINDOWSNT
82#include <fcntl.h>
83#endif
84
81#ifdef DOUG_LEA_MALLOC 85#ifdef DOUG_LEA_MALLOC
82 86
83#include <malloc.h> 87#include <malloc.h>
@@ -289,10 +293,18 @@ static size_t pure_bytes_used_before_overflow;
289 && ((PNTR_COMPARISON_TYPE) (P) \ 293 && ((PNTR_COMPARISON_TYPE) (P) \
290 >= (PNTR_COMPARISON_TYPE) purebeg)) 294 >= (PNTR_COMPARISON_TYPE) purebeg))
291 295
292/* Index in pure at which next pure object will be allocated.. */ 296/* Total number of bytes allocated in pure storage. */
293 297
294EMACS_INT pure_bytes_used; 298EMACS_INT pure_bytes_used;
295 299
300/* Index in pure at which next pure Lisp object will be allocated.. */
301
302static EMACS_INT pure_bytes_used_lisp;
303
304/* Number of bytes allocated for non-Lisp objects in pure storage. */
305
306static EMACS_INT pure_bytes_used_non_lisp;
307
296/* If nonzero, this is a warning delivered by malloc and not yet 308/* If nonzero, this is a warning delivered by malloc and not yet
297 displayed. */ 309 displayed. */
298 310
@@ -4555,6 +4567,28 @@ mark_stack ()
4555#endif /* GC_MARK_STACK != 0 */ 4567#endif /* GC_MARK_STACK != 0 */
4556 4568
4557 4569
4570/* Determine whether it is safe to access memory at address P. */
4571int
4572valid_pointer_p (p)
4573 void *p;
4574{
4575 int fd;
4576
4577 /* Obviously, we cannot just access it (we would SEGV trying), so we
4578 trick the o/s to tell us whether p is a valid pointer.
4579 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
4580 not validate p in that case. */
4581
4582 if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0)
4583 {
4584 int valid = (emacs_write (fd, (char *)p, 16) == 16);
4585 emacs_close (fd);
4586 unlink ("__Valid__Lisp__Object__");
4587 return valid;
4588 }
4589
4590 return -1;
4591}
4558 4592
4559/* Return 1 if OBJ is a valid lisp object. 4593/* Return 1 if OBJ is a valid lisp object.
4560 Return 0 if OBJ is NOT a valid lisp object. 4594 Return 0 if OBJ is NOT a valid lisp object.
@@ -4567,9 +4601,7 @@ valid_lisp_object_p (obj)
4567 Lisp_Object obj; 4601 Lisp_Object obj;
4568{ 4602{
4569 void *p; 4603 void *p;
4570#if !GC_MARK_STACK 4604#if GC_MARK_STACK
4571 int fd;
4572#else
4573 struct mem_node *m; 4605 struct mem_node *m;
4574#endif 4606#endif
4575 4607
@@ -4581,26 +4613,22 @@ valid_lisp_object_p (obj)
4581 return 1; 4613 return 1;
4582 4614
4583#if !GC_MARK_STACK 4615#if !GC_MARK_STACK
4584 /* We need to determine whether it is safe to access memory at 4616 return valid_pointer_p (p);
4585 address P. Obviously, we cannot just access it (we would SEGV
4586 trying), so we trick the o/s to tell us whether p is a valid
4587 pointer. Unfortunately, we cannot use NULL_DEVICE here, as
4588 emacs_write may not validate p in that case. */
4589 if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0)
4590 {
4591 int valid = (emacs_write (fd, (char *)p, 16) == 16);
4592 emacs_close (fd);
4593 unlink ("__Valid__Lisp__Object__");
4594 return valid;
4595 }
4596
4597 return -1;
4598#else 4617#else
4599 4618
4600 m = mem_find (p); 4619 m = mem_find (p);
4601 4620
4602 if (m == MEM_NIL) 4621 if (m == MEM_NIL)
4603 return 0; 4622 {
4623 int valid = valid_pointer_p (p);
4624 if (valid <= 0)
4625 return valid;
4626
4627 if (SUBRP (obj))
4628 return 1;
4629
4630 return 0;
4631 }
4604 4632
4605 switch (m->type) 4633 switch (m->type)
4606 { 4634 {
@@ -4649,10 +4677,7 @@ valid_lisp_object_p (obj)
4649 4677
4650/* Allocate room for SIZE bytes from pure Lisp storage and return a 4678/* Allocate room for SIZE bytes from pure Lisp storage and return a
4651 pointer to it. TYPE is the Lisp type for which the memory is 4679 pointer to it. TYPE is the Lisp type for which the memory is
4652 allocated. TYPE < 0 means it's not used for a Lisp object. 4680 allocated. TYPE < 0 means it's not used for a Lisp object. */
4653
4654 If store_pure_type_info is set and TYPE is >= 0, the type of
4655 the allocated object is recorded in pure_types. */
4656 4681
4657static POINTER_TYPE * 4682static POINTER_TYPE *
4658pure_alloc (size, type) 4683pure_alloc (size, type)
@@ -4677,8 +4702,21 @@ pure_alloc (size, type)
4677#endif 4702#endif
4678 4703
4679 again: 4704 again:
4680 result = ALIGN (purebeg + pure_bytes_used, alignment); 4705 if (type >= 0)
4681 pure_bytes_used = ((char *)result - (char *)purebeg) + size; 4706 {
4707 /* Allocate space for a Lisp object from the beginning of the free
4708 space with taking account of alignment. */
4709 result = ALIGN (purebeg + pure_bytes_used_lisp, alignment);
4710 pure_bytes_used_lisp = ((char *)result - (char *)purebeg) + size;
4711 }
4712 else
4713 {
4714 /* Allocate space for a non-Lisp object from the end of the free
4715 space. */
4716 pure_bytes_used_non_lisp += size;
4717 result = purebeg + pure_size - pure_bytes_used_non_lisp;
4718 }
4719 pure_bytes_used = pure_bytes_used_lisp + pure_bytes_used_non_lisp;
4682 4720
4683 if (pure_bytes_used <= pure_size) 4721 if (pure_bytes_used <= pure_size)
4684 return result; 4722 return result;
@@ -4690,6 +4728,7 @@ pure_alloc (size, type)
4690 pure_size = 10000; 4728 pure_size = 10000;
4691 pure_bytes_used_before_overflow += pure_bytes_used - size; 4729 pure_bytes_used_before_overflow += pure_bytes_used - size;
4692 pure_bytes_used = 0; 4730 pure_bytes_used = 0;
4731 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0;
4693 goto again; 4732 goto again;
4694} 4733}
4695 4734
@@ -4705,6 +4744,73 @@ check_pure_size ()
4705} 4744}
4706 4745
4707 4746
4747/* Find the byte sequence {DATA[0], ..., DATA[NBYTES-1], '\0'} from
4748 the non-Lisp data pool of the pure storage, and return its start
4749 address. Return NULL if not found. */
4750
4751static char *
4752find_string_data_in_pure (data, nbytes)
4753 char *data;
4754 int nbytes;
4755{
4756 int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max;
4757 unsigned char *p;
4758 char *non_lisp_beg;
4759
4760 if (pure_bytes_used_non_lisp < nbytes + 1)
4761 return NULL;
4762
4763 /* Set up the Boyer-Moore table. */
4764 skip = nbytes + 1;
4765 for (i = 0; i < 256; i++)
4766 bm_skip[i] = skip;
4767
4768 p = (unsigned char *) data;
4769 while (--skip > 0)
4770 bm_skip[*p++] = skip;
4771
4772 last_char_skip = bm_skip['\0'];
4773
4774 non_lisp_beg = purebeg + pure_size - pure_bytes_used_non_lisp;
4775 start_max = pure_bytes_used_non_lisp - (nbytes + 1);
4776
4777 /* See the comments in the function `boyer_moore' (search.c) for the
4778 use of `infinity'. */
4779 infinity = pure_bytes_used_non_lisp + 1;
4780 bm_skip['\0'] = infinity;
4781
4782 p = (unsigned char *) non_lisp_beg + nbytes;
4783 start = 0;
4784 do
4785 {
4786 /* Check the last character (== '\0'). */
4787 do
4788 {
4789 start += bm_skip[*(p + start)];
4790 }
4791 while (start <= start_max);
4792
4793 if (start < infinity)
4794 /* Couldn't find the last character. */
4795 return NULL;
4796
4797 /* No less than `infinity' means we could find the last
4798 character at `p[start - infinity]'. */
4799 start -= infinity;
4800
4801 /* Check the remaining characters. */
4802 if (memcmp (data, non_lisp_beg + start, nbytes) == 0)
4803 /* Found. */
4804 return non_lisp_beg + start;
4805
4806 start += last_char_skip;
4807 }
4808 while (start <= start_max);
4809
4810 return NULL;
4811}
4812
4813
4708/* Return a string allocated in pure space. DATA is a buffer holding 4814/* Return a string allocated in pure space. DATA is a buffer holding
4709 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE 4815 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE
4710 non-zero means make the result string multibyte. 4816 non-zero means make the result string multibyte.
@@ -4723,11 +4829,15 @@ make_pure_string (data, nchars, nbytes, multibyte)
4723 struct Lisp_String *s; 4829 struct Lisp_String *s;
4724 4830
4725 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); 4831 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
4726 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); 4832 s->data = find_string_data_in_pure (data, nbytes);
4833 if (s->data == NULL)
4834 {
4835 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1);
4836 bcopy (data, s->data, nbytes);
4837 s->data[nbytes] = '\0';
4838 }
4727 s->size = nchars; 4839 s->size = nchars;
4728 s->size_byte = multibyte ? nbytes : -1; 4840 s->size_byte = multibyte ? nbytes : -1;
4729 bcopy (data, s->data, nbytes);
4730 s->data[nbytes] = '\0';
4731 s->intervals = NULL_INTERVAL; 4841 s->intervals = NULL_INTERVAL;
4732 XSETSTRING (string, s); 4842 XSETSTRING (string, s);
4733 return string; 4843 return string;
@@ -6182,6 +6292,7 @@ init_alloc_once ()
6182 purebeg = PUREBEG; 6292 purebeg = PUREBEG;
6183 pure_size = PURESIZE; 6293 pure_size = PURESIZE;
6184 pure_bytes_used = 0; 6294 pure_bytes_used = 0;
6295 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0;
6185 pure_bytes_used_before_overflow = 0; 6296 pure_bytes_used_before_overflow = 0;
6186 6297
6187 /* Initialize the list of free aligned blocks. */ 6298 /* Initialize the list of free aligned blocks. */
diff --git a/src/callint.c b/src/callint.c
index 475042abbe1..4c8a5718cd9 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -563,7 +563,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
563 break; 563 break;
564 564
565 case 'c': /* Character */ 565 case 'c': /* Character */
566 args[i] = Fread_char (build_string (callint_message), Qnil); 566 args[i] = Fread_char (build_string (callint_message), Qnil, Qnil);
567 message1_nolog ((char *) 0); 567 message1_nolog ((char *) 0);
568 /* Passing args[i] directly stimulates compiler bug */ 568 /* Passing args[i] directly stimulates compiler bug */
569 teml = args[i]; 569 teml = args[i];
@@ -635,7 +635,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
635 /* Ignore first element, which is the base key. */ 635 /* Ignore first element, which is the base key. */
636 tem2 = Fmemq (intern ("down"), Fcdr (teml)); 636 tem2 = Fmemq (intern ("down"), Fcdr (teml));
637 if (! NILP (tem2)) 637 if (! NILP (tem2))
638 up_event = Fread_event (Qnil, Qnil); 638 up_event = Fread_event (Qnil, Qnil, Qnil);
639 } 639 }
640 } 640 }
641 break; 641 break;
@@ -663,7 +663,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
663 /* Ignore first element, which is the base key. */ 663 /* Ignore first element, which is the base key. */
664 tem2 = Fmemq (intern ("down"), Fcdr (teml)); 664 tem2 = Fmemq (intern ("down"), Fcdr (teml));
665 if (! NILP (tem2)) 665 if (! NILP (tem2))
666 up_event = Fread_event (Qnil, Qnil); 666 up_event = Fread_event (Qnil, Qnil, Qnil);
667 } 667 }
668 } 668 }
669 break; 669 break;
diff --git a/src/coding.c b/src/coding.c
index cb6df79fca0..9ba96981c7f 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -8390,7 +8390,10 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */)
8390 return Fcons (val, val); 8390 return Fcons (val, val);
8391 if (! NILP (Ffboundp (val))) 8391 if (! NILP (Ffboundp (val)))
8392 { 8392 {
8393 val = safe_call1 (val, Flist (nargs, args)); 8393 /* We use call1 rather than safe_call1
8394 so as to get bug reports about functions called here
8395 which don't handle the current interface. */
8396 val = call1 (val, Flist (nargs, args));
8394 if (CONSP (val)) 8397 if (CONSP (val))
8395 return val; 8398 return val;
8396 if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val))) 8399 if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val)))
diff --git a/src/editfns.c b/src/editfns.c
index 46d661452b2..02ea2d2abb8 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -627,10 +627,7 @@ find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end)
627DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0, 627DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0,
628 doc: /* Delete the field surrounding POS. 628 doc: /* Delete the field surrounding POS.
629A field is a region of text with the same `field' property. 629A field is a region of text with the same `field' property.
630If POS is nil, the value of point is used for POS. 630If POS is nil, the value of point is used for POS. */)
631
632An `args-out-of-range' error is signaled if POS is outside the
633buffer's accessible portion. */)
634 (pos) 631 (pos)
635 Lisp_Object pos; 632 Lisp_Object pos;
636{ 633{
@@ -644,10 +641,7 @@ buffer's accessible portion. */)
644DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0, 641DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0,
645 doc: /* Return the contents of the field surrounding POS as a string. 642 doc: /* Return the contents of the field surrounding POS as a string.
646A field is a region of text with the same `field' property. 643A field is a region of text with the same `field' property.
647If POS is nil, the value of point is used for POS. 644If POS is nil, the value of point is used for POS. */)
648
649An `args-out-of-range' error is signaled if POS is outside the
650buffer's accessible portion. */)
651 (pos) 645 (pos)
652 Lisp_Object pos; 646 Lisp_Object pos;
653{ 647{
@@ -659,10 +653,7 @@ buffer's accessible portion. */)
659DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0, 653DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0,
660 doc: /* Return the contents of the field around POS, without text-properties. 654 doc: /* Return the contents of the field around POS, without text-properties.
661A field is a region of text with the same `field' property. 655A field is a region of text with the same `field' property.
662If POS is nil, the value of point is used for POS. 656If POS is nil, the value of point is used for POS. */)
663
664An `args-out-of-range' error is signaled if POS is outside the
665buffer's accessible portion. */)
666 (pos) 657 (pos)
667 Lisp_Object pos; 658 Lisp_Object pos;
668{ 659{
@@ -678,10 +669,7 @@ If POS is nil, the value of point is used for POS.
678If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its 669If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its
679field, then the beginning of the *previous* field is returned. 670field, then the beginning of the *previous* field is returned.
680If LIMIT is non-nil, it is a buffer position; if the beginning of the field 671If LIMIT is non-nil, it is a buffer position; if the beginning of the field
681is before LIMIT, then LIMIT will be returned instead. 672is before LIMIT, then LIMIT will be returned instead. */)
682
683An `args-out-of-range' error is signaled if POS is outside the
684buffer's accessible portion. */)
685 (pos, escape_from_edge, limit) 673 (pos, escape_from_edge, limit)
686 Lisp_Object pos, escape_from_edge, limit; 674 Lisp_Object pos, escape_from_edge, limit;
687{ 675{
@@ -697,10 +685,7 @@ If POS is nil, the value of point is used for POS.
697If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, 685If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field,
698then the end of the *following* field is returned. 686then the end of the *following* field is returned.
699If LIMIT is non-nil, it is a buffer position; if the end of the field 687If LIMIT is non-nil, it is a buffer position; if the end of the field
700is after LIMIT, then LIMIT will be returned instead. 688is after LIMIT, then LIMIT will be returned instead. */)
701
702An `args-out-of-range' error is signaled if POS is outside the
703buffer's accessible portion. */)
704 (pos, escape_from_edge, limit) 689 (pos, escape_from_edge, limit)
705 Lisp_Object pos, escape_from_edge, limit; 690 Lisp_Object pos, escape_from_edge, limit;
706{ 691{
diff --git a/src/fns.c b/src/fns.c
index 4c1e5b79ae2..a01cb97d685 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2618,7 +2618,7 @@ is nil and `use-dialog-box' is non-nil. */)
2618 Fraise_frame (mini_frame); 2618 Fraise_frame (mini_frame);
2619 } 2619 }
2620 2620
2621 obj = read_filtered_event (1, 0, 0, 0); 2621 obj = read_filtered_event (1, 0, 0, 0, Qnil);
2622 cursor_in_echo_area = 0; 2622 cursor_in_echo_area = 0;
2623 /* If we need to quit, quit with cursor_in_echo_area = 0. */ 2623 /* If we need to quit, quit with cursor_in_echo_area = 0. */
2624 QUIT; 2624 QUIT;
diff --git a/src/keyboard.c b/src/keyboard.c
index e58c78c84ac..45d5832a905 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2032,6 +2032,8 @@ static Lisp_Object
2032safe_run_hooks_1 (hook) 2032safe_run_hooks_1 (hook)
2033 Lisp_Object hook; 2033 Lisp_Object hook;
2034{ 2034{
2035 if (NILP (Vrun_hooks))
2036 return Qnil;
2035 return call1 (Vrun_hooks, Vinhibit_quit); 2037 return call1 (Vrun_hooks, Vinhibit_quit);
2036} 2038}
2037 2039
@@ -2385,15 +2387,20 @@ do { if (polling_stopped_here) start_polling (); \
2385 if we used a mouse menu to read the input, or zero otherwise. If 2387 if we used a mouse menu to read the input, or zero otherwise. If
2386 USED_MOUSE_MENU is null, we don't dereference it. 2388 USED_MOUSE_MENU is null, we don't dereference it.
2387 2389
2390 If END_TIME is non-null, it is a pointer to an EMACS_TIME
2391 specifying the maximum time to wait until. If no input arrives by
2392 that time, stop waiting and return nil.
2393
2388 Value is t if we showed a menu and the user rejected it. */ 2394 Value is t if we showed a menu and the user rejected it. */
2389 2395
2390Lisp_Object 2396Lisp_Object
2391read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) 2397read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
2392 int commandflag; 2398 int commandflag;
2393 int nmaps; 2399 int nmaps;
2394 Lisp_Object *maps; 2400 Lisp_Object *maps;
2395 Lisp_Object prev_event; 2401 Lisp_Object prev_event;
2396 int *used_mouse_menu; 2402 int *used_mouse_menu;
2403 EMACS_TIME *end_time;
2397{ 2404{
2398 volatile Lisp_Object c; 2405 volatile Lisp_Object c;
2399 int count; 2406 int count;
@@ -2673,6 +2680,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2673 start echoing if enough time elapses. */ 2680 start echoing if enough time elapses. */
2674 2681
2675 if (minibuf_level == 0 2682 if (minibuf_level == 0
2683 && !end_time
2676 && !current_kboard->immediate_echo 2684 && !current_kboard->immediate_echo
2677 && this_command_key_count > 0 2685 && this_command_key_count > 0
2678 && ! noninteractive 2686 && ! noninteractive
@@ -2855,11 +2863,19 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2855 { 2863 {
2856 KBOARD *kb; 2864 KBOARD *kb;
2857 2865
2866 if (end_time)
2867 {
2868 EMACS_TIME now;
2869 EMACS_GET_TIME (now);
2870 if (EMACS_TIME_GE (now, *end_time))
2871 goto exit;
2872 }
2873
2858 /* Actually read a character, waiting if necessary. */ 2874 /* Actually read a character, waiting if necessary. */
2859 save_getcjmp (save_jump); 2875 save_getcjmp (save_jump);
2860 restore_getcjmp (local_getcjmp); 2876 restore_getcjmp (local_getcjmp);
2861 timer_start_idle (); 2877 timer_start_idle ();
2862 c = kbd_buffer_get_event (&kb, used_mouse_menu); 2878 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
2863 restore_getcjmp (save_jump); 2879 restore_getcjmp (save_jump);
2864 2880
2865#ifdef MULTI_KBOARD 2881#ifdef MULTI_KBOARD
@@ -3196,7 +3212,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
3196 3212
3197 cancel_echoing (); 3213 cancel_echoing ();
3198 do 3214 do
3199 c = read_char (0, 0, 0, Qnil, 0); 3215 c = read_char (0, 0, 0, Qnil, 0, NULL);
3200 while (BUFFERP (c)); 3216 while (BUFFERP (c));
3201 /* Remove the help from the frame */ 3217 /* Remove the help from the frame */
3202 unbind_to (count, Qnil); 3218 unbind_to (count, Qnil);
@@ -3206,7 +3222,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
3206 { 3222 {
3207 cancel_echoing (); 3223 cancel_echoing ();
3208 do 3224 do
3209 c = read_char (0, 0, 0, Qnil, 0); 3225 c = read_char (0, 0, 0, Qnil, 0, NULL);
3210 while (BUFFERP (c)); 3226 while (BUFFERP (c));
3211 } 3227 }
3212 } 3228 }
@@ -3885,9 +3901,10 @@ clear_event (event)
3885 We always read and discard one event. */ 3901 We always read and discard one event. */
3886 3902
3887static Lisp_Object 3903static Lisp_Object
3888kbd_buffer_get_event (kbp, used_mouse_menu) 3904kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
3889 KBOARD **kbp; 3905 KBOARD **kbp;
3890 int *used_mouse_menu; 3906 int *used_mouse_menu;
3907 EMACS_TIME *end_time;
3891{ 3908{
3892 register int c; 3909 register int c;
3893 Lisp_Object obj; 3910 Lisp_Object obj;
@@ -3931,13 +3948,24 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
3931 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) 3948 if (!NILP (do_mouse_tracking) && some_mouse_moved ())
3932 break; 3949 break;
3933#endif 3950#endif
3934 { 3951 if (end_time)
3952 {
3953 EMACS_TIME duration;
3954 EMACS_GET_TIME (duration);
3955 EMACS_SUB_TIME (duration, *end_time, duration);
3956 if (EMACS_TIME_NEG_P (duration))
3957 return Qnil;
3958 else
3959 wait_reading_process_output (EMACS_SECS (duration),
3960 EMACS_USECS (duration),
3961 -1, 1, Qnil, NULL, 0);
3962 }
3963 else
3935 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); 3964 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0);
3936 3965
3937 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) 3966 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr)
3938 /* Pass 1 for EXPECT since we just waited to have input. */ 3967 /* Pass 1 for EXPECT since we just waited to have input. */
3939 read_avail_input (1); 3968 read_avail_input (1);
3940 }
3941#endif /* not VMS */ 3969#endif /* not VMS */
3942 } 3970 }
3943 3971
@@ -8282,7 +8310,7 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps)
8282 orig_defn_macro = current_kboard->defining_kbd_macro; 8310 orig_defn_macro = current_kboard->defining_kbd_macro;
8283 current_kboard->defining_kbd_macro = Qnil; 8311 current_kboard->defining_kbd_macro = Qnil;
8284 do 8312 do
8285 obj = read_char (commandflag, 0, 0, Qt, 0); 8313 obj = read_char (commandflag, 0, 0, Qt, 0, NULL);
8286 while (BUFFERP (obj)); 8314 while (BUFFERP (obj));
8287 current_kboard->defining_kbd_macro = orig_defn_macro; 8315 current_kboard->defining_kbd_macro = orig_defn_macro;
8288 8316
@@ -8655,7 +8683,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8655 /* Read the first char of the sequence specially, before setting 8683 /* Read the first char of the sequence specially, before setting
8656 up any keymaps, in case a filter runs and switches buffers on us. */ 8684 up any keymaps, in case a filter runs and switches buffers on us. */
8657 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, 8685 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event,
8658 &junk); 8686 &junk, NULL);
8659#endif /* GOBBLE_FIRST_EVENT */ 8687#endif /* GOBBLE_FIRST_EVENT */
8660 8688
8661 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); 8689 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
@@ -8858,7 +8886,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8858#endif 8886#endif
8859 key = read_char (NILP (prompt), nmaps, 8887 key = read_char (NILP (prompt), nmaps,
8860 (Lisp_Object *) submaps, last_nonmenu_event, 8888 (Lisp_Object *) submaps, last_nonmenu_event,
8861 &used_mouse_menu); 8889 &used_mouse_menu, NULL);
8862 } 8890 }
8863 8891
8864 /* read_char returns t when it shows a menu and the user rejects it. 8892 /* read_char returns t when it shows a menu and the user rejects it.
diff --git a/src/keyboard.h b/src/keyboard.h
index c0c941a0646..96ac7d2e856 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -19,6 +19,8 @@ along with GNU Emacs; see the file COPYING. If not, write to
19the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA. */ 20Boston, MA 02110-1301, USA. */
21 21
22#include "systime.h" /* for EMACS_TIME */
23
22/* Length of echobuf field in each KBOARD. */ 24/* Length of echobuf field in each KBOARD. */
23 25
24/* Each KBOARD represents one logical input stream from which Emacs gets input. 26/* Each KBOARD represents one logical input stream from which Emacs gets input.
@@ -297,7 +299,8 @@ struct input_event;
297 299
298extern Lisp_Object parse_modifiers P_ ((Lisp_Object)); 300extern Lisp_Object parse_modifiers P_ ((Lisp_Object));
299extern Lisp_Object reorder_modifiers P_ ((Lisp_Object)); 301extern Lisp_Object reorder_modifiers P_ ((Lisp_Object));
300extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *)); 302extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object,
303 int *, EMACS_TIME *));
301/* User-supplied string to translate input characters through. */ 304/* User-supplied string to translate input characters through. */
302extern Lisp_Object Vkeyboard_translate_table; 305extern Lisp_Object Vkeyboard_translate_table;
303 306
diff --git a/src/keymap.c b/src/keymap.c
index af9d817a1eb..cdc45485e0a 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1172,6 +1172,20 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1172 1172
1173 meta_bit = VECTORP (key) ? meta_modifier : 0x80; 1173 meta_bit = VECTORP (key) ? meta_modifier : 0x80;
1174 1174
1175 if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, make_number (0))))
1176 { /* DEF is apparently an XEmacs-style keyboard macro. */
1177 Lisp_Object tmp = Fmake_vector (make_number (ASIZE (def)), Qnil);
1178 int i = ASIZE (def);
1179 while (--i >= 0)
1180 {
1181 Lisp_Object c = AREF (def, i);
1182 if (CONSP (c) && lucid_event_type_list_p (c))
1183 c = Fevent_convert_list (c);
1184 ASET (tmp, i, c);
1185 }
1186 def = tmp;
1187 }
1188
1175 idx = 0; 1189 idx = 0;
1176 while (1) 1190 while (1)
1177 { 1191 {
diff --git a/src/lisp.h b/src/lisp.h
index 8224117241c..171f8340885 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2681,9 +2681,9 @@ EXFUN (Fintern_soft, 2);
2681EXFUN (Fload, 5); 2681EXFUN (Fload, 5);
2682EXFUN (Fget_load_suffixes, 0); 2682EXFUN (Fget_load_suffixes, 0);
2683EXFUN (Fget_file_char, 0); 2683EXFUN (Fget_file_char, 0);
2684EXFUN (Fread_char, 2); 2684EXFUN (Fread_char, 3);
2685EXFUN (Fread_event, 2); 2685EXFUN (Fread_event, 3);
2686extern Lisp_Object read_filtered_event P_ ((int, int, int, int)); 2686extern Lisp_Object read_filtered_event P_ ((int, int, int, int, Lisp_Object));
2687EXFUN (Feval_region, 4); 2687EXFUN (Feval_region, 4);
2688extern Lisp_Object intern P_ ((const char *)); 2688extern Lisp_Object intern P_ ((const char *));
2689extern Lisp_Object make_symbol P_ ((char *)); 2689extern Lisp_Object make_symbol P_ ((char *));
diff --git a/src/lread.c b/src/lread.c
index 08ba5123fcb..c263c458a12 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -630,14 +630,19 @@ extern Lisp_Object read_char ();
630 character. 630 character.
631 631
632 If INPUT_METHOD is nonzero, we invoke the current input method 632 If INPUT_METHOD is nonzero, we invoke the current input method
633 if the character warrants that. */ 633 if the character warrants that.
634
635 If SECONDS is a number, we wait that many seconds for input, and
636 return Qnil if no input arrives within that time. */
634 637
635Lisp_Object 638Lisp_Object
636read_filtered_event (no_switch_frame, ascii_required, error_nonascii, 639read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
637 input_method) 640 input_method, seconds)
638 int no_switch_frame, ascii_required, error_nonascii, input_method; 641 int no_switch_frame, ascii_required, error_nonascii, input_method;
642 Lisp_Object seconds;
639{ 643{
640 Lisp_Object val, delayed_switch_frame; 644 Lisp_Object val, delayed_switch_frame;
645 EMACS_TIME end_time;
641 646
642#ifdef HAVE_WINDOW_SYSTEM 647#ifdef HAVE_WINDOW_SYSTEM
643 if (display_hourglass_p) 648 if (display_hourglass_p)
@@ -646,11 +651,24 @@ read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
646 651
647 delayed_switch_frame = Qnil; 652 delayed_switch_frame = Qnil;
648 653
654 /* Compute timeout. */
655 if (NUMBERP (seconds))
656 {
657 EMACS_TIME wait_time;
658 int sec, usec;
659 double duration = extract_float (seconds);
660
661 sec = (int) duration;
662 usec = (duration - sec) * 1000000;
663 EMACS_GET_TIME (end_time);
664 EMACS_SET_SECS_USECS (wait_time, sec, usec);
665 EMACS_ADD_TIME (end_time, end_time, wait_time);
666 }
667
649 /* Read until we get an acceptable event. */ 668 /* Read until we get an acceptable event. */
650 retry: 669 retry:
651 val = read_char (0, 0, 0, 670 val = read_char (0, 0, 0, (input_method ? Qnil : Qt), 0,
652 (input_method ? Qnil : Qt), 671 NUMBERP (seconds) ? &end_time : NULL);
653 0);
654 672
655 if (BUFFERP (val)) 673 if (BUFFERP (val))
656 goto retry; 674 goto retry;
@@ -668,7 +686,7 @@ read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
668 goto retry; 686 goto retry;
669 } 687 }
670 688
671 if (ascii_required) 689 if (ascii_required && !(NUMBERP (seconds) && NILP (val)))
672 { 690 {
673 /* Convert certain symbols to their ASCII equivalents. */ 691 /* Convert certain symbols to their ASCII equivalents. */
674 if (SYMBOLP (val)) 692 if (SYMBOLP (val))
@@ -713,7 +731,7 @@ read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
713 return val; 731 return val;
714} 732}
715 733
716DEFUN ("read-char", Fread_char, Sread_char, 0, 2, 0, 734DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0,
717 doc: /* Read a character from the command input (keyboard or macro). 735 doc: /* Read a character from the command input (keyboard or macro).
718It is returned as a number. 736It is returned as a number.
719If the user generates an event which is not a character (i.e. a mouse 737If the user generates an event which is not a character (i.e. a mouse
@@ -726,43 +744,55 @@ If you want to read non-character events, or ignore them, call
726If the optional argument PROMPT is non-nil, display that as a prompt. 744If the optional argument PROMPT is non-nil, display that as a prompt.
727If the optional argument INHERIT-INPUT-METHOD is non-nil and some 745If the optional argument INHERIT-INPUT-METHOD is non-nil and some
728input method is turned on in the current buffer, that input method 746input method is turned on in the current buffer, that input method
729is used for reading a character. */) 747is used for reading a character.
730 (prompt, inherit_input_method) 748If the optional argument SECONDS is non-nil, it should be a number
731 Lisp_Object prompt, inherit_input_method; 749specifying the maximum number of seconds to wait for input. If no
750input arrives in that time, return nil. SECONDS may be a
751floating-point value. */)
752 (prompt, inherit_input_method, seconds)
753 Lisp_Object prompt, inherit_input_method, seconds;
732{ 754{
733 if (! NILP (prompt)) 755 if (! NILP (prompt))
734 message_with_string ("%s", prompt, 0); 756 message_with_string ("%s", prompt, 0);
735 return read_filtered_event (1, 1, 1, ! NILP (inherit_input_method)); 757 return read_filtered_event (1, 1, 1, ! NILP (inherit_input_method), seconds);
736} 758}
737 759
738DEFUN ("read-event", Fread_event, Sread_event, 0, 2, 0, 760DEFUN ("read-event", Fread_event, Sread_event, 0, 3, 0,
739 doc: /* Read an event object from the input stream. 761 doc: /* Read an event object from the input stream.
740If the optional argument PROMPT is non-nil, display that as a prompt. 762If the optional argument PROMPT is non-nil, display that as a prompt.
741If the optional argument INHERIT-INPUT-METHOD is non-nil and some 763If the optional argument INHERIT-INPUT-METHOD is non-nil and some
742input method is turned on in the current buffer, that input method 764input method is turned on in the current buffer, that input method
743is used for reading a character. */) 765is used for reading a character.
744 (prompt, inherit_input_method) 766If the optional argument SECONDS is non-nil, it should be a number
745 Lisp_Object prompt, inherit_input_method; 767specifying the maximum number of seconds to wait for input. If no
768input arrives in that time, return nil. SECONDS may be a
769floating-point value. */)
770 (prompt, inherit_input_method, seconds)
771 Lisp_Object prompt, inherit_input_method, seconds;
746{ 772{
747 if (! NILP (prompt)) 773 if (! NILP (prompt))
748 message_with_string ("%s", prompt, 0); 774 message_with_string ("%s", prompt, 0);
749 return read_filtered_event (0, 0, 0, ! NILP (inherit_input_method)); 775 return read_filtered_event (0, 0, 0, ! NILP (inherit_input_method), seconds);
750} 776}
751 777
752DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 2, 0, 778DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 3, 0,
753 doc: /* Read a character from the command input (keyboard or macro). 779 doc: /* Read a character from the command input (keyboard or macro).
754It is returned as a number. Non-character events are ignored. 780It is returned as a number. Non-character events are ignored.
755 781
756If the optional argument PROMPT is non-nil, display that as a prompt. 782If the optional argument PROMPT is non-nil, display that as a prompt.
757If the optional argument INHERIT-INPUT-METHOD is non-nil and some 783If the optional argument INHERIT-INPUT-METHOD is non-nil and some
758input method is turned on in the current buffer, that input method 784input method is turned on in the current buffer, that input method
759is used for reading a character. */) 785is used for reading a character.
760 (prompt, inherit_input_method) 786If the optional argument SECONDS is non-nil, it should be a number
761 Lisp_Object prompt, inherit_input_method; 787specifying the maximum number of seconds to wait for input. If no
788input arrives in that time, return nil. SECONDS may be a
789floating-point value. */)
790 (prompt, inherit_input_method, seconds)
791 Lisp_Object prompt, inherit_input_method, seconds;
762{ 792{
763 if (! NILP (prompt)) 793 if (! NILP (prompt))
764 message_with_string ("%s", prompt, 0); 794 message_with_string ("%s", prompt, 0);
765 return read_filtered_event (1, 1, 0, ! NILP (inherit_input_method)); 795 return read_filtered_event (1, 1, 0, ! NILP (inherit_input_method), seconds);
766} 796}
767 797
768DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, 798DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
diff --git a/src/process.c b/src/process.c
index 45bf6446644..b218a952e5f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4157,6 +4157,14 @@ server_accept_connection (server, channel)
4157 when not inside wait_reading_process_output. */ 4157 when not inside wait_reading_process_output. */
4158static int waiting_for_user_input_p; 4158static int waiting_for_user_input_p;
4159 4159
4160static Lisp_Object
4161wait_reading_process_output_unwind (data)
4162 Lisp_Object data;
4163{
4164 waiting_for_user_input_p = XINT (data);
4165 return Qnil;
4166}
4167
4160/* This is here so breakpoints can be put on it. */ 4168/* This is here so breakpoints can be put on it. */
4161static void 4169static void
4162wait_reading_process_output_1 () 4170wait_reading_process_output_1 ()
@@ -4239,9 +4247,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4239 EMACS_TIME timeout, end_time; 4247 EMACS_TIME timeout, end_time;
4240 int wait_channel = -1; 4248 int wait_channel = -1;
4241 int got_some_input = 0; 4249 int got_some_input = 0;
4242 /* Either nil or a cons cell, the car of which is of interest and 4250 int count = SPECPDL_INDEX ();
4243 may be changed outside of this routine. */
4244 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4245 4251
4246 FD_ZERO (&Available); 4252 FD_ZERO (&Available);
4247#ifdef NON_BLOCKING_CONNECT 4253#ifdef NON_BLOCKING_CONNECT
@@ -4252,6 +4258,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4252 if (wait_proc != NULL) 4258 if (wait_proc != NULL)
4253 wait_channel = XINT (wait_proc->infd); 4259 wait_channel = XINT (wait_proc->infd);
4254 4260
4261 record_unwind_protect (wait_reading_process_output_unwind,
4262 make_number (waiting_for_user_input_p));
4255 waiting_for_user_input_p = read_kbd; 4263 waiting_for_user_input_p = read_kbd;
4256 4264
4257 /* Since we may need to wait several times, 4265 /* Since we may need to wait several times,
@@ -4878,7 +4886,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4878 } /* end for each file descriptor */ 4886 } /* end for each file descriptor */
4879 } /* end while exit conditions not met */ 4887 } /* end while exit conditions not met */
4880 4888
4881 waiting_for_user_input_p = saved_waiting_for_user_input_p; 4889 unbind_to (count, Qnil);
4882 4890
4883 /* If calling from keyboard input, do not quit 4891 /* If calling from keyboard input, do not quit
4884 since we want to return C-g as an input character. 4892 since we want to return C-g as an input character.
diff --git a/src/puresize.h b/src/puresize.h
index 457a75ea023..bae7cbb6d6a 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -43,7 +43,7 @@ Boston, MA 02110-1301, USA. */
43#endif 43#endif
44 44
45#ifndef BASE_PURESIZE 45#ifndef BASE_PURESIZE
46#define BASE_PURESIZE (1211000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) 46#define BASE_PURESIZE (1102000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA)
47#endif 47#endif
48 48
49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ 49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */
diff --git a/src/w32.c b/src/w32.c
index d01a1022a19..c093eab599e 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2256,16 +2256,17 @@ convert_time (FILETIME ft)
2256 2256
2257 SystemTimeToFileTime (&st, &utc_base_ft); 2257 SystemTimeToFileTime (&st, &utc_base_ft);
2258 utc_base = (long double) utc_base_ft.dwHighDateTime 2258 utc_base = (long double) utc_base_ft.dwHighDateTime
2259 * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime; 2259 * 4096.0L * 1024.0L * 1024.0L + utc_base_ft.dwLowDateTime;
2260 init = 1; 2260 init = 1;
2261 } 2261 }
2262 2262
2263 if (CompareFileTime (&ft, &utc_base_ft) < 0) 2263 if (CompareFileTime (&ft, &utc_base_ft) < 0)
2264 return 0; 2264 return 0;
2265 2265
2266 ret = (long double) ft.dwHighDateTime * 4096 * 1024 * 1024 + ft.dwLowDateTime; 2266 ret = (long double) ft.dwHighDateTime
2267 * 4096.0L * 1024.0L * 1024.0L + ft.dwLowDateTime;
2267 ret -= utc_base; 2268 ret -= utc_base;
2268 return (time_t) (ret * 1e-7); 2269 return (time_t) (ret * 1e-7L);
2269} 2270}
2270 2271
2271void 2272void
diff --git a/src/w32fns.c b/src/w32fns.c
index b548c2c1efe..9c0198f288d 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2067,6 +2067,7 @@ w32_createwindow (f)
2067{ 2067{
2068 HWND hwnd; 2068 HWND hwnd;
2069 RECT rect; 2069 RECT rect;
2070 Lisp_Object top, left;
2070 2071
2071 rect.left = rect.top = 0; 2072 rect.left = rect.top = 0;
2072 rect.right = FRAME_PIXEL_WIDTH (f); 2073 rect.right = FRAME_PIXEL_WIDTH (f);
@@ -2082,12 +2083,17 @@ w32_createwindow (f)
2082 w32_init_class (hinst); 2083 w32_init_class (hinst);
2083 } 2084 }
2084 2085
2086 /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero
2087 for anything that is not a number and is not Qunbound. */
2088 left = w32_get_arg (Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
2089 top = w32_get_arg (Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
2090
2085 FRAME_W32_WINDOW (f) = hwnd 2091 FRAME_W32_WINDOW (f) = hwnd
2086 = CreateWindow (EMACS_CLASS, 2092 = CreateWindow (EMACS_CLASS,
2087 f->namebuf, 2093 f->namebuf,
2088 f->output_data.w32->dwStyle | WS_CLIPCHILDREN, 2094 f->output_data.w32->dwStyle | WS_CLIPCHILDREN,
2089 CW_USEDEFAULT, 2095 EQ (left, Qunbound) ? CW_USEDEFAULT : XINT (left),
2090 SW_SHOW, 2096 EQ (top, Qunbound) ? CW_USEDEFAULT : XINT (top),
2091 rect.right - rect.left, 2097 rect.right - rect.left,
2092 rect.bottom - rect.top, 2098 rect.bottom - rect.top,
2093 NULL, 2099 NULL,
diff --git a/src/xdisp.c b/src/xdisp.c
index b9b630d2e74..073b100694f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -909,7 +909,7 @@ static void redisplay_window P_ ((Lisp_Object, int));
909static Lisp_Object redisplay_window_error (); 909static Lisp_Object redisplay_window_error ();
910static Lisp_Object redisplay_window_0 P_ ((Lisp_Object)); 910static Lisp_Object redisplay_window_0 P_ ((Lisp_Object));
911static Lisp_Object redisplay_window_1 P_ ((Lisp_Object)); 911static Lisp_Object redisplay_window_1 P_ ((Lisp_Object));
912static void update_menu_bar P_ ((struct frame *, int)); 912static int update_menu_bar P_ ((struct frame *, int, int));
913static int try_window_reusing_current_matrix P_ ((struct window *)); 913static int try_window_reusing_current_matrix P_ ((struct window *));
914static int try_window_id P_ ((struct window *)); 914static int try_window_id P_ ((struct window *));
915static int display_line P_ ((struct it *)); 915static int display_line P_ ((struct it *));
@@ -9190,6 +9190,9 @@ prepare_menu_bars ()
9190 { 9190 {
9191 Lisp_Object tail, frame; 9191 Lisp_Object tail, frame;
9192 int count = SPECPDL_INDEX (); 9192 int count = SPECPDL_INDEX ();
9193 /* 1 means that update_menu_bar has run its hooks
9194 so any further calls to update_menu_bar shouldn't do so again. */
9195 int menu_bar_hooks_run = 0;
9193 9196
9194 record_unwind_save_match_data (); 9197 record_unwind_save_match_data ();
9195 9198
@@ -9221,7 +9224,7 @@ prepare_menu_bars ()
9221 } 9224 }
9222 9225
9223 GCPRO1 (tail); 9226 GCPRO1 (tail);
9224 update_menu_bar (f, 0); 9227 menu_bar_hooks_run = update_menu_bar (f, 0, menu_bar_hooks_run);
9225#ifdef HAVE_WINDOW_SYSTEM 9228#ifdef HAVE_WINDOW_SYSTEM
9226 update_tool_bar (f, 0); 9229 update_tool_bar (f, 0);
9227#ifdef MAC_OS 9230#ifdef MAC_OS
@@ -9236,7 +9239,7 @@ prepare_menu_bars ()
9236 else 9239 else
9237 { 9240 {
9238 struct frame *sf = SELECTED_FRAME (); 9241 struct frame *sf = SELECTED_FRAME ();
9239 update_menu_bar (sf, 1); 9242 update_menu_bar (sf, 1, 0);
9240#ifdef HAVE_WINDOW_SYSTEM 9243#ifdef HAVE_WINDOW_SYSTEM
9241 update_tool_bar (sf, 1); 9244 update_tool_bar (sf, 1);
9242#ifdef MAC_OS 9245#ifdef MAC_OS
@@ -9257,12 +9260,18 @@ prepare_menu_bars ()
9257 before we start to fill in any display lines, because it can call 9260 before we start to fill in any display lines, because it can call
9258 eval. 9261 eval.
9259 9262
9260 If SAVE_MATCH_DATA is non-zero, we must save and restore it here. */ 9263 If SAVE_MATCH_DATA is non-zero, we must save and restore it here.
9261 9264
9262static void 9265 If HOOKS_RUN is 1, that means a previous call to update_menu_bar
9263update_menu_bar (f, save_match_data) 9266 already ran the menu bar hooks for this redisplay, so there
9267 is no need to run them again. The return value is the
9268 updated value of this flag, to pass to the next call. */
9269
9270static int
9271update_menu_bar (f, save_match_data, hooks_run)
9264 struct frame *f; 9272 struct frame *f;
9265 int save_match_data; 9273 int save_match_data;
9274 int hooks_run;
9266{ 9275{
9267 Lisp_Object window; 9276 Lisp_Object window;
9268 register struct window *w; 9277 register struct window *w;
@@ -9327,15 +9336,21 @@ update_menu_bar (f, save_match_data)
9327 specbind (Qoverriding_local_map, Qnil); 9336 specbind (Qoverriding_local_map, Qnil);
9328 } 9337 }
9329 9338
9330 /* Run the Lucid hook. */ 9339 if (!hooks_run)
9331 safe_run_hooks (Qactivate_menubar_hook); 9340 {
9341 /* Run the Lucid hook. */
9342 safe_run_hooks (Qactivate_menubar_hook);
9343
9344 /* If it has changed current-menubar from previous value,
9345 really recompute the menu-bar from the value. */
9346 if (! NILP (Vlucid_menu_bar_dirty_flag))
9347 call0 (Qrecompute_lucid_menubar);
9348
9349 safe_run_hooks (Qmenu_bar_update_hook);
9332 9350
9333 /* If it has changed current-menubar from previous value, 9351 hooks_run = 1;
9334 really recompute the menu-bar from the value. */ 9352 }
9335 if (! NILP (Vlucid_menu_bar_dirty_flag))
9336 call0 (Qrecompute_lucid_menubar);
9337 9353
9338 safe_run_hooks (Qmenu_bar_update_hook);
9339 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); 9354 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
9340 9355
9341 /* Redisplay the menu bar in case we changed it. */ 9356 /* Redisplay the menu bar in case we changed it. */
@@ -9364,6 +9379,8 @@ update_menu_bar (f, save_match_data)
9364 set_buffer_internal_1 (prev); 9379 set_buffer_internal_1 (prev);
9365 } 9380 }
9366 } 9381 }
9382
9383 return hooks_run;
9367} 9384}
9368 9385
9369 9386
diff --git a/src/xfaces.c b/src/xfaces.c
index 6a05611939e..ea263929df6 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -6125,6 +6125,8 @@ lookup_named_face (f, symbol, signal_p)
6125 if (!realize_basic_faces (f)) 6125 if (!realize_basic_faces (f))
6126 return -1; 6126 return -1;
6127 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 6127 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6128 if (default_face == NULL)
6129 abort (); /* realize_basic_faces must have set it up */
6128 } 6130 }
6129 6131
6130 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p)) 6132 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p))
@@ -6630,6 +6632,8 @@ face for italic. */)
6630 if (! realize_basic_faces (f)) 6632 if (! realize_basic_faces (f))
6631 error ("Cannot realize default face"); 6633 error ("Cannot realize default face");
6632 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 6634 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6635 if (def_face == NULL)
6636 abort (); /* realize_basic_faces must have set it up */
6633 } 6637 }
6634 6638
6635 /* Dispatch to the appropriate handler. */ 6639 /* Dispatch to the appropriate handler. */