aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2006-02-26 07:09:24 +0000
committerMiles Bader2006-02-26 07:09:24 +0000
commita6c05016ac9ce84cdff34608b36d5677e9843068 (patch)
treeb7f6958e7114053de680f16ea840a970c594b085 /src
parent50ca3b1a04f92fed78e7f69ad57479416dc15634 (diff)
parent782ea71aba3761983d71bf8ab9bb77c974abab56 (diff)
downloademacs-a6c05016ac9ce84cdff34608b36d5677e9843068.tar.gz
emacs-a6c05016ac9ce84cdff34608b36d5677e9843068.zip
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-26
Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 119-122) - Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog44
-rw-r--r--src/buffer.c5
-rw-r--r--src/eval.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/gtkutil.c18
-rw-r--r--src/process.c8
-rw-r--r--src/xfns.c16
-rw-r--r--src/xselect.c35
-rw-r--r--src/xterm.c96
-rw-r--r--src/xterm.h8
10 files changed, 131 insertions, 103 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 829ca27c585..4176e2f29c8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,47 @@
12006-02-25 Chong Yidong <cyd@stupidchicken.com>
2
3 * xterm.h (x_catch_errors) Return value changed to void.
4 (x_uncatch_errors): Unused count argument deleted.
5
6 * xterm.c (x_catch_errors): Don't use record_unwind_protect, since
7 it can be called in a signal handler.
8 (x_catch_errors_unwind): Function deleted.
9 (x_uncatch_errors): Deallocate last x_error_message_stack struct.
10 (x_check_errors): Call x_uncatch_errors before signalling error.
11
12 (x_load_font, x_term_init, XTmouse_position, handle_one_xevent)
13 (x_connection_closed, x_list_fonts): Use new versions of
14 x_catch_errors and x_uncatch_errors.
15
16 * xselect.c (x_own_selection, x_decline_selection_request)
17 (x_reply_selection_request, x_get_foreign_selection)
18 (Fx_get_atom_name, Fx_send_client_event): Likewise.
19
20 * xfns.c (x_real_positions, x_set_mouse_color, Fx_focus_frame):
21 Likewise.
22
23 * eval.c (record_unwind_protect): Add an assertion.
24
252006-02-25 Stefan Monnier <monnier@iro.umontreal.ca>
26
27 * process.c (Fmake_network_process): Init the process's mark.
28
292006-02-25 Kim F. Storm <storm@cua.dk>
30
31 * buffer.c (modify_overlay): Force redisplay if we modify an
32 overlay at the end of the buffer.
33
342006-02-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
35
36 * gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
37 nil the image file has been removed, in that case use the (cached)
38 pixmap.
39
402006-02-24 Kenichi Handa <handa@m17n.org>
41
42 * fileio.c (Finsert_file_contents): When a text is replaced
43 partially, be sure to set point before the inserted characters.
44
12006-02-23 Zhang Wei <id.brep@gmail.com> (tiny change) 452006-02-23 Zhang Wei <id.brep@gmail.com> (tiny change)
2 46
3 * xfns.c (Fx_file_dialog): Return a decoded file name. 47 * xfns.c (Fx_file_dialog): Return a decoded file name.
diff --git a/src/buffer.c b/src/buffer.c
index e6f93726f5a..e4d846c8093 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3665,6 +3665,10 @@ modify_overlay (buf, start, end)
3665 /* If multiple windows show this buffer, we must do other windows. */ 3665 /* If multiple windows show this buffer, we must do other windows. */
3666 else if (buffer_shared > 1) 3666 else if (buffer_shared > 1)
3667 windows_or_buffers_changed = 1; 3667 windows_or_buffers_changed = 1;
3668 /* If we modify an overlay at the end of the buffer, we cannot
3669 be sure that window end is still valid. */
3670 else if (end >= ZV && start <= ZV)
3671 windows_or_buffers_changed = 1;
3668 3672
3669 ++BUF_OVERLAY_MODIFF (buf); 3673 ++BUF_OVERLAY_MODIFF (buf);
3670} 3674}
@@ -4106,6 +4110,7 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
4106 == OVERLAY_POSITION (OVERLAY_END (overlay)))) 4110 == OVERLAY_POSITION (OVERLAY_END (overlay))))
4107 Fdelete_overlay (overlay); 4111 Fdelete_overlay (overlay);
4108 } 4112 }
4113
4109 return value; 4114 return value;
4110} 4115}
4111 4116
diff --git a/src/eval.c b/src/eval.c
index eff284820f0..06d53c907b4 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3199,6 +3199,8 @@ record_unwind_protect (function, arg)
3199 Lisp_Object (*function) P_ ((Lisp_Object)); 3199 Lisp_Object (*function) P_ ((Lisp_Object));
3200 Lisp_Object arg; 3200 Lisp_Object arg;
3201{ 3201{
3202 eassert (!handling_signal);
3203
3202 if (specpdl_ptr == specpdl + specpdl_size) 3204 if (specpdl_ptr == specpdl + specpdl_size)
3203 grow_specpdl (); 3205 grow_specpdl ();
3204 specpdl_ptr->func = function; 3206 specpdl_ptr->func = function;
diff --git a/src/fileio.c b/src/fileio.c
index ad3d89aa983..b1f9b91654a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4397,6 +4397,8 @@ actually used. */)
4397 same_at_start_charpos, inserted_chars, 0); 4397 same_at_start_charpos, inserted_chars, 0);
4398 /* Set `inserted' to the number of inserted characters. */ 4398 /* Set `inserted' to the number of inserted characters. */
4399 inserted = PT - temp; 4399 inserted = PT - temp;
4400 /* Set point before the inserted characters. */
4401 SET_PT_BOTH (temp, same_at_start);
4400 4402
4401 unbind_to (this_count, Qnil); 4403 unbind_to (this_count, Qnil);
4402 4404
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 203eab257f3..b8d37df2214 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -327,6 +327,7 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
327 look good in all cases. */ 327 look good in all cases. */
328 Lisp_Object specified_file = Qnil; 328 Lisp_Object specified_file = Qnil;
329 Lisp_Object tail; 329 Lisp_Object tail;
330 Lisp_Object file;
330 extern Lisp_Object QCfile; 331 extern Lisp_Object QCfile;
331 332
332 for (tail = XCDR (img->spec); 333 for (tail = XCDR (img->spec);
@@ -335,23 +336,18 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
335 if (EQ (XCAR (tail), QCfile)) 336 if (EQ (XCAR (tail), QCfile))
336 specified_file = XCAR (XCDR (tail)); 337 specified_file = XCAR (XCDR (tail));
337 338
338 if (STRINGP (specified_file)) 339 /* We already loaded the image once before calling this
339 { 340 function, so this only fails if the image file has been removed.
340 Lisp_Object file = Qnil; 341 In that case, use the pixmap already loaded. */
341 struct gcpro gcpro1;
342 GCPRO1 (file);
343
344 file = x_find_image_file (specified_file);
345 /* We already loaded the image once before calling this
346 function, so this should not fail. */
347 xassert (STRINGP (file) != 0);
348 342
343 if (STRINGP (specified_file)
344 && STRINGP (file = x_find_image_file (specified_file)))
345 {
349 if (! old_widget) 346 if (! old_widget)
350 old_widget = GTK_IMAGE (gtk_image_new_from_file (SSDATA (file))); 347 old_widget = GTK_IMAGE (gtk_image_new_from_file (SSDATA (file)));
351 else 348 else
352 gtk_image_set_from_file (old_widget, SSDATA (file)); 349 gtk_image_set_from_file (old_widget, SSDATA (file));
353 350
354 UNGCPRO;
355 return GTK_WIDGET (old_widget); 351 return GTK_WIDGET (old_widget);
356 } 352 }
357 353
diff --git a/src/process.c b/src/process.c
index 74922b0f57d..eae63553d38 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1583,7 +1583,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1583#endif 1583#endif
1584 1584
1585 /* Make the process marker point into the process buffer (if any). */ 1585 /* Make the process marker point into the process buffer (if any). */
1586 if (!NILP (buffer)) 1586 if (BUFFERP (buffer))
1587 set_marker_both (XPROCESS (proc)->mark, buffer, 1587 set_marker_both (XPROCESS (proc)->mark, buffer,
1588 BUF_ZV (XBUFFER (buffer)), 1588 BUF_ZV (XBUFFER (buffer)),
1589 BUF_ZV_BYTE (XBUFFER (buffer))); 1589 BUF_ZV_BYTE (XBUFFER (buffer)));
@@ -3356,6 +3356,12 @@ usage: (make-network-process &rest ARGS) */)
3356 if (is_server && socktype == SOCK_STREAM) 3356 if (is_server && socktype == SOCK_STREAM)
3357 p->status = Qlisten; 3357 p->status = Qlisten;
3358 3358
3359 /* Make the process marker point into the process buffer (if any). */
3360 if (BUFFERP (buffer))
3361 set_marker_both (p->mark, buffer,
3362 BUF_ZV (XBUFFER (buffer)),
3363 BUF_ZV_BYTE (XBUFFER (buffer)));
3364
3359#ifdef NON_BLOCKING_CONNECT 3365#ifdef NON_BLOCKING_CONNECT
3360 if (is_non_blocking_client) 3366 if (is_non_blocking_client)
3361 { 3367 {
diff --git a/src/xfns.c b/src/xfns.c
index cbdfa56dec4..2ad80fb95fa 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -578,11 +578,9 @@ x_real_positions (f, xptr, yptr)
578 int had_errors = 0; 578 int had_errors = 0;
579 Window win = f->output_data.x->parent_desc; 579 Window win = f->output_data.x->parent_desc;
580 580
581 int count;
582
583 BLOCK_INPUT; 581 BLOCK_INPUT;
584 582
585 count = x_catch_errors (FRAME_X_DISPLAY (f)); 583 x_catch_errors (FRAME_X_DISPLAY (f));
586 584
587 if (win == FRAME_X_DISPLAY_INFO (f)->root_window) 585 if (win == FRAME_X_DISPLAY_INFO (f)->root_window)
588 win = FRAME_OUTER_WINDOW (f); 586 win = FRAME_OUTER_WINDOW (f);
@@ -669,7 +667,7 @@ x_real_positions (f, xptr, yptr)
669 had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); 667 had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
670 } 668 }
671 669
672 x_uncatch_errors (FRAME_X_DISPLAY (f), count); 670 x_uncatch_errors (FRAME_X_DISPLAY (f));
673 671
674 UNBLOCK_INPUT; 672 UNBLOCK_INPUT;
675 673
@@ -947,7 +945,6 @@ x_set_mouse_color (f, arg, oldval)
947 Display *dpy = FRAME_X_DISPLAY (f); 945 Display *dpy = FRAME_X_DISPLAY (f);
948 Cursor cursor, nontext_cursor, mode_cursor, hand_cursor; 946 Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
949 Cursor hourglass_cursor, horizontal_drag_cursor; 947 Cursor hourglass_cursor, horizontal_drag_cursor;
950 int count;
951 unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); 948 unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
952 unsigned long mask_color = x->background_pixel; 949 unsigned long mask_color = x->background_pixel;
953 950
@@ -964,7 +961,7 @@ x_set_mouse_color (f, arg, oldval)
964 BLOCK_INPUT; 961 BLOCK_INPUT;
965 962
966 /* It's not okay to crash if the user selects a screwy cursor. */ 963 /* It's not okay to crash if the user selects a screwy cursor. */
967 count = x_catch_errors (dpy); 964 x_catch_errors (dpy);
968 965
969 if (!NILP (Vx_pointer_shape)) 966 if (!NILP (Vx_pointer_shape))
970 { 967 {
@@ -1025,7 +1022,7 @@ x_set_mouse_color (f, arg, oldval)
1025 1022
1026 /* Check and report errors with the above calls. */ 1023 /* Check and report errors with the above calls. */
1027 x_check_errors (dpy, "can't set cursor shape: %s"); 1024 x_check_errors (dpy, "can't set cursor shape: %s");
1028 x_uncatch_errors (dpy, count); 1025 x_uncatch_errors (dpy);
1029 1026
1030 { 1027 {
1031 XColor fore_color, back_color; 1028 XColor fore_color, back_color;
@@ -3425,13 +3422,12 @@ FRAME nil means use the selected frame. */)
3425{ 3422{
3426 struct frame *f = check_x_frame (frame); 3423 struct frame *f = check_x_frame (frame);
3427 Display *dpy = FRAME_X_DISPLAY (f); 3424 Display *dpy = FRAME_X_DISPLAY (f);
3428 int count;
3429 3425
3430 BLOCK_INPUT; 3426 BLOCK_INPUT;
3431 count = x_catch_errors (dpy); 3427 x_catch_errors (dpy);
3432 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3428 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3433 RevertToParent, CurrentTime); 3429 RevertToParent, CurrentTime);
3434 x_uncatch_errors (dpy, count); 3430 x_uncatch_errors (dpy);
3435 UNBLOCK_INPUT; 3431 UNBLOCK_INPUT;
3436 3432
3437 return Qnil; 3433 return Qnil;
diff --git a/src/xselect.c b/src/xselect.c
index 850cb058e86..6efa625543e 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -402,16 +402,15 @@ x_own_selection (selection_name, selection_value)
402 Time time = last_event_timestamp; 402 Time time = last_event_timestamp;
403 Atom selection_atom; 403 Atom selection_atom;
404 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf); 404 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf);
405 int count;
406 405
407 CHECK_SYMBOL (selection_name); 406 CHECK_SYMBOL (selection_name);
408 selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name); 407 selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
409 408
410 BLOCK_INPUT; 409 BLOCK_INPUT;
411 count = x_catch_errors (display); 410 x_catch_errors (display);
412 XSetSelectionOwner (display, selection_atom, selecting_window, time); 411 XSetSelectionOwner (display, selection_atom, selecting_window, time);
413 x_check_errors (display, "Can't set selection: %s"); 412 x_check_errors (display, "Can't set selection: %s");
414 x_uncatch_errors (display, count); 413 x_uncatch_errors (display);
415 UNBLOCK_INPUT; 414 UNBLOCK_INPUT;
416 415
417 /* Now update the local cache */ 416 /* Now update the local cache */
@@ -572,7 +571,6 @@ x_decline_selection_request (event)
572 struct input_event *event; 571 struct input_event *event;
573{ 572{
574 XSelectionEvent reply; 573 XSelectionEvent reply;
575 int count;
576 574
577 reply.type = SelectionNotify; 575 reply.type = SelectionNotify;
578 reply.display = SELECTION_EVENT_DISPLAY (event); 576 reply.display = SELECTION_EVENT_DISPLAY (event);
@@ -585,10 +583,10 @@ x_decline_selection_request (event)
585 /* The reason for the error may be that the receiver has 583 /* The reason for the error may be that the receiver has
586 died in the meantime. Handle that case. */ 584 died in the meantime. Handle that case. */
587 BLOCK_INPUT; 585 BLOCK_INPUT;
588 count = x_catch_errors (reply.display); 586 x_catch_errors (reply.display);
589 XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply); 587 XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
590 XFlush (reply.display); 588 XFlush (reply.display);
591 x_uncatch_errors (reply.display, count); 589 x_uncatch_errors (reply.display);
592 UNBLOCK_INPUT; 590 UNBLOCK_INPUT;
593} 591}
594 592
@@ -690,7 +688,7 @@ x_reply_selection_request (event, format, data, size, type)
690 int format_bytes = format/8; 688 int format_bytes = format/8;
691 int max_bytes = SELECTION_QUANTUM (display); 689 int max_bytes = SELECTION_QUANTUM (display);
692 struct x_display_info *dpyinfo = x_display_info_for_display (display); 690 struct x_display_info *dpyinfo = x_display_info_for_display (display);
693 int count; 691 int count = SPECPDL_INDEX ();
694 692
695 if (max_bytes > MAX_SELECTION_QUANTUM) 693 if (max_bytes > MAX_SELECTION_QUANTUM)
696 max_bytes = MAX_SELECTION_QUANTUM; 694 max_bytes = MAX_SELECTION_QUANTUM;
@@ -707,7 +705,7 @@ x_reply_selection_request (event, format, data, size, type)
707 705
708 /* #### XChangeProperty can generate BadAlloc, and we must handle it! */ 706 /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
709 BLOCK_INPUT; 707 BLOCK_INPUT;
710 count = x_catch_errors (display); 708 x_catch_errors (display);
711 709
712#ifdef TRACE_SELECTION 710#ifdef TRACE_SELECTION
713 { 711 {
@@ -860,7 +858,9 @@ x_reply_selection_request (event, format, data, size, type)
860 UNBLOCK to enter the event loop and get possible errors delivered, 858 UNBLOCK to enter the event loop and get possible errors delivered,
861 and then BLOCK again because x_uncatch_errors requires it. */ 859 and then BLOCK again because x_uncatch_errors requires it. */
862 BLOCK_INPUT; 860 BLOCK_INPUT;
863 x_uncatch_errors (display, count); 861
862 unbind_to (count, Qnil);
863 x_uncatch_errors (display);
864 UNBLOCK_INPUT; 864 UNBLOCK_INPUT;
865} 865}
866 866
@@ -1392,7 +1392,7 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1392 1392
1393 BLOCK_INPUT; 1393 BLOCK_INPUT;
1394 1394
1395 count = x_catch_errors (display); 1395 x_catch_errors (display);
1396 1396
1397 TRACE2 ("Get selection %s, type %s", 1397 TRACE2 ("Get selection %s, type %s",
1398 XGetAtomName (display, type_atom), 1398 XGetAtomName (display, type_atom),
@@ -1409,6 +1409,8 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1409 1409
1410 frame = some_frame_on_display (dpyinfo); 1410 frame = some_frame_on_display (dpyinfo);
1411 1411
1412 count = SPECPDL_INDEX ();
1413
1412 /* If the display no longer has frames, we can't expect 1414 /* If the display no longer has frames, we can't expect
1413 to get many more selection requests from it, so don't 1415 to get many more selection requests from it, so don't
1414 bother trying to queue them. */ 1416 bother trying to queue them. */
@@ -1430,8 +1432,9 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1430 TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply))); 1432 TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply)));
1431 1433
1432 BLOCK_INPUT; 1434 BLOCK_INPUT;
1435 unbind_to (count, Qnil);
1433 x_check_errors (display, "Cannot get selection: %s"); 1436 x_check_errors (display, "Cannot get selection: %s");
1434 x_uncatch_errors (display, count); 1437 x_uncatch_errors (display);
1435 UNBLOCK_INPUT; 1438 UNBLOCK_INPUT;
1436 1439
1437 if (NILP (XCAR (reading_selection_reply))) 1440 if (NILP (XCAR (reading_selection_reply)))
@@ -2650,7 +2653,6 @@ If the value is 0 or the atom is not known, return the empty string. */)
2650 struct frame *f = check_x_frame (frame); 2653 struct frame *f = check_x_frame (frame);
2651 char *name = 0; 2654 char *name = 0;
2652 Lisp_Object ret = Qnil; 2655 Lisp_Object ret = Qnil;
2653 int count;
2654 Display *dpy = FRAME_X_DISPLAY (f); 2656 Display *dpy = FRAME_X_DISPLAY (f);
2655 Atom atom; 2657 Atom atom;
2656 2658
@@ -2664,14 +2666,14 @@ If the value is 0 or the atom is not known, return the empty string. */)
2664 error ("Wrong type, value must be number or cons"); 2666 error ("Wrong type, value must be number or cons");
2665 2667
2666 BLOCK_INPUT; 2668 BLOCK_INPUT;
2667 count = x_catch_errors (dpy); 2669 x_catch_errors (dpy);
2668 2670
2669 name = atom ? XGetAtomName (dpy, atom) : ""; 2671 name = atom ? XGetAtomName (dpy, atom) : "";
2670 2672
2671 if (! x_had_errors_p (dpy)) 2673 if (! x_had_errors_p (dpy))
2672 ret = make_string (name, strlen (name)); 2674 ret = make_string (name, strlen (name));
2673 2675
2674 x_uncatch_errors (dpy, count); 2676 x_uncatch_errors (dpy);
2675 2677
2676 if (atom && name) XFree (name); 2678 if (atom && name) XFree (name);
2677 if (NILP (ret)) ret = make_string ("", 0); 2679 if (NILP (ret)) ret = make_string ("", 0);
@@ -2771,7 +2773,6 @@ are ignored. */)
2771 Lisp_Object cons; 2773 Lisp_Object cons;
2772 int size; 2774 int size;
2773 struct frame *f = check_x_frame (from); 2775 struct frame *f = check_x_frame (from);
2774 int count;
2775 int to_root; 2776 int to_root;
2776 2777
2777 CHECK_STRING (message_type); 2778 CHECK_STRING (message_type);
@@ -2841,14 +2842,14 @@ are ignored. */)
2841 the destination window. But if we are sending to the root window, 2842 the destination window. But if we are sending to the root window,
2842 there is no such client. Then we set the event mask to 0xffff. The 2843 there is no such client. Then we set the event mask to 0xffff. The
2843 event then goes to clients selecting for events on the root window. */ 2844 event then goes to clients selecting for events on the root window. */
2844 count = x_catch_errors (dpyinfo->display); 2845 x_catch_errors (dpyinfo->display);
2845 { 2846 {
2846 int propagate = to_root ? False : True; 2847 int propagate = to_root ? False : True;
2847 unsigned mask = to_root ? 0xffff : 0; 2848 unsigned mask = to_root ? 0xffff : 0;
2848 XSendEvent (dpyinfo->display, wdest, propagate, mask, &event); 2849 XSendEvent (dpyinfo->display, wdest, propagate, mask, &event);
2849 XFlush (dpyinfo->display); 2850 XFlush (dpyinfo->display);
2850 } 2851 }
2851 x_uncatch_errors (dpyinfo->display, count); 2852 x_uncatch_errors (dpyinfo->display);
2852 UNBLOCK_INPUT; 2853 UNBLOCK_INPUT;
2853 2854
2854 return Qnil; 2855 return Qnil;
diff --git a/src/xterm.c b/src/xterm.c
index 640d7c553da..698ec1b935c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -325,8 +325,8 @@ static void x_update_window_end P_ ((struct window *, int, int));
325void x_delete_display P_ ((struct x_display_info *)); 325void x_delete_display P_ ((struct x_display_info *));
326 326
327static int x_io_error_quitter P_ ((Display *)); 327static int x_io_error_quitter P_ ((Display *));
328int x_catch_errors P_ ((Display *)); 328void x_catch_errors P_ ((Display *));
329void x_uncatch_errors P_ ((Display *, int)); 329void x_uncatch_errors P_ ((Display *));
330void x_lower_frame P_ ((struct frame *)); 330void x_lower_frame P_ ((struct frame *));
331void x_scroll_bar_clear P_ ((struct frame *)); 331void x_scroll_bar_clear P_ ((struct frame *));
332int x_had_errors_p P_ ((Display *)); 332int x_had_errors_p P_ ((Display *));
@@ -3799,7 +3799,6 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3799 Window win, child; 3799 Window win, child;
3800 int win_x, win_y; 3800 int win_x, win_y;
3801 int parent_x = 0, parent_y = 0; 3801 int parent_x = 0, parent_y = 0;
3802 int count;
3803 3802
3804 win = root; 3803 win = root;
3805 3804
@@ -3807,7 +3806,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3807 structure is changing at the same time this function 3806 structure is changing at the same time this function
3808 is running. So at least we must not crash from them. */ 3807 is running. So at least we must not crash from them. */
3809 3808
3810 count = x_catch_errors (FRAME_X_DISPLAY (*fp)); 3809 x_catch_errors (FRAME_X_DISPLAY (*fp));
3811 3810
3812 if (FRAME_X_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame 3811 if (FRAME_X_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
3813 && FRAME_LIVE_P (last_mouse_frame)) 3812 && FRAME_LIVE_P (last_mouse_frame))
@@ -3876,7 +3875,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3876 if (x_had_errors_p (FRAME_X_DISPLAY (*fp))) 3875 if (x_had_errors_p (FRAME_X_DISPLAY (*fp)))
3877 f1 = 0; 3876 f1 = 0;
3878 3877
3879 x_uncatch_errors (FRAME_X_DISPLAY (*fp), count); 3878 x_uncatch_errors (FRAME_X_DISPLAY (*fp));
3880 3879
3881 /* If not, is it one of our scroll bars? */ 3880 /* If not, is it one of our scroll bars? */
3882 if (! f1) 3881 if (! f1)
@@ -5793,7 +5792,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5793 Display *d = event.xclient.display; 5792 Display *d = event.xclient.display;
5794 /* Catch and ignore errors, in case window has been 5793 /* Catch and ignore errors, in case window has been
5795 iconified by a window manager such as GWM. */ 5794 iconified by a window manager such as GWM. */
5796 int count = x_catch_errors (d); 5795 x_catch_errors (d);
5797 XSetInputFocus (d, event.xclient.window, 5796 XSetInputFocus (d, event.xclient.window,
5798 /* The ICCCM says this is 5797 /* The ICCCM says this is
5799 the only valid choice. */ 5798 the only valid choice. */
@@ -5802,7 +5801,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5802 /* This is needed to detect the error 5801 /* This is needed to detect the error
5803 if there is an error. */ 5802 if there is an error. */
5804 XSync (d, False); 5803 XSync (d, False);
5805 x_uncatch_errors (d, count); 5804 x_uncatch_errors (d);
5806 } 5805 }
5807 /* Not certain about handling scroll bars here */ 5806 /* Not certain about handling scroll bars here */
5808#endif /* 0 */ 5807#endif /* 0 */
@@ -7523,7 +7522,11 @@ x_text_icon (f, icon_name)
7523#define X_ERROR_MESSAGE_SIZE 200 7522#define X_ERROR_MESSAGE_SIZE 200
7524 7523
7525/* If non-nil, this should be a string. 7524/* If non-nil, this should be a string.
7526 It means catch X errors and store the error message in this string. */ 7525 It means catch X errors and store the error message in this string.
7526
7527 The reason we use a stack is that x_catch_error/x_uncatch_error can
7528 be called from a signal handler.
7529*/
7527 7530
7528struct x_error_message_stack { 7531struct x_error_message_stack {
7529 char string[X_ERROR_MESSAGE_SIZE]; 7532 char string[X_ERROR_MESSAGE_SIZE];
@@ -7560,20 +7563,12 @@ x_error_catcher (display, error)
7560 Calling x_uncatch_errors resumes the normal error handling. */ 7563 Calling x_uncatch_errors resumes the normal error handling. */
7561 7564
7562void x_check_errors (); 7565void x_check_errors ();
7563static Lisp_Object x_catch_errors_unwind ();
7564 7566
7565int 7567void
7566x_catch_errors (dpy) 7568x_catch_errors (dpy)
7567 Display *dpy; 7569 Display *dpy;
7568{ 7570{
7569 int count = SPECPDL_INDEX ();
7570 struct x_error_message_stack *data = xmalloc (sizeof (*data)); 7571 struct x_error_message_stack *data = xmalloc (sizeof (*data));
7571 Lisp_Object dummy;
7572#ifdef ENABLE_CHECKING
7573 dummy = make_number ((EMACS_INT)dpy + (EMACS_INT)x_error_message);
7574#else
7575 dummy = Qnil;
7576#endif
7577 7572
7578 /* Make sure any errors from previous requests have been dealt with. */ 7573 /* Make sure any errors from previous requests have been dealt with. */
7579 XSync (dpy, False); 7574 XSync (dpy, False);
@@ -7582,21 +7577,19 @@ x_catch_errors (dpy)
7582 data->string[0] = 0; 7577 data->string[0] = 0;
7583 data->prev = x_error_message; 7578 data->prev = x_error_message;
7584 x_error_message = data; 7579 x_error_message = data;
7585
7586 record_unwind_protect (x_catch_errors_unwind, dummy);
7587
7588 return count;
7589} 7580}
7590 7581
7591/* Unbind the binding that we made to check for X errors. */ 7582/* Undo the last x_catch_errors call.
7583 DPY should be the display that was passed to x_catch_errors. */
7592 7584
7593static Lisp_Object 7585void
7594x_catch_errors_unwind (dummy) 7586x_uncatch_errors (dpy)
7595 Lisp_Object dummy; 7587 Display *dpy;
7596{ 7588{
7597 Display *dpy = x_error_message->dpy;
7598 struct x_error_message_stack *tmp; 7589 struct x_error_message_stack *tmp;
7599 7590
7591 eassert (x_error_message && dpy == x_error_message->dpy);
7592
7600 /* The display may have been closed before this function is called. 7593 /* The display may have been closed before this function is called.
7601 Check if it is still open before calling XSync. */ 7594 Check if it is still open before calling XSync. */
7602 if (x_display_info_for_display (dpy) != 0) 7595 if (x_display_info_for_display (dpy) != 0)
@@ -7608,12 +7601,7 @@ x_catch_errors_unwind (dummy)
7608 7601
7609 tmp = x_error_message; 7602 tmp = x_error_message;
7610 x_error_message = x_error_message->prev; 7603 x_error_message = x_error_message->prev;
7611 free (tmp); 7604 xfree (tmp);
7612
7613 eassert (EQ (dummy,
7614 make_number ((EMACS_INT)dpy + (EMACS_INT)x_error_message)));
7615
7616 return Qnil;
7617} 7605}
7618 7606
7619/* If any X protocol errors have arrived since the last call to 7607/* If any X protocol errors have arrived since the last call to
@@ -7629,7 +7617,12 @@ x_check_errors (dpy, format)
7629 XSync (dpy, False); 7617 XSync (dpy, False);
7630 7618
7631 if (x_error_message->string[0]) 7619 if (x_error_message->string[0])
7632 error (format, x_error_message->string); 7620 {
7621 char string[X_ERROR_MESSAGE_SIZE];
7622 bcopy (x_error_message->string, string, X_ERROR_MESSAGE_SIZE);
7623 x_uncatch_errors (dpy);
7624 error (format, string);
7625 }
7633} 7626}
7634 7627
7635/* Nonzero if we had any X protocol errors 7628/* Nonzero if we had any X protocol errors
@@ -7654,19 +7647,6 @@ x_clear_errors (dpy)
7654 x_error_message->string[0] = 0; 7647 x_error_message->string[0] = 0;
7655} 7648}
7656 7649
7657/* Stop catching X protocol errors and let them make Emacs die.
7658 DPY should be the display that was passed to x_catch_errors.
7659 COUNT should be the value that was returned by
7660 the corresponding call to x_catch_errors. */
7661
7662void
7663x_uncatch_errors (dpy, count)
7664 Display *dpy;
7665 int count;
7666{
7667 unbind_to (count, Qnil);
7668}
7669
7670#if 0 7650#if 0
7671static unsigned int x_wire_count; 7651static unsigned int x_wire_count;
7672x_trace_wire () 7652x_trace_wire ()
@@ -7723,7 +7703,6 @@ x_connection_closed (dpy, error_message)
7723{ 7703{
7724 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 7704 struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
7725 Lisp_Object frame, tail; 7705 Lisp_Object frame, tail;
7726 int count;
7727 7706
7728 error_msg = (char *) alloca (strlen (error_message) + 1); 7707 error_msg = (char *) alloca (strlen (error_message) + 1);
7729 strcpy (error_msg, error_message); 7708 strcpy (error_msg, error_message);
@@ -7733,7 +7712,7 @@ x_connection_closed (dpy, error_message)
7733 below. Otherwise, we might end up with printing ``can't find per 7712 below. Otherwise, we might end up with printing ``can't find per
7734 display information'' in the recursive call instead of printing 7713 display information'' in the recursive call instead of printing
7735 the original message here. */ 7714 the original message here. */
7736 count = x_catch_errors (dpy); 7715 x_catch_errors (dpy);
7737 7716
7738 /* We have to close the display to inform Xt that it doesn't 7717 /* We have to close the display to inform Xt that it doesn't
7739 exist anymore. If we don't, Xt will continue to wait for 7718 exist anymore. If we don't, Xt will continue to wait for
@@ -7801,7 +7780,7 @@ x_connection_closed (dpy, error_message)
7801 if (dpyinfo) 7780 if (dpyinfo)
7802 x_delete_display (dpyinfo); 7781 x_delete_display (dpyinfo);
7803 7782
7804 x_uncatch_errors (dpy, count); 7783 x_uncatch_errors (dpy);
7805 7784
7806 if (x_display_list == 0) 7785 if (x_display_list == 0)
7807 { 7786 {
@@ -9424,7 +9403,6 @@ x_list_fonts (f, pattern, size, maxnames)
9424 = f ? FRAME_X_DISPLAY_INFO (f) : x_display_list; 9403 = f ? FRAME_X_DISPLAY_INFO (f) : x_display_list;
9425 Display *dpy = dpyinfo->display; 9404 Display *dpy = dpyinfo->display;
9426 int try_XLoadQueryFont = 0; 9405 int try_XLoadQueryFont = 0;
9427 int count;
9428 int allow_auto_scaled_font = 0; 9406 int allow_auto_scaled_font = 0;
9429 9407
9430 if (size < 0) 9408 if (size < 0)
@@ -9464,7 +9442,7 @@ x_list_fonts (f, pattern, size, maxnames)
9464 /* At first, put PATTERN in the cache. */ 9442 /* At first, put PATTERN in the cache. */
9465 9443
9466 BLOCK_INPUT; 9444 BLOCK_INPUT;
9467 count = x_catch_errors (dpy); 9445 x_catch_errors (dpy);
9468 9446
9469 if (try_XLoadQueryFont) 9447 if (try_XLoadQueryFont)
9470 { 9448 {
@@ -9545,7 +9523,7 @@ x_list_fonts (f, pattern, size, maxnames)
9545 } 9523 }
9546 } 9524 }
9547 9525
9548 x_uncatch_errors (dpy, count); 9526 x_uncatch_errors (dpy);
9549 UNBLOCK_INPUT; 9527 UNBLOCK_INPUT;
9550 9528
9551 if (names) 9529 if (names)
@@ -9636,7 +9614,7 @@ x_list_fonts (f, pattern, size, maxnames)
9636 XFontStruct *thisinfo; 9614 XFontStruct *thisinfo;
9637 9615
9638 BLOCK_INPUT; 9616 BLOCK_INPUT;
9639 count = x_catch_errors (dpy); 9617 x_catch_errors (dpy);
9640 thisinfo = XLoadQueryFont (dpy, 9618 thisinfo = XLoadQueryFont (dpy,
9641 SDATA (XCAR (tem))); 9619 SDATA (XCAR (tem)));
9642 if (x_had_errors_p (dpy)) 9620 if (x_had_errors_p (dpy))
@@ -9646,7 +9624,7 @@ x_list_fonts (f, pattern, size, maxnames)
9646 thisinfo = NULL; 9624 thisinfo = NULL;
9647 x_clear_errors (dpy); 9625 x_clear_errors (dpy);
9648 } 9626 }
9649 x_uncatch_errors (dpy, count); 9627 x_uncatch_errors (dpy);
9650 UNBLOCK_INPUT; 9628 UNBLOCK_INPUT;
9651 9629
9652 if (thisinfo) 9630 if (thisinfo)
@@ -9802,7 +9780,6 @@ x_load_font (f, fontname, size)
9802{ 9780{
9803 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 9781 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9804 Lisp_Object font_names; 9782 Lisp_Object font_names;
9805 int count;
9806 9783
9807 /* Get a list of all the fonts that match this name. Once we 9784 /* Get a list of all the fonts that match this name. Once we
9808 have a list of matching fonts, we compare them against the fonts 9785 have a list of matching fonts, we compare them against the fonts
@@ -9841,7 +9818,7 @@ x_load_font (f, fontname, size)
9841 fontname = (char *) SDATA (XCAR (font_names)); 9818 fontname = (char *) SDATA (XCAR (font_names));
9842 9819
9843 BLOCK_INPUT; 9820 BLOCK_INPUT;
9844 count = x_catch_errors (FRAME_X_DISPLAY (f)); 9821 x_catch_errors (FRAME_X_DISPLAY (f));
9845 font = (XFontStruct *) XLoadQueryFont (FRAME_X_DISPLAY (f), fontname); 9822 font = (XFontStruct *) XLoadQueryFont (FRAME_X_DISPLAY (f), fontname);
9846 if (x_had_errors_p (FRAME_X_DISPLAY (f))) 9823 if (x_had_errors_p (FRAME_X_DISPLAY (f)))
9847 { 9824 {
@@ -9850,7 +9827,7 @@ x_load_font (f, fontname, size)
9850 font = NULL; 9827 font = NULL;
9851 x_clear_errors (FRAME_X_DISPLAY (f)); 9828 x_clear_errors (FRAME_X_DISPLAY (f));
9852 } 9829 }
9853 x_uncatch_errors (FRAME_X_DISPLAY (f), count); 9830 x_uncatch_errors (FRAME_X_DISPLAY (f));
9854 UNBLOCK_INPUT; 9831 UNBLOCK_INPUT;
9855 if (!font) 9832 if (!font)
9856 return NULL; 9833 return NULL;
@@ -10778,7 +10755,6 @@ x_term_init (display_name, xrm_option, resource_name)
10778 Display *dpy = dpyinfo->display; 10755 Display *dpy = dpyinfo->display;
10779 XrmValue d, fr, to; 10756 XrmValue d, fr, to;
10780 Font font; 10757 Font font;
10781 int count;
10782 10758
10783 d.addr = (XPointer)&dpy; 10759 d.addr = (XPointer)&dpy;
10784 d.size = sizeof (Display *); 10760 d.size = sizeof (Display *);
@@ -10786,12 +10762,12 @@ x_term_init (display_name, xrm_option, resource_name)
10786 fr.size = sizeof (XtDefaultFont); 10762 fr.size = sizeof (XtDefaultFont);
10787 to.size = sizeof (Font *); 10763 to.size = sizeof (Font *);
10788 to.addr = (XPointer)&font; 10764 to.addr = (XPointer)&font;
10789 count = x_catch_errors (dpy); 10765 x_catch_errors (dpy);
10790 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL)) 10766 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
10791 abort (); 10767 abort ();
10792 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font)) 10768 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
10793 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15"); 10769 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
10794 x_uncatch_errors (dpy, count); 10770 x_uncatch_errors (dpy);
10795 } 10771 }
10796#endif 10772#endif
10797#endif 10773#endif
diff --git a/src/xterm.h b/src/xterm.h
index aeb408fd170..b92a27979dd 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -961,9 +961,9 @@ void x_delete_display P_ ((struct x_display_info *));
961void x_make_frame_visible P_ ((struct frame *)); 961void x_make_frame_visible P_ ((struct frame *));
962void x_iconify_frame P_ ((struct frame *)); 962void x_iconify_frame P_ ((struct frame *));
963void x_wm_set_size_hint P_ ((struct frame *, long, int)); 963void x_wm_set_size_hint P_ ((struct frame *, long, int));
964int x_catch_errors P_ ((Display *)); 964void x_catch_errors P_ ((Display *));
965int x_had_errors_p P_ ((Display *)); 965int x_had_errors_p P_ ((Display *));
966void x_uncatch_errors P_ ((Display *, int)); 966void x_uncatch_errors P_ ((Display *));
967void x_check_errors P_ ((Display *, char *)); 967void x_check_errors P_ ((Display *, char *));
968int x_text_icon P_ ((struct frame *, char *)); 968int x_text_icon P_ ((struct frame *, char *));
969int x_bitmap_icon P_ ((struct frame *, Lisp_Object)); 969int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
@@ -977,10 +977,10 @@ extern void cancel_mouse_face P_ ((struct frame *));
977extern void x_scroll_bar_clear P_ ((struct frame *)); 977extern void x_scroll_bar_clear P_ ((struct frame *));
978extern int x_text_icon P_ ((struct frame *, char *)); 978extern int x_text_icon P_ ((struct frame *, char *));
979extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object)); 979extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
980extern int x_catch_errors P_ ((Display *)); 980extern void x_catch_errors P_ ((Display *));
981extern void x_check_errors P_ ((Display *, char *)); 981extern void x_check_errors P_ ((Display *, char *));
982extern int x_had_errors_p P_ ((Display *)); 982extern int x_had_errors_p P_ ((Display *));
983extern void x_uncatch_errors P_ ((Display *, int)); 983extern void x_uncatch_errors P_ ((Display *));
984extern void x_set_window_size P_ ((struct frame *, int, int, int)); 984extern void x_set_window_size P_ ((struct frame *, int, int, int));
985extern void x_set_mouse_position P_ ((struct frame *, int, int)); 985extern void x_set_mouse_position P_ ((struct frame *, int, int));
986extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int)); 986extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));