summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog314
-rw-r--r--src/alloc.c11
-rw-r--r--src/buffer.c2
-rw-r--r--src/bytecode.c3
-rw-r--r--src/callint.c3
-rw-r--r--src/coding.c5
-rw-r--r--src/data.c4
-rw-r--r--src/dispextern.h3
-rw-r--r--src/dispnew.c49
-rw-r--r--src/editfns.c5
-rw-r--r--src/eval.c11
-rw-r--r--src/fileio.c17
-rw-r--r--src/frame.c18
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/indent.c79
-rw-r--r--src/intervals.c4
-rw-r--r--src/keyboard.c24
-rw-r--r--src/keyboard.h1
-rw-r--r--src/keymap.c31
-rw-r--r--src/lisp.h5
-rw-r--r--src/macfns.c265
-rw-r--r--src/macmenu.c101
-rw-r--r--src/macterm.c10
-rw-r--r--src/minibuf.c5
-rw-r--r--src/msdos.c2
-rw-r--r--src/process.c226
-rw-r--r--src/s/darwin.h17
-rw-r--r--src/syntax.c12
-rw-r--r--src/sysdep.c37
-rw-r--r--src/w32fns.c12
-rw-r--r--src/w32menu.c198
-rw-r--r--src/w32proc.c2
-rw-r--r--src/w32term.c2
-rw-r--r--src/window.c22
-rw-r--r--src/xdisp.c111
-rw-r--r--src/xfaces.c6
-rw-r--r--src/xfns.c223
-rw-r--r--src/xmenu.c56
-rw-r--r--src/xselect.c6
-rw-r--r--src/xterm.c12
41 files changed, 1332 insertions, 586 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e51cdf554ce..8fd72a29c29 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,317 @@
+2004-09-03 Jason Rumney <jasonr@gnu.org>
+
+ * w32menu.c (_widget_value): Added lname and lkey.
+ (digest_single_submenu): Set lname and lkey in widget_value
+ instead of name and key.
+ (update_submenu_strings): New function.
+ (set_frame_menubar): Remove call to inhibit_garbage_collection,
+ call update_submenu_strings.
+
+ * w32menu.c (globals_of_w32menu): Check for Unicode API.
+ (digest_single_submenu, w32_menu_show): Encode menu strings as
+ UTF-8 if Unicode API is available.
+ (utf8to16): New function.
+ (add_menu_item): Use it when calling Unicode API.
+
+2004-09-03 Kim F. Storm <storm@cua.dk>
+
+ * xdisp.c (set_cursor_from_row): Look for non-nil `cursor' property
+ in overlay or text-property strings; set cursor on corresponding
+ glyph rather than at end of the string.
+
+2004-09-02 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macfns.c (x_real_positions): Save the current window port and
+ set a new one before obtaining the global coordinate. Use
+ FRAME_MAC_WINDOW.
+ (x_set_name, x_set_title): Encode title to UTF8. Use
+ SetWindowTitleWithCFString.
+ (Fx_server_version): Get correct OS version.
+
+ * macmenu.c (add_menu_item): Remove unused variable `i'. Don't
+ let separator items destroy refence constants of other menu items.
+
+ * macterm.c (x_update_end): Move SetPortWindowPort to inside
+ BLOCK_INPUT.
+ (x_set_offset): Use FRAME_MAC_WINDOW.
+
+ * xdisp.c (note_mouse_highlight): Set the mouse pointer shape to
+ nontext_cursor if it is on a scroll bar.
+
+ * s/darwin.h (LIBS_CARBON): New define to specify libraries for
+ Carbon support.
+ (LD_SWITCH_SYSTEM_TEMACS): Don't link with unused libstdc++. Use
+ LIBS_CARBON.
+
+2004-09-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * xfns.c (x_set_name_internal): New function. Check if we shall call
+ xfree before ENCODE_UTF_8.
+ (x_set_name, x_set_title): Call x_set_name_internal.
+
+2004-08-31 NAKAMURA Toshikazu <nr-tkz@nifty.com> (tiny change)
+
+ * w32fns.c (w32_load_font): If a BDF font is already loaded, do not
+ reload it.
+
+2004-08-30 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * macmenu.c (_widget_value): Added lname and lkey.
+ (single_submenu): Set lname and lkey in widget_value
+ instead of name and key.
+ (update_submenu_strings): New function.
+ (set_frame_menubar): Remove call to inhibit_garbage_collection,
+ call update_submenu_strings.
+
+ * xmenu.c (digest_single_submenu): Set lname and lkey in widget_value
+ instead of name and key.
+ (update_submenu_strings): New function.
+ (set_frame_menubar): Remove call to inhibit_garbage_collection,
+ call update_submenu_strings.
+
+ * gtkutil.h (_widget_value): Added lname and lkey.
+
+2004-08-30 Steven Tamm <steventamm@mac.com>
+
+ * macmenu.c (mac_menu_show): Remove shadowing of menu variable
+ by using different names for inner loop variables.
+
+2004-08-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * xmenu.c (set_frame_menubar): Reintroduce inhibit_garbage_collection
+ from 2002-07-15T00:01:34Z!raeburn@raeburn.org so that strings from ENCODE_UTF_8 isn't GC:ed before used.
+
+ * gtkutil.c (xg_create_frame_widgets): Compensate for tool bar when
+ tool bar items is 0.
+
+2004-08-26 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
+ strings in menu items.
+ (single_submenu): Use ENCODE_MENU_STRING
+ (mac_menu_show): Use ENCODE_MENU_STRING. Reset grabbed because
+ button release isn't passed to event loop
+ (add_menu_item): Use SetMenuItemWithCFString
+
+2004-08-26 Steven Tamm <steventamm@mac.com>
+
+ * fileio.c (Fread_file_name): Call x_file_dialog on carbon on
+ tool-bar/menu click
+ * macfns.c (Fx_file_dialog): Implemented using NavServices
+
+2004-08-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * xterm.c (x_catch_errors_unwind): Do not XSync if display has closed.
+
+ * xfns.c (x_window_to_frame, x_any_window_to_frame)
+ (x_non_menubar_window_to_frame, x_menubar_window_to_frame)
+ (x_top_window_to_frame): Return 0 if wdesc is None.
+
+2004-08-22 Richard M. Stallman <rms@gnu.org>
+
+ * process.c (process_send_signal) [SIGNALS_VIA_CHARACTERS,
+ HAVE_TERMIOS]: If there's no char for this signal, drop through
+ and use system calls.
+
+ * bytecode.c (Fbyte_code) <unwind-protect>: Cannot GC.
+
+2004-08-20 Kim F. Storm <storm@cua.dk>
+
+ * process.c (wait_reading_process_output): Rename from
+ wait_reading_process_input. All uses changed.
+ (wait_reading_process_output_1): Rename from
+ wait_reading_process_input_1. All uses changed.
+
+ * dispnew.c (Fsleep_for): Remove obsolete code.
+
+2004-08-20 Kenichi Handa <handa@m17n.org>
+
+ * syntax.c (skip_chars): Fix for unibyte case.
+
+2004-08-19 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * syntax.c (char_quoted): Mixup byte/char pos.
+ (back_comment): Fixup globals in all cases.
+
+2004-08-19 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * xfns.c (x_set_name, x_set_title): Encode title to UTF8 before
+ passing it to gtk_window_set_title.
+
+2004-08-19 Kim F. Storm <storm@cua.dk>
+
+ * process.c (wait_reading_process_input): Clean up.
+ Add wait_for_cell, wait_proc, and just_wait_proc args
+ to avoid overloading `read_kbd' and `do_display' args.
+ Change read_kbd arg to int. All callers changed.
+
+ * process.c (process_send_signal): Use CDISABLE.
+
+ * sysdep.c (child_setup_tty, init_sys_modes): Use CDISABLE.
+
+2004-08-18 Kim F. Storm <storm@cua.dk>
+
+ * process.c (Faccept_process_output): Add arg JUST-THIS-ONE;
+ forward to wait_reading_process_input via DO_DISPLAY arg.
+ (wait_reading_process_input): If DO_DISPLAY < 0 for a process
+ object, only process output from that process; also inhibit
+ running timers if DO_DISPLAY==-2.
+
+2004-08-17 Kim F. Storm <storm@cua.dk>
+
+ * process.c (process_send_signal): Fix last change--use
+ _POSIX_VDISABLE instead of CVDISABLE when available.
+
+2004-08-16 Richard M. Stallman <rms@gnu.org>
+
+ * sysdep.c (child_setup_tty) [SIGNALS_VIA_CHARACTERS]:
+ Set VQUIT and VINTR chars to the standard ones if they are unset.
+ [AIX]: Don't do that here. And don't force VINTR to standard
+ when SIGNALS_VIA_CHARACTERS.
+
+ * process.c (process_send_signal)
+ [SIGNALS_VIA_CHARACTERS, HAVE_TERMIOS]: Clean up.
+ Do nothing if the character is CVDISABLE.
+
+ * xfaces.c (merge_face_ref): Specifying `unspecified' is a no-op.
+
+ * intervals.c (move_if_not_intangible):
+ Force POSITION to be between BEGV and ZV.
+
+2004-08-14 John Paul Wallington <jpw@gnu.org>
+
+ * buffer.c (Frestore_buffer_modified_p): Doc fix.
+
+ * fileio.c (Fread_file_name): Doc fix.
+
+ * minibuf.c (syms_of_minibuf) <completion-ignore-case>: Doc fix.
+
+2004-08-09 Luc Teirlinck <teirllm@auburn.edu>
+
+ * keymap.c (Fmake_keymap, Fmap_keymap, Fwhere_is_internal): Doc fixes.
+
+2004-08-08 Luc Teirlinck <teirllm@auburn.edu>
+
+ * keyboard.c: Declare Qdisabled_command_function instead of
+ Qdisabled_command_hook.
+ (Fcommand_execute): Use Qdisabled_command_function instead of
+ Qdisabled_command_hook.
+ (syms_of_keyboard): Ditto.
+
+2004-08-07 Luc Teirlinck <teirllm@auburn.edu>
+
+ * keymap.c (Flocal_key_binding, Fglobal_key_binding)
+ (syms_of_keymap) <key-translation-map>: Doc fixes.
+
+2004-08-07 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * window.c (window_list_1): YAILOM.
+
+ * fileio.c (make_temp_name): Handle multibyte prefixes.
+
+2004-08-06 Luc Teirlinck <teirllm@auburn.edu>
+
+ * keyboard.c (syms_of_keyboard) <overriding-terminal-local-map>:
+ Doc fix.
+
+2004-08-03 Kenichi Handa <handa@m17n.org>
+
+ * coding.c (decode_coding_string): Adjust coding->consumed, and
+ etc. with shrinked_bytes.
+
+2004-08-03 Kim F. Storm <storm@cua.dk>
+
+ * indent.c (compute_motion): Fix check for full width window
+ in non-window case. Do not count left truncation glyph on
+ window systems.
+
+2004-08-02 Luc Teirlinck <teirllm@auburn.edu>
+
+ * data.c (Finteractive_form): Doc fix.
+
+2004-08-02 Kim F. Storm <storm@cua.dk>
+
+ * indent.c (compute_motion): Use actual window width if WIDTH is -1,
+ properly accounting for continuation glyph on non-window systems.
+ (Fcompute_motion): Use actual window width if WIDTH is nil, and
+ actual window width/height if TOPOS is nil, properly accounting for
+ continuation glyphs on non-window systems, and optional header lines.
+ (vmotion): Let compute_motion calculate actual window width.
+
+ * window.c (window_scroll_line_based): Let compute_motion
+ calculate actual window width.
+
+2004-08-02 Kim F. Storm <storm@cua.dk>
+
+ * process.c (read_process_output): Use whole read buffer.
+ Don't trigger adaptive read buffering on errors.
+
+2004-07-31 Luc Teirlinck <teirllm@auburn.edu>
+
+ * keymap.c (Fset_keymap_parent, Fdefine_prefix_command): Doc fixes.
+
+ * keyboard.c (syms_of_keyboard) <disable-point-adjustment>: Doc fix.
+
+ * callint.c (Fcall_interactively): Doc fix.
+
+2004-07-30 Richard M. Stallman <rms@gnu.org>
+
+ * abbrev.c (Fexpand_abbrev): Undo previous change.
+
+2004-07-30 Kim F. Storm <storm@cua.dk>
+
+ * editfns.c (Fformat): Allocate extra (dummy) element in info.
+
+2004-07-28 Luc Teirlinck <teirllm@auburn.edu>
+
+ * eval.c (Fdefvar, Fdefconst): Doc fixes.
+
+2004-07-27 Kim F. Storm <storm@cua.dk>
+
+ * xdisp.c (move_it_in_display_line_to): Check BUFFER_POS_REACHED_P after
+ we have ensured that the glyph fits on the current line (or returned
+ MOVE_LINE_CONTINUED otherwise).
+
+2004-07-26 Kim F. Storm <storm@cua.dk>
+
+ * xdisp.c (move_it_in_display_line_to): If overflow-newline-into-fringe
+ is enabled, return MOVE_LINE_CONTINUED rather than MOVE_POS_MATCH_OR_ZV
+ if target position is at end of display line but char is not a newline.
+
+2004-07-25 Richard M. Stallman <rms@gnu.org>
+
+ * window.c (coordinates_in_window): Return ON_SCROLL_BAR
+ instead of ON_VERTICAL_BORDER, when on scroll bar.
+ (Fcoordinates_in_window_p): Handle ON_SCROLL_BAR--return nil.
+
+ * dispextern.h (enum window_part): Add ON_SCROLL_BAR.
+
+ * window.c (Fcoordinates_in_window_p):
+ Take account of FRAME_INTERNAL_BORDER_WIDTH.
+
+ * alloc.c (check_cons_list): New function (contents commented out).
+
+2004-07-24 Luc Teirlinck <teirllm@auburn.edu>
+
+ * xfaces.c (Fcolor_supported_p): Doc fix.
+
+ * frame.c (Fselect_frame, Fset_frame_selected_window)
+ (Fframe_visible_p, Fraise_frame): Doc fixes.
+
+2004-07-24 Richard M. Stallman <rms@gnu.org>
+
+ * keyboard.h (not_single_kboard_state): Declared.
+
+ * fileio.c (Fwrite_region): Doc fix.
+
+ * window.c (Fwindow_at): Take account of FRAME_INTERNAL_BORDER_WIDTH.
+
+ * abbrev.c (Fexpand_abbrev): Run Qpre_abbrev_expand_hook
+ only when a real abbrev is present.
+
+ * xfns.c (x_icon_verify): New function.
+ (Fx_create_frame): Use it.
+
2004-07-22 Barry Fishman <barry_fishman@att.net> (tiny change)
* s/gnu-linux.h: Use GC_MARK_STACK if __amd64__ is defined.
diff --git a/src/alloc.c b/src/alloc.c
index 5c2a6fb48c3..ece150f083c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2395,6 +2395,17 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
return val;
}
+/* Get an error now if there's any junk in the cons free list. */
+void
+check_cons_list ()
+{
+ struct Lisp_Cons *tail = cons_free_list;
+
+#if 0
+ while (tail)
+ tail = *(struct Lisp_Cons **)&tail->cdr;
+#endif
+}
/* Make a list of 2, 3, 4 or 5 specified objects. */
diff --git a/src/buffer.c b/src/buffer.c
index f55ae7983f4..bade501b1a7 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1077,7 +1077,7 @@ A non-nil FLAG means mark the buffer modified. */)
DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p,
Srestore_buffer_modified_p, 1, 1, 0,
- doc: /* Like `set-buffer-modified-p', with a differences concerning redisplay.
+ doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay.
It is not ensured that mode lines will be updated to show the modified
state of the current buffer. Use with care. */)
(flag)
diff --git a/src/bytecode.c b/src/bytecode.c
index a13ecc19770..0d3be49877c 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -855,10 +855,7 @@ If the third argument is incorrect, Emacs may crash. */)
}
case Bunwind_protect:
- /* The function record_unwind_protect can GC. */
- BEFORE_POTENTIAL_GC ();
record_unwind_protect (Fprogn, POP);
- AFTER_POTENTIAL_GC ();
break;
case Bcondition_case:
diff --git a/src/callint.c b/src/callint.c
index a3e4984fd16..8b8cb032095 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -256,7 +256,8 @@ Optional second arg RECORD-FLAG non-nil
means unconditionally put this command in the command-history.
Otherwise, this is done only if an arg is read using the minibuffer.
Optional third arg KEYS, if given, specifies the sequence of events to
-supply if the command inquires which events were used to invoke it. */)
+supply if the command inquires which events were used to invoke it.
+If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
(function, record_flag, keys)
Lisp_Object function, record_flag, keys;
{
diff --git a/src/coding.c b/src/coding.c
index c1394d0f135..7f87abce34d 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6238,6 +6238,11 @@ decode_coding_string (str, coding, nocopy)
shrinked_bytes - from);
free_conversion_buffer (&buf);
+ coding->consumed += shrinked_bytes;
+ coding->consumed_char += shrinked_bytes;
+ coding->produced += shrinked_bytes;
+ coding->produced_char += shrinked_bytes;
+
if (coding->cmp_data && coding->cmp_data->used)
coding_restore_composition (coding, newstr);
coding_free_composition_data (coding);
diff --git a/src/data.c b/src/data.c
index 1259c5891a1..616e91c2d62 100644
--- a/src/data.c
+++ b/src/data.c
@@ -776,8 +776,8 @@ SUBR must be a built-in function. */)
DEFUN ("interactive-form", Finteractive_form, Sinteractive_form, 1, 1, 0,
doc: /* Return the interactive form of CMD or nil if none.
-CMD must be a command. Value, if non-nil, is a list
-\(interactive SPEC). */)
+If CMD is not a command, the return value is nil.
+Value, if non-nil, is a list \(interactive SPEC). */)
(cmd)
Lisp_Object cmd;
{
diff --git a/src/dispextern.h b/src/dispextern.h
index 10754a4c01d..0dd9f3ed428 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -99,7 +99,8 @@ enum window_part
ON_LEFT_FRINGE,
ON_RIGHT_FRINGE,
ON_LEFT_MARGIN,
- ON_RIGHT_MARGIN
+ ON_RIGHT_MARGIN,
+ ON_SCROLL_BAR
};
/* Number of bits allocated to store fringe bitmap numbers. */
diff --git a/src/dispnew.c b/src/dispnew.c
index 8a713857273..903bdaabf3b 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6331,52 +6331,13 @@ Emacs was built without floating point support.
if (sec < 0 || (sec == 0 && usec == 0))
return Qnil;
- {
- Lisp_Object zero;
-
- XSETFASTINT (zero, 0);
- wait_reading_process_input (sec, usec, zero, 0);
- }
-
- /* We should always have wait_reading_process_input; we have a dummy
- implementation for systems which don't support subprocesses. */
-#if 0
- /* No wait_reading_process_input */
- immediate_quit = 1;
- QUIT;
-
-#ifdef VMS
- sys_sleep (sec);
-#else /* not VMS */
-/* The reason this is done this way
- (rather than defined (H_S) && defined (H_T))
- is because the VMS preprocessor doesn't grok `defined'. */
-#ifdef HAVE_SELECT
- EMACS_GET_TIME (end_time);
- EMACS_SET_SECS_USECS (timeout, sec, usec);
- EMACS_ADD_TIME (end_time, end_time, timeout);
-
- while (1)
- {
- EMACS_GET_TIME (timeout);
- EMACS_SUB_TIME (timeout, end_time, timeout);
- if (EMACS_TIME_NEG_P (timeout)
- || !select (1, 0, 0, 0, &timeout))
- break;
- }
-#else /* not HAVE_SELECT */
- sleep (sec);
-#endif /* HAVE_SELECT */
-#endif /* not VMS */
-
- immediate_quit = 0;
-#endif /* no subprocesses */
+ wait_reading_process_output (sec, usec, 0, 0, Qnil, NULL, 0);
return Qnil;
}
-/* This is just like wait_reading_process_input, except that
+/* This is just like wait_reading_process_output, except that
it does the redisplay.
It's also much like Fsit_for, except that it can be used for
@@ -6386,8 +6347,6 @@ Lisp_Object
sit_for (sec, usec, reading, display, initial_display)
int sec, usec, reading, display, initial_display;
{
- Lisp_Object read_kbd;
-
swallow_events (display);
if (detect_input_pending_run_timers (display) || !NILP (Vexecuting_macro))
@@ -6403,8 +6362,8 @@ sit_for (sec, usec, reading, display, initial_display)
gobble_input (0);
#endif
- XSETINT (read_kbd, reading ? -1 : 1);
- wait_reading_process_input (sec, usec, read_kbd, display);
+ wait_reading_process_output (sec, usec, reading ? -1 : 1, display,
+ Qnil, NULL, 0);
return detect_input_pending () ? Qnil : Qt;
}
diff --git a/src/editfns.c b/src/editfns.c
index a506c5f4fc8..88a0e63118f 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3254,6 +3254,7 @@ usage: (format STRING &rest OBJECTS) */)
/* Piggyback on this loop to initialize precision[N]. */
precision[n] = -1;
}
+ precision[nargs] = -1;
CHECK_STRING (args[0]);
/* We may have to change "%S" to "%s". */
@@ -3277,11 +3278,11 @@ usage: (format STRING &rest OBJECTS) */)
/* Allocate the info and discarded tables. */
{
- int nbytes = nargs * sizeof *info;
+ int nbytes = (nargs+1) * sizeof *info;
int i;
info = (struct info *) alloca (nbytes);
bzero (info, nbytes);
- for (i = 0; i < nargs; i++)
+ for (i = 0; i <= nargs; i++)
info[i].start = -1;
discarded = (char *) alloca (SBYTES (args[0]));
bzero (discarded, SBYTES (args[0]));
diff --git a/src/eval.c b/src/eval.c
index f28105ac987..ee74215b2ee 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -742,6 +742,13 @@ If DOCSTRING starts with *, this variable is identified as a user option.
This means that M-x set-variable recognizes it.
See also `user-variable-p'.
If INITVALUE is missing, SYMBOL's value is not set.
+
+If SYMBOL has a local binding, then this form affects the local
+binding. This is usually not what you want. Thus, if you need to
+load a file defining variables, with this form or with `defconst' or
+`defcustom', you should always load that file _outside_ any bindings
+for these variables. \(`defconst' and `defcustom' behave similarly in
+this respect.)
usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
(args)
Lisp_Object args;
@@ -784,6 +791,10 @@ Always sets the value of SYMBOL to the result of evalling INITVALUE.
If SYMBOL is buffer-local, its default value is what is set;
buffer-local values are not affected.
DOCSTRING is optional.
+
+If SYMBOL has a local binding, then this form sets the local binding's
+value. However, you should normally not make local bindings for
+variables defined with this form.
usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */)
(args)
Lisp_Object args;
diff --git a/src/fileio.c b/src/fileio.c
index 1615bca3781..a90111b22b6 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -886,7 +886,7 @@ make_temp_name (prefix, base64_p)
int base64_p;
{
Lisp_Object val;
- int len;
+ int len, clen;
int pid;
unsigned char *p, *data;
char pidbuf[20];
@@ -921,8 +921,10 @@ make_temp_name (prefix, base64_p)
#endif
}
- len = SCHARS (prefix);
- val = make_uninit_string (len + 3 + pidlen);
+ len = SBYTES (prefix); clen = SCHARS (prefix);
+ val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen);
+ if (!STRING_MULTIBYTE (prefix))
+ STRING_SET_UNIBYTE (val);
data = SDATA (val);
bcopy(SDATA (prefix), data, len);
p = data + len;
@@ -4866,7 +4868,7 @@ instead of any buffer contents; END is ignored.
Optional fourth argument APPEND if non-nil means
append to existing file contents (if any). If it is an integer,
seek to that offset in the file before writing.
-Optional fifth argument VISIT if t means
+Optional fifth argument VISIT, if t or a string, means
set the last-save-file-modtime of buffer to this file's modtime
and mark buffer not modified.
If VISIT is a string, it is a second file name;
@@ -6191,7 +6193,10 @@ DIR should be an absolute directory name. It defaults to the value of
If this command was invoked with the mouse, use a file dialog box if
`use-dialog-box' is non-nil, and the window system or X toolkit in use
-provides a file dialog box. */)
+provides a file dialog box.
+
+See also `read-file-name-completion-ignore-case'
+and `read-file-name-function'. */)
(prompt, dir, default_filename, mustmatch, initial, predicate)
Lisp_Object prompt, dir, default_filename, mustmatch, initial, predicate;
{
@@ -6299,7 +6304,7 @@ provides a file dialog box. */)
GCPRO2 (insdef, default_filename);
-#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK)
+#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
&& use_dialog_box
&& use_file_dialog
diff --git a/src/frame.c b/src/frame.c
index 691ff8c44d5..78d803abc8d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1,5 +1,5 @@
/* Generic frame functions.
- Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003
+ Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003, 2004
Free Software Foundation.
This file is part of GNU Emacs.
@@ -733,7 +733,12 @@ DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
Subsequent editing commands apply to its selected window.
The selection of FRAME lasts until the next time the user does
something to select a different frame, or until the next time this
-function is called. */)
+function is called. If you are using a window system, the previously
+selected frame may be restored as the selected frame after return to
+the command loop, because it still may have the window system's input
+focus. On a text-only terminal, the next redisplay will display FRAME.
+
+This function returns FRAME, or nil if FRAME has been deleted. */)
(frame, no_enter)
Lisp_Object frame, no_enter;
{
@@ -861,6 +866,7 @@ If omitted, FRAME defaults to the currently selected frame. */)
DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
Sset_frame_selected_window, 2, 2, 0,
doc: /* Set the selected window of frame object FRAME to WINDOW.
+Return WINDOW.
If FRAME is nil, the selected frame is used.
If FRAME is the selected frame, this makes WINDOW the selected window. */)
(frame, window)
@@ -1711,7 +1717,11 @@ DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
doc: /* Return t if FRAME is now \"visible\" (actually in use for display).
A frame that is not \"visible\" is not updated and, if it works through
a window system, it may not show at all.
-Return the symbol `icon' if frame is visible only as an icon. */)
+Return the symbol `icon' if frame is visible only as an icon.
+
+On a text-only terminal, all frames are considered visible, whether
+they are currently being displayed or not, and this function returns t
+for all frames. */)
(frame)
Lisp_Object frame;
{
@@ -1751,7 +1761,7 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
doc: /* Bring FRAME to the front, so it occludes any frames it overlaps.
-If FRAME is invisible, make it visible.
+If FRAME is invisible or iconified, make it visible.
If you don't specify a frame, the selected frame is used.
If Emacs is displaying on an ordinary terminal or some other device which
doesn't support multiple overlapping frames, this function does nothing. */)
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 3ffba0ba745..fabdae74dc6 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -793,7 +793,7 @@ xg_create_frame_widgets (f)
up in the wrong place as tool bar height has not been taken into account.
So we cheat a bit by setting a height that is what it will have
later on when tool bar items are added. */
- if (FRAME_EXTERNAL_TOOL_BAR (f) && FRAME_TOOLBAR_HEIGHT (f) == 0)
+ if (FRAME_EXTERNAL_TOOL_BAR (f) && f->n_tool_bar_items == 0)
FRAME_TOOLBAR_HEIGHT (f) = 34;
diff --git a/src/gtkutil.h b/src/gtkutil.h
index b31ec8c2a1f..b35ab94b2cb 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -96,10 +96,12 @@ typedef struct xg_menu_item_cb_data_
typedef struct _widget_value
{
/* name of widget */
+ Lisp_Object lname;
char *name;
/* value (meaning depend on widget type) */
char *value;
/* keyboard equivalent. no implications for XtTranslations */
+ Lisp_Object lkey;
char *key;
/* Help string or nil if none.
GC finds this string through the frame's menu_bar_vector
diff --git a/src/indent.c b/src/indent.c
index 091c702ac2c..de76464564e 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1131,6 +1131,9 @@ struct position val_compute_motion;
WIDTH is the number of columns available to display text;
compute_motion uses this to handle continuation lines and such.
+ If WIDTH is -1, use width of window's text area adjusted for
+ continuation glyph when needed.
+
HSCROLL is the number of columns not being displayed at the left
margin; this is usually taken from a window's hscroll member.
TAB_OFFSET is the number of columns of the first tab that aren't
@@ -1228,6 +1231,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
int prev_vpos = 0;
int contin_hpos; /* HPOS of last column of continued line. */
int prev_tab_offset; /* Previous tab offset. */
+ int continuation_glyph_width;
XSETBUFFER (buffer, current_buffer);
XSETWINDOW (window, win);
@@ -1245,6 +1249,23 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
if (tab_width <= 0 || tab_width > 1000)
tab_width = 8;
+ /* Negative width means use all available text columns. */
+ if (width < 0)
+ {
+ width = window_box_text_cols (win);
+ /* We must make room for continuation marks if we don't have fringes. */
+#ifdef HAVE_WINDOW_SYSTEM
+ if (!FRAME_WINDOW_P (XFRAME (win->frame)))
+#endif
+ width -= 1;
+ }
+
+ continuation_glyph_width = 1;
+#ifdef HAVE_WINDOW_SYSTEM
+ if (FRAME_WINDOW_P (XFRAME (win->frame)))
+ continuation_glyph_width = 0; /* In the fringe. */
+#endif
+
immediate_quit = 1;
QUIT;
@@ -1368,7 +1389,8 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
{
if (hscroll
|| (truncate_partial_width_windows
- && width + 1 < FRAME_COLS (XFRAME (WINDOW_FRAME (win))))
+ && ((width + continuation_glyph_width)
+ < FRAME_COLS (XFRAME (WINDOW_FRAME (win)))))
|| !NILP (current_buffer->truncate_lines))
{
/* Truncating: skip to newline, unless we are already past
@@ -1652,7 +1674,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
hpos -= hscroll;
/* Count the truncation glyph on column 0 */
if (hscroll > 0)
- hpos++;
+ hpos += continuation_glyph_width;
tab_offset = 0;
}
contin_hpos = 0;
@@ -1737,12 +1759,14 @@ assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--
to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--
and return the ending buffer position and screen location.
+If TOPOS is nil, the actual width and height of the window's
+text area are used.
+
There are three additional arguments:
WIDTH is the number of columns available to display text;
-this affects handling of continuation lines.
-This is usually the value returned by `window-width', less one (to allow
-for the continuation glyph).
+this affects handling of continuation lines. A value of nil
+corresponds to the actual number of available text columns.
OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).
HSCROLL is the number of columns not being displayed at the left
@@ -1774,6 +1798,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */)
Lisp_Object from, frompos, to, topos;
Lisp_Object width, offsets, window;
{
+ struct window *w;
Lisp_Object bufpos, hpos, vpos, prevhpos;
struct position *pos;
int hscroll, tab_offset;
@@ -1783,10 +1808,15 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */)
CHECK_NUMBER_CAR (frompos);
CHECK_NUMBER_CDR (frompos);
CHECK_NUMBER_COERCE_MARKER (to);
- CHECK_CONS (topos);
- CHECK_NUMBER_CAR (topos);
- CHECK_NUMBER_CDR (topos);
- CHECK_NUMBER (width);
+ if (!NILP (topos))
+ {
+ CHECK_CONS (topos);
+ CHECK_NUMBER_CAR (topos);
+ CHECK_NUMBER_CDR (topos);
+ }
+ if (!NILP (width))
+ CHECK_NUMBER (width);
+
if (!NILP (offsets))
{
CHECK_CONS (offsets);
@@ -1802,6 +1832,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */)
window = Fselected_window ();
else
CHECK_LIVE_WINDOW (window);
+ w = XWINDOW (window);
if (XINT (from) < BEGV || XINT (from) > ZV)
args_out_of_range_3 (from, make_number (BEGV), make_number (ZV));
@@ -1810,9 +1841,20 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */)
pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
XINT (XCAR (frompos)), 0,
- XINT (to), XINT (XCDR (topos)),
- XINT (XCAR (topos)),
- XINT (width), hscroll, tab_offset,
+ XINT (to),
+ (NILP (topos)
+ ? window_internal_height (w)
+ : XINT (XCDR (topos))),
+ (NILP (topos)
+ ? (window_box_text_cols (w)
+ - (
+#ifdef HAVE_WINDOW_SYSTEM
+ FRAME_WINDOW_P (XFRAME (w->frame)) ? 0 :
+#endif
+ 1))
+ : XINT (XCAR (topos))),
+ (NILP (width) ? -1 : XINT (width)),
+ hscroll, tab_offset,
XWINDOW (window));
XSETFASTINT (bufpos, pos->bufpos);
@@ -1837,7 +1879,6 @@ vmotion (from, vtarget, w)
register int from, vtarget;
struct window *w;
{
- int width = window_box_text_cols (w);
int hscroll = XINT (w->hscroll);
struct position pos;
/* vpos is cumulative vertical position, changed as from is changed */
@@ -1858,12 +1899,6 @@ vmotion (from, vtarget, w)
XSETWINDOW (window, w);
- /* We must make room for continuation marks if we don't have fringes. */
-#ifdef HAVE_WINDOW_SYSTEM
- if (!FRAME_WINDOW_P (XFRAME (w->frame)))
-#endif
- width -= 1;
-
/* If the window contains this buffer, use it for getting text properties.
Otherwise use the current buffer as arg for doing that. */
if (EQ (w->buffer, Fcurrent_buffer ()))
@@ -1905,7 +1940,7 @@ vmotion (from, vtarget, w)
1 << (BITS_PER_SHORT - 1),
/* ... nor HPOS. */
1 << (BITS_PER_SHORT - 1),
- width, hscroll,
+ -1, hscroll,
/* This compensates for start_hpos
so that a tab as first character
still occupies 8 columns. */
@@ -1964,7 +1999,7 @@ vmotion (from, vtarget, w)
1 << (BITS_PER_SHORT - 1),
/* ... nor HPOS. */
1 << (BITS_PER_SHORT - 1),
- width, hscroll,
+ -1, hscroll,
(XFASTINT (prevline) == BEG ? -start_hpos : 0),
w);
did_motion = 1;
@@ -1978,7 +2013,7 @@ vmotion (from, vtarget, w)
}
return compute_motion (from, vpos, pos.hpos, did_motion,
ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)),
- width, hscroll,
+ -1, hscroll,
pos.tab_offset - (from == BEG ? start_hpos : 0),
w);
}
diff --git a/src/intervals.c b/src/intervals.c
index 33ef9a34177..a822dafefcf 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -2275,6 +2275,10 @@ move_if_not_intangible (position)
pos = Fnext_char_property_change (pos, Qnil);
}
+ else if (position < BEGV)
+ position = BEGV;
+ else if (position > ZV)
+ position = ZV;
/* If the whole stretch between PT and POSITION isn't intangible,
try moving to POSITION (which means we actually move farther
diff --git a/src/keyboard.c b/src/keyboard.c
index eb2ed608856..78e7498287e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -131,8 +131,8 @@ KBOARD the_only_kboard;
#endif
/* Non-nil disable property on a command means
- do not execute it; call disabled-command-hook's value instead. */
-Lisp_Object Qdisabled, Qdisabled_command_hook;
+ do not execute it; call disabled-command-function's value instead. */
+Lisp_Object Qdisabled, Qdisabled_command_function;
#define NUM_RECENT_KEYS (100)
int recent_keys_index; /* Index for storing next element into recent_keys */
@@ -3899,10 +3899,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
break;
#endif
{
- Lisp_Object minus_one;
-
- XSETINT (minus_one, -1);
- wait_reading_process_input (0, 0, minus_one, 1);
+ wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0);
if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr)
/* Pass 1 for EXPECT since we just waited to have input. */
@@ -9665,9 +9662,9 @@ a special event, so ignore the prefix argument and don't clear it. */)
tem = Fget (cmd, Qdisabled);
if (!NILP (tem) && !NILP (Vrun_hooks))
{
- tem = Fsymbol_value (Qdisabled_command_hook);
+ tem = Fsymbol_value (Qdisabled_command_function);
if (!NILP (tem))
- return call1 (Vrun_hooks, Qdisabled_command_hook);
+ return call1 (Vrun_hooks, Qdisabled_command_function);
}
}
@@ -9920,7 +9917,7 @@ clear_input_pending ()
}
/* Return nonzero if there are pending requeued events.
- This isn't used yet. The hope is to make wait_reading_process_input
+ This isn't used yet. The hope is to make wait_reading_process_output
call it, and return if it runs Lisp code that unreads something.
The problem is, kbd_buffer_get_event needs to be fixed to know what
to do in that case. It isn't trivial. */
@@ -10782,8 +10779,8 @@ syms_of_keyboard ()
Qtimer_event_handler = intern ("timer-event-handler");
staticpro (&Qtimer_event_handler);
- Qdisabled_command_hook = intern ("disabled-command-hook");
- staticpro (&Qdisabled_command_hook);
+ Qdisabled_command_function = intern ("disabled-command-function");
+ staticpro (&Qdisabled_command_function);
Qself_insert_command = intern ("self-insert-command");
staticpro (&Qself_insert_command);
@@ -11280,6 +11277,7 @@ The elements of the list are event types that may have menu bar bindings. */);
doc: /* Per-terminal keymap that overrides all other local keymaps.
If this variable is non-nil, it is used as a keymap instead of the
buffer's local map, and the minor mode keymaps and text property keymaps.
+It also overrides `overriding-local-map'.
This variable is intended to let commands such as `universal-argument'
set up a different keymap for reading the next command. */);
@@ -11371,8 +11369,8 @@ It's called with one argument, the help string to display. */);
After a command is executed, if point is moved into a region that has
special properties (e.g. composition, display), we adjust point to
-the boundary of the region. But, several special commands sets this
-variable to non-nil, then we suppress the point adjustment.
+the boundary of the region. But, when a command sets this variable to
+non-nil, we suppress the point adjustment.
This variable is set to nil before reading a command, and is checked
just after executing the command. */);
diff --git a/src/keyboard.h b/src/keyboard.h
index d92f13a5059..4e14257359f 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -307,6 +307,7 @@ extern void echo_now P_ ((void));
extern void init_kboard P_ ((KBOARD *));
extern void delete_kboard P_ ((KBOARD *));
extern void single_kboard_state P_ ((void));
+extern void not_single_kboard_state P_ ((KBOARD *));
extern void push_frame_kboard P_ ((struct frame *));
extern void pop_frame_kboard P_ ((void));
extern void record_asynch_buffer_change P_ ((void));
diff --git a/src/keymap.c b/src/keymap.c
index 48108fbfa12..92cb6902a1e 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -130,10 +130,11 @@ static void silly_event_symbol_error P_ ((Lisp_Object));
DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0,
doc: /* Construct and return a new keymap, of the form (keymap CHARTABLE . ALIST).
-CHARTABLE is a char-table that holds the bindings for the ASCII
-characters. ALIST is an assoc-list which holds bindings for function keys,
-mouse events, and any other things that appear in the input stream.
-All entries in it are initially nil, meaning "command undefined".
+CHARTABLE is a char-table that holds the bindings for all characters
+without modifiers. All entries in it are initially nil, meaning
+"command undefined". ALIST is an assoc-list which holds bindings for
+function keys, mouse events, and any other things that appear in the
+input stream. Initially, ALIST is nil.
The optional arg STRING supplies a menu name for the keymap
in case you use it as a menu with `x-popup-menu'. */)
@@ -342,7 +343,7 @@ keymap_memberp (map, maps)
DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0,
doc: /* Modify KEYMAP to set its parent map to PARENT.
-PARENT should be nil or another keymap. */)
+Return PARENT. PARENT should be nil or another keymap. */)
(keymap, parent)
Lisp_Object keymap, parent;
{
@@ -728,7 +729,10 @@ map_keymap_call (key, val, fun, dummy)
DEFUN ("map-keymap", Fmap_keymap, Smap_keymap, 2, 2, 0,
doc: /* Call FUNCTION for every binding in KEYMAP.
-FUNCTION is called with two arguments: the event and its binding. */)
+FUNCTION is called with two arguments: the event and its binding.
+If KEYMAP has a parent, the parent's bindings are included as well.
+This works recursively: if the parent has itself a parent, then the
+grandparent's bindings are also included and so on. */)
(function, keymap)
Lisp_Object function, keymap;
{
@@ -1602,7 +1606,7 @@ is non-nil, `key-binding' returns the unmapped command. */)
DEFUN ("local-key-binding", Flocal_key_binding, Slocal_key_binding, 1, 2, 0,
doc: /* Return the binding for command KEYS in current local keymap only.
-KEYS is a string, a sequence of keystrokes.
+KEYS is a string or vector, a sequence of keystrokes.
The binding is probably a symbol with a function definition.
If optional argument ACCEPT-DEFAULT is non-nil, recognize default
@@ -1621,7 +1625,7 @@ bindings; see the description of `lookup-key' for more details about this. */)
DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 2, 0,
doc: /* Return the binding for command KEYS in current global keymap only.
-KEYS is a string, a sequence of keystrokes.
+KEYS is a string or vector, a sequence of keystrokes.
The binding is probably a symbol with a function definition.
This function's return values are the same as those of `lookup-key'
\(which see).
@@ -1686,7 +1690,8 @@ If a second optional argument MAPVAR is given, the map is stored as
its value instead of as COMMAND's value; but COMMAND is still defined
as a function.
The third optional argument NAME, if given, supplies a menu name
-string for the map. This is required to use the keymap as a menu. */)
+string for the map. This is required to use the keymap as a menu.
+This function returns COMMAND. */)
(command, mapvar, name)
Lisp_Object command, mapvar, name;
{
@@ -2571,7 +2576,7 @@ where_is_internal (definition, keymaps, firstonly, noindirect, no_remap)
DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0,
doc: /* Return list of keys that invoke DEFINITION.
-If KEYMAP is non-nil, search only KEYMAP and the global keymap.
+If KEYMAP is a keymap, search only KEYMAP and the global keymap.
If KEYMAP is nil, search all the currently active keymaps.
If KEYMAP is a list of keymaps, search only those keymaps.
@@ -2579,8 +2584,8 @@ If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found,
rather than a list of all possible key sequences.
If FIRSTONLY is the symbol `non-ascii', return the first binding found,
no matter what it is.
-If FIRSTONLY has another non-nil value, prefer sequences of ASCII characters,
-and entirely reject menu bindings.
+If FIRSTONLY has another non-nil value, prefer sequences of ASCII characters
+\(or their meta variants) and entirely reject menu bindings.
If optional 4th arg NOINDIRECT is non-nil, don't follow indirections
to other keymaps or slots. This makes it possible to search for an
@@ -3750,7 +3755,7 @@ key, typing `ESC O P x' would return [f1 x]. */);
DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
doc: /* Keymap of key translations that can override keymaps.
This keymap works like `function-key-map', but comes after that,
-and applies even for keys that have ordinary bindings. */);
+and its non-prefix bindings override ordinary bindings. */);
Vkey_translation_map = Qnil;
staticpro (&Vmouse_events);
diff --git a/src/lisp.h b/src/lisp.h
index a0345653924..7e1e122fbc2 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2964,7 +2964,10 @@ EXFUN (Fprocess_send_eof, 1);
EXFUN (Fwaiting_for_user_input_p, 0);
extern Lisp_Object Qprocessp;
extern void kill_buffer_processes P_ ((Lisp_Object));
-extern int wait_reading_process_input P_ ((int, int, Lisp_Object, int));
+extern int wait_reading_process_output P_ ((int, int, int, int,
+ Lisp_Object,
+ struct Lisp_Process *,
+ int));
extern void deactivate_process P_ ((Lisp_Object));
extern void add_keyboard_wait_descriptor P_ ((int));
extern void delete_keyboard_wait_descriptor P_ ((int));
diff --git a/src/macfns.c b/src/macfns.c
index ec014e772e3..3b09b344a55 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -324,19 +324,21 @@ x_real_positions (f, xptr, yptr)
Point pt;
GrafPtr oldport;
-#ifdef TARGET_API_MAC_CARBON
+ GetPort (&oldport);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
+
+#if TARGET_API_MAC_CARBON
{
Rect r;
- GetWindowPortBounds (f->output_data.mac->mWP, &r);
+ GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
SetPt (&pt, r.left, r.top);
}
#else /* not TARGET_API_MAC_CARBON */
SetPt (&pt,
- f->output_data.mac->mWP->portRect.left,
- f->output_data.mac->mWP->portRect.top);
+ FRAME_MAC_WINDOW (f)->portRect.left,
+ FRAME_MAC_WINDOW (f)->portRect.top);
#endif /* not TARGET_API_MAC_CARBON */
- GetPort (&oldport);
LocalToGlobal (&pt);
SetPort (oldport);
@@ -1934,8 +1936,8 @@ x_set_name (f, name, explicit)
if (FRAME_MAC_WINDOW (f))
{
if (STRING_MULTIBYTE (name))
-#if 0 /* MAC_TODO: encoding title string */
- name = ENCODE_SYSTEM (name);
+#if TARGET_API_MAC_CARBON
+ name = ENCODE_UTF_8 (name);
#else
return;
#endif
@@ -1943,6 +1945,14 @@ x_set_name (f, name, explicit)
BLOCK_INPUT;
{
+#if TARGET_API_MAC_CARBON
+ CFStringRef windowTitle =
+ CFStringCreateWithCString (NULL, SDATA (name),
+ kCFStringEncodingUTF8);
+
+ SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+ CFRelease (windowTitle);
+#else
Str255 windowTitle;
if (strlen (SDATA (name)) < 255)
{
@@ -1950,6 +1960,7 @@ x_set_name (f, name, explicit)
c2pstr (windowTitle);
SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
}
+#endif
}
UNBLOCK_INPUT;
@@ -2008,8 +2019,8 @@ x_set_title (f, name, old_name)
if (FRAME_MAC_WINDOW (f))
{
if (STRING_MULTIBYTE (name))
-#if 0 /* MAC_TODO: encoding title string */
- name = ENCODE_SYSTEM (name);
+#if TARGET_API_MAC_CARBON
+ name = ENCODE_UTF_8 (name);
#else
return;
#endif
@@ -2017,6 +2028,14 @@ x_set_title (f, name, old_name)
BLOCK_INPUT;
{
+#if TARGET_API_MAC_CARBON
+ CFStringRef windowTitle =
+ CFStringCreateWithCString (NULL, SDATA (name),
+ kCFStringEncodingUTF8);
+
+ SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+ CFRelease (windowTitle);
+#else
Str255 windowTitle;
if (strlen (SDATA (name)) < 255)
{
@@ -2024,6 +2043,7 @@ x_set_title (f, name, old_name)
c2pstr (windowTitle);
SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
}
+#endif
}
UNBLOCK_INPUT;
@@ -2981,17 +3001,20 @@ If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
- int mac_major_version, mac_minor_version;
+ int mac_major_version;
SInt32 response;
if (Gestalt (gestaltSystemVersion, &response) != noErr)
error ("Cannot get Mac OS version");
- mac_major_version = (response >> 8) & 0xf;
- mac_minor_version = (response >> 4) & 0xf;
+ mac_major_version = (response >> 8) & 0xff;
+ /* convert BCD to int */
+ mac_major_version -= (mac_major_version >> 4) * 6;
return Fcons (make_number (mac_major_version),
- Fcons (make_number (mac_minor_version), Qnil));
+ Fcons (make_number ((response >> 4) & 0xf),
+ Fcons (make_number (response & 0xf),
+ Qnil)));
}
DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
@@ -4192,19 +4215,27 @@ Value is t if tooltip was open, nil otherwise. */)
+#ifdef TARGET_API_MAC_CARBON
/***********************************************************************
File selection dialog
***********************************************************************/
-#if 0 /* MAC_TODO: can standard file dialog */
+/**
+ There is a relatively standard way to do this using applescript to run
+ a (choose file) method. However, this doesn't do "the right thing"
+ by working only if the find-file occurred during a menu or toolbar
+ click. So we must do the file dialog by hand, using the navigation
+ manager. This also has more flexibility in determining the default
+ directory and whether or not we are going to choose a file.
+ **/
+
extern Lisp_Object Qfile_name_history;
DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
doc: /* Read file name, prompting with PROMPT in directory DIR.
Use a file selection dialog.
Select DEFAULT-FILENAME in the dialog's file selection box, if
-specified. Don't let the user enter a file name in the file
-selection dialog's entry field, if MUSTMATCH is non-nil. */)
+specified. Ensure that file exists if MUSTMATCH is non-nil. */)
(prompt, dir, default_filename, mustmatch)
Lisp_Object prompt, dir, default_filename, mustmatch;
{
@@ -4212,9 +4243,8 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */)
Lisp_Object file = Qnil;
int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
- char filename[MAX_PATH + 1];
- char init_dir[MAX_PATH + 1];
- int use_dialog_p = 1;
+ char filename[1001];
+ int default_filter_index = 1; /* 1: All Files, 2: Directories only */
GCPRO5 (prompt, dir, default_filename, mustmatch, file);
CHECK_STRING (prompt);
@@ -4223,87 +4253,150 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */)
/* Create the dialog with PROMPT as title, using DIR as initial
directory and using "*" as pattern. */
dir = Fexpand_file_name (dir, Qnil);
- strncpy (init_dir, SDATA (dir), MAX_PATH);
- init_dir[MAX_PATH] = '\0';
- unixtodos_filename (init_dir);
- if (STRINGP (default_filename))
- {
- char *file_name_only;
- char *full_path_name = SDATA (default_filename);
-
- unixtodos_filename (full_path_name);
-
- file_name_only = strrchr (full_path_name, '\\');
- if (!file_name_only)
- file_name_only = full_path_name;
- else
- {
- file_name_only++;
-
- /* If default_file_name is a directory, don't use the open
- file dialog, as it does not support selecting
- directories. */
- if (!(*file_name_only))
- use_dialog_p = 0;
- }
-
- strncpy (filename, file_name_only, MAX_PATH);
- filename[MAX_PATH] = '\0';
- }
- else
- filename[0] = '\0';
-
- if (use_dialog_p)
- {
- OPENFILENAME file_details;
- char *filename_file;
+ {
+ OSStatus status;
+ NavDialogCreationOptions options;
+ NavDialogRef dialogRef;
+ NavTypeListHandle fileTypes = NULL;
+ NavUserAction userAction;
+ CFStringRef message=NULL, client=NULL, saveName = NULL;
+
+ /* No need for a callback function because we are modal */
+ NavGetDefaultDialogCreationOptions(&options);
+ options.modality = kWindowModalityAppModal;
+ options.location.h = options.location.v = -1;
+ options.optionFlags = kNavDefaultNavDlogOptions;
+ options.optionFlags |= kNavAllFilesInPopup; /* All files allowed */
+ options.optionFlags |= kNavSelectAllReadableItem;
+ if (!NILP(prompt))
+ {
+ message = CFStringCreateWithCStringNoCopy(NULL, SDATA(prompt),
+ kCFStringEncodingUTF8,
+ kCFAllocatorNull);
+ options.message = message;
+ }
+ /* Don't set the application, let it use default.
+ client = CFStringCreateWithCStringNoCopy(NULL, "Emacs",
+ kCFStringEncodingMacRoman, NULL);
+ options.clientName = client;
+ */
+
+ /* Do Dired hack copied from w32fns.c */
+ if (!NILP(prompt) && strncmp (SDATA(prompt), "Dired", 5) == 0)
+ status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL,
+ &dialogRef);
+ else if (NILP (mustmatch))
+ {
+ /* This is a save dialog */
+ if (!NILP(default_filename))
+ {
+ saveName = CFStringCreateWithCString(NULL, SDATA(default_filename),
+ kCFStringEncodingUTF8);
+ options.saveFileName = saveName;
+ options.optionFlags |= kNavSelectDefaultLocation;
+ }
+ /* MAC_TODO: Find a better way to determine if this is a save
+ or load dialog than comparing dir with default_filename */
+ if (EQ(dir, default_filename))
+ {
+ status = NavCreateChooseFileDialog(&options, fileTypes,
+ NULL, NULL, NULL, NULL,
+ &dialogRef);
+ }
+ else {
+ status = NavCreatePutFileDialog(&options,
+ 'TEXT', kNavGenericSignature,
+ NULL, NULL, &dialogRef);
+ }
+ }
+ else
+ {
+ /* This is an open dialog*/
+ status = NavCreateChooseFileDialog(&options, fileTypes,
+ NULL, NULL, NULL, NULL,
+ &dialogRef);
+ }
+
+ /* Set the default location and continue*/
+ if (status == noErr) {
+ if (!NILP(dir)) {
+ FSRef defLoc;
+ AEDesc defLocAed;
+ status = FSPathMakeRef(SDATA(dir), &defLoc, NULL);
+ if (status == noErr)
+ {
+ AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed);
+ NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
+ }
+ AEDisposeDesc(&defLocAed);
+ }
- /* Prevent redisplay. */
- specbind (Qinhibit_redisplay, Qt);
BLOCK_INPUT;
+ status = NavDialogRun(dialogRef);
+ UNBLOCK_INPUT;
+ }
- bzero (&file_details, sizeof (file_details));
- file_details.lStructSize = sizeof (file_details);
- file_details.hwndOwner = FRAME_W32_WINDOW (f);
- file_details.lpstrFile = filename;
- file_details.nMaxFile = sizeof (filename);
- file_details.lpstrInitialDir = init_dir;
- file_details.lpstrTitle = SDATA (prompt);
- file_details.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
-
- if (!NILP (mustmatch))
- file_details.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
-
- if (GetOpenFileName (&file_details))
- {
- dostounix_filename (filename);
- file = build_string (filename);
- }
- else
- file = Qnil;
+ if (saveName) CFRelease(saveName);
+ if (client) CFRelease(client);
+ if (message) CFRelease(message);
- UNBLOCK_INPUT;
- file = unbind_to (count, file);
+ if (status == noErr) {
+ userAction = NavDialogGetUserAction(dialogRef);
+ switch (userAction)
+ {
+ case kNavUserActionNone:
+ case kNavUserActionCancel:
+ NavDialogDispose(dialogRef);
+ Fsignal (Qquit, Qnil); /* Treat cancel like C-g */
+ return;
+ case kNavUserActionOpen:
+ case kNavUserActionChoose:
+ case kNavUserActionSaveAs:
+ {
+ NavReplyRecord reply;
+ AEDesc aed;
+ FSRef fsRef;
+ status = NavDialogGetReply(dialogRef, &reply);
+ AECoerceDesc(&reply.selection, typeFSRef, &aed);
+ AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef));
+ FSRefMakePath(&fsRef, (UInt8 *) filename, 1000);
+ AEDisposeDesc(&aed);
+ if (reply.saveFileName)
+ {
+ /* If it was a saved file, we need to add the file name */
+ int len = strlen(filename);
+ if (len && filename[len-1] != '/')
+ filename[len++] = '/';
+ CFStringGetCString(reply.saveFileName, filename+len,
+ 1000-len, kCFStringEncodingUTF8);
+ }
+ file = DECODE_FILE(build_string (filename));
+ NavDisposeReply(&reply);
+ }
+ break;
+ }
+ NavDialogDispose(dialogRef);
}
- /* Open File dialog will not allow folders to be selected, so resort
- to minibuffer completing reads for directories. */
- else
- file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
- dir, mustmatch, dir, Qfile_name_history,
- default_filename, Qnil);
+ else {
+ /* Fall back on minibuffer if there was a problem */
+ file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
+ dir, mustmatch, dir, Qfile_name_history,
+ default_filename, Qnil);
+ }
+ }
UNGCPRO;
-
+
/* Make "Cancel" equivalent to C-g. */
if (NILP (file))
Fsignal (Qquit, Qnil);
-
+
return unbind_to (count, file);
}
-#endif /* MAC_TODO */
+#endif
/***********************************************************************
Initialization
@@ -4507,7 +4600,7 @@ Chinese, Japanese, and Korean. */);
last_show_tip_args = Qnil;
staticpro (&last_show_tip_args);
-#if 0 /* MAC_TODO */
+#if TARGET_API_MAC_CARBON
defsubr (&Sx_file_dialog);
#endif
}
diff --git a/src/macmenu.c b/src/macmenu.c
index d205ee3b877..740bda261d8 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -90,10 +90,12 @@ enum button_type
typedef struct _widget_value
{
/* name of widget */
+ Lisp_Object lname;
char* name;
/* value (meaning depend on widget type) */
char* value;
/* keyboard equivalent. no implications for XtTranslations */
+ Lisp_Object lkey;
char* key;
/* Help string or nil if none.
GC finds this string through the frame's menu_bar_vector
@@ -163,6 +165,12 @@ extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
extern Lisp_Object Qmenu_bar_update_hook;
+#if TARGET_API_MAC_CARBON
+#define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
+#else
+#define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
+#endif
+
void set_frame_menubar ();
static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
@@ -1215,12 +1223,9 @@ single_submenu (item_key, item_name, maps)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
- /* Ignore the @ that means "separate pane".
- This is a kludge, but this isn't worth more time. */
- if (!NILP (prefix) && wv->name[0] == '@')
- wv->name++;
- wv->value = 0;
+ wv->lname = pane_name;
+ /* Set value to 1 so update_submenu_strings can handle '@' */
+ wv->value = (char *)1;
wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
wv->help = Qnil;
@@ -1246,13 +1251,13 @@ single_submenu (item_key, item_name, maps)
#ifndef HAVE_MULTILINGUAL_MENU
if (STRING_MULTIBYTE (item_name))
{
- item_name = ENCODE_SYSTEM (item_name);
+ item_name = ENCODE_MENU_STRING (item_name);
AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
}
if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
{
- descrip = ENCODE_SYSTEM (descrip);
+ descrip = ENCODE_MENU_STRING (descrip);
AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
}
#endif /* not HAVE_MULTILINGUAL_MENU */
@@ -1263,9 +1268,9 @@ single_submenu (item_key, item_name, maps)
else
save_wv->contents = wv;
- wv->name = (char *) SDATA (item_name);
+ wv->lname = item_name;
if (!NILP (descrip))
- wv->key = (char *) SDATA (descrip);
+ wv->lkey = descrip;
wv->value = 0;
/* The EMACS_INT cast avoids a warning. There's no problem
as long as pointers have enough bits to hold small integers. */
@@ -1304,6 +1309,41 @@ single_submenu (item_key, item_name, maps)
return first_wv;
}
+/* Walk through the widget_value tree starting at FIRST_WV and update
+ the char * pointers from the corresponding lisp values.
+ We do this after building the whole tree, since GC may happen while the
+ tree is constructed, and small strings are relocated. So we must wait
+ until no GC can happen before storing pointers into lisp values. */
+static void
+update_submenu_strings (first_wv)
+ widget_value *first_wv;
+{
+ widget_value *wv;
+
+ for (wv = first_wv; wv; wv = wv->next)
+ {
+ if (wv->lname && ! NILP (wv->lname))
+ {
+ wv->name = SDATA (wv->lname);
+
+ /* Ignore the @ that means "separate pane".
+ This is a kludge, but this isn't worth more time. */
+ if (wv->value == (char *)1)
+ {
+ if (wv->name[0] == '@')
+ wv->name++;
+ wv->value = 0;
+ }
+ }
+
+ if (wv->lkey && ! NILP (wv->lkey))
+ wv->key = SDATA (wv->lkey);
+
+ if (wv->contents)
+ update_submenu_strings (wv->contents);
+ }
+}
+
/* Set the contents of the menubar widgets of frame F.
The argument FIRST_TIME is currently ignored;
@@ -1382,8 +1422,6 @@ set_frame_menubar (f, first_time, deep_p)
items = FRAME_MENU_BAR_ITEMS (f);
- inhibit_garbage_collection ();
-
/* Save the frame's previous menu bar contents data. */
if (previous_menu_items_used)
bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
@@ -1448,6 +1486,7 @@ set_frame_menubar (f, first_time, deep_p)
if (NILP (string))
break;
wv->name = (char *) SDATA (string);
+ update_submenu_strings (wv->contents);
wv = wv->next;
}
@@ -1705,12 +1744,12 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
#ifndef HAVE_MULTILINGUAL_MENU
if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
{
- item_name = ENCODE_SYSTEM (item_name);
+ item_name = ENCODE_MENU_STRING (item_name);
AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
}
if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
{
- descrip = ENCODE_SYSTEM (descrip);
+ descrip = ENCODE_MENU_STRING (descrip);
AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
}
#endif /* not HAVE_MULTILINGUAL_MENU */
@@ -1764,7 +1803,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
#ifndef HAVE_MULTILINGUAL_MENU
if (STRING_MULTIBYTE (title))
- title = ENCODE_SYSTEM (title);
+ title = ENCODE_MENU_STRING (title);
#endif
wv_title->name = (char *) SDATA (title);
wv_title->enabled = TRUE;
@@ -1801,9 +1840,9 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
/* Get the refcon to find the correct item*/
if (menu_item_selection)
{
- menu = GetMenuHandle (HiWord (menu_item_choice));
- if (menu) {
- GetMenuItemRefCon (menu, menu_item_selection, &refcon);
+ MenuHandle sel_menu = GetMenuHandle (HiWord (menu_item_choice));
+ if (sel_menu) {
+ GetMenuItemRefCon (sel_menu, menu_item_selection, &refcon);
}
}
@@ -1813,6 +1852,10 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
discard_mouse_events ();
#endif
+ /* Must reset this manually because the button release event is not
+ passed to Emacs event loop. */
+ FRAME_MAC_DISPLAY_INFO (f)->grabbed = 0;
+
/* Free the widget_value objects we used to specify the
contents. */
free_menubar_widget_value_tree (first_wv);
@@ -1821,11 +1864,11 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
{
int i = MIN_POPUP_SUBMENU_ID;
MenuHandle submenu = GetMenuHandle (i);
- while (menu != NULL)
+ while (submenu != NULL)
{
DeleteMenu (i);
- DisposeMenu (menu);
- menu = GetMenuHandle (++i);
+ DisposeMenu (submenu);
+ submenu = GetMenuHandle (++i);
}
}
@@ -2197,7 +2240,7 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
int force_disable)
{
Str255 item_name;
- int pos, i;
+ int pos;
if (name_is_separator (wv->name))
AppendMenu (menu, "\p-");
@@ -2219,8 +2262,18 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
strncat (item_name, wv->key, 255);
}
item_name[255] = 0;
+#if TARGET_API_MAC_CARBON
+ {
+ CFStringRef string =
+ CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8);
+
+ SetMenuItemTextWithCFString (menu, pos, string);
+ CFRelease (string);
+ }
+#else
c2pstr (item_name);
SetMenuItemText (menu, pos, item_name);
+#endif
if (wv->enabled && !force_disable)
#if TARGET_API_MAC_CARBON
@@ -2243,9 +2296,9 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
else
SetItemMark (menu, pos, noMark);
}
- }
- SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
+ SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
+ }
if (submenu != NULL)
SetMenuItemHierarchicalID (menu, pos, submenu);
diff --git a/src/macterm.c b/src/macterm.c
index 9e482a17c8e..0177d57fec8 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1325,6 +1325,10 @@ static void
x_update_end (f)
struct frame *f;
{
+ /* Mouse highlight may be displayed again. */
+ FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
+
+ BLOCK_INPUT;
/* Reset the background color of Mac OS Window to that of the frame after
update so that it is used by Mac Toolbox to clear the update region before
an update event is generated. */
@@ -1332,10 +1336,6 @@ x_update_end (f)
mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
- /* Mouse highlight may be displayed again. */
- FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
-
- BLOCK_INPUT;
XFlush (FRAME_MAC_DISPLAY (f));
UNBLOCK_INPUT;
}
@@ -5123,7 +5123,7 @@ x_set_offset (f, xoff, yoff, change_gravity)
modified_left = f->left_pos;
modified_top = f->top_pos;
- MoveWindow (f->output_data.mac->mWP, modified_left + 6,
+ MoveWindow (FRAME_MAC_WINDOW (f), modified_left + 6,
modified_top + 42, false);
UNBLOCK_INPUT;
diff --git a/src/minibuf.c b/src/minibuf.c
index dd7bb42263b..d50e7404ab3 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2673,7 +2673,10 @@ property of a history variable overrides this default. */);
Vcompletion_auto_help = Qt;
DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case,
- doc: /* Non-nil means don't consider case significant in completion. */);
+ doc: /* Non-nil means don't consider case significant in completion.
+
+See also `read-file-name-completion-ignore-case' concerning case significance
+in completion when reading a file name. */);
completion_ignore_case = 0;
DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers,
diff --git a/src/msdos.c b/src/msdos.c
index 2653f0bf213..f2d1dc66a69 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -5102,7 +5102,7 @@ dos_yield_time_slice (void)
/* Only event queue is checked. */
/* We don't have to call timer_check here
- because wait_reading_process_input takes care of that. */
+ because wait_reading_process_output takes care of that. */
int
sys_select (nfds, rfds, wfds, efds, timeout)
int nfds;
diff --git a/src/process.c b/src/process.c
index aad36b904b5..d20290813e1 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3718,7 +3718,7 @@ close_process_descs ()
}
DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output,
- 0, 3, 0,
+ 0, 4, 0,
doc: /* Allow any pending output from subprocesses to be read by Emacs.
It is read into the process' buffers or given to their filter functions.
Non-nil arg PROCESS means do not return until some output has been received
@@ -3726,15 +3726,20 @@ from PROCESS.
Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of
seconds and microseconds to wait; return after that much time whether
or not there is input.
+If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
+from PROCESS, suspending reading output from other processes.
+If JUST-THIS-ONE is an integer, don't run any timers either.
Return non-nil iff we received any output before the timeout expired. */)
- (process, timeout, timeout_msecs)
- register Lisp_Object process, timeout, timeout_msecs;
+ (process, timeout, timeout_msecs, just_this_one)
+ register Lisp_Object process, timeout, timeout_msecs, just_this_one;
{
int seconds;
int useconds;
if (! NILP (process))
CHECK_PROCESS (process);
+ else
+ just_this_one = Qnil;
if (! NILP (timeout_msecs))
{
@@ -3772,11 +3777,12 @@ Return non-nil iff we received any output before the timeout expired. */)
else
seconds = NILP (process) ? -1 : 0;
- if (NILP (process))
- XSETFASTINT (process, 0);
-
return
- (wait_reading_process_input (seconds, useconds, process, 0)
+ (wait_reading_process_output (seconds, useconds, 0, 0,
+ Qnil,
+ !NILP (process) ? XPROCESS (process) : NULL,
+ NILP (just_this_one) ? 0 :
+ !INTEGERP (just_this_one) ? 1 : -1)
? Qt : Qnil);
}
@@ -3976,12 +3982,12 @@ server_accept_connection (server, channel)
lisp code is being evalled.
This is also used in record_asynch_buffer_change.
For that purpose, this must be 0
- when not inside wait_reading_process_input. */
+ when not inside wait_reading_process_output. */
static int waiting_for_user_input_p;
/* This is here so breakpoints can be put on it. */
static void
-wait_reading_process_input_1 ()
+wait_reading_process_output_1 ()
{
}
@@ -4003,25 +4009,32 @@ wait_reading_process_input_1 ()
1 to return when input is available, or
-1 meaning caller will actually read the input, so don't throw to
the quit handler, or
- a cons cell, meaning wait until its car is non-nil
- (and gobble terminal input into the buffer if any arrives), or
- a process object, meaning wait until something arrives from that
- process. The return value is true iff we read some input from
- that process.
DO_DISPLAY != 0 means redisplay should be done to show subprocess
- output that arrives.
+ output that arrives.
+
+ If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil
+ (and gobble terminal input into the buffer if any arrives).
- If READ_KBD is a pointer to a struct Lisp_Process, then the
- function returns true iff we received input from that process
- before the timeout elapsed.
+ If WAIT_PROC is specified, wait until something arrives from that
+ process. The return value is true iff we read some input from
+ that process.
+
+ If JUST_WAIT_PROC is non-nil, handle only output from WAIT_PROC
+ (suspending output from other processes). A negative value
+ means don't run any timers either.
+
+ If WAIT_PROC is specified, then the function returns true iff we
+ received input from that process before the timeout elapsed.
Otherwise, return true iff we received input from any process. */
int
-wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
- int time_limit, microsecs;
- Lisp_Object read_kbd;
- int do_display;
+wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
+ wait_for_cell, wait_proc, just_wait_proc)
+ int time_limit, microsecs, read_kbd, do_display;
+ Lisp_Object wait_for_cell;
+ struct Lisp_Process *wait_proc;
+ int just_wait_proc;
{
register int channel, nfds;
SELECT_TYPE Available;
@@ -4031,33 +4044,19 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
Lisp_Object proc;
EMACS_TIME timeout, end_time;
int wait_channel = -1;
- struct Lisp_Process *wait_proc = 0;
int got_some_input = 0;
/* Either nil or a cons cell, the car of which is of interest and
may be changed outside of this routine. */
- Lisp_Object wait_for_cell = Qnil;
int saved_waiting_for_user_input_p = waiting_for_user_input_p;
FD_ZERO (&Available);
FD_ZERO (&Connecting);
- /* If read_kbd is a process to watch, set wait_proc and wait_channel
- accordingly. */
- if (PROCESSP (read_kbd))
- {
- wait_proc = XPROCESS (read_kbd);
- wait_channel = XINT (wait_proc->infd);
- XSETFASTINT (read_kbd, 0);
- }
-
- /* If waiting for non-nil in a cell, record where. */
- if (CONSP (read_kbd))
- {
- wait_for_cell = read_kbd;
- XSETFASTINT (read_kbd, 0);
- }
+ /* If wait_proc is a process to watch, set wait_channel accordingly. */
+ if (wait_proc != NULL)
+ wait_channel = XINT (wait_proc->infd);
- waiting_for_user_input_p = XINT (read_kbd);
+ waiting_for_user_input_p = read_kbd;
/* Since we may need to wait several times,
compute the absolute time to return at. */
@@ -4085,7 +4084,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If calling from keyboard input, do not quit
since we want to return C-g as an input character.
Otherwise, do pending quit if requested. */
- if (XINT (read_kbd) >= 0)
+ if (read_kbd >= 0)
QUIT;
#ifdef SYNC_INPUT
else if (interrupt_input_pending)
@@ -4122,7 +4121,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
But not if wait_for_cell; in those cases,
the wait is supposed to be short,
and those callers cannot handle running arbitrary Lisp code here. */
- if (NILP (wait_for_cell))
+ if (NILP (wait_for_cell)
+ && just_wait_proc >= 0)
{
EMACS_TIME timer_delay;
@@ -4150,7 +4150,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
while (!detect_input_pending ());
/* If there is unread keyboard input, also return. */
- if (XINT (read_kbd) != 0
+ if (read_kbd != 0
&& requeued_events_pending_p ())
break;
@@ -4168,7 +4168,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
else if (time_limit != -1)
{
/* This is so a breakpoint can be put here. */
- wait_reading_process_input_1 ();
+ wait_reading_process_output_1 ();
}
}
@@ -4178,7 +4178,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
It is important that we do this before checking for process
activity. If we get a SIGCHLD after the explicit checks for
process activity, timeout is the only way we will know. */
- if (XINT (read_kbd) < 0)
+ if (read_kbd < 0)
set_waiting_for_input (&timeout);
/* If status of something has changed, and no input is
@@ -4195,7 +4195,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
present (for reading) at stdin, even when none is. This
causes the call to SELECT below to return 1 and
status_notify not to be called. As a result output of
- subprocesses are incorrectly discarded.
+ subprocesses are incorrectly discarded.
*/
FD_CLR (0, &Atemp);
#endif
@@ -4258,14 +4258,21 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* Wait till there is something to do */
- if (!NILP (wait_for_cell))
+ if (wait_proc && just_wait_proc)
+ {
+ if (XINT (wait_proc->infd) < 0) /* Terminated */
+ break;
+ FD_SET (XINT (wait_proc->infd), &Available);
+ check_connect = check_delay = 0;
+ }
+ else if (!NILP (wait_for_cell))
{
Available = non_process_wait_mask;
check_connect = check_delay = 0;
}
else
{
- if (! XINT (read_kbd))
+ if (! read_kbd)
Available = non_keyboard_wait_mask;
else
Available = input_wait_mask;
@@ -4282,12 +4289,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
{
clear_waiting_for_input ();
redisplay_preserve_echo_area (11);
- if (XINT (read_kbd) < 0)
+ if (read_kbd < 0)
set_waiting_for_input (&timeout);
}
no_avail = 0;
- if (XINT (read_kbd) && detect_input_pending ())
+ if (read_kbd && detect_input_pending ())
{
nfds = 0;
no_avail = 1;
@@ -4404,10 +4411,10 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If we are using polling for input,
and we see input available, make it get read now.
Otherwise it might not actually get read for a second.
- And on hpux, since we turn off polling in wait_reading_process_input,
+ And on hpux, since we turn off polling in wait_reading_process_output,
it might never get read at all if we don't spend much time
- outside of wait_reading_process_input. */
- if (XINT (read_kbd) && interrupt_input
+ outside of wait_reading_process_output. */
+ if (read_kbd && interrupt_input
&& keyboard_bit_set (&Available)
&& input_polling_used ())
kill (getpid (), SIGALRM);
@@ -4417,7 +4424,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If there is any, return immediately
to give it higher priority than subprocesses */
- if (XINT (read_kbd) != 0)
+ if (read_kbd != 0)
{
int old_timers_run = timers_run;
struct buffer *old_buffer = current_buffer;
@@ -4442,7 +4449,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
}
/* If there is unread keyboard input, also return. */
- if (XINT (read_kbd) != 0
+ if (read_kbd != 0
&& requeued_events_pending_p ())
break;
@@ -4453,7 +4460,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
That would causes delays in pasting selections, for example.
(We used to do this only if wait_for_cell.) */
- if (XINT (read_kbd) == 0 && detect_input_pending ())
+ if (read_kbd == 0 && detect_input_pending ())
{
swallow_events (do_display);
#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */
@@ -4472,7 +4479,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
In that case, there really is no input and no SIGIO,
but select says there is input. */
- if (XINT (read_kbd) && interrupt_input
+ if (read_kbd && interrupt_input
&& keyboard_bit_set (&Available) && ! noninteractive)
kill (getpid (), SIGIO);
#endif
@@ -4482,7 +4489,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If checking input just got us a size-change event from X,
obey it now if we should. */
- if (XINT (read_kbd) || ! NILP (wait_for_cell))
+ if (read_kbd || ! NILP (wait_for_cell))
do_pending_window_change (0);
/* Check for data from a process. */
@@ -4657,7 +4664,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If calling from keyboard input, do not quit
since we want to return C-g as an input character.
Otherwise, do pending quit if requested. */
- if (XINT (read_kbd) >= 0)
+ if (read_kbd >= 0)
{
/* Prevent input_pending from remaining set if we quit. */
clear_input_pending ();
@@ -4762,16 +4769,16 @@ read_process_output (proc, channel)
if (DATAGRAM_CHAN_P (channel))
{
int len = datagram_address[channel].len;
- nbytes = recvfrom (channel, chars + carryover, readmax - carryover,
+ nbytes = recvfrom (channel, chars + carryover, readmax,
0, datagram_address[channel].sa, &len);
}
else
#endif
if (proc_buffered_char[channel] < 0)
{
- nbytes = emacs_read (channel, chars + carryover, readmax - carryover);
+ nbytes = emacs_read (channel, chars + carryover, readmax);
#ifdef ADAPTIVE_READ_BUFFERING
- if (!NILP (p->adaptive_read_buffering))
+ if (nbytes > 0 && !NILP (p->adaptive_read_buffering))
{
int delay = XINT (p->read_output_delay);
if (nbytes < 256)
@@ -4783,7 +4790,7 @@ read_process_output (proc, channel)
delay += READ_OUTPUT_DELAY_INCREMENT * 2;
}
}
- else if (delay > 0 && (nbytes == readmax - carryover))
+ else if (delay > 0 && (nbytes == readmax))
{
delay -= READ_OUTPUT_DELAY_INCREMENT;
if (delay == 0)
@@ -4802,7 +4809,7 @@ read_process_output (proc, channel)
{
chars[carryover] = proc_buffered_char[channel];
proc_buffered_char[channel] = -1;
- nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1 - carryover);
+ nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
if (nbytes < 0)
nbytes = 1;
else
@@ -5304,7 +5311,6 @@ send_process (proc, buf, len, object)
that may allow the program
to finish doing output and read more. */
{
- Lisp_Object zero;
int offset = 0;
#ifdef BROKEN_PTY_READ_AFTER_EAGAIN
@@ -5339,11 +5345,10 @@ send_process (proc, buf, len, object)
else if (STRINGP (object))
offset = buf - SDATA (object);
- XSETFASTINT (zero, 0);
#ifdef EMACS_HAS_USECS
- wait_reading_process_input (0, 20000, zero, 0);
+ wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0);
#else
- wait_reading_process_input (1, 0, zero, 0);
+ wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0);
#endif
if (BUFFERP (object))
@@ -5549,29 +5554,36 @@ process_send_signal (process, signo, current_group, nomsg)
work. If the system has it, use it. */
#ifdef HAVE_TERMIOS
struct termios t;
+ cc_t *sig_char = NULL;
+
+ tcgetattr (XINT (p->infd), &t);
switch (signo)
{
case SIGINT:
- tcgetattr (XINT (p->infd), &t);
- send_process (proc, &t.c_cc[VINTR], 1, Qnil);
- return;
+ sig_char = &t.c_cc[VINTR];
+ break;
case SIGQUIT:
- tcgetattr (XINT (p->infd), &t);
- send_process (proc, &t.c_cc[VQUIT], 1, Qnil);
- return;
+ sig_char = &t.c_cc[VQUIT];
+ break;
case SIGTSTP:
- tcgetattr (XINT (p->infd), &t);
#if defined (VSWTCH) && !defined (PREFER_VSUSP)
- send_process (proc, &t.c_cc[VSWTCH], 1, Qnil);
+ sig_char = &t.c_cc[VSWTCH];
#else
- send_process (proc, &t.c_cc[VSUSP], 1, Qnil);
+ sig_char = &t.c_cc[VSUSP];
#endif
- return;
+ break;
}
+ if (sig_char && *sig_char != CDISABLE)
+ {
+ send_process (proc, sig_char, 1, Qnil);
+ return;
+ }
+ /* If we can't send the signal with a character,
+ fall through and send it another way. */
#else /* ! HAVE_TERMIOS */
/* On Berkeley descendants, the following IOCTL's retrieve the
@@ -5628,9 +5640,12 @@ process_send_signal (process, signo, current_group, nomsg)
you'd better be using one of the alternatives above! */
#endif /* ! defined (TCGETA) */
#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
-#endif /* ! defined HAVE_TERMIOS */
+ /* In this case, the code above should alway returns. */
abort ();
- /* The code above always returns from the function. */
+#endif /* ! defined HAVE_TERMIOS */
+
+ /* The code above may fall through if it can't
+ handle the signal. */
#endif /* defined (SIGNALS_VIA_CHARACTERS) */
#ifdef TIOCGPGRP
@@ -6202,7 +6217,7 @@ sigchld_handler (signo)
FD_CLR (XINT (p->infd), &non_keyboard_wait_mask);
}
- /* Tell wait_reading_process_input that it needs to wake up and
+ /* Tell wait_reading_process_output that it needs to wake up and
look around. */
if (input_available_clear_time)
EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
@@ -6220,7 +6235,7 @@ sigchld_handler (signo)
else if (WIFSIGNALED (w))
synch_process_termsig = WTERMSIG (w);
- /* Tell wait_reading_process_input that it needs to wake up and
+ /* Tell wait_reading_process_output that it needs to wake up and
look around. */
if (input_available_clear_time)
EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
@@ -6862,10 +6877,9 @@ Lisp_Object QCtype;
1 to return when input is available, or
-1 means caller will actually read the input, so don't throw to
the quit handler.
- a cons cell, meaning wait until its car is non-nil
- (and gobble terminal input into the buffer if any arrives), or
- We know that read_kbd will never be a Lisp_Process, since
- `subprocesses' isn't defined.
+
+ see full version for other parameters. We know that wait_proc will
+ always be NULL, since `subprocesses' isn't defined.
do_display != 0 means redisplay should be done to show subprocess
output that arrives.
@@ -6873,27 +6887,17 @@ Lisp_Object QCtype;
Return true iff we received input from any process. */
int
-wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
- int time_limit, microsecs;
- Lisp_Object read_kbd;
- int do_display;
+wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
+ wait_for_cell, wait_proc, just_wait_proc)
+ int time_limit, microsecs, read_kbd, do_display;
+ Lisp_Object wait_for_cell;
+ struct Lisp_Process *wait_proc;
+ int just_wait_proc;
{
register int nfds;
EMACS_TIME end_time, timeout;
SELECT_TYPE waitchannels;
int xerrno;
- /* Either nil or a cons cell, the car of which is of interest and
- may be changed outside of this routine. */
- Lisp_Object wait_for_cell;
-
- wait_for_cell = Qnil;
-
- /* If waiting for non-nil in a cell, record where. */
- if (CONSP (read_kbd))
- {
- wait_for_cell = read_kbd;
- XSETFASTINT (read_kbd, 0);
- }
/* What does time_limit really mean? */
if (time_limit || microsecs)
@@ -6916,7 +6920,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If calling from keyboard input, do not quit
since we want to return C-g as an input character.
Otherwise, do pending quit if requested. */
- if (XINT (read_kbd) >= 0)
+ if (read_kbd >= 0)
QUIT;
/* Exit now if the cell we're waiting for became non-nil. */
@@ -6967,7 +6971,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
while (!detect_input_pending ());
/* If there is unread keyboard input, also return. */
- if (XINT (read_kbd) != 0
+ if (read_kbd != 0
&& requeued_events_pending_p ())
break;
@@ -6985,12 +6989,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* Cause C-g and alarm signals to take immediate action,
and cause input available signals to zero out timeout. */
- if (XINT (read_kbd) < 0)
+ if (read_kbd < 0)
set_waiting_for_input (&timeout);
/* Wait till there is something to do. */
- if (! XINT (read_kbd) && NILP (wait_for_cell))
+ if (! read_kbd && NILP (wait_for_cell))
FD_ZERO (&waitchannels);
else
FD_SET (0, &waitchannels);
@@ -7001,11 +7005,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
{
clear_waiting_for_input ();
redisplay_preserve_echo_area (15);
- if (XINT (read_kbd) < 0)
+ if (read_kbd < 0)
set_waiting_for_input (&timeout);
}
- if (XINT (read_kbd) && detect_input_pending ())
+ if (read_kbd && detect_input_pending ())
{
nfds = 0;
FD_ZERO (&waitchannels);
@@ -7041,13 +7045,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
kill (getpid (), SIGIO);
#endif
#ifdef SIGIO
- if (XINT (read_kbd) && interrupt_input && (waitchannels & 1))
+ if (read_kbd && interrupt_input && (waitchannels & 1))
kill (getpid (), SIGIO);
#endif
/* Check for keyboard input */
- if ((XINT (read_kbd) != 0)
+ if (read_kbd
&& detect_input_pending_run_timers (do_display))
{
swallow_events (do_display);
@@ -7056,7 +7060,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
}
/* If there is unread keyboard input, also return. */
- if (XINT (read_kbd) != 0
+ if (read_kbd
&& requeued_events_pending_p ())
break;
diff --git a/src/s/darwin.h b/src/s/darwin.h
index 814de2c2c51..f854ed9380b 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -243,11 +243,18 @@ Boston, MA 02111-1307, USA. */
specific headers. */
#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src
-/* Link in the Carbon lib. The -headerpad option tells ld (see man
- page) to leave room at the end of the header for adding load
- commands. Needed for dumping. 0x690 is the total size of 30
- segment load commands (at 56 each). */
-#define LD_SWITCH_SYSTEM_TEMACS -prebind -framework Carbon -framework QuickTime -lstdc++ -Xlinker -headerpad -Xlinker 690
+/* Link in the Carbon lib. */
+#ifdef HAVE_CARBON
+#define LIBS_CARBON -framework Carbon -framework QuickTime
+#else
+#define LIBS_CARBON -framework Carbon
+#endif
+
+/* The -headerpad option tells ld (see man page) to leave room at the
+ end of the header for adding load commands. Needed for dumping.
+ 0x690 is the total size of 30 segment load commands (at 56
+ each). */
+#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_CARBON -Xlinker -headerpad -Xlinker 690
#define C_SWITCH_SYSTEM_TEMACS -Dtemacs
diff --git a/src/syntax.c b/src/syntax.c
index 83763061d82..272e9cf1b12 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -292,7 +292,7 @@ char_quoted (charpos, bytepos)
DEC_BOTH (charpos, bytepos);
- while (bytepos >= beg)
+ while (charpos >= beg)
{
int c;
@@ -673,7 +673,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p
{
from = comstart_pos;
from_byte = comstart_byte;
- /* Globals are correct now. */
+ UPDATE_SYNTAX_TABLE_FORWARD (from - 1);
}
else
{
@@ -1728,12 +1728,12 @@ skip_chars (forwardp, syntaxp, string, lim, handle_iso_classes)
if (negate)
break;
else
- goto fwd_ok;
+ goto fwd_unibyte_ok;
}
if (!fastmap[*p])
break;
-
+ fwd_unibyte_ok:
p++, pos++;
}
}
@@ -1801,12 +1801,12 @@ skip_chars (forwardp, syntaxp, string, lim, handle_iso_classes)
if (negate)
break;
else
- goto fwd_ok;
+ goto back_unibyte_ok;
}
if (!fastmap[p[-1]])
break;
-
+ back_unibyte_ok:
p--, pos--;
}
}
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)
s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
#endif /* HPUX */
+#ifdef SIGNALS_VIA_CHARACTERS
+ /* the QUIT and INTR character are used in process_send_signal
+ so set them here to something useful. */
+ if (s.main.c_cc[VQUIT] == CDISABLE)
+ s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */
+ if (s.main.c_cc[VINTR] == CDISABLE)
+ s.main.c_cc[VINTR] = 'C'&037; /* Control-C */
+#endif /* not SIGNALS_VIA_CHARACTERS */
+
#ifdef AIX
/* AIX enhanced edit loses NULs, so disable it */
#ifndef IBMR2AIX
@@ -620,22 +629,16 @@ child_setup_tty (out)
don't ignore break, but don't signal either, so it looks like NUL. */
s.main.c_iflag &= ~IGNBRK;
s.main.c_iflag &= ~BRKINT;
+ /* rms: Formerly it set s.main.c_cc[VINTR] to 0377 here
+ unconditionally. Then a SIGNALS_VIA_CHARACTERS conditional
+ would force it to 0377. That looks like duplicated code. */
+#ifndef SIGNALS_VIA_CHARACTERS
/* QUIT and INTR work better as signals, so disable character forms */
- s.main.c_cc[VINTR] = 0377;
-#ifdef SIGNALS_VIA_CHARACTERS
- /* the QUIT and INTR character are used in process_send_signal
- so set them here to something useful. */
- if (s.main.c_cc[VQUIT] == 0377)
- s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */
- if (s.main.c_cc[VINTR] == 0377)
- s.main.c_cc[VINTR] = 'C'&037; /* Control-C */
-#else /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */
- /* QUIT and INTR work better as signals, so disable character forms */
- s.main.c_cc[VQUIT] = 0377;
- s.main.c_cc[VINTR] = 0377;
+ s.main.c_cc[VQUIT] = CDISABLE;
+ s.main.c_cc[VINTR] = CDISABLE;
s.main.c_lflag &= ~ISIG;
#endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */
- s.main.c_cc[VEOL] = 0377;
+ s.main.c_cc[VEOL] = CDISABLE;
s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
#endif /* AIX */
@@ -1476,10 +1479,10 @@ nil means don't delete them until `list-processes' is run. */);
tty.main.c_line = 0;
tty.main.c_iflag &= ~ASCEDIT;
#else
- tty.main.c_cc[VSTRT] = 255;
- tty.main.c_cc[VSTOP] = 255;
- tty.main.c_cc[VSUSP] = 255;
- tty.main.c_cc[VDSUSP] = 255;
+ tty.main.c_cc[VSTRT] = CDISABLE;
+ tty.main.c_cc[VSTOP] = CDISABLE;
+ tty.main.c_cc[VSUSP] = CDISABLE;
+ tty.main.c_cc[VDSUSP] = CDISABLE;
#endif /* IBMR2AIX */
if (flow_control)
{
diff --git a/src/w32fns.c b/src/w32fns.c
index 0cb3abe91cd..e60385c8129 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -4642,6 +4642,7 @@ int size;
{
Lisp_Object bdf_fonts;
struct font_info *retval = NULL;
+ struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
bdf_fonts = w32_list_bdf_fonts (build_string (fontname), 1);
@@ -4649,11 +4650,22 @@ int size;
{
char *bdf_name, *bdf_file;
Lisp_Object bdf_pair;
+ int i;
bdf_name = SDATA (XCAR (bdf_fonts));
bdf_pair = Fassoc (XCAR (bdf_fonts), Vw32_bdf_filename_alist);
bdf_file = SDATA (XCDR (bdf_pair));
+ // If the font is already loaded, do not load it again.
+ for (i = 0; i < dpyinfo->n_fonts; i++)
+ {
+ if ((dpyinfo->font_table[i].name
+ && !strcmp (dpyinfo->font_table[i].name, bdf_name))
+ || (dpyinfo->font_table[i].full_name
+ && !strcmp (dpyinfo->font_table[i].full_name, bdf_name)))
+ return dpyinfo->font_table + i;
+ }
+
retval = w32_load_bdf_font (f, bdf_name, size, bdf_file);
bdf_fonts = XCDR (bdf_fonts);
diff --git a/src/w32menu.c b/src/w32menu.c
index cc0932d7bf5..f3f3eb785b0 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -45,7 +45,6 @@ Boston, MA 02111-1307, USA. */
#include "dispextern.h"
-#undef HAVE_MULTILINGUAL_MENU
#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
/******************************************************************/
@@ -66,10 +65,12 @@ enum button_type
typedef struct _widget_value
{
/* name of widget */
+ Lisp_Object lname;
char* name;
/* value (meaning depend on widget type) */
char* value;
/* keyboard equivalent. no implications for XtTranslations */
+ Lisp_Object lkey;
char* key;
/* Help string or nil if none.
GC finds this string through the frame's menu_bar_vector
@@ -136,17 +137,21 @@ typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
IN HMENU,
IN UINT,
IN BOOL,
- IN OUT LPMENUITEMINFOA
- );
+ IN OUT LPMENUITEMINFOA);
typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
IN HMENU,
IN UINT,
IN BOOL,
- IN LPCMENUITEMINFOA
- );
+ IN LPCMENUITEMINFOA);
+typedef BOOL (WINAPI * AppendMenuW_Proc) (
+ IN HMENU,
+ IN UINT,
+ IN UINT_PTR,
+ IN LPCWSTR);
-GetMenuItemInfoA_Proc get_menu_item_info=NULL;
-SetMenuItemInfoA_Proc set_menu_item_info=NULL;
+GetMenuItemInfoA_Proc get_menu_item_info = NULL;
+SetMenuItemInfoA_Proc set_menu_item_info = NULL;
+AppendMenuW_Proc unicode_append_menu = NULL;
Lisp_Object Vmenu_updating_frame;
@@ -1235,13 +1240,17 @@ digest_single_submenu (start, end, top_level_items)
pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
-#ifndef HAVE_MULTILINGUAL_MENU
- if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
+ if (STRINGP (pane_name))
{
- pane_name = ENCODE_SYSTEM (pane_name);
+ if (unicode_append_menu)
+ /* Encode as UTF-8 for now. */
+ pane_name = ENCODE_UTF_8 (pane_name);
+ else if (STRING_MULTIBYTE (pane_name))
+ pane_name = ENCODE_SYSTEM (pane_name);
+
ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
}
-#endif
+
pane_string = (NILP (pane_name)
? "" : (char *) SDATA (pane_name));
/* If there is just one top-level pane, put all its items directly
@@ -1259,12 +1268,9 @@ digest_single_submenu (start, end, top_level_items)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
- /* Ignore the @ that means "separate pane".
- This is a kludge, but this isn't worth more time. */
- if (!NILP (prefix) && wv->name[0] == '@')
- wv->name++;
- wv->value = 0;
+ wv->lname = pane_name;
+ /* Set value to 1 so update_submenu_strings can handle '@' */
+ wv->value = (char *) 1;
wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
wv->help = Qnil;
@@ -1287,10 +1293,13 @@ digest_single_submenu (start, end, top_level_items)
selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
-#ifndef HAVE_MULTILINGUAL_MENU
- if (STRING_MULTIBYTE (item_name))
+ if (STRINGP (item_name))
{
- item_name = ENCODE_SYSTEM (item_name);
+ if (unicode_append_menu)
+ item_name = ENCODE_UTF_8 (item_name);
+ else if (STRING_MULTIBYTE (item_name))
+ item_name = ENCODE_SYSTEM (item_name);
+
ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
}
@@ -1299,7 +1308,6 @@ digest_single_submenu (start, end, top_level_items)
descrip = ENCODE_SYSTEM (descrip);
ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
}
-#endif /* not HAVE_MULTILINGUAL_MENU */
wv = xmalloc_widget_value ();
if (prev_wv)
@@ -1307,9 +1315,9 @@ digest_single_submenu (start, end, top_level_items)
else
save_wv->contents = wv;
- wv->name = (char *) SDATA (item_name);
+ wv->lname = item_name;
if (!NILP (descrip))
- wv->key = (char *) SDATA (descrip);
+ wv->lkey = descrip;
wv->value = 0;
/* The EMACS_INT cast avoids a warning. There's no problem
as long as pointers have enough bits to hold small integers. */
@@ -1348,6 +1356,43 @@ digest_single_submenu (start, end, top_level_items)
return first_wv;
}
+
+
+/* Walk through the widget_value tree starting at FIRST_WV and update
+ the char * pointers from the corresponding lisp values.
+ We do this after building the whole tree, since GC may happen while the
+ tree is constructed, and small strings are relocated. So we must wait
+ until no GC can happen before storing pointers into lisp values. */
+static void
+update_submenu_strings (first_wv)
+ widget_value *first_wv;
+{
+ widget_value *wv;
+
+ for (wv = first_wv; wv; wv = wv->next)
+ {
+ if (wv->lname && ! NILP (wv->lname))
+ {
+ wv->name = SDATA (wv->lname);
+
+ /* Ignore the @ that means "separate pane".
+ This is a kludge, but this isn't worth more time. */
+ if (wv->value == (char *)1)
+ {
+ if (wv->name[0] == '@')
+ wv->name++;
+ wv->value = 0;
+ }
+ }
+
+ if (wv->lkey && ! NILP (wv->lkey))
+ wv->key = SDATA (wv->lkey);
+
+ if (wv->contents)
+ update_submenu_strings (wv->contents);
+ }
+}
+
/* Set the contents of the menubar widgets of frame F.
The argument FIRST_TIME is currently ignored;
@@ -1516,6 +1561,7 @@ set_frame_menubar (f, first_time, deep_p)
if (NILP (string))
break;
wv->name = (char *) SDATA (string);
+ update_submenu_strings (wv->contents);
wv = wv->next;
}
@@ -1729,13 +1775,17 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
char *pane_string;
pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
-#ifndef HAVE_MULTILINGUAL_MENU
- if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
+
+ if (STRINGP (pane_name))
{
- pane_name = ENCODE_SYSTEM (pane_name);
+ if (unicode_append_menu)
+ pane_name = ENCODE_UTF_8 (pane_name);
+ else if (STRING_MULTIBYTE (pane_name))
+ pane_name = ENCODE_SYSTEM (pane_name);
+
ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
}
-#endif
+
pane_string = (NILP (pane_name)
? "" : (char *) SDATA (pane_name));
/* If there is just one top-level pane, put all its items directly
@@ -1784,18 +1834,21 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
-#ifndef HAVE_MULTILINGUAL_MENU
- if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
+ if (STRINGP (item_name))
{
- item_name = ENCODE_SYSTEM (item_name);
+ if (unicode_append_menu)
+ item_name = ENCODE_UTF_8 (item_name);
+ else if (STRING_MULTIBYTE (item_name))
+ item_name = ENCODE_SYSTEM (item_name);
+
ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
}
- if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
+
+ if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
{
descrip = ENCODE_SYSTEM (descrip);
ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
}
-#endif /* not HAVE_MULTILINGUAL_MENU */
wv = xmalloc_widget_value ();
if (prev_wv)
@@ -1844,10 +1897,11 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
wv_sep->next = first_wv->contents;
wv_sep->help = Qnil;
-#ifndef HAVE_MULTILINGUAL_MENU
- if (STRING_MULTIBYTE (title))
+ if (unicode_append_menu)
+ title = ENCODE_UTF_8 (title);
+ else if (STRING_MULTIBYTE (title))
title = ENCODE_SYSTEM (title);
-#endif
+
wv_title->name = (char *) SDATA (title);
wv_title->enabled = TRUE;
wv_title->title = TRUE;
@@ -2150,6 +2204,46 @@ add_left_right_boundary (HMENU menu)
return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL);
}
+/* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
+static void
+utf8to16 (unsigned char * src, int len, WCHAR * dest)
+{
+ while (len > 0)
+ {
+ int utf16;
+ if (*src < 0x80)
+ {
+ *dest = (WCHAR) *src;
+ dest++; src++; len--;
+ }
+ /* Since we might get >3 byte sequences which we don't handle, ignore the extra parts. */
+ else if (*src < 0xC0)
+ {
+ src++; len--;
+ }
+ /* 2 char UTF-8 sequence. */
+ else if (*src < 0xE0)
+ {
+ *dest = (WCHAR) (((*src & 0x1f) << 6)
+ | (*(src + 1) & 0x3f));
+ src += 2; len -= 2; dest++;
+ }
+ else if (*src < 0xF0)
+ {
+ *dest = (WCHAR) (((*src & 0x0f) << 12)
+ | ((*(src + 1) & 0x3f) << 6)
+ | (*(src + 2) & 0x3f));
+ src += 3; len -= 3; dest++;
+ }
+ else /* Not encodable. Insert Unicode Substitution char. */
+ {
+ *dest = (WCHAR) 0xfffd;
+ src++; len--; dest++;
+ }
+ }
+ *dest = 0;
+}
+
static int
add_menu_item (HMENU menu, widget_value *wv, HMENU item)
{
@@ -2206,11 +2300,32 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
fuFlags |= MF_UNCHECKED;
}
- return_value =
- AppendMenu (menu,
- fuFlags,
- item != NULL ? (UINT) item : (UINT) wv->call_data,
- out_string );
+ if (unicode_append_menu && out_string)
+ {
+ /* Convert out_string from UTF-8 to UTF-16-LE. */
+ int utf8_len = strlen (out_string);
+ WCHAR * utf16_string;
+ if (fuFlags & MF_OWNERDRAW)
+ utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
+ else
+ utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
+
+ utf8to16 (out_string, utf8_len, utf16_string);
+ return_value = unicode_append_menu (menu, fuFlags,
+ item != NULL ? (UINT) item
+ : (UINT) wv->call_data,
+ utf16_string);
+ if (fuFlags & MF_OWNERDRAW)
+ local_free (out_string);
+ }
+ else
+ {
+ return_value =
+ AppendMenu (menu,
+ fuFlags,
+ item != NULL ? (UINT) item : (UINT) wv->call_data,
+ out_string );
+ }
/* This must be done after the menu item is created. */
if (!wv->title && wv->call_data != 0)
@@ -2298,7 +2413,7 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
Lisp_Object frame, help;
- // No help echo on owner-draw menu items.
+ /* No help echo on owner-draw menu items. */
if (flags & MF_OWNERDRAW || flags & MF_POPUP)
help = Qnil;
else
@@ -2422,6 +2537,7 @@ void globals_of_w32menu ()
HMODULE user32 = GetModuleHandle ("user32.dll");
get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
+ unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
}
/* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
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:
{
DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n",
nh + nc, timeout_ms, GetLastError ()));
- /* don't return EBADF - this causes wait_reading_process_input to
+ /* don't return EBADF - this causes wait_reading_process_output to
abort; WAIT_FAILED is returned when single-stepping under
Windows 95 after switching thread focus in debugger, and
possibly at other times. */
diff --git a/src/w32term.c b/src/w32term.c
index 71125fe4195..f71736dffad 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4570,7 +4570,7 @@ w32_read_socket (sd, expected, hold_quit)
f->async_visible = 1;
f->async_iconified = 0;
- /* wait_reading_process_input will notice this and update
+ /* wait_reading_process_output will notice this and update
the frame's display structures. */
SET_FRAME_GARBAGED (f);
diff --git a/src/window.c b/src/window.c
index 5aafd8a741a..463c8f1f1bd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -579,6 +579,8 @@ display margins, fringes, header line, and/or mode line. */)
if it is on the window's modeline, return ON_MODE_LINE;
if it is on the border between the window and its right sibling,
return ON_VERTICAL_BORDER.
+ if it is on a scroll bar,
+ return ON_SCROLL_BAR.
if it is on the window's top line, return ON_HEADER_LINE;
if it is in left or right fringe of the window,
return ON_LEFT_FRINGE or ON_RIGHT_FRINGE, and convert *X and *Y
@@ -673,7 +675,7 @@ coordinates_in_window (w, x, y)
/* Outside any interesting column? */
if (*x < left_x || *x > right_x)
- return ON_VERTICAL_BORDER;
+ return ON_SCROLL_BAR;
lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
@@ -783,8 +785,8 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
ly = Fcdr (coordinates);
CHECK_NUMBER_OR_FLOAT (lx);
CHECK_NUMBER_OR_FLOAT (ly);
- x = FRAME_PIXEL_X_FROM_CANON_X (f, lx);
- y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly);
+ x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f);
+ y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f);
switch (coordinates_in_window (w, &x, &y))
{
@@ -818,6 +820,10 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
case ON_RIGHT_MARGIN:
return Qright_margin;
+ case ON_SCROLL_BAR:
+ /* Historically we are supposed to return nil in this case. */
+ return Qnil;
+
default:
abort ();
}
@@ -938,8 +944,10 @@ column 0. */)
CHECK_NUMBER_OR_FLOAT (y);
return window_from_coordinates (f,
- FRAME_PIXEL_X_FROM_CANON_X (f, x),
- FRAME_PIXEL_Y_FROM_CANON_Y (f, y),
+ (FRAME_PIXEL_X_FROM_CANON_X (f, x)
+ + FRAME_INTERNAL_BORDER_WIDTH (f)),
+ (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
+ + FRAME_INTERNAL_BORDER_WIDTH (f)),
0, 0, 0, 0);
}
@@ -1820,7 +1828,7 @@ window_list_1 (window, minibuf, all_frames)
rest = Fmemq (window, list);
if (!NILP (rest) && !EQ (rest, list))
{
- for (tail = list; XCDR (tail) != rest; tail = XCDR (tail))
+ for (tail = list; !EQ (XCDR (tail), rest); tail = XCDR (tail))
;
XSETCDR (tail, Qnil);
list = nconc2 (rest, list);
@@ -4699,7 +4707,7 @@ window_scroll_line_based (window, n, whole, noerror)
posit = *compute_motion (startpos, 0, 0, 0,
PT, ht, 0,
- window_box_text_cols (w), XINT (w->hscroll),
+ -1, XINT (w->hscroll),
0, w);
original_vpos = posit.vpos;
diff --git a/src/xdisp.c b/src/xdisp.c
index 4083ce7a438..409d32449e5 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -306,6 +306,7 @@ Lisp_Object Qline_height, Qtotal;
extern Lisp_Object Qheight;
extern Lisp_Object QCwidth, QCheight, QCascent;
extern Lisp_Object Qscroll_bar;
+extern Lisp_Object Qcursor;
/* Non-nil means highlight trailing whitespace. */
@@ -5649,9 +5650,13 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
{
int x, i, ascent = 0, descent = 0;
- /* Stop when ZV or TO_CHARPOS reached. */
+ /* Stop when ZV reached.
+ We used to stop here when TO_CHARPOS reached as well, but that is
+ too soon if this glyph does not fit on this line. So we handle it
+ explicitly below. */
if (!get_next_display_element (it)
- || BUFFER_POS_REACHED_P ())
+ || (it->truncate_lines_p
+ && BUFFER_POS_REACHED_P ()))
{
result = MOVE_POS_MATCH_OR_ZV;
break;
@@ -5711,6 +5716,8 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
/* We want to leave anything reaching TO_X to the caller. */
if ((op & MOVE_TO_X) && new_x > to_x)
{
+ if (BUFFER_POS_REACHED_P ())
+ goto buffer_pos_reached;
it->current_x = x;
result = MOVE_X_REACHED;
break;
@@ -5738,12 +5745,19 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
#ifdef HAVE_WINDOW_SYSTEM
if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
{
- if (!get_next_display_element (it)
- || BUFFER_POS_REACHED_P ())
+ if (!get_next_display_element (it))
{
result = MOVE_POS_MATCH_OR_ZV;
break;
}
+ if (BUFFER_POS_REACHED_P ())
+ {
+ if (ITERATOR_AT_END_OF_LINE_P (it))
+ result = MOVE_POS_MATCH_OR_ZV;
+ else
+ result = MOVE_LINE_CONTINUED;
+ break;
+ }
if (ITERATOR_AT_END_OF_LINE_P (it))
{
result = MOVE_NEWLINE_OR_CR;
@@ -5765,6 +5779,8 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
result = MOVE_LINE_CONTINUED;
break;
}
+ else if (BUFFER_POS_REACHED_P ())
+ goto buffer_pos_reached;
else if (new_x > it->first_visible_x)
{
/* Glyph is visible. Increment number of glyphs that
@@ -5781,6 +5797,15 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
if (result != MOVE_UNDEFINED)
break;
}
+ else if (BUFFER_POS_REACHED_P ())
+ {
+ buffer_pos_reached:
+ it->current_x = x;
+ it->max_ascent = ascent;
+ it->max_descent = descent;
+ result = MOVE_POS_MATCH_OR_ZV;
+ break;
+ }
else if ((op & MOVE_TO_X) && it->current_x >= to_x)
{
/* Stop when TO_X specified and reached. This check is
@@ -10357,7 +10382,7 @@ redisplay_internal (preserve_echo_area)
This is useful in situations where you need to redisplay but no
user action has occurred, making it inappropriate for the message
area to be cleared. See tracking_off and
- wait_reading_process_input for examples of these situations.
+ wait_reading_process_output for examples of these situations.
FROM_WHERE is an integer saying from where this function was
called. This is useful for debugging. */
@@ -10623,6 +10648,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
{
struct glyph *glyph = row->glyphs[TEXT_AREA];
struct glyph *end = glyph + row->used[TEXT_AREA];
+ struct glyph *cursor = NULL;
/* The first glyph that starts a sequence of glyphs from string. */
struct glyph *string_start;
/* The X coordinate of string_start. */
@@ -10632,6 +10658,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
/* The last known character position before string_start. */
int string_before_pos;
int x = row->x;
+ int cursor_x = x;
int pt_old = PT - delta;
/* Skip over glyphs not having an object at the start of the row.
@@ -10664,12 +10691,29 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
string_start = glyph;
string_start_x = x;
/* Skip all glyphs from string. */
- SKIP_GLYPHS (glyph, end, x, STRINGP (glyph->object));
+ do
+ {
+ if ((cursor == NULL || glyph > cursor)
+ && !NILP (Fget_char_property (make_number ((glyph)->charpos),
+ Qcursor, (glyph)->object)))
+ {
+ cursor = glyph;
+ cursor_x = x;
+ }
+ x += glyph->pixel_width;
+ ++glyph;
+ }
+ while (glyph < end && STRINGP (glyph->object));
}
}
- if (string_start
- && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
+ if (cursor != NULL)
+ {
+ glyph = cursor;
+ x = cursor_x;
+ }
+ else if (string_start
+ && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
{
/* We may have skipped over point because the previous glyphs
are from string. As there's no easy way to know the
@@ -11061,8 +11105,8 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
start_display (&it, w, startp);
if (scroll_conservatively)
- amount_to_scroll =
- max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step));
+ amount_to_scroll
+ = max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step));
else if (scroll_step || temp_scroll_step)
amount_to_scroll = scroll_max;
else
@@ -11341,8 +11385,7 @@ try_cursor_movement (window, startp, scroll_step)
else if (PT < XFASTINT (w->last_point))
{
/* Cursor has to be moved backward. Note that PT >=
- CHARPOS (startp) because of the outer
- if-statement. */
+ CHARPOS (startp) because of the outer if-statement. */
while (!row->mode_line_p
&& (MATRIX_ROW_START_CHARPOS (row) > PT
|| (MATRIX_ROW_START_CHARPOS (row) == PT
@@ -11854,8 +11897,8 @@ redisplay_window (window, just_this_one_p)
buffer. */
|| !NILP (Vwindow_scroll_functions)
|| MINI_WINDOW_P (w)
- || !(used_current_matrix_p =
- try_window_reusing_current_matrix (w)))
+ || !(used_current_matrix_p
+ = try_window_reusing_current_matrix (w)))
{
IF_DEBUG (debug_method_add (w, "1"));
try_window (window, startp);
@@ -11984,8 +12027,8 @@ redisplay_window (window, just_this_one_p)
|| !NILP (Vwindow_scroll_functions)
|| !just_this_one_p
|| MINI_WINDOW_P (w)
- || !(used_current_matrix_p =
- try_window_reusing_current_matrix (w)))
+ || !(used_current_matrix_p
+ = try_window_reusing_current_matrix (w)))
try_window (window, startp);
/* If new fonts have been loaded (due to fontsets), give up. We
@@ -15650,7 +15693,8 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
The mode_line_string_face face property is always added to the string.
*/
-static int store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props)
+static int
+store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props)
char *string;
Lisp_Object lisp_string;
int copy_string;
@@ -15762,32 +15806,32 @@ If third optional arg NO-PROPS is non-nil, string is not propertized. */)
if (NILP (format) || EQ (format, Qt))
{
- face_id = NILP (format)
- ? CURRENT_MODE_LINE_FACE_ID (w) :
- HEADER_LINE_FACE_ID;
- format = NILP (format)
- ? current_buffer->mode_line_format
- : current_buffer->header_line_format;
+ face_id = (NILP (format)
+ ? CURRENT_MODE_LINE_FACE_ID (w)
+ : HEADER_LINE_FACE_ID);
+ format = (NILP (format)
+ ? current_buffer->mode_line_format
+ : current_buffer->header_line_format);
}
init_iterator (&it, w, -1, -1, NULL, face_id);
if (NILP (no_props))
{
- mode_line_string_face =
- (face_id == MODE_LINE_FACE_ID ? Qmode_line :
- face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive :
- face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil);
+ mode_line_string_face
+ = (face_id == MODE_LINE_FACE_ID ? Qmode_line
+ : face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive
+ : face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil);
- mode_line_string_face_prop =
- NILP (mode_line_string_face) ? Qnil :
- Fcons (Qface, Fcons (mode_line_string_face, Qnil));
+ mode_line_string_face_prop
+ = (NILP (mode_line_string_face) ? Qnil
+ : Fcons (Qface, Fcons (mode_line_string_face, Qnil)));
/* We need a dummy last element in mode_line_string_list to
indicate we are building the propertized mode-line string.
Using mode_line_string_face_prop here GC protects it. */
- mode_line_string_list =
- Fcons (mode_line_string_face_prop, Qnil);
+ mode_line_string_list
+ = Fcons (mode_line_string_face_prop, Qnil);
frame_title_ptr = NULL;
}
else
@@ -20868,7 +20912,8 @@ note_mouse_highlight (f, x, y)
if (part == ON_VERTICAL_BORDER)
cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
- else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE)
+ else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
+ || part == ON_SCROLL_BAR)
cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
else
cursor = FRAME_X_OUTPUT (f)->text_cursor;
diff --git a/src/xfaces.c b/src/xfaces.c
index 7f5012f3e0a..aafd762b73b 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1544,6 +1544,7 @@ DEFUN ("color-supported-p", Fcolor_supported_p,
Scolor_supported_p, 1, 3, 0,
doc: /* Return non-nil if COLOR can be displayed on FRAME.
BACKGROUND-P non-nil means COLOR is used as a background.
+Otherwise, this function tells whether it can be used as a foreground.
If FRAME is nil or omitted, use the selected frame.
COLOR must be a valid color name. */)
(color, frame, background_p)
@@ -3625,7 +3626,10 @@ merge_face_ref (f, face_ref, to, err_msgs, named_merge_points)
Lisp_Object value = XCAR (XCDR (face_ref));
int err = 0;
- if (EQ (keyword, QCfamily))
+ /* Specifying `unspecified' is a no-op. */
+ if (EQ (value, Qunspecified))
+ ;
+ else if (EQ (keyword, QCfamily))
{
if (STRINGP (value))
to[LFACE_FAMILY_INDEX] = value;
diff --git a/src/xfns.c b/src/xfns.c
index 931d31bcedf..5ebdeca97d5 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -281,6 +281,8 @@ x_window_to_frame (dpyinfo, wdesc)
Lisp_Object tail, frame;
struct frame *f;
+ if (wdesc == None) return 0;
+
for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
frame = XCAR (tail);
@@ -330,6 +332,8 @@ x_any_window_to_frame (dpyinfo, wdesc)
struct frame *f, *found;
struct x_output *x;
+ if (wdesc == None) return NULL;
+
found = NULL;
for (tail = Vframe_list; GC_CONSP (tail) && !found; tail = XCDR (tail))
{
@@ -384,6 +388,8 @@ x_non_menubar_window_to_frame (dpyinfo, wdesc)
struct frame *f;
struct x_output *x;
+ if (wdesc == None) return 0;
+
for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
frame = XCAR (tail);
@@ -430,6 +436,8 @@ x_menubar_window_to_frame (dpyinfo, wdesc)
struct frame *f;
struct x_output *x;
+ if (wdesc == None) return 0;
+
for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
frame = XCAR (tail);
@@ -475,6 +483,8 @@ x_top_window_to_frame (dpyinfo, wdesc)
struct frame *f;
struct x_output *x;
+ if (wdesc == None) return 0;
+
for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
frame = XCAR (tail);
@@ -1550,61 +1560,15 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
}
-/* Change the name of frame F to NAME. If NAME is nil, set F's name to
- x_id_name.
-
- If EXPLICIT is non-zero, that indicates that lisp code is setting the
- name; if NAME is a string, set F's name to NAME and set
- F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
-
- If EXPLICIT is zero, that indicates that Emacs redisplay code is
- suggesting a new name, which lisp code should override; if
- F->explicit_name is set, ignore the new name; otherwise, set it. */
+/* Set the WM name to NAME for frame F. Also set the icon name.
+ If the frame already has an icon name, use that, otherwise set the
+ icon name to NAME. */
-void
-x_set_name (f, name, explicit)
- struct frame *f;
+static void
+x_set_name_internal (f, name)
+ FRAME_PTR f;
Lisp_Object name;
- int explicit;
{
- /* Make sure that requests from lisp code override requests from
- Emacs redisplay code. */
- if (explicit)
- {
- /* If we're switching from explicit to implicit, we had better
- update the mode lines and thereby update the title. */
- if (f->explicit_name && NILP (name))
- update_mode_lines = 1;
-
- f->explicit_name = ! NILP (name);
- }
- else if (f->explicit_name)
- return;
-
- /* If NAME is nil, set the name to the x_id_name. */
- if (NILP (name))
- {
- /* Check for no change needed in this very common case
- before we do any consing. */
- if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
- SDATA (f->name)))
- return;
- name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
- }
- else
- CHECK_STRING (name);
-
- /* Don't change the name if it's already NAME. */
- if (! NILP (Fstring_equal (name, f->name)))
- return;
-
- f->name = name;
-
- /* For setting the frame title, the title parameter should override
- the name parameter. */
- if (! NILP (f->title))
- name = f->title;
-
if (FRAME_X_WINDOW (f))
{
BLOCK_INPUT;
@@ -1612,8 +1576,10 @@ x_set_name (f, name, explicit)
{
XTextProperty text, icon;
int bytes, stringp;
+ int do_free_icon_value = 0, do_free_text_value = 0;
Lisp_Object coding_system;
+ coding_system = Qcompound_text;
/* Note: Encoding strategy
We encode NAME by compound-text and use "COMPOUND-TEXT" in
@@ -1628,13 +1594,16 @@ x_set_name (f, name, explicit)
in the future which can encode all Unicode characters.
But, for the moment, there's no way to know that the
current window manager supports it or not. */
- coding_system = Qcompound_text;
text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
text.encoding = (stringp ? XA_STRING
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
text.format = 8;
text.nitems = bytes;
+ /* Check early, because ENCODE_UTF_8 below may GC and name may be
+ relocated. */
+ do_free_text_value = text.value != SDATA (name);
+
if (NILP (f->icon_name))
{
icon = text;
@@ -1648,20 +1617,21 @@ x_set_name (f, name, explicit)
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
icon.format = 8;
icon.nitems = bytes;
+ do_free_icon_value = icon.value != SDATA (f->icon_name);
}
+
#ifdef USE_GTK
gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
- SDATA (name));
+ SDATA (ENCODE_UTF_8 (name)));
#else /* not USE_GTK */
XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
#endif /* not USE_GTK */
XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
- if (!NILP (f->icon_name)
- && icon.value != (unsigned char *) SDATA (f->icon_name))
+ if (do_free_icon_value)
xfree (icon.value);
- if (text.value != (unsigned char *) SDATA (name))
+ if (do_free_text_value)
xfree (text.value);
}
#else /* not HAVE_X11R4 */
@@ -1674,6 +1644,64 @@ x_set_name (f, name, explicit)
}
}
+/* Change the name of frame F to NAME. If NAME is nil, set F's name to
+ x_id_name.
+
+ If EXPLICIT is non-zero, that indicates that lisp code is setting the
+ name; if NAME is a string, set F's name to NAME and set
+ F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
+
+ If EXPLICIT is zero, that indicates that Emacs redisplay code is
+ suggesting a new name, which lisp code should override; if
+ F->explicit_name is set, ignore the new name; otherwise, set it. */
+
+void
+x_set_name (f, name, explicit)
+ struct frame *f;
+ Lisp_Object name;
+ int explicit;
+{
+ /* Make sure that requests from lisp code override requests from
+ Emacs redisplay code. */
+ if (explicit)
+ {
+ /* If we're switching from explicit to implicit, we had better
+ update the mode lines and thereby update the title. */
+ if (f->explicit_name && NILP (name))
+ update_mode_lines = 1;
+
+ f->explicit_name = ! NILP (name);
+ }
+ else if (f->explicit_name)
+ return;
+
+ /* If NAME is nil, set the name to the x_id_name. */
+ if (NILP (name))
+ {
+ /* Check for no change needed in this very common case
+ before we do any consing. */
+ if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
+ SDATA (f->name)))
+ return;
+ name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
+ }
+ else
+ CHECK_STRING (name);
+
+ /* Don't change the name if it's already NAME. */
+ if (! NILP (Fstring_equal (name, f->name)))
+ return;
+
+ f->name = name;
+
+ /* For setting the frame title, the title parameter should override
+ the name parameter. */
+ if (! NILP (f->title))
+ name = f->title;
+
+ x_set_name_internal (f, name);
+}
+
/* This function should be called when the user's lisp code has
specified a name for the frame; the name will override any set by the
redisplay code. */
@@ -1725,62 +1753,7 @@ x_set_title (f, name, old_name)
else
CHECK_STRING (name);
- if (FRAME_X_WINDOW (f))
- {
- BLOCK_INPUT;
-#ifdef HAVE_X11R4
- {
- XTextProperty text, icon;
- int bytes, stringp;
- Lisp_Object coding_system;
-
- coding_system = Qcompound_text;
- /* See the comment "Note: Encoding strategy" in x_set_name. */
- text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
- text.encoding = (stringp ? XA_STRING
- : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
- text.format = 8;
- text.nitems = bytes;
-
- if (NILP (f->icon_name))
- {
- icon = text;
- }
- else
- {
- /* See the comment "Note: Encoding strategy" in x_set_name. */
- icon.value = x_encode_text (f->icon_name, coding_system, 0,
- &bytes, &stringp);
- icon.encoding = (stringp ? XA_STRING
- : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
- icon.format = 8;
- icon.nitems = bytes;
- }
-
-#ifdef USE_GTK
- gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
- SDATA (name));
-#else /* not USE_GTK */
- XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
-#endif /* not USE_GTK */
-
- XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
- &icon);
-
- if (!NILP (f->icon_name)
- && icon.value != (unsigned char *) SDATA (f->icon_name))
- xfree (icon.value);
- if (text.value != (unsigned char *) SDATA (name))
- xfree (text.value);
- }
-#else /* not HAVE_X11R4 */
- XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- SDATA (name));
- XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- SDATA (name));
-#endif /* not HAVE_X11R4 */
- UNBLOCK_INPUT;
- }
+ x_set_name_internal (f, name);
}
void
@@ -2633,6 +2606,28 @@ x_window (f)
#endif /* not USE_GTK */
#endif /* not USE_X_TOOLKIT */
+/* Verify that the icon position args for this window are valid. */
+
+static void
+x_icon_verify (f, parms)
+ struct frame *f;
+ Lisp_Object parms;
+{
+ Lisp_Object icon_x, icon_y;
+
+ /* Set the position of the icon. Note that twm groups all
+ icons in an icon window. */
+ icon_x = x_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
+ icon_y = x_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
+ if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
+ {
+ CHECK_NUMBER (icon_x);
+ CHECK_NUMBER (icon_y);
+ }
+ else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
+ error ("Both left and top icon corners of icon must be specified");
+}
+
/* Handle the icon stuff for this window. Perhaps later we might
want an x_set_icon_position which can be called interactively as
well. */
@@ -3117,6 +3112,8 @@ This function is an internal primitive--use `make-frame' instead. */)
tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
f->no_split = minibuffer_only || EQ (tem, Qt);
+ x_icon_verify (f, parms);
+
/* Create the X widget or window. */
#ifdef USE_X_TOOLKIT
x_window (f, window_prompting, minibuffer_only);
diff --git a/src/xmenu.c b/src/xmenu.c
index 473e29de88d..7f6e7c398a9 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1701,12 +1701,9 @@ digest_single_submenu (start, end, top_level_items)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
- /* Ignore the @ that means "separate pane".
- This is a kludge, but this isn't worth more time. */
- if (!NILP (prefix) && wv->name[0] == '@')
- wv->name++;
- wv->value = 0;
+ wv->lname = pane_name;
+ /* Set value to 1 so update_submenu_strings can handle '@' */
+ wv->value = (char *)1;
wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
wv->help = Qnil;
@@ -1749,9 +1746,9 @@ digest_single_submenu (start, end, top_level_items)
else
save_wv->contents = wv;
- wv->name = (char *) SDATA (item_name);
+ wv->lname = item_name;
if (!NILP (descrip))
- wv->key = (char *) SDATA (descrip);
+ wv->lkey = descrip;
wv->value = 0;
/* The EMACS_INT cast avoids a warning. There's no problem
as long as pointers have enough bits to hold small integers. */
@@ -1790,6 +1787,42 @@ digest_single_submenu (start, end, top_level_items)
return first_wv;
}
+
+/* Walk through the widget_value tree starting at FIRST_WV and update
+ the char * pointers from the corresponding lisp values.
+ We do this after building the whole tree, since GC may happen while the
+ tree is constructed, and small strings are relocated. So we must wait
+ until no GC can happen before storing pointers into lisp values. */
+static void
+update_submenu_strings (first_wv)
+ widget_value *first_wv;
+{
+ widget_value *wv;
+
+ for (wv = first_wv; wv; wv = wv->next)
+ {
+ if (wv->lname && ! NILP (wv->lname))
+ {
+ wv->name = SDATA (wv->lname);
+
+ /* Ignore the @ that means "separate pane".
+ This is a kludge, but this isn't worth more time. */
+ if (wv->value == (char *)1)
+ {
+ if (wv->name[0] == '@')
+ wv->name++;
+ wv->value = 0;
+ }
+ }
+
+ if (wv->lkey && ! NILP (wv->lkey))
+ wv->key = SDATA (wv->lkey);
+
+ if (wv->contents)
+ update_submenu_strings (wv->contents);
+ }
+}
+
/* Recompute all the widgets of frame F, when the menu bar has been
changed. Value is non-zero if widgets were updated. */
@@ -2022,9 +2055,10 @@ set_frame_menubar (f, first_time, deep_p)
Lisp_Object string;
string = XVECTOR (items)->contents[i + 1];
if (NILP (string))
- break;
- wv->name = (char *) SDATA (string);
- wv = wv->next;
+ break;
+ wv->name = (char *) SDATA (string);
+ update_submenu_strings (wv->contents);
+ wv = wv->next;
}
f->menu_bar_vector = menu_items;
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)
secs = x_selection_timeout / 1000;
usecs = (x_selection_timeout % 1000) * 1000;
TRACE2 (" Waiting %d secs, %d usecs", secs, usecs);
- wait_reading_process_input (secs, usecs, property_change_reply, 0);
+ wait_reading_process_output (secs, usecs, 0, 0,
+ property_change_reply, NULL, 0);
if (NILP (XCAR (property_change_reply)))
{
@@ -1288,7 +1289,8 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
secs = x_selection_timeout / 1000;
usecs = (x_selection_timeout % 1000) * 1000;
TRACE1 (" Start waiting %d secs for SelectionNotify", secs);
- wait_reading_process_input (secs, usecs, reading_selection_reply, 0);
+ wait_reading_process_output (secs, usecs, 0, 0,
+ reading_selection_reply, NULL, 0);
TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply)));
BLOCK_INPUT;
diff --git a/src/xterm.c b/src/xterm.c
index 593716032e1..c1bfd11985e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6174,7 +6174,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
f = x_top_window_to_frame (dpyinfo, event.xmap.window);
if (f)
{
- /* wait_reading_process_input will notice this and update
+ /* wait_reading_process_output will notice this and update
the frame's display structures.
If we where iconified, we should not set garbaged,
because that stops redrawing on Expose events. This looks
@@ -7604,11 +7604,13 @@ static Lisp_Object
x_catch_errors_unwind (old_val)
Lisp_Object old_val;
{
- Lisp_Object first;
+ Lisp_Object first = XCAR (old_val);
+ Display *dpy = XSAVE_VALUE (first)->pointer;
- first = XCAR (old_val);
-
- XSync (XSAVE_VALUE (first)->pointer, False);
+ /* The display may have been closed before this function is called.
+ Check if it is still open before calling XSync. */
+ if (x_display_info_for_display (dpy) != 0)
+ XSync (dpy, False);
x_error_message_string = XCDR (old_val);
return Qnil;