aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2004-08-27 07:00:34 +0000
committerMiles Bader2004-08-27 07:00:34 +0000
commitb71f2b97d343dd5ec39b64b66de86051ee47eb3e (patch)
tree85e3d906c7ba13a3fd447ad054a430388386b748 /src
parent21b4a4fb21f6254fb37da88b0d5858575f953e22 (diff)
parent11d2e01ba3a82c41eec105df81260568f048e726 (diff)
downloademacs-b71f2b97d343dd5ec39b64b66de86051ee47eb3e.tar.gz
emacs-b71f2b97d343dd5ec39b64b66de86051ee47eb3e.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-32
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-486 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-487 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-488 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-489 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-490 Update from CVS: man/fixit.texi (Spelling): Fix typo. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-491 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-494 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-495 Update from CVS: Add missing lisp/mh-e files * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-496 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-499 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-500 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-513 Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog106
-rw-r--r--src/buffer.c2
-rw-r--r--src/bytecode.c3
-rw-r--r--src/dispnew.c49
-rw-r--r--src/fileio.c7
-rw-r--r--src/intervals.c4
-rw-r--r--src/keyboard.c7
-rw-r--r--src/lisp.h5
-rw-r--r--src/macfns.c216
-rw-r--r--src/macmenu.c30
-rw-r--r--src/minibuf.c5
-rw-r--r--src/msdos.c2
-rw-r--r--src/process.c214
-rw-r--r--src/syntax.c4
-rw-r--r--src/sysdep.c37
-rw-r--r--src/w32proc.c2
-rw-r--r--src/w32term.c2
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xfaces.c5
-rw-r--r--src/xfns.c14
-rw-r--r--src/xselect.c6
-rw-r--r--src/xterm.c12
22 files changed, 460 insertions, 274 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3f9b6d85e51..aa3721d9106 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,105 @@
12004-08-26 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
4 strings in menu items.
5 (single_submenu): Use ENCODE_MENU_STRING
6 (mac_menu_show): Use ENCODE_MENU_STRING. Reset grabbed because
7 button release isn't passed to event loop
8 (add_menu_item): Use SetMenuItemWithCFString
9
102004-08-26 Steven Tamm <steventamm@mac.com>
11
12 * fileio.c (Fread_file_name): Call x_file_dialog on carbon on
13 tool-bar/menu click
14 * macfns.c (Fx_file_dialog): Implemented using NavServices
15
162004-08-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
17
18 * xterm.c (x_catch_errors_unwind): Do not XSync if display has closed.
19
20 * xfns.c (x_window_to_frame, x_any_window_to_frame)
21 (x_non_menubar_window_to_frame, x_menubar_window_to_frame)
22 (x_top_window_to_frame): Return 0 if wdesc is None.
23
242004-08-22 Richard M. Stallman <rms@gnu.org>
25
26 * process.c (process_send_signal) [SIGNALS_VIA_CHARACTERS,
27 HAVE_TERMIOS]: If there's no char for this signal, drop through
28 and use system calls.
29
30 * bytecode.c (Fbyte_code) <unwind-protect>: Cannot GC.
31
322004-08-20 Kim F. Storm <storm@cua.dk>
33
34 * process.c (wait_reading_process_output): Rename from
35 wait_reading_process_input. All uses changed.
36 (wait_reading_process_output_1): Rename from
37 wait_reading_process_input_1. All uses changed.
38
39 * dispnew.c (Fsleep_for): Remove obsolete code.
40
412004-08-20 Kenichi Handa <handa@m17n.org>
42
43 * syntax.c (skip_chars): Fix for unibyte case.
44
452004-08-19 Stefan Monnier <monnier@iro.umontreal.ca>
46
47 * syntax.c (char_quoted): Mixup byte/char pos.
48 (back_comment): Fixup globals in all cases.
49
502004-08-19 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
51
52 * xfns.c (x_set_name, x_set_title): Encode title to UTF8 before
53 passing it to gtk_window_set_title.
54
552004-08-19 Kim F. Storm <storm@cua.dk>
56
57 * process.c (wait_reading_process_input): Clean up.
58 Add wait_for_cell, wait_proc, and just_wait_proc args
59 to avoid overloading `read_kbd' and `do_display' args.
60 Change read_kbd arg to int. All callers changed.
61
62 * process.c (process_send_signal): Use CDISABLE.
63
64 * sysdep.c (child_setup_tty, init_sys_modes): Use CDISABLE.
65
662004-08-18 Kim F. Storm <storm@cua.dk>
67
68 * process.c (Faccept_process_output): Add arg JUST-THIS-ONE;
69 forward to wait_reading_process_input via DO_DISPLAY arg.
70 (wait_reading_process_input): If DO_DISPLAY < 0 for a process
71 object, only process output from that process; also inhibit
72 running timers if DO_DISPLAY==-2.
73
742004-08-17 Kim F. Storm <storm@cua.dk>
75
76 * process.c (process_send_signal): Fix last change--use
77 _POSIX_VDISABLE instead of CVDISABLE when available.
78
792004-08-16 Richard M. Stallman <rms@gnu.org>
80
81 * sysdep.c (child_setup_tty) [SIGNALS_VIA_CHARACTERS]:
82 Set VQUIT and VINTR chars to the standard ones if they are unset.
83 [AIX]: Don't do that here. And don't force VINTR to standard
84 when SIGNALS_VIA_CHARACTERS.
85
86 * process.c (process_send_signal)
87 [SIGNALS_VIA_CHARACTERS, HAVE_TERMIOS]: Clean up.
88 Do nothing if the character is CVDISABLE.
89
90 * xfaces.c (merge_face_ref): Specifying `unspecified' is a no-op.
91
92 * intervals.c (move_if_not_intangible):
93 Force POSITION to be between BEGV and ZV.
94
952004-08-14 John Paul Wallington <jpw@gnu.org>
96
97 * buffer.c (Frestore_buffer_modified_p): Doc fix.
98
99 * fileio.c (Fread_file_name): Doc fix.
100
101 * minibuf.c (syms_of_minibuf) <completion-ignore-case>: Doc fix.
102
12004-08-09 Luc Teirlinck <teirllm@auburn.edu> 1032004-08-09 Luc Teirlinck <teirllm@auburn.edu>
2 104
3 * keymap.c (Fmake_keymap, Fmap_keymap, Fwhere_is_internal): Doc fixes. 105 * keymap.c (Fmake_keymap, Fmap_keymap, Fwhere_is_internal): Doc fixes.
@@ -66,6 +168,10 @@
66 168
67 * callint.c (Fcall_interactively): Doc fix. 169 * callint.c (Fcall_interactively): Doc fix.
68 170
1712004-07-30 Richard M. Stallman <rms@gnu.org>
172
173 * abbrev.c (Fexpand_abbrev): Undo previous change.
174
692004-07-30 Kim F. Storm <storm@cua.dk> 1752004-07-30 Kim F. Storm <storm@cua.dk>
70 176
71 * editfns.c (Fformat): Allocate extra (dummy) element in info. 177 * editfns.c (Fformat): Allocate extra (dummy) element in info.
diff --git a/src/buffer.c b/src/buffer.c
index fb8fa9bc332..bae964bc139 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1078,7 +1078,7 @@ A non-nil FLAG means mark the buffer modified. */)
1078 1078
1079DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p, 1079DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p,
1080 Srestore_buffer_modified_p, 1, 1, 0, 1080 Srestore_buffer_modified_p, 1, 1, 0,
1081 doc: /* Like `set-buffer-modified-p', with a differences concerning redisplay. 1081 doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay.
1082It is not ensured that mode lines will be updated to show the modified 1082It is not ensured that mode lines will be updated to show the modified
1083state of the current buffer. Use with care. */) 1083state of the current buffer. Use with care. */)
1084 (flag) 1084 (flag)
diff --git a/src/bytecode.c b/src/bytecode.c
index 659f79bca08..b30a410f80e 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -855,10 +855,7 @@ If the third argument is incorrect, Emacs may crash. */)
855 } 855 }
856 856
857 case Bunwind_protect: 857 case Bunwind_protect:
858 /* The function record_unwind_protect can GC. */
859 BEFORE_POTENTIAL_GC ();
860 record_unwind_protect (Fprogn, POP); 858 record_unwind_protect (Fprogn, POP);
861 AFTER_POTENTIAL_GC ();
862 break; 859 break;
863 860
864 case Bcondition_case: 861 case Bcondition_case:
diff --git a/src/dispnew.c b/src/dispnew.c
index 90ef0f64dbd..657a8e87b95 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6317,52 +6317,13 @@ Emacs was built without floating point support.
6317 if (sec < 0 || (sec == 0 && usec == 0)) 6317 if (sec < 0 || (sec == 0 && usec == 0))
6318 return Qnil; 6318 return Qnil;
6319 6319
6320 { 6320 wait_reading_process_output (sec, usec, 0, 0, Qnil, NULL, 0);
6321 Lisp_Object zero;
6322
6323 XSETFASTINT (zero, 0);
6324 wait_reading_process_input (sec, usec, zero, 0);
6325 }
6326
6327 /* We should always have wait_reading_process_input; we have a dummy
6328 implementation for systems which don't support subprocesses. */
6329#if 0
6330 /* No wait_reading_process_input */
6331 immediate_quit = 1;
6332 QUIT;
6333
6334#ifdef VMS
6335 sys_sleep (sec);
6336#else /* not VMS */
6337/* The reason this is done this way
6338 (rather than defined (H_S) && defined (H_T))
6339 is because the VMS preprocessor doesn't grok `defined'. */
6340#ifdef HAVE_SELECT
6341 EMACS_GET_TIME (end_time);
6342 EMACS_SET_SECS_USECS (timeout, sec, usec);
6343 EMACS_ADD_TIME (end_time, end_time, timeout);
6344
6345 while (1)
6346 {
6347 EMACS_GET_TIME (timeout);
6348 EMACS_SUB_TIME (timeout, end_time, timeout);
6349 if (EMACS_TIME_NEG_P (timeout)
6350 || !select (1, 0, 0, 0, &timeout))
6351 break;
6352 }
6353#else /* not HAVE_SELECT */
6354 sleep (sec);
6355#endif /* HAVE_SELECT */
6356#endif /* not VMS */
6357
6358 immediate_quit = 0;
6359#endif /* no subprocesses */
6360 6321
6361 return Qnil; 6322 return Qnil;
6362} 6323}
6363 6324
6364 6325
6365/* This is just like wait_reading_process_input, except that 6326/* This is just like wait_reading_process_output, except that
6366 it does the redisplay. 6327 it does the redisplay.
6367 6328
6368 It's also much like Fsit_for, except that it can be used for 6329 It's also much like Fsit_for, except that it can be used for
@@ -6372,8 +6333,6 @@ Lisp_Object
6372sit_for (sec, usec, reading, display, initial_display) 6333sit_for (sec, usec, reading, display, initial_display)
6373 int sec, usec, reading, display, initial_display; 6334 int sec, usec, reading, display, initial_display;
6374{ 6335{
6375 Lisp_Object read_kbd;
6376
6377 swallow_events (display); 6336 swallow_events (display);
6378 6337
6379 if (detect_input_pending_run_timers (display) || !NILP (Vexecuting_macro)) 6338 if (detect_input_pending_run_timers (display) || !NILP (Vexecuting_macro))
@@ -6389,8 +6348,8 @@ sit_for (sec, usec, reading, display, initial_display)
6389 gobble_input (0); 6348 gobble_input (0);
6390#endif 6349#endif
6391 6350
6392 XSETINT (read_kbd, reading ? -1 : 1); 6351 wait_reading_process_output (sec, usec, reading ? -1 : 1, display,
6393 wait_reading_process_input (sec, usec, read_kbd, display); 6352 Qnil, NULL, 0);
6394 6353
6395 return detect_input_pending () ? Qnil : Qt; 6354 return detect_input_pending () ? Qnil : Qt;
6396} 6355}
diff --git a/src/fileio.c b/src/fileio.c
index 5f5a3c84d73..66b7d8b83fc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6106,7 +6106,10 @@ DIR should be an absolute directory name. It defaults to the value of
6106 6106
6107If this command was invoked with the mouse, use a file dialog box if 6107If this command was invoked with the mouse, use a file dialog box if
6108`use-dialog-box' is non-nil, and the window system or X toolkit in use 6108`use-dialog-box' is non-nil, and the window system or X toolkit in use
6109provides a file dialog box. */) 6109provides a file dialog box.
6110
6111See also `read-file-name-completion-ignore-case'
6112and `read-file-name-function'. */)
6110 (prompt, dir, default_filename, mustmatch, initial, predicate) 6113 (prompt, dir, default_filename, mustmatch, initial, predicate)
6111 Lisp_Object prompt, dir, default_filename, mustmatch, initial, predicate; 6114 Lisp_Object prompt, dir, default_filename, mustmatch, initial, predicate;
6112{ 6115{
@@ -6214,7 +6217,7 @@ provides a file dialog box. */)
6214 6217
6215 GCPRO2 (insdef, default_filename); 6218 GCPRO2 (insdef, default_filename);
6216 6219
6217#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) 6220#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined(TARGET_API_MAC_CARBON)
6218 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 6221 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
6219 && use_dialog_box 6222 && use_dialog_box
6220 && use_file_dialog 6223 && use_file_dialog
diff --git a/src/intervals.c b/src/intervals.c
index ade15360c9f..4a9b51f7e7e 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -2275,6 +2275,10 @@ move_if_not_intangible (position)
2275 pos = Fnext_char_property_change (pos, Qnil); 2275 pos = Fnext_char_property_change (pos, Qnil);
2276 2276
2277 } 2277 }
2278 else if (position < BEGV)
2279 position = BEGV;
2280 else if (position > ZV)
2281 position = ZV;
2278 2282
2279 /* If the whole stretch between PT and POSITION isn't intangible, 2283 /* If the whole stretch between PT and POSITION isn't intangible,
2280 try moving to POSITION (which means we actually move farther 2284 try moving to POSITION (which means we actually move farther
diff --git a/src/keyboard.c b/src/keyboard.c
index f26d104d67b..378350710b9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3898,10 +3898,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
3898 break; 3898 break;
3899#endif 3899#endif
3900 { 3900 {
3901 Lisp_Object minus_one; 3901 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0);
3902
3903 XSETINT (minus_one, -1);
3904 wait_reading_process_input (0, 0, minus_one, 1);
3905 3902
3906 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) 3903 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr)
3907 /* Pass 1 for EXPECT since we just waited to have input. */ 3904 /* Pass 1 for EXPECT since we just waited to have input. */
@@ -9918,7 +9915,7 @@ clear_input_pending ()
9918} 9915}
9919 9916
9920/* Return nonzero if there are pending requeued events. 9917/* Return nonzero if there are pending requeued events.
9921 This isn't used yet. The hope is to make wait_reading_process_input 9918 This isn't used yet. The hope is to make wait_reading_process_output
9922 call it, and return if it runs Lisp code that unreads something. 9919 call it, and return if it runs Lisp code that unreads something.
9923 The problem is, kbd_buffer_get_event needs to be fixed to know what 9920 The problem is, kbd_buffer_get_event needs to be fixed to know what
9924 to do in that case. It isn't trivial. */ 9921 to do in that case. It isn't trivial. */
diff --git a/src/lisp.h b/src/lisp.h
index 780ee76c271..4794f77d5a1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3005,7 +3005,10 @@ EXFUN (Fprocess_send_eof, 1);
3005EXFUN (Fwaiting_for_user_input_p, 0); 3005EXFUN (Fwaiting_for_user_input_p, 0);
3006extern Lisp_Object Qprocessp; 3006extern Lisp_Object Qprocessp;
3007extern void kill_buffer_processes P_ ((Lisp_Object)); 3007extern void kill_buffer_processes P_ ((Lisp_Object));
3008extern int wait_reading_process_input P_ ((int, int, Lisp_Object, int)); 3008extern int wait_reading_process_output P_ ((int, int, int, int,
3009 Lisp_Object,
3010 struct Lisp_Process *,
3011 int));
3009extern void deactivate_process P_ ((Lisp_Object)); 3012extern void deactivate_process P_ ((Lisp_Object));
3010extern void add_keyboard_wait_descriptor P_ ((int)); 3013extern void add_keyboard_wait_descriptor P_ ((int));
3011extern void delete_keyboard_wait_descriptor P_ ((int)); 3014extern void delete_keyboard_wait_descriptor P_ ((int));
diff --git a/src/macfns.c b/src/macfns.c
index ec014e772e3..fbade05ea17 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -4192,19 +4192,27 @@ Value is t if tooltip was open, nil otherwise. */)
4192 4192
4193 4193
4194 4194
4195#ifdef TARGET_API_MAC_CARBON
4195/*********************************************************************** 4196/***********************************************************************
4196 File selection dialog 4197 File selection dialog
4197 ***********************************************************************/ 4198 ***********************************************************************/
4198 4199
4199#if 0 /* MAC_TODO: can standard file dialog */ 4200/**
4201 There is a relatively standard way to do this using applescript to run
4202 a (choose file) method. However, this doesn't do "the right thing"
4203 by working only if the find-file occurred during a menu or toolbar
4204 click. So we must do the file dialog by hand, using the navigation
4205 manager. This also has more flexibility in determining the default
4206 directory and whether or not we are going to choose a file.
4207 **/
4208
4200extern Lisp_Object Qfile_name_history; 4209extern Lisp_Object Qfile_name_history;
4201 4210
4202DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0, 4211DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
4203 doc: /* Read file name, prompting with PROMPT in directory DIR. 4212 doc: /* Read file name, prompting with PROMPT in directory DIR.
4204Use a file selection dialog. 4213Use a file selection dialog.
4205Select DEFAULT-FILENAME in the dialog's file selection box, if 4214Select DEFAULT-FILENAME in the dialog's file selection box, if
4206specified. Don't let the user enter a file name in the file 4215specified. Ensure that file exists if MUSTMATCH is non-nil. */)
4207selection dialog's entry field, if MUSTMATCH is non-nil. */)
4208 (prompt, dir, default_filename, mustmatch) 4216 (prompt, dir, default_filename, mustmatch)
4209 Lisp_Object prompt, dir, default_filename, mustmatch; 4217 Lisp_Object prompt, dir, default_filename, mustmatch;
4210{ 4218{
@@ -4212,9 +4220,8 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */)
4212 Lisp_Object file = Qnil; 4220 Lisp_Object file = Qnil;
4213 int count = SPECPDL_INDEX (); 4221 int count = SPECPDL_INDEX ();
4214 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 4222 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
4215 char filename[MAX_PATH + 1]; 4223 char filename[1001];
4216 char init_dir[MAX_PATH + 1]; 4224 int default_filter_index = 1; /* 1: All Files, 2: Directories only */
4217 int use_dialog_p = 1;
4218 4225
4219 GCPRO5 (prompt, dir, default_filename, mustmatch, file); 4226 GCPRO5 (prompt, dir, default_filename, mustmatch, file);
4220 CHECK_STRING (prompt); 4227 CHECK_STRING (prompt);
@@ -4223,87 +4230,150 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */)
4223 /* Create the dialog with PROMPT as title, using DIR as initial 4230 /* Create the dialog with PROMPT as title, using DIR as initial
4224 directory and using "*" as pattern. */ 4231 directory and using "*" as pattern. */
4225 dir = Fexpand_file_name (dir, Qnil); 4232 dir = Fexpand_file_name (dir, Qnil);
4226 strncpy (init_dir, SDATA (dir), MAX_PATH);
4227 init_dir[MAX_PATH] = '\0';
4228 unixtodos_filename (init_dir);
4229
4230 if (STRINGP (default_filename))
4231 {
4232 char *file_name_only;
4233 char *full_path_name = SDATA (default_filename);
4234
4235 unixtodos_filename (full_path_name);
4236
4237 file_name_only = strrchr (full_path_name, '\\');
4238 if (!file_name_only)
4239 file_name_only = full_path_name;
4240 else
4241 {
4242 file_name_only++;
4243
4244 /* If default_file_name is a directory, don't use the open
4245 file dialog, as it does not support selecting
4246 directories. */
4247 if (!(*file_name_only))
4248 use_dialog_p = 0;
4249 }
4250
4251 strncpy (filename, file_name_only, MAX_PATH);
4252 filename[MAX_PATH] = '\0';
4253 }
4254 else
4255 filename[0] = '\0';
4256 4233
4257 if (use_dialog_p) 4234 {
4258 { 4235 OSStatus status;
4259 OPENFILENAME file_details; 4236 NavDialogCreationOptions options;
4260 char *filename_file; 4237 NavDialogRef dialogRef;
4238 NavTypeListHandle fileTypes = NULL;
4239 NavUserAction userAction;
4240 CFStringRef message=NULL, client=NULL, saveName = NULL;
4241
4242 /* No need for a callback function because we are modal */
4243 NavGetDefaultDialogCreationOptions(&options);
4244 options.modality = kWindowModalityAppModal;
4245 options.location.h = options.location.v = -1;
4246 options.optionFlags = kNavDefaultNavDlogOptions;
4247 options.optionFlags |= kNavAllFilesInPopup; /* All files allowed */
4248 options.optionFlags |= kNavSelectAllReadableItem;
4249 if (!NILP(prompt))
4250 {
4251 message = CFStringCreateWithCStringNoCopy(NULL, SDATA(prompt),
4252 kCFStringEncodingUTF8,
4253 kCFAllocatorNull);
4254 options.message = message;
4255 }
4256 /* Don't set the application, let it use default.
4257 client = CFStringCreateWithCStringNoCopy(NULL, "Emacs",
4258 kCFStringEncodingMacRoman, NULL);
4259 options.clientName = client;
4260 */
4261
4262 /* Do Dired hack copied from w32fns.c */
4263 if (!NILP(prompt) && strncmp (SDATA(prompt), "Dired", 5) == 0)
4264 status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL,
4265 &dialogRef);
4266 else if (NILP (mustmatch))
4267 {
4268 /* This is a save dialog */
4269 if (!NILP(default_filename))
4270 {
4271 saveName = CFStringCreateWithCString(NULL, SDATA(default_filename),
4272 kCFStringEncodingUTF8);
4273 options.saveFileName = saveName;
4274 options.optionFlags |= kNavSelectDefaultLocation;
4275 }
4276 /* MAC_TODO: Find a better way to determine if this is a save
4277 or load dialog than comparing dir with default_filename */
4278 if (EQ(dir, default_filename))
4279 {
4280 status = NavCreateChooseFileDialog(&options, fileTypes,
4281 NULL, NULL, NULL, NULL,
4282 &dialogRef);
4283 }
4284 else {
4285 status = NavCreatePutFileDialog(&options,
4286 'TEXT', kNavGenericSignature,
4287 NULL, NULL, &dialogRef);
4288 }
4289 }
4290 else
4291 {
4292 /* This is an open dialog*/
4293 status = NavCreateChooseFileDialog(&options, fileTypes,
4294 NULL, NULL, NULL, NULL,
4295 &dialogRef);
4296 }
4297
4298 /* Set the default location and continue*/
4299 if (status == noErr) {
4300 if (!NILP(dir)) {
4301 FSRef defLoc;
4302 AEDesc defLocAed;
4303 status = FSPathMakeRef(SDATA(dir), &defLoc, NULL);
4304 if (status == noErr)
4305 {
4306 AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed);
4307 NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
4308 }
4309 AEDisposeDesc(&defLocAed);
4310 }
4261 4311
4262 /* Prevent redisplay. */
4263 specbind (Qinhibit_redisplay, Qt);
4264 BLOCK_INPUT; 4312 BLOCK_INPUT;
4313 status = NavDialogRun(dialogRef);
4314 UNBLOCK_INPUT;
4315 }
4265 4316
4266 bzero (&file_details, sizeof (file_details)); 4317 if (saveName) CFRelease(saveName);
4267 file_details.lStructSize = sizeof (file_details); 4318 if (client) CFRelease(client);
4268 file_details.hwndOwner = FRAME_W32_WINDOW (f); 4319 if (message) CFRelease(message);
4269 file_details.lpstrFile = filename;
4270 file_details.nMaxFile = sizeof (filename);
4271 file_details.lpstrInitialDir = init_dir;
4272 file_details.lpstrTitle = SDATA (prompt);
4273 file_details.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
4274
4275 if (!NILP (mustmatch))
4276 file_details.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
4277 4320
4278 if (GetOpenFileName (&file_details)) 4321 if (status == noErr) {
4279 { 4322 userAction = NavDialogGetUserAction(dialogRef);
4280 dostounix_filename (filename); 4323 switch (userAction)
4281 file = build_string (filename); 4324 {
4282 } 4325 case kNavUserActionNone:
4283 else 4326 case kNavUserActionCancel:
4284 file = Qnil; 4327 NavDialogDispose(dialogRef);
4285 4328 Fsignal (Qquit, Qnil); /* Treat cancel like C-g */
4286 UNBLOCK_INPUT; 4329 return;
4287 file = unbind_to (count, file); 4330 case kNavUserActionOpen:
4331 case kNavUserActionChoose:
4332 case kNavUserActionSaveAs:
4333 {
4334 NavReplyRecord reply;
4335 AEDesc aed;
4336 FSRef fsRef;
4337 status = NavDialogGetReply(dialogRef, &reply);
4338 AECoerceDesc(&reply.selection, typeFSRef, &aed);
4339 AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef));
4340 FSRefMakePath(&fsRef, (UInt8 *) filename, 1000);
4341 AEDisposeDesc(&aed);
4342 if (reply.saveFileName)
4343 {
4344 /* If it was a saved file, we need to add the file name */
4345 int len = strlen(filename);
4346 if (len && filename[len-1] != '/')
4347 filename[len++] = '/';
4348 CFStringGetCString(reply.saveFileName, filename+len,
4349 1000-len, kCFStringEncodingUTF8);
4350 }
4351 file = DECODE_FILE(build_string (filename));
4352 NavDisposeReply(&reply);
4353 }
4354 break;
4355 }
4356 NavDialogDispose(dialogRef);
4288 } 4357 }
4289 /* Open File dialog will not allow folders to be selected, so resort 4358 else {
4290 to minibuffer completing reads for directories. */ 4359 /* Fall back on minibuffer if there was a problem */
4291 else 4360 file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
4292 file = Fcompleting_read (prompt, intern ("read-file-name-internal"), 4361 dir, mustmatch, dir, Qfile_name_history,
4293 dir, mustmatch, dir, Qfile_name_history, 4362 default_filename, Qnil);
4294 default_filename, Qnil); 4363 }
4364 }
4295 4365
4296 UNGCPRO; 4366 UNGCPRO;
4297 4367
4298 /* Make "Cancel" equivalent to C-g. */ 4368 /* Make "Cancel" equivalent to C-g. */
4299 if (NILP (file)) 4369 if (NILP (file))
4300 Fsignal (Qquit, Qnil); 4370 Fsignal (Qquit, Qnil);
4301 4371
4302 return unbind_to (count, file); 4372 return unbind_to (count, file);
4303} 4373}
4304#endif /* MAC_TODO */
4305 4374
4306 4375
4376#endif
4307 4377
4308/*********************************************************************** 4378/***********************************************************************
4309 Initialization 4379 Initialization
@@ -4507,7 +4577,7 @@ Chinese, Japanese, and Korean. */);
4507 last_show_tip_args = Qnil; 4577 last_show_tip_args = Qnil;
4508 staticpro (&last_show_tip_args); 4578 staticpro (&last_show_tip_args);
4509 4579
4510#if 0 /* MAC_TODO */ 4580#if TARGET_API_MAC_CARBON
4511 defsubr (&Sx_file_dialog); 4581 defsubr (&Sx_file_dialog);
4512#endif 4582#endif
4513} 4583}
diff --git a/src/macmenu.c b/src/macmenu.c
index d205ee3b877..67e18481a1b 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -163,6 +163,12 @@ extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
163 163
164extern Lisp_Object Qmenu_bar_update_hook; 164extern Lisp_Object Qmenu_bar_update_hook;
165 165
166#if TARGET_API_MAC_CARBON
167#define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
168#else
169#define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
170#endif
171
166void set_frame_menubar (); 172void set_frame_menubar ();
167 173
168static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 174static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
@@ -1246,13 +1252,13 @@ single_submenu (item_key, item_name, maps)
1246#ifndef HAVE_MULTILINGUAL_MENU 1252#ifndef HAVE_MULTILINGUAL_MENU
1247 if (STRING_MULTIBYTE (item_name)) 1253 if (STRING_MULTIBYTE (item_name))
1248 { 1254 {
1249 item_name = ENCODE_SYSTEM (item_name); 1255 item_name = ENCODE_MENU_STRING (item_name);
1250 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; 1256 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
1251 } 1257 }
1252 1258
1253 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 1259 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
1254 { 1260 {
1255 descrip = ENCODE_SYSTEM (descrip); 1261 descrip = ENCODE_MENU_STRING (descrip);
1256 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; 1262 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
1257 } 1263 }
1258#endif /* not HAVE_MULTILINGUAL_MENU */ 1264#endif /* not HAVE_MULTILINGUAL_MENU */
@@ -1705,12 +1711,12 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
1705#ifndef HAVE_MULTILINGUAL_MENU 1711#ifndef HAVE_MULTILINGUAL_MENU
1706 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) 1712 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
1707 { 1713 {
1708 item_name = ENCODE_SYSTEM (item_name); 1714 item_name = ENCODE_MENU_STRING (item_name);
1709 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; 1715 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
1710 } 1716 }
1711 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 1717 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
1712 { 1718 {
1713 descrip = ENCODE_SYSTEM (descrip); 1719 descrip = ENCODE_MENU_STRING (descrip);
1714 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; 1720 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
1715 } 1721 }
1716#endif /* not HAVE_MULTILINGUAL_MENU */ 1722#endif /* not HAVE_MULTILINGUAL_MENU */
@@ -1764,7 +1770,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
1764 1770
1765#ifndef HAVE_MULTILINGUAL_MENU 1771#ifndef HAVE_MULTILINGUAL_MENU
1766 if (STRING_MULTIBYTE (title)) 1772 if (STRING_MULTIBYTE (title))
1767 title = ENCODE_SYSTEM (title); 1773 title = ENCODE_MENU_STRING (title);
1768#endif 1774#endif
1769 wv_title->name = (char *) SDATA (title); 1775 wv_title->name = (char *) SDATA (title);
1770 wv_title->enabled = TRUE; 1776 wv_title->enabled = TRUE;
@@ -1813,6 +1819,10 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
1813 discard_mouse_events (); 1819 discard_mouse_events ();
1814#endif 1820#endif
1815 1821
1822 /* Must reset this manually because the button release event is not
1823 passed to Emacs event loop. */
1824 FRAME_MAC_DISPLAY_INFO (f)->grabbed = 0;
1825
1816 /* Free the widget_value objects we used to specify the 1826 /* Free the widget_value objects we used to specify the
1817 contents. */ 1827 contents. */
1818 free_menubar_widget_value_tree (first_wv); 1828 free_menubar_widget_value_tree (first_wv);
@@ -2219,8 +2229,18 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
2219 strncat (item_name, wv->key, 255); 2229 strncat (item_name, wv->key, 255);
2220 } 2230 }
2221 item_name[255] = 0; 2231 item_name[255] = 0;
2232#if TARGET_API_MAC_CARBON
2233 {
2234 CFStringRef string =
2235 CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8);
2236
2237 SetMenuItemTextWithCFString (menu, pos, string);
2238 CFRelease (string);
2239 }
2240#else
2222 c2pstr (item_name); 2241 c2pstr (item_name);
2223 SetMenuItemText (menu, pos, item_name); 2242 SetMenuItemText (menu, pos, item_name);
2243#endif
2224 2244
2225 if (wv->enabled && !force_disable) 2245 if (wv->enabled && !force_disable)
2226#if TARGET_API_MAC_CARBON 2246#if TARGET_API_MAC_CARBON
diff --git a/src/minibuf.c b/src/minibuf.c
index a313016154e..07b9a0d9c7a 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2663,7 +2663,10 @@ property of a history variable overrides this default. */);
2663 Vcompletion_auto_help = Qt; 2663 Vcompletion_auto_help = Qt;
2664 2664
2665 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case, 2665 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case,
2666 doc: /* Non-nil means don't consider case significant in completion. */); 2666 doc: /* Non-nil means don't consider case significant in completion.
2667
2668See also `read-file-name-completion-ignore-case' concerning case significance
2669in completion when reading a file name. */);
2667 completion_ignore_case = 0; 2670 completion_ignore_case = 0;
2668 2671
2669 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers, 2672 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers,
diff --git a/src/msdos.c b/src/msdos.c
index 0aec39e1440..daa4199d6a7 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -5102,7 +5102,7 @@ dos_yield_time_slice (void)
5102 5102
5103/* Only event queue is checked. */ 5103/* Only event queue is checked. */
5104/* We don't have to call timer_check here 5104/* We don't have to call timer_check here
5105 because wait_reading_process_input takes care of that. */ 5105 because wait_reading_process_output takes care of that. */
5106int 5106int
5107sys_select (nfds, rfds, wfds, efds, timeout) 5107sys_select (nfds, rfds, wfds, efds, timeout)
5108 int nfds; 5108 int nfds;
diff --git a/src/process.c b/src/process.c
index 24ec816a699..688f97dc199 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3719,7 +3719,7 @@ close_process_descs ()
3719} 3719}
3720 3720
3721DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, 3721DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output,
3722 0, 3, 0, 3722 0, 4, 0,
3723 doc: /* Allow any pending output from subprocesses to be read by Emacs. 3723 doc: /* Allow any pending output from subprocesses to be read by Emacs.
3724It is read into the process' buffers or given to their filter functions. 3724It is read into the process' buffers or given to their filter functions.
3725Non-nil arg PROCESS means do not return until some output has been received 3725Non-nil arg PROCESS means do not return until some output has been received
@@ -3727,15 +3727,20 @@ from PROCESS.
3727Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of 3727Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of
3728seconds and microseconds to wait; return after that much time whether 3728seconds and microseconds to wait; return after that much time whether
3729or not there is input. 3729or not there is input.
3730If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
3731from PROCESS, suspending reading output from other processes.
3732If JUST-THIS-ONE is an integer, don't run any timers either.
3730Return non-nil iff we received any output before the timeout expired. */) 3733Return non-nil iff we received any output before the timeout expired. */)
3731 (process, timeout, timeout_msecs) 3734 (process, timeout, timeout_msecs, just_this_one)
3732 register Lisp_Object process, timeout, timeout_msecs; 3735 register Lisp_Object process, timeout, timeout_msecs, just_this_one;
3733{ 3736{
3734 int seconds; 3737 int seconds;
3735 int useconds; 3738 int useconds;
3736 3739
3737 if (! NILP (process)) 3740 if (! NILP (process))
3738 CHECK_PROCESS (process); 3741 CHECK_PROCESS (process);
3742 else
3743 just_this_one = Qnil;
3739 3744
3740 if (! NILP (timeout_msecs)) 3745 if (! NILP (timeout_msecs))
3741 { 3746 {
@@ -3773,11 +3778,12 @@ Return non-nil iff we received any output before the timeout expired. */)
3773 else 3778 else
3774 seconds = NILP (process) ? -1 : 0; 3779 seconds = NILP (process) ? -1 : 0;
3775 3780
3776 if (NILP (process))
3777 XSETFASTINT (process, 0);
3778
3779 return 3781 return
3780 (wait_reading_process_input (seconds, useconds, process, 0) 3782 (wait_reading_process_output (seconds, useconds, 0, 0,
3783 Qnil,
3784 !NILP (process) ? XPROCESS (process) : NULL,
3785 NILP (just_this_one) ? 0 :
3786 !INTEGERP (just_this_one) ? 1 : -1)
3781 ? Qt : Qnil); 3787 ? Qt : Qnil);
3782} 3788}
3783 3789
@@ -3977,12 +3983,12 @@ server_accept_connection (server, channel)
3977 lisp code is being evalled. 3983 lisp code is being evalled.
3978 This is also used in record_asynch_buffer_change. 3984 This is also used in record_asynch_buffer_change.
3979 For that purpose, this must be 0 3985 For that purpose, this must be 0
3980 when not inside wait_reading_process_input. */ 3986 when not inside wait_reading_process_output. */
3981static int waiting_for_user_input_p; 3987static int waiting_for_user_input_p;
3982 3988
3983/* This is here so breakpoints can be put on it. */ 3989/* This is here so breakpoints can be put on it. */
3984static void 3990static void
3985wait_reading_process_input_1 () 3991wait_reading_process_output_1 ()
3986{ 3992{
3987} 3993}
3988 3994
@@ -4004,25 +4010,32 @@ wait_reading_process_input_1 ()
4004 1 to return when input is available, or 4010 1 to return when input is available, or
4005 -1 meaning caller will actually read the input, so don't throw to 4011 -1 meaning caller will actually read the input, so don't throw to
4006 the quit handler, or 4012 the quit handler, or
4007 a cons cell, meaning wait until its car is non-nil
4008 (and gobble terminal input into the buffer if any arrives), or
4009 a process object, meaning wait until something arrives from that
4010 process. The return value is true iff we read some input from
4011 that process.
4012 4013
4013 DO_DISPLAY != 0 means redisplay should be done to show subprocess 4014 DO_DISPLAY != 0 means redisplay should be done to show subprocess
4014 output that arrives. 4015 output that arrives.
4016
4017 If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil
4018 (and gobble terminal input into the buffer if any arrives).
4015 4019
4016 If READ_KBD is a pointer to a struct Lisp_Process, then the 4020 If WAIT_PROC is specified, wait until something arrives from that
4017 function returns true iff we received input from that process 4021 process. The return value is true iff we read some input from
4018 before the timeout elapsed. 4022 that process.
4023
4024 If JUST_WAIT_PROC is non-nil, handle only output from WAIT_PROC
4025 (suspending output from other processes). A negative value
4026 means don't run any timers either.
4027
4028 If WAIT_PROC is specified, then the function returns true iff we
4029 received input from that process before the timeout elapsed.
4019 Otherwise, return true iff we received input from any process. */ 4030 Otherwise, return true iff we received input from any process. */
4020 4031
4021int 4032int
4022wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) 4033wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4023 int time_limit, microsecs; 4034 wait_for_cell, wait_proc, just_wait_proc)
4024 Lisp_Object read_kbd; 4035 int time_limit, microsecs, read_kbd, do_display;
4025 int do_display; 4036 Lisp_Object wait_for_cell;
4037 struct Lisp_Process *wait_proc;
4038 int just_wait_proc;
4026{ 4039{
4027 register int channel, nfds; 4040 register int channel, nfds;
4028 SELECT_TYPE Available; 4041 SELECT_TYPE Available;
@@ -4032,33 +4045,19 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4032 Lisp_Object proc; 4045 Lisp_Object proc;
4033 EMACS_TIME timeout, end_time; 4046 EMACS_TIME timeout, end_time;
4034 int wait_channel = -1; 4047 int wait_channel = -1;
4035 struct Lisp_Process *wait_proc = 0;
4036 int got_some_input = 0; 4048 int got_some_input = 0;
4037 /* Either nil or a cons cell, the car of which is of interest and 4049 /* Either nil or a cons cell, the car of which is of interest and
4038 may be changed outside of this routine. */ 4050 may be changed outside of this routine. */
4039 Lisp_Object wait_for_cell = Qnil;
4040 int saved_waiting_for_user_input_p = waiting_for_user_input_p; 4051 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4041 4052
4042 FD_ZERO (&Available); 4053 FD_ZERO (&Available);
4043 FD_ZERO (&Connecting); 4054 FD_ZERO (&Connecting);
4044 4055
4045 /* If read_kbd is a process to watch, set wait_proc and wait_channel 4056 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4046 accordingly. */ 4057 if (wait_proc != NULL)
4047 if (PROCESSP (read_kbd)) 4058 wait_channel = XINT (wait_proc->infd);
4048 {
4049 wait_proc = XPROCESS (read_kbd);
4050 wait_channel = XINT (wait_proc->infd);
4051 XSETFASTINT (read_kbd, 0);
4052 }
4053
4054 /* If waiting for non-nil in a cell, record where. */
4055 if (CONSP (read_kbd))
4056 {
4057 wait_for_cell = read_kbd;
4058 XSETFASTINT (read_kbd, 0);
4059 }
4060 4059
4061 waiting_for_user_input_p = XINT (read_kbd); 4060 waiting_for_user_input_p = read_kbd;
4062 4061
4063 /* Since we may need to wait several times, 4062 /* Since we may need to wait several times,
4064 compute the absolute time to return at. */ 4063 compute the absolute time to return at. */
@@ -4086,7 +4085,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4086 /* If calling from keyboard input, do not quit 4085 /* If calling from keyboard input, do not quit
4087 since we want to return C-g as an input character. 4086 since we want to return C-g as an input character.
4088 Otherwise, do pending quit if requested. */ 4087 Otherwise, do pending quit if requested. */
4089 if (XINT (read_kbd) >= 0) 4088 if (read_kbd >= 0)
4090 QUIT; 4089 QUIT;
4091#ifdef SYNC_INPUT 4090#ifdef SYNC_INPUT
4092 else if (interrupt_input_pending) 4091 else if (interrupt_input_pending)
@@ -4123,7 +4122,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4123 But not if wait_for_cell; in those cases, 4122 But not if wait_for_cell; in those cases,
4124 the wait is supposed to be short, 4123 the wait is supposed to be short,
4125 and those callers cannot handle running arbitrary Lisp code here. */ 4124 and those callers cannot handle running arbitrary Lisp code here. */
4126 if (NILP (wait_for_cell)) 4125 if (NILP (wait_for_cell)
4126 && just_wait_proc >= 0)
4127 { 4127 {
4128 EMACS_TIME timer_delay; 4128 EMACS_TIME timer_delay;
4129 4129
@@ -4151,7 +4151,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4151 while (!detect_input_pending ()); 4151 while (!detect_input_pending ());
4152 4152
4153 /* If there is unread keyboard input, also return. */ 4153 /* If there is unread keyboard input, also return. */
4154 if (XINT (read_kbd) != 0 4154 if (read_kbd != 0
4155 && requeued_events_pending_p ()) 4155 && requeued_events_pending_p ())
4156 break; 4156 break;
4157 4157
@@ -4169,7 +4169,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4169 else if (time_limit != -1) 4169 else if (time_limit != -1)
4170 { 4170 {
4171 /* This is so a breakpoint can be put here. */ 4171 /* This is so a breakpoint can be put here. */
4172 wait_reading_process_input_1 (); 4172 wait_reading_process_output_1 ();
4173 } 4173 }
4174 } 4174 }
4175 4175
@@ -4179,7 +4179,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4179 It is important that we do this before checking for process 4179 It is important that we do this before checking for process
4180 activity. If we get a SIGCHLD after the explicit checks for 4180 activity. If we get a SIGCHLD after the explicit checks for
4181 process activity, timeout is the only way we will know. */ 4181 process activity, timeout is the only way we will know. */
4182 if (XINT (read_kbd) < 0) 4182 if (read_kbd < 0)
4183 set_waiting_for_input (&timeout); 4183 set_waiting_for_input (&timeout);
4184 4184
4185 /* If status of something has changed, and no input is 4185 /* If status of something has changed, and no input is
@@ -4259,14 +4259,21 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4259 4259
4260 /* Wait till there is something to do */ 4260 /* Wait till there is something to do */
4261 4261
4262 if (!NILP (wait_for_cell)) 4262 if (wait_proc && just_wait_proc)
4263 {
4264 if (XINT (wait_proc->infd) < 0) /* Terminated */
4265 break;
4266 FD_SET (XINT (wait_proc->infd), &Available);
4267 check_connect = check_delay = 0;
4268 }
4269 else if (!NILP (wait_for_cell))
4263 { 4270 {
4264 Available = non_process_wait_mask; 4271 Available = non_process_wait_mask;
4265 check_connect = check_delay = 0; 4272 check_connect = check_delay = 0;
4266 } 4273 }
4267 else 4274 else
4268 { 4275 {
4269 if (! XINT (read_kbd)) 4276 if (! read_kbd)
4270 Available = non_keyboard_wait_mask; 4277 Available = non_keyboard_wait_mask;
4271 else 4278 else
4272 Available = input_wait_mask; 4279 Available = input_wait_mask;
@@ -4283,12 +4290,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4283 { 4290 {
4284 clear_waiting_for_input (); 4291 clear_waiting_for_input ();
4285 redisplay_preserve_echo_area (11); 4292 redisplay_preserve_echo_area (11);
4286 if (XINT (read_kbd) < 0) 4293 if (read_kbd < 0)
4287 set_waiting_for_input (&timeout); 4294 set_waiting_for_input (&timeout);
4288 } 4295 }
4289 4296
4290 no_avail = 0; 4297 no_avail = 0;
4291 if (XINT (read_kbd) && detect_input_pending ()) 4298 if (read_kbd && detect_input_pending ())
4292 { 4299 {
4293 nfds = 0; 4300 nfds = 0;
4294 no_avail = 1; 4301 no_avail = 1;
@@ -4405,10 +4412,10 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4405 /* If we are using polling for input, 4412 /* If we are using polling for input,
4406 and we see input available, make it get read now. 4413 and we see input available, make it get read now.
4407 Otherwise it might not actually get read for a second. 4414 Otherwise it might not actually get read for a second.
4408 And on hpux, since we turn off polling in wait_reading_process_input, 4415 And on hpux, since we turn off polling in wait_reading_process_output,
4409 it might never get read at all if we don't spend much time 4416 it might never get read at all if we don't spend much time
4410 outside of wait_reading_process_input. */ 4417 outside of wait_reading_process_output. */
4411 if (XINT (read_kbd) && interrupt_input 4418 if (read_kbd && interrupt_input
4412 && keyboard_bit_set (&Available) 4419 && keyboard_bit_set (&Available)
4413 && input_polling_used ()) 4420 && input_polling_used ())
4414 kill (getpid (), SIGALRM); 4421 kill (getpid (), SIGALRM);
@@ -4418,7 +4425,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4418 /* If there is any, return immediately 4425 /* If there is any, return immediately
4419 to give it higher priority than subprocesses */ 4426 to give it higher priority than subprocesses */
4420 4427
4421 if (XINT (read_kbd) != 0) 4428 if (read_kbd != 0)
4422 { 4429 {
4423 int old_timers_run = timers_run; 4430 int old_timers_run = timers_run;
4424 struct buffer *old_buffer = current_buffer; 4431 struct buffer *old_buffer = current_buffer;
@@ -4443,7 +4450,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4443 } 4450 }
4444 4451
4445 /* If there is unread keyboard input, also return. */ 4452 /* If there is unread keyboard input, also return. */
4446 if (XINT (read_kbd) != 0 4453 if (read_kbd != 0
4447 && requeued_events_pending_p ()) 4454 && requeued_events_pending_p ())
4448 break; 4455 break;
4449 4456
@@ -4454,7 +4461,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4454 That would causes delays in pasting selections, for example. 4461 That would causes delays in pasting selections, for example.
4455 4462
4456 (We used to do this only if wait_for_cell.) */ 4463 (We used to do this only if wait_for_cell.) */
4457 if (XINT (read_kbd) == 0 && detect_input_pending ()) 4464 if (read_kbd == 0 && detect_input_pending ())
4458 { 4465 {
4459 swallow_events (do_display); 4466 swallow_events (do_display);
4460#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ 4467#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */
@@ -4473,7 +4480,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4473 In that case, there really is no input and no SIGIO, 4480 In that case, there really is no input and no SIGIO,
4474 but select says there is input. */ 4481 but select says there is input. */
4475 4482
4476 if (XINT (read_kbd) && interrupt_input 4483 if (read_kbd && interrupt_input
4477 && keyboard_bit_set (&Available) && ! noninteractive) 4484 && keyboard_bit_set (&Available) && ! noninteractive)
4478 kill (getpid (), SIGIO); 4485 kill (getpid (), SIGIO);
4479#endif 4486#endif
@@ -4483,7 +4490,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4483 4490
4484 /* If checking input just got us a size-change event from X, 4491 /* If checking input just got us a size-change event from X,
4485 obey it now if we should. */ 4492 obey it now if we should. */
4486 if (XINT (read_kbd) || ! NILP (wait_for_cell)) 4493 if (read_kbd || ! NILP (wait_for_cell))
4487 do_pending_window_change (0); 4494 do_pending_window_change (0);
4488 4495
4489 /* Check for data from a process. */ 4496 /* Check for data from a process. */
@@ -4658,7 +4665,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4658 /* If calling from keyboard input, do not quit 4665 /* If calling from keyboard input, do not quit
4659 since we want to return C-g as an input character. 4666 since we want to return C-g as an input character.
4660 Otherwise, do pending quit if requested. */ 4667 Otherwise, do pending quit if requested. */
4661 if (XINT (read_kbd) >= 0) 4668 if (read_kbd >= 0)
4662 { 4669 {
4663 /* Prevent input_pending from remaining set if we quit. */ 4670 /* Prevent input_pending from remaining set if we quit. */
4664 clear_input_pending (); 4671 clear_input_pending ();
@@ -5303,7 +5310,6 @@ send_process (proc, buf, len, object)
5303 that may allow the program 5310 that may allow the program
5304 to finish doing output and read more. */ 5311 to finish doing output and read more. */
5305 { 5312 {
5306 Lisp_Object zero;
5307 int offset = 0; 5313 int offset = 0;
5308 5314
5309#ifdef BROKEN_PTY_READ_AFTER_EAGAIN 5315#ifdef BROKEN_PTY_READ_AFTER_EAGAIN
@@ -5338,11 +5344,10 @@ send_process (proc, buf, len, object)
5338 else if (STRINGP (object)) 5344 else if (STRINGP (object))
5339 offset = buf - SDATA (object); 5345 offset = buf - SDATA (object);
5340 5346
5341 XSETFASTINT (zero, 0);
5342#ifdef EMACS_HAS_USECS 5347#ifdef EMACS_HAS_USECS
5343 wait_reading_process_input (0, 20000, zero, 0); 5348 wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0);
5344#else 5349#else
5345 wait_reading_process_input (1, 0, zero, 0); 5350 wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0);
5346#endif 5351#endif
5347 5352
5348 if (BUFFERP (object)) 5353 if (BUFFERP (object))
@@ -5548,29 +5553,36 @@ process_send_signal (process, signo, current_group, nomsg)
5548 work. If the system has it, use it. */ 5553 work. If the system has it, use it. */
5549#ifdef HAVE_TERMIOS 5554#ifdef HAVE_TERMIOS
5550 struct termios t; 5555 struct termios t;
5556 cc_t *sig_char = NULL;
5557
5558 tcgetattr (XINT (p->infd), &t);
5551 5559
5552 switch (signo) 5560 switch (signo)
5553 { 5561 {
5554 case SIGINT: 5562 case SIGINT:
5555 tcgetattr (XINT (p->infd), &t); 5563 sig_char = &t.c_cc[VINTR];
5556 send_process (proc, &t.c_cc[VINTR], 1, Qnil); 5564 break;
5557 return;
5558 5565
5559 case SIGQUIT: 5566 case SIGQUIT:
5560 tcgetattr (XINT (p->infd), &t); 5567 sig_char = &t.c_cc[VQUIT];
5561 send_process (proc, &t.c_cc[VQUIT], 1, Qnil); 5568 break;
5562 return;
5563 5569
5564 case SIGTSTP: 5570 case SIGTSTP:
5565 tcgetattr (XINT (p->infd), &t);
5566#if defined (VSWTCH) && !defined (PREFER_VSUSP) 5571#if defined (VSWTCH) && !defined (PREFER_VSUSP)
5567 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); 5572 sig_char = &t.c_cc[VSWTCH];
5568#else 5573#else
5569 send_process (proc, &t.c_cc[VSUSP], 1, Qnil); 5574 sig_char = &t.c_cc[VSUSP];
5570#endif 5575#endif
5571 return; 5576 break;
5572 } 5577 }
5573 5578
5579 if (sig_char && *sig_char != CDISABLE)
5580 {
5581 send_process (proc, sig_char, 1, Qnil);
5582 return;
5583 }
5584 /* If we can't send the signal with a character,
5585 fall through and send it another way. */
5574#else /* ! HAVE_TERMIOS */ 5586#else /* ! HAVE_TERMIOS */
5575 5587
5576 /* On Berkeley descendants, the following IOCTL's retrieve the 5588 /* On Berkeley descendants, the following IOCTL's retrieve the
@@ -5627,9 +5639,12 @@ process_send_signal (process, signo, current_group, nomsg)
5627 you'd better be using one of the alternatives above! */ 5639 you'd better be using one of the alternatives above! */
5628#endif /* ! defined (TCGETA) */ 5640#endif /* ! defined (TCGETA) */
5629#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ 5641#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
5630#endif /* ! defined HAVE_TERMIOS */ 5642 /* In this case, the code above should alway returns. */
5631 abort (); 5643 abort ();
5632 /* The code above always returns from the function. */ 5644#endif /* ! defined HAVE_TERMIOS */
5645
5646 /* The code above may fall through if it can't
5647 handle the signal. */
5633#endif /* defined (SIGNALS_VIA_CHARACTERS) */ 5648#endif /* defined (SIGNALS_VIA_CHARACTERS) */
5634 5649
5635#ifdef TIOCGPGRP 5650#ifdef TIOCGPGRP
@@ -6201,7 +6216,7 @@ sigchld_handler (signo)
6201 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 6216 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask);
6202 } 6217 }
6203 6218
6204 /* Tell wait_reading_process_input that it needs to wake up and 6219 /* Tell wait_reading_process_output that it needs to wake up and
6205 look around. */ 6220 look around. */
6206 if (input_available_clear_time) 6221 if (input_available_clear_time)
6207 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6222 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
@@ -6219,7 +6234,7 @@ sigchld_handler (signo)
6219 else if (WIFSIGNALED (w)) 6234 else if (WIFSIGNALED (w))
6220 synch_process_termsig = WTERMSIG (w); 6235 synch_process_termsig = WTERMSIG (w);
6221 6236
6222 /* Tell wait_reading_process_input that it needs to wake up and 6237 /* Tell wait_reading_process_output that it needs to wake up and
6223 look around. */ 6238 look around. */
6224 if (input_available_clear_time) 6239 if (input_available_clear_time)
6225 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6240 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
@@ -6861,10 +6876,9 @@ Lisp_Object QCtype;
6861 1 to return when input is available, or 6876 1 to return when input is available, or
6862 -1 means caller will actually read the input, so don't throw to 6877 -1 means caller will actually read the input, so don't throw to
6863 the quit handler. 6878 the quit handler.
6864 a cons cell, meaning wait until its car is non-nil 6879
6865 (and gobble terminal input into the buffer if any arrives), or 6880 see full version for other parameters. We know that wait_proc will
6866 We know that read_kbd will never be a Lisp_Process, since 6881 always be NULL, since `subprocesses' isn't defined.
6867 `subprocesses' isn't defined.
6868 6882
6869 do_display != 0 means redisplay should be done to show subprocess 6883 do_display != 0 means redisplay should be done to show subprocess
6870 output that arrives. 6884 output that arrives.
@@ -6872,27 +6886,17 @@ Lisp_Object QCtype;
6872 Return true iff we received input from any process. */ 6886 Return true iff we received input from any process. */
6873 6887
6874int 6888int
6875wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) 6889wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
6876 int time_limit, microsecs; 6890 wait_for_cell, wait_proc, just_wait_proc)
6877 Lisp_Object read_kbd; 6891 int time_limit, microsecs, read_kbd, do_display;
6878 int do_display; 6892 Lisp_Object wait_for_cell;
6893 struct Lisp_Process *wait_proc;
6894 int just_wait_proc;
6879{ 6895{
6880 register int nfds; 6896 register int nfds;
6881 EMACS_TIME end_time, timeout; 6897 EMACS_TIME end_time, timeout;
6882 SELECT_TYPE waitchannels; 6898 SELECT_TYPE waitchannels;
6883 int xerrno; 6899 int xerrno;
6884 /* Either nil or a cons cell, the car of which is of interest and
6885 may be changed outside of this routine. */
6886 Lisp_Object wait_for_cell;
6887
6888 wait_for_cell = Qnil;
6889
6890 /* If waiting for non-nil in a cell, record where. */
6891 if (CONSP (read_kbd))
6892 {
6893 wait_for_cell = read_kbd;
6894 XSETFASTINT (read_kbd, 0);
6895 }
6896 6900
6897 /* What does time_limit really mean? */ 6901 /* What does time_limit really mean? */
6898 if (time_limit || microsecs) 6902 if (time_limit || microsecs)
@@ -6915,7 +6919,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
6915 /* If calling from keyboard input, do not quit 6919 /* If calling from keyboard input, do not quit
6916 since we want to return C-g as an input character. 6920 since we want to return C-g as an input character.
6917 Otherwise, do pending quit if requested. */ 6921 Otherwise, do pending quit if requested. */
6918 if (XINT (read_kbd) >= 0) 6922 if (read_kbd >= 0)
6919 QUIT; 6923 QUIT;
6920 6924
6921 /* Exit now if the cell we're waiting for became non-nil. */ 6925 /* Exit now if the cell we're waiting for became non-nil. */
@@ -6966,7 +6970,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
6966 while (!detect_input_pending ()); 6970 while (!detect_input_pending ());
6967 6971
6968 /* If there is unread keyboard input, also return. */ 6972 /* If there is unread keyboard input, also return. */
6969 if (XINT (read_kbd) != 0 6973 if (read_kbd != 0
6970 && requeued_events_pending_p ()) 6974 && requeued_events_pending_p ())
6971 break; 6975 break;
6972 6976
@@ -6984,12 +6988,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
6984 6988
6985 /* Cause C-g and alarm signals to take immediate action, 6989 /* Cause C-g and alarm signals to take immediate action,
6986 and cause input available signals to zero out timeout. */ 6990 and cause input available signals to zero out timeout. */
6987 if (XINT (read_kbd) < 0) 6991 if (read_kbd < 0)
6988 set_waiting_for_input (&timeout); 6992 set_waiting_for_input (&timeout);
6989 6993
6990 /* Wait till there is something to do. */ 6994 /* Wait till there is something to do. */
6991 6995
6992 if (! XINT (read_kbd) && NILP (wait_for_cell)) 6996 if (! read_kbd && NILP (wait_for_cell))
6993 FD_ZERO (&waitchannels); 6997 FD_ZERO (&waitchannels);
6994 else 6998 else
6995 FD_SET (0, &waitchannels); 6999 FD_SET (0, &waitchannels);
@@ -7000,11 +7004,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7000 { 7004 {
7001 clear_waiting_for_input (); 7005 clear_waiting_for_input ();
7002 redisplay_preserve_echo_area (15); 7006 redisplay_preserve_echo_area (15);
7003 if (XINT (read_kbd) < 0) 7007 if (read_kbd < 0)
7004 set_waiting_for_input (&timeout); 7008 set_waiting_for_input (&timeout);
7005 } 7009 }
7006 7010
7007 if (XINT (read_kbd) && detect_input_pending ()) 7011 if (read_kbd && detect_input_pending ())
7008 { 7012 {
7009 nfds = 0; 7013 nfds = 0;
7010 FD_ZERO (&waitchannels); 7014 FD_ZERO (&waitchannels);
@@ -7040,13 +7044,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7040 kill (getpid (), SIGIO); 7044 kill (getpid (), SIGIO);
7041#endif 7045#endif
7042#ifdef SIGIO 7046#ifdef SIGIO
7043 if (XINT (read_kbd) && interrupt_input && (waitchannels & 1)) 7047 if (read_kbd && interrupt_input && (waitchannels & 1))
7044 kill (getpid (), SIGIO); 7048 kill (getpid (), SIGIO);
7045#endif 7049#endif
7046 7050
7047 /* Check for keyboard input */ 7051 /* Check for keyboard input */
7048 7052
7049 if ((XINT (read_kbd) != 0) 7053 if (read_kbd
7050 && detect_input_pending_run_timers (do_display)) 7054 && detect_input_pending_run_timers (do_display))
7051 { 7055 {
7052 swallow_events (do_display); 7056 swallow_events (do_display);
@@ -7055,7 +7059,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7055 } 7059 }
7056 7060
7057 /* If there is unread keyboard input, also return. */ 7061 /* If there is unread keyboard input, also return. */
7058 if (XINT (read_kbd) != 0 7062 if (read_kbd
7059 && requeued_events_pending_p ()) 7063 && requeued_events_pending_p ())
7060 break; 7064 break;
7061 7065
diff --git a/src/syntax.c b/src/syntax.c
index 57606f314d6..a8b6a58a89b 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -293,7 +293,7 @@ char_quoted (charpos, bytepos)
293 293
294 DEC_BOTH (charpos, bytepos); 294 DEC_BOTH (charpos, bytepos);
295 295
296 while (bytepos >= beg) 296 while (charpos >= beg)
297 { 297 {
298 int c; 298 int c;
299 299
@@ -674,7 +674,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
674 { 674 {
675 from = comstart_pos; 675 from = comstart_pos;
676 from_byte = comstart_byte; 676 from_byte = comstart_byte;
677 /* Globals are correct now. */ 677 UPDATE_SYNTAX_TABLE_FORWARD (from - 1);
678 } 678 }
679 else 679 else
680 { 680 {
diff --git a/src/sysdep.c b/src/sysdep.c
index d5236a3f88a..b120dcd950d 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -610,6 +610,15 @@ child_setup_tty (out)
610 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ 610 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
611#endif /* HPUX */ 611#endif /* HPUX */
612 612
613#ifdef SIGNALS_VIA_CHARACTERS
614 /* the QUIT and INTR character are used in process_send_signal
615 so set them here to something useful. */
616 if (s.main.c_cc[VQUIT] == CDISABLE)
617 s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */
618 if (s.main.c_cc[VINTR] == CDISABLE)
619 s.main.c_cc[VINTR] = 'C'&037; /* Control-C */
620#endif /* not SIGNALS_VIA_CHARACTERS */
621
613#ifdef AIX 622#ifdef AIX
614/* AIX enhanced edit loses NULs, so disable it */ 623/* AIX enhanced edit loses NULs, so disable it */
615#ifndef IBMR2AIX 624#ifndef IBMR2AIX
@@ -620,22 +629,16 @@ child_setup_tty (out)
620 don't ignore break, but don't signal either, so it looks like NUL. */ 629 don't ignore break, but don't signal either, so it looks like NUL. */
621 s.main.c_iflag &= ~IGNBRK; 630 s.main.c_iflag &= ~IGNBRK;
622 s.main.c_iflag &= ~BRKINT; 631 s.main.c_iflag &= ~BRKINT;
632 /* rms: Formerly it set s.main.c_cc[VINTR] to 0377 here
633 unconditionally. Then a SIGNALS_VIA_CHARACTERS conditional
634 would force it to 0377. That looks like duplicated code. */
635#ifndef SIGNALS_VIA_CHARACTERS
623 /* QUIT and INTR work better as signals, so disable character forms */ 636 /* QUIT and INTR work better as signals, so disable character forms */
624 s.main.c_cc[VINTR] = 0377; 637 s.main.c_cc[VQUIT] = CDISABLE;
625#ifdef SIGNALS_VIA_CHARACTERS 638 s.main.c_cc[VINTR] = CDISABLE;
626 /* the QUIT and INTR character are used in process_send_signal
627 so set them here to something useful. */
628 if (s.main.c_cc[VQUIT] == 0377)
629 s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */
630 if (s.main.c_cc[VINTR] == 0377)
631 s.main.c_cc[VINTR] = 'C'&037; /* Control-C */
632#else /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */
633 /* QUIT and INTR work better as signals, so disable character forms */
634 s.main.c_cc[VQUIT] = 0377;
635 s.main.c_cc[VINTR] = 0377;
636 s.main.c_lflag &= ~ISIG; 639 s.main.c_lflag &= ~ISIG;
637#endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ 640#endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */
638 s.main.c_cc[VEOL] = 0377; 641 s.main.c_cc[VEOL] = CDISABLE;
639 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ 642 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
640#endif /* AIX */ 643#endif /* AIX */
641 644
@@ -1476,10 +1479,10 @@ nil means don't delete them until `list-processes' is run. */);
1476 tty.main.c_line = 0; 1479 tty.main.c_line = 0;
1477 tty.main.c_iflag &= ~ASCEDIT; 1480 tty.main.c_iflag &= ~ASCEDIT;
1478#else 1481#else
1479 tty.main.c_cc[VSTRT] = 255; 1482 tty.main.c_cc[VSTRT] = CDISABLE;
1480 tty.main.c_cc[VSTOP] = 255; 1483 tty.main.c_cc[VSTOP] = CDISABLE;
1481 tty.main.c_cc[VSUSP] = 255; 1484 tty.main.c_cc[VSUSP] = CDISABLE;
1482 tty.main.c_cc[VDSUSP] = 255; 1485 tty.main.c_cc[VDSUSP] = CDISABLE;
1483#endif /* IBMR2AIX */ 1486#endif /* IBMR2AIX */
1484 if (flow_control) 1487 if (flow_control)
1485 { 1488 {
diff --git a/src/w32proc.c b/src/w32proc.c
index 8452337f7e2..9abee2bf0c2 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1218,7 +1218,7 @@ count_children:
1218 { 1218 {
1219 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", 1219 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n",
1220 nh + nc, timeout_ms, GetLastError ())); 1220 nh + nc, timeout_ms, GetLastError ()));
1221 /* don't return EBADF - this causes wait_reading_process_input to 1221 /* don't return EBADF - this causes wait_reading_process_output to
1222 abort; WAIT_FAILED is returned when single-stepping under 1222 abort; WAIT_FAILED is returned when single-stepping under
1223 Windows 95 after switching thread focus in debugger, and 1223 Windows 95 after switching thread focus in debugger, and
1224 possibly at other times. */ 1224 possibly at other times. */
diff --git a/src/w32term.c b/src/w32term.c
index 95ccafe415b..50a777f2002 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4721,7 +4721,7 @@ w32_read_socket (sd, expected, hold_quit)
4721 f->async_visible = 1; 4721 f->async_visible = 1;
4722 f->async_iconified = 0; 4722 f->async_iconified = 0;
4723 4723
4724 /* wait_reading_process_input will notice this and update 4724 /* wait_reading_process_output will notice this and update
4725 the frame's display structures. */ 4725 the frame's display structures. */
4726 SET_FRAME_GARBAGED (f); 4726 SET_FRAME_GARBAGED (f);
4727 4727
diff --git a/src/xdisp.c b/src/xdisp.c
index 463889507e4..35a4d755577 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10492,7 +10492,7 @@ redisplay_internal (preserve_echo_area)
10492 This is useful in situations where you need to redisplay but no 10492 This is useful in situations where you need to redisplay but no
10493 user action has occurred, making it inappropriate for the message 10493 user action has occurred, making it inappropriate for the message
10494 area to be cleared. See tracking_off and 10494 area to be cleared. See tracking_off and
10495 wait_reading_process_input for examples of these situations. 10495 wait_reading_process_output for examples of these situations.
10496 10496
10497 FROM_WHERE is an integer saying from where this function was 10497 FROM_WHERE is an integer saying from where this function was
10498 called. This is useful for debugging. */ 10498 called. This is useful for debugging. */
diff --git a/src/xfaces.c b/src/xfaces.c
index 0a81342e96d..6e8a64e3c41 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3705,7 +3705,10 @@ merge_face_ref (f, face_ref, to, err_msgs, named_merge_points)
3705 Lisp_Object value = XCAR (XCDR (face_ref)); 3705 Lisp_Object value = XCAR (XCDR (face_ref));
3706 int err = 0; 3706 int err = 0;
3707 3707
3708 if (EQ (keyword, QCfamily)) 3708 /* Specifying `unspecified' is a no-op. */
3709 if (EQ (value, Qunspecified))
3710 ;
3711 else if (EQ (keyword, QCfamily))
3709 { 3712 {
3710 if (STRINGP (value)) 3713 if (STRINGP (value))
3711 to[LFACE_FAMILY_INDEX] = value; 3714 to[LFACE_FAMILY_INDEX] = value;
diff --git a/src/xfns.c b/src/xfns.c
index 8d182a6788b..f392757b949 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -282,6 +282,8 @@ x_window_to_frame (dpyinfo, wdesc)
282 Lisp_Object tail, frame; 282 Lisp_Object tail, frame;
283 struct frame *f; 283 struct frame *f;
284 284
285 if (wdesc == None) return 0;
286
285 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) 287 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
286 { 288 {
287 frame = XCAR (tail); 289 frame = XCAR (tail);
@@ -331,6 +333,8 @@ x_any_window_to_frame (dpyinfo, wdesc)
331 struct frame *f, *found; 333 struct frame *f, *found;
332 struct x_output *x; 334 struct x_output *x;
333 335
336 if (wdesc == None) return NULL;
337
334 found = NULL; 338 found = NULL;
335 for (tail = Vframe_list; GC_CONSP (tail) && !found; tail = XCDR (tail)) 339 for (tail = Vframe_list; GC_CONSP (tail) && !found; tail = XCDR (tail))
336 { 340 {
@@ -385,6 +389,8 @@ x_non_menubar_window_to_frame (dpyinfo, wdesc)
385 struct frame *f; 389 struct frame *f;
386 struct x_output *x; 390 struct x_output *x;
387 391
392 if (wdesc == None) return 0;
393
388 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) 394 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
389 { 395 {
390 frame = XCAR (tail); 396 frame = XCAR (tail);
@@ -431,6 +437,8 @@ x_menubar_window_to_frame (dpyinfo, wdesc)
431 struct frame *f; 437 struct frame *f;
432 struct x_output *x; 438 struct x_output *x;
433 439
440 if (wdesc == None) return 0;
441
434 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) 442 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
435 { 443 {
436 frame = XCAR (tail); 444 frame = XCAR (tail);
@@ -476,6 +484,8 @@ x_top_window_to_frame (dpyinfo, wdesc)
476 struct frame *f; 484 struct frame *f;
477 struct x_output *x; 485 struct x_output *x;
478 486
487 if (wdesc == None) return 0;
488
479 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) 489 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
480 { 490 {
481 frame = XCAR (tail); 491 frame = XCAR (tail);
@@ -1631,7 +1641,7 @@ x_set_name (f, name, explicit)
1631 } 1641 }
1632#ifdef USE_GTK 1642#ifdef USE_GTK
1633 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1643 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1634 SDATA (name)); 1644 SDATA (ENCODE_UTF_8 (name)));
1635#else /* not USE_GTK */ 1645#else /* not USE_GTK */
1636 XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text); 1646 XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
1637#endif /* not USE_GTK */ 1647#endif /* not USE_GTK */
@@ -1739,7 +1749,7 @@ x_set_title (f, name, old_name)
1739 1749
1740#ifdef USE_GTK 1750#ifdef USE_GTK
1741 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1751 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1742 SDATA (name)); 1752 SDATA (ENCODE_UTF_8 (name)));
1743#else /* not USE_GTK */ 1753#else /* not USE_GTK */
1744 XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text); 1754 XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
1745#endif /* not USE_GTK */ 1755#endif /* not USE_GTK */
diff --git a/src/xselect.c b/src/xselect.c
index 7be238651a0..5de1beb9ac4 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1109,7 +1109,8 @@ wait_for_property_change (location)
1109 secs = x_selection_timeout / 1000; 1109 secs = x_selection_timeout / 1000;
1110 usecs = (x_selection_timeout % 1000) * 1000; 1110 usecs = (x_selection_timeout % 1000) * 1000;
1111 TRACE2 (" Waiting %d secs, %d usecs", secs, usecs); 1111 TRACE2 (" Waiting %d secs, %d usecs", secs, usecs);
1112 wait_reading_process_input (secs, usecs, property_change_reply, 0); 1112 wait_reading_process_output (secs, usecs, 0, 0,
1113 property_change_reply, NULL, 0);
1113 1114
1114 if (NILP (XCAR (property_change_reply))) 1115 if (NILP (XCAR (property_change_reply)))
1115 { 1116 {
@@ -1288,7 +1289,8 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1288 secs = x_selection_timeout / 1000; 1289 secs = x_selection_timeout / 1000;
1289 usecs = (x_selection_timeout % 1000) * 1000; 1290 usecs = (x_selection_timeout % 1000) * 1000;
1290 TRACE1 (" Start waiting %d secs for SelectionNotify", secs); 1291 TRACE1 (" Start waiting %d secs for SelectionNotify", secs);
1291 wait_reading_process_input (secs, usecs, reading_selection_reply, 0); 1292 wait_reading_process_output (secs, usecs, 0, 0,
1293 reading_selection_reply, NULL, 0);
1292 TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply))); 1294 TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply)));
1293 1295
1294 BLOCK_INPUT; 1296 BLOCK_INPUT;
diff --git a/src/xterm.c b/src/xterm.c
index 6eb106e5b3f..e7fb798eb60 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6180,7 +6180,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6180 f = x_top_window_to_frame (dpyinfo, event.xmap.window); 6180 f = x_top_window_to_frame (dpyinfo, event.xmap.window);
6181 if (f) 6181 if (f)
6182 { 6182 {
6183 /* wait_reading_process_input will notice this and update 6183 /* wait_reading_process_output will notice this and update
6184 the frame's display structures. 6184 the frame's display structures.
6185 If we where iconified, we should not set garbaged, 6185 If we where iconified, we should not set garbaged,
6186 because that stops redrawing on Expose events. This looks 6186 because that stops redrawing on Expose events. This looks
@@ -7611,11 +7611,13 @@ static Lisp_Object
7611x_catch_errors_unwind (old_val) 7611x_catch_errors_unwind (old_val)
7612 Lisp_Object old_val; 7612 Lisp_Object old_val;
7613{ 7613{
7614 Lisp_Object first; 7614 Lisp_Object first = XCAR (old_val);
7615 Display *dpy = XSAVE_VALUE (first)->pointer;
7615 7616
7616 first = XCAR (old_val); 7617 /* The display may have been closed before this function is called.
7617 7618 Check if it is still open before calling XSync. */
7618 XSync (XSAVE_VALUE (first)->pointer, False); 7619 if (x_display_info_for_display (dpy) != 0)
7620 XSync (dpy, False);
7619 7621
7620 x_error_message_string = XCDR (old_val); 7622 x_error_message_string = XCDR (old_val);
7621 return Qnil; 7623 return Qnil;