aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2013-04-05 23:17:55 +0900
committerKenichi Handa2013-04-05 23:17:55 +0900
commitb7a6f9f7919b7fc0871ae768b58f8e746aa7dd9f (patch)
treef32c8cce416e346d2953f063a0f22e95382cf57e /src
parent251e91474c91e16b101502c2ed7c05fc13e4ecea (diff)
parent73931ad14ad7a51d91f10b19ae9ca8cadb256916 (diff)
downloademacs-b7a6f9f7919b7fc0871ae768b58f8e746aa7dd9f.tar.gz
emacs-b7a6f9f7919b7fc0871ae768b58f8e746aa7dd9f.zip
merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog405
-rw-r--r--src/ChangeLog.102
-rw-r--r--src/alloc.c118
-rw-r--r--src/blockinput.h2
-rw-r--r--src/buffer.c26
-rw-r--r--src/bytecode.c4
-rw-r--r--src/callproc.c8
-rw-r--r--src/casetab.c12
-rw-r--r--src/ccl.c2
-rw-r--r--src/cm.c4
-rw-r--r--src/dired.c14
-rw-r--r--src/dispextern.h31
-rw-r--r--src/dispnew.c127
-rw-r--r--src/editfns.c15
-rw-r--r--src/emacsgtkfixed.c2
-rw-r--r--src/fileio.c9
-rw-r--r--src/floatfns.c4
-rw-r--r--src/font.c4
-rw-r--r--src/fontset.c8
-rw-r--r--src/fontset.h3
-rw-r--r--src/frame.c62
-rw-r--r--src/frame.h9
-rw-r--r--src/fringe.c12
-rw-r--r--src/ftfont.c6
-rw-r--r--src/gtkutil.c4
-rw-r--r--src/image.c42
-rw-r--r--src/indent.c27
-rw-r--r--src/insdel.c2
-rw-r--r--src/intervals.c54
-rw-r--r--src/keyboard.c42
-rw-r--r--src/keymap.c9
-rw-r--r--src/lisp.h171
-rw-r--r--src/lread.c12
-rw-r--r--src/makefile.w32-in2
-rw-r--r--src/menu.c5
-rw-r--r--src/minibuf.c4
-rw-r--r--src/msdos.c8
-rw-r--r--src/nsfns.m67
-rw-r--r--src/nsmenu.m53
-rw-r--r--src/nsselect.m14
-rw-r--r--src/nsterm.h4
-rw-r--r--src/nsterm.m104
-rw-r--r--src/print.c81
-rw-r--r--src/process.c31
-rw-r--r--src/profiler.c4
-rw-r--r--src/regex.c6
-rw-r--r--src/regex.h2
-rw-r--r--src/search.c10
-rw-r--r--src/sysdep.c6
-rw-r--r--src/systime.h2
-rw-r--r--src/term.c2
-rw-r--r--src/textprop.c3
-rw-r--r--src/unexcw.c17
-rw-r--r--src/w32.c20
-rw-r--r--src/w32fns.c31
-rw-r--r--src/w32menu.c4
-rw-r--r--src/w32term.c60
-rw-r--r--src/w32term.h14
-rw-r--r--src/window.c489
-rw-r--r--src/window.h63
-rw-r--r--src/xdisp.c282
-rw-r--r--src/xfaces.c33
-rw-r--r--src/xfns.c27
-rw-r--r--src/xmenu.c8
-rw-r--r--src/xselect.c6
-rw-r--r--src/xterm.c10
-rw-r--r--src/xterm.h4
67 files changed, 1618 insertions, 1110 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6b3ca9d3ff3..70e342dfb2f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -18,6 +18,407 @@
18 18
19 * insdel.c (insert_from_gap): Fix previous change. 19 * insdel.c (insert_from_gap): Fix previous change.
20 20
212013-04-05 Dmitry Antipov <dmantipov@yandex.ru>
22
23 Consistently use platform-specific function to detect window system.
24 * lisp.h (check_window_system): New prototype. This function is
25 going to replace check_x, check_w32 and check_ns.
26 (have_menus_p): Mention msdos.c in comment.
27 * fontset.c (check_window_system_func): Remove. Adjust all users.
28 * fontset.h (check_window_system_func): Remove prototype.
29 * nsterm.h (check_ns):
30 * xterm.h (check_x):
31 * w32term.h (check_w32): Likewise.
32 * menu.c (Fx_popup_menu): Use check_window_system.
33 * msdos.c (check_window_system): Define for MS-DOS.
34 * nsfns.m (check_window_system): Define for NS. Adjust all users.
35 * w32fns.c (check_window_system): Likewise for MS-Windows.
36 * xfns.c (check_window_system): Likewise for X.
37 * font.c, frame.c, nsmenu.m, nsselect.m, nsterm.m, w32menu.c:
38 * xfaces.c, xmenu.c: Use check_window_system where appropriate.
39
402013-04-02 Paul Eggert <eggert@cs.ucla.edu>
41
42 Prefer < to > in range checks such as 0 <= i && i < N.
43 This makes it easier to visualize quantities on a number line.
44 This patch doesn't apply to all such range checks,
45 only to the range checks affected by the 2013-03-24 change.
46 This patch reverts most of the 2013-03-24 change.
47 * alloc.c (xpalloc, Fgarbage_collect):
48 * ccl.c (ccl_driver, resolve_symbol_ccl_program):
49 * character.c (string_escape_byte8):
50 * charset.c (read_hex):
51 * data.c (cons_to_unsigned):
52 * dispnew.c (update_frame_1):
53 * doc.c (Fsubstitute_command_keys):
54 * doprnt.c (doprnt):
55 * editfns.c (hi_time, decode_time_components):
56 * fileio.c (file_offset):
57 * fns.c (larger_vector, make_hash_table, Fmake_hash_table):
58 * font.c (font_intern_prop):
59 * frame.c (x_set_alpha):
60 * gtkutil.c (get_utf8_string):
61 * indent.c (check_display_width):
62 * keymap.c (Fkey_description):
63 * lisp.h (FIXNUM_OVERFLOW_P, vcopy):
64 * lread.c (read1):
65 * minibuf.c (read_minibuf_noninteractive):
66 * process.c (wait_reading_process_output):
67 * search.c (Freplace_match):
68 * window.c (get_phys_cursor_glyph):
69 * xdisp.c (redisplay_internal):
70 * xsmfns.c (smc_save_yourself_CB):
71 Prefer < to > for range checks.
72 * dispnew.c (sit_for): Don't mishandle NaNs.
73 This fixes a bug introduced in the 2013-03-24 change.
74 * editfns.c (decode_time_components): Don't hoist comparison.
75 This fixes another bug introduced in the 2013-03-24 change.
76
772013-03-31 Dmitry Antipov <dmantipov@yandex.ru>
78
79 * frame.h (struct frame): Drop scroll_bottom_vpos
80 member becaue all real users are dead long ago.
81 (FRAME_SCROLL_BOTTOM_VPOS): Remove.
82 * xdisp.c (redisplay_internal): Adjust user.
83
842013-03-30 Darren Ho <darren.hoo@gmail.com> (tiny change)
85
86 * nsmenu.m (showAtX:Y:for:): setLevel to
87 NSPopUpMenuWindowLevel (Bug#13998).
88
892013-03-30 Jan Djärv <jan.h.d@swipnet.se>
90
91 * nsterm.h (ns_get_pending_menu_title, ns_check_menu_open)
92 (ns_check_pending_open_menu): Declare.
93
94 * nsmenu.m (ns_update_menubar): Correct NSTRACE.
95 (x_activate_menubar): Update the menu with title that matches
96 ns_get_pending_menu_title, and call
97 ns_check_pending_openmenu (Bug#12698).
98 (menuWillOpen:): New method.
99 (menuNeedsUpdate:): Add check for ! COCOA || OSX < 10.5 (Bug#12698).
100
101 * nsterm.m (menu_will_open_state, menu_mouse_point)
102 (menu_pending_title): New varaibles.
103 (ns_get_pending_menu_title, ns_check_menu_open)
104 (ns_check_pending_open_menu): New functions.
105
1062013-03-29 Dmitry Antipov <dmantipov@yandex.ru>
107
108 * indent.c (current_column_bol_cache): Remove leftover which is not
109 used in Fmove_to_column any more.
110 (current_column, scan_for_column): Adjust users.
111 * keyboard.c (last_point_position_buffer, last_point_position_window):
112 Remove leftovers which are not used for recording undo any more.
113 (command_loop_1, syms_of_keyboard): Adjust users.
114 * xdisp.c (last_max_ascent): Remove leftover which is not used in
115 redisplay_window any more.
116 (move_it_to): Adjust user.
117
1182013-03-29 Juanma Barranquero <lekktu@gmail.com>
119
120 * makefile.w32-in ($(BLD)/filelock.$(O), $(BLD)/filelock.$(O)):
121 Update dependencies.
122
1232013-03-28 Stefan Monnier <monnier@iro.umontreal.ca>
124
125 * lisp.h (save_type, XSAVE_POINTER, set_save_pointer, XSAVE_INTEGER)
126 (set_save_integer, XSAVE_OBJECT, XSAVE_VALUE): Move to avoid
127 forward references.
128
1292013-03-28 Dmitry Antipov <dmantipov@yandex.ru>
130
131 * window.h (struct window): Replace hchild, vchild and buffer slots
132 with the only contents slot. This is possible because each valid
133 window may have either the child window (in vertical or horizontal
134 combination) or buffer to display (for the leaf window). Using that,
135 a lof of operations to traverse and/or change window hierarchies may
136 be simplified. New member horizontal is used to distinguish between
137 horizontal and vertical combinations of internal windows.
138 (WINDOW_LEAF_P, WINDOW_HORIZONTAL_COMBINATION_P)
139 (WINDOW_VERTICAL_COMBINATION_P): New macros.
140 (WINDOW_VALID_P, WINDOW_LIVE_P): Adjust to match struct window changes.
141 * window.c (wset_hchild, wset_vchild): Remove. Adjust all users.
142 Use contents slot, not buffer, where appropriate.
143 (wset_combination): New function.
144 (wset_buffer): Add eassert.
145 (Fframe_first_window): Simplify the loop reaching first window.
146 (Fwindow_buffer): Use WINDOW_LEAF_P.
147 (Fwindow_top_child): Use WINDOW_VERTICAL_COMBINATION_P.
148 (Fwindow_left_child): Use WINDOW_HORIZONTAL_COMBINATION_P.
149 (unshow_buffer): Convert initial debugging check to eassert.
150 (replace_window, recombine_windows, Fdelete_other_windows_internal)
151 (make_parent_window, window_resize_check, window_resize_apply)
152 (resize_frame_windows, Fsplit_window_internal, Fdelete_window_internal)
153 (Fset_window_configuration, delete_all_child_windows, save_window_save):
154 Adjust to match struct window changes.
155 (window_loop): Check for broken markers in CHECK_ALL_WINDOWS.
156 (mark_window_cursors_off, count_windows, get_leaf_windows)
157 (foreach_window_1): Simplify the loop.
158 * alloc.c (mark_object): Do not check for the leaf window because
159 internal windows has no glyph matrices anyway.
160 * dispnew.c (clear_window_matrices, showing_window_margins_p)
161 (allocate_matrices_for_window_redisplay, fake_current_matrices)
162 (allocate_matrices_for_frame_redisplay, free_window_matrices)
163 (build_frame_matrix_from_window_tree, mirror_make_current)
164 (frame_row_to_window, mirror_line_dance, check_window_matrix_pointers)
165 (update_window_tree, set_window_update_flags): Simplify the loop.
166 (sync_window_with_frame_matrix_rows): Enforce live window.
167 Use contents slot, not buffer, where appropriate.
168 * frame.c (set_menu_bar_lines_1): Use WINDOW_VERTICAL_COMBINATION_P
169 and WINDOW_HORIZONTAL_COMBINATION_P.
170 (make_frame_visible_1): Simplify the loop.
171 Use contents slot, not buffer, where appropriate.
172 * xdisp.c (hscroll_window_tree, mark_window_display_accurate)
173 (redisplay_windows, redisplay_mode_lines, update_cursor_in_window_tree)
174 (expose_window_tree): Likewise.
175 Use contents slot, not buffer, where appropriate.
176 * textprop.c (get_char_property_and_overlay): Add CHECK_LIVE_WINDOW
177 to avoid deleted windows. Use contents slot instead of buffer.
178 * buffer.c, dispextern.h, editfns.c, fileio.c, font.c, fringe.c:
179 * indent.c, insdel.c, keyboard.c, keymap.c, minibuf.c, msdos.c:
180 * nsfns.m, nsmenu.m, nsterm.m, print.c, w32fns.c, w32menu.c, xfaces.c:
181 * xfns.c, xmenu.c: Use contents slot, not buffer, where appropriate.
182
1832013-03-28 Eli Zaretskii <eliz@gnu.org>
184
185 * w32fns.c (w32_wnd_proc) [ENABLE_CHECKING]: Add code to help
186 identify the reasons for assertion violations in bug#14062 and
187 similar ones.
188 (Fx_show_tip): Fix compilation error under
189 "--enable-check-lisp-object-type". (Bug#14073)
190
191 * image.c (g_error_free) [WINDOWSNT]: Add DEF_IMGLIB_FN.
192 Reported by <rzl24ozi@gmail.com>.
193
1942013-03-28 Dmitry Antipov <dmantipov@yandex.ru>
195
196 * xdisp.c (with_echo_area_buffer_unwind_data): Save window
197 start marker...
198 (unwind_with_echo_area_buffer): ...to restore it here. This
199 is needed to ensure that...
200 (redisplay_window): ...both window markers are valid here,
201 which is verified by eassert.
202 * editfns.c (save_excursion_save): Do not assume that
203 selected_window always displays the buffer.
204 * buffer.c (Fbuffer_swap_text): Adjust window start markers.
205 Fix comment.
206
2072013-03-27 Stefan Monnier <monnier@iro.umontreal.ca>
208
209 * casetab.c (init_casetab_once): Don't abuse the ascii eqv table for
210 the upcase table.
211
2122013-03-27 rzl24ozi <rzl24ozi@gmail.com> (tiny changes)
213
214 * image.c [WINDOWSNT]: Fix calls to DEF_IMGLIB_FN for SVG function.
215
2162013-03-27 Eli Zaretskii <eliz@gnu.org>
217
218 * w32proc.c (IsValidLocale) [__GNUC__]: Don't declare prototype,
219 since MinGW's w32api headers do. This avoids compiler warnings.
220
221 * w32.c (FSCTL_GET_REPARSE_POINT) [_MSC_VER || _W64]: Don't define
222 if already defined.
223
2242013-03-26 Eli Zaretskii <eliz@gnu.org>
225
226 * w32.c (_REPARSE_DATA_BUFFER): Condition by _MSVC and _W64.
227
2282013-03-26 Jan Djärv <jan.h.d@swipnet.se>
229
230 * gtkutil.c (style_changed_cb): Check if frame is live and an
231 X frame (Bug#14038).
232
2332013-03-26 Eli Zaretskii <eliz@gnu.org>
234
235 * w32.c (_PROCESS_MEMORY_COUNTERS_EX) [_WIN32_WINNT < 0x0500]:
236 Define only for _WIN32_WINNT less than 0x0500.
237 (_ANONYMOUS_UNION, _ANONYMOUS_STRUCT) [!_W64]: Don't define for
238 MinGW64.
239 Move inclusion of time.h before sys/time.h, so that MinGW64 could
240 see its own definitions of 'struct timeval' and 'struct timezone'.
241
242 Fix incompatibilities between MinGW.org and MinGW64 headers.
243 * w32term.c (WCRANGE, GLYPHSET): Don't define if _W64 is defined.
244
245 * w32.c (REPARSE_DATA_BUFFER): Guard with
246 MAXIMUM_REPARSE_DATA_BUFFER_SIZE being defined.
247
2482013-03-25 Jan Djärv <jan.h.d@swipnet.se>
249
250 * xterm.c: Include X11/XKBlib.h
251 (XTring_bell): Use XkbBell if HAVE_XKB (Bug#14041).
252
2532013-03-24 Andreas Schwab <schwab@linux-m68k.org>
254
255 * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are
256 written backwards.
257 * blockinput.h (input_blocked_p): Likewise.
258 * bytecode.c (exec_byte_code): Likewise.
259 * callproc.c (call_process_kill, call_process_cleanup)
260 (Fcall_process): Likewise.
261 * ccl.c (ccl_driver, resolve_symbol_ccl_program)
262 (Fccl_execute_on_string): Likewise.
263 * character.c (string_escape_byte8): Likewise.
264 * charset.c (read_hex): Likewise.
265 * cm.c (calccost): Likewise.
266 * data.c (cons_to_unsigned): Likewise.
267 * dired.c (directory_files_internal, file_name_completion):
268 Likewise.
269 * dispnew.c (scrolling_window, update_frame_1, Fsleep_for)
270 (sit_for): Likewise.
271 * doc.c (Fsubstitute_command_keys): Likewise.
272 * doprnt.c (doprnt): Likewise.
273 * editfns.c (hi_time, decode_time_components, Fformat): Likewise.
274 * emacsgtkfixed.c: Likewise.
275 * fileio.c (file_offset, Fwrite_region): Likewise.
276 * floatfns.c (Fexpt, fmod_float): Likewise.
277 * fns.c (larger_vector, make_hash_table, Fmake_hash_table):
278 Likewise.
279 * font.c (font_intern_prop): Likewise.
280 * frame.c (x_set_alpha): Likewise.
281 * gtkutil.c (get_utf8_string): Likewise.
282 * indent.c (check_display_width): Likewise.
283 * intervals.c (create_root_interval, rotate_right, rotate_left)
284 (split_interval_right, split_interval_left)
285 (adjust_intervals_for_insertion, delete_node)
286 (interval_deletion_adjustment, adjust_intervals_for_deletion)
287 (merge_interval_right, merge_interval_left, copy_intervals)
288 (set_intervals_multibyte_1): Likewise.
289 * keyboard.c (gobble_input, append_tool_bar_item): Likewise.
290 * keymap.c (Fkey_description): Likewise.
291 * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise.
292 * lread.c (openp, read_integer, read1, string_to_number):
293 Likewise.
294 * menu.c (ensure_menu_items): Likewise.
295 * minibuf.c (read_minibuf_noninteractive): Likewise.
296 * print.c (printchar, strout): Likewise.
297 * process.c (create_process, Faccept_process_output)
298 (wait_reading_process_output, read_process_output, send_process)
299 (wait_reading_process_output): Likewise.
300 * profiler.c (make_log, handle_profiler_signal): Likewise.
301 * regex.c (re_exec): Likewise.
302 * regex.h: Likewise.
303 * search.c (looking_at_1, Freplace_match): Likewise.
304 * sysdep.c (get_child_status, procfs_ttyname)
305 (procfs_get_total_memory): Likewise.
306 * systime.h (EMACS_TIME_VALID_P): Likewise.
307 * term.c (dissociate_if_controlling_tty): Likewise.
308 * window.c (get_phys_cursor_glyph): Likewise.
309 * xdisp.c (init_iterator, redisplay_internal, redisplay_window)
310 (try_window_reusing_current_matrix, try_window_id, pint2hrstr):
311 Likewise.
312 * xfns.c (Fx_window_property): Likewise.
313 * xmenu.c (set_frame_menubar): Likewise.
314 * xselect.c (x_get_window_property, x_handle_dnd_message):
315 Likewise.
316 * xsmfns.c (smc_save_yourself_CB): Likewise.
317 * xterm.c (x_scroll_bar_set_handle): Likewise.
318
3192013-03-24 Dmitry Antipov <dmantipov@yandex.ru>
320
321 * xfaces.c (Finternal_face_x_get_resource): Allow 3rd (frame) argument
322 to be optional or nil. Adjust comment and convert it to docstring.
323 * xselect.c (Fx_send_client_event): Rename to Fx_send_client_message.
324 * frame.c (display_x_get_resource, Fx_get_resource): Break long line.
325
3262013-03-24 Paul Eggert <eggert@cs.ucla.edu>
327
328 Static checking by GCC 4.8-20130319.
329 * image.c (gif_load): Assume pass < 3 to pacify GCC.
330 * process.c (Fset_process_datagram_address)
331 (Fmake_network_process): Check get_lisp_to_sockaddr_size return value.
332 * xdisp.c (get_char_face_and_encoding):
333 (get_glyph_face_and_encoding): Ensure that *CHAR2B is initialized.
334 (get_glyph_face_and_encoding): Prepare face before possibly using it.
335 (get_per_char_metric): Don't use CHAR2B if it might not be initialized.
336
3372013-03-24 Ken Brown <kbrown@cornell.edu>
338
339 * w32fns.c (emacs_abort) [CYGWIN]: Define `_open' as a macro to
340 fix compilation on 64-bit Cygwin, where underscores are not
341 automatically prepended.
342
343 * w32term.c (w32_initialize): Silence compiler warning.
344
3452013-03-23 Eli Zaretskii <eliz@gnu.org>
346
347 * w32term.c (w32fullscreen_hook): Use FRAME_NORMAL_WIDTH,
348 FRAME_NORMAL_HEIGHT, and FRAME_PREV_FSMODE, instead of static
349 variables, to save and restore frame dimensions. Use
350 FRAME_NORMAL_LEFT and FRAME_NORMAL_TOP to restore frame position
351 after returning from a 'fullscreen' configuration. use
352 SendMessage instead of PostMessage to send the SC_RESTORE message,
353 to avoid races between the main thread and the input thread.
354
355 * w32term.h (struct w32_output): New members normal_width,
356 normal_height, normal_top, normal_left, and prev_fsmode.
357 (FRAME_NORMAL_WIDTH, FRAME_NORMAL_HEIGHT, FRAME_NORMAL_TOP)
358 (FRAME_NORMAL_LEFT, FRAME_PREV_FSMODE): New macros to access these
359 members of a frame.
360
361 * w32term.c (w32fullscreen_hook): Record last value of the frame's
362 'fullscreen' parameter. Always record previous width and height
363 of the frame, except when switching out of maximized modes, so
364 that they could be restored correctly, instead of resetting to the
365 default frame dimensions. Send SC_RESTORE command to the frame,
366 unless we are going to send SC_MAXIMIZE, to restore the frame
367 resize hints in the mouse pointer shown by the window manager.
368 (Bug#14032)
369
370 * frame.c (get_frame_param): Now extern for WINDOWSNT as well.
371
372 * lisp.h (get_frame_param): Adjust conditions for prototype
373 declaration.
374
3752013-03-22 Ken Brown <kbrown@cornell.edu>
376
377 * unexcw.c: Drop unneeded inclusion of w32common.h.
378 (report_sheap_usage): Declare.
379 (read_exe_header): Add magic numbers for x86_64.
380 (fixup_executable): Fix printf format specifier for unsigned long
381 argument.
382
3832013-03-22 Dmitry Antipov <dmantipov@yandex.ru>
384
385 * frame.h (struct frame): Put menu_bar_window under #ifdef
386 because this member is not needed when X toolkit is in use.
387 (fset_menu_bar_window):
388 * dispnew.c (clear_current_matrices, clear_desired_matrices)
389 (free_glyphs, update_frame):
390 * xdisp.c (expose_frame): Likewise.
391 (display_menu_bar): Likewise. Remove redundant eassert.
392 * window.h (WINDOW_MENU_BAR_P): Always define to 0 if X
393 toolkit is in use.
394
3952013-03-21 Paul Eggert <eggert@cs.ucla.edu>
396
397 Use functions and constants to manipulate Lisp_Save_Value objects.
398 This replaces code that used macros and strings and token-pasting.
399 The change makes the C source a bit easier to follow,
400 and shrinks the Emacs executable a bit.
401 * alloc.c: Verify some properties of Lisp_Save_Value's representation.
402 (make_save_value): Change 1st arg from string to enum. All callers
403 changed.
404 (INTX): Remove.
405 (mark_object): Use if, not #if, for GC_MARK_STACK.
406 * lisp.h (SAVE_VALUEP, XSAVE_VALUE, XSAVE_POINTER, XSAVE_INTEGER)
407 (XSAVE_OBJECT): Now functions, not macros.
408 (STRING_BYTES_BOUND): Now just a macro, not a constant too;
409 the constant was never used.
410 (SAVE_SLOT_BITS, SAVE_VALUE_SLOTS, SAVE_TYPE_BITS, SAVE_TYPE_INT_INT)
411 (SAVE_TYPE_INT_INT_INT, SAVE_TYPE_OBJ_OBJ, SAVE_TYPE_OBJ_OBJ_OBJ)
412 (SAVE_TYPE_OBJ_OBJ_OBJ_OBJ, SAVE_TYPE_PTR_INT, SAVE_TYPE_PTR_OBJ)
413 (SAVE_TYPE_PTR_PTR, SAVE_TYPE_PTR_PTR_OBJ, SAVE_TYPE_MEMORY):
414 New constants.
415 (struct Lisp_Save_Value): Replace members area, type0, type1, type2,
416 type3 with a single member save_type. All uses changed.
417 (save_type, set_save_pointer, set_save_integer): New functions.
418 * print.c (PRINTX): Remove.
419
420 * alloc.c: Remove redundant static declarations.
421
212013-03-20 Dmitry Antipov <dmantipov@yandex.ru> 4222013-03-20 Dmitry Antipov <dmantipov@yandex.ru>
22 423
23 * window.h (struct window): Convert left_col, top_line, total_lines 424 * window.h (struct window): Convert left_col, top_line, total_lines
@@ -5190,8 +5591,8 @@
5190 a public macro and no need to inline by hand. 5591 a public macro and no need to inline by hand.
5191 5592
51922012-09-26 Tomohiro Matsuyama <tomo@cx4a.org> 55932012-09-26 Tomohiro Matsuyama <tomo@cx4a.org>
5193 Stefan Monnier <monnier@iro.umontreal.ca> 5594 Stefan Monnier <monnier@iro.umontreal.ca>
5194 Juanma Barranquero <lekktu@gmail.com> 5595 Juanma Barranquero <lekktu@gmail.com>
5195 5596
5196 * profiler.c: New file. 5597 * profiler.c: New file.
5197 * Makefile.in (base_obj): Add profiler.o. 5598 * Makefile.in (base_obj): Add profiler.o.
diff --git a/src/ChangeLog.10 b/src/ChangeLog.10
index 508a2a9dd4c..57c1cbf1299 100644
--- a/src/ChangeLog.10
+++ b/src/ChangeLog.10
@@ -1865,7 +1865,7 @@
1865 1865
18662006-10-07 Ralf Angeli <angeli@caeruleus.net> 18662006-10-07 Ralf Angeli <angeli@caeruleus.net>
1867 1867
1868 * w32fns.c (w32_createwindow): Honour left and top positions if 1868 * w32fns.c (w32_createwindow): Honor left and top positions if
1869 supplied explicitly. 1869 supplied explicitly.
1870 1870
18712006-10-06 Kim F. Storm <storm@cua.dk> 18712006-10-06 Kim F. Storm <storm@cua.dk>
diff --git a/src/alloc.c b/src/alloc.c
index 5e30c1b20ad..7a56c78e2ba 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -323,20 +323,7 @@ static void *min_heap_address, *max_heap_address;
323static struct mem_node mem_z; 323static struct mem_node mem_z;
324#define MEM_NIL &mem_z 324#define MEM_NIL &mem_z
325 325
326static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t);
327static void lisp_free (void *);
328static void mark_stack (void);
329static bool live_vector_p (struct mem_node *, void *);
330static bool live_buffer_p (struct mem_node *, void *);
331static bool live_string_p (struct mem_node *, void *);
332static bool live_cons_p (struct mem_node *, void *);
333static bool live_symbol_p (struct mem_node *, void *);
334static bool live_float_p (struct mem_node *, void *);
335static bool live_misc_p (struct mem_node *, void *);
336static void mark_maybe_object (Lisp_Object);
337static void mark_memory (void *, void *);
338#if GC_MARK_STACK || defined GC_MALLOC_CHECK 326#if GC_MARK_STACK || defined GC_MALLOC_CHECK
339static void mem_init (void);
340static struct mem_node *mem_insert (void *, void *, enum mem_type); 327static struct mem_node *mem_insert (void *, void *, enum mem_type);
341static void mem_insert_fixup (struct mem_node *); 328static void mem_insert_fixup (struct mem_node *);
342static void mem_rotate_left (struct mem_node *); 329static void mem_rotate_left (struct mem_node *);
@@ -346,11 +333,6 @@ static void mem_delete_fixup (struct mem_node *);
346static struct mem_node *mem_find (void *); 333static struct mem_node *mem_find (void *);
347#endif 334#endif
348 335
349
350#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS
351static void check_gcpros (void);
352#endif
353
354#endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ 336#endif /* GC_MARK_STACK || GC_MALLOC_CHECK */
355 337
356#ifndef DEADP 338#ifndef DEADP
@@ -3344,56 +3326,50 @@ free_misc (Lisp_Object misc)
3344 total_free_markers++; 3326 total_free_markers++;
3345} 3327}
3346 3328
3329/* Verify properties of Lisp_Save_Value's representation
3330 that are assumed here and elsewhere. */
3331
3332verify (SAVE_UNUSED == 0);
3333verify ((SAVE_INTEGER | SAVE_POINTER | SAVE_OBJECT) >> SAVE_SLOT_BITS == 0);
3334
3347/* Return a Lisp_Save_Value object with the data saved according to 3335/* Return a Lisp_Save_Value object with the data saved according to
3348 FMT. Format specifiers are `i' for an integer, `p' for a pointer 3336 DATA_TYPE. DATA_TYPE should be one of SAVE_TYPE_INT_INT, etc. */
3349 and `o' for Lisp_Object. Up to 4 objects can be specified. */
3350 3337
3351Lisp_Object 3338Lisp_Object
3352make_save_value (const char *fmt, ...) 3339make_save_value (enum Lisp_Save_Type save_type, ...)
3353{ 3340{
3354 va_list ap; 3341 va_list ap;
3355 int len = strlen (fmt); 3342 int i;
3356 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); 3343 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3357 struct Lisp_Save_Value *p = XSAVE_VALUE (val); 3344 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3358 3345
3359 eassert (0 < len && len < 5); 3346 eassert (0 < save_type
3360 va_start (ap, fmt); 3347 && (save_type < 1 << (SAVE_TYPE_BITS - 1)
3361 3348 || save_type == SAVE_TYPE_MEMORY));
3362#define INITX(index) \ 3349 p->save_type = save_type;
3363 do { \ 3350 va_start (ap, save_type);
3364 if (len <= index) \ 3351 save_type &= ~ (1 << (SAVE_TYPE_BITS - 1));
3365 p->type ## index = SAVE_UNUSED; \ 3352
3366 else \ 3353 for (i = 0; save_type; i++, save_type >>= SAVE_SLOT_BITS)
3367 { \ 3354 switch (save_type & ((1 << SAVE_SLOT_BITS) - 1))
3368 if (fmt[index] == 'i') \ 3355 {
3369 { \ 3356 case SAVE_POINTER:
3370 p->type ## index = SAVE_INTEGER; \ 3357 p->data[i].pointer = va_arg (ap, void *);
3371 p->data[index].integer = va_arg (ap, ptrdiff_t); \ 3358 break;
3372 } \
3373 else if (fmt[index] == 'p') \
3374 { \
3375 p->type ## index = SAVE_POINTER; \
3376 p->data[index].pointer = va_arg (ap, void *); \
3377 } \
3378 else if (fmt[index] == 'o') \
3379 { \
3380 p->type ## index = SAVE_OBJECT; \
3381 p->data[index].object = va_arg (ap, Lisp_Object); \
3382 } \
3383 else \
3384 emacs_abort (); \
3385 } \
3386 } while (0)
3387 3359
3388 INITX (0); 3360 case SAVE_INTEGER:
3389 INITX (1); 3361 p->data[i].integer = va_arg (ap, ptrdiff_t);
3390 INITX (2); 3362 break;
3391 INITX (3);
3392 3363
3393#undef INITX 3364 case SAVE_OBJECT:
3365 p->data[i].object = va_arg (ap, Lisp_Object);
3366 break;
3367
3368 default:
3369 emacs_abort ();
3370 }
3394 3371
3395 va_end (ap); 3372 va_end (ap);
3396 p->area = 0;
3397 return val; 3373 return val;
3398} 3374}
3399 3375
@@ -3404,11 +3380,8 @@ make_save_pointer (void *pointer)
3404{ 3380{
3405 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); 3381 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3406 struct Lisp_Save_Value *p = XSAVE_VALUE (val); 3382 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3407 3383 p->save_type = SAVE_POINTER;
3408 p->area = 0;
3409 p->type0 = SAVE_POINTER;
3410 p->data[0].pointer = pointer; 3384 p->data[0].pointer = pointer;
3411 p->type1 = p->type2 = p->type3 = SAVE_UNUSED;
3412 return val; 3385 return val;
3413} 3386}
3414 3387
@@ -5837,14 +5810,13 @@ mark_object (Lisp_Object arg)
5837 case PVEC_WINDOW: 5810 case PVEC_WINDOW:
5838 { 5811 {
5839 struct window *w = (struct window *) ptr; 5812 struct window *w = (struct window *) ptr;
5840 bool leaf = NILP (w->hchild) && NILP (w->vchild);
5841 5813
5842 mark_vectorlike (ptr); 5814 mark_vectorlike (ptr);
5843 5815
5844 /* Mark glyphs for leaf windows. Marking window 5816 /* Mark glyph matrices, if any. Marking window
5845 matrices is sufficient because frame matrices 5817 matrices is sufficient because frame matrices
5846 use the same glyph memory. */ 5818 use the same glyph memory. */
5847 if (leaf && w->current_matrix) 5819 if (w->current_matrix)
5848 { 5820 {
5849 mark_glyph_matrix (w->current_matrix); 5821 mark_glyph_matrix (w->current_matrix);
5850 mark_glyph_matrix (w->desired_matrix); 5822 mark_glyph_matrix (w->desired_matrix);
@@ -5976,12 +5948,11 @@ mark_object (Lisp_Object arg)
5976 case Lisp_Misc_Save_Value: 5948 case Lisp_Misc_Save_Value:
5977 XMISCANY (obj)->gcmarkbit = 1; 5949 XMISCANY (obj)->gcmarkbit = 1;
5978 { 5950 {
5979 register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); 5951 struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj);
5980 /* If `area' is nonzero, `data[0].pointer' is the address 5952 /* If `save_type' is zero, `data[0].pointer' is the address
5981 of a memory area containing `data[1].integer' potential 5953 of a memory area containing `data[1].integer' potential
5982 Lisp_Objects. */ 5954 Lisp_Objects. */
5983#if GC_MARK_STACK 5955 if (GC_MARK_STACK && ptr->save_type == SAVE_TYPE_MEMORY)
5984 if (ptr->area)
5985 { 5956 {
5986 Lisp_Object *p = ptr->data[0].pointer; 5957 Lisp_Object *p = ptr->data[0].pointer;
5987 ptrdiff_t nelt; 5958 ptrdiff_t nelt;
@@ -5989,17 +5960,12 @@ mark_object (Lisp_Object arg)
5989 mark_maybe_object (*p); 5960 mark_maybe_object (*p);
5990 } 5961 }
5991 else 5962 else
5992#endif /* GC_MARK_STACK */
5993 { 5963 {
5994 /* Find Lisp_Objects in `data[N]' slots and mark them. */ 5964 /* Find Lisp_Objects in `data[N]' slots and mark them. */
5995 if (ptr->type0 == SAVE_OBJECT) 5965 int i;
5996 mark_object (ptr->data[0].object); 5966 for (i = 0; i < SAVE_VALUE_SLOTS; i++)
5997 if (ptr->type1 == SAVE_OBJECT) 5967 if (save_type (ptr, i) == SAVE_OBJECT)
5998 mark_object (ptr->data[1].object); 5968 mark_object (ptr->data[i].object);
5999 if (ptr->type2 == SAVE_OBJECT)
6000 mark_object (ptr->data[2].object);
6001 if (ptr->type3 == SAVE_OBJECT)
6002 mark_object (ptr->data[3].object);
6003 } 5969 }
6004 } 5970 }
6005 break; 5971 break;
diff --git a/src/blockinput.h b/src/blockinput.h
index 192c813073d..6dc22c6f5dd 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -67,7 +67,7 @@ extern void unblock_input_to (int);
67BLOCKINPUT_INLINE bool 67BLOCKINPUT_INLINE bool
68input_blocked_p (void) 68input_blocked_p (void)
69{ 69{
70 return 0 < interrupt_input_blocked; 70 return interrupt_input_blocked > 0;
71} 71}
72 72
73INLINE_HEADER_END 73INLINE_HEADER_END
diff --git a/src/buffer.c b/src/buffer.c
index aa3fcf8c234..8728b418812 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1769,7 +1769,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1769 since anything can happen within do_yes_or_no_p. */ 1769 since anything can happen within do_yes_or_no_p. */
1770 1770
1771 /* Don't kill the minibuffer now current. */ 1771 /* Don't kill the minibuffer now current. */
1772 if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) 1772 if (EQ (buffer, XWINDOW (minibuf_window)->contents))
1773 return Qnil; 1773 return Qnil;
1774 1774
1775 /* When we kill an ordinary buffer which shares it's buffer text 1775 /* When we kill an ordinary buffer which shares it's buffer text
@@ -1820,7 +1820,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1820 /* If the buffer now current is shown in the minibuffer and our buffer 1820 /* If the buffer now current is shown in the minibuffer and our buffer
1821 is the sole other buffer give up. */ 1821 is the sole other buffer give up. */
1822 XSETBUFFER (tem, current_buffer); 1822 XSETBUFFER (tem, current_buffer);
1823 if (EQ (tem, XWINDOW (minibuf_window)->buffer) 1823 if (EQ (tem, XWINDOW (minibuf_window)->contents)
1824 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil))) 1824 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil)))
1825 return Qnil; 1825 return Qnil;
1826 1826
@@ -2394,8 +2394,9 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2394 BUF_MARKERS(buf) should either be for `buf' or dead. */ 2394 BUF_MARKERS(buf) should either be for `buf' or dead. */
2395 eassert (!m->buffer); 2395 eassert (!m->buffer);
2396 } 2396 }
2397 { /* Some of the C code expects that w->buffer == w->pointm->buffer. 2397 { /* Some of the C code expects that both window markers of a
2398 So since we just swapped the markers between the two buffers, we need 2398 live window points to that window's buffer. So since we
2399 just swapped the markers between the two buffers, we need
2399 to undo the effect of this swap for window markers. */ 2400 to undo the effect of this swap for window markers. */
2400 Lisp_Object w = Fselected_window (), ws = Qnil; 2401 Lisp_Object w = Fselected_window (), ws = Qnil;
2401 Lisp_Object buf1, buf2; 2402 Lisp_Object buf1, buf2;
@@ -2405,12 +2406,19 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2405 { 2406 {
2406 ws = Fcons (w, ws); 2407 ws = Fcons (w, ws);
2407 if (MARKERP (XWINDOW (w)->pointm) 2408 if (MARKERP (XWINDOW (w)->pointm)
2408 && (EQ (XWINDOW (w)->buffer, buf1) 2409 && (EQ (XWINDOW (w)->contents, buf1)
2409 || EQ (XWINDOW (w)->buffer, buf2))) 2410 || EQ (XWINDOW (w)->contents, buf2)))
2410 Fset_marker (XWINDOW (w)->pointm, 2411 Fset_marker (XWINDOW (w)->pointm,
2411 make_number 2412 make_number
2412 (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))), 2413 (BUF_BEGV (XBUFFER (XWINDOW (w)->contents))),
2413 XWINDOW (w)->buffer); 2414 XWINDOW (w)->contents);
2415 if (MARKERP (XWINDOW (w)->start)
2416 && (EQ (XWINDOW (w)->contents, buf1)
2417 || EQ (XWINDOW (w)->contents, buf2)))
2418 Fset_marker (XWINDOW (w)->start,
2419 make_number
2420 (XBUFFER (XWINDOW (w)->contents)->last_window_start),
2421 XWINDOW (w)->contents);
2414 w = Fnext_window (w, Qt, Qt); 2422 w = Fnext_window (w, Qt, Qt);
2415 } 2423 }
2416 } 2424 }
@@ -3893,7 +3901,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
3893 if (buffer_window_count (buf) > 0) 3901 if (buffer_window_count (buf) > 0)
3894 { 3902 {
3895 /* ... it's visible in other window than selected, */ 3903 /* ... it's visible in other window than selected, */
3896 if (buf != XBUFFER (XWINDOW (selected_window)->buffer)) 3904 if (buf != XBUFFER (XWINDOW (selected_window)->contents))
3897 windows_or_buffers_changed = 1; 3905 windows_or_buffers_changed = 1;
3898 /* ... or if we modify an overlay at the end of the buffer 3906 /* ... or if we modify an overlay at the end of the buffer
3899 and so we cannot be sure that window end is still valid. */ 3907 and so we cannot be sure that window end is still valid. */
diff --git a/src/bytecode.c b/src/bytecode.c
index acb96c1e61b..7676c8550a4 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -660,7 +660,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
660 the table clearer. */ 660 the table clearer. */
661#define LABEL(OP) [OP] = &&insn_ ## OP 661#define LABEL(OP) [OP] = &&insn_ ## OP
662 662
663#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ 663#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
664# pragma GCC diagnostic push 664# pragma GCC diagnostic push
665# pragma GCC diagnostic ignored "-Woverride-init" 665# pragma GCC diagnostic ignored "-Woverride-init"
666#endif 666#endif
@@ -676,7 +676,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
676#undef DEFINE 676#undef DEFINE
677 }; 677 };
678 678
679#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ 679#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
680# pragma GCC diagnostic pop 680# pragma GCC diagnostic pop
681#endif 681#endif
682 682
diff --git a/src/callproc.c b/src/callproc.c
index 9132c0dd976..46a37701a40 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1,5 +1,5 @@
1/* Synchronous subprocess invocation for GNU Emacs. 1/* Synchronous subprocess invocation for GNU Emacs.
2 Copyright (C) 1985-1988, 1993-1995, 1999-2012 2 Copyright (C) 1985-1988, 1993-1995, 1999-2013
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -125,7 +125,7 @@ record_kill_process (struct Lisp_Process *p)
125static Lisp_Object 125static Lisp_Object
126call_process_kill (Lisp_Object ignored) 126call_process_kill (Lisp_Object ignored)
127{ 127{
128 if (0 <= synch_process_fd) 128 if (synch_process_fd >= 0)
129 emacs_close (synch_process_fd); 129 emacs_close (synch_process_fd);
130 130
131 if (synch_process_pid) 131 if (synch_process_pid)
@@ -173,7 +173,7 @@ call_process_cleanup (Lisp_Object arg)
173 } 173 }
174#endif 174#endif
175 175
176 if (0 <= synch_process_fd) 176 if (synch_process_fd >= 0)
177 emacs_close (synch_process_fd); 177 emacs_close (synch_process_fd);
178 178
179#ifdef MSDOS 179#ifdef MSDOS
@@ -682,7 +682,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
682 682
683 child_errno = errno; 683 child_errno = errno;
684 684
685 if (0 < pid) 685 if (pid > 0)
686 { 686 {
687 if (INTEGERP (buffer)) 687 if (INTEGERP (buffer))
688 record_deleted_pid (pid); 688 record_deleted_pid (pid);
diff --git a/src/casetab.c b/src/casetab.c
index 76f72b26db3..13bed64e4b2 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -246,7 +246,7 @@ void
246init_casetab_once (void) 246init_casetab_once (void)
247{ 247{
248 register int i; 248 register int i;
249 Lisp_Object down, up; 249 Lisp_Object down, up, eqv;
250 DEFSYM (Qcase_table, "case-table"); 250 DEFSYM (Qcase_table, "case-table");
251 251
252 /* Intern this now in case it isn't already done. 252 /* Intern this now in case it isn't already done.
@@ -275,13 +275,21 @@ init_casetab_once (void)
275 275
276 for (i = 0; i < 128; i++) 276 for (i = 0; i < 128; i++)
277 { 277 {
278 int c = (i >= 'a' && i <= 'z') ? i + ('A' - 'a') : i;
279 CHAR_TABLE_SET (up, i, make_number (c));
280 }
281
282 eqv = Fmake_char_table (Qcase_table, Qnil);
283
284 for (i = 0; i < 128; i++)
285 {
278 int c = ((i >= 'A' && i <= 'Z') ? i + ('a' - 'A') 286 int c = ((i >= 'A' && i <= 'Z') ? i + ('a' - 'A')
279 : ((i >= 'a' && i <= 'z') ? i + ('A' - 'a') 287 : ((i >= 'a' && i <= 'z') ? i + ('A' - 'a')
280 : i)); 288 : i));
281 CHAR_TABLE_SET (up, i, make_number (c)); 289 CHAR_TABLE_SET (up, i, make_number (c));
282 } 290 }
283 291
284 set_char_table_extras (down, 2, Fcopy_sequence (up)); 292 set_char_table_extras (down, 2, eqv);
285 293
286 /* Fill in what isn't filled in. */ 294 /* Fill in what isn't filled in. */
287 set_case_table (down, 1); 295 set_case_table (down, 1);
diff --git a/src/ccl.c b/src/ccl.c
index 7f77e1d22fa..8fec18296a6 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -2130,7 +2130,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
2130 produced_chars += ccl.produced; 2130 produced_chars += ccl.produced;
2131 offset = outp - outbuf; 2131 offset = outp - outbuf;
2132 shortfall = ccl.produced * max_expansion - (outbufsize - offset); 2132 shortfall = ccl.produced * max_expansion - (outbufsize - offset);
2133 if (0 < shortfall) 2133 if (shortfall > 0)
2134 { 2134 {
2135 outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1); 2135 outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1);
2136 outp = outbuf + offset; 2136 outp = outbuf + offset;
diff --git a/src/cm.c b/src/cm.c
index 3a5f927eda3..481ac15e435 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -214,7 +214,7 @@ calccost (struct tty_display_info *tty,
214 if (doit) 214 if (doit)
215 do 215 do
216 emacs_tputs (tty, p, 1, cmputc); 216 emacs_tputs (tty, p, 1, cmputc);
217 while (0 < --deltay); 217 while (--deltay > 0);
218x: 218x:
219 if ((deltax = dstx - srcx) == 0) 219 if ((deltax = dstx - srcx) == 0)
220 goto done; 220 goto done;
@@ -297,7 +297,7 @@ fail:
297 if (doit) 297 if (doit)
298 do 298 do
299 emacs_tputs (tty, p, 1, cmputc); 299 emacs_tputs (tty, p, 1, cmputc);
300 while (0 < --deltax); 300 while (--deltax > 0);
301done: 301done:
302 return totalcost; 302 return totalcost;
303} 303}
diff --git a/src/dired.c b/src/dired.c
index 0e37568f211..7bbfee7e5b0 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -258,7 +258,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
258 QUIT; 258 QUIT;
259 259
260 if (NILP (match) 260 if (NILP (match)
261 || (0 <= re_search (bufp, SSDATA (name), len, 0, len, 0))) 261 || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0)
262 wanted = 1; 262 wanted = 1;
263 263
264 immediate_quit = 0; 264 immediate_quit = 0;
@@ -517,8 +517,9 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
517 517
518 QUIT; 518 QUIT;
519 if (len < SCHARS (encoded_file) 519 if (len < SCHARS (encoded_file)
520 || 0 <= scmp (dp->d_name, SSDATA (encoded_file), 520 || (scmp (dp->d_name, SSDATA (encoded_file),
521 SCHARS (encoded_file))) 521 SCHARS (encoded_file))
522 >= 0))
522 continue; 523 continue;
523 524
524 if (file_name_completion_stat (fd, dp, &st) < 0) 525 if (file_name_completion_stat (fd, dp, &st) < 0)
@@ -580,7 +581,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
580 if (skip < 0) 581 if (skip < 0)
581 continue; 582 continue;
582 583
583 if (0 <= scmp (dp->d_name + skip, p1, elt_len)) 584 if (scmp (dp->d_name + skip, p1, elt_len) >= 0)
584 continue; 585 continue;
585 break; 586 break;
586 } 587 }
@@ -602,9 +603,8 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
602 skip = len - SCHARS (elt); 603 skip = len - SCHARS (elt);
603 if (skip < 0) continue; 604 if (skip < 0) continue;
604 605
605 if (0 <= scmp (dp->d_name + skip, 606 if (scmp (dp->d_name + skip, SSDATA (elt), SCHARS (elt))
606 SSDATA (elt), 607 >= 0)
607 SCHARS (elt)))
608 continue; 608 continue;
609 break; 609 break;
610 } 610 }
diff --git a/src/dispextern.h b/src/dispextern.h
index 1f269902435..cb2e944d1cc 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1412,25 +1412,24 @@ struct glyph_string
1412 1412
1413/* Value is non-zero if window W wants a mode line. */ 1413/* Value is non-zero if window W wants a mode line. */
1414 1414
1415#define WINDOW_WANTS_MODELINE_P(W) \ 1415#define WINDOW_WANTS_MODELINE_P(W) \
1416 (!MINI_WINDOW_P ((W)) \ 1416 (!MINI_WINDOW_P ((W)) \
1417 && !(W)->pseudo_window_p \ 1417 && !(W)->pseudo_window_p \
1418 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ 1418 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
1419 && BUFFERP (W->buffer) \ 1419 && BUFFERP (W->contents) \
1420 && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \ 1420 && !NILP (BVAR (XBUFFER (W->contents), mode_line_format)) \
1421 && WINDOW_TOTAL_LINES (W) > 1) 1421 && WINDOW_TOTAL_LINES (W) > 1)
1422 1422
1423/* Value is true if window W wants a header line. */ 1423/* Value is true if window W wants a header line. */
1424 1424
1425#define WINDOW_WANTS_HEADER_LINE_P(W) \ 1425#define WINDOW_WANTS_HEADER_LINE_P(W) \
1426 (!MINI_WINDOW_P ((W)) \ 1426 (!MINI_WINDOW_P ((W)) \
1427 && !(W)->pseudo_window_p \ 1427 && !(W)->pseudo_window_p \
1428 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ 1428 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
1429 && BUFFERP (W->buffer) \ 1429 && BUFFERP (W->contents) \
1430 && !NILP (BVAR (XBUFFER (W->buffer), header_line_format)) \ 1430 && !NILP (BVAR (XBUFFER (W->contents), header_line_format)) \
1431 && WINDOW_TOTAL_LINES (W) > 1 \ 1431 && WINDOW_TOTAL_LINES (W) > 1 \
1432 + !NILP (BVAR (XBUFFER (W->buffer), mode_line_format))) 1432 + !NILP (BVAR (XBUFFER (W->contents), mode_line_format)))
1433
1434 1433
1435/* Return proper value to be used as baseline offset of font that has 1434/* Return proper value to be used as baseline offset of font that has
1436 ASCENT and DESCENT to draw characters by the font at the vertical 1435 ASCENT and DESCENT to draw characters by the font at the vertical
diff --git a/src/dispnew.c b/src/dispnew.c
index bc65050605a..b4ca654a8f7 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -223,9 +223,9 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p)
223 "%"pMu": window %p (`%s')%s\n%s", 223 "%"pMu": window %p (`%s')%s\n%s",
224 history_tick++, 224 history_tick++,
225 w, 225 w,
226 ((BUFFERP (w->buffer) 226 ((BUFFERP (w->contents)
227 && STRINGP (BVAR (XBUFFER (w->buffer), name))) 227 && STRINGP (BVAR (XBUFFER (w->contents), name)))
228 ? SSDATA (BVAR (XBUFFER (w->buffer), name)) 228 ? SSDATA (BVAR (XBUFFER (w->contents), name))
229 : "???"), 229 : "???"),
230 paused_p ? " ***paused***" : "", 230 paused_p ? " ***paused***" : "",
231 msg); 231 msg);
@@ -794,11 +794,13 @@ clear_current_matrices (register struct frame *f)
794 if (f->current_matrix) 794 if (f->current_matrix)
795 clear_glyph_matrix (f->current_matrix); 795 clear_glyph_matrix (f->current_matrix);
796 796
797#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
797 /* Clear the matrix of the menu bar window, if such a window exists. 798 /* Clear the matrix of the menu bar window, if such a window exists.
798 The menu bar window is currently used to display menus on X when 799 The menu bar window is currently used to display menus on X when
799 no toolkit support is compiled in. */ 800 no toolkit support is compiled in. */
800 if (WINDOWP (f->menu_bar_window)) 801 if (WINDOWP (f->menu_bar_window))
801 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix); 802 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
803#endif
802 804
803 /* Clear the matrix of the tool-bar window, if any. */ 805 /* Clear the matrix of the tool-bar window, if any. */
804 if (WINDOWP (f->tool_bar_window)) 806 if (WINDOWP (f->tool_bar_window))
@@ -818,8 +820,10 @@ clear_desired_matrices (register struct frame *f)
818 if (f->desired_matrix) 820 if (f->desired_matrix)
819 clear_glyph_matrix (f->desired_matrix); 821 clear_glyph_matrix (f->desired_matrix);
820 822
823#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
821 if (WINDOWP (f->menu_bar_window)) 824 if (WINDOWP (f->menu_bar_window))
822 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix); 825 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix);
826#endif
823 827
824 if (WINDOWP (f->tool_bar_window)) 828 if (WINDOWP (f->tool_bar_window))
825 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix); 829 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix);
@@ -838,16 +842,8 @@ clear_window_matrices (struct window *w, bool desired_p)
838{ 842{
839 while (w) 843 while (w)
840 { 844 {
841 if (!NILP (w->hchild)) 845 if (WINDOWP (w->contents))
842 { 846 clear_window_matrices (XWINDOW (w->contents), desired_p);
843 eassert (WINDOWP (w->hchild));
844 clear_window_matrices (XWINDOW (w->hchild), desired_p);
845 }
846 else if (!NILP (w->vchild))
847 {
848 eassert (WINDOWP (w->vchild));
849 clear_window_matrices (XWINDOW (w->vchild), desired_p);
850 }
851 else 847 else
852 { 848 {
853 if (desired_p) 849 if (desired_p)
@@ -1468,7 +1464,7 @@ check_matrix_invariants (struct window *w)
1468 struct glyph_row *row = matrix->rows; 1464 struct glyph_row *row = matrix->rows;
1469 struct glyph_row *last_text_row = NULL; 1465 struct glyph_row *last_text_row = NULL;
1470 struct buffer *saved = current_buffer; 1466 struct buffer *saved = current_buffer;
1471 struct buffer *buffer = XBUFFER (w->buffer); 1467 struct buffer *buffer = XBUFFER (w->contents);
1472 int c; 1468 int c;
1473 1469
1474 /* This can sometimes happen for a fresh window. */ 1470 /* This can sometimes happen for a fresh window. */
@@ -1632,7 +1628,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1632 vertically below other windows. */ 1628 vertically below other windows. */
1633 in_horz_combination_p 1629 in_horz_combination_p
1634 = (!NILP (XWINDOW (window)->parent) 1630 = (!NILP (XWINDOW (window)->parent)
1635 && !NILP (XWINDOW (XWINDOW (window)->parent)->hchild)); 1631 && WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (XWINDOW (window)->parent)));
1636 1632
1637 /* For WINDOW and all windows on the same level. */ 1633 /* For WINDOW and all windows on the same level. */
1638 do 1634 do
@@ -1641,12 +1637,8 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1641 1637
1642 /* Get the dimension of the window sub-matrix for W, depending 1638 /* Get the dimension of the window sub-matrix for W, depending
1643 on whether this is a combination or a leaf window. */ 1639 on whether this is a combination or a leaf window. */
1644 if (!NILP (w->hchild)) 1640 if (WINDOWP (w->contents))
1645 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, 1641 dim = allocate_matrices_for_frame_redisplay (w->contents, x, y,
1646 dim_only_p,
1647 window_change_flags);
1648 else if (!NILP (w->vchild))
1649 dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y,
1650 dim_only_p, 1642 dim_only_p,
1651 window_change_flags); 1643 window_change_flags);
1652 else 1644 else
@@ -1788,10 +1780,8 @@ allocate_matrices_for_window_redisplay (struct window *w)
1788{ 1780{
1789 while (w) 1781 while (w)
1790 { 1782 {
1791 if (!NILP (w->vchild)) 1783 if (WINDOWP (w->contents))
1792 allocate_matrices_for_window_redisplay (XWINDOW (w->vchild)); 1784 allocate_matrices_for_window_redisplay (XWINDOW (w->contents));
1793 else if (!NILP (w->hchild))
1794 allocate_matrices_for_window_redisplay (XWINDOW (w->hchild));
1795 else 1785 else
1796 { 1786 {
1797 /* W is a leaf window. */ 1787 /* W is a leaf window. */
@@ -1863,18 +1853,12 @@ showing_window_margins_p (struct window *w)
1863{ 1853{
1864 while (w) 1854 while (w)
1865 { 1855 {
1866 if (!NILP (w->hchild)) 1856 if (WINDOWP (w->contents))
1867 {
1868 if (showing_window_margins_p (XWINDOW (w->hchild)))
1869 return 1;
1870 }
1871 else if (!NILP (w->vchild))
1872 { 1857 {
1873 if (showing_window_margins_p (XWINDOW (w->vchild))) 1858 if (showing_window_margins_p (XWINDOW (w->contents)))
1874 return 1; 1859 return 1;
1875 } 1860 }
1876 else if (!NILP (w->left_margin_cols) 1861 else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols))
1877 || !NILP (w->right_margin_cols))
1878 return 1; 1862 return 1;
1879 1863
1880 w = NILP (w->next) ? 0 : XWINDOW (w->next); 1864 w = NILP (w->next) ? 0 : XWINDOW (w->next);
@@ -1895,10 +1879,8 @@ fake_current_matrices (Lisp_Object window)
1895 { 1879 {
1896 w = XWINDOW (window); 1880 w = XWINDOW (window);
1897 1881
1898 if (!NILP (w->hchild)) 1882 if (WINDOWP (w->contents))
1899 fake_current_matrices (w->hchild); 1883 fake_current_matrices (w->contents);
1900 else if (!NILP (w->vchild))
1901 fake_current_matrices (w->vchild);
1902 else 1884 else
1903 { 1885 {
1904 int i; 1886 int i;
@@ -2184,6 +2166,7 @@ free_glyphs (struct frame *f)
2184 if (!NILP (f->root_window)) 2166 if (!NILP (f->root_window))
2185 free_window_matrices (XWINDOW (f->root_window)); 2167 free_window_matrices (XWINDOW (f->root_window));
2186 2168
2169#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
2187 /* Free the dummy window for menu bars without X toolkit and its 2170 /* Free the dummy window for menu bars without X toolkit and its
2188 glyph matrices. */ 2171 glyph matrices. */
2189 if (!NILP (f->menu_bar_window)) 2172 if (!NILP (f->menu_bar_window))
@@ -2194,6 +2177,7 @@ free_glyphs (struct frame *f)
2194 w->desired_matrix = w->current_matrix = NULL; 2177 w->desired_matrix = w->current_matrix = NULL;
2195 fset_menu_bar_window (f, Qnil); 2178 fset_menu_bar_window (f, Qnil);
2196 } 2179 }
2180#endif
2197 2181
2198 /* Free the tool bar window and its glyph matrices. */ 2182 /* Free the tool bar window and its glyph matrices. */
2199 if (!NILP (f->tool_bar_window)) 2183 if (!NILP (f->tool_bar_window))
@@ -2236,10 +2220,8 @@ free_window_matrices (struct window *w)
2236{ 2220{
2237 while (w) 2221 while (w)
2238 { 2222 {
2239 if (!NILP (w->hchild)) 2223 if (WINDOWP (w->contents))
2240 free_window_matrices (XWINDOW (w->hchild)); 2224 free_window_matrices (XWINDOW (w->contents));
2241 else if (!NILP (w->vchild))
2242 free_window_matrices (XWINDOW (w->vchild));
2243 else 2225 else
2244 { 2226 {
2245 /* This is a leaf window. Free its memory and reset fields 2227 /* This is a leaf window. Free its memory and reset fields
@@ -2372,10 +2354,8 @@ build_frame_matrix_from_window_tree (struct glyph_matrix *matrix, struct window
2372{ 2354{
2373 while (w) 2355 while (w)
2374 { 2356 {
2375 if (!NILP (w->hchild)) 2357 if (WINDOWP (w->contents))
2376 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->hchild)); 2358 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->contents));
2377 else if (!NILP (w->vchild))
2378 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->vchild));
2379 else 2359 else
2380 build_frame_matrix_from_leaf_window (matrix, w); 2360 build_frame_matrix_from_leaf_window (matrix, w);
2381 2361
@@ -2639,10 +2619,8 @@ mirror_make_current (struct window *w, int frame_row)
2639{ 2619{
2640 while (w) 2620 while (w)
2641 { 2621 {
2642 if (!NILP (w->hchild)) 2622 if (WINDOWP (w->contents))
2643 mirror_make_current (XWINDOW (w->hchild), frame_row); 2623 mirror_make_current (XWINDOW (w->contents), frame_row);
2644 else if (!NILP (w->vchild))
2645 mirror_make_current (XWINDOW (w->vchild), frame_row);
2646 else 2624 else
2647 { 2625 {
2648 /* Row relative to window W. Don't use FRAME_TO_WINDOW_VPOS 2626 /* Row relative to window W. Don't use FRAME_TO_WINDOW_VPOS
@@ -2738,8 +2716,8 @@ sync_window_with_frame_matrix_rows (struct window *w)
2738 struct glyph_row *window_row, *window_row_end, *frame_row; 2716 struct glyph_row *window_row, *window_row_end, *frame_row;
2739 int left, right, x, width; 2717 int left, right, x, width;
2740 2718
2741 /* Preconditions: W must be a leaf window on a tty frame. */ 2719 /* Preconditions: W must be a live window on a tty frame. */
2742 eassert (NILP (w->hchild) && NILP (w->vchild)); 2720 eassert (BUFFERP (w->contents));
2743 eassert (!FRAME_WINDOW_P (f)); 2721 eassert (!FRAME_WINDOW_P (f));
2744 2722
2745 left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols); 2723 left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols);
@@ -2775,10 +2753,8 @@ frame_row_to_window (struct window *w, int row)
2775 2753
2776 while (w && !found) 2754 while (w && !found)
2777 { 2755 {
2778 if (!NILP (w->hchild)) 2756 if (WINDOWP (w->contents))
2779 found = frame_row_to_window (XWINDOW (w->hchild), row); 2757 found = frame_row_to_window (XWINDOW (w->contents), row);
2780 else if (!NILP (w->vchild))
2781 found = frame_row_to_window (XWINDOW (w->vchild), row);
2782 else if (row >= WINDOW_TOP_EDGE_LINE (w) 2758 else if (row >= WINDOW_TOP_EDGE_LINE (w)
2783 && row < WINDOW_BOTTOM_EDGE_LINE (w)) 2759 && row < WINDOW_BOTTOM_EDGE_LINE (w))
2784 found = w; 2760 found = w;
@@ -2806,11 +2782,8 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
2806{ 2782{
2807 while (w) 2783 while (w)
2808 { 2784 {
2809 if (!NILP (w->hchild)) 2785 if (WINDOWP (w->contents))
2810 mirror_line_dance (XWINDOW (w->hchild), unchanged_at_top, 2786 mirror_line_dance (XWINDOW (w->contents), unchanged_at_top,
2811 nlines, copy_from, retained_p);
2812 else if (!NILP (w->vchild))
2813 mirror_line_dance (XWINDOW (w->vchild), unchanged_at_top,
2814 nlines, copy_from, retained_p); 2787 nlines, copy_from, retained_p);
2815 else 2788 else
2816 { 2789 {
@@ -2919,10 +2892,8 @@ check_window_matrix_pointers (struct window *w)
2919{ 2892{
2920 while (w) 2893 while (w)
2921 { 2894 {
2922 if (!NILP (w->hchild)) 2895 if (WINDOWP (w->contents))
2923 check_window_matrix_pointers (XWINDOW (w->hchild)); 2896 check_window_matrix_pointers (XWINDOW (w->contents));
2924 else if (!NILP (w->vchild))
2925 check_window_matrix_pointers (XWINDOW (w->vchild));
2926 else 2897 else
2927 { 2898 {
2928 struct frame *f = XFRAME (w->frame); 2899 struct frame *f = XFRAME (w->frame);
@@ -3092,10 +3063,12 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
3092 when pending input is detected. */ 3063 when pending input is detected. */
3093 update_begin (f); 3064 update_begin (f);
3094 3065
3066#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
3095 /* Update the menu bar on X frames that don't have toolkit 3067 /* Update the menu bar on X frames that don't have toolkit
3096 support. */ 3068 support. */
3097 if (WINDOWP (f->menu_bar_window)) 3069 if (WINDOWP (f->menu_bar_window))
3098 update_window (XWINDOW (f->menu_bar_window), 1); 3070 update_window (XWINDOW (f->menu_bar_window), 1);
3071#endif
3099 3072
3100 /* Update the tool-bar window, if present. */ 3073 /* Update the tool-bar window, if present. */
3101 if (WINDOWP (f->tool_bar_window)) 3074 if (WINDOWP (f->tool_bar_window))
@@ -3186,10 +3159,8 @@ update_window_tree (struct window *w, bool force_p)
3186 3159
3187 while (w && !paused_p) 3160 while (w && !paused_p)
3188 { 3161 {
3189 if (!NILP (w->hchild)) 3162 if (WINDOWP (w->contents))
3190 paused_p |= update_window_tree (XWINDOW (w->hchild), force_p); 3163 paused_p |= update_window_tree (XWINDOW (w->contents), force_p);
3191 else if (!NILP (w->vchild))
3192 paused_p |= update_window_tree (XWINDOW (w->vchild), force_p);
3193 else if (w->must_be_updated_p) 3164 else if (w->must_be_updated_p)
3194 paused_p |= update_window (w, force_p); 3165 paused_p |= update_window (w, force_p);
3195 3166
@@ -3967,10 +3938,8 @@ set_window_update_flags (struct window *w, bool on_p)
3967{ 3938{
3968 while (w) 3939 while (w)
3969 { 3940 {
3970 if (!NILP (w->hchild)) 3941 if (WINDOWP (w->contents))
3971 set_window_update_flags (XWINDOW (w->hchild), on_p); 3942 set_window_update_flags (XWINDOW (w->contents), on_p);
3972 else if (!NILP (w->vchild))
3973 set_window_update_flags (XWINDOW (w->vchild), on_p);
3974 else 3943 else
3975 w->must_be_updated_p = on_p; 3944 w->must_be_updated_p = on_p;
3976 3945
@@ -4451,7 +4420,7 @@ scrolling_window (struct window *w, bool header_line_p)
4451 row_table[row_entry_pool[i].bucket] = NULL; 4420 row_table[row_entry_pool[i].bucket] = NULL;
4452 4421
4453 /* Value is 1 to indicate that we scrolled the display. */ 4422 /* Value is 1 to indicate that we scrolled the display. */
4454 return 0 < nruns; 4423 return nruns > 0;
4455} 4424}
4456 4425
4457 4426
@@ -5117,7 +5086,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5117 5086
5118 /* We used to set current_buffer directly here, but that does the 5087 /* We used to set current_buffer directly here, but that does the
5119 wrong thing with `face-remapping-alist' (bug#2044). */ 5088 wrong thing with `face-remapping-alist' (bug#2044). */
5120 Fset_buffer (w->buffer); 5089 Fset_buffer (w->contents);
5121 itdata = bidi_shelve_cache (); 5090 itdata = bidi_shelve_cache ();
5122 SET_TEXT_POS_FROM_MARKER (startp, w->start); 5091 SET_TEXT_POS_FROM_MARKER (startp, w->start);
5123 CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp))); 5092 CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp)));
@@ -5163,7 +5132,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5163 *dx = x0 + it.first_visible_x - it.current_x; 5132 *dx = x0 + it.first_visible_x - it.current_x;
5164 *dy = *y - it.current_y; 5133 *dy = *y - it.current_y;
5165 5134
5166 string = w->buffer; 5135 string = w->contents;
5167 if (STRINGP (it.string)) 5136 if (STRINGP (it.string))
5168 string = it.string; 5137 string = it.string;
5169 *pos = it.current; 5138 *pos = it.current;
@@ -5181,7 +5150,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5181 if (STRINGP (it.string)) 5150 if (STRINGP (it.string))
5182 BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); 5151 BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
5183 else 5152 else
5184 BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer), 5153 BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->contents),
5185 CHARPOS (pos->pos)); 5154 CHARPOS (pos->pos));
5186 } 5155 }
5187 5156
@@ -5756,7 +5725,7 @@ additional wait period, in milliseconds; this is for backwards compatibility.
5756 duration += XINT (milliseconds) / 1000.0; 5725 duration += XINT (milliseconds) / 1000.0;
5757 } 5726 }
5758 5727
5759 if (0 < duration) 5728 if (duration > 0)
5760 { 5729 {
5761 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration); 5730 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration);
5762 wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX), 5731 wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX),
@@ -5796,7 +5765,7 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
5796 if (INTEGERP (timeout)) 5765 if (INTEGERP (timeout))
5797 { 5766 {
5798 sec = XINT (timeout); 5767 sec = XINT (timeout);
5799 if (! (0 < sec)) 5768 if (sec <= 0)
5800 return Qt; 5769 return Qt;
5801 nsec = 0; 5770 nsec = 0;
5802 } 5771 }
diff --git a/src/editfns.c b/src/editfns.c
index f34c574cae3..e0b0347fe69 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -373,7 +373,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
373 if (NILP (object)) 373 if (NILP (object))
374 XSETBUFFER (object, current_buffer); 374 XSETBUFFER (object, current_buffer);
375 else if (WINDOWP (object)) 375 else if (WINDOWP (object))
376 object = XWINDOW (object)->buffer; 376 object = XWINDOW (object)->contents;
377 377
378 if (!BUFFERP (object)) 378 if (!BUFFERP (object))
379 /* pos-property only makes sense in buffers right now, since strings 379 /* pos-property only makes sense in buffers right now, since strings
@@ -839,14 +839,14 @@ Lisp_Object
839save_excursion_save (void) 839save_excursion_save (void)
840{ 840{
841 return make_save_value 841 return make_save_value
842 ("oooo", 842 (SAVE_TYPE_OBJ_OBJ_OBJ_OBJ,
843 Fpoint_marker (), 843 Fpoint_marker (),
844 /* Do not copy the mark if it points to nowhere. */ 844 /* Do not copy the mark if it points to nowhere. */
845 (XMARKER (BVAR (current_buffer, mark))->buffer 845 (XMARKER (BVAR (current_buffer, mark))->buffer
846 ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) 846 ? Fcopy_marker (BVAR (current_buffer, mark), Qnil)
847 : Qnil), 847 : Qnil),
848 /* Selected window if current buffer is shown in it, nil otherwise. */ 848 /* Selected window if current buffer is shown in it, nil otherwise. */
849 ((XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) 849 (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ())
850 ? selected_window : Qnil), 850 ? selected_window : Qnil),
851 BVAR (current_buffer, mark_active)); 851 BVAR (current_buffer, mark_active));
852} 852}
@@ -915,7 +915,7 @@ save_excursion_restore (Lisp_Object info)
915 tem = XSAVE_OBJECT (info, 2); 915 tem = XSAVE_OBJECT (info, 2);
916 if (WINDOWP (tem) 916 if (WINDOWP (tem)
917 && !EQ (tem, selected_window) 917 && !EQ (tem, selected_window)
918 && (tem1 = XWINDOW (tem)->buffer, 918 && (tem1 = XWINDOW (tem)->contents,
919 (/* Window is live... */ 919 (/* Window is live... */
920 BUFFERP (tem1) 920 BUFFERP (tem1)
921 /* ...and it shows the current buffer. */ 921 /* ...and it shows the current buffer. */
@@ -3958,7 +3958,7 @@ usage: (format STRING &rest OBJECTS) */)
3958 trailing "d"). */ 3958 trailing "d"). */
3959 pMlen = sizeof pMd - 2 3959 pMlen = sizeof pMd - 2
3960 }; 3960 };
3961 verify (0 < USEFUL_PRECISION_MAX); 3961 verify (USEFUL_PRECISION_MAX > 0);
3962 3962
3963 int prec; 3963 int prec;
3964 ptrdiff_t padding, sprintf_bytes; 3964 ptrdiff_t padding, sprintf_bytes;
@@ -4241,7 +4241,10 @@ usage: (format STRING &rest OBJECTS) */)
4241 memcpy (buf, initial_buffer, used); 4241 memcpy (buf, initial_buffer, used);
4242 } 4242 }
4243 else 4243 else
4244 XSAVE_POINTER (buf_save_value, 0) = buf = xrealloc (buf, bufsize); 4244 {
4245 buf = xrealloc (buf, bufsize);
4246 set_save_pointer (buf_save_value, 0, buf);
4247 }
4245 4248
4246 p = buf + used; 4249 p = buf + used;
4247 } 4250 }
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 6a8c751e306..970683da9c4 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -28,7 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include "xterm.h" 28#include "xterm.h"
29 29
30/* Silence a bogus diagnostic; see GNOME bug 683906. */ 30/* Silence a bogus diagnostic; see GNOME bug 683906. */
31#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ 31#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
32# pragma GCC diagnostic push 32# pragma GCC diagnostic push
33# pragma GCC diagnostic ignored "-Wunused-local-typedefs" 33# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
34#endif 34#endif
diff --git a/src/fileio.c b/src/fileio.c
index 724250c8aaa..2047338f03e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3958,7 +3958,7 @@ by calling `format-decode', which see. */)
3958 3958
3959 /* If display currently starts at beginning of line, 3959 /* If display currently starts at beginning of line,
3960 keep it that way. */ 3960 keep it that way. */
3961 if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) 3961 if (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer)
3962 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ()); 3962 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ());
3963 3963
3964 replace_handled = 1; 3964 replace_handled = 1;
@@ -4108,7 +4108,7 @@ by calling `format-decode', which see. */)
4108 4108
4109 /* If display currently starts at beginning of line, 4109 /* If display currently starts at beginning of line,
4110 keep it that way. */ 4110 keep it that way. */
4111 if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) 4111 if (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer)
4112 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ()); 4112 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ());
4113 4113
4114 /* Replace the chars that we need to replace, 4114 /* Replace the chars that we need to replace,
@@ -4218,7 +4218,8 @@ by calling `format-decode', which see. */)
4218 to be signaled after decoding the text we read. */ 4218 to be signaled after decoding the text we read. */
4219 nbytes = internal_condition_case_1 4219 nbytes = internal_condition_case_1
4220 (read_non_regular, 4220 (read_non_regular,
4221 make_save_value ("iii", (ptrdiff_t) fd, inserted, trytry), 4221 make_save_value (SAVE_TYPE_INT_INT_INT, (ptrdiff_t) fd,
4222 inserted, trytry),
4222 Qerror, read_non_regular_quit); 4223 Qerror, read_non_regular_quit);
4223 4224
4224 if (NILP (nbytes)) 4225 if (NILP (nbytes))
@@ -5012,7 +5013,7 @@ This calls `write-region-annotate-functions' at the start, and
5012 && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system)) 5013 && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system))
5013 { 5014 {
5014 int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0); 5015 int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0);
5015 if (0 <= desc1) 5016 if (desc1 >= 0)
5016 { 5017 {
5017 struct stat st1; 5018 struct stat st1;
5018 if (fstat (desc1, &st1) == 0 5019 if (fstat (desc1, &st1) == 0
diff --git a/src/floatfns.c b/src/floatfns.c
index 43576a16248..6113758f964 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -193,7 +193,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
193 CHECK_NUMBER_OR_FLOAT (arg2); 193 CHECK_NUMBER_OR_FLOAT (arg2);
194 if (INTEGERP (arg1) /* common lisp spec */ 194 if (INTEGERP (arg1) /* common lisp spec */
195 && INTEGERP (arg2) /* don't promote, if both are ints, and */ 195 && INTEGERP (arg2) /* don't promote, if both are ints, and */
196 && 0 <= XINT (arg2)) /* we are sure the result is not fractional */ 196 && XINT (arg2) >= 0) /* we are sure the result is not fractional */
197 { /* this can be improved by pre-calculating */ 197 { /* this can be improved by pre-calculating */
198 EMACS_INT y; /* some binary powers of x then accumulating */ 198 EMACS_INT y; /* some binary powers of x then accumulating */
199 EMACS_UINT acc, x; /* Unsigned so that overflow is well defined. */ 199 EMACS_UINT acc, x; /* Unsigned so that overflow is well defined. */
@@ -475,7 +475,7 @@ fmod_float (Lisp_Object x, Lisp_Object y)
475 f1 = fmod (f1, f2); 475 f1 = fmod (f1, f2);
476 476
477 /* If the "remainder" comes out with the wrong sign, fix it. */ 477 /* If the "remainder" comes out with the wrong sign, fix it. */
478 if (f2 < 0 ? 0 < f1 : f1 < 0) 478 if (f2 < 0 ? f1 > 0 : f1 < 0)
479 f1 += f2; 479 f1 += f2;
480 480
481 return make_float (f1); 481 return make_float (f1);
diff --git a/src/font.c b/src/font.c
index ba98d19afa0..17573cdc264 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4761,7 +4761,7 @@ character at index specified by POSITION. */)
4761 4761
4762 if (NILP (string)) 4762 if (NILP (string))
4763 { 4763 {
4764 if (XBUFFER (w->buffer) != current_buffer) 4764 if (XBUFFER (w->contents) != current_buffer)
4765 error ("Specified window is not displaying the current buffer."); 4765 error ("Specified window is not displaying the current buffer.");
4766 CHECK_NUMBER_COERCE_MARKER (position); 4766 CHECK_NUMBER_COERCE_MARKER (position);
4767 if (! (BEGV <= XINT (position) && XINT (position) < ZV)) 4767 if (! (BEGV <= XINT (position) && XINT (position) < ZV))
@@ -4844,7 +4844,7 @@ If the named font is not yet loaded, return nil. */)
4844 Lisp_Object info; 4844 Lisp_Object info;
4845 Lisp_Object font_object; 4845 Lisp_Object font_object;
4846 4846
4847 (*check_window_system_func) (); 4847 check_window_system ();
4848 4848
4849 if (! FONTP (name)) 4849 if (! FONTP (name))
4850 CHECK_STRING (name); 4850 CHECK_STRING (name);
diff --git a/src/fontset.c b/src/fontset.c
index 3578bc9403d..7aec26bbb5b 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -179,10 +179,6 @@ static int next_fontset_id;
179 font for each character. */ 179 font for each character. */
180static Lisp_Object Vdefault_fontset; 180static Lisp_Object Vdefault_fontset;
181 181
182/* Check if any window system is used now. */
183void (*check_window_system_func) (void);
184
185
186/* Prototype declarations for static functions. */ 182/* Prototype declarations for static functions. */
187static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object); 183static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object);
188 184
@@ -1213,7 +1209,7 @@ If REGEXPP is non-nil, PATTERN is a regular expression. */)
1213 Lisp_Object fontset; 1209 Lisp_Object fontset;
1214 int id; 1210 int id;
1215 1211
1216 (*check_window_system_func) (); 1212 check_window_system ();
1217 1213
1218 CHECK_STRING (pattern); 1214 CHECK_STRING (pattern);
1219 1215
@@ -1919,7 +1915,7 @@ format is the same as above. */)
1919 Lisp_Object val, elt; 1915 Lisp_Object val, elt;
1920 int c, i, j, k; 1916 int c, i, j, k;
1921 1917
1922 (*check_window_system_func) (); 1918 check_window_system ();
1923 1919
1924 fontset = check_fontset_name (fontset, &frame); 1920 fontset = check_fontset_name (fontset, &frame);
1925 1921
diff --git a/src/fontset.h b/src/fontset.h
index 07ee5d65c25..926520c8001 100644
--- a/src/fontset.h
+++ b/src/fontset.h
@@ -26,9 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#ifndef EMACS_FONTSET_H 26#ifndef EMACS_FONTSET_H
27#define EMACS_FONTSET_H 27#define EMACS_FONTSET_H
28 28
29/* Check if any window system is used now. */
30extern void (*check_window_system_func) (void);
31
32struct face; 29struct face;
33 30
34extern void free_face_fontset (FRAME_PTR, struct face *); 31extern void free_face_fontset (FRAME_PTR, struct face *);
diff --git a/src/frame.c b/src/frame.c
index 2ed2c5a2771..5d5876ed097 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -159,15 +159,15 @@ set_menu_bar_lines_1 (Lisp_Object window, int n)
159 w->total_lines -= n; 159 w->total_lines -= n;
160 160
161 /* Handle just the top child in a vertical split. */ 161 /* Handle just the top child in a vertical split. */
162 if (!NILP (w->vchild)) 162 if (WINDOW_VERTICAL_COMBINATION_P (w))
163 set_menu_bar_lines_1 (w->vchild, n); 163 set_menu_bar_lines_1 (w->contents, n);
164 164 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
165 /* Adjust all children in a horizontal split. */ 165 /* Adjust all children in a horizontal split. */
166 for (window = w->hchild; !NILP (window); window = w->next) 166 for (window = w->contents; !NILP (window); window = w->next)
167 { 167 {
168 w = XWINDOW (window); 168 w = XWINDOW (window);
169 set_menu_bar_lines_1 (window, n); 169 set_menu_bar_lines_1 (window, n);
170 } 170 }
171} 171}
172 172
173void 173void
@@ -421,7 +421,7 @@ make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lis
421 421
422 /* Make the chosen minibuffer window display the proper minibuffer, 422 /* Make the chosen minibuffer window display the proper minibuffer,
423 unless it is already showing a minibuffer. */ 423 unless it is already showing a minibuffer. */
424 if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list))) 424 if (NILP (Fmemq (XWINDOW (mini_window)->contents, Vminibuffer_list)))
425 /* Use set_window_buffer instead of Fset_window_buffer (see 425 /* Use set_window_buffer instead of Fset_window_buffer (see
426 discussion of bug#11984, bug#12025, bug#12026). */ 426 discussion of bug#11984, bug#12025, bug#12026). */
427 set_window_buffer (mini_window, 427 set_window_buffer (mini_window,
@@ -889,7 +889,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
889/* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the 889/* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
890 same tty (for tty frames) or among frames which uses FRAME's keyboard. 890 same tty (for tty frames) or among frames which uses FRAME's keyboard.
891 If MINIBUF is nil, do not consider minibuffer-only candidate. 891 If MINIBUF is nil, do not consider minibuffer-only candidate.
892 If MINIBUF is `visible', do not consider an invisible candidate. 892 If MINIBUF is `visible', do not consider an invisible candidate.
893 If MINIBUF is a window, consider only its own frame and candidate now 893 If MINIBUF is a window, consider only its own frame and candidate now
894 using that window as the minibuffer. 894 using that window as the minibuffer.
895 If MINIBUF is 0, consider candidate if it is visible or iconified. 895 If MINIBUF is 0, consider candidate if it is visible or iconified.
@@ -1189,7 +1189,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1189 /* Use set_window_buffer instead of Fset_window_buffer (see 1189 /* Use set_window_buffer instead of Fset_window_buffer (see
1190 discussion of bug#11984, bug#12025, bug#12026). */ 1190 discussion of bug#11984, bug#12025, bug#12026). */
1191 set_window_buffer (sf->minibuffer_window, 1191 set_window_buffer (sf->minibuffer_window,
1192 XWINDOW (minibuf_window)->buffer, 0, 0); 1192 XWINDOW (minibuf_window)->contents, 0, 0);
1193 minibuf_window = sf->minibuffer_window; 1193 minibuf_window = sf->minibuffer_window;
1194 1194
1195 /* If the dying minibuffer window was selected, 1195 /* If the dying minibuffer window was selected,
@@ -1593,17 +1593,13 @@ make_frame_visible_1 (Lisp_Object window)
1593{ 1593{
1594 struct window *w; 1594 struct window *w;
1595 1595
1596 for (;!NILP (window); window = w->next) 1596 for (; !NILP (window); window = w->next)
1597 { 1597 {
1598 w = XWINDOW (window); 1598 w = XWINDOW (window);
1599 1599 if (WINDOWP (w->contents))
1600 if (!NILP (w->buffer)) 1600 make_frame_visible_1 (w->contents);
1601 bset_display_time (XBUFFER (w->buffer), Fcurrent_time ()); 1601 else
1602 1602 bset_display_time (XBUFFER (w->contents), Fcurrent_time ());
1603 if (!NILP (w->vchild))
1604 make_frame_visible_1 (w->vchild);
1605 if (!NILP (w->hchild))
1606 make_frame_visible_1 (w->hchild);
1607 } 1603 }
1608} 1604}
1609 1605
@@ -1634,7 +1630,7 @@ displayed in the terminal. */)
1634 /* Use set_window_buffer instead of Fset_window_buffer (see 1630 /* Use set_window_buffer instead of Fset_window_buffer (see
1635 discussion of bug#11984, bug#12025, bug#12026). */ 1631 discussion of bug#11984, bug#12025, bug#12026). */
1636 set_window_buffer (sf->minibuffer_window, 1632 set_window_buffer (sf->minibuffer_window,
1637 XWINDOW (minibuf_window)->buffer, 0, 0); 1633 XWINDOW (minibuf_window)->contents, 0, 0);
1638 minibuf_window = sf->minibuffer_window; 1634 minibuf_window = sf->minibuffer_window;
1639 } 1635 }
1640 1636
@@ -1665,7 +1661,7 @@ If omitted, FRAME defaults to the currently selected frame. */)
1665 /* Use set_window_buffer instead of Fset_window_buffer (see 1661 /* Use set_window_buffer instead of Fset_window_buffer (see
1666 discussion of bug#11984, bug#12025, bug#12026). */ 1662 discussion of bug#11984, bug#12025, bug#12026). */
1667 set_window_buffer (sf->minibuffer_window, 1663 set_window_buffer (sf->minibuffer_window,
1668 XWINDOW (minibuf_window)->buffer, 0, 0); 1664 XWINDOW (minibuf_window)->contents, 0, 0);
1669 minibuf_window = sf->minibuffer_window; 1665 minibuf_window = sf->minibuffer_window;
1670 } 1666 }
1671 1667
@@ -1819,7 +1815,7 @@ See `redirect-frame-focus'. */)
1819/* Return the value of frame parameter PROP in frame FRAME. */ 1815/* Return the value of frame parameter PROP in frame FRAME. */
1820 1816
1821#ifdef HAVE_WINDOW_SYSTEM 1817#ifdef HAVE_WINDOW_SYSTEM
1822#if !HAVE_NS 1818#if !HAVE_NS && !defined(WINDOWSNT)
1823static 1819static
1824#endif 1820#endif
1825Lisp_Object 1821Lisp_Object
@@ -3315,16 +3311,15 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3315 else if (FLOATP (item)) 3311 else if (FLOATP (item))
3316 { 3312 {
3317 alpha = XFLOAT_DATA (item); 3313 alpha = XFLOAT_DATA (item);
3318 if (alpha < 0.0 || 1.0 < alpha) 3314 if (! (0 <= alpha && alpha <= 1.0))
3319 args_out_of_range (make_float (0.0), make_float (1.0)); 3315 args_out_of_range (make_float (0.0), make_float (1.0));
3320 } 3316 }
3321 else if (INTEGERP (item)) 3317 else if (INTEGERP (item))
3322 { 3318 {
3323 EMACS_INT ialpha = XINT (item); 3319 EMACS_INT ialpha = XINT (item);
3324 if (ialpha < 0 || 100 < ialpha) 3320 if (! (0 <= ialpha && alpha <= 100))
3325 args_out_of_range (make_number (0), make_number (100)); 3321 args_out_of_range (make_number (0), make_number (100));
3326 else 3322 alpha = ialpha / 100.0;
3327 alpha = ialpha / 100.0;
3328 } 3323 }
3329 else 3324 else
3330 wrong_type_argument (Qnumberp, item); 3325 wrong_type_argument (Qnumberp, item);
@@ -3495,11 +3490,10 @@ The optional arguments COMPONENT and SUBCLASS add to the key and the
3495class, respectively. You must specify both of them or neither. 3490class, respectively. You must specify both of them or neither.
3496If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE' 3491If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3497and the class is `Emacs.CLASS.SUBCLASS'. */) 3492and the class is `Emacs.CLASS.SUBCLASS'. */)
3498 (Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) 3493 (Lisp_Object attribute, Lisp_Object class, Lisp_Object component,
3494 Lisp_Object subclass)
3499{ 3495{
3500#ifdef HAVE_X_WINDOWS 3496 check_window_system ();
3501 check_x ();
3502#endif
3503 3497
3504 return xrdb_get_resource (check_x_display_info (Qnil)->xrdb, 3498 return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
3505 attribute, class, component, subclass); 3499 attribute, class, component, subclass);
@@ -3508,7 +3502,9 @@ and the class is `Emacs.CLASS.SUBCLASS'. */)
3508/* Get an X resource, like Fx_get_resource, but for display DPYINFO. */ 3502/* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3509 3503
3510Lisp_Object 3504Lisp_Object
3511display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) 3505display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute,
3506 Lisp_Object class, Lisp_Object component,
3507 Lisp_Object subclass)
3512{ 3508{
3513 return xrdb_get_resource (dpyinfo->xrdb, 3509 return xrdb_get_resource (dpyinfo->xrdb,
3514 attribute, class, component, subclass); 3510 attribute, class, component, subclass);
diff --git a/src/frame.h b/src/frame.h
index 7a4943327eb..46e18dd8ddb 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -170,9 +170,11 @@ struct frame
170 most recently buried buffer is first. For last-buffer. */ 170 most recently buried buffer is first. For last-buffer. */
171 Lisp_Object buried_buffer_list; 171 Lisp_Object buried_buffer_list;
172 172
173#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
173 /* A dummy window used to display menu bars under X when no X 174 /* A dummy window used to display menu bars under X when no X
174 toolkit support is available. */ 175 toolkit support is available. */
175 Lisp_Object menu_bar_window; 176 Lisp_Object menu_bar_window;
177#endif
176 178
177 /* A window used to display the tool-bar of a frame. */ 179 /* A window used to display the tool-bar of a frame. */
178 Lisp_Object tool_bar_window; 180 Lisp_Object tool_bar_window;
@@ -425,10 +427,6 @@ struct frame
425 /* Width of bar cursor (if we are using that) for blink-off state. */ 427 /* Width of bar cursor (if we are using that) for blink-off state. */
426 int blink_off_cursor_width; 428 int blink_off_cursor_width;
427 429
428 /* Nonnegative if current redisplay should not do scroll computation
429 for lines beyond a certain vpos. This is the vpos. */
430 int scroll_bottom_vpos;
431
432 /* Configured width of the scroll bar, in pixels and in characters. 430 /* Configured width of the scroll bar, in pixels and in characters.
433 config_scroll_bar_cols tracks config_scroll_bar_width if the 431 config_scroll_bar_cols tracks config_scroll_bar_width if the
434 latter is positive; a zero value in config_scroll_bar_width means 432 latter is positive; a zero value in config_scroll_bar_width means
@@ -515,11 +513,13 @@ fset_menu_bar_vector (struct frame *f, Lisp_Object val)
515{ 513{
516 f->menu_bar_vector = val; 514 f->menu_bar_vector = val;
517} 515}
516#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
518FRAME_INLINE void 517FRAME_INLINE void
519fset_menu_bar_window (struct frame *f, Lisp_Object val) 518fset_menu_bar_window (struct frame *f, Lisp_Object val)
520{ 519{
521 f->menu_bar_window = val; 520 f->menu_bar_window = val;
522} 521}
522#endif
523FRAME_INLINE void 523FRAME_INLINE void
524fset_name (struct frame *f, Lisp_Object val) 524fset_name (struct frame *f, Lisp_Object val)
525{ 525{
@@ -781,7 +781,6 @@ typedef struct frame *FRAME_PTR;
781#define FRAME_DELETE_COST(f) (f)->delete_line_cost 781#define FRAME_DELETE_COST(f) (f)->delete_line_cost
782#define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost 782#define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
783#define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost 783#define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
784#define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
785#define FRAME_FOCUS_FRAME(f) f->focus_frame 784#define FRAME_FOCUS_FRAME(f) f->focus_frame
786 785
787/* This frame slot says whether scroll bars are currently enabled for frame F, 786/* This frame slot says whether scroll bars are currently enabled for frame F,
diff --git a/src/fringe.c b/src/fringe.c
index fa6f889ba69..f728cd6d5ff 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -699,7 +699,7 @@ get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor)
699{ 699{
700 Lisp_Object cmap, bm = Qnil; 700 Lisp_Object cmap, bm = Qnil;
701 701
702 if ((cmap = BVAR (XBUFFER (w->buffer), fringe_cursor_alist)), !NILP (cmap)) 702 if ((cmap = BVAR (XBUFFER (w->contents), fringe_cursor_alist)), !NILP (cmap))
703 { 703 {
704 bm = Fassq (cursor, cmap); 704 bm = Fassq (cursor, cmap);
705 if (CONSP (bm)) 705 if (CONSP (bm))
@@ -736,7 +736,7 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
736 If partial, lookup partial bitmap in default value if not found here. 736 If partial, lookup partial bitmap in default value if not found here.
737 If not partial, or no partial spec is present, use non-partial bitmap. */ 737 If not partial, or no partial spec is present, use non-partial bitmap. */
738 738
739 if ((cmap = BVAR (XBUFFER (w->buffer), fringe_indicator_alist)), !NILP (cmap)) 739 if ((cmap = BVAR (XBUFFER (w->contents), fringe_indicator_alist)), !NILP (cmap))
740 { 740 {
741 bm1 = Fassq (bitmap, cmap); 741 bm1 = Fassq (bitmap, cmap);
742 if (CONSP (bm1)) 742 if (CONSP (bm1))
@@ -963,7 +963,7 @@ update_window_fringes (struct window *w, int keep_current_p)
963 return 0; 963 return 0;
964 964
965 if (!MINI_WINDOW_P (w) 965 if (!MINI_WINDOW_P (w)
966 && (ind = BVAR (XBUFFER (w->buffer), indicate_buffer_boundaries), !NILP (ind))) 966 && (ind = BVAR (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind)))
967 { 967 {
968 if (EQ (ind, Qleft) || EQ (ind, Qright)) 968 if (EQ (ind, Qleft) || EQ (ind, Qright))
969 boundary_top = boundary_bot = arrow_top = arrow_bot = ind; 969 boundary_top = boundary_bot = arrow_top = arrow_bot = ind;
@@ -1004,7 +1004,7 @@ update_window_fringes (struct window *w, int keep_current_p)
1004 { 1004 {
1005 if (top_ind_rn < 0 && row->visible_height > 0) 1005 if (top_ind_rn < 0 && row->visible_height > 0)
1006 { 1006 {
1007 if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)) 1007 if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->contents))
1008 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) 1008 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row))
1009 row->indicate_bob_p = !NILP (boundary_top); 1009 row->indicate_bob_p = !NILP (boundary_top);
1010 else 1010 else
@@ -1014,7 +1014,7 @@ update_window_fringes (struct window *w, int keep_current_p)
1014 1014
1015 if (bot_ind_rn < 0) 1015 if (bot_ind_rn < 0)
1016 { 1016 {
1017 if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)) 1017 if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->contents))
1018 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P (w, row)) 1018 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P (w, row))
1019 row->indicate_eob_p = !NILP (boundary_bot), bot_ind_rn = rn; 1019 row->indicate_eob_p = !NILP (boundary_bot), bot_ind_rn = rn;
1020 else if (y + row->height >= yb) 1020 else if (y + row->height >= yb)
@@ -1024,7 +1024,7 @@ update_window_fringes (struct window *w, int keep_current_p)
1024 } 1024 }
1025 } 1025 }
1026 1026
1027 empty_pos = BVAR (XBUFFER (w->buffer), indicate_empty_lines); 1027 empty_pos = BVAR (XBUFFER (w->contents), indicate_empty_lines);
1028 if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) 1028 if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
1029 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; 1029 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
1030 1030
diff --git a/src/ftfont.c b/src/ftfont.c
index 867e25a7a25..0ad173af98a 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -393,7 +393,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for)
393 cache_data = xmalloc (sizeof *cache_data); 393 cache_data = xmalloc (sizeof *cache_data);
394 cache_data->ft_face = NULL; 394 cache_data->ft_face = NULL;
395 cache_data->fc_charset = NULL; 395 cache_data->fc_charset = NULL;
396 val = make_save_value ("pi", cache_data, 0); 396 val = make_save_value (SAVE_TYPE_PTR_INT, cache_data, 0);
397 cache = Fcons (Qnil, val); 397 cache = Fcons (Qnil, val);
398 Fputhash (key, cache, ft_face_cache); 398 Fputhash (key, cache, ft_face_cache);
399 } 399 }
@@ -1211,7 +1211,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
1211 return Qnil; 1211 return Qnil;
1212 } 1212 }
1213 } 1213 }
1214 XSAVE_INTEGER (val, 1)++; 1214 set_save_integer (val, 1, XSAVE_INTEGER (val, 1) + 1);
1215 size = XINT (AREF (entity, FONT_SIZE_INDEX)); 1215 size = XINT (AREF (entity, FONT_SIZE_INDEX));
1216 if (size == 0) 1216 if (size == 0)
1217 size = pixel_size; 1217 size = pixel_size;
@@ -1326,7 +1326,7 @@ ftfont_close (FRAME_PTR f, struct font *font)
1326 cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE); 1326 cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE);
1327 eassert (CONSP (cache)); 1327 eassert (CONSP (cache));
1328 val = XCDR (cache); 1328 val = XCDR (cache);
1329 XSAVE_INTEGER (val, 1)--; 1329 set_save_integer (val, 1, XSAVE_INTEGER (val, 1) - 1);
1330 if (XSAVE_INTEGER (val, 1) == 0) 1330 if (XSAVE_INTEGER (val, 1) == 0)
1331 { 1331 {
1332 struct ftfont_cache_data *cache_data = XSAVE_POINTER (val, 0); 1332 struct ftfont_cache_data *cache_data = XSAVE_POINTER (val, 0);
diff --git a/src/gtkutil.c b/src/gtkutil.c
index d6e4dcebcd3..f83d8660fcc 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1094,7 +1094,9 @@ style_changed_cb (GObject *go,
1094 FOR_EACH_FRAME (rest, frame) 1094 FOR_EACH_FRAME (rest, frame)
1095 { 1095 {
1096 FRAME_PTR f = XFRAME (frame); 1096 FRAME_PTR f = XFRAME (frame);
1097 if (FRAME_X_DISPLAY (f) == dpy) 1097 if (FRAME_LIVE_P (f)
1098 && FRAME_X_P (f)
1099 && FRAME_X_DISPLAY (f) == dpy)
1098 { 1100 {
1099 x_set_scroll_bar_default_width (f); 1101 x_set_scroll_bar_default_width (f);
1100 xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f)); 1102 xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f));
diff --git a/src/image.c b/src/image.c
index 3eec8b6c13d..cac23b7fa87 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7373,11 +7373,10 @@ gif_load (struct frame *f, struct image *img)
7373 y < subimg_height; 7373 y < subimg_height;
7374 y++, row += interlace_increment[pass]) 7374 y++, row += interlace_increment[pass])
7375 { 7375 {
7376 if (row >= subimg_height) 7376 while (subimg_height <= row)
7377 { 7377 {
7378 lint_assume (pass < 3);
7378 row = interlace_start[++pass]; 7379 row = interlace_start[++pass];
7379 while (row >= subimg_height)
7380 row = interlace_start[++pass];
7381 } 7380 }
7382 7381
7383 for (x = 0; x < subimg_width; x++) 7382 for (x = 0; x < subimg_width; x++)
@@ -8121,24 +8120,25 @@ svg_image_p (Lisp_Object object)
8121#ifdef WINDOWSNT 8120#ifdef WINDOWSNT
8122 8121
8123/* SVG library functions. */ 8122/* SVG library functions. */
8124DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new); 8123DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new, (void));
8125DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions); 8124DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions, (RsvgHandle *, RsvgDimensionData *));
8126DEF_IMGLIB_FN (gboolean, rsvg_handle_write); 8125DEF_IMGLIB_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **));
8127DEF_IMGLIB_FN (gboolean, rsvg_handle_close); 8126DEF_IMGLIB_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **));
8128DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf); 8127DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *));
8129 8128DEF_IMGLIB_FN (void *, rsvg_handle_set_size_callback, (RsvgHandle *, RsvgSizeFunc, gpointer, GDestroyNotify));
8130DEF_IMGLIB_FN (int, gdk_pixbuf_get_width); 8129
8131DEF_IMGLIB_FN (int, gdk_pixbuf_get_height); 8130DEF_IMGLIB_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *));
8132DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels); 8131DEF_IMGLIB_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *));
8133DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride); 8132DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *));
8134DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace); 8133DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *));
8135DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels); 8134DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *));
8136DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha); 8135DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *));
8137DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample); 8136DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *));
8138 8137DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *));
8139DEF_IMGLIB_FN (void, g_type_init); 8138
8140DEF_IMGLIB_FN (void, g_object_unref); 8139DEF_IMGLIB_FN (void, g_type_init, (void));
8141DEF_IMGLIB_FN (void, g_error_free); 8140DEF_IMGLIB_FN (void, g_object_unref, (gpointer));
8141DEF_IMGLIB_FN (void, g_error_free, (GError *));
8142 8142
8143Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; 8143Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
8144 8144
diff --git a/src/indent.c b/src/indent.c
index d1f95da6bcf..67796ab8a8f 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -56,11 +56,6 @@ static EMACS_INT last_known_column_modified;
56static ptrdiff_t current_column_1 (void); 56static ptrdiff_t current_column_1 (void);
57static ptrdiff_t position_indentation (ptrdiff_t); 57static ptrdiff_t position_indentation (ptrdiff_t);
58 58
59/* Cache of beginning of line found by the last call of
60 current_column. */
61
62static ptrdiff_t current_column_bol_cache;
63
64/* Get the display table to use for the current buffer. */ 59/* Get the display table to use for the current buffer. */
65 60
66struct Lisp_Char_Table * 61struct Lisp_Char_Table *
@@ -254,7 +249,7 @@ skip_invisible (ptrdiff_t pos, ptrdiff_t *next_boundary_p, ptrdiff_t to, Lisp_Ob
254 the next property change */ 249 the next property change */
255 prop = Fget_char_property (position, Qinvisible, 250 prop = Fget_char_property (position, Qinvisible,
256 (!NILP (window) 251 (!NILP (window)
257 && EQ (XWINDOW (window)->buffer, buffer)) 252 && EQ (XWINDOW (window)->contents, buffer))
258 ? window : buffer); 253 ? window : buffer);
259 inv_p = TEXT_PROP_MEANS_INVISIBLE (prop); 254 inv_p = TEXT_PROP_MEANS_INVISIBLE (prop);
260 /* When counting columns (window == nil), don't skip over ellipsis text. */ 255 /* When counting columns (window == nil), don't skip over ellipsis text. */
@@ -439,11 +434,6 @@ current_column (void)
439 col += post_tab; 434 col += post_tab;
440 } 435 }
441 436
442 if (ptr == BEGV_ADDR)
443 current_column_bol_cache = BEGV;
444 else
445 current_column_bol_cache = BYTE_TO_CHAR (PTR_BYTE_POS (ptr));
446
447 last_known_column = col; 437 last_known_column = col;
448 last_known_column_point = PT; 438 last_known_column_point = PT;
449 last_known_column_modified = MODIFF; 439 last_known_column_modified = MODIFF;
@@ -525,7 +515,6 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol)
525 { 515 {
526 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; 516 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
527 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); 517 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
528 current_column_bol_cache = PT;
529 scan = PT, scan_byte = PT_BYTE; 518 scan = PT, scan_byte = PT_BYTE;
530 SET_PT_BOTH (opoint, opoint_byte); 519 SET_PT_BOTH (opoint, opoint_byte);
531 next_boundary = scan; 520 next_boundary = scan;
@@ -1088,8 +1077,8 @@ static struct position val_compute_motion;
1088 : (window_width + window_left != frame_cols)) 1077 : (window_width + window_left != frame_cols))
1089 1078
1090 where 1079 where
1091 window_width is XFASTINT (w->total_cols), 1080 window_width is w->total_cols,
1092 window_left is XFASTINT (w->left_col), 1081 window_left is w->left_col,
1093 has_vertical_scroll_bars is 1082 has_vertical_scroll_bars is
1094 WINDOW_HAS_VERTICAL_SCROLL_BAR (window) 1083 WINDOW_HAS_VERTICAL_SCROLL_BAR (window)
1095 and frame_cols = FRAME_COLS (XFRAME (window->frame)) 1084 and frame_cols = FRAME_COLS (XFRAME (window->frame))
@@ -1826,7 +1815,7 @@ vmotion (register ptrdiff_t from, register ptrdiff_t from_byte,
1826 1815
1827 /* If the window contains this buffer, use it for getting text properties. 1816 /* If the window contains this buffer, use it for getting text properties.
1828 Otherwise use the current buffer as arg for doing that. */ 1817 Otherwise use the current buffer as arg for doing that. */
1829 if (EQ (w->buffer, Fcurrent_buffer ())) 1818 if (EQ (w->contents, Fcurrent_buffer ()))
1830 text_prop_object = window; 1819 text_prop_object = window;
1831 else 1820 else
1832 text_prop_object = Fcurrent_buffer (); 1821 text_prop_object = Fcurrent_buffer ();
@@ -1979,14 +1968,14 @@ whether or not it is currently displayed in some window. */)
1979 1968
1980 old_buffer = Qnil; 1969 old_buffer = Qnil;
1981 GCPRO1 (old_buffer); 1970 GCPRO1 (old_buffer);
1982 if (XBUFFER (w->buffer) != current_buffer) 1971 if (XBUFFER (w->contents) != current_buffer)
1983 { 1972 {
1984 /* Set the window's buffer temporarily to the current buffer. */ 1973 /* Set the window's buffer temporarily to the current buffer. */
1985 old_buffer = w->buffer; 1974 old_buffer = w->contents;
1986 old_charpos = marker_position (w->pointm); 1975 old_charpos = marker_position (w->pointm);
1987 old_bytepos = marker_byte_position (w->pointm); 1976 old_bytepos = marker_byte_position (w->pointm);
1988 wset_buffer (w, Fcurrent_buffer ()); 1977 wset_buffer (w, Fcurrent_buffer ());
1989 set_marker_both (w->pointm, w->buffer, 1978 set_marker_both (w->pointm, w->contents,
1990 BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer)); 1979 BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer));
1991 } 1980 }
1992 1981
@@ -2139,7 +2128,7 @@ whether or not it is currently displayed in some window. */)
2139 if (BUFFERP (old_buffer)) 2128 if (BUFFERP (old_buffer))
2140 { 2129 {
2141 wset_buffer (w, old_buffer); 2130 wset_buffer (w, old_buffer);
2142 set_marker_both (w->pointm, w->buffer, 2131 set_marker_both (w->pointm, w->contents,
2143 old_charpos, old_bytepos); 2132 old_charpos, old_bytepos);
2144 } 2133 }
2145 2134
diff --git a/src/insdel.c b/src/insdel.c
index 3dd81ffeb62..8029291cd68 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1801,7 +1801,7 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
1801 1801
1802 /* If we're modifying the buffer other than shown in a selected window, 1802 /* If we're modifying the buffer other than shown in a selected window,
1803 let redisplay consider other windows if this buffer is visible. */ 1803 let redisplay consider other windows if this buffer is visible. */
1804 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer 1804 if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer
1805 && buffer_window_count (current_buffer)) 1805 && buffer_window_count (current_buffer))
1806 ++windows_or_buffers_changed; 1806 ++windows_or_buffers_changed;
1807 1807
diff --git a/src/intervals.c b/src/intervals.c
index db38c86c00b..f65ce0ecc77 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -110,14 +110,14 @@ create_root_interval (Lisp_Object parent)
110 { 110 {
111 new->total_length = (BUF_Z (XBUFFER (parent)) 111 new->total_length = (BUF_Z (XBUFFER (parent))
112 - BUF_BEG (XBUFFER (parent))); 112 - BUF_BEG (XBUFFER (parent)));
113 eassert (0 <= TOTAL_LENGTH (new)); 113 eassert (TOTAL_LENGTH (new) >= 0);
114 set_buffer_intervals (XBUFFER (parent), new); 114 set_buffer_intervals (XBUFFER (parent), new);
115 new->position = BEG; 115 new->position = BEG;
116 } 116 }
117 else if (STRINGP (parent)) 117 else if (STRINGP (parent))
118 { 118 {
119 new->total_length = SCHARS (parent); 119 new->total_length = SCHARS (parent);
120 eassert (0 <= TOTAL_LENGTH (new)); 120 eassert (TOTAL_LENGTH (new) >= 0);
121 set_string_intervals (parent, new); 121 set_string_intervals (parent, new);
122 new->position = 0; 122 new->position = 0;
123 } 123 }
@@ -371,11 +371,11 @@ rotate_right (INTERVAL interval)
371 371
372 /* A's total length is decreased by the length of B and its left child. */ 372 /* A's total length is decreased by the length of B and its left child. */
373 interval->total_length -= B->total_length - LEFT_TOTAL_LENGTH (interval); 373 interval->total_length -= B->total_length - LEFT_TOTAL_LENGTH (interval);
374 eassert (0 <= TOTAL_LENGTH (interval)); 374 eassert (TOTAL_LENGTH (interval) >= 0);
375 375
376 /* B must have the same total length of A. */ 376 /* B must have the same total length of A. */
377 B->total_length = old_total; 377 B->total_length = old_total;
378 eassert (0 <= TOTAL_LENGTH (B)); 378 eassert (TOTAL_LENGTH (B) >= 0);
379 379
380 return B; 380 return B;
381} 381}
@@ -418,11 +418,11 @@ rotate_left (INTERVAL interval)
418 418
419 /* A's total length is decreased by the length of B and its right child. */ 419 /* A's total length is decreased by the length of B and its right child. */
420 interval->total_length -= B->total_length - RIGHT_TOTAL_LENGTH (interval); 420 interval->total_length -= B->total_length - RIGHT_TOTAL_LENGTH (interval);
421 eassert (0 <= TOTAL_LENGTH (interval)); 421 eassert (TOTAL_LENGTH (interval) >= 0);
422 422
423 /* B must have the same total length of A. */ 423 /* B must have the same total length of A. */
424 B->total_length = old_total; 424 B->total_length = old_total;
425 eassert (0 <= TOTAL_LENGTH (B)); 425 eassert (TOTAL_LENGTH (B) >= 0);
426 426
427 return B; 427 return B;
428} 428}
@@ -556,7 +556,7 @@ split_interval_right (INTERVAL interval, ptrdiff_t offset)
556 { 556 {
557 set_interval_right (interval, new); 557 set_interval_right (interval, new);
558 new->total_length = new_length; 558 new->total_length = new_length;
559 eassert (0 <= TOTAL_LENGTH (new)); 559 eassert (TOTAL_LENGTH (new) >= 0);
560 } 560 }
561 else 561 else
562 { 562 {
@@ -565,7 +565,7 @@ split_interval_right (INTERVAL interval, ptrdiff_t offset)
565 set_interval_parent (interval->right, new); 565 set_interval_parent (interval->right, new);
566 set_interval_right (interval, new); 566 set_interval_right (interval, new);
567 new->total_length = new_length + new->right->total_length; 567 new->total_length = new_length + new->right->total_length;
568 eassert (0 <= TOTAL_LENGTH (new)); 568 eassert (TOTAL_LENGTH (new) >= 0);
569 balance_an_interval (new); 569 balance_an_interval (new);
570 } 570 }
571 571
@@ -601,7 +601,7 @@ split_interval_left (INTERVAL interval, ptrdiff_t offset)
601 { 601 {
602 set_interval_left (interval, new); 602 set_interval_left (interval, new);
603 new->total_length = new_length; 603 new->total_length = new_length;
604 eassert (0 <= TOTAL_LENGTH (new)); 604 eassert (TOTAL_LENGTH (new) >= 0);
605 } 605 }
606 else 606 else
607 { 607 {
@@ -610,7 +610,7 @@ split_interval_left (INTERVAL interval, ptrdiff_t offset)
610 set_interval_parent (new->left, new); 610 set_interval_parent (new->left, new);
611 set_interval_left (interval, new); 611 set_interval_left (interval, new);
612 new->total_length = new_length + new->left->total_length; 612 new->total_length = new_length + new->left->total_length;
613 eassert (0 <= TOTAL_LENGTH (new)); 613 eassert (TOTAL_LENGTH (new) >= 0);
614 balance_an_interval (new); 614 balance_an_interval (new);
615 } 615 }
616 616
@@ -960,7 +960,7 @@ adjust_intervals_for_insertion (INTERVAL tree,
960 for (temp = prev ? prev : i; temp; temp = INTERVAL_PARENT_OR_NULL (temp)) 960 for (temp = prev ? prev : i; temp; temp = INTERVAL_PARENT_OR_NULL (temp))
961 { 961 {
962 temp->total_length += length; 962 temp->total_length += length;
963 eassert (0 <= TOTAL_LENGTH (temp)); 963 eassert (TOTAL_LENGTH (temp) >= 0);
964 temp = balance_possible_root_interval (temp); 964 temp = balance_possible_root_interval (temp);
965 } 965 }
966 966
@@ -1016,7 +1016,7 @@ adjust_intervals_for_insertion (INTERVAL tree,
1016 for (temp = i; temp; temp = INTERVAL_PARENT_OR_NULL (temp)) 1016 for (temp = i; temp; temp = INTERVAL_PARENT_OR_NULL (temp))
1017 { 1017 {
1018 temp->total_length += length; 1018 temp->total_length += length;
1019 eassert (0 <= TOTAL_LENGTH (temp)); 1019 eassert (TOTAL_LENGTH (temp) >= 0);
1020 temp = balance_possible_root_interval (temp); 1020 temp = balance_possible_root_interval (temp);
1021 } 1021 }
1022 } 1022 }
@@ -1218,7 +1218,7 @@ delete_node (register INTERVAL i)
1218 this = this->left; 1218 this = this->left;
1219 this->total_length += migrate_amt; 1219 this->total_length += migrate_amt;
1220 } 1220 }
1221 eassert (0 <= TOTAL_LENGTH (this)); 1221 eassert (TOTAL_LENGTH (this) >= 0);
1222 set_interval_left (this, migrate); 1222 set_interval_left (this, migrate);
1223 set_interval_parent (migrate, this); 1223 set_interval_parent (migrate, this);
1224 1224
@@ -1300,7 +1300,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from,
1300 relative_position, 1300 relative_position,
1301 amount); 1301 amount);
1302 tree->total_length -= subtract; 1302 tree->total_length -= subtract;
1303 eassert (0 <= TOTAL_LENGTH (tree)); 1303 eassert (TOTAL_LENGTH (tree) >= 0);
1304 return subtract; 1304 return subtract;
1305 } 1305 }
1306 /* Right branch. */ 1306 /* Right branch. */
@@ -1315,7 +1315,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from,
1315 relative_position, 1315 relative_position,
1316 amount); 1316 amount);
1317 tree->total_length -= subtract; 1317 tree->total_length -= subtract;
1318 eassert (0 <= TOTAL_LENGTH (tree)); 1318 eassert (TOTAL_LENGTH (tree) >= 0);
1319 return subtract; 1319 return subtract;
1320 } 1320 }
1321 /* Here -- this node. */ 1321 /* Here -- this node. */
@@ -1330,7 +1330,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from,
1330 amount = my_amount; 1330 amount = my_amount;
1331 1331
1332 tree->total_length -= amount; 1332 tree->total_length -= amount;
1333 eassert (0 <= TOTAL_LENGTH (tree)); 1333 eassert (TOTAL_LENGTH (tree) >= 0);
1334 if (LENGTH (tree) == 0) 1334 if (LENGTH (tree) == 0)
1335 delete_interval (tree); 1335 delete_interval (tree);
1336 1336
@@ -1372,7 +1372,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
1372 if (ONLY_INTERVAL_P (tree)) 1372 if (ONLY_INTERVAL_P (tree))
1373 { 1373 {
1374 tree->total_length -= length; 1374 tree->total_length -= length;
1375 eassert (0 <= TOTAL_LENGTH (tree)); 1375 eassert (TOTAL_LENGTH (tree) >= 0);
1376 return; 1376 return;
1377 } 1377 }
1378 1378
@@ -1435,19 +1435,19 @@ merge_interval_right (register INTERVAL i)
1435 while (! NULL_LEFT_CHILD (successor)) 1435 while (! NULL_LEFT_CHILD (successor))
1436 { 1436 {
1437 successor->total_length += absorb; 1437 successor->total_length += absorb;
1438 eassert (0 <= TOTAL_LENGTH (successor)); 1438 eassert (TOTAL_LENGTH (successor) >= 0);
1439 successor = successor->left; 1439 successor = successor->left;
1440 } 1440 }
1441 1441
1442 successor->total_length += absorb; 1442 successor->total_length += absorb;
1443 eassert (0 <= TOTAL_LENGTH (successor)); 1443 eassert (TOTAL_LENGTH (successor) >= 0);
1444 delete_interval (i); 1444 delete_interval (i);
1445 return successor; 1445 return successor;
1446 } 1446 }
1447 1447
1448 /* Zero out this interval. */ 1448 /* Zero out this interval. */
1449 i->total_length -= absorb; 1449 i->total_length -= absorb;
1450 eassert (0 <= TOTAL_LENGTH (i)); 1450 eassert (TOTAL_LENGTH (i) >= 0);
1451 1451
1452 successor = i; 1452 successor = i;
1453 while (! NULL_PARENT (successor)) /* It's above us. Subtract as 1453 while (! NULL_PARENT (successor)) /* It's above us. Subtract as
@@ -1462,7 +1462,7 @@ merge_interval_right (register INTERVAL i)
1462 1462
1463 successor = INTERVAL_PARENT (successor); 1463 successor = INTERVAL_PARENT (successor);
1464 successor->total_length -= absorb; 1464 successor->total_length -= absorb;
1465 eassert (0 <= TOTAL_LENGTH (successor)); 1465 eassert (TOTAL_LENGTH (successor) >= 0);
1466 } 1466 }
1467 1467
1468 /* This must be the rightmost or last interval and cannot 1468 /* This must be the rightmost or last interval and cannot
@@ -1491,19 +1491,19 @@ merge_interval_left (register INTERVAL i)
1491 while (! NULL_RIGHT_CHILD (predecessor)) 1491 while (! NULL_RIGHT_CHILD (predecessor))
1492 { 1492 {
1493 predecessor->total_length += absorb; 1493 predecessor->total_length += absorb;
1494 eassert (0 <= TOTAL_LENGTH (predecessor)); 1494 eassert (TOTAL_LENGTH (predecessor) >= 0);
1495 predecessor = predecessor->right; 1495 predecessor = predecessor->right;
1496 } 1496 }
1497 1497
1498 predecessor->total_length += absorb; 1498 predecessor->total_length += absorb;
1499 eassert (0 <= TOTAL_LENGTH (predecessor)); 1499 eassert (TOTAL_LENGTH (predecessor) >= 0);
1500 delete_interval (i); 1500 delete_interval (i);
1501 return predecessor; 1501 return predecessor;
1502 } 1502 }
1503 1503
1504 /* Zero out this interval. */ 1504 /* Zero out this interval. */
1505 i->total_length -= absorb; 1505 i->total_length -= absorb;
1506 eassert (0 <= TOTAL_LENGTH (i)); 1506 eassert (TOTAL_LENGTH (i) >= 0);
1507 1507
1508 predecessor = i; 1508 predecessor = i;
1509 while (! NULL_PARENT (predecessor)) /* It's above us. Go up, 1509 while (! NULL_PARENT (predecessor)) /* It's above us. Go up,
@@ -1518,7 +1518,7 @@ merge_interval_left (register INTERVAL i)
1518 1518
1519 predecessor = INTERVAL_PARENT (predecessor); 1519 predecessor = INTERVAL_PARENT (predecessor);
1520 predecessor->total_length -= absorb; 1520 predecessor->total_length -= absorb;
1521 eassert (0 <= TOTAL_LENGTH (predecessor)); 1521 eassert (TOTAL_LENGTH (predecessor) >= 0);
1522 } 1522 }
1523 1523
1524 /* This must be the leftmost or first interval and cannot 1524 /* This must be the leftmost or first interval and cannot
@@ -2272,7 +2272,7 @@ copy_intervals (INTERVAL tree, ptrdiff_t start, ptrdiff_t length)
2272 new->position = 0; 2272 new->position = 0;
2273 got = (LENGTH (i) - (start - i->position)); 2273 got = (LENGTH (i) - (start - i->position));
2274 new->total_length = length; 2274 new->total_length = length;
2275 eassert (0 <= TOTAL_LENGTH (new)); 2275 eassert (TOTAL_LENGTH (new) >= 0);
2276 copy_properties (i, new); 2276 copy_properties (i, new);
2277 2277
2278 t = new; 2278 t = new;
@@ -2355,7 +2355,7 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag,
2355 i->total_length = end - start; 2355 i->total_length = end - start;
2356 else 2356 else
2357 i->total_length = end_byte - start_byte; 2357 i->total_length = end_byte - start_byte;
2358 eassert (0 <= TOTAL_LENGTH (i)); 2358 eassert (TOTAL_LENGTH (i) >= 0);
2359 2359
2360 if (TOTAL_LENGTH (i) == 0) 2360 if (TOTAL_LENGTH (i) == 0)
2361 { 2361 {
diff --git a/src/keyboard.c b/src/keyboard.c
index e43b7a73172..beba3025887 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -210,12 +210,6 @@ static EMACS_INT last_auto_save;
210/* The value of point when the last command was started. */ 210/* The value of point when the last command was started. */
211static ptrdiff_t last_point_position; 211static ptrdiff_t last_point_position;
212 212
213/* The buffer that was current when the last command was started. */
214static Lisp_Object last_point_position_buffer;
215
216/* The window that was selected when the last command was started. */
217static Lisp_Object last_point_position_window;
218
219/* The frame in which the last input event occurred, or Qmacro if the 213/* The frame in which the last input event occurred, or Qmacro if the
220 last event came from a macro. We use this to determine when to 214 last event came from a macro. We use this to determine when to
221 generate switch-frame events. This may be cleared by functions 215 generate switch-frame events. This may be cleared by functions
@@ -833,7 +827,7 @@ This function is called by the editor initialization to begin editing. */)
833 update_mode_lines = 1; 827 update_mode_lines = 1;
834 828
835 if (command_loop_level 829 if (command_loop_level
836 && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) 830 && current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
837 buffer = Fcurrent_buffer (); 831 buffer = Fcurrent_buffer ();
838 else 832 else
839 buffer = Qnil; 833 buffer = Qnil;
@@ -1395,7 +1389,7 @@ command_loop_1 (void)
1395 Fkill_emacs (Qnil); 1389 Fkill_emacs (Qnil);
1396 1390
1397 /* Make sure the current window's buffer is selected. */ 1391 /* Make sure the current window's buffer is selected. */
1398 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); 1392 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
1399 1393
1400 /* Display any malloc warning that just came out. Use while because 1394 /* Display any malloc warning that just came out. Use while because
1401 displaying one warning can cause another. */ 1395 displaying one warning can cause another. */
@@ -1461,7 +1455,7 @@ command_loop_1 (void)
1461 /* A filter may have run while we were reading the input. */ 1455 /* A filter may have run while we were reading the input. */
1462 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 1456 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
1463 Fkill_emacs (Qnil); 1457 Fkill_emacs (Qnil);
1464 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); 1458 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
1465 1459
1466 ++num_input_keys; 1460 ++num_input_keys;
1467 1461
@@ -1492,7 +1486,7 @@ command_loop_1 (void)
1492 { 1486 {
1493 struct buffer *b; 1487 struct buffer *b;
1494 XWINDOW (selected_window)->force_start = 0; 1488 XWINDOW (selected_window)->force_start = 0;
1495 b = XBUFFER (XWINDOW (selected_window)->buffer); 1489 b = XBUFFER (XWINDOW (selected_window)->contents);
1496 BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0; 1490 BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0;
1497 } 1491 }
1498 1492
@@ -1512,8 +1506,6 @@ command_loop_1 (void)
1512 prev_buffer = current_buffer; 1506 prev_buffer = current_buffer;
1513 prev_modiff = MODIFF; 1507 prev_modiff = MODIFF;
1514 last_point_position = PT; 1508 last_point_position = PT;
1515 last_point_position_window = selected_window;
1516 XSETBUFFER (last_point_position_buffer, prev_buffer);
1517 1509
1518 /* By default, we adjust point to a boundary of a region that 1510 /* By default, we adjust point to a boundary of a region that
1519 has such a property that should be treated intangible 1511 has such a property that should be treated intangible
@@ -5142,7 +5134,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
5142 if (STRINGP (string)) 5134 if (STRINGP (string))
5143 string_info = Fcons (string, make_number (charpos)); 5135 string_info = Fcons (string, make_number (charpos));
5144 textpos = (w == XWINDOW (selected_window) 5136 textpos = (w == XWINDOW (selected_window)
5145 && current_buffer == XBUFFER (w->buffer)) 5137 && current_buffer == XBUFFER (w->contents))
5146 ? PT : marker_position (w->pointm); 5138 ? PT : marker_position (w->pointm);
5147 5139
5148 xret = wx; 5140 xret = wx;
@@ -6766,7 +6758,7 @@ gobble_input (void)
6766 hold_quit.kind = NO_EVENT; 6758 hold_quit.kind = NO_EVENT;
6767 6759
6768 /* No need for FIONREAD or fcntl; just say don't wait. */ 6760 /* No need for FIONREAD or fcntl; just say don't wait. */
6769 while (0 < (nr = (*t->read_socket_hook) (t, &hold_quit))) 6761 while ((nr = (*t->read_socket_hook) (t, &hold_quit)) > 0)
6770 nread += nr; 6762 nread += nr;
6771 6763
6772 if (nr == -1) /* Not OK to read input now. */ 6764 if (nr == -1) /* Not OK to read input now. */
@@ -8240,9 +8232,8 @@ append_tool_bar_item (void)
8240 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); 8232 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS));
8241 8233
8242 /* Enlarge tool_bar_items_vector if necessary. */ 8234 /* Enlarge tool_bar_items_vector if necessary. */
8243 if (0 < incr) 8235 if (incr > 0)
8244 tool_bar_items_vector 8236 tool_bar_items_vector = larger_vector (tool_bar_items_vector, incr, -1);
8245 = larger_vector (tool_bar_items_vector, incr, -1);
8246 8237
8247 /* Append entries from tool_bar_item_properties to the end of 8238 /* Append entries from tool_bar_item_properties to the end of
8248 tool_bar_items_vector. */ 8239 tool_bar_items_vector. */
@@ -9146,9 +9137,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9146 { 9137 {
9147 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9138 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9148 Fkill_emacs (Qnil); 9139 Fkill_emacs (Qnil);
9149 if (XBUFFER (XWINDOW (selected_window)->buffer) 9140 if (XBUFFER (XWINDOW (selected_window)->contents)
9150 != current_buffer) 9141 != current_buffer)
9151 Fset_buffer (XWINDOW (selected_window)->buffer); 9142 Fset_buffer (XWINDOW (selected_window)->contents);
9152 } 9143 }
9153 9144
9154 goto replay_sequence; 9145 goto replay_sequence;
@@ -9196,9 +9187,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9196 special-event-map, ...) might have switched the current buffer 9187 special-event-map, ...) might have switched the current buffer
9197 or the selected window from under us in the mean time. */ 9188 or the selected window from under us in the mean time. */
9198 if (fix_current_buffer 9189 if (fix_current_buffer
9199 && (XBUFFER (XWINDOW (selected_window)->buffer) 9190 && (XBUFFER (XWINDOW (selected_window)->contents)
9200 != current_buffer)) 9191 != current_buffer))
9201 Fset_buffer (XWINDOW (selected_window)->buffer); 9192 Fset_buffer (XWINDOW (selected_window)->contents);
9202 current_binding = active_maps (first_event); 9193 current_binding = active_maps (first_event);
9203 } 9194 }
9204 9195
@@ -9247,8 +9238,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9247 not the current buffer. If we're at the 9238 not the current buffer. If we're at the
9248 beginning of a key sequence, switch buffers. */ 9239 beginning of a key sequence, switch buffers. */
9249 if (WINDOWP (window) 9240 if (WINDOWP (window)
9250 && BUFFERP (XWINDOW (window)->buffer) 9241 && BUFFERP (XWINDOW (window)->contents)
9251 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) 9242 && XBUFFER (XWINDOW (window)->contents) != current_buffer)
9252 { 9243 {
9253 ASET (raw_keybuf, raw_keybuf_count, key); 9244 ASET (raw_keybuf, raw_keybuf_count, key);
9254 raw_keybuf_count++; 9245 raw_keybuf_count++;
@@ -9269,7 +9260,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9269 9260
9270 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9261 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9271 Fkill_emacs (Qnil); 9262 Fkill_emacs (Qnil);
9272 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 9263 set_buffer_internal (XBUFFER (XWINDOW (window)->contents));
9273 goto replay_sequence; 9264 goto replay_sequence;
9274 } 9265 }
9275 } 9266 }
@@ -11048,9 +11039,6 @@ syms_of_keyboard (void)
11048 Fset (Qinput_method_exit_on_first_char, Qnil); 11039 Fset (Qinput_method_exit_on_first_char, Qnil);
11049 Fset (Qinput_method_use_echo_area, Qnil); 11040 Fset (Qinput_method_use_echo_area, Qnil);
11050 11041
11051 last_point_position_buffer = Qnil;
11052 last_point_position_window = Qnil;
11053
11054 { 11042 {
11055 int i; 11043 int i;
11056 int len = sizeof (head_table) / sizeof (head_table[0]); 11044 int len = sizeof (head_table) / sizeof (head_table[0]);
diff --git a/src/keymap.c b/src/keymap.c
index 00eefb375ef..c43d528b25b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -611,7 +611,8 @@ map_keymap_internal (Lisp_Object map,
611 } 611 }
612 else if (CHAR_TABLE_P (binding)) 612 else if (CHAR_TABLE_P (binding))
613 map_char_table (map_keymap_char_table_item, Qnil, binding, 613 map_char_table (map_keymap_char_table_item, Qnil, binding,
614 make_save_value ("ppo", fun, data, args)); 614 make_save_value (SAVE_TYPE_PTR_PTR_OBJ,
615 fun, data, args));
615 } 616 }
616 UNGCPRO; 617 UNGCPRO;
617 return tail; 618 return tail;
@@ -1555,8 +1556,8 @@ like in the respective argument of `key-binding'. */)
1555 window = POSN_WINDOW (position); 1556 window = POSN_WINDOW (position);
1556 1557
1557 if (WINDOWP (window) 1558 if (WINDOWP (window)
1558 && BUFFERP (XWINDOW (window)->buffer) 1559 && BUFFERP (XWINDOW (window)->contents)
1559 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) 1560 && XBUFFER (XWINDOW (window)->contents) != current_buffer)
1560 { 1561 {
1561 /* Arrange to go back to the original buffer once we're done 1562 /* Arrange to go back to the original buffer once we're done
1562 processing the key sequence. We don't use 1563 processing the key sequence. We don't use
@@ -1566,7 +1567,7 @@ like in the respective argument of `key-binding'. */)
1566 things the same. 1567 things the same.
1567 */ 1568 */
1568 record_unwind_current_buffer (); 1569 record_unwind_current_buffer ();
1569 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 1570 set_buffer_internal (XBUFFER (XWINDOW (window)->contents));
1570 } 1571 }
1571 } 1572 }
1572 1573
diff --git a/src/lisp.h b/src/lisp.h
index f526cd36a6f..2e1d20a5109 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -551,6 +551,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
551 return num < lower ? lower : num <= upper ? num : upper; 551 return num < lower ? lower : num <= upper ? num : upper;
552} 552}
553 553
554
554/* Extract a value or address from a Lisp_Object. */ 555/* Extract a value or address from a Lisp_Object. */
555 556
556#define XCONS(a) (eassert (CONSP (a)), \ 557#define XCONS(a) (eassert (CONSP (a)), \
@@ -571,7 +572,6 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
571#define XMISCTYPE(a) (XMISCANY (a)->type) 572#define XMISCTYPE(a) (XMISCANY (a)->type)
572#define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker)) 573#define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker))
573#define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC (a)->u_overlay)) 574#define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC (a)->u_overlay))
574#define XSAVE_VALUE(a) (eassert (SAVE_VALUEP (a)), &(XMISC (a)->u_save_value))
575 575
576/* Forwarding object types. */ 576/* Forwarding object types. */
577 577
@@ -781,13 +781,10 @@ extern ptrdiff_t string_bytes (struct Lisp_String *);
781 would expose alloc.c internal details that we'd rather keep 781 would expose alloc.c internal details that we'd rather keep
782 private. 782 private.
783 783
784 This is a macro for use in static initializers, and a constant for 784 This is a macro for use in static initializers. The cast to
785 visibility to GDB. The cast to ptrdiff_t ensures that 785 ptrdiff_t ensures that the macro is signed. */
786 the macro is signed. */
787static ptrdiff_t const STRING_BYTES_BOUND =
788#define STRING_BYTES_BOUND \ 786#define STRING_BYTES_BOUND \
789 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1)) 787 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1))
790 STRING_BYTES_BOUND;
791 788
792/* Mark STR as a unibyte string. */ 789/* Mark STR as a unibyte string. */
793#define STRING_SET_UNIBYTE(STR) \ 790#define STRING_SET_UNIBYTE(STR) \
@@ -1392,6 +1389,35 @@ enum
1392 SAVE_OBJECT 1389 SAVE_OBJECT
1393 }; 1390 };
1394 1391
1392/* Number of bits needed to store one of the above values. */
1393enum { SAVE_SLOT_BITS = 2 };
1394
1395/* Number of slots in a save value where save_type is nonzero. */
1396enum { SAVE_VALUE_SLOTS = 4 };
1397
1398/* Bit-width and values for struct Lisp_Save_Value's save_type member. */
1399
1400enum { SAVE_TYPE_BITS = SAVE_VALUE_SLOTS * SAVE_SLOT_BITS + 1 };
1401
1402enum Lisp_Save_Type
1403 {
1404 SAVE_TYPE_INT_INT = SAVE_INTEGER + (SAVE_INTEGER << SAVE_SLOT_BITS),
1405 SAVE_TYPE_INT_INT_INT
1406 = (SAVE_INTEGER + (SAVE_TYPE_INT_INT << SAVE_SLOT_BITS)),
1407 SAVE_TYPE_OBJ_OBJ = SAVE_OBJECT + (SAVE_OBJECT << SAVE_SLOT_BITS),
1408 SAVE_TYPE_OBJ_OBJ_OBJ = SAVE_OBJECT + (SAVE_TYPE_OBJ_OBJ << SAVE_SLOT_BITS),
1409 SAVE_TYPE_OBJ_OBJ_OBJ_OBJ
1410 = SAVE_OBJECT + (SAVE_TYPE_OBJ_OBJ_OBJ << SAVE_SLOT_BITS),
1411 SAVE_TYPE_PTR_INT = SAVE_POINTER + (SAVE_INTEGER << SAVE_SLOT_BITS),
1412 SAVE_TYPE_PTR_OBJ = SAVE_POINTER + (SAVE_OBJECT << SAVE_SLOT_BITS),
1413 SAVE_TYPE_PTR_PTR = SAVE_POINTER + (SAVE_POINTER << SAVE_SLOT_BITS),
1414 SAVE_TYPE_PTR_PTR_OBJ
1415 = SAVE_POINTER + (SAVE_TYPE_PTR_OBJ << SAVE_SLOT_BITS),
1416
1417 /* This has an extra bit indicating it's raw memory. */
1418 SAVE_TYPE_MEMORY = SAVE_TYPE_PTR_INT + (1 << (SAVE_TYPE_BITS - 1))
1419 };
1420
1395/* Special object used to hold a different values for later use. 1421/* Special object used to hold a different values for later use.
1396 1422
1397 This is mostly used to package C integers and pointers to call 1423 This is mostly used to package C integers and pointers to call
@@ -1412,74 +1438,50 @@ enum
1412 1438
1413 If yon need to pass more than just one C pointer, you should 1439 If yon need to pass more than just one C pointer, you should
1414 use make_save_value. This function allows you to pack up to 1440 use make_save_value. This function allows you to pack up to
1415 4 integers, pointers or Lisp_Objects and conveniently get them 1441 SAVE_VALUE_SLOTS integers, pointers or Lisp_Objects and
1416 back with XSAVE_POINTER, XSAVE_INTEGER and XSAVE_OBJECT macros: 1442 conveniently get them back with XSAVE_POINTER, XSAVE_INTEGER and
1443 XSAVE_OBJECT macros:
1417 1444
1418 ... 1445 ...
1419 struct my_data *md = get_my_data (); 1446 struct my_data *md = get_my_data ();
1420 ptrdiff_t my_offset = get_my_offset ();
1421 Lisp_Object my_object = get_my_object (); 1447 Lisp_Object my_object = get_my_object ();
1422 record_unwind_protect 1448 record_unwind_protect
1423 (my_unwind, make_save_value ("pio", md, my_offset, my_object)); 1449 (my_unwind, make_save_value (SAVE_TYPE_PTR_OBJ, md, my_object));
1424 ... 1450 ...
1425 1451
1426 Lisp_Object my_unwind (Lisp_Object arg) 1452 Lisp_Object my_unwind (Lisp_Object arg)
1427 { 1453 {
1428 struct my_data *md = XSAVE_POINTER (arg, 0); 1454 struct my_data *md = XSAVE_POINTER (arg, 0);
1429 ptrdiff_t my_offset = XSAVE_INTEGER (arg, 1); 1455 Lisp_Object my_object = XSAVE_OBJECT (arg, 1);
1430 Lisp_Object my_object = XSAVE_OBJECT (arg, 2);
1431 ... 1456 ...
1432 } 1457 }
1433 1458
1434 If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the 1459 If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the
1435 saved objects and raise eassert if type of the saved object doesn't match 1460 saved objects and raise eassert if type of the saved object doesn't match
1436 the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2) 1461 the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2)
1437 or XSAVE_OBJECT (arg, 1) are wrong because integer was saved in slot 1 and 1462 or XSAVE_OBJECT (arg, 0) are wrong because nothing was saved in slot 2 and
1438 Lisp_Object was saved in slot 2 of ARG. */ 1463 Lisp_Object was saved in slot 1 of ARG. */
1439 1464
1440struct Lisp_Save_Value 1465struct Lisp_Save_Value
1441 { 1466 {
1442 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */ 1467 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */
1443 unsigned gcmarkbit : 1; 1468 unsigned gcmarkbit : 1;
1444 int spacer : 6; 1469 int spacer : 32 - (16 + 1 + SAVE_TYPE_BITS);
1445 /* If `area' is nonzero, `data[0].pointer' is the address of a memory area 1470
1446 containing `data[1].integer' potential Lisp_Objects. The rest of `data' 1471 /* DATA[N] may hold up to SAVE_VALUE_SLOTS entries. The type of
1447 fields are unused. */ 1472 V's Ith entry is given by save_type (V, I). E.g., if save_type
1448 unsigned area : 1; 1473 (V, 3) == SAVE_INTEGER, V->data[3].integer is in use.
1449 /* If `area' is zero, `data[N]' may hold different objects which type is 1474
1450 encoded in `typeN' fields as described by the anonymous enum above. 1475 If SAVE_TYPE == SAVE_TYPE_MEMORY, DATA[0].pointer is the address of
1451 E.g. if `type0' is SAVE_INTEGER, `data[0].integer' is in use. */ 1476 a memory area containing DATA[1].integer potential Lisp_Objects. */
1452 unsigned type0 : 2; 1477 ENUM_BF (Lisp_Save_Type) save_type : SAVE_TYPE_BITS;
1453 unsigned type1 : 2;
1454 unsigned type2 : 2;
1455 unsigned type3 : 2;
1456 union { 1478 union {
1457 void *pointer; 1479 void *pointer;
1458 ptrdiff_t integer; 1480 ptrdiff_t integer;
1459 Lisp_Object object; 1481 Lisp_Object object;
1460 } data[4]; 1482 } data[SAVE_VALUE_SLOTS];
1461 }; 1483 };
1462 1484
1463/* Macro to set and extract Nth saved pointer. Type
1464 checking is ugly because it's used as an lvalue. */
1465
1466#define XSAVE_POINTER(obj, n) \
1467 XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type \
1468 ## n == SAVE_POINTER), n)].pointer
1469
1470/* Likewise for the saved integer. */
1471
1472#define XSAVE_INTEGER(obj, n) \
1473 XSAVE_VALUE (obj)->data[(eassert (XSAVE_VALUE (obj)->type \
1474 ## n == SAVE_INTEGER), n)].integer
1475
1476/* Macro to extract Nth saved object. This is never used as
1477 an lvalue, so we can do more convenient type checking. */
1478
1479#define XSAVE_OBJECT(obj, n) \
1480 (eassert (XSAVE_VALUE (obj)->type ## n == SAVE_OBJECT), \
1481 XSAVE_VALUE (obj)->data[n].object)
1482
1483/* A miscellaneous object, when it's on the free list. */ 1485/* A miscellaneous object, when it's on the free list. */
1484struct Lisp_Free 1486struct Lisp_Free
1485 { 1487 {
@@ -1786,7 +1788,66 @@ typedef struct {
1786#define VECTORP(x) (VECTORLIKEP (x) && !(ASIZE (x) & PSEUDOVECTOR_FLAG)) 1788#define VECTORP(x) (VECTORLIKEP (x) && !(ASIZE (x) & PSEUDOVECTOR_FLAG))
1787#define OVERLAYP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Overlay) 1789#define OVERLAYP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Overlay)
1788#define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) 1790#define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker)
1789#define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value) 1791
1792LISP_INLINE bool
1793SAVE_VALUEP (Lisp_Object x)
1794{
1795 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value;
1796}
1797
1798LISP_INLINE struct Lisp_Save_Value *
1799XSAVE_VALUE (Lisp_Object a)
1800{
1801 eassert (SAVE_VALUEP (a));
1802 return & XMISC (a)->u_save_value;
1803}
1804
1805/* Return the type of V's Nth saved value. */
1806LISP_INLINE int
1807save_type (struct Lisp_Save_Value *v, int n)
1808{
1809 eassert (0 <= n && n < SAVE_VALUE_SLOTS);
1810 return (v->save_type >> (SAVE_SLOT_BITS * n) & ((1 << SAVE_SLOT_BITS) - 1));
1811}
1812
1813/* Get and set the Nth saved pointer. */
1814
1815LISP_INLINE void *
1816XSAVE_POINTER (Lisp_Object obj, int n)
1817{
1818 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_POINTER);
1819 return XSAVE_VALUE (obj)->data[n].pointer;;
1820}
1821LISP_INLINE void
1822set_save_pointer (Lisp_Object obj, int n, void *val)
1823{
1824 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_POINTER);
1825 XSAVE_VALUE (obj)->data[n].pointer = val;
1826}
1827
1828/* Likewise for the saved integer. */
1829
1830LISP_INLINE ptrdiff_t
1831XSAVE_INTEGER (Lisp_Object obj, int n)
1832{
1833 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_INTEGER);
1834 return XSAVE_VALUE (obj)->data[n].integer;
1835}
1836LISP_INLINE void
1837set_save_integer (Lisp_Object obj, int n, ptrdiff_t val)
1838{
1839 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_INTEGER);
1840 XSAVE_VALUE (obj)->data[n].integer = val;
1841}
1842
1843/* Extract Nth saved object. */
1844
1845LISP_INLINE Lisp_Object
1846XSAVE_OBJECT (Lisp_Object obj, int n)
1847{
1848 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_OBJECT);
1849 return XSAVE_VALUE (obj)->data[n].object;
1850}
1790 1851
1791#define AUTOLOADP(x) (CONSP (x) && EQ (Qautoload, XCAR (x))) 1852#define AUTOLOADP(x) (CONSP (x) && EQ (Qautoload, XCAR (x)))
1792 1853
@@ -3105,7 +3166,7 @@ extern bool abort_on_gc;
3105extern Lisp_Object make_float (double); 3166extern Lisp_Object make_float (double);
3106extern void display_malloc_warning (void); 3167extern void display_malloc_warning (void);
3107extern ptrdiff_t inhibit_garbage_collection (void); 3168extern ptrdiff_t inhibit_garbage_collection (void);
3108extern Lisp_Object make_save_value (const char *, ...); 3169extern Lisp_Object make_save_value (enum Lisp_Save_Type, ...);
3109extern Lisp_Object make_save_pointer (void *); 3170extern Lisp_Object make_save_pointer (void *);
3110extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); 3171extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object);
3111extern void free_marker (Lisp_Object); 3172extern void free_marker (Lisp_Object);
@@ -3445,7 +3506,7 @@ extern Lisp_Object Qvisible;
3445extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); 3506extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object);
3446extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); 3507extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object);
3447extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); 3508extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
3448#if HAVE_NS 3509#if HAVE_NS || defined(WINDOWSNT)
3449extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); 3510extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
3450#endif 3511#endif
3451extern void frames_discard_buffer (Lisp_Object); 3512extern void frames_discard_buffer (Lisp_Object);
@@ -3704,6 +3765,11 @@ extern void syms_of_xterm (void);
3704extern char *x_get_keysym_name (int); 3765extern char *x_get_keysym_name (int);
3705#endif /* HAVE_WINDOW_SYSTEM */ 3766#endif /* HAVE_WINDOW_SYSTEM */
3706 3767
3768#if defined(HAVE_WINDOW_SYSTEM) || defined (MSDOS)
3769/* Defined in (x|w32)fns.c, nsfns.m, msdos.c. */
3770extern void check_window_system (void);
3771#endif
3772
3707#ifdef HAVE_LIBXML2 3773#ifdef HAVE_LIBXML2
3708/* Defined in xml.c. */ 3774/* Defined in xml.c. */
3709extern void syms_of_xml (void); 3775extern void syms_of_xml (void);
@@ -3711,7 +3777,7 @@ extern void xml_cleanup_parser (void);
3711#endif 3777#endif
3712 3778
3713#ifdef HAVE_MENUS 3779#ifdef HAVE_MENUS
3714/* Defined in (x|w32)fns.c, nsfns.m... */ 3780/* Defined in (x|w32)fns.c, nsfns.m, msdos.c. */
3715extern int have_menus_p (void); 3781extern int have_menus_p (void);
3716#endif 3782#endif
3717 3783
@@ -3822,8 +3888,7 @@ extern void *record_xmalloc (size_t);
3822 { \ 3888 { \
3823 Lisp_Object arg_; \ 3889 Lisp_Object arg_; \
3824 buf = xmalloc ((nelt) * word_size); \ 3890 buf = xmalloc ((nelt) * word_size); \
3825 arg_ = make_save_value ("pi", buf, nelt); \ 3891 arg_ = make_save_value (SAVE_TYPE_MEMORY, buf, nelt); \
3826 XSAVE_VALUE (arg_)->area = 1; \
3827 sa_must_free = 1; \ 3892 sa_must_free = 1; \
3828 record_unwind_protect (safe_alloca_unwind, arg_); \ 3893 record_unwind_protect (safe_alloca_unwind, arg_); \
3829 } \ 3894 } \
diff --git a/src/lread.c b/src/lread.c
index f8ab03af218..8e623e838c7 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1571,7 +1571,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1571 { 1571 {
1572 struct stat st; 1572 struct stat st;
1573 fd = emacs_open (pfn, O_RDONLY, 0); 1573 fd = emacs_open (pfn, O_RDONLY, 0);
1574 if (0 <= fd 1574 if (fd >= 0
1575 && (fstat (fd, &st) != 0 || S_ISDIR (st.st_mode))) 1575 && (fstat (fd, &st) != 0 || S_ISDIR (st.st_mode)))
1576 { 1576 {
1577 emacs_close (fd); 1577 emacs_close (fd);
@@ -2359,7 +2359,7 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix)
2359 while (c == '0'); 2359 while (c == '0');
2360 } 2360 }
2361 2361
2362 while (-1 <= (digit = digit_to_number (c, radix))) 2362 while ((digit = digit_to_number (c, radix)) >= -1)
2363 { 2363 {
2364 if (digit == -1) 2364 if (digit == -1)
2365 valid = 0; 2365 valid = 0;
@@ -2636,7 +2636,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2636 nskip--; 2636 nskip--;
2637 else 2637 else
2638 UNREAD (c); 2638 UNREAD (c);
2639 2639
2640 if (load_force_doc_strings 2640 if (load_force_doc_strings
2641 && (FROM_FILE_P (readcharfun))) 2641 && (FROM_FILE_P (readcharfun)))
2642 { 2642 {
@@ -3298,12 +3298,12 @@ string_to_number (char const *string, int base, bool ignore_trailing)
3298 state = 0; 3298 state = 0;
3299 3299
3300 leading_digit = digit_to_number (*cp, base); 3300 leading_digit = digit_to_number (*cp, base);
3301 if (0 <= leading_digit) 3301 if (leading_digit >= 0)
3302 { 3302 {
3303 state |= LEAD_INT; 3303 state |= LEAD_INT;
3304 do 3304 do
3305 ++cp; 3305 ++cp;
3306 while (0 <= digit_to_number (*cp, base)); 3306 while (digit_to_number (*cp, base) >= 0);
3307 } 3307 }
3308 if (*cp == '.') 3308 if (*cp == '.')
3309 { 3309 {
@@ -3380,7 +3380,7 @@ string_to_number (char const *string, int base, bool ignore_trailing)
3380 3380
3381 /* If the number uses integer and not float syntax, and is in C-language 3381 /* If the number uses integer and not float syntax, and is in C-language
3382 range, use its value, preferably as a fixnum. */ 3382 range, use its value, preferably as a fixnum. */
3383 if (0 <= leading_digit && ! float_syntax) 3383 if (leading_digit >= 0 && ! float_syntax)
3384 { 3384 {
3385 uintmax_t n; 3385 uintmax_t n;
3386 3386
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 93f12900dde..aacc258cd11 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -873,6 +873,7 @@ $(BLD)/filelock.$(O) : \
873 $(CHARACTER_H) \ 873 $(CHARACTER_H) \
874 $(CODING_H) \ 874 $(CODING_H) \
875 $(CONFIG_H) \ 875 $(CONFIG_H) \
876 $(C_CTYPE_H) \
876 $(LISP_H) \ 877 $(LISP_H) \
877 $(SYSTIME_H) 878 $(SYSTIME_H)
878 879
@@ -1398,6 +1399,7 @@ $(BLD)/sysdep.$(O) : \
1398 $(NT_INC)/netdb.h \ 1399 $(NT_INC)/netdb.h \
1399 $(NT_INC)/pwd.h \ 1400 $(NT_INC)/pwd.h \
1400 $(NT_INC)/sys/file.h \ 1401 $(NT_INC)/sys/file.h \
1402 $(NT_INC)/sys/param.h \
1401 $(NT_INC)/sys/stat.h \ 1403 $(NT_INC)/sys/stat.h \
1402 $(NT_INC)/unistd.h \ 1404 $(NT_INC)/unistd.h \
1403 $(GNU_LIB)/execinfo.h \ 1405 $(GNU_LIB)/execinfo.h \
diff --git a/src/menu.c b/src/menu.c
index fdef54dd657..ec9c681a3a9 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -173,7 +173,7 @@ static void
173ensure_menu_items (int items) 173ensure_menu_items (int items)
174{ 174{
175 int incr = items - (menu_items_allocated - menu_items_used); 175 int incr = items - (menu_items_allocated - menu_items_used);
176 if (0 < incr) 176 if (incr > 0)
177 { 177 {
178 menu_items = larger_vector (menu_items, incr, INT_MAX); 178 menu_items = larger_vector (menu_items, incr, INT_MAX);
179 menu_items_allocated = ASIZE (menu_items); 179 menu_items_allocated = ASIZE (menu_items);
@@ -1085,7 +1085,8 @@ no quit occurs and `x-popup-menu' returns nil. */)
1085#ifdef HAVE_MENUS 1085#ifdef HAVE_MENUS
1086 { 1086 {
1087 bool get_current_pos_p = 0; 1087 bool get_current_pos_p = 0;
1088 /* FIXME!! check_w32 (); or check_x (); or check_ns (); */ 1088
1089 check_window_system ();
1089 1090
1090 /* Decode the first argument: find the window and the coordinates. */ 1091 /* Decode the first argument: find the window and the coordinates. */
1091 if (EQ (position, Qt) 1092 if (EQ (position, Qt)
diff --git a/src/minibuf.c b/src/minibuf.c
index 25425cb97dc..68c39310f01 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -114,7 +114,7 @@ choose_minibuf_frame (void)
114 /* Under X, we come here with minibuf_window being the 114 /* Under X, we come here with minibuf_window being the
115 minibuffer window of the unused termcap window created in 115 minibuffer window of the unused termcap window created in
116 init_window_once. That window doesn't have a buffer. */ 116 init_window_once. That window doesn't have a buffer. */
117 buffer = XWINDOW (minibuf_window)->buffer; 117 buffer = XWINDOW (minibuf_window)->contents;
118 if (BUFFERP (buffer)) 118 if (BUFFERP (buffer))
119 /* Use set_window_buffer instead of Fset_window_buffer (see 119 /* Use set_window_buffer instead of Fset_window_buffer (see
120 discussion of bug#11984, bug#12025, bug#12026). */ 120 discussion of bug#11984, bug#12025, bug#12026). */
@@ -844,7 +844,7 @@ read_minibuf_unwind (Lisp_Object data)
844 window = minibuf_window; 844 window = minibuf_window;
845 /* To keep things predictable, in case it matters, let's be in the 845 /* To keep things predictable, in case it matters, let's be in the
846 minibuffer when we reset the relevant variables. */ 846 minibuffer when we reset the relevant variables. */
847 Fset_buffer (XWINDOW (window)->buffer); 847 Fset_buffer (XWINDOW (window)->contents);
848 848
849 /* Restore prompt, etc, from outer minibuffer level. */ 849 /* Restore prompt, etc, from outer minibuffer level. */
850 minibuf_prompt = Fcar (minibuf_save_list); 850 minibuf_prompt = Fcar (minibuf_save_list);
diff --git a/src/msdos.c b/src/msdos.c
index ee47109d5f2..dc79b66e0b1 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1261,7 +1261,7 @@ IT_update_begin (struct frame *f)
1261 /* If the mouse highlight is in the window that was deleted 1261 /* If the mouse highlight is in the window that was deleted
1262 (e.g., if it was popped by completion), clear highlight 1262 (e.g., if it was popped by completion), clear highlight
1263 unconditionally. */ 1263 unconditionally. */
1264 if (NILP (w->buffer)) 1264 if (NILP (w->contents))
1265 hlinfo->mouse_face_window = Qnil; 1265 hlinfo->mouse_face_window = Qnil;
1266 else 1266 else
1267 { 1267 {
@@ -1271,7 +1271,7 @@ IT_update_begin (struct frame *f)
1271 break; 1271 break;
1272 } 1272 }
1273 1273
1274 if (NILP (w->buffer) || i < w->desired_matrix->nrows) 1274 if (NILP (w->contents) || i < w->desired_matrix->nrows)
1275 clear_mouse_face (hlinfo); 1275 clear_mouse_face (hlinfo);
1276 } 1276 }
1277 } 1277 }
@@ -1321,7 +1321,7 @@ IT_frame_up_to_date (struct frame *f)
1321 new_cursor = frame_desired_cursor; 1321 new_cursor = frame_desired_cursor;
1322 else 1322 else
1323 { 1323 {
1324 struct buffer *b = XBUFFER (sw->buffer); 1324 struct buffer *b = XBUFFER (sw->contents);
1325 1325
1326 if (EQ (BVAR (b,cursor_type), Qt)) 1326 if (EQ (BVAR (b,cursor_type), Qt))
1327 new_cursor = frame_desired_cursor; 1327 new_cursor = frame_desired_cursor;
@@ -1920,7 +1920,7 @@ dos_get_saved_screen (char **screen, int *rows, int *cols)
1920 1920
1921/* We are not X, but we can emulate it well enough for our needs... */ 1921/* We are not X, but we can emulate it well enough for our needs... */
1922void 1922void
1923check_x (void) 1923check_window_system (void)
1924{ 1924{
1925 if (! FRAME_MSDOS_P (SELECTED_FRAME ())) 1925 if (! FRAME_MSDOS_P (SELECTED_FRAME ()))
1926 error ("Not running under a window system"); 1926 error ("Not running under a window system");
diff --git a/src/nsfns.m b/src/nsfns.m
index 9c3051a8c6a..f7cf898c7a9 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -109,7 +109,7 @@ static ptrdiff_t image_cache_refcount;
109 109
110 110
111void 111void
112check_ns (void) 112check_window_system (void)
113{ 113{
114 if (NSApp == nil) 114 if (NSApp == nil)
115 error ("OpenStep is not in use or not initialized"); 115 error ("OpenStep is not in use or not initialized");
@@ -619,7 +619,7 @@ ns_set_name_as_filename (struct frame *f)
619{ 619{
620 NSView *view; 620 NSView *view;
621 Lisp_Object name, filename; 621 Lisp_Object name, filename;
622 Lisp_Object buf = XWINDOW (f->selected_window)->buffer; 622 Lisp_Object buf = XWINDOW (f->selected_window)->contents;
623 const char *title; 623 const char *title;
624 NSAutoreleasePool *pool; 624 NSAutoreleasePool *pool;
625 struct gcpro gcpro1; 625 struct gcpro gcpro1;
@@ -1145,7 +1145,7 @@ This function is an internal primitive--use `make-frame' instead. */)
1145 Lisp_Object tfont, tfontsize; 1145 Lisp_Object tfont, tfontsize;
1146 static int desc_ctr = 1; 1146 static int desc_ctr = 1;
1147 1147
1148 check_ns (); 1148 check_window_system ();
1149 1149
1150 /* x_get_arg modifies parms. */ 1150 /* x_get_arg modifies parms. */
1151 parms = Fcopy_alist (parms); 1151 parms = Fcopy_alist (parms);
@@ -1442,7 +1442,7 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
1442 id fm; 1442 id fm;
1443 struct frame *f; 1443 struct frame *f;
1444 1444
1445 check_ns (); 1445 check_window_system ();
1446 fm = [NSFontManager sharedFontManager]; 1446 fm = [NSFontManager sharedFontManager];
1447 if (NILP (frame)) 1447 if (NILP (frame))
1448 f = SELECTED_FRAME (); 1448 f = SELECTED_FRAME ();
@@ -1466,7 +1466,7 @@ DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
1466{ 1466{
1467 struct frame *f; 1467 struct frame *f;
1468 1468
1469 check_ns (); 1469 check_window_system ();
1470 if (NILP (frame)) 1470 if (NILP (frame))
1471 f = SELECTED_FRAME (); 1471 f = SELECTED_FRAME ();
1472 else 1472 else
@@ -1503,7 +1503,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1503 NSString *initS = NILP (init) || !STRINGP (init) ? nil : 1503 NSString *initS = NILP (init) || !STRINGP (init) ? nil :
1504 [NSString stringWithUTF8String: SSDATA (init)]; 1504 [NSString stringWithUTF8String: SSDATA (init)];
1505 1505
1506 check_ns (); 1506 check_window_system ();
1507 1507
1508 if (fileDelegate == nil) 1508 if (fileDelegate == nil)
1509 fileDelegate = [EmacsFileDelegate new]; 1509 fileDelegate = [EmacsFileDelegate new];
@@ -1594,7 +1594,7 @@ If OWNER is nil, Emacs is assumed. */)
1594{ 1594{
1595 const char *value; 1595 const char *value;
1596 1596
1597 check_ns (); 1597 check_window_system ();
1598 if (NILP (owner)) 1598 if (NILP (owner))
1599 owner = build_string([ns_app_name UTF8String]); 1599 owner = build_string([ns_app_name UTF8String]);
1600 CHECK_STRING (name); 1600 CHECK_STRING (name);
@@ -1614,7 +1614,7 @@ If OWNER is nil, Emacs is assumed.
1614If VALUE is nil, the default is removed. */) 1614If VALUE is nil, the default is removed. */)
1615 (Lisp_Object owner, Lisp_Object name, Lisp_Object value) 1615 (Lisp_Object owner, Lisp_Object name, Lisp_Object value)
1616{ 1616{
1617 check_ns (); 1617 check_window_system ();
1618 if (NILP (owner)) 1618 if (NILP (owner))
1619 owner = build_string ([ns_app_name UTF8String]); 1619 owner = build_string ([ns_app_name UTF8String]);
1620 CHECK_STRING (name); 1620 CHECK_STRING (name);
@@ -1642,7 +1642,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
1642 doc: /* This function is a no-op. It is only present for completeness. */) 1642 doc: /* This function is a no-op. It is only present for completeness. */)
1643 (Lisp_Object display) 1643 (Lisp_Object display)
1644{ 1644{
1645 check_ns (); 1645 check_window_system ();
1646 /* This function has no real equivalent under NeXTstep. Return nil to 1646 /* This function has no real equivalent under NeXTstep. Return nil to
1647 indicate this. */ 1647 indicate this. */
1648 return Qnil; 1648 return Qnil;
@@ -1692,7 +1692,7 @@ If omitted or nil, the selected frame's display is used. */)
1692{ 1692{
1693 int num; 1693 int num;
1694 1694
1695 check_ns (); 1695 check_window_system ();
1696 num = [[NSScreen screens] count]; 1696 num = [[NSScreen screens] count];
1697 1697
1698 return (num != 0) ? make_number (num) : Qnil; 1698 return (num != 0) ? make_number (num) : Qnil;
@@ -1706,7 +1706,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1706If omitted or nil, the selected frame's display is used. */) 1706If omitted or nil, the selected frame's display is used. */)
1707 (Lisp_Object display) 1707 (Lisp_Object display)
1708{ 1708{
1709 check_ns (); 1709 check_window_system ();
1710 return make_number ((int) 1710 return make_number ((int)
1711 ([ns_get_screen (display) frame].size.height/(92.0/25.4))); 1711 ([ns_get_screen (display) frame].size.height/(92.0/25.4)));
1712} 1712}
@@ -1719,7 +1719,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1719If omitted or nil, the selected frame's display is used. */) 1719If omitted or nil, the selected frame's display is used. */)
1720 (Lisp_Object display) 1720 (Lisp_Object display)
1721{ 1721{
1722 check_ns (); 1722 check_window_system ();
1723 return make_number ((int) 1723 return make_number ((int)
1724 ([ns_get_screen (display) frame].size.width/(92.0/25.4))); 1724 ([ns_get_screen (display) frame].size.width/(92.0/25.4)));
1725} 1725}
@@ -1733,7 +1733,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1733If omitted or nil, the selected frame's display is used. */) 1733If omitted or nil, the selected frame's display is used. */)
1734 (Lisp_Object display) 1734 (Lisp_Object display)
1735{ 1735{
1736 check_ns (); 1736 check_window_system ();
1737 switch ([ns_get_window (display) backingType]) 1737 switch ([ns_get_window (display) backingType])
1738 { 1738 {
1739 case NSBackingStoreBuffered: 1739 case NSBackingStoreBuffered:
@@ -1759,7 +1759,7 @@ If omitted or nil, the selected frame's display is used. */)
1759 (Lisp_Object display) 1759 (Lisp_Object display)
1760{ 1760{
1761 NSWindowDepth depth; 1761 NSWindowDepth depth;
1762 check_ns (); 1762 check_window_system ();
1763 depth = [ns_get_screen (display) depth]; 1763 depth = [ns_get_screen (display) depth];
1764 1764
1765 if ( depth == NSBestDepth (NSCalibratedWhiteColorSpace, 2, 2, YES, NULL)) 1765 if ( depth == NSBestDepth (NSCalibratedWhiteColorSpace, 2, 2, YES, NULL))
@@ -1786,7 +1786,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1786If omitted or nil, the selected frame's display is used. */) 1786If omitted or nil, the selected frame's display is used. */)
1787 (Lisp_Object display) 1787 (Lisp_Object display)
1788{ 1788{
1789 check_ns (); 1789 check_window_system ();
1790 switch ([ns_get_window (display) backingType]) 1790 switch ([ns_get_window (display) backingType])
1791 { 1791 {
1792 case NSBackingStoreBuffered: 1792 case NSBackingStoreBuffered:
@@ -1839,7 +1839,7 @@ DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection,
1839The argument DISPLAY is currently ignored. */) 1839The argument DISPLAY is currently ignored. */)
1840 (Lisp_Object display) 1840 (Lisp_Object display)
1841{ 1841{
1842 check_ns (); 1842 check_window_system ();
1843 /*ns_delete_terminal (dpyinfo->terminal); */ 1843 /*ns_delete_terminal (dpyinfo->terminal); */
1844 [NSApp terminate: NSApp]; 1844 [NSApp terminate: NSApp];
1845 return Qnil; 1845 return Qnil;
@@ -1865,7 +1865,7 @@ DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others,
1865 doc: /* Hides all applications other than Emacs. */) 1865 doc: /* Hides all applications other than Emacs. */)
1866 (void) 1866 (void)
1867{ 1867{
1868 check_ns (); 1868 check_window_system ();
1869 [NSApp hideOtherApplications: NSApp]; 1869 [NSApp hideOtherApplications: NSApp];
1870 return Qnil; 1870 return Qnil;
1871} 1871}
@@ -1878,7 +1878,7 @@ If ON is equal to `activate', Emacs is unhidden and becomes
1878the active application. */) 1878the active application. */)
1879 (Lisp_Object on) 1879 (Lisp_Object on)
1880{ 1880{
1881 check_ns (); 1881 check_window_system ();
1882 if (EQ (on, intern ("activate"))) 1882 if (EQ (on, intern ("activate")))
1883 { 1883 {
1884 [NSApp unhide: NSApp]; 1884 [NSApp unhide: NSApp];
@@ -1897,7 +1897,7 @@ DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel,
1897 doc: /* Shows the 'Info' or 'About' panel for Emacs. */) 1897 doc: /* Shows the 'Info' or 'About' panel for Emacs. */)
1898 (void) 1898 (void)
1899{ 1899{
1900 check_ns (); 1900 check_window_system ();
1901 [NSApp orderFrontStandardAboutPanel: nil]; 1901 [NSApp orderFrontStandardAboutPanel: nil];
1902 return Qnil; 1902 return Qnil;
1903} 1903}
@@ -1975,7 +1975,7 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
1975 NSMenu *svcs; 1975 NSMenu *svcs;
1976 id delegate; 1976 id delegate;
1977 1977
1978 check_ns (); 1978 check_window_system ();
1979 svcs = [[NSMenu alloc] initWithTitle: @"Services"]; 1979 svcs = [[NSMenu alloc] initWithTitle: @"Services"];
1980 [NSApp setServicesMenu: svcs]; 1980 [NSApp setServicesMenu: svcs];
1981 [NSApp registerServicesMenuSendTypes: ns_send_types 1981 [NSApp registerServicesMenuSendTypes: ns_send_types
@@ -2028,7 +2028,7 @@ there was no result. */)
2028 char *utfStr; 2028 char *utfStr;
2029 2029
2030 CHECK_STRING (service); 2030 CHECK_STRING (service);
2031 check_ns (); 2031 check_window_system ();
2032 2032
2033 utfStr = SSDATA (service); 2033 utfStr = SSDATA (service);
2034 svcName = [NSString stringWithUTF8String: utfStr]; 2034 svcName = [NSString stringWithUTF8String: utfStr];
@@ -2152,7 +2152,7 @@ In case the execution fails, an error is signaled. */)
2152 NSEvent *nxev; 2152 NSEvent *nxev;
2153 2153
2154 CHECK_STRING (script); 2154 CHECK_STRING (script);
2155 check_ns (); 2155 check_window_system ();
2156 2156
2157 block_input (); 2157 block_input ();
2158 2158
@@ -2235,7 +2235,7 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
2235 /* remove appname prefix; TODO: allow for !="Emacs" */ 2235 /* remove appname prefix; TODO: allow for !="Emacs" */
2236 char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0); 2236 char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0);
2237 const char *res; 2237 const char *res;
2238 check_ns (); 2238 check_window_system ();
2239 2239
2240 if (inhibit_x_resources) 2240 if (inhibit_x_resources)
2241 /* --quick was passed, so this is a no-op. */ 2241 /* --quick was passed, so this is a no-op. */
@@ -2305,7 +2305,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
2305 (Lisp_Object color, Lisp_Object frame) 2305 (Lisp_Object color, Lisp_Object frame)
2306{ 2306{
2307 NSColor * col; 2307 NSColor * col;
2308 check_ns (); 2308 check_window_system ();
2309 return ns_lisp_to_color (color, &col) ? Qnil : Qt; 2309 return ns_lisp_to_color (color, &col) ? Qnil : Qt;
2310} 2310}
2311 2311
@@ -2317,7 +2317,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2317 NSColor * col; 2317 NSColor * col;
2318 CGFloat red, green, blue, alpha; 2318 CGFloat red, green, blue, alpha;
2319 2319
2320 check_ns (); 2320 check_window_system ();
2321 CHECK_STRING (color); 2321 CHECK_STRING (color);
2322 2322
2323 if (ns_lisp_to_color (color, &col)) 2323 if (ns_lisp_to_color (color, &col))
@@ -2336,7 +2336,7 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2336{ 2336{
2337 NSWindowDepth depth; 2337 NSWindowDepth depth;
2338 NSString *colorSpace; 2338 NSString *colorSpace;
2339 check_ns (); 2339 check_window_system ();
2340 depth = [ns_get_screen (display) depth]; 2340 depth = [ns_get_screen (display) depth];
2341 colorSpace = NSColorSpaceFromDepth (depth); 2341 colorSpace = NSColorSpaceFromDepth (depth);
2342 2342
@@ -2356,7 +2356,7 @@ If omitted or nil, that stands for the selected frame's display. */)
2356 (Lisp_Object display) 2356 (Lisp_Object display)
2357{ 2357{
2358 NSWindowDepth depth; 2358 NSWindowDepth depth;
2359 check_ns (); 2359 check_window_system ();
2360 depth = [ns_get_screen (display) depth]; 2360 depth = [ns_get_screen (display) depth];
2361 2361
2362 return NSBitsPerPixelFromDepth (depth) > 1 ? Qt : Qnil; 2362 return NSBitsPerPixelFromDepth (depth) > 1 ? Qt : Qnil;
@@ -2371,7 +2371,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2371If omitted or nil, that stands for the selected frame's display. */) 2371If omitted or nil, that stands for the selected frame's display. */)
2372 (Lisp_Object display) 2372 (Lisp_Object display)
2373{ 2373{
2374 check_ns (); 2374 check_window_system ();
2375 return make_number ((int) [ns_get_screen (display) frame].size.width); 2375 return make_number ((int) [ns_get_screen (display) frame].size.width);
2376} 2376}
2377 2377
@@ -2384,7 +2384,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2384If omitted or nil, that stands for the selected frame's display. */) 2384If omitted or nil, that stands for the selected frame's display. */)
2385 (Lisp_Object display) 2385 (Lisp_Object display)
2386{ 2386{
2387 check_ns (); 2387 check_window_system ();
2388 return make_number ((int) [ns_get_screen (display) frame].size.height); 2388 return make_number ((int) [ns_get_screen (display) frame].size.height);
2389} 2389}
2390 2390
@@ -2404,7 +2404,7 @@ that stands for the selected frame's display. */)
2404 NSScreen *screen; 2404 NSScreen *screen;
2405 NSRect vScreen; 2405 NSRect vScreen;
2406 2406
2407 check_ns (); 2407 check_window_system ();
2408 screen = ns_get_screen (display); 2408 screen = ns_get_screen (display);
2409 if (!screen) 2409 if (!screen)
2410 return Qnil; 2410 return Qnil;
@@ -2428,7 +2428,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2428If omitted or nil, that stands for the selected frame's display. */) 2428If omitted or nil, that stands for the selected frame's display. */)
2429 (Lisp_Object display) 2429 (Lisp_Object display)
2430{ 2430{
2431 check_ns (); 2431 check_window_system ();
2432 return make_number 2432 return make_number
2433 (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth])); 2433 (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth]));
2434} 2434}
@@ -2443,7 +2443,7 @@ If omitted or nil, that stands for the selected frame's display. */)
2443 (Lisp_Object display) 2443 (Lisp_Object display)
2444{ 2444{
2445 struct ns_display_info *dpyinfo; 2445 struct ns_display_info *dpyinfo;
2446 check_ns (); 2446 check_window_system ();
2447 2447
2448 dpyinfo = check_ns_display_info (display); 2448 dpyinfo = check_ns_display_info (display);
2449 /* We force 24+ bit depths to 24-bit to prevent an overflow. */ 2449 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
@@ -2787,9 +2787,6 @@ be used as the image of the icon representing the frame. */);
2787 defsubr (&Sx_show_tip); 2787 defsubr (&Sx_show_tip);
2788 defsubr (&Sx_hide_tip); 2788 defsubr (&Sx_hide_tip);
2789 2789
2790 /* used only in fontset.c */
2791 check_window_system_func = check_ns;
2792
2793 as_status = 0; 2790 as_status = 0;
2794 as_script = Qnil; 2791 as_script = Qnil;
2795 as_result = 0; 2792 as_result = 0;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 22ff4dd0b53..d364639b0bc 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -88,14 +88,6 @@ static int trackingMenu;
88 ========================================================================== */ 88 ========================================================================== */
89 89
90 90
91/* FIXME: not currently used, but should normalize with other terms. */
92void
93x_activate_menubar (struct frame *f)
94{
95 fprintf (stderr, "XXX: Received x_activate_menubar event.\n");
96}
97
98
99/* Supposed to discard menubar and free storage. Since we share the 91/* Supposed to discard menubar and free storage. Since we share the
100 menubar among frames and update its context for the focused window, 92 menubar among frames and update its context for the focused window,
101 there is nothing to do here. */ 93 there is nothing to do here. */
@@ -138,7 +130,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
138 long t; 130 long t;
139#endif 131#endif
140 132
141 NSTRACE (set_frame_menubar); 133 NSTRACE (ns_update_menubar);
142 134
143 if (f != SELECTED_FRAME ()) 135 if (f != SELECTED_FRAME ())
144 return; 136 return;
@@ -191,7 +183,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
191 = alloca (previous_menu_items_used * sizeof *previous_items); 183 = alloca (previous_menu_items_used * sizeof *previous_items);
192 184
193 /* lisp preliminaries */ 185 /* lisp preliminaries */
194 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; 186 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
195 specbind (Qinhibit_quit, Qt); 187 specbind (Qinhibit_quit, Qt);
196 specbind (Qdebug_on_next_call, Qnil); 188 specbind (Qdebug_on_next_call, Qnil);
197 record_unwind_save_match_data (); 189 record_unwind_save_match_data ();
@@ -512,6 +504,29 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
512 ns_update_menubar (f, deep_p, nil); 504 ns_update_menubar (f, deep_p, nil);
513} 505}
514 506
507void
508x_activate_menubar (struct frame *f)
509{
510 NSArray *a = [[NSApp mainMenu] itemArray];
511 /* Update each submenu separately so ns_update_menubar doesn't reset
512 the delegate. */
513 int i = 0;
514 while (i < [a count])
515 {
516 EmacsMenu *menu = (EmacsMenu *)[[a objectAtIndex:i] submenu];
517 const char *title = [[menu title] UTF8String];
518 if (strcmp (title, ns_get_pending_menu_title ()) == 0)
519 {
520 ns_update_menubar (f, true, menu);
521 break;
522 }
523 ++i;
524 }
525 ns_check_pending_open_menu ();
526}
527
528
529
515 530
516/* ========================================================================== 531/* ==========================================================================
517 532
@@ -564,6 +579,14 @@ extern NSString *NSMenuDidBeginTrackingNotification;
564 trackingMenu = ([notification name] == NSMenuDidBeginTrackingNotification 579 trackingMenu = ([notification name] == NSMenuDidBeginTrackingNotification
565 ? 1 : 0); 580 ? 1 : 0);
566} 581}
582
583#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
584- (void)menuWillOpen:(NSMenu *)menu
585{
586 ns_check_menu_open (menu);
587}
588#endif
589
567#endif 590#endif
568 591
569/* delegate method called when a submenu is being opened: run a 'deep' call 592/* delegate method called when a submenu is being opened: run a 'deep' call
@@ -591,7 +614,12 @@ extern NSString *NSMenuDidBeginTrackingNotification;
591 if (trackingMenu == 0) 614 if (trackingMenu == 0)
592 return; 615 return;
593/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ 616/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */
594 ns_update_menubar (frame, 1, self); 617#if ! defined(NS_IMPL_COCOA) || \
618 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
619 /* Don't know how to do this for anything other than OSX >= 10.5
620 This is wrong, as it might run Lisp code in the event loop. */
621 ns_update_menubar (frame, true, self);
622#endif
595} 623}
596 624
597 625
@@ -1300,6 +1328,7 @@ update_frame_tool_bar (FRAME_PTR f)
1300 wr.size = [textField frame].size; 1328 wr.size = [textField frame].size;
1301 1329
1302 [win setFrame: wr display: YES]; 1330 [win setFrame: wr display: YES];
1331 [win setLevel: NSPopUpMenuWindowLevel];
1303 [win orderFront: self]; 1332 [win orderFront: self];
1304 [win display]; 1333 [win display];
1305 timer = [NSTimer scheduledTimerWithTimeInterval: (float)seconds target: self 1334 timer = [NSTimer scheduledTimerWithTimeInterval: (float)seconds target: self
@@ -1380,7 +1409,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1380 1409
1381 NSTRACE (x-popup-dialog); 1410 NSTRACE (x-popup-dialog);
1382 1411
1383 check_ns (); 1412 check_window_system ();
1384 1413
1385 isQ = NILP (header); 1414 isQ = NILP (header);
1386 1415
diff --git a/src/nsselect.m b/src/nsselect.m
index 49380f87945..2f539a16406 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -355,7 +355,7 @@ On Nextstep, FRAME is unused. */)
355 Lisp_Object target_symbol, data; 355 Lisp_Object target_symbol, data;
356 356
357 357
358 check_ns (); 358 check_window_system ();
359 CHECK_SYMBOL (selection); 359 CHECK_SYMBOL (selection);
360 if (NILP (value)) 360 if (NILP (value))
361 error ("selection value may not be nil."); 361 error ("selection value may not be nil.");
@@ -409,7 +409,7 @@ On MS-DOS, all this does is return non-nil if we own the selection. */)
409 (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal) 409 (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal)
410{ 410{
411 id pb; 411 id pb;
412 check_ns (); 412 check_window_system ();
413 CHECK_SYMBOL (selection); 413 CHECK_SYMBOL (selection);
414 if (NILP (assq_no_quit (selection, Vselection_alist))) return Qnil; 414 if (NILP (assq_no_quit (selection, Vselection_alist))) return Qnil;
415 415
@@ -436,7 +436,7 @@ On Nextstep, TERMINAL is unused. */)
436 id pb; 436 id pb;
437 NSArray *types; 437 NSArray *types;
438 438
439 check_ns (); 439 check_window_system ();
440 CHECK_SYMBOL (selection); 440 CHECK_SYMBOL (selection);
441 if (EQ (selection, Qnil)) selection = QPRIMARY; 441 if (EQ (selection, Qnil)) selection = QPRIMARY;
442 if (EQ (selection, Qt)) selection = QSECONDARY; 442 if (EQ (selection, Qt)) selection = QSECONDARY;
@@ -464,7 +464,7 @@ frame's display, or the first available X display.
464On Nextstep, TERMINAL is unused. */) 464On Nextstep, TERMINAL is unused. */)
465 (Lisp_Object selection, Lisp_Object terminal) 465 (Lisp_Object selection, Lisp_Object terminal)
466{ 466{
467 check_ns (); 467 check_window_system ();
468 CHECK_SYMBOL (selection); 468 CHECK_SYMBOL (selection);
469 if (EQ (selection, Qnil)) selection = QPRIMARY; 469 if (EQ (selection, Qnil)) selection = QPRIMARY;
470 if (EQ (selection, Qt)) selection = QSECONDARY; 470 if (EQ (selection, Qt)) selection = QSECONDARY;
@@ -492,7 +492,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused. */)
492{ 492{
493 Lisp_Object val; 493 Lisp_Object val;
494 494
495 check_ns (); 495 check_window_system ();
496 CHECK_SYMBOL (selection_name); 496 CHECK_SYMBOL (selection_name);
497 CHECK_SYMBOL (target_type); 497 CHECK_SYMBOL (target_type);
498 val = ns_get_local_selection (selection_name, target_type); 498 val = ns_get_local_selection (selection_name, target_type);
@@ -516,7 +516,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
516 (Lisp_Object selection) 516 (Lisp_Object selection)
517{ 517{
518 id pb; 518 id pb;
519 check_ns (); 519 check_window_system ();
520 pb = ns_symbol_to_pb (selection); 520 pb = ns_symbol_to_pb (selection);
521 return pb != nil ? ns_string_from_pasteboard (pb) : Qnil; 521 return pb != nil ? ns_string_from_pasteboard (pb) : Qnil;
522} 522}
@@ -529,7 +529,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
529 (Lisp_Object selection, Lisp_Object string) 529 (Lisp_Object selection, Lisp_Object string)
530{ 530{
531 id pb; 531 id pb;
532 check_ns (); 532 check_window_system ();
533 pb = ns_symbol_to_pb (selection); 533 pb = ns_symbol_to_pb (selection);
534 if (pb != nil) ns_string_to_pasteboard (pb, string); 534 if (pb != nil) ns_string_to_pasteboard (pb, string);
535 return Qnil; 535 return Qnil;
diff --git a/src/nsterm.h b/src/nsterm.h
index 6bd04b96684..59cac34773a 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -764,7 +764,6 @@ extern void ns_clear_frame (struct frame *f);
764 764
765extern const char *ns_xlfd_to_fontname (const char *xlfd); 765extern const char *ns_xlfd_to_fontname (const char *xlfd);
766 766
767extern void check_ns (void);
768extern Lisp_Object ns_map_event_to_object (void); 767extern Lisp_Object ns_map_event_to_object (void);
769#ifdef __OBJC__ 768#ifdef __OBJC__
770extern Lisp_Object ns_string_from_pasteboard (id pb); 769extern Lisp_Object ns_string_from_pasteboard (id pb);
@@ -792,6 +791,9 @@ extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
792extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f); 791extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
793extern unsigned long ns_index_color (NSColor *color, struct frame *f); 792extern unsigned long ns_index_color (NSColor *color, struct frame *f);
794extern void ns_free_indexed_color (unsigned long idx, struct frame *f); 793extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
794extern const char *ns_get_pending_menu_title ();
795extern void ns_check_menu_open (NSMenu *menu);
796extern void ns_check_pending_open_menu ();
795#endif 797#endif
796 798
797/* C access to ObjC functionality */ 799/* C access to ObjC functionality */
diff --git a/src/nsterm.m b/src/nsterm.m
index 40e506eab27..fb1b0aa327c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -228,6 +228,25 @@ static struct {
228 NULL, 0, 0 228 NULL, 0, 0
229}; 229};
230 230
231/*
232 * State for pending menu activation:
233 * MENU_NONE Normal state
234 * MENU_PENDING A menu has been clicked on, but has been canceled so we can
235 * run lisp to update the menu.
236 * MENU_OPENING Menu is up to date, and the click event is redone so the menu
237 * will open.
238 */
239#define MENU_NONE 0
240#define MENU_PENDING 1
241#define MENU_OPENING 2
242static int menu_will_open_state = MENU_NONE;
243
244/* Saved position for menu click. */
245static CGPoint menu_mouse_point;
246
247/* Title for the menu to open. */
248static char *menu_pending_title = 0;
249
231/* Convert modifiers in a NeXTstep event to emacs style modifiers. */ 250/* Convert modifiers in a NeXTstep event to emacs style modifiers. */
232#define NS_FUNCTION_KEY_MASK 0x800000 251#define NS_FUNCTION_KEY_MASK 0x800000
233#define NSLeftControlKeyMask (0x000001 | NSControlKeyMask) 252#define NSLeftControlKeyMask (0x000001 | NSControlKeyMask)
@@ -994,7 +1013,7 @@ ns_raise_frame (struct frame *f)
994 -------------------------------------------------------------------------- */ 1013 -------------------------------------------------------------------------- */
995{ 1014{
996 NSView *view = FRAME_NS_VIEW (f); 1015 NSView *view = FRAME_NS_VIEW (f);
997 check_ns (); 1016 check_window_system ();
998 block_input (); 1017 block_input ();
999 if (FRAME_VISIBLE_P (f)) 1018 if (FRAME_VISIBLE_P (f))
1000 [[view window] makeKeyAndOrderFront: NSApp]; 1019 [[view window] makeKeyAndOrderFront: NSApp];
@@ -1009,7 +1028,7 @@ ns_lower_frame (struct frame *f)
1009 -------------------------------------------------------------------------- */ 1028 -------------------------------------------------------------------------- */
1010{ 1029{
1011 NSView *view = FRAME_NS_VIEW (f); 1030 NSView *view = FRAME_NS_VIEW (f);
1012 check_ns (); 1031 check_window_system ();
1013 block_input (); 1032 block_input ();
1014 [[view window] orderBack: NSApp]; 1033 [[view window] orderBack: NSApp];
1015 unblock_input (); 1034 unblock_input ();
@@ -1114,7 +1133,7 @@ x_make_frame_invisible (struct frame *f)
1114{ 1133{
1115 NSView * view = FRAME_NS_VIEW (f); 1134 NSView * view = FRAME_NS_VIEW (f);
1116 NSTRACE (x_make_frame_invisible); 1135 NSTRACE (x_make_frame_invisible);
1117 check_ns (); 1136 check_window_system ();
1118 [[view window] orderOut: NSApp]; 1137 [[view window] orderOut: NSApp];
1119 SET_FRAME_VISIBLE (f, 0); 1138 SET_FRAME_VISIBLE (f, 0);
1120 SET_FRAME_ICONIFIED (f, 0); 1139 SET_FRAME_ICONIFIED (f, 0);
@@ -1130,7 +1149,7 @@ x_iconify_frame (struct frame *f)
1130 NSView * view = FRAME_NS_VIEW (f); 1149 NSView * view = FRAME_NS_VIEW (f);
1131 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1150 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1132 NSTRACE (x_iconify_frame); 1151 NSTRACE (x_iconify_frame);
1133 check_ns (); 1152 check_window_system ();
1134 1153
1135 if (dpyinfo->x_highlight_frame == f) 1154 if (dpyinfo->x_highlight_frame == f)
1136 dpyinfo->x_highlight_frame = 0; 1155 dpyinfo->x_highlight_frame = 0;
@@ -1159,7 +1178,7 @@ x_free_frame_resources (struct frame *f)
1159 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1178 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1160 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 1179 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
1161 NSTRACE (x_free_frame_resources); 1180 NSTRACE (x_free_frame_resources);
1162 check_ns (); 1181 check_window_system ();
1163 1182
1164 [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */ 1183 [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */
1165 1184
@@ -1200,7 +1219,7 @@ x_destroy_window (struct frame *f)
1200 -------------------------------------------------------------------------- */ 1219 -------------------------------------------------------------------------- */
1201{ 1220{
1202 NSTRACE (x_destroy_window); 1221 NSTRACE (x_destroy_window);
1203 check_ns (); 1222 check_window_system ();
1204 x_free_frame_resources (f); 1223 x_free_frame_resources (f);
1205 ns_window_num--; 1224 ns_window_num--;
1206} 1225}
@@ -3388,6 +3407,77 @@ check_native_fs ()
3388} 3407}
3389#endif 3408#endif
3390 3409
3410const char *
3411ns_get_pending_menu_title ()
3412{
3413 return menu_pending_title;
3414}
3415
3416/* Check if menu open should be cancelled or continued as normal. */
3417void
3418ns_check_menu_open (NSMenu *menu)
3419{
3420 /* GNUStep and OSX <= 10.4 does not have cancelTracking. */
3421#if defined(NS_IMPL_COCOA) && \
3422 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
3423
3424 /* Click in menu bar? */
3425 NSArray *a = [[NSApp mainMenu] itemArray];
3426 int i;
3427 BOOL found = NO;
3428 for (i = 0; ! found && i < [a count]; i++)
3429 found = menu == [[a objectAtIndex:i] submenu];
3430 if (found)
3431 {
3432 if (menu_will_open_state == MENU_NONE && emacs_event)
3433 {
3434 NSEvent *theEvent = [NSApp currentEvent];
3435 struct frame *emacsframe = SELECTED_FRAME ();
3436
3437 [menu cancelTracking];
3438 menu_will_open_state = MENU_PENDING;
3439 emacs_event->kind = MENU_BAR_ACTIVATE_EVENT;
3440 EV_TRAILER (theEvent);
3441
3442 CGEventRef ourEvent = CGEventCreate (NULL);
3443 menu_mouse_point = CGEventGetLocation (ourEvent);
3444 CFRelease (ourEvent);
3445 xfree (menu_pending_title);
3446 menu_pending_title = xstrdup ([[menu title] UTF8String]);
3447 }
3448 else if (menu_will_open_state == MENU_OPENING)
3449 {
3450 menu_will_open_state = MENU_NONE;
3451 }
3452 }
3453#endif
3454}
3455
3456/* Redo saved menu click if state is MENU_PENDING. */
3457void
3458ns_check_pending_open_menu ()
3459{
3460#ifdef NS_IMPL_COCOA
3461 if (menu_will_open_state == MENU_PENDING)
3462 {
3463 CGEventSourceRef source
3464 = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
3465
3466 CGEventRef event = CGEventCreateMouseEvent (source,
3467 kCGEventLeftMouseDown,
3468 menu_mouse_point,
3469 kCGMouseButtonLeft);
3470 CGEventSetType (event, kCGEventLeftMouseDown);
3471 CGEventPost (kCGHIDEventTap, event);
3472 CFRelease (event);
3473 CFRelease (source);
3474
3475 menu_will_open_state = MENU_OPENING;
3476 }
3477#endif
3478}
3479
3480
3391static int 3481static int
3392ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) 3482ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
3393/* -------------------------------------------------------------------------- 3483/* --------------------------------------------------------------------------
@@ -6532,7 +6622,7 @@ not_in_argv (NSString *arg)
6532{ 6622{
6533 Lisp_Object str = Qnil; 6623 Lisp_Object str = Qnil;
6534 struct frame *f = SELECTED_FRAME (); 6624 struct frame *f = SELECTED_FRAME ();
6535 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer); 6625 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->contents);
6536 6626
6537 if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) 6627 if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
6538 return NSAccessibilityTextFieldRole; 6628 return NSAccessibilityTextFieldRole;
diff --git a/src/print.c b/src/print.c
index 53c0d99f836..811ab5011ce 100644
--- a/src/print.c
+++ b/src/print.c
@@ -227,9 +227,9 @@ printchar (unsigned int ch, Lisp_Object fun)
227 if (NILP (fun)) 227 if (NILP (fun))
228 { 228 {
229 ptrdiff_t incr = len - (print_buffer_size - print_buffer_pos_byte); 229 ptrdiff_t incr = len - (print_buffer_size - print_buffer_pos_byte);
230 if (0 < incr) 230 if (incr > 0)
231 print_buffer = 231 print_buffer = xpalloc (print_buffer, &print_buffer_size,
232 xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); 232 incr, -1, 1);
233 memcpy (print_buffer + print_buffer_pos_byte, str, len); 233 memcpy (print_buffer + print_buffer_pos_byte, str, len);
234 print_buffer_pos += 1; 234 print_buffer_pos += 1;
235 print_buffer_pos_byte += len; 235 print_buffer_pos_byte += len;
@@ -273,7 +273,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte,
273 if (NILP (printcharfun)) 273 if (NILP (printcharfun))
274 { 274 {
275 ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte); 275 ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte);
276 if (0 < incr) 276 if (incr > 0)
277 print_buffer = xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); 277 print_buffer = xpalloc (print_buffer, &print_buffer_size, incr, -1, 1);
278 memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte); 278 memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte);
279 print_buffer_pos += size; 279 print_buffer_pos += size;
@@ -1769,10 +1769,10 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1769 strout ("#<window ", -1, -1, printcharfun); 1769 strout ("#<window ", -1, -1, printcharfun);
1770 len = sprintf (buf, "%p", XWINDOW (obj)); 1770 len = sprintf (buf, "%p", XWINDOW (obj));
1771 strout (buf, len, len, printcharfun); 1771 strout (buf, len, len, printcharfun);
1772 if (!NILP (XWINDOW (obj)->buffer)) 1772 if (BUFFERP (XWINDOW (obj)->contents))
1773 { 1773 {
1774 strout (" on ", -1, -1, printcharfun); 1774 strout (" on ", -1, -1, printcharfun);
1775 print_string (BVAR (XBUFFER (XWINDOW (obj)->buffer), name), 1775 print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name),
1776 printcharfun); 1776 printcharfun);
1777 } 1777 }
1778 PRINTCHAR ('>'); 1778 PRINTCHAR ('>');
@@ -2042,17 +2042,15 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2042 2042
2043 strout ("#<save-value ", -1, -1, printcharfun); 2043 strout ("#<save-value ", -1, -1, printcharfun);
2044 2044
2045 if (v->area) 2045 if (v->save_type == SAVE_TYPE_MEMORY)
2046 { 2046 {
2047 ptrdiff_t amount = v->data[1].integer; 2047 ptrdiff_t amount = v->data[1].integer;
2048 2048
2049#if GC_MARK_STACK 2049#if GC_MARK_STACK
2050 2050
2051 /* If GC_MARK_STACK, valid_lisp_object_p is quite reliable, 2051 /* valid_lisp_object_p is reliable, so try to print up
2052 and so we try to print up to 8 objects we have saved. 2052 to 8 saved objects. This code is rarely used, so
2053 Although valid_lisp_object_p is slow, this shouldn't be 2053 it's OK that valid_lisp_object_p is slow. */
2054 a real bottleneck because we do not use this code under
2055 normal circumstances. */
2056 2054
2057 int limit = min (amount, 8); 2055 int limit = min (amount, 8);
2058 Lisp_Object *area = v->data[0].pointer; 2056 Lisp_Object *area = v->data[0].pointer;
@@ -2077,9 +2075,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2077 2075
2078#else /* not GC_MARK_STACK */ 2076#else /* not GC_MARK_STACK */
2079 2077
2080 /* If !GC_MARK_STACK, we have no reliable way to find 2078 /* There is no reliable way to determine whether the objects
2081 whether Lisp_Object pointers points to an initialized 2079 are initialized, so do not try to print them. */
2082 objects, and so we do not ever trying to print them. */
2083 2080
2084 i = sprintf (buf, "with %"pD"d objects", amount); 2081 i = sprintf (buf, "with %"pD"d objects", amount);
2085 strout (buf, i, i, printcharfun); 2082 strout (buf, i, i, printcharfun);
@@ -2088,33 +2085,37 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2088 } 2085 }
2089 else 2086 else
2090 { 2087 {
2091 /* Print each `data[N]' slot according to its type. */ 2088 /* Print each slot according to its type. */
2092 2089 int index;
2093#define PRINTX(index) \ 2090 for (index = 0; index < SAVE_VALUE_SLOTS; index++)
2094 do { \ 2091 {
2095 i = 0; \ 2092 if (index)
2096 if (v->type ## index == SAVE_UNUSED) \ 2093 PRINTCHAR (' ');
2097 i = sprintf (buf, "<unused>"); \
2098 else if (v->type ## index == SAVE_INTEGER) \
2099 i = sprintf (buf, "<integer %"pD"d>", v->data[index].integer); \
2100 else if (v->type ## index == SAVE_POINTER) \
2101 i = sprintf (buf, "<pointer %p>", v->data[index].pointer); \
2102 else /* SAVE_OBJECT */ \
2103 print_object (v->data[index].object, printcharfun, escapeflag); \
2104 if (i) \
2105 strout (buf, i, i, printcharfun); \
2106 } while (0)
2107
2108 PRINTX (0);
2109 PRINTCHAR (' ');
2110 PRINTX (1);
2111 PRINTCHAR (' ');
2112 PRINTX (2);
2113 PRINTCHAR (' ');
2114 PRINTX (3);
2115 2094
2116#undef PRINTX 2095 switch (save_type (v, index))
2096 {
2097 case SAVE_UNUSED:
2098 i = sprintf (buf, "<unused>");
2099 break;
2100
2101 case SAVE_POINTER:
2102 i = sprintf (buf, "<pointer %p>",
2103 v->data[index].pointer);
2104 break;
2105
2106 case SAVE_INTEGER:
2107 i = sprintf (buf, "<integer %"pD"d>",
2108 v->data[index].integer);
2109 break;
2110
2111 case SAVE_OBJECT:
2112 print_object (v->data[index].object, printcharfun,
2113 escapeflag);
2114 continue;
2115 }
2117 2116
2117 strout (buf, i, i, printcharfun);
2118 }
2118 } 2119 }
2119 PRINTCHAR ('>'); 2120 PRINTCHAR ('>');
2120 } 2121 }
diff --git a/src/process.c b/src/process.c
index bafdca9bd63..911a30bc808 100644
--- a/src/process.c
+++ b/src/process.c
@@ -136,7 +136,7 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
136/* Work around GCC 4.7.0 bug with strict overflow checking; see 136/* Work around GCC 4.7.0 bug with strict overflow checking; see
137 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 137 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
138 These lines can be removed once the GCC bug is fixed. */ 138 These lines can be removed once the GCC bug is fixed. */
139#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ 139#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
140# pragma GCC diagnostic ignored "-Wstrict-overflow" 140# pragma GCC diagnostic ignored "-Wstrict-overflow"
141#endif 141#endif
142 142
@@ -1804,7 +1804,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1804 /* Back in the parent process. */ 1804 /* Back in the parent process. */
1805 1805
1806 XPROCESS (process)->pid = pid; 1806 XPROCESS (process)->pid = pid;
1807 if (0 <= pid) 1807 if (pid >= 0)
1808 XPROCESS (process)->alive = 1; 1808 XPROCESS (process)->alive = 1;
1809 1809
1810 /* Stop blocking signals in the parent. */ 1810 /* Stop blocking signals in the parent. */
@@ -2155,7 +2155,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */)
2155 channel = XPROCESS (process)->infd; 2155 channel = XPROCESS (process)->infd;
2156 2156
2157 len = get_lisp_to_sockaddr_size (address, &family); 2157 len = get_lisp_to_sockaddr_size (address, &family);
2158 if (datagram_address[channel].len != len) 2158 if (len == 0 || datagram_address[channel].len != len)
2159 return Qnil; 2159 return Qnil;
2160 conv_lisp_to_sockaddr (family, address, datagram_address[channel].sa, len); 2160 conv_lisp_to_sockaddr (family, address, datagram_address[channel].sa, len);
2161 return address; 2161 return address;
@@ -3269,7 +3269,8 @@ usage: (make-network-process &rest ARGS) */)
3269 { 3269 {
3270 int rfamily, rlen; 3270 int rfamily, rlen;
3271 rlen = get_lisp_to_sockaddr_size (remote, &rfamily); 3271 rlen = get_lisp_to_sockaddr_size (remote, &rfamily);
3272 if (rfamily == lres->ai_family && rlen == lres->ai_addrlen) 3272 if (rlen != 0 && rfamily == lres->ai_family
3273 && rlen == lres->ai_addrlen)
3273 conv_lisp_to_sockaddr (rfamily, remote, 3274 conv_lisp_to_sockaddr (rfamily, remote,
3274 datagram_address[s].sa, rlen); 3275 datagram_address[s].sa, rlen);
3275 } 3276 }
@@ -3900,7 +3901,7 @@ Return non-nil if we received any output before the timeout expired. */)
3900 { 3901 {
3901 if (INTEGERP (seconds)) 3902 if (INTEGERP (seconds))
3902 { 3903 {
3903 if (0 < XINT (seconds)) 3904 if (XINT (seconds) > 0)
3904 { 3905 {
3905 secs = XINT (seconds); 3906 secs = XINT (seconds);
3906 nsecs = 0; 3907 nsecs = 0;
@@ -3908,7 +3909,7 @@ Return non-nil if we received any output before the timeout expired. */)
3908 } 3909 }
3909 else if (FLOATP (seconds)) 3910 else if (FLOATP (seconds))
3910 { 3911 {
3911 if (0 < XFLOAT_DATA (seconds)) 3912 if (XFLOAT_DATA (seconds) > 0)
3912 { 3913 {
3913 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds)); 3914 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds));
3914 secs = min (EMACS_SECS (t), WAIT_READING_MAX); 3915 secs = min (EMACS_SECS (t), WAIT_READING_MAX);
@@ -4240,7 +4241,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4240 4241
4241 /* Since we may need to wait several times, 4242 /* Since we may need to wait several times,
4242 compute the absolute time to return at. */ 4243 compute the absolute time to return at. */
4243 if (time_limit || 0 < nsecs) 4244 if (time_limit || nsecs > 0)
4244 { 4245 {
4245 timeout = make_emacs_time (time_limit, nsecs); 4246 timeout = make_emacs_time (time_limit, nsecs);
4246 end_time = add_emacs_time (current_emacs_time (), timeout); 4247 end_time = add_emacs_time (current_emacs_time (), timeout);
@@ -4272,7 +4273,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4272 4273
4273 timeout = make_emacs_time (0, 0); 4274 timeout = make_emacs_time (0, 0);
4274 } 4275 }
4275 else if (time_limit || 0 < nsecs) 4276 else if (time_limit || nsecs > 0)
4276 { 4277 {
4277 EMACS_TIME now = current_emacs_time (); 4278 EMACS_TIME now = current_emacs_time ();
4278 if (EMACS_TIME_LE (end_time, now)) 4279 if (EMACS_TIME_LE (end_time, now))
@@ -4324,7 +4325,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4324 break; 4325 break;
4325 4326
4326 /* A negative timeout means do not wait at all. */ 4327 /* A negative timeout means do not wait at all. */
4327 if (0 <= nsecs) 4328 if (nsecs >= 0)
4328 { 4329 {
4329 if (EMACS_TIME_VALID_P (timer_delay)) 4330 if (EMACS_TIME_VALID_P (timer_delay))
4330 { 4331 {
@@ -4406,7 +4407,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4406 if (nread == 0) 4407 if (nread == 0)
4407 break; 4408 break;
4408 4409
4409 if (0 < nread) 4410 if (nread > 0)
4410 { 4411 {
4411 total_nread += nread; 4412 total_nread += nread;
4412 got_some_input = 1; 4413 got_some_input = 1;
@@ -4947,7 +4948,7 @@ read_process_output (Lisp_Object proc, register int channel)
4947 else 4948 else
4948#endif 4949#endif
4949 { 4950 {
4950 bool buffered = 0 <= proc_buffered_char[channel]; 4951 bool buffered = proc_buffered_char[channel] >= 0;
4951 if (buffered) 4952 if (buffered)
4952 { 4953 {
4953 chars[carryover] = proc_buffered_char[channel]; 4954 chars[carryover] = proc_buffered_char[channel];
@@ -5454,7 +5455,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5454 rv = sendto (outfd, cur_buf, cur_len, 5455 rv = sendto (outfd, cur_buf, cur_len,
5455 0, datagram_address[outfd].sa, 5456 0, datagram_address[outfd].sa,
5456 datagram_address[outfd].len); 5457 datagram_address[outfd].len);
5457 if (0 <= rv) 5458 if (rv >= 0)
5458 written = rv; 5459 written = rv;
5459 else if (errno == EMSGSIZE) 5460 else if (errno == EMSGSIZE)
5460 report_file_error ("sending datagram", Fcons (proc, Qnil)); 5461 report_file_error ("sending datagram", Fcons (proc, Qnil));
@@ -6577,7 +6578,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6577 time_limit = TYPE_MAXIMUM (time_t); 6578 time_limit = TYPE_MAXIMUM (time_t);
6578 6579
6579 /* What does time_limit really mean? */ 6580 /* What does time_limit really mean? */
6580 if (time_limit || 0 < nsecs) 6581 if (time_limit || nsecs > 0)
6581 { 6582 {
6582 timeout = make_emacs_time (time_limit, nsecs); 6583 timeout = make_emacs_time (time_limit, nsecs);
6583 end_time = add_emacs_time (current_emacs_time (), timeout); 6584 end_time = add_emacs_time (current_emacs_time (), timeout);
@@ -6615,7 +6616,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6615 6616
6616 timeout = make_emacs_time (0, 0); 6617 timeout = make_emacs_time (0, 0);
6617 } 6618 }
6618 else if (time_limit || 0 < nsecs) 6619 else if (time_limit || nsecs > 0)
6619 { 6620 {
6620 EMACS_TIME now = current_emacs_time (); 6621 EMACS_TIME now = current_emacs_time ();
6621 if (EMACS_TIME_LE (end_time, now)) 6622 if (EMACS_TIME_LE (end_time, now))
@@ -6653,7 +6654,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6653 && requeued_events_pending_p ()) 6654 && requeued_events_pending_p ())
6654 break; 6655 break;
6655 6656
6656 if (EMACS_TIME_VALID_P (timer_delay) && 0 <= nsecs) 6657 if (EMACS_TIME_VALID_P (timer_delay) && nsecs >= 0)
6657 { 6658 {
6658 if (EMACS_TIME_LT (timer_delay, timeout)) 6659 if (EMACS_TIME_LT (timer_delay, timeout))
6659 { 6660 {
diff --git a/src/profiler.c b/src/profiler.c
index 85d9c1ca88a..0a0a4d0bc57 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -55,7 +55,7 @@ make_log (int heap_size, int max_stack_depth)
55 /* What is special about our hash-tables is that the keys are pre-filled 55 /* What is special about our hash-tables is that the keys are pre-filled
56 with the vectors we'll put in them. */ 56 with the vectors we'll put in them. */
57 int i = ASIZE (h->key_and_value) / 2; 57 int i = ASIZE (h->key_and_value) / 2;
58 while (0 < i) 58 while (i > 0)
59 set_hash_key_slot (h, --i, 59 set_hash_key_slot (h, --i,
60 Fmake_vector (make_number (max_stack_depth), Qnil)); 60 Fmake_vector (make_number (max_stack_depth), Qnil));
61 return log; 61 return log;
@@ -247,7 +247,7 @@ handle_profiler_signal (int signal)
247 if (profiler_timer_ok) 247 if (profiler_timer_ok)
248 { 248 {
249 int overruns = timer_getoverrun (profiler_timer); 249 int overruns = timer_getoverrun (profiler_timer);
250 eassert (0 <= overruns); 250 eassert (overruns >= 0);
251 count += overruns; 251 count += overruns;
252 } 252 }
253#endif 253#endif
diff --git a/src/regex.c b/src/regex.c
index 051a4fdc26b..648f2529649 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -33,7 +33,7 @@
33 33
34/* Ignore some GCC warnings for now. This section should go away 34/* Ignore some GCC warnings for now. This section should go away
35 once the Emacs and Gnulib regex code is merged. */ 35 once the Emacs and Gnulib regex code is merged. */
36#if (__GNUC__ == 4 && 5 <= __GNUC_MINOR__) || 4 < __GNUC__ 36#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
37# pragma GCC diagnostic ignored "-Wstrict-overflow" 37# pragma GCC diagnostic ignored "-Wstrict-overflow"
38# ifndef emacs 38# ifndef emacs
39# pragma GCC diagnostic ignored "-Wunused-but-set-variable" 39# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
@@ -6404,8 +6404,8 @@ weak_function
6404re_exec (const char *s) 6404re_exec (const char *s)
6405{ 6405{
6406 const size_t len = strlen (s); 6406 const size_t len = strlen (s);
6407 return 6407 return (re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0)
6408 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); 6408 >= 0);
6409} 6409}
6410#endif /* _REGEX_RE_COMP */ 6410#endif /* _REGEX_RE_COMP */
6411 6411
diff --git a/src/regex.h b/src/regex.h
index f1fd837bd6f..8fe7ba16adc 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -530,7 +530,7 @@ extern int re_exec (const char *);
530/* GCC 2.95 and later have "__restrict"; C99 compilers have 530/* GCC 2.95 and later have "__restrict"; C99 compilers have
531 "restrict", and "configure" may have defined "restrict". */ 531 "restrict", and "configure" may have defined "restrict". */
532#ifndef __restrict 532#ifndef __restrict
533# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) 533# if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
534# if defined restrict || 199901L <= __STDC_VERSION__ 534# if defined restrict || 199901L <= __STDC_VERSION__
535# define __restrict restrict 535# define __restrict restrict
536# else 536# else
diff --git a/src/search.c b/src/search.c
index c5ac7d494dc..ea36133deb7 100644
--- a/src/search.c
+++ b/src/search.c
@@ -326,7 +326,7 @@ looking_at_1 (Lisp_Object string, bool posix)
326 if (i == -2) 326 if (i == -2)
327 matcher_overflow (); 327 matcher_overflow ();
328 328
329 val = (0 <= i ? Qt : Qnil); 329 val = (i >= 0 ? Qt : Qnil);
330 if (NILP (Vinhibit_changing_match_data) && i >= 0) 330 if (NILP (Vinhibit_changing_match_data) && i >= 0)
331 for (i = 0; i < search_regs.num_regs; i++) 331 for (i = 0; i < search_regs.num_regs; i++)
332 if (search_regs.start[i] >= 0) 332 if (search_regs.start[i] >= 0)
@@ -2450,7 +2450,7 @@ since only regular expressions have distinguished subexpressions. */)
2450 else if (c >= '1' && c <= '9') 2450 else if (c >= '1' && c <= '9')
2451 { 2451 {
2452 if (c - '0' < search_regs.num_regs 2452 if (c - '0' < search_regs.num_regs
2453 && 0 <= search_regs.start[c - '0']) 2453 && search_regs.start[c - '0'] >= 0)
2454 { 2454 {
2455 substart = search_regs.start[c - '0']; 2455 substart = search_regs.start[c - '0'];
2456 subend = search_regs.end[c - '0']; 2456 subend = search_regs.end[c - '0'];
@@ -2533,9 +2533,9 @@ since only regular expressions have distinguished subexpressions. */)
2533 bool str_multibyte = STRING_MULTIBYTE (newtext); 2533 bool str_multibyte = STRING_MULTIBYTE (newtext);
2534 bool really_changed = 0; 2534 bool really_changed = 0;
2535 2535
2536 substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length 2536 substed_alloc_size = (length <= (STRING_BYTES_BOUND - 100) / 2
2537 ? STRING_BYTES_BOUND 2537 ? length * 2 + 100
2538 : length * 2 + 100); 2538 : STRING_BYTES_BOUND);
2539 substed = xmalloc (substed_alloc_size); 2539 substed = xmalloc (substed_alloc_size);
2540 substed_len = 0; 2540 substed_len = 0;
2541 2541
diff --git a/src/sysdep.c b/src/sysdep.c
index bff11fc9f75..1d3e646d359 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -282,7 +282,7 @@ get_child_status (pid_t child, int *status, int options, bool interruptible)
282 reap an unwanted process by mistake. For example, invoking 282 reap an unwanted process by mistake. For example, invoking
283 waitpid (-1, ...) can mess up glib by reaping glib's subprocesses, 283 waitpid (-1, ...) can mess up glib by reaping glib's subprocesses,
284 so that another thread running glib won't find them. */ 284 so that another thread running glib won't find them. */
285 eassert (0 < child); 285 eassert (child > 0);
286 286
287 while ((pid = waitpid (child, status, options)) < 0) 287 while ((pid = waitpid (child, status, options)) < 0)
288 { 288 {
@@ -2691,7 +2691,7 @@ procfs_ttyname (int rdev)
2691 2691
2692 while (!feof (fdev) && !ferror (fdev)) 2692 while (!feof (fdev) && !ferror (fdev))
2693 { 2693 {
2694 if (3 <= fscanf (fdev, "%*s %s %u %s %*s\n", name, &major, minor) 2694 if (fscanf (fdev, "%*s %s %u %s %*s\n", name, &major, minor) >= 3
2695 && major == MAJOR (rdev)) 2695 && major == MAJOR (rdev))
2696 { 2696 {
2697 minor_beg = strtoul (minor, &endp, 0); 2697 minor_beg = strtoul (minor, &endp, 0);
@@ -2731,7 +2731,7 @@ procfs_get_total_memory (void)
2731 2731
2732 while (!feof (fmem) && !ferror (fmem)) 2732 while (!feof (fmem) && !ferror (fmem))
2733 { 2733 {
2734 if (2 <= fscanf (fmem, "%s %lu kB\n", entry_name, &entry_value) 2734 if (fscanf (fmem, "%s %lu kB\n", entry_name, &entry_value) >= 2
2735 && strcmp (entry_name, "MemTotal:") == 0) 2735 && strcmp (entry_name, "MemTotal:") == 0)
2736 { 2736 {
2737 retval = entry_value; 2737 retval = entry_value;
diff --git a/src/systime.h b/src/systime.h
index fa5e7270cb5..da495b9064b 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -121,7 +121,7 @@ EMACS_TIME_SIGN (EMACS_TIME t)
121SYSTIME_INLINE int 121SYSTIME_INLINE int
122EMACS_TIME_VALID_P (EMACS_TIME t) 122EMACS_TIME_VALID_P (EMACS_TIME t)
123{ 123{
124 return 0 <= t.tv_nsec; 124 return t.tv_nsec >= 0;
125} 125}
126 126
127/* Convert the double D to the greatest EMACS_TIME not greater than D. 127/* Convert the double D to the greatest EMACS_TIME not greater than D.
diff --git a/src/term.c b/src/term.c
index 38706602a02..28b944c6436 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2909,7 +2909,7 @@ dissociate_if_controlling_tty (int fd)
2909{ 2909{
2910 /* If tcgetpgrp succeeds, fd is the controlling terminal, 2910 /* If tcgetpgrp succeeds, fd is the controlling terminal,
2911 so dissociate it by invoking setsid. */ 2911 so dissociate it by invoking setsid. */
2912 if (0 <= tcgetpgrp (fd) && setsid () < 0) 2912 if (tcgetpgrp (fd) >= 0 && setsid () < 0)
2913 { 2913 {
2914#ifdef TIOCNOTTY 2914#ifdef TIOCNOTTY
2915 /* setsid failed, presumably because Emacs is already a process 2915 /* setsid failed, presumably because Emacs is already a process
diff --git a/src/textprop.c b/src/textprop.c
index 2b454485370..cc364d5a38c 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -597,8 +597,9 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
597 597
598 if (WINDOWP (object)) 598 if (WINDOWP (object))
599 { 599 {
600 CHECK_LIVE_WINDOW (object);
600 w = XWINDOW (object); 601 w = XWINDOW (object);
601 object = w->buffer; 602 object = w->contents;
602 } 603 }
603 if (BUFFERP (object)) 604 if (BUFFERP (object))
604 { 605 {
diff --git a/src/unexcw.c b/src/unexcw.c
index af93e158e14..1290c28d245 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include "unexec.h" 22#include "unexec.h"
23#include "w32common.h"
24 23
25#include <lisp.h> 24#include <lisp.h>
26#include <stdio.h> 25#include <stdio.h>
@@ -31,6 +30,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 30
32#define DOTEXE ".exe" 31#define DOTEXE ".exe"
33 32
33extern void report_sheap_usage (int);
34
34extern int bss_sbrk_did_unexec; 35extern int bss_sbrk_did_unexec;
35 36
36extern int __malloc_initialized; 37extern int __malloc_initialized;
@@ -73,7 +74,11 @@ read_exe_header (int fd, exe_header_t * exe_header_buffer)
73 74
74 assert (exe_header_buffer->file_header.e_magic == 0x5a4d); 75 assert (exe_header_buffer->file_header.e_magic == 0x5a4d);
75 assert (exe_header_buffer->file_header.nt_signature == 0x4550); 76 assert (exe_header_buffer->file_header.nt_signature == 0x4550);
77#ifdef __x86_64__
78 assert (exe_header_buffer->file_header.f_magic == 0x8664);
79#else
76 assert (exe_header_buffer->file_header.f_magic == 0x014c); 80 assert (exe_header_buffer->file_header.f_magic == 0x014c);
81#endif
77 assert (exe_header_buffer->file_header.f_nscns > 0); 82 assert (exe_header_buffer->file_header.f_nscns > 0);
78 assert (exe_header_buffer->file_header.f_nscns <= 83 assert (exe_header_buffer->file_header.f_nscns <=
79 sizeof (exe_header_buffer->section_header) / 84 sizeof (exe_header_buffer->section_header) /
@@ -85,7 +90,11 @@ read_exe_header (int fd, exe_header_t * exe_header_buffer)
85 sizeof (exe_header_buffer->file_optional_header)); 90 sizeof (exe_header_buffer->file_optional_header));
86 assert (ret == sizeof (exe_header_buffer->file_optional_header)); 91 assert (ret == sizeof (exe_header_buffer->file_optional_header));
87 92
93#ifdef __x86_64__
94 assert (exe_header_buffer->file_optional_header.magic == 0x020b);
95#else
88 assert (exe_header_buffer->file_optional_header.magic == 0x010b); 96 assert (exe_header_buffer->file_optional_header.magic == 0x010b);
97#endif
89 98
90 for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i) 99 for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i)
91 { 100 {
@@ -132,7 +141,7 @@ fixup_executable (int fd)
132 exe_header->file_optional_header.ImageBase + 141 exe_header->file_optional_header.ImageBase +
133 exe_header->section_header[i].s_paddr; 142 exe_header->section_header[i].s_paddr;
134 if (debug_unexcw) 143 if (debug_unexcw)
135 printf ("%8s start 0x%08x end 0x%08x\n", 144 printf ("%8s start %#lx end %#lx\n",
136 exe_header->section_header[i].s_name, 145 exe_header->section_header[i].s_name,
137 start_address, end_address); 146 start_address, end_address);
138 if (my_edata >= (char *) start_address 147 if (my_edata >= (char *) start_address
@@ -149,7 +158,7 @@ fixup_executable (int fd)
149 assert (ret == my_edata - (char *) start_address); 158 assert (ret == my_edata - (char *) start_address);
150 ++found_data; 159 ++found_data;
151 if (debug_unexcw) 160 if (debug_unexcw)
152 printf (" .data, mem start 0x%08x mem length %d\n", 161 printf (" .data, mem start %#lx mem length %d\n",
153 start_address, my_edata - (char *) start_address); 162 start_address, my_edata - (char *) start_address);
154 if (debug_unexcw) 163 if (debug_unexcw)
155 printf (" .data, file start %d file length %d\n", 164 printf (" .data, file start %d file length %d\n",
@@ -233,7 +242,7 @@ fixup_executable (int fd)
233 __malloc_initialized = 1; 242 __malloc_initialized = 1;
234 assert (ret == (my_endbss - (char *) start_address)); 243 assert (ret == (my_endbss - (char *) start_address));
235 if (debug_unexcw) 244 if (debug_unexcw)
236 printf (" .bss, mem start 0x%08x mem length %d\n", 245 printf (" .bss, mem start %#lx mem length %d\n",
237 start_address, my_endbss - (char *) start_address); 246 start_address, my_endbss - (char *) start_address);
238 if (debug_unexcw) 247 if (debug_unexcw)
239 printf (" .bss, file start %d file length %d\n", 248 printf (" .bss, file start %d file length %d\n",
diff --git a/src/w32.c b/src/w32.c
index 647faf94ef1..431826c4b82 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -29,10 +29,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include <ctype.h> 29#include <ctype.h>
30#include <signal.h> 30#include <signal.h>
31#include <sys/file.h> 31#include <sys/file.h>
32#include <time.h> /* must be before nt/inc/sys/time.h, for MinGW64 */
32#include <sys/time.h> 33#include <sys/time.h>
33#include <sys/utime.h> 34#include <sys/utime.h>
34#include <math.h> 35#include <math.h>
35#include <time.h>
36 36
37/* must include CRT headers *before* config.h */ 37/* must include CRT headers *before* config.h */
38 38
@@ -69,7 +69,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
69#include <pwd.h> 69#include <pwd.h>
70#include <grp.h> 70#include <grp.h>
71 71
72#ifdef __GNUC__ 72/* MinGW64 (_W64) defines these in its _mingw.h. */
73#if defined(__GNUC__) && !defined(_W64)
73#define _ANONYMOUS_UNION 74#define _ANONYMOUS_UNION
74#define _ANONYMOUS_STRUCT 75#define _ANONYMOUS_STRUCT
75#endif 76#endif
@@ -96,6 +97,7 @@ typedef struct _MEMORY_STATUS_EX {
96#ifndef _MSC_VER 97#ifndef _MSC_VER
97#include <w32api.h> 98#include <w32api.h>
98#endif 99#endif
100#if _WIN32_WINNT < 0x0500
99#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15) 101#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
100/* This either is not in psapi.h or guarded by higher value of 102/* This either is not in psapi.h or guarded by higher value of
101 _WIN32_WINNT than what we use. w32api supplied with MinGW 3.15 103 _WIN32_WINNT than what we use. w32api supplied with MinGW 3.15
@@ -114,6 +116,7 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
114 SIZE_T PrivateUsage; 116 SIZE_T PrivateUsage;
115} PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; 117} PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX;
116#endif 118#endif
119#endif
117 120
118#include <winioctl.h> 121#include <winioctl.h>
119#include <aclapi.h> 122#include <aclapi.h>
@@ -127,11 +130,11 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
127#define SDDL_REVISION_1 1 130#define SDDL_REVISION_1 1
128#endif /* SDDL_REVISION_1 */ 131#endif /* SDDL_REVISION_1 */
129 132
130#ifdef _MSC_VER 133#if defined(_MSC_VER) || defined(_W64)
131/* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the 134/* MSVC and MinGW64 don't provide the definition of
132 associated macros, except on ntifs.h, which cannot be included 135 REPARSE_DATA_BUFFER and the associated macros, except on ntifs.h,
133 because it triggers conflicts with other Windows API headers. So 136 which cannot be included because it triggers conflicts with other
134 we define it here by hand. */ 137 Windows API headers. So we define it here by hand. */
135 138
136typedef struct _REPARSE_DATA_BUFFER { 139typedef struct _REPARSE_DATA_BUFFER {
137 ULONG ReparseTag; 140 ULONG ReparseTag;
@@ -171,9 +174,12 @@ typedef struct _REPARSE_DATA_BUFFER {
171#ifndef CTL_CODE 174#ifndef CTL_CODE
172#define CTL_CODE(t,f,m,a) (((t)<<16)|((a)<<14)|((f)<<2)|(m)) 175#define CTL_CODE(t,f,m,a) (((t)<<16)|((a)<<14)|((f)<<2)|(m))
173#endif 176#endif
177/* MinGW64 defines FSCTL_GET_REPARSE_POINT on winioctl.h. */
178#ifndef FSCTL_GET_REPARSE_POINT
174#define FSCTL_GET_REPARSE_POINT \ 179#define FSCTL_GET_REPARSE_POINT \
175 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) 180 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
176#endif 181#endif
182#endif
177 183
178/* TCP connection support. */ 184/* TCP connection support. */
179#include <sys/socket.h> 185#include <sys/socket.h>
diff --git a/src/w32fns.c b/src/w32fns.c
index 4c47465e67b..2bc1042e126 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -242,7 +242,7 @@ static unsigned int sound_type = 0xFFFFFFFF;
242 242
243/* Error if we are not connected to MS-Windows. */ 243/* Error if we are not connected to MS-Windows. */
244void 244void
245check_w32 (void) 245check_window_system (void)
246{ 246{
247 if (! w32_in_use) 247 if (! w32_in_use)
248 error ("MS-Windows not in use or not initialized"); 248 error ("MS-Windows not in use or not initialized");
@@ -3155,8 +3155,26 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3155 form.ptCurrentPos.y = w32_system_caret_y; 3155 form.ptCurrentPos.y = w32_system_caret_y;
3156 3156
3157 form.rcArea.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, 0); 3157 form.rcArea.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, 0);
3158
3159#ifdef ENABLE_CHECKING
3160 /* Temporary code to catch crashes in computing form.rcArea.top. */
3161 {
3162 int wmbp = WINDOW_MENU_BAR_P (w);
3163 int wtbp = WINDOW_TOOL_BAR_P (w);
3164 struct frame *wf = WINDOW_XFRAME (w);
3165 int fibw = FRAME_INTERNAL_BORDER_WIDTH (wf);
3166 int wtel = WINDOW_TOP_EDGE_LINE (w);
3167 int wflh = FRAME_LINE_HEIGHT (wf);
3168 int wwhlp= WINDOW_WANTS_HEADER_LINE_P (w);
3169 int chlh = CURRENT_HEADER_LINE_HEIGHT (w);
3170 int whlh = (wwhlp ? chlh : 0);
3171
3172 form.rcArea.top = ((wmbp || wtbp) ? 0 : fibw) + wtel * wflh + whlh;
3173 }
3174#else
3158 form.rcArea.top = (WINDOW_TOP_EDGE_Y (w) 3175 form.rcArea.top = (WINDOW_TOP_EDGE_Y (w)
3159 + WINDOW_HEADER_LINE_HEIGHT (w)); 3176 + WINDOW_HEADER_LINE_HEIGHT (w));
3177#endif
3160 form.rcArea.right = (WINDOW_BOX_RIGHT_EDGE_X (w) 3178 form.rcArea.right = (WINDOW_BOX_RIGHT_EDGE_X (w)
3161 - WINDOW_RIGHT_MARGIN_WIDTH (w) 3179 - WINDOW_RIGHT_MARGIN_WIDTH (w)
3162 - WINDOW_RIGHT_FRINGE_WIDTH (w)); 3180 - WINDOW_RIGHT_FRINGE_WIDTH (w));
@@ -5340,7 +5358,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5340 Lisp_Object buffer; 5358 Lisp_Object buffer;
5341 struct buffer *old_buffer; 5359 struct buffer *old_buffer;
5342 5360
5343 check_w32 (); 5361 check_window_system ();
5344 5362
5345 /* Use this general default value to start with until we know if 5363 /* Use this general default value to start with until we know if
5346 this frame has a specified name. */ 5364 this frame has a specified name. */
@@ -5792,13 +5810,13 @@ Text larger than the specified size is clipped. */)
5792 w->total_lines = 40; 5810 w->total_lines = 40;
5793 } 5811 }
5794 5812
5795 FRAME_TOTAL_COLS (f) = XINT (w->total_cols); 5813 FRAME_TOTAL_COLS (f) = WINDOW_TOTAL_COLS (w);
5796 adjust_glyphs (f); 5814 adjust_glyphs (f);
5797 w->pseudo_window_p = 1; 5815 w->pseudo_window_p = 1;
5798 5816
5799 /* Display the tooltip text in a temporary buffer. */ 5817 /* Display the tooltip text in a temporary buffer. */
5800 old_buffer = current_buffer; 5818 old_buffer = current_buffer;
5801 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); 5819 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->contents));
5802 bset_truncate_lines (current_buffer, Qnil); 5820 bset_truncate_lines (current_buffer, Qnil);
5803 clear_glyph_matrix (w->desired_matrix); 5821 clear_glyph_matrix (w->desired_matrix);
5804 clear_glyph_matrix (w->current_matrix); 5822 clear_glyph_matrix (w->current_matrix);
@@ -7617,8 +7635,6 @@ only be necessary if the default setting causes problems. */);
7617 defsubr (&Sdefault_printer_name); 7635 defsubr (&Sdefault_printer_name);
7618 defsubr (&Sset_message_beep); 7636 defsubr (&Sset_message_beep);
7619 7637
7620 check_window_system_func = check_w32;
7621
7622 hourglass_hwnd = NULL; 7638 hourglass_hwnd = NULL;
7623 7639
7624 defsubr (&Sx_show_tip); 7640 defsubr (&Sx_show_tip);
@@ -7759,6 +7775,9 @@ emacs_abort (void)
7759#endif 7775#endif
7760 if (stderr_fd >= 0) 7776 if (stderr_fd >= 0)
7761 write (stderr_fd, "\r\nBacktrace:\r\n", 14); 7777 write (stderr_fd, "\r\nBacktrace:\r\n", 14);
7778#ifdef CYGWIN
7779#define _open open
7780#endif
7762 errfile_fd = _open ("emacs_backtrace.txt", O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE); 7781 errfile_fd = _open ("emacs_backtrace.txt", O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
7763 if (errfile_fd >= 0) 7782 if (errfile_fd >= 0)
7764 { 7783 {
diff --git a/src/w32menu.c b/src/w32menu.c
index 03904cf20b8..0c8d5ca06c5 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -140,7 +140,7 @@ otherwise it is "Question". */)
140 FRAME_PTR f = NULL; 140 FRAME_PTR f = NULL;
141 Lisp_Object window; 141 Lisp_Object window;
142 142
143 check_w32 (); 143 check_window_system ();
144 144
145 /* Decode the first argument: find the window or frame to use. */ 145 /* Decode the first argument: find the window or frame to use. */
146 if (EQ (position, Qt) 146 if (EQ (position, Qt)
@@ -396,7 +396,7 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p)
396 if (! menubar_widget) 396 if (! menubar_widget)
397 previous_menu_items_used = 0; 397 previous_menu_items_used = 0;
398 398
399 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; 399 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
400 specbind (Qinhibit_quit, Qt); 400 specbind (Qinhibit_quit, Qt);
401 /* Don't let the debugger step into this code 401 /* Don't let the debugger step into this code
402 because it is not reentrant. */ 402 because it is not reentrant. */
diff --git a/src/w32term.c b/src/w32term.c
index 989ceb0f847..d249d6e3252 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -109,9 +109,10 @@ struct w32_display_info *x_display_list;
109Lisp_Object w32_display_name_list; 109Lisp_Object w32_display_name_list;
110 110
111 111
112#if _WIN32_WINNT < 0x0500 112#if _WIN32_WINNT < 0x0500 && !defined(_W64)
113/* Pre Windows 2000, this was not available, but define it here so 113/* Pre Windows 2000, this was not available, but define it here so
114 that Emacs compiled on such a platform will run on newer versions. */ 114 that Emacs compiled on such a platform will run on newer versions.
115 MinGW64 (_W64) defines these unconditionally, so avoid redefining. */
115 116
116typedef struct tagWCRANGE 117typedef struct tagWCRANGE
117{ 118{
@@ -5660,8 +5661,6 @@ x_check_fullscreen (struct frame *f)
5660static void 5661static void
5661w32fullscreen_hook (FRAME_PTR f) 5662w32fullscreen_hook (FRAME_PTR f)
5662{ 5663{
5663 static int normal_width, normal_height;
5664
5665 if (FRAME_VISIBLE_P (f)) 5664 if (FRAME_VISIBLE_P (f))
5666 { 5665 {
5667 int width, height, top_pos, left_pos, pixel_height, pixel_width; 5666 int width, height, top_pos, left_pos, pixel_height, pixel_width;
@@ -5669,17 +5668,38 @@ w32fullscreen_hook (FRAME_PTR f)
5669 RECT workarea_rect; 5668 RECT workarea_rect;
5670 5669
5671 block_input (); 5670 block_input ();
5672 if (normal_height <= 0) 5671 /* Record current "normal" dimensions for restoring later. */
5673 normal_height = cur_h; 5672 if (!( FRAME_PREV_FSMODE (f) == FULLSCREEN_BOTH
5674 if (normal_width <= 0) 5673 || FRAME_PREV_FSMODE (f) == FULLSCREEN_MAXIMIZED))
5675 normal_width = cur_w; 5674 {
5675 if (FRAME_PREV_FSMODE (f) != FULLSCREEN_HEIGHT)
5676 {
5677 FRAME_NORMAL_HEIGHT (f) = cur_h;
5678 FRAME_NORMAL_TOP (f) = f->top_pos;
5679 }
5680 if (FRAME_PREV_FSMODE (f) != FULLSCREEN_WIDTH)
5681 {
5682 FRAME_NORMAL_WIDTH (f) = cur_w;
5683 FRAME_NORMAL_LEFT (f) = f->left_pos;
5684 }
5685 }
5686 eassert (FRAME_NORMAL_HEIGHT (f) > 0);
5687 eassert (FRAME_NORMAL_WIDTH (f) > 0);
5676 x_real_positions (f, &f->left_pos, &f->top_pos); 5688 x_real_positions (f, &f->left_pos, &f->top_pos);
5677 x_fullscreen_adjust (f, &width, &height, &top_pos, &left_pos); 5689 x_fullscreen_adjust (f, &width, &height, &top_pos, &left_pos);
5678 5690
5679 SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0); 5691 SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0);
5680 pixel_height = workarea_rect.bottom - workarea_rect.top; 5692 pixel_height = workarea_rect.bottom - workarea_rect.top;
5681 pixel_width = workarea_rect.right - workarea_rect.left; 5693 pixel_width = workarea_rect.right - workarea_rect.left;
5682 5694 /* Need to send SC_RESTORE to the window, in case we are
5695 resizing from FULLSCREEN_MAXIMIZED. Otherwise, the mouse
5696 resize hints will not be shown by the window manager when the
5697 mouse pointer hovers over the window edges, because the WM
5698 will still think the window is maximized. */
5699 if (f->want_fullscreen != FULLSCREEN_BOTH)
5700 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_RESTORE, 0);
5701
5702 FRAME_PREV_FSMODE (f) = f->want_fullscreen;
5683 switch (f->want_fullscreen) 5703 switch (f->want_fullscreen)
5684 { 5704 {
5685 case FULLSCREEN_BOTH: 5705 case FULLSCREEN_BOTH:
@@ -5700,8 +5720,7 @@ w32fullscreen_hook (FRAME_PTR f)
5700 width = 5720 width =
5701 FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width) 5721 FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width)
5702 - FRAME_SCROLL_BAR_COLS (f); 5722 - FRAME_SCROLL_BAR_COLS (f);
5703 if (normal_height > 0) 5723 height = FRAME_NORMAL_HEIGHT (f);
5704 height = normal_height;
5705 left_pos = workarea_rect.left; 5724 left_pos = workarea_rect.left;
5706 break; 5725 break;
5707 case FULLSCREEN_HEIGHT: 5726 case FULLSCREEN_HEIGHT:
@@ -5709,21 +5728,14 @@ w32fullscreen_hook (FRAME_PTR f)
5709 FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) 5728 FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height)
5710 - XINT (Ftool_bar_lines_needed (selected_frame)) 5729 - XINT (Ftool_bar_lines_needed (selected_frame))
5711 + (NILP (Vmenu_bar_mode) ? 1 : 0); 5730 + (NILP (Vmenu_bar_mode) ? 1 : 0);
5712 if (normal_width > 0) 5731 width = FRAME_NORMAL_WIDTH (f);
5713 width = normal_width;
5714 top_pos = workarea_rect.top; 5732 top_pos = workarea_rect.top;
5715 break; 5733 break;
5716 case FULLSCREEN_NONE: 5734 case FULLSCREEN_NONE:
5717 if (normal_height > 0) 5735 height = FRAME_NORMAL_HEIGHT (f);
5718 height = normal_height; 5736 width = FRAME_NORMAL_WIDTH (f);
5719 else 5737 left_pos = FRAME_NORMAL_LEFT (f);
5720 normal_height = height; 5738 top_pos = FRAME_NORMAL_TOP (f);
5721 if (normal_width > 0)
5722 width = normal_width;
5723 else
5724 normal_width = width;
5725 /* FIXME: Should restore the original position of the frame. */
5726 top_pos = left_pos = 0;
5727 break; 5739 break;
5728 } 5740 }
5729 5741
@@ -6651,7 +6663,7 @@ w32_initialize (void)
6651 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil); 6663 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil);
6652 6664
6653 { 6665 {
6654 DWORD input_locale_id = (DWORD) GetKeyboardLayout (0); 6666 DWORD input_locale_id = ((DWORD_PTR) GetKeyboardLayout (0) & 0xffffffff);
6655 w32_keyboard_codepage = 6667 w32_keyboard_codepage =
6656 codepage_for_locale ((LCID) (input_locale_id & 0xffff)); 6668 codepage_for_locale ((LCID) (input_locale_id & 0xffff));
6657 } 6669 }
diff --git a/src/w32term.h b/src/w32term.h
index a31c5de193d..e85ee7790d5 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -203,7 +203,6 @@ extern void x_focus_on_frame (struct frame *f);
203 203
204extern struct w32_display_info *w32_term_init (Lisp_Object, 204extern struct w32_display_info *w32_term_init (Lisp_Object,
205 char *, char *); 205 char *, char *);
206extern void check_w32 (void);
207extern int w32_defined_color (FRAME_PTR f, const char *color, 206extern int w32_defined_color (FRAME_PTR f, const char *color,
208 XColor *color_def, int alloc); 207 XColor *color_def, int alloc);
209extern void x_set_window_size (struct frame *f, int change_grav, 208extern void x_set_window_size (struct frame *f, int change_grav,
@@ -359,6 +358,12 @@ struct w32_output
359 /* The background for which the above relief GCs were set up. 358 /* The background for which the above relief GCs were set up.
360 They are changed only when a different background is involved. */ 359 They are changed only when a different background is involved. */
361 unsigned long relief_background; 360 unsigned long relief_background;
361
362 /* Frame geometry and full-screen mode before it was resized by
363 specifying the 'fullscreen' frame parameter. Used to restore the
364 geometry when 'fullscreen' is reset to nil. */
365 int normal_width, normal_height, normal_top, normal_left;
366 int prev_fsmode;
362}; 367};
363 368
364extern struct w32_output w32term_display; 369extern struct w32_output w32term_display;
@@ -390,6 +395,13 @@ extern struct w32_output w32term_display;
390 395
391#define FRAME_SMALLEST_FONT_HEIGHT(F) \ 396#define FRAME_SMALLEST_FONT_HEIGHT(F) \
392 FRAME_W32_DISPLAY_INFO(F)->smallest_font_height 397 FRAME_W32_DISPLAY_INFO(F)->smallest_font_height
398
399#define FRAME_NORMAL_WIDTH(F) ((F)->output_data.w32->normal_width)
400#define FRAME_NORMAL_HEIGHT(F) ((F)->output_data.w32->normal_height)
401#define FRAME_NORMAL_TOP(F) ((F)->output_data.w32->normal_top)
402#define FRAME_NORMAL_LEFT(F) ((F)->output_data.w32->normal_left)
403#define FRAME_PREV_FSMODE(F) ((F)->output_data.w32->prev_fsmode)
404
393 405
394/* W32-specific scroll bar stuff. */ 406/* W32-specific scroll bar stuff. */
395 407
diff --git a/src/window.c b/src/window.c
index 875d7770277..feb5f7b5cc7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -147,11 +147,6 @@ wset_display_table (struct window *w, Lisp_Object val)
147 w->display_table = val; 147 w->display_table = val;
148} 148}
149static void 149static void
150wset_hchild (struct window *w, Lisp_Object val)
151{
152 w->hchild = val;
153}
154static void
155wset_left_fringe_width (struct window *w, Lisp_Object val) 150wset_left_fringe_width (struct window *w, Lisp_Object val)
156{ 151{
157 w->left_fringe_width = val; 152 w->left_fringe_width = val;
@@ -217,11 +212,6 @@ wset_temslot (struct window *w, Lisp_Object val)
217 w->temslot = val; 212 w->temslot = val;
218} 213}
219static void 214static void
220wset_vchild (struct window *w, Lisp_Object val)
221{
222 w->vchild = val;
223}
224static void
225wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) 215wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val)
226{ 216{
227 w->vertical_scroll_bar_type = val; 217 w->vertical_scroll_bar_type = val;
@@ -231,6 +221,18 @@ wset_window_parameters (struct window *w, Lisp_Object val)
231{ 221{
232 w->window_parameters = val; 222 w->window_parameters = val;
233} 223}
224static void
225wset_combination (struct window *w, bool horflag, Lisp_Object val)
226{
227 /* Since leaf windows never becomes non-leaf, there should
228 be no buffer and markers in start and pointm fields of W. */
229 eassert (!BUFFERP (w->contents) && NILP (w->start) && NILP (w->pointm));
230 w->contents = val;
231 /* When an internal window is deleted and VAL is nil, HORFLAG
232 is meaningless. */
233 if (!NILP (val))
234 w->horizontal = horflag;
235}
234 236
235struct window * 237struct window *
236decode_live_window (register Lisp_Object window) 238decode_live_window (register Lisp_Object window)
@@ -275,9 +277,9 @@ static void
275adjust_window_count (struct window *w, int arg) 277adjust_window_count (struct window *w, int arg)
276{ 278{
277 eassert (eabs (arg) == 1); 279 eassert (eabs (arg) == 1);
278 if (BUFFERP (w->buffer)) 280 if (BUFFERP (w->contents))
279 { 281 {
280 struct buffer *b = XBUFFER (w->buffer); 282 struct buffer *b = XBUFFER (w->contents);
281 283
282 if (b->base_buffer) 284 if (b->base_buffer)
283 b = b->base_buffer; 285 b = b->base_buffer;
@@ -296,7 +298,11 @@ void
296wset_buffer (struct window *w, Lisp_Object val) 298wset_buffer (struct window *w, Lisp_Object val)
297{ 299{
298 adjust_window_count (w, -1); 300 adjust_window_count (w, -1);
299 w->buffer = val; 301 if (BUFFERP (val))
302 /* Make sure that we do not assign the buffer
303 to an internal window. */
304 eassert (MARKERP (w->start) && MARKERP (w->pointm));
305 w->contents = val;
300 adjust_window_count (w, 1); 306 adjust_window_count (w, 1);
301} 307}
302 308
@@ -394,15 +400,8 @@ the first window of that frame. */)
394 window = XFRAME (frame_or_window)->root_window; 400 window = XFRAME (frame_or_window)->root_window;
395 } 401 }
396 402
397 while (NILP (XWINDOW (window)->buffer)) 403 while (WINDOWP (XWINDOW (window)->contents))
398 { 404 window = XWINDOW (window)->contents;
399 if (! NILP (XWINDOW (window)->hchild))
400 window = XWINDOW (window)->hchild;
401 else if (! NILP (XWINDOW (window)->vchild))
402 window = XWINDOW (window)->vchild;
403 else
404 emacs_abort ();
405 }
406 405
407 return window; 406 return window;
408} 407}
@@ -489,11 +488,11 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
489 if (NILP (norecord)) 488 if (NILP (norecord))
490 { 489 {
491 w->use_time = ++window_select_count; 490 w->use_time = ++window_select_count;
492 record_buffer (w->buffer); 491 record_buffer (w->contents);
493 } 492 }
494 493
495 /* Make the selected window's buffer current. */ 494 /* Make the selected window's buffer current. */
496 Fset_buffer (w->buffer); 495 Fset_buffer (w->contents);
497 496
498 if (EQ (window, selected_window) && !inhibit_point_swap) 497 if (EQ (window, selected_window) && !inhibit_point_swap)
499 return window; 498 return window;
@@ -516,7 +515,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
516 515
517 select_window_1 (window, inhibit_point_swap); 516 select_window_1 (window, inhibit_point_swap);
518 517
519 bset_last_selected_window (XBUFFER (w->buffer), window); 518 bset_last_selected_window (XBUFFER (w->contents), window);
520 windows_or_buffers_changed++; 519 windows_or_buffers_changed++;
521 return window; 520 return window;
522} 521}
@@ -533,10 +532,10 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap)
533 if (!inhibit_point_swap) 532 if (!inhibit_point_swap)
534 { 533 {
535 struct window *ow = XWINDOW (selected_window); 534 struct window *ow = XWINDOW (selected_window);
536 if (! NILP (ow->buffer)) 535 if (BUFFERP (ow->contents))
537 set_marker_both (ow->pointm, ow->buffer, 536 set_marker_both (ow->pointm, ow->contents,
538 BUF_PT (XBUFFER (ow->buffer)), 537 BUF_PT (XBUFFER (ow->contents)),
539 BUF_PT_BYTE (XBUFFER (ow->buffer))); 538 BUF_PT_BYTE (XBUFFER (ow->contents)));
540 } 539 }
541 540
542 selected_window = window; 541 selected_window = window;
@@ -581,7 +580,8 @@ If WINDOW is omitted or nil, it defaults to the selected window.
581Return nil for an internal window or a deleted window. */) 580Return nil for an internal window or a deleted window. */)
582 (Lisp_Object window) 581 (Lisp_Object window)
583{ 582{
584 return decode_any_window (window)->buffer; 583 struct window *w = decode_any_window (window);
584 return WINDOW_LEAF_P (w) ? w->contents : Qnil;
585} 585}
586 586
587DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, 587DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0,
@@ -601,7 +601,8 @@ Return nil if WINDOW is an internal window whose children form a
601horizontal combination. */) 601horizontal combination. */)
602 (Lisp_Object window) 602 (Lisp_Object window)
603{ 603{
604 return decode_valid_window (window)->vchild; 604 struct window *w = decode_valid_window (window);
605 return WINDOW_VERTICAL_COMBINATION_P (w) ? w->contents : Qnil;
605} 606}
606 607
607DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, 608DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0,
@@ -612,7 +613,8 @@ Return nil if WINDOW is an internal window whose children form a
612vertical combination. */) 613vertical combination. */)
613 (Lisp_Object window) 614 (Lisp_Object window)
614{ 615{
615 return decode_valid_window (window)->hchild; 616 struct window *w = decode_valid_window (window);
617 return WINDOW_HORIZONTAL_COMBINATION_P (w) ? w->contents : Qnil;
616} 618}
617 619
618DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, 620DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0,
@@ -645,9 +647,9 @@ WINDOW are never \(re-)combined with WINDOW's siblings. */)
645 647
646 CHECK_VALID_WINDOW (window); 648 CHECK_VALID_WINDOW (window);
647 w = XWINDOW (window); 649 w = XWINDOW (window);
648 if (!NILP (w->buffer)) 650 if (WINDOW_LEAF_P (w))
649 error ("Combination limit is meaningful for internal windows only"); 651 error ("Combination limit is meaningful for internal windows only");
650 return XWINDOW (window)->combination_limit; 652 return w->combination_limit;
651} 653}
652 654
653DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 655DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
@@ -663,7 +665,7 @@ future use. */)
663 665
664 CHECK_VALID_WINDOW (window); 666 CHECK_VALID_WINDOW (window);
665 w = XWINDOW (window); 667 w = XWINDOW (window);
666 if (!NILP (w->buffer)) 668 if (WINDOW_LEAF_P (w))
667 error ("Combination limit is meaningful for internal windows only"); 669 error ("Combination limit is meaningful for internal windows only");
668 wset_combination_limit (w, limit); 670 wset_combination_limit (w, limit);
669 return limit; 671 return limit;
@@ -860,7 +862,7 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll)
860 862
861 /* Prevent redisplay shortcuts when changing the hscroll. */ 863 /* Prevent redisplay shortcuts when changing the hscroll. */
862 if (w->hscroll != new_hscroll) 864 if (w->hscroll != new_hscroll)
863 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 865 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
864 866
865 w->hscroll = new_hscroll; 867 w->hscroll = new_hscroll;
866 return make_number (new_hscroll); 868 return make_number (new_hscroll);
@@ -1441,7 +1443,7 @@ correct to return the top-level value of `point', outside of any
1441 register struct window *w = decode_live_window (window); 1443 register struct window *w = decode_live_window (window);
1442 1444
1443 if (w == XWINDOW (selected_window)) 1445 if (w == XWINDOW (selected_window))
1444 return make_number (BUF_PT (XBUFFER (w->buffer))); 1446 return make_number (BUF_PT (XBUFFER (w->contents)));
1445 else 1447 else
1446 return Fmarker_position (w->pointm); 1448 return Fmarker_position (w->pointm);
1447} 1449}
@@ -1483,7 +1485,7 @@ if it isn't already recorded. */)
1483 Lisp_Object buf; 1485 Lisp_Object buf;
1484 struct buffer *b; 1486 struct buffer *b;
1485 1487
1486 buf = w->buffer; 1488 buf = w->contents;
1487 CHECK_BUFFER (buf); 1489 CHECK_BUFFER (buf);
1488 b = XBUFFER (buf); 1490 b = XBUFFER (buf);
1489 1491
@@ -1546,7 +1548,7 @@ Return POS. */)
1546 1548
1547 if (w == XWINDOW (selected_window)) 1549 if (w == XWINDOW (selected_window))
1548 { 1550 {
1549 if (XBUFFER (w->buffer) == current_buffer) 1551 if (XBUFFER (w->contents) == current_buffer)
1550 Fgoto_char (pos); 1552 Fgoto_char (pos);
1551 else 1553 else
1552 { 1554 {
@@ -1554,14 +1556,14 @@ Return POS. */)
1554 1556
1555 /* ... but here we want to catch type error before buffer change. */ 1557 /* ... but here we want to catch type error before buffer change. */
1556 CHECK_NUMBER_COERCE_MARKER (pos); 1558 CHECK_NUMBER_COERCE_MARKER (pos);
1557 set_buffer_internal (XBUFFER (w->buffer)); 1559 set_buffer_internal (XBUFFER (w->contents));
1558 Fgoto_char (pos); 1560 Fgoto_char (pos);
1559 set_buffer_internal (old_buffer); 1561 set_buffer_internal (old_buffer);
1560 } 1562 }
1561 } 1563 }
1562 else 1564 else
1563 { 1565 {
1564 set_marker_restricted (w->pointm, pos, w->buffer); 1566 set_marker_restricted (w->pointm, pos, w->contents);
1565 /* We have to make sure that redisplay updates the window to show 1567 /* We have to make sure that redisplay updates the window to show
1566 the new value of point. */ 1568 the new value of point. */
1567 ++windows_or_buffers_changed; 1569 ++windows_or_buffers_changed;
@@ -1579,7 +1581,7 @@ overriding motion of point in order to display at this exact start. */)
1579{ 1581{
1580 register struct window *w = decode_live_window (window); 1582 register struct window *w = decode_live_window (window);
1581 1583
1582 set_marker_restricted (w->start, pos, w->buffer); 1584 set_marker_restricted (w->start, pos, w->contents);
1583 /* This is not right, but much easier than doing what is right. */ 1585 /* This is not right, but much easier than doing what is right. */
1584 w->start_at_line_beg = 0; 1586 w->start_at_line_beg = 0;
1585 if (NILP (noforce)) 1587 if (NILP (noforce))
@@ -1623,7 +1625,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1623 int x, y; 1625 int x, y;
1624 1626
1625 w = decode_live_window (window); 1627 w = decode_live_window (window);
1626 buf = XBUFFER (w->buffer); 1628 buf = XBUFFER (w->contents);
1627 SET_TEXT_POS_FROM_MARKER (top, w->start); 1629 SET_TEXT_POS_FROM_MARKER (top, w->start);
1628 1630
1629 if (EQ (pos, Qt)) 1631 if (EQ (pos, Qt))
@@ -1692,8 +1694,8 @@ Return nil if window display is not up-to-date. In that case, use
1692 if (noninteractive || w->pseudo_window_p) 1694 if (noninteractive || w->pseudo_window_p)
1693 return Qnil; 1695 return Qnil;
1694 1696
1695 CHECK_BUFFER (w->buffer); 1697 CHECK_BUFFER (w->contents);
1696 b = XBUFFER (w->buffer); 1698 b = XBUFFER (w->contents);
1697 1699
1698 /* Fail if current matrix is not up-to-date. */ 1700 /* Fail if current matrix is not up-to-date. */
1699 if (!w->window_end_valid 1701 if (!w->window_end_valid
@@ -1919,9 +1921,9 @@ window_display_table (struct window *w)
1919 1921
1920 if (DISP_TABLE_P (w->display_table)) 1922 if (DISP_TABLE_P (w->display_table))
1921 dp = XCHAR_TABLE (w->display_table); 1923 dp = XCHAR_TABLE (w->display_table);
1922 else if (BUFFERP (w->buffer)) 1924 else if (BUFFERP (w->contents))
1923 { 1925 {
1924 struct buffer *b = XBUFFER (w->buffer); 1926 struct buffer *b = XBUFFER (w->contents);
1925 1927
1926 if (DISP_TABLE_P (BVAR (b, display_table))) 1928 if (DISP_TABLE_P (BVAR (b, display_table)))
1927 dp = XCHAR_TABLE (BVAR (b, display_table)); 1929 dp = XCHAR_TABLE (BVAR (b, display_table));
@@ -1946,17 +1948,14 @@ WINDOW must be a live window and defaults to the selected one. */)
1946static void 1948static void
1947unshow_buffer (register struct window *w) 1949unshow_buffer (register struct window *w)
1948{ 1950{
1949 Lisp_Object buf; 1951 Lisp_Object buf = w->contents;
1950 struct buffer *b; 1952 struct buffer *b = XBUFFER (buf);
1951 1953
1952 buf = w->buffer; 1954 eassert (b == XMARKER (w->pointm)->buffer);
1953 b = XBUFFER (buf);
1954 if (b != XMARKER (w->pointm)->buffer)
1955 emacs_abort ();
1956 1955
1957#if 0 1956#if 0
1958 if (w == XWINDOW (selected_window) 1957 if (w == XWINDOW (selected_window)
1959 || ! EQ (buf, XWINDOW (selected_window)->buffer)) 1958 || ! EQ (buf, XWINDOW (selected_window)->contents))
1960 /* Do this except when the selected window's buffer 1959 /* Do this except when the selected window's buffer
1961 is being removed from some other window. */ 1960 is being removed from some other window. */
1962#endif 1961#endif
@@ -1972,14 +1971,14 @@ unshow_buffer (register struct window *w)
1972 /* Point in the selected window's buffer 1971 /* Point in the selected window's buffer
1973 is actually stored in that buffer, and the window's pointm isn't used. 1972 is actually stored in that buffer, and the window's pointm isn't used.
1974 So don't clobber point in that buffer. */ 1973 So don't clobber point in that buffer. */
1975 if (! EQ (buf, XWINDOW (selected_window)->buffer) 1974 if (! EQ (buf, XWINDOW (selected_window)->contents)
1976 /* Don't clobber point in current buffer either (this could be 1975 /* Don't clobber point in current buffer either (this could be
1977 useful in connection with bug#12208). 1976 useful in connection with bug#12208).
1978 && XBUFFER (buf) != current_buffer */ 1977 && XBUFFER (buf) != current_buffer */
1979 /* This line helps to fix Horsley's testbug.el bug. */ 1978 /* This line helps to fix Horsley's testbug.el bug. */
1980 && !(WINDOWP (BVAR (b, last_selected_window)) 1979 && !(WINDOWP (BVAR (b, last_selected_window))
1981 && w != XWINDOW (BVAR (b, last_selected_window)) 1980 && w != XWINDOW (BVAR (b, last_selected_window))
1982 && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) 1981 && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->contents)))
1983 temp_set_point_both (b, 1982 temp_set_point_both (b,
1984 clip_to_bounds (BUF_BEGV (b), 1983 clip_to_bounds (BUF_BEGV (b),
1985 marker_position (w->pointm), 1984 marker_position (w->pointm),
@@ -2044,13 +2043,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
2044 2043
2045 tem = o->parent; 2044 tem = o->parent;
2046 wset_parent (n, tem); 2045 wset_parent (n, tem);
2047 if (!NILP (tem)) 2046 if (!NILP (tem) && EQ (XWINDOW (tem)->contents, old))
2048 { 2047 wset_combination (XWINDOW (tem), XWINDOW (tem)->horizontal, new);
2049 if (EQ (XWINDOW (tem)->vchild, old))
2050 wset_vchild (XWINDOW (tem), new);
2051 if (EQ (XWINDOW (tem)->hchild, old))
2052 wset_hchild (XWINDOW (tem), new);
2053 }
2054} 2048}
2055 2049
2056/* If window WINDOW and its parent window are iso-combined, merge 2050/* If window WINDOW and its parent window are iso-combined, merge
@@ -2069,22 +2063,19 @@ recombine_windows (Lisp_Object window)
2069 if (!NILP (parent) && NILP (w->combination_limit)) 2063 if (!NILP (parent) && NILP (w->combination_limit))
2070 { 2064 {
2071 p = XWINDOW (parent); 2065 p = XWINDOW (parent);
2072 if (((!NILP (p->vchild) && !NILP (w->vchild)) 2066 if (WINDOWP (p->contents) && WINDOWP (w->contents)
2073 || (!NILP (p->hchild) && !NILP (w->hchild)))) 2067 && p->horizontal == w->horizontal)
2074 /* WINDOW and PARENT are both either a vertical or a horizontal 2068 /* WINDOW and PARENT are both either a vertical or a horizontal
2075 combination. */ 2069 combination. */
2076 { 2070 {
2077 horflag = NILP (w->vchild); 2071 horflag = WINDOW_HORIZONTAL_COMBINATION_P (w);
2078 child = horflag ? w->hchild : w->vchild; 2072 child = w->contents;
2079 c = XWINDOW (child); 2073 c = XWINDOW (child);
2080 2074
2081 /* Splice WINDOW's children into its parent's children and 2075 /* Splice WINDOW's children into its parent's children and
2082 assign new normal sizes. */ 2076 assign new normal sizes. */
2083 if (NILP (w->prev)) 2077 if (NILP (w->prev))
2084 if (horflag) 2078 wset_combination (p, horflag, child);
2085 wset_hchild (p, child);
2086 else
2087 wset_vchild (p, child);
2088 else 2079 else
2089 { 2080 {
2090 wset_prev (c, w->prev); 2081 wset_prev (c, w->prev);
@@ -2122,8 +2113,7 @@ recombine_windows (Lisp_Object window)
2122 } 2113 }
2123 2114
2124 /* WINDOW can be deleted now. */ 2115 /* WINDOW can be deleted now. */
2125 wset_vchild (w, Qnil); 2116 wset_combination (w, 0, Qnil);
2126 wset_hchild (w, Qnil);
2127 } 2117 }
2128 } 2118 }
2129} 2119}
@@ -2209,7 +2199,7 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf
2209 struct frame *f = XFRAME (w->frame); 2199 struct frame *f = XFRAME (w->frame);
2210 int candidate_p = 1; 2200 int candidate_p = 1;
2211 2201
2212 if (!BUFFERP (w->buffer)) 2202 if (!BUFFERP (w->contents))
2213 candidate_p = 0; 2203 candidate_p = 0;
2214 else if (MINI_WINDOW_P (w) 2204 else if (MINI_WINDOW_P (w)
2215 && (EQ (minibuf, Qlambda) 2205 && (EQ (minibuf, Qlambda)
@@ -2549,7 +2539,7 @@ enum window_loop
2549 GET_BUFFER_WINDOW, /* Arg is buffer */ 2539 GET_BUFFER_WINDOW, /* Arg is buffer */
2550 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */ 2540 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */
2551 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ 2541 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */
2552 CHECK_ALL_WINDOWS 2542 CHECK_ALL_WINDOWS /* Arg is ignored */
2553}; 2543};
2554 2544
2555static Lisp_Object 2545static Lisp_Object
@@ -2613,7 +2603,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2613 switch (type) 2603 switch (type)
2614 { 2604 {
2615 case GET_BUFFER_WINDOW: 2605 case GET_BUFFER_WINDOW:
2616 if (EQ (w->buffer, obj) 2606 if (EQ (w->contents, obj)
2617 /* Don't find any minibuffer window except the one that 2607 /* Don't find any minibuffer window except the one that
2618 is currently in use. */ 2608 is currently in use. */
2619 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) 2609 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1))
@@ -2637,25 +2627,25 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2637 case REPLACE_BUFFER_IN_WINDOWS_SAFELY: 2627 case REPLACE_BUFFER_IN_WINDOWS_SAFELY:
2638 /* We could simply check whether the buffer shown by window 2628 /* We could simply check whether the buffer shown by window
2639 is live, and show another buffer in case it isn't. */ 2629 is live, and show another buffer in case it isn't. */
2640 if (EQ (w->buffer, obj)) 2630 if (EQ (w->contents, obj))
2641 { 2631 {
2642 /* Undedicate WINDOW. */ 2632 /* Undedicate WINDOW. */
2643 wset_dedicated (w, Qnil); 2633 wset_dedicated (w, Qnil);
2644 /* Make WINDOW show the buffer returned by 2634 /* Make WINDOW show the buffer returned by
2645 other_buffer_safely, don't run any hooks. */ 2635 other_buffer_safely, don't run any hooks. */
2646 set_window_buffer 2636 set_window_buffer
2647 (window, other_buffer_safely (w->buffer), 0, 0); 2637 (window, other_buffer_safely (w->contents), 0, 0);
2648 /* If WINDOW is the selected window, make its buffer 2638 /* If WINDOW is the selected window, make its buffer
2649 current. But do so only if the window shows the 2639 current. But do so only if the window shows the
2650 current buffer (Bug#6454). */ 2640 current buffer (Bug#6454). */
2651 if (EQ (window, selected_window) 2641 if (EQ (window, selected_window)
2652 && XBUFFER (w->buffer) == current_buffer) 2642 && XBUFFER (w->contents) == current_buffer)
2653 Fset_buffer (w->buffer); 2643 Fset_buffer (w->contents);
2654 } 2644 }
2655 break; 2645 break;
2656 2646
2657 case REDISPLAY_BUFFER_WINDOWS: 2647 case REDISPLAY_BUFFER_WINDOWS:
2658 if (EQ (w->buffer, obj)) 2648 if (EQ (w->contents, obj))
2659 { 2649 {
2660 mark_window_display_accurate (window, 0); 2650 mark_window_display_accurate (window, 0);
2661 w->update_mode_line = 1; 2651 w->update_mode_line = 1;
@@ -2665,11 +2655,20 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2665 } 2655 }
2666 break; 2656 break;
2667 2657
2668 /* Check for a window that has a killed buffer. */ 2658 /* Check for a leaf window that has a killed buffer
2659 or broken markers. */
2669 case CHECK_ALL_WINDOWS: 2660 case CHECK_ALL_WINDOWS:
2670 if (! NILP (w->buffer) 2661 if (BUFFERP (w->contents))
2671 && !BUFFER_LIVE_P (XBUFFER (w->buffer))) 2662 {
2672 emacs_abort (); 2663 struct buffer *b = XBUFFER (w->contents);
2664
2665 if (!BUFFER_LIVE_P (b))
2666 emacs_abort ();
2667 if (!MARKERP (w->start) || XMARKER (w->start)->buffer != b)
2668 emacs_abort ();
2669 if (!MARKERP (w->pointm) || XMARKER (w->pointm)->buffer != b)
2670 emacs_abort ();
2671 }
2673 break; 2672 break;
2674 2673
2675 case WINDOW_LOOP_UNUSED: 2674 case WINDOW_LOOP_UNUSED:
@@ -2786,7 +2785,7 @@ window-start value is reasonable when this function is called. */)
2786 else if (MINI_WINDOW_P (w)) /* && top > 0) */ 2785 else if (MINI_WINDOW_P (w)) /* && top > 0) */
2787 error ("Can't expand minibuffer to full frame"); 2786 error ("Can't expand minibuffer to full frame");
2788 2787
2789 if (!NILP (w->buffer)) 2788 if (BUFFERP (w->contents))
2790 { 2789 {
2791 startpos = marker_position (w->start); 2790 startpos = marker_position (w->start);
2792 startbyte = marker_byte_position (w->start); 2791 startbyte = marker_byte_position (w->start);
@@ -2858,7 +2857,7 @@ window-start value is reasonable when this function is called. */)
2858 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 2857 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
2859 resize_failed = 0; 2858 resize_failed = 0;
2860 2859
2861 if (NILP (w->buffer)) 2860 if (!WINDOW_LEAF_P (w))
2862 { 2861 {
2863 /* Resize child windows vertically. */ 2862 /* Resize child windows vertically. */
2864 XSETINT (delta, r->total_lines - w->total_lines); 2863 XSETINT (delta, r->total_lines - w->total_lines);
@@ -2917,28 +2916,21 @@ window-start value is reasonable when this function is called. */)
2917 sibling = w->next; 2916 sibling = w->next;
2918 s = XWINDOW (sibling); 2917 s = XWINDOW (sibling);
2919 wset_prev (s, Qnil); 2918 wset_prev (s, Qnil);
2920 if (!NILP (XWINDOW (w->parent)->vchild)) 2919 wset_combination (XWINDOW (w->parent),
2921 wset_vchild (XWINDOW (w->parent), sibling); 2920 XWINDOW (w->parent)->horizontal, sibling);
2922 else
2923 wset_hchild (XWINDOW (w->parent), sibling);
2924 } 2921 }
2925 2922
2926 /* Delete ROOT and all child windows of ROOT. */ 2923 /* Delete ROOT and all child windows of ROOT. */
2927 if (!NILP (r->vchild)) 2924 if (WINDOWP (r->contents))
2928 { 2925 {
2929 delete_all_child_windows (r->vchild); 2926 delete_all_child_windows (r->contents);
2930 wset_vchild (r, Qnil); 2927 wset_combination (r, 0, Qnil);
2931 }
2932 else if (!NILP (r->hchild))
2933 {
2934 delete_all_child_windows (r->hchild);
2935 wset_hchild (r, Qnil);
2936 } 2928 }
2937 2929
2938 replace_window (root, window, 1); 2930 replace_window (root, window, 1);
2939 2931
2940 /* This must become SWINDOW anyway ....... */ 2932 /* This must become SWINDOW anyway ....... */
2941 if (!NILP (w->buffer) && !resize_failed) 2933 if (BUFFERP (w->contents) && !resize_failed)
2942 { 2934 {
2943 /* Try to minimize scrolling, by setting the window start to the 2935 /* Try to minimize scrolling, by setting the window start to the
2944 point will cause the text at the old window start to be at the 2936 point will cause the text at the old window start to be at the
@@ -2947,18 +2939,18 @@ window-start value is reasonable when this function is called. */)
2947 when the display is not current, due to typeahead). */ 2939 when the display is not current, due to typeahead). */
2948 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); 2940 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
2949 if (new_top != top 2941 if (new_top != top
2950 && startpos >= BUF_BEGV (XBUFFER (w->buffer)) 2942 && startpos >= BUF_BEGV (XBUFFER (w->contents))
2951 && startpos <= BUF_ZV (XBUFFER (w->buffer))) 2943 && startpos <= BUF_ZV (XBUFFER (w->contents)))
2952 { 2944 {
2953 struct position pos; 2945 struct position pos;
2954 struct buffer *obuf = current_buffer; 2946 struct buffer *obuf = current_buffer;
2955 2947
2956 Fset_buffer (w->buffer); 2948 Fset_buffer (w->contents);
2957 /* This computation used to temporarily move point, but that 2949 /* This computation used to temporarily move point, but that
2958 can have unwanted side effects due to text properties. */ 2950 can have unwanted side effects due to text properties. */
2959 pos = *vmotion (startpos, startbyte, -top, w); 2951 pos = *vmotion (startpos, startbyte, -top, w);
2960 2952
2961 set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); 2953 set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos);
2962 w->window_end_valid = 0; 2954 w->window_end_valid = 0;
2963 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE 2955 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE
2964 || FETCH_BYTE (pos.bytepos - 1) == '\n'); 2956 || FETCH_BYTE (pos.bytepos - 1) == '\n');
@@ -3158,7 +3150,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3158 struct window *w = XWINDOW (window); 3150 struct window *w = XWINDOW (window);
3159 struct buffer *b = XBUFFER (buffer); 3151 struct buffer *b = XBUFFER (buffer);
3160 ptrdiff_t count = SPECPDL_INDEX (); 3152 ptrdiff_t count = SPECPDL_INDEX ();
3161 int samebuf = EQ (buffer, w->buffer); 3153 int samebuf = EQ (buffer, w->contents);
3162 3154
3163 wset_buffer (w, buffer); 3155 wset_buffer (w, buffer);
3164 3156
@@ -3277,7 +3269,7 @@ This function runs `window-scroll-functions' before running
3277 if (!BUFFER_LIVE_P (XBUFFER (buffer))) 3269 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
3278 error ("Attempt to display deleted buffer"); 3270 error ("Attempt to display deleted buffer");
3279 3271
3280 tem = w->buffer; 3272 tem = w->contents;
3281 if (NILP (tem)) 3273 if (NILP (tem))
3282 error ("Window is deleted"); 3274 error ("Window is deleted");
3283 else 3275 else
@@ -3330,8 +3322,8 @@ displaying that buffer. */)
3330 struct window *w = XWINDOW (object); 3322 struct window *w = XWINDOW (object);
3331 mark_window_display_accurate (object, 0); 3323 mark_window_display_accurate (object, 0);
3332 w->update_mode_line = 1; 3324 w->update_mode_line = 1;
3333 if (BUFFERP (w->buffer)) 3325 if (BUFFERP (w->contents))
3334 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 3326 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
3335 ++update_mode_lines; 3327 ++update_mode_lines;
3336 return Qt; 3328 return Qt;
3337 } 3329 }
@@ -3400,7 +3392,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3400 record_unwind_protect (Fset_buffer, prev_buffer); 3392 record_unwind_protect (Fset_buffer, prev_buffer);
3401 record_unwind_protect (select_window_norecord, prev_window); 3393 record_unwind_protect (select_window_norecord, prev_window);
3402 Fselect_window (window, Qt); 3394 Fselect_window (window, Qt);
3403 Fset_buffer (w->buffer); 3395 Fset_buffer (w->contents);
3404 Frun_hooks (1, &Qtemp_buffer_show_hook); 3396 Frun_hooks (1, &Qtemp_buffer_show_hook);
3405 unbind_to (count, Qnil); 3397 unbind_to (count, Qnil);
3406 } 3398 }
@@ -3421,7 +3413,7 @@ make_parent_window (Lisp_Object window, bool horflag)
3421 memcpy ((char *) p + sizeof (struct vectorlike_header), 3413 memcpy ((char *) p + sizeof (struct vectorlike_header),
3422 (char *) o + sizeof (struct vectorlike_header), 3414 (char *) o + sizeof (struct vectorlike_header),
3423 word_size * VECSIZE (struct window)); 3415 word_size * VECSIZE (struct window));
3424 /* P's buffer slot may change from nil to a buffer. */ 3416 /* P's buffer slot may change from nil to a buffer... */
3425 adjust_window_count (p, 1); 3417 adjust_window_count (p, 1);
3426 XSETWINDOW (parent, p); 3418 XSETWINDOW (parent, p);
3427 3419
@@ -3430,12 +3422,11 @@ make_parent_window (Lisp_Object window, bool horflag)
3430 wset_next (o, Qnil); 3422 wset_next (o, Qnil);
3431 wset_prev (o, Qnil); 3423 wset_prev (o, Qnil);
3432 wset_parent (o, parent); 3424 wset_parent (o, parent);
3433 3425 /* ...but now P becomes an internal window. */
3434 wset_hchild (p, horflag ? window : Qnil);
3435 wset_vchild (p, horflag ? Qnil : window);
3436 wset_start (p, Qnil); 3426 wset_start (p, Qnil);
3437 wset_pointm (p, Qnil); 3427 wset_pointm (p, Qnil);
3438 wset_buffer (p, Qnil); 3428 wset_buffer (p, Qnil);
3429 wset_combination (p, horflag, window);
3439 wset_combination_limit (p, Qnil); 3430 wset_combination_limit (p, Qnil);
3440 wset_window_parameters (p, Qnil); 3431 wset_window_parameters (p, Qnil);
3441} 3432}
@@ -3524,10 +3515,10 @@ window_resize_check (struct window *w, bool horflag)
3524{ 3515{
3525 struct window *c; 3516 struct window *c;
3526 3517
3527 if (!NILP (w->vchild)) 3518 if (WINDOW_VERTICAL_COMBINATION_P (w))
3528 /* W is a vertical combination. */ 3519 /* W is a vertical combination. */
3529 { 3520 {
3530 c = XWINDOW (w->vchild); 3521 c = XWINDOW (w->contents);
3531 if (horflag) 3522 if (horflag)
3532 /* All child windows of W must have the same width as W. */ 3523 /* All child windows of W must have the same width as W. */
3533 { 3524 {
@@ -3555,10 +3546,10 @@ window_resize_check (struct window *w, bool horflag)
3555 return (sum_of_sizes == XINT (w->new_total)); 3546 return (sum_of_sizes == XINT (w->new_total));
3556 } 3547 }
3557 } 3548 }
3558 else if (!NILP (w->hchild)) 3549 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
3559 /* W is a horizontal combination. */ 3550 /* W is a horizontal combination. */
3560 { 3551 {
3561 c = XWINDOW (w->hchild); 3552 c = XWINDOW (w->contents);
3562 if (horflag) 3553 if (horflag)
3563 /* The sum of the widths of the child windows of W must equal W's 3554 /* The sum of the widths of the child windows of W must equal W's
3564 width. */ 3555 width. */
@@ -3625,10 +3616,10 @@ window_resize_apply (struct window *w, bool horflag)
3625 pos = w->top_line; 3616 pos = w->top_line;
3626 } 3617 }
3627 3618
3628 if (!NILP (w->vchild)) 3619 if (WINDOW_VERTICAL_COMBINATION_P (w))
3629 /* W is a vertical combination. */ 3620 /* W is a vertical combination. */
3630 { 3621 {
3631 c = XWINDOW (w->vchild); 3622 c = XWINDOW (w->contents);
3632 while (c) 3623 while (c)
3633 { 3624 {
3634 if (horflag) 3625 if (horflag)
@@ -3641,10 +3632,10 @@ window_resize_apply (struct window *w, bool horflag)
3641 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3632 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3642 } 3633 }
3643 } 3634 }
3644 else if (!NILP (w->hchild)) 3635 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
3645 /* W is a horizontal combination. */ 3636 /* W is a horizontal combination. */
3646 { 3637 {
3647 c = XWINDOW (w->hchild); 3638 c = XWINDOW (w->contents);
3648 while (c) 3639 while (c)
3649 { 3640 {
3650 if (horflag) 3641 if (horflag)
@@ -3727,7 +3718,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag)
3727 ? 1 : 0))); 3718 ? 1 : 0)));
3728 3719
3729 r->top_line = FRAME_TOP_MARGIN (f); 3720 r->top_line = FRAME_TOP_MARGIN (f);
3730 if (NILP (r->vchild) && NILP (r->hchild)) 3721 if (WINDOW_LEAF_P (r))
3731 /* For a leaf root window just set the size. */ 3722 /* For a leaf root window just set the size. */
3732 if (horflag) 3723 if (horflag)
3733 r->total_cols = new_size; 3724 r->total_cols = new_size;
@@ -3842,9 +3833,9 @@ set correctly. See the code of `split-window' for how this is done. */)
3842 combination_limit = 3833 combination_limit =
3843 EQ (Vwindow_combination_limit, Qt) 3834 EQ (Vwindow_combination_limit, Qt)
3844 || NILP (o->parent) 3835 || NILP (o->parent)
3845 || NILP (horflag 3836 || (horflag
3846 ? (XWINDOW (o->parent)->hchild) 3837 ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent))
3847 : (XWINDOW (o->parent)->vchild)); 3838 : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent)));
3848 3839
3849 /* We need a live reference window to initialize some parameters. */ 3840 /* We need a live reference window to initialize some parameters. */
3850 if (WINDOW_LIVE_P (old)) 3841 if (WINDOW_LIVE_P (old))
@@ -3914,17 +3905,12 @@ set correctly. See the code of `split-window' for how this is done. */)
3914 n = XWINDOW (new); 3905 n = XWINDOW (new);
3915 wset_frame (n, frame); 3906 wset_frame (n, frame);
3916 wset_parent (n, o->parent); 3907 wset_parent (n, o->parent);
3917 wset_vchild (n, Qnil);
3918 wset_hchild (n, Qnil);
3919 3908
3920 if (EQ (side, Qabove) || EQ (side, Qleft)) 3909 if (EQ (side, Qabove) || EQ (side, Qleft))
3921 { 3910 {
3922 wset_prev (n, o->prev); 3911 wset_prev (n, o->prev);
3923 if (NILP (n->prev)) 3912 if (NILP (n->prev))
3924 if (horflag) 3913 wset_combination (p, horflag, new);
3925 wset_hchild (p, new);
3926 else
3927 wset_vchild (p, new);
3928 else 3914 else
3929 wset_next (XWINDOW (n->prev), new); 3915 wset_next (XWINDOW (n->prev), new);
3930 wset_next (n, old); 3916 wset_next (n, old);
@@ -3973,7 +3959,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3973 adjust_glyphs (f); 3959 adjust_glyphs (f);
3974 /* Set buffer of NEW to buffer of reference window. Don't run 3960 /* Set buffer of NEW to buffer of reference window. Don't run
3975 any hooks. */ 3961 any hooks. */
3976 set_window_buffer (new, r->buffer, 0, 1); 3962 set_window_buffer (new, r->contents, 0, 1);
3977 unblock_input (); 3963 unblock_input ();
3978 3964
3979 /* Maybe we should run the scroll functions in Elisp (which already 3965 /* Maybe we should run the scroll functions in Elisp (which already
@@ -3995,13 +3981,11 @@ Signal an error when WINDOW is the only window on its frame. */)
3995 register Lisp_Object parent, sibling, frame, root; 3981 register Lisp_Object parent, sibling, frame, root;
3996 struct window *w, *p, *s, *r; 3982 struct window *w, *p, *s, *r;
3997 struct frame *f; 3983 struct frame *f;
3998 bool horflag; 3984 bool horflag, before_sibling = 0;
3999 int before_sibling = 0;
4000 3985
4001 w = decode_any_window (window); 3986 w = decode_any_window (window);
4002 XSETWINDOW (window, w); 3987 XSETWINDOW (window, w);
4003 if (NILP (w->buffer) 3988 if (NILP (w->contents))
4004 && NILP (w->hchild) && NILP (w->vchild))
4005 /* It's a no-op to delete an already deleted window. */ 3989 /* It's a no-op to delete an already deleted window. */
4006 return Qnil; 3990 return Qnil;
4007 3991
@@ -4015,7 +3999,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4015 error ("Attempt to delete sole window of parent"); 3999 error ("Attempt to delete sole window of parent");
4016 4000
4017 p = XWINDOW (parent); 4001 p = XWINDOW (parent);
4018 horflag = NILP (p->vchild); 4002 horflag = WINDOW_HORIZONTAL_COMBINATION_P (p);
4019 4003
4020 frame = WINDOW_FRAME (w); 4004 frame = WINDOW_FRAME (w);
4021 f = XFRAME (frame); 4005 f = XFRAME (frame);
@@ -4033,10 +4017,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4033 sibling = w->next; 4017 sibling = w->next;
4034 s = XWINDOW (sibling); 4018 s = XWINDOW (sibling);
4035 wset_prev (s, Qnil); 4019 wset_prev (s, Qnil);
4036 if (horflag) 4020 wset_combination (p, horflag, sibling);
4037 wset_hchild (p, sibling);
4038 else
4039 wset_vchild (p, sibling);
4040 } 4021 }
4041 else 4022 else
4042 /* Get SIBLING above (on the left of) WINDOW. */ 4023 /* Get SIBLING above (on the left of) WINDOW. */
@@ -4075,17 +4056,12 @@ Signal an error when WINDOW is the only window on its frame. */)
4075 wset_next (w, Qnil); /* Don't delete w->next too. */ 4056 wset_next (w, Qnil); /* Don't delete w->next too. */
4076 free_window_matrices (w); 4057 free_window_matrices (w);
4077 4058
4078 if (!NILP (w->vchild)) 4059 if (WINDOWP (w->contents))
4079 { 4060 {
4080 delete_all_child_windows (w->vchild); 4061 delete_all_child_windows (w->contents);
4081 wset_vchild (w, Qnil); 4062 wset_combination (w, 0, Qnil);
4082 } 4063 }
4083 else if (!NILP (w->hchild)) 4064 else
4084 {
4085 delete_all_child_windows (w->hchild);
4086 wset_hchild (w, Qnil);
4087 }
4088 else if (!NILP (w->buffer))
4089 { 4065 {
4090 unshow_buffer (w); 4066 unshow_buffer (w);
4091 unchain_marker (XMARKER (w->pointm)); 4067 unchain_marker (XMARKER (w->pointm));
@@ -4104,8 +4080,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4104 wset_normal_cols (s, p->normal_cols); 4080 wset_normal_cols (s, p->normal_cols);
4105 wset_normal_lines (s, p->normal_lines); 4081 wset_normal_lines (s, p->normal_lines);
4106 /* Mark PARENT as deleted. */ 4082 /* Mark PARENT as deleted. */
4107 wset_vchild (p, Qnil); 4083 wset_combination (p, 0, Qnil);
4108 wset_hchild (p, Qnil);
4109 /* Try to merge SIBLING into its new parent. */ 4084 /* Try to merge SIBLING into its new parent. */
4110 recombine_windows (sibling); 4085 recombine_windows (sibling);
4111 } 4086 }
@@ -4153,10 +4128,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4153 if (before_sibling) 4128 if (before_sibling)
4154 { 4129 {
4155 wset_prev (s, window); 4130 wset_prev (s, window);
4156 if (horflag) 4131 wset_combination (p, horflag, window);
4157 wset_hchild (p, window);
4158 else
4159 wset_vchild (p, window);
4160 } 4132 }
4161 else 4133 else
4162 { 4134 {
@@ -4299,10 +4271,8 @@ mark_window_cursors_off (struct window *w)
4299{ 4271{
4300 while (w) 4272 while (w)
4301 { 4273 {
4302 if (!NILP (w->hchild)) 4274 if (WINDOWP (w->contents))
4303 mark_window_cursors_off (XWINDOW (w->hchild)); 4275 mark_window_cursors_off (XWINDOW (w->contents));
4304 else if (!NILP (w->vchild))
4305 mark_window_cursors_off (XWINDOW (w->vchild));
4306 else 4276 else
4307 w->phys_cursor_on_p = 0; 4277 w->phys_cursor_on_p = 0;
4308 4278
@@ -4321,8 +4291,7 @@ window_internal_height (struct window *w)
4321 if (!MINI_WINDOW_P (w)) 4291 if (!MINI_WINDOW_P (w))
4322 { 4292 {
4323 if (!NILP (w->parent) 4293 if (!NILP (w->parent)
4324 || !NILP (w->vchild) 4294 || WINDOWP (w->contents)
4325 || !NILP (w->hchild)
4326 || !NILP (w->next) 4295 || !NILP (w->next)
4327 || !NILP (w->prev) 4296 || !NILP (w->prev)
4328 || WINDOW_WANTS_MODELINE_P (w)) 4297 || WINDOW_WANTS_MODELINE_P (w))
@@ -4461,7 +4430,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4461 else 4430 else
4462 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); 4431 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV);
4463 set_marker_restricted (w->start, make_number (spos), 4432 set_marker_restricted (w->start, make_number (spos),
4464 w->buffer); 4433 w->contents);
4465 w->start_at_line_beg = 1; 4434 w->start_at_line_beg = 1;
4466 w->update_mode_line = 1; 4435 w->update_mode_line = 1;
4467 w->last_modified = 0; 4436 w->last_modified = 0;
@@ -4585,7 +4554,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4585 4554
4586 /* If control gets here, then we vscrolled. */ 4555 /* If control gets here, then we vscrolled. */
4587 4556
4588 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 4557 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
4589 4558
4590 /* Don't try to change the window start below. */ 4559 /* Don't try to change the window start below. */
4591 vscrolled = 1; 4560 vscrolled = 1;
@@ -4605,7 +4574,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4605 } 4574 }
4606 4575
4607 /* Set the window start, and set up the window for redisplay. */ 4576 /* Set the window start, and set up the window for redisplay. */
4608 set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), 4577 set_marker_restricted_both (w->start, w->contents, IT_CHARPOS (it),
4609 IT_BYTEPOS (it)); 4578 IT_BYTEPOS (it));
4610 bytepos = marker_byte_position (w->start); 4579 bytepos = marker_byte_position (w->start);
4611 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); 4580 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
@@ -4805,7 +4774,7 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
4805 int this_scroll_margin = 4774 int this_scroll_margin =
4806 max (0, min (scroll_margin, w->total_lines / 4)); 4775 max (0, min (scroll_margin, w->total_lines / 4));
4807 4776
4808 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); 4777 set_marker_restricted_both (w->start, w->contents, pos, pos_byte);
4809 w->start_at_line_beg = !NILP (bolp); 4778 w->start_at_line_beg = !NILP (bolp);
4810 w->update_mode_line = 1; 4779 w->update_mode_line = 1;
4811 w->last_modified = 0; 4780 w->last_modified = 0;
@@ -4899,10 +4868,10 @@ scroll_command (Lisp_Object n, int direction)
4899 4868
4900 /* If selected window's buffer isn't current, make it current for 4869 /* If selected window's buffer isn't current, make it current for
4901 the moment. But don't screw up if window_scroll gets an error. */ 4870 the moment. But don't screw up if window_scroll gets an error. */
4902 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 4871 if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer)
4903 { 4872 {
4904 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4873 record_unwind_protect (save_excursion_restore, save_excursion_save ());
4905 Fset_buffer (XWINDOW (selected_window)->buffer); 4874 Fset_buffer (XWINDOW (selected_window)->contents);
4906 4875
4907 /* Make redisplay consider other windows than just selected_window. */ 4876 /* Make redisplay consider other windows than just selected_window. */
4908 ++windows_or_buffers_changed; 4877 ++windows_or_buffers_changed;
@@ -5017,7 +4986,7 @@ specifies the window to scroll. This takes precedence over
5017 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4986 record_unwind_protect (save_excursion_restore, save_excursion_save ());
5018 ++windows_or_buffers_changed; 4987 ++windows_or_buffers_changed;
5019 4988
5020 Fset_buffer (w->buffer); 4989 Fset_buffer (w->contents);
5021 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm)); 4990 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm));
5022 4991
5023 if (NILP (arg)) 4992 if (NILP (arg))
@@ -5111,10 +5080,10 @@ displayed_window_lines (struct window *w)
5111 int bottom_y; 5080 int bottom_y;
5112 void *itdata = NULL; 5081 void *itdata = NULL;
5113 5082
5114 if (XBUFFER (w->buffer) != current_buffer) 5083 if (XBUFFER (w->contents) != current_buffer)
5115 { 5084 {
5116 old_buffer = current_buffer; 5085 old_buffer = current_buffer;
5117 set_buffer_internal (XBUFFER (w->buffer)); 5086 set_buffer_internal (XBUFFER (w->contents));
5118 } 5087 }
5119 else 5088 else
5120 old_buffer = NULL; 5089 old_buffer = NULL;
@@ -5176,7 +5145,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5176 (register Lisp_Object arg) 5145 (register Lisp_Object arg)
5177{ 5146{
5178 struct window *w = XWINDOW (selected_window); 5147 struct window *w = XWINDOW (selected_window);
5179 struct buffer *buf = XBUFFER (w->buffer); 5148 struct buffer *buf = XBUFFER (w->contents);
5180 struct buffer *obuf = current_buffer; 5149 struct buffer *obuf = current_buffer;
5181 int center_p = 0; 5150 int center_p = 0;
5182 ptrdiff_t charpos, bytepos; 5151 ptrdiff_t charpos, bytepos;
@@ -5342,7 +5311,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5342 } 5311 }
5343 5312
5344 /* Set the new window start. */ 5313 /* Set the new window start. */
5345 set_marker_both (w->start, w->buffer, charpos, bytepos); 5314 set_marker_both (w->start, w->contents, charpos, bytepos);
5346 w->window_end_valid = 0; 5315 w->window_end_valid = 0;
5347 5316
5348 w->optional_new_start = 1; 5317 w->optional_new_start = 1;
@@ -5386,9 +5355,8 @@ zero means top of window, negative means relative to bottom of window. */)
5386 int this_scroll_margin; 5355 int this_scroll_margin;
5387#endif 5356#endif
5388 5357
5389 if (!(BUFFERP (w->buffer) 5358 if (!(BUFFERP (w->contents) && XBUFFER (w->contents) == current_buffer))
5390 && XBUFFER (w->buffer) == current_buffer)) 5359 /* This test is needed to make sure PT/PT_BYTE make sense in w->contents
5391 /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer
5392 when passed below to set_marker_both. */ 5360 when passed below to set_marker_both. */
5393 error ("move-to-window-line called from unrelated buffer"); 5361 error ("move-to-window-line called from unrelated buffer");
5394 5362
@@ -5398,7 +5366,7 @@ zero means top of window, negative means relative to bottom of window. */)
5398 { 5366 {
5399 int height = window_internal_height (w); 5367 int height = window_internal_height (w);
5400 Fvertical_motion (make_number (- (height / 2)), window); 5368 Fvertical_motion (make_number (- (height / 2)), window);
5401 set_marker_both (w->start, w->buffer, PT, PT_BYTE); 5369 set_marker_both (w->start, w->contents, PT, PT_BYTE);
5402 w->start_at_line_beg = !NILP (Fbolp ()); 5370 w->start_at_line_beg = !NILP (Fbolp ());
5403 w->force_start = 1; 5371 w->force_start = 1;
5404 } 5372 }
@@ -5548,9 +5516,9 @@ the return value is nil. Otherwise the value is t. */)
5548 window-point of the final-selected-window to the window-point of 5516 window-point of the final-selected-window to the window-point of
5549 the current-selected-window. So we have to be careful which 5517 the current-selected-window. So we have to be careful which
5550 point of the current-buffer we copy into old_point. */ 5518 point of the current-buffer we copy into old_point. */
5551 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) 5519 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)
5552 && WINDOWP (selected_window) 5520 && WINDOWP (selected_window)
5553 && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) 5521 && EQ (XWINDOW (selected_window)->contents, new_current_buffer)
5554 && !EQ (selected_window, data->current_window)) 5522 && !EQ (selected_window, data->current_window))
5555 old_point = marker_position (XWINDOW (data->current_window)->pointm); 5523 old_point = marker_position (XWINDOW (data->current_window)->pointm);
5556 else 5524 else
@@ -5564,7 +5532,7 @@ the return value is nil. Otherwise the value is t. */)
5564 So if possible we want this arbitrary choice of "which point" to 5532 So if possible we want this arbitrary choice of "which point" to
5565 be the one from the to-be-selected-window so as to prevent this 5533 be the one from the to-be-selected-window so as to prevent this
5566 window's cursor from being copied from another window. */ 5534 window's cursor from being copied from another window. */
5567 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) 5535 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)
5568 /* If current_window = selected_window, its point is in BUF_PT. */ 5536 /* If current_window = selected_window, its point is in BUF_PT. */
5569 && !EQ (selected_window, data->current_window)) 5537 && !EQ (selected_window, data->current_window))
5570 old_point = marker_position (XWINDOW (data->current_window)->pointm); 5538 old_point = marker_position (XWINDOW (data->current_window)->pointm);
@@ -5606,8 +5574,8 @@ the return value is nil. Otherwise the value is t. */)
5606 p = SAVED_WINDOW_N (saved_windows, k); 5574 p = SAVED_WINDOW_N (saved_windows, k);
5607 window = p->window; 5575 window = p->window;
5608 w = XWINDOW (window); 5576 w = XWINDOW (window);
5609 if (!NILP (w->buffer) 5577 if (BUFFERP (w->contents)
5610 && !EQ (w->buffer, p->buffer) 5578 && !EQ (w->contents, p->buffer)
5611 && BUFFER_LIVE_P (XBUFFER (p->buffer))) 5579 && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5612 /* If a window we restore gets another buffer, record the 5580 /* If a window we restore gets another buffer, record the
5613 window's old buffer. */ 5581 window's old buffer. */
@@ -5640,13 +5608,13 @@ the return value is nil. Otherwise the value is t. */)
5640 window holds garbage.) We do this now, before 5608 window holds garbage.) We do this now, before
5641 restoring the window contents, and prevent it from 5609 restoring the window contents, and prevent it from
5642 being done later on when we select a new window. */ 5610 being done later on when we select a new window. */
5643 if (! NILP (XWINDOW (selected_window)->buffer)) 5611 if (! NILP (XWINDOW (selected_window)->contents))
5644 { 5612 {
5645 w = XWINDOW (selected_window); 5613 w = XWINDOW (selected_window);
5646 set_marker_both (w->pointm, 5614 set_marker_both (w->pointm,
5647 w->buffer, 5615 w->contents,
5648 BUF_PT (XBUFFER (w->buffer)), 5616 BUF_PT (XBUFFER (w->contents)),
5649 BUF_PT_BYTE (XBUFFER (w->buffer))); 5617 BUF_PT_BYTE (XBUFFER (w->contents)));
5650 } 5618 }
5651 5619
5652 windows_or_buffers_changed++; 5620 windows_or_buffers_changed++;
@@ -5693,18 +5661,10 @@ the return value is nil. Otherwise the value is t. */)
5693 { 5661 {
5694 wset_prev (w, Qnil); 5662 wset_prev (w, Qnil);
5695 if (!NILP (w->parent)) 5663 if (!NILP (w->parent))
5696 { 5664 wset_combination (XWINDOW (w->parent),
5697 if (XINT (p->total_cols) == XWINDOW (w->parent)->total_cols) 5665 (XINT (p->total_cols)
5698 { 5666 != XWINDOW (w->parent)->total_cols),
5699 wset_vchild (XWINDOW (w->parent), p->window); 5667 p->window);
5700 wset_hchild (XWINDOW (w->parent), Qnil);
5701 }
5702 else
5703 {
5704 wset_hchild (XWINDOW (w->parent), p->window);
5705 wset_vchild (XWINDOW (w->parent), Qnil);
5706 }
5707 }
5708 } 5668 }
5709 5669
5710 /* If we squirreled away the buffer, restore it now. */ 5670 /* If we squirreled away the buffer, restore it now. */
@@ -5753,20 +5713,16 @@ the return value is nil. Otherwise the value is t. */)
5753 w->last_modified = 0; 5713 w->last_modified = 0;
5754 w->last_overlay_modified = 0; 5714 w->last_overlay_modified = 0;
5755 5715
5756 /* Reinstall the saved buffer and pointers into it. */ 5716 if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5757 if (NILP (p->buffer))
5758 /* An internal window. */
5759 wset_buffer (w, p->buffer);
5760 else if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
5761 /* If saved buffer is alive, install it. */ 5717 /* If saved buffer is alive, install it. */
5762 { 5718 {
5763 wset_buffer (w, p->buffer); 5719 wset_buffer (w, p->buffer);
5764 w->start_at_line_beg = !NILP (p->start_at_line_beg); 5720 w->start_at_line_beg = !NILP (p->start_at_line_beg);
5765 set_marker_restricted (w->start, p->start, w->buffer); 5721 set_marker_restricted (w->start, p->start, w->contents);
5766 set_marker_restricted (w->pointm, p->pointm, 5722 set_marker_restricted (w->pointm, p->pointm,
5767 w->buffer); 5723 w->contents);
5768 Fset_marker (BVAR (XBUFFER (w->buffer), mark), 5724 Fset_marker (BVAR (XBUFFER (w->contents), mark),
5769 p->mark, w->buffer); 5725 p->mark, w->contents);
5770 5726
5771 /* As documented in Fcurrent_window_configuration, don't 5727 /* As documented in Fcurrent_window_configuration, don't
5772 restore the location of point in the buffer which was 5728 restore the location of point in the buffer which was
@@ -5775,23 +5731,21 @@ the return value is nil. Otherwise the value is t. */)
5775 && XBUFFER (p->buffer) == current_buffer) 5731 && XBUFFER (p->buffer) == current_buffer)
5776 Fgoto_char (w->pointm); 5732 Fgoto_char (w->pointm);
5777 } 5733 }
5778 else if (!NILP (w->buffer) 5734 else if (BUFFERP (w->contents) && BUFFER_LIVE_P (XBUFFER (w->contents)))
5779 && BUFFER_LIVE_P (XBUFFER (w->buffer))) 5735 /* Keep window's old buffer; make sure the markers are real. */
5780 /* Keep window's old buffer; make sure the markers are 5736 {
5781 real. */ 5737 /* Set window markers at start of visible range. */
5782 { 5738 if (XMARKER (w->start)->buffer == 0)
5783 /* Set window markers at start of visible range. */ 5739 set_marker_restricted_both (w->start, w->contents, 0, 0);
5784 if (XMARKER (w->start)->buffer == 0) 5740 if (XMARKER (w->pointm)->buffer == 0)
5785 set_marker_restricted_both (w->start, w->buffer, 0, 0); 5741 set_marker_restricted_both
5786 if (XMARKER (w->pointm)->buffer == 0) 5742 (w->pointm, w->contents,
5787 set_marker_restricted_both 5743 BUF_PT (XBUFFER (w->contents)),
5788 (w->pointm, w->buffer, 5744 BUF_PT_BYTE (XBUFFER (w->contents)));
5789 BUF_PT (XBUFFER (w->buffer)), 5745 w->start_at_line_beg = 1;
5790 BUF_PT_BYTE (XBUFFER (w->buffer))); 5746 }
5791 w->start_at_line_beg = 1; 5747 else if (!NILP (w->start))
5792 } 5748 /* Leaf window has no live buffer, get one. */
5793 else
5794 /* Window has no live buffer, get one. */
5795 { 5749 {
5796 /* Get the buffer via other_buffer_safely in order to 5750 /* Get the buffer via other_buffer_safely in order to
5797 avoid showing an unimportant buffer and, if necessary, to 5751 avoid showing an unimportant buffer and, if necessary, to
@@ -5800,8 +5754,8 @@ the return value is nil. Otherwise the value is t. */)
5800 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); 5754 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ()));
5801 /* This will set the markers to beginning of visible 5755 /* This will set the markers to beginning of visible
5802 range. */ 5756 range. */
5803 set_marker_restricted_both (w->start, w->buffer, 0, 0); 5757 set_marker_restricted_both (w->start, w->contents, 0, 0);
5804 set_marker_restricted_both (w->pointm, w->buffer, 0, 0); 5758 set_marker_restricted_both (w->pointm, w->contents, 0, 0);
5805 w->start_at_line_beg = 1; 5759 w->start_at_line_beg = 1;
5806 if (!NILP (w->dedicated)) 5760 if (!NILP (w->dedicated))
5807 /* Record this window as dead. */ 5761 /* Record this window as dead. */
@@ -5814,17 +5768,17 @@ the return value is nil. Otherwise the value is t. */)
5814 fset_root_window (f, data->root_window); 5768 fset_root_window (f, data->root_window);
5815 /* Arrange *not* to restore point in the buffer that was 5769 /* Arrange *not* to restore point in the buffer that was
5816 current when the window configuration was saved. */ 5770 current when the window configuration was saved. */
5817 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5771 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer))
5818 set_marker_restricted (XWINDOW (data->current_window)->pointm, 5772 set_marker_restricted (XWINDOW (data->current_window)->pointm,
5819 make_number (old_point), 5773 make_number (old_point),
5820 XWINDOW (data->current_window)->buffer); 5774 XWINDOW (data->current_window)->contents);
5821 5775
5822 /* In the following call to `select-window', prevent "swapping out 5776 /* In the following call to `select-window', prevent "swapping out
5823 point" in the old selected window using the buffer that has 5777 point" in the old selected window using the buffer that has
5824 been restored into it. We already swapped out that point from 5778 been restored into it. We already swapped out that point from
5825 that window's old buffer. */ 5779 that window's old buffer. */
5826 select_window (data->current_window, Qnil, 1); 5780 select_window (data->current_window, Qnil, 1);
5827 BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window) 5781 BVAR (XBUFFER (XWINDOW (selected_window)->contents), last_selected_window)
5828 = selected_window; 5782 = selected_window;
5829 5783
5830 if (NILP (data->focus_frame) 5784 if (NILP (data->focus_frame)
@@ -5851,14 +5805,9 @@ the return value is nil. Otherwise the value is t. */)
5851 /* Now, free glyph matrices in windows that were not reused. */ 5805 /* Now, free glyph matrices in windows that were not reused. */
5852 for (i = n = 0; i < n_leaf_windows; ++i) 5806 for (i = n = 0; i < n_leaf_windows; ++i)
5853 { 5807 {
5854 if (NILP (leaf_windows[i]->buffer)) 5808 if (NILP (leaf_windows[i]->contents))
5855 { 5809 free_window_matrices (leaf_windows[i]);
5856 /* Assert it's not reused as a combination. */ 5810 else if (EQ (leaf_windows[i]->contents, new_current_buffer))
5857 eassert (NILP (leaf_windows[i]->hchild)
5858 && NILP (leaf_windows[i]->vchild));
5859 free_window_matrices (leaf_windows[i]);
5860 }
5861 else if (EQ (leaf_windows[i]->buffer, new_current_buffer))
5862 ++n; 5811 ++n;
5863 } 5812 }
5864 5813
@@ -5889,7 +5838,7 @@ the return value is nil. Otherwise the value is t. */)
5889 Fset_buffer (new_current_buffer); 5838 Fset_buffer (new_current_buffer);
5890 /* If the new current buffer doesn't appear in the selected 5839 /* If the new current buffer doesn't appear in the selected
5891 window, go to its old point (see bug#12208). */ 5840 window, go to its old point (see bug#12208). */
5892 if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5841 if (!EQ (XWINDOW (data->current_window)->contents, new_current_buffer))
5893 Fgoto_char (make_number (old_point)); 5842 Fgoto_char (make_number (old_point));
5894 } 5843 }
5895 5844
@@ -5900,8 +5849,10 @@ the return value is nil. Otherwise the value is t. */)
5900} 5849}
5901 5850
5902 5851
5903/* Recursively delete all child windows reachable via the next, vchild, 5852/* If WINDOW is an internal window, recursively delete all child windows
5904 and hchild slots of WINDOW. */ 5853 reachable via the next and contents slots of WINDOW. Otherwise setup
5854 WINDOW to not show any buffer. */
5855
5905void 5856void
5906delete_all_child_windows (Lisp_Object window) 5857delete_all_child_windows (Lisp_Object window)
5907{ 5858{
@@ -5913,17 +5864,12 @@ delete_all_child_windows (Lisp_Object window)
5913 /* Delete WINDOW's siblings (we traverse postorderly). */ 5864 /* Delete WINDOW's siblings (we traverse postorderly). */
5914 delete_all_child_windows (w->next); 5865 delete_all_child_windows (w->next);
5915 5866
5916 if (!NILP (w->vchild)) 5867 if (WINDOWP (w->contents))
5917 {
5918 delete_all_child_windows (w->vchild);
5919 wset_vchild (w, Qnil);
5920 }
5921 else if (!NILP (w->hchild))
5922 { 5868 {
5923 delete_all_child_windows (w->hchild); 5869 delete_all_child_windows (w->contents);
5924 wset_hchild (w, Qnil); 5870 wset_combination (w, 0, Qnil);
5925 } 5871 }
5926 else if (!NILP (w->buffer)) 5872 else if (BUFFERP (w->contents))
5927 { 5873 {
5928 unshow_buffer (w); 5874 unshow_buffer (w);
5929 unchain_marker (XMARKER (w->pointm)); 5875 unchain_marker (XMARKER (w->pointm));
@@ -5931,7 +5877,7 @@ delete_all_child_windows (Lisp_Object window)
5931 /* Since combination limit makes sense for an internal windows 5877 /* Since combination limit makes sense for an internal windows
5932 only, we use this slot to save the buffer for the sake of 5878 only, we use this slot to save the buffer for the sake of
5933 possible resurrection in Fset_window_configuration. */ 5879 possible resurrection in Fset_window_configuration. */
5934 wset_combination_limit (w, w->buffer); 5880 wset_combination_limit (w, w->contents);
5935 wset_buffer (w, Qnil); 5881 wset_buffer (w, Qnil);
5936 } 5882 }
5937 5883
@@ -5944,10 +5890,8 @@ count_windows (register struct window *window)
5944 register int count = 1; 5890 register int count = 1;
5945 if (!NILP (window->next)) 5891 if (!NILP (window->next))
5946 count += count_windows (XWINDOW (window->next)); 5892 count += count_windows (XWINDOW (window->next));
5947 if (!NILP (window->vchild)) 5893 if (WINDOWP (window->contents))
5948 count += count_windows (XWINDOW (window->vchild)); 5894 count += count_windows (XWINDOW (window->contents));
5949 if (!NILP (window->hchild))
5950 count += count_windows (XWINDOW (window->hchild));
5951 return count; 5895 return count;
5952} 5896}
5953 5897
@@ -5959,10 +5903,8 @@ get_leaf_windows (struct window *w, struct window **flat, int i)
5959{ 5903{
5960 while (w) 5904 while (w)
5961 { 5905 {
5962 if (!NILP (w->hchild)) 5906 if (WINDOWP (w->contents))
5963 i = get_leaf_windows (XWINDOW (w->hchild), flat, i); 5907 i = get_leaf_windows (XWINDOW (w->contents), flat, i);
5964 else if (!NILP (w->vchild))
5965 i = get_leaf_windows (XWINDOW (w->vchild), flat, i);
5966 else 5908 else
5967 flat[i++] = w; 5909 flat[i++] = w;
5968 5910
@@ -6002,8 +5944,7 @@ get_phys_cursor_glyph (struct window *w)
6002 hpos = row->used[TEXT_AREA] - 1; 5944 hpos = row->used[TEXT_AREA] - 1;
6003 } 5945 }
6004 5946
6005 if (row->used[TEXT_AREA] > hpos 5947 if (0 <= hpos && hpos < row->used[TEXT_AREA])
6006 && 0 <= hpos)
6007 glyph = row->glyphs[TEXT_AREA] + hpos; 5948 glyph = row->glyphs[TEXT_AREA] + hpos;
6008 else 5949 else
6009 glyph = NULL; 5950 glyph = NULL;
@@ -6019,14 +5960,14 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6019 register struct window *w; 5960 register struct window *w;
6020 register Lisp_Object tem, pers, par; 5961 register Lisp_Object tem, pers, par;
6021 5962
6022 for (;!NILP (window); window = w->next) 5963 for (; !NILP (window); window = w->next)
6023 { 5964 {
6024 p = SAVED_WINDOW_N (vector, i); 5965 p = SAVED_WINDOW_N (vector, i);
6025 w = XWINDOW (window); 5966 w = XWINDOW (window);
6026 5967
6027 wset_temslot (w, make_number (i)); i++; 5968 wset_temslot (w, make_number (i)); i++;
6028 p->window = window; 5969 p->window = window;
6029 p->buffer = w->buffer; 5970 p->buffer = (WINDOW_LEAF_P (w) ? w->contents : Qnil);
6030 p->left_col = make_number (w->left_col); 5971 p->left_col = make_number (w->left_col);
6031 p->top_line = make_number (w->top_line); 5972 p->top_line = make_number (w->top_line);
6032 p->total_cols = make_number (w->total_cols); 5973 p->total_cols = make_number (w->total_cols);
@@ -6093,15 +6034,15 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6093 } 6034 }
6094 } 6035 }
6095 6036
6096 if (!NILP (w->buffer)) 6037 if (BUFFERP (w->contents))
6097 { 6038 {
6098 /* Save w's value of point in the window configuration. If w 6039 /* Save w's value of point in the window configuration. If w
6099 is the selected window, then get the value of point from 6040 is the selected window, then get the value of point from
6100 the buffer; pointm is garbage in the selected window. */ 6041 the buffer; pointm is garbage in the selected window. */
6101 if (EQ (window, selected_window)) 6042 if (EQ (window, selected_window))
6102 p->pointm = build_marker (XBUFFER (w->buffer), 6043 p->pointm = build_marker (XBUFFER (w->contents),
6103 BUF_PT (XBUFFER (w->buffer)), 6044 BUF_PT (XBUFFER (w->contents)),
6104 BUF_PT_BYTE (XBUFFER (w->buffer))); 6045 BUF_PT_BYTE (XBUFFER (w->contents)));
6105 else 6046 else
6106 p->pointm = Fcopy_marker (w->pointm, Qnil); 6047 p->pointm = Fcopy_marker (w->pointm, Qnil);
6107 XMARKER (p->pointm)->insertion_type 6048 XMARKER (p->pointm)->insertion_type
@@ -6110,7 +6051,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6110 p->start = Fcopy_marker (w->start, Qnil); 6051 p->start = Fcopy_marker (w->start, Qnil);
6111 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; 6052 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
6112 6053
6113 tem = BVAR (XBUFFER (w->buffer), mark); 6054 tem = BVAR (XBUFFER (w->contents), mark);
6114 p->mark = Fcopy_marker (tem, Qnil); 6055 p->mark = Fcopy_marker (tem, Qnil);
6115 } 6056 }
6116 else 6057 else
@@ -6131,10 +6072,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6131 else 6072 else
6132 p->prev = XWINDOW (w->prev)->temslot; 6073 p->prev = XWINDOW (w->prev)->temslot;
6133 6074
6134 if (!NILP (w->vchild)) 6075 if (WINDOWP (w->contents))
6135 i = save_window_save (w->vchild, vector, i); 6076 i = save_window_save (w->contents, vector, i);
6136 if (!NILP (w->hchild))
6137 i = save_window_save (w->hchild, vector, i);
6138 } 6077 }
6139 6078
6140 return i; 6079 return i;
@@ -6451,7 +6390,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
6451 adjust_glyphs (f); 6390 adjust_glyphs (f);
6452 6391
6453 /* Prevent redisplay shortcuts. */ 6392 /* Prevent redisplay shortcuts. */
6454 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 6393 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
6455 } 6394 }
6456 } 6395 }
6457 6396
@@ -6485,10 +6424,8 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u
6485 6424
6486 for (cont = 1; w && cont;) 6425 for (cont = 1; w && cont;)
6487 { 6426 {
6488 if (!NILP (w->hchild)) 6427 if (WINDOWP (w->contents))
6489 cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data); 6428 cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data);
6490 else if (!NILP (w->vchild))
6491 cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data);
6492 else 6429 else
6493 cont = fn (w, user_data); 6430 cont = fn (w, user_data);
6494 6431
diff --git a/src/window.h b/src/window.h
index 4f6374b9d3e..411756f045e 100644
--- a/src/window.h
+++ b/src/window.h
@@ -41,14 +41,13 @@ They are deleted only by calling delete-window on them (but
41this can be done implicitly). Combination windows can be created 41this can be done implicitly). Combination windows can be created
42and deleted at any time. 42and deleted at any time.
43 43
44A leaf window has a non-nil buffer field, and also 44A leaf window has a buffer stored in contents field and markers in its start
45 has markers in its start and pointm fields. Non-leaf windows 45and pointm fields. Non-leaf windows have nil in the latter two fields.
46 have nil in these fields.
47 46
48Non-leaf windows are either vertical or horizontal combinations. 47Non-leaf windows are either vertical or horizontal combinations.
49 48
50A vertical combination window has children that are arranged on the frame 49A vertical combination window has children that are arranged on the frame
51one above the next. Its vchild field points to the uppermost child. 50one above the next. Its contents field points to the uppermost child.
52The parent field of each of the children points to the vertical 51The parent field of each of the children points to the vertical
53combination window. The next field of each child points to the 52combination window. The next field of each child points to the
54child below it, or is nil for the lowest child. The prev field 53child below it, or is nil for the lowest child. The prev field
@@ -56,7 +55,7 @@ of each child points to the child above it, or is nil for the
56highest child. 55highest child.
57 56
58A horizontal combination window has children that are side by side. 57A horizontal combination window has children that are side by side.
59Its hchild field points to the leftmost child. In each child 58Its contents field points to the leftmost child. In each child
60the next field points to the child to the right and the prev field 59the next field points to the child to the right and the prev field
61points to the child to the left. 60points to the child to the left.
62 61
@@ -78,7 +77,7 @@ the root window is the minibuf window. On minibufferless screens or
78minibuffer-only screens, the root window and the minibuffer window are 77minibuffer-only screens, the root window and the minibuffer window are
79one and the same, so its prev and next members are nil. 78one and the same, so its prev and next members are nil.
80 79
81A dead window has its buffer, hchild, and vchild windows all nil. */ 80A dead window has its contents field set to nil. */
82 81
83struct cursor_pos 82struct cursor_pos
84{ 83{
@@ -102,13 +101,6 @@ struct window
102 Lisp_Object next; 101 Lisp_Object next;
103 Lisp_Object prev; 102 Lisp_Object prev;
104 103
105 /* First child of this window: vchild is used if this is a vertical
106 combination, hchild if this is a horizontal combination. Of the
107 fields vchild, hchild and buffer, one and only one is non-nil
108 unless the window is dead. */
109 Lisp_Object hchild;
110 Lisp_Object vchild;
111
112 /* The window this one is a child of. */ 104 /* The window this one is a child of. */
113 Lisp_Object parent; 105 Lisp_Object parent;
114 106
@@ -123,10 +115,8 @@ struct window
123 Lisp_Object new_total; 115 Lisp_Object new_total;
124 Lisp_Object new_normal; 116 Lisp_Object new_normal;
125 117
126 /* The buffer displayed in this window. Of the fields vchild, 118 /* May be buffer, window, or nil. */
127 hchild and buffer, one and only one is non-nil unless the window 119 Lisp_Object contents;
128 is dead. */
129 Lisp_Object buffer;
130 120
131 /* A marker pointing to where in the text to start displaying. 121 /* A marker pointing to where in the text to start displaying.
132 BIDI Note: This is the _logical-order_ start, i.e. the smallest 122 BIDI Note: This is the _logical-order_ start, i.e. the smallest
@@ -282,6 +272,10 @@ struct window
282 /* Non-zero if this window is a minibuffer window. */ 272 /* Non-zero if this window is a minibuffer window. */
283 unsigned mini : 1; 273 unsigned mini : 1;
284 274
275 /* Meaningful only if contents is a window, non-zero if this
276 internal window is used in horizontal combination. */
277 unsigned horizontal : 1;
278
285 /* Non-zero means must regenerate mode line of this window. */ 279 /* Non-zero means must regenerate mode line of this window. */
286 unsigned update_mode_line : 1; 280 unsigned update_mode_line : 1;
287 281
@@ -428,6 +422,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
428 422
429/* A handy macro. */ 423/* A handy macro. */
430 424
425/* Non-zero if W is leaf (carry the buffer). */
426
427#define WINDOW_LEAF_P(W) \
428 (BUFFERP ((W)->contents))
429
430/* Non-zero if W is a member of horizontal combination. */
431
432#define WINDOW_HORIZONTAL_COMBINATION_P(W) \
433 (WINDOWP ((W)->contents) && (W)->horizontal)
434
435/* Non-zero if W is a member of vertical combination. */
436
437#define WINDOW_VERTICAL_COMBINATION_P(W) \
438 (WINDOWP ((W)->contents) && !(W)->horizontal)
439
431#define WINDOW_XFRAME(W) \ 440#define WINDOW_XFRAME(W) \
432 (XFRAME (WINDOW_FRAME ((W)))) 441 (XFRAME (WINDOW_FRAME ((W))))
433 442
@@ -512,9 +521,14 @@ wset_next_buffers (struct window *w, Lisp_Object val)
512 521
513/* 1 if W is a menu bar window. */ 522/* 1 if W is a menu bar window. */
514 523
524#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
515#define WINDOW_MENU_BAR_P(W) \ 525#define WINDOW_MENU_BAR_P(W) \
516 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \ 526 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
517 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window)) 527 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
528#else
529/* No menu bar windows if X toolkit is in use. */
530#define WINDOW_MENU_BAR_P(W) (0)
531#endif
518 532
519/* 1 if W is a tool bar window. */ 533/* 1 if W is a tool bar window. */
520 534
@@ -926,20 +940,17 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols);
926struct glyph *get_phys_cursor_glyph (struct window *w); 940struct glyph *get_phys_cursor_glyph (struct window *w);
927 941
928/* Value is non-zero if WINDOW is a valid window. */ 942/* Value is non-zero if WINDOW is a valid window. */
929#define WINDOW_VALID_P(WINDOW) \ 943#define WINDOW_VALID_P(WINDOW) \
930 (WINDOWP (WINDOW) \ 944 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \
931 && (!NILP (XWINDOW (WINDOW)->buffer) \ 945
932 || !NILP (XWINDOW (WINDOW)->vchild) \ 946/* A window of any sort, leaf or interior, is "valid" if its
933 || !NILP (XWINDOW (WINDOW)->hchild))) 947 contents slot is non-nil. */
934
935/* A window of any sort, leaf or interior, is "valid" if one
936 of its buffer, vchild, or hchild members is non-nil. */
937#define CHECK_VALID_WINDOW(WINDOW) \ 948#define CHECK_VALID_WINDOW(WINDOW) \
938 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) 949 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
939 950
940/* Value is non-zero if WINDOW is a live window. */ 951/* Value is non-zero if WINDOW is a live window. */
941#define WINDOW_LIVE_P(WINDOW) \ 952#define WINDOW_LIVE_P(WINDOW) \
942 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) 953 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
943 954
944/* A window is "live" if and only if it shows a buffer. */ 955/* A window is "live" if and only if it shows a buffer. */
945#define CHECK_LIVE_WINDOW(WINDOW) \ 956#define CHECK_LIVE_WINDOW(WINDOW) \
diff --git a/src/xdisp.c b/src/xdisp.c
index 2a565b5cffd..41214880a56 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -580,7 +580,7 @@ static struct glyph scratch_glyphs[MAX_SCRATCH_GLYPHS];
580 580
581/* Ascent and height of the last line processed by move_it_to. */ 581/* Ascent and height of the last line processed by move_it_to. */
582 582
583static int last_max_ascent, last_height; 583static int last_height;
584 584
585/* Non-zero if there's a help-echo in the echo area. */ 585/* Non-zero if there's a help-echo in the echo area. */
586 586
@@ -1283,10 +1283,10 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1283 if (FRAME_INITIAL_P (XFRAME (WINDOW_FRAME (w)))) 1283 if (FRAME_INITIAL_P (XFRAME (WINDOW_FRAME (w))))
1284 return visible_p; 1284 return visible_p;
1285 1285
1286 if (XBUFFER (w->buffer) != current_buffer) 1286 if (XBUFFER (w->contents) != current_buffer)
1287 { 1287 {
1288 old_buffer = current_buffer; 1288 old_buffer = current_buffer;
1289 set_buffer_internal_1 (XBUFFER (w->buffer)); 1289 set_buffer_internal_1 (XBUFFER (w->contents));
1290 } 1290 }
1291 1291
1292 SET_TEXT_POS_FROM_MARKER (top, w->start); 1292 SET_TEXT_POS_FROM_MARKER (top, w->start);
@@ -2677,7 +2677,7 @@ init_iterator (struct it *it, struct window *w,
2677 and IT->region_end_charpos to the start and end of a visible region 2677 and IT->region_end_charpos to the start and end of a visible region
2678 in window IT->w. Set both to -1 to indicate no region. */ 2678 in window IT->w. Set both to -1 to indicate no region. */
2679 markpos = markpos_of_region (); 2679 markpos = markpos_of_region ();
2680 if (0 <= markpos 2680 if (markpos >= 0
2681 /* Maybe highlight only in selected window. */ 2681 /* Maybe highlight only in selected window. */
2682 && (/* Either show region everywhere. */ 2682 && (/* Either show region everywhere. */
2683 highlight_nonselected_windows 2683 highlight_nonselected_windows
@@ -4458,7 +4458,7 @@ handle_display_prop (struct it *it)
4458 if it was a text property. */ 4458 if it was a text property. */
4459 4459
4460 if (!STRINGP (it->string)) 4460 if (!STRINGP (it->string))
4461 object = it->w->buffer; 4461 object = it->w->contents;
4462 4462
4463 display_replaced_p = handle_display_spec (it, propval, object, overlay, 4463 display_replaced_p = handle_display_spec (it, propval, object, overlay,
4464 position, bufpos, 4464 position, bufpos,
@@ -4866,7 +4866,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4866 it->what = IT_IMAGE; 4866 it->what = IT_IMAGE;
4867 it->image_id = -1; /* no image */ 4867 it->image_id = -1; /* no image */
4868 it->position = start_pos; 4868 it->position = start_pos;
4869 it->object = NILP (object) ? it->w->buffer : object; 4869 it->object = NILP (object) ? it->w->contents : object;
4870 it->method = GET_FROM_IMAGE; 4870 it->method = GET_FROM_IMAGE;
4871 it->from_overlay = Qnil; 4871 it->from_overlay = Qnil;
4872 it->face_id = face_id; 4872 it->face_id = face_id;
@@ -5012,7 +5012,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5012 it->what = IT_IMAGE; 5012 it->what = IT_IMAGE;
5013 it->image_id = lookup_image (it->f, value); 5013 it->image_id = lookup_image (it->f, value);
5014 it->position = start_pos; 5014 it->position = start_pos;
5015 it->object = NILP (object) ? it->w->buffer : object; 5015 it->object = NILP (object) ? it->w->contents : object;
5016 it->method = GET_FROM_IMAGE; 5016 it->method = GET_FROM_IMAGE;
5017 5017
5018 /* Say that we haven't consumed the characters with 5018 /* Say that we haven't consumed the characters with
@@ -5836,7 +5836,7 @@ pop_it (struct it *it)
5836 it->object = p->u.stretch.object; 5836 it->object = p->u.stretch.object;
5837 break; 5837 break;
5838 case GET_FROM_BUFFER: 5838 case GET_FROM_BUFFER:
5839 it->object = it->w->buffer; 5839 it->object = it->w->contents;
5840 break; 5840 break;
5841 case GET_FROM_STRING: 5841 case GET_FROM_STRING:
5842 it->object = it->string; 5842 it->object = it->string;
@@ -5849,7 +5849,7 @@ pop_it (struct it *it)
5849 else 5849 else
5850 { 5850 {
5851 it->method = GET_FROM_BUFFER; 5851 it->method = GET_FROM_BUFFER;
5852 it->object = it->w->buffer; 5852 it->object = it->w->contents;
5853 } 5853 }
5854 } 5854 }
5855 it->end_charpos = p->end_charpos; 5855 it->end_charpos = p->end_charpos;
@@ -6290,7 +6290,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
6290 IT_STRING_BYTEPOS (*it) = -1; 6290 IT_STRING_BYTEPOS (*it) = -1;
6291 it->string = Qnil; 6291 it->string = Qnil;
6292 it->method = GET_FROM_BUFFER; 6292 it->method = GET_FROM_BUFFER;
6293 it->object = it->w->buffer; 6293 it->object = it->w->contents;
6294 it->area = TEXT_AREA; 6294 it->area = TEXT_AREA;
6295 it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 6295 it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters));
6296 it->sp = 0; 6296 it->sp = 0;
@@ -7141,7 +7141,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
7141 else 7141 else
7142 { 7142 {
7143 it->method = GET_FROM_BUFFER; 7143 it->method = GET_FROM_BUFFER;
7144 it->object = it->w->buffer; 7144 it->object = it->w->contents;
7145 } 7145 }
7146 7146
7147 it->dpvec = NULL; 7147 it->dpvec = NULL;
@@ -7714,7 +7714,7 @@ next_element_from_ellipsis (struct it *it)
7714 setting face_before_selective_p. */ 7714 setting face_before_selective_p. */
7715 it->saved_face_id = it->face_id; 7715 it->saved_face_id = it->face_id;
7716 it->method = GET_FROM_BUFFER; 7716 it->method = GET_FROM_BUFFER;
7717 it->object = it->w->buffer; 7717 it->object = it->w->contents;
7718 reseat_at_next_visible_line_start (it, 1); 7718 reseat_at_next_visible_line_start (it, 1);
7719 it->face_before_selective_p = 1; 7719 it->face_before_selective_p = 1;
7720 } 7720 }
@@ -7978,7 +7978,7 @@ next_element_from_buffer (struct it *it)
7978 7978
7979 /* Record what we have and where it came from. */ 7979 /* Record what we have and where it came from. */
7980 it->what = IT_CHARACTER; 7980 it->what = IT_CHARACTER;
7981 it->object = it->w->buffer; 7981 it->object = it->w->contents;
7982 it->position = it->current.pos; 7982 it->position = it->current.pos;
7983 7983
7984 /* Normally we return the character found above, except when we 7984 /* Normally we return the character found above, except when we
@@ -8084,7 +8084,7 @@ next_element_from_composition (struct it *it)
8084 return 0; 8084 return 0;
8085 } 8085 }
8086 it->position = it->current.pos; 8086 it->position = it->current.pos;
8087 it->object = it->w->buffer; 8087 it->object = it->w->contents;
8088 it->c = composition_update_it (&it->cmp_it, IT_CHARPOS (*it), 8088 it->c = composition_update_it (&it->cmp_it, IT_CHARPOS (*it),
8089 IT_BYTEPOS (*it), Qnil); 8089 IT_BYTEPOS (*it), Qnil);
8090 } 8090 }
@@ -8925,7 +8925,6 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
8925 it->current_y += it->max_ascent + it->max_descent; 8925 it->current_y += it->max_ascent + it->max_descent;
8926 ++it->vpos; 8926 ++it->vpos;
8927 last_height = it->max_ascent + it->max_descent; 8927 last_height = it->max_ascent + it->max_descent;
8928 last_max_ascent = it->max_ascent;
8929 it->max_ascent = it->max_descent = 0; 8928 it->max_ascent = it->max_descent = 0;
8930 } 8929 }
8931 8930
@@ -8952,7 +8951,6 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
8952 it->current_y += it->max_ascent + it->max_descent; 8951 it->current_y += it->max_ascent + it->max_descent;
8953 ++it->vpos; 8952 ++it->vpos;
8954 last_height = it->max_ascent + it->max_descent; 8953 last_height = it->max_ascent + it->max_descent;
8955 last_max_ascent = it->max_ascent;
8956 } 8954 }
8957 8955
8958 if (backup_data) 8956 if (backup_data)
@@ -9994,7 +9992,7 @@ with_echo_area_buffer_unwind_data (struct window *w)
9994 Vwith_echo_area_save_vector = Qnil; 9992 Vwith_echo_area_save_vector = Qnil;
9995 9993
9996 if (NILP (vector)) 9994 if (NILP (vector))
9997 vector = Fmake_vector (make_number (7), Qnil); 9995 vector = Fmake_vector (make_number (9), Qnil);
9998 9996
9999 XSETBUFFER (tmp, current_buffer); ASET (vector, i, tmp); ++i; 9997 XSETBUFFER (tmp, current_buffer); ASET (vector, i, tmp); ++i;
10000 ASET (vector, i, Vdeactivate_mark); ++i; 9998 ASET (vector, i, Vdeactivate_mark); ++i;
@@ -10003,13 +10001,15 @@ with_echo_area_buffer_unwind_data (struct window *w)
10003 if (w) 10001 if (w)
10004 { 10002 {
10005 XSETWINDOW (tmp, w); ASET (vector, i, tmp); ++i; 10003 XSETWINDOW (tmp, w); ASET (vector, i, tmp); ++i;
10006 ASET (vector, i, w->buffer); ++i; 10004 ASET (vector, i, w->contents); ++i;
10007 ASET (vector, i, make_number (marker_position (w->pointm))); ++i; 10005 ASET (vector, i, make_number (marker_position (w->pointm))); ++i;
10008 ASET (vector, i, make_number (marker_byte_position (w->pointm))); ++i; 10006 ASET (vector, i, make_number (marker_byte_position (w->pointm))); ++i;
10007 ASET (vector, i, make_number (marker_position (w->start))); ++i;
10008 ASET (vector, i, make_number (marker_byte_position (w->start))); ++i;
10009 } 10009 }
10010 else 10010 else
10011 { 10011 {
10012 int end = i + 4; 10012 int end = i + 6;
10013 for (; i < end; ++i) 10013 for (; i < end; ++i)
10014 ASET (vector, i, Qnil); 10014 ASET (vector, i, Qnil);
10015 } 10015 }
@@ -10032,16 +10032,18 @@ unwind_with_echo_area_buffer (Lisp_Object vector)
10032 if (WINDOWP (AREF (vector, 3))) 10032 if (WINDOWP (AREF (vector, 3)))
10033 { 10033 {
10034 struct window *w; 10034 struct window *w;
10035 Lisp_Object buffer, charpos, bytepos; 10035 Lisp_Object buffer;
10036 10036
10037 w = XWINDOW (AREF (vector, 3)); 10037 w = XWINDOW (AREF (vector, 3));
10038 buffer = AREF (vector, 4); 10038 buffer = AREF (vector, 4);
10039 charpos = AREF (vector, 5);
10040 bytepos = AREF (vector, 6);
10041 10039
10042 wset_buffer (w, buffer); 10040 wset_buffer (w, buffer);
10043 set_marker_both (w->pointm, buffer, 10041 set_marker_both (w->pointm, buffer,
10044 XFASTINT (charpos), XFASTINT (bytepos)); 10042 XFASTINT (AREF (vector, 5)),
10043 XFASTINT (AREF (vector, 6)));
10044 set_marker_both (w->start, buffer,
10045 XFASTINT (AREF (vector, 7)),
10046 XFASTINT (AREF (vector, 8)));
10045 } 10047 }
10046 10048
10047 Vwith_echo_area_save_vector = vector; 10049 Vwith_echo_area_save_vector = vector;
@@ -10255,9 +10257,9 @@ resize_mini_window (struct window *w, int exact_p)
10255 eassert (MINI_WINDOW_P (w)); 10257 eassert (MINI_WINDOW_P (w));
10256 10258
10257 /* By default, start display at the beginning. */ 10259 /* By default, start display at the beginning. */
10258 set_marker_both (w->start, w->buffer, 10260 set_marker_both (w->start, w->contents,
10259 BUF_BEGV (XBUFFER (w->buffer)), 10261 BUF_BEGV (XBUFFER (w->contents)),
10260 BUF_BEGV_BYTE (XBUFFER (w->buffer))); 10262 BUF_BEGV_BYTE (XBUFFER (w->contents)));
10261 10263
10262 /* Don't resize windows while redisplaying a window; it would 10264 /* Don't resize windows while redisplaying a window; it would
10263 confuse redisplay functions when the size of the window they are 10265 confuse redisplay functions when the size of the window they are
@@ -10284,10 +10286,10 @@ resize_mini_window (struct window *w, int exact_p)
10284 struct text_pos start; 10286 struct text_pos start;
10285 struct buffer *old_current_buffer = NULL; 10287 struct buffer *old_current_buffer = NULL;
10286 10288
10287 if (current_buffer != XBUFFER (w->buffer)) 10289 if (current_buffer != XBUFFER (w->contents))
10288 { 10290 {
10289 old_current_buffer = current_buffer; 10291 old_current_buffer = current_buffer;
10290 set_buffer_internal (XBUFFER (w->buffer)); 10292 set_buffer_internal (XBUFFER (w->contents));
10291 } 10293 }
10292 10294
10293 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); 10295 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID);
@@ -10736,7 +10738,7 @@ buffer_shared_and_changed (void)
10736 10738
10737/* Nonzero if W doesn't reflect the actual state of current buffer due 10739/* Nonzero if W doesn't reflect the actual state of current buffer due
10738 to its text or overlays change. FIXME: this may be called when 10740 to its text or overlays change. FIXME: this may be called when
10739 XBUFFER (w->buffer) != current_buffer, which looks suspicious. */ 10741 XBUFFER (w->contents) != current_buffer, which looks suspicious. */
10740 10742
10741static int 10743static int
10742window_outdated (struct window *w) 10744window_outdated (struct window *w)
@@ -10751,7 +10753,7 @@ window_outdated (struct window *w)
10751static int 10753static int
10752window_buffer_changed (struct window *w) 10754window_buffer_changed (struct window *w)
10753{ 10755{
10754 struct buffer *b = XBUFFER (w->buffer); 10756 struct buffer *b = XBUFFER (w->contents);
10755 10757
10756 eassert (BUFFER_LIVE_P (b)); 10758 eassert (BUFFER_LIVE_P (b));
10757 10759
@@ -11005,7 +11007,7 @@ x_consider_frame_title (Lisp_Object frame)
11005 11007
11006 Fselect_window (f->selected_window, Qt); 11008 Fselect_window (f->selected_window, Qt);
11007 set_buffer_internal_1 11009 set_buffer_internal_1
11008 (XBUFFER (XWINDOW (f->selected_window)->buffer)); 11010 (XBUFFER (XWINDOW (f->selected_window)->contents));
11009 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; 11011 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format;
11010 11012
11011 mode_line_target = MODE_LINE_TITLE; 11013 mode_line_target = MODE_LINE_TITLE;
@@ -11124,7 +11126,7 @@ prepare_menu_bars (void)
11124 if (windows_or_buffers_changed 11126 if (windows_or_buffers_changed
11125 && FRAME_NS_P (f)) 11127 && FRAME_NS_P (f))
11126 ns_set_doc_edited 11128 ns_set_doc_edited
11127 (f, Fbuffer_modified_p (XWINDOW (f->selected_window)->buffer)); 11129 (f, Fbuffer_modified_p (XWINDOW (f->selected_window)->contents));
11128#endif 11130#endif
11129 UNGCPRO; 11131 UNGCPRO;
11130 } 11132 }
@@ -11196,7 +11198,7 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
11196 11198
11197 specbind (Qinhibit_menubar_update, Qt); 11199 specbind (Qinhibit_menubar_update, Qt);
11198 11200
11199 set_buffer_internal_1 (XBUFFER (w->buffer)); 11201 set_buffer_internal_1 (XBUFFER (w->contents));
11200 if (save_match_data) 11202 if (save_match_data)
11201 record_unwind_save_match_data (); 11203 record_unwind_save_match_data ();
11202 if (NILP (Voverriding_local_map_menu_flag)) 11204 if (NILP (Voverriding_local_map_menu_flag))
@@ -11400,7 +11402,7 @@ update_tool_bar (struct frame *f, int save_match_data)
11400 /* Set current_buffer to the buffer of the selected 11402 /* Set current_buffer to the buffer of the selected
11401 window of the frame, so that we get the right local 11403 window of the frame, so that we get the right local
11402 keymaps. */ 11404 keymaps. */
11403 set_buffer_internal_1 (XBUFFER (w->buffer)); 11405 set_buffer_internal_1 (XBUFFER (w->contents));
11404 11406
11405 /* Save match data, if we must. */ 11407 /* Save match data, if we must. */
11406 if (save_match_data) 11408 if (save_match_data)
@@ -12267,10 +12269,8 @@ hscroll_window_tree (Lisp_Object window)
12267 { 12269 {
12268 struct window *w = XWINDOW (window); 12270 struct window *w = XWINDOW (window);
12269 12271
12270 if (WINDOWP (w->hchild)) 12272 if (WINDOWP (w->contents))
12271 hscrolled_p |= hscroll_window_tree (w->hchild); 12273 hscrolled_p |= hscroll_window_tree (w->contents);
12272 else if (WINDOWP (w->vchild))
12273 hscrolled_p |= hscroll_window_tree (w->vchild);
12274 else if (w->cursor.vpos >= 0) 12274 else if (w->cursor.vpos >= 0)
12275 { 12275 {
12276 int h_margin; 12276 int h_margin;
@@ -12290,7 +12290,7 @@ hscroll_window_tree (Lisp_Object window)
12290 /* Scroll when cursor is inside this scroll margin. */ 12290 /* Scroll when cursor is inside this scroll margin. */
12291 h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w); 12291 h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w);
12292 12292
12293 if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->buffer)) 12293 if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->contents))
12294 /* For left-to-right rows, hscroll when cursor is either 12294 /* For left-to-right rows, hscroll when cursor is either
12295 (i) inside the right hscroll margin, or (ii) if it is 12295 (i) inside the right hscroll margin, or (ii) if it is
12296 inside the left margin and the window is already 12296 inside the left margin and the window is already
@@ -12325,7 +12325,7 @@ hscroll_window_tree (Lisp_Object window)
12325 12325
12326 /* Find point in a display of infinite width. */ 12326 /* Find point in a display of infinite width. */
12327 saved_current_buffer = current_buffer; 12327 saved_current_buffer = current_buffer;
12328 current_buffer = XBUFFER (w->buffer); 12328 current_buffer = XBUFFER (w->contents);
12329 12329
12330 if (w == XWINDOW (selected_window)) 12330 if (w == XWINDOW (selected_window))
12331 pt = PT; 12331 pt = PT;
@@ -12378,7 +12378,7 @@ hscroll_window_tree (Lisp_Object window)
12378 redisplay. */ 12378 redisplay. */
12379 if (w->hscroll != hscroll) 12379 if (w->hscroll != hscroll)
12380 { 12380 {
12381 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 12381 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
12382 w->hscroll = hscroll; 12382 w->hscroll = hscroll;
12383 hscrolled_p = 1; 12383 hscrolled_p = 1;
12384 } 12384 }
@@ -12467,9 +12467,9 @@ debug_method_add (struct window *w, char const *fmt, ...)
12467 if (trace_redisplay_p) 12467 if (trace_redisplay_p)
12468 fprintf (stderr, "%p (%s): %s\n", 12468 fprintf (stderr, "%p (%s): %s\n",
12469 w, 12469 w,
12470 ((BUFFERP (w->buffer) 12470 ((BUFFERP (w->contents)
12471 && STRINGP (BVAR (XBUFFER (w->buffer), name))) 12471 && STRINGP (BVAR (XBUFFER (w->contents), name)))
12472 ? SSDATA (BVAR (XBUFFER (w->buffer), name)) 12472 ? SSDATA (BVAR (XBUFFER (w->contents), name))
12473 : "no buffer"), 12473 : "no buffer"),
12474 method + len); 12474 method + len);
12475} 12475}
@@ -12533,8 +12533,8 @@ text_outside_line_unchanged_p (struct window *w,
12533 require to redisplay the whole paragraph. It might be worthwhile 12533 require to redisplay the whole paragraph. It might be worthwhile
12534 to find the paragraph limits and widen the range of redisplayed 12534 to find the paragraph limits and widen the range of redisplayed
12535 lines to that, but for now just give up this optimization. */ 12535 lines to that, but for now just give up this optimization. */
12536 if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) 12536 if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
12537 && NILP (BVAR (XBUFFER (w->buffer), bidi_paragraph_direction))) 12537 && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
12538 unchanged_p = 0; 12538 unchanged_p = 0;
12539 } 12539 }
12540 12540
@@ -12757,7 +12757,7 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
12757 we set b->clip_changed to 1 to force updating the screen. If 12757 we set b->clip_changed to 1 to force updating the screen. If
12758 b->clip_changed has already been set to 1, we can skip this 12758 b->clip_changed has already been set to 1, we can skip this
12759 check. */ 12759 check. */
12760 if (!b->clip_changed && BUFFERP (w->buffer) && w->window_end_valid) 12760 if (!b->clip_changed && BUFFERP (w->contents) && w->window_end_valid)
12761 { 12761 {
12762 ptrdiff_t pt; 12762 ptrdiff_t pt;
12763 12763
@@ -12766,11 +12766,11 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
12766 else 12766 else
12767 pt = marker_position (w->pointm); 12767 pt = marker_position (w->pointm);
12768 12768
12769 if ((w->current_matrix->buffer != XBUFFER (w->buffer) 12769 if ((w->current_matrix->buffer != XBUFFER (w->contents)
12770 || pt != w->last_point) 12770 || pt != w->last_point)
12771 && check_point_in_composition (w->current_matrix->buffer, 12771 && check_point_in_composition (w->current_matrix->buffer,
12772 w->last_point, 12772 w->last_point,
12773 XBUFFER (w->buffer), pt)) 12773 XBUFFER (w->contents), pt))
12774 b->clip_changed = 1; 12774 b->clip_changed = 1;
12775 } 12775 }
12776} 12776}
@@ -12948,8 +12948,6 @@ redisplay_internal (void)
12948 12948
12949 unbind_to (count1, Qnil); 12949 unbind_to (count1, Qnil);
12950 12950
12951 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1;
12952
12953 consider_all_windows_p = (update_mode_lines 12951 consider_all_windows_p = (update_mode_lines
12954 || buffer_shared_and_changed () 12952 || buffer_shared_and_changed ()
12955 || cursor_type_changed); 12953 || cursor_type_changed);
@@ -13025,11 +13023,11 @@ redisplay_internal (void)
13025 the whole window. The assignment to this_line_start_pos prevents 13023 the whole window. The assignment to this_line_start_pos prevents
13026 the optimization directly below this if-statement. */ 13024 the optimization directly below this if-statement. */
13027 if (((!NILP (Vtransient_mark_mode) 13025 if (((!NILP (Vtransient_mark_mode)
13028 && !NILP (BVAR (XBUFFER (w->buffer), mark_active))) 13026 && !NILP (BVAR (XBUFFER (w->contents), mark_active)))
13029 != (w->region_showing > 0)) 13027 != (w->region_showing > 0))
13030 || (w->region_showing 13028 || (w->region_showing
13031 && w->region_showing 13029 && w->region_showing
13032 != XINT (Fmarker_position (BVAR (XBUFFER (w->buffer), mark))))) 13030 != XINT (Fmarker_position (BVAR (XBUFFER (w->contents), mark)))))
13033 CHARPOS (this_line_start_pos) = 0; 13031 CHARPOS (this_line_start_pos) = 0;
13034 13032
13035 /* Optimize the case that only the line containing the cursor in the 13033 /* Optimize the case that only the line containing the cursor in the
@@ -13047,7 +13045,7 @@ redisplay_internal (void)
13047 && !FRAME_OBSCURED_P (XFRAME (w->frame)) 13045 && !FRAME_OBSCURED_P (XFRAME (w->frame))
13048 /* Make sure recorded data applies to current buffer, etc. */ 13046 /* Make sure recorded data applies to current buffer, etc. */
13049 && this_line_buffer == current_buffer 13047 && this_line_buffer == current_buffer
13050 && current_buffer == XBUFFER (w->buffer) 13048 && current_buffer == XBUFFER (w->contents)
13051 && !w->force_start 13049 && !w->force_start
13052 && !w->optional_new_start 13050 && !w->optional_new_start
13053 /* Point must be on the line that we have info recorded about. */ 13051 /* Point must be on the line that we have info recorded about. */
@@ -13171,7 +13169,7 @@ redisplay_internal (void)
13171 /* Make sure the cursor was last displayed 13169 /* Make sure the cursor was last displayed
13172 in this window. Otherwise we have to reposition it. */ 13170 in this window. Otherwise we have to reposition it. */
13173 && 0 <= w->cursor.vpos 13171 && 0 <= w->cursor.vpos
13174 && WINDOW_TOTAL_LINES (w) > w->cursor.vpos) 13172 && w->cursor.vpos < WINDOW_TOTAL_LINES (w))
13175 { 13173 {
13176 if (!must_finish) 13174 if (!must_finish)
13177 { 13175 {
@@ -13338,7 +13336,7 @@ redisplay_internal (void)
13338 Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf); 13336 Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf);
13339 struct frame *mini_frame; 13337 struct frame *mini_frame;
13340 13338
13341 displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer); 13339 displayed_buffer = XBUFFER (XWINDOW (selected_window)->contents);
13342 /* Use list_of_error, not Qerror, so that 13340 /* Use list_of_error, not Qerror, so that
13343 we catch only errors and don't run the debugger. */ 13341 we catch only errors and don't run the debugger. */
13344 internal_condition_case_1 (redisplay_window_1, selected_window, 13342 internal_condition_case_1 (redisplay_window_1, selected_window,
@@ -13548,7 +13546,7 @@ unwind_redisplay (Lisp_Object old_frame)
13548static void 13546static void
13549mark_window_display_accurate_1 (struct window *w, int accurate_p) 13547mark_window_display_accurate_1 (struct window *w, int accurate_p)
13550{ 13548{
13551 struct buffer *b = XBUFFER (w->buffer); 13549 struct buffer *b = XBUFFER (w->contents);
13552 13550
13553 w->last_modified = accurate_p ? BUF_MODIFF (b) : 0; 13551 w->last_modified = accurate_p ? BUF_MODIFF (b) : 0;
13554 w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0; 13552 w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0;
@@ -13595,11 +13593,9 @@ mark_window_display_accurate (Lisp_Object window, int accurate_p)
13595 for (; !NILP (window); window = w->next) 13593 for (; !NILP (window); window = w->next)
13596 { 13594 {
13597 w = XWINDOW (window); 13595 w = XWINDOW (window);
13598 if (!NILP (w->vchild)) 13596 if (WINDOWP (w->contents))
13599 mark_window_display_accurate (w->vchild, accurate_p); 13597 mark_window_display_accurate (w->contents, accurate_p);
13600 else if (!NILP (w->hchild)) 13598 else
13601 mark_window_display_accurate (w->hchild, accurate_p);
13602 else if (BUFFERP (w->buffer))
13603 mark_window_display_accurate_1 (w, accurate_p); 13599 mark_window_display_accurate_1 (w, accurate_p);
13604 } 13600 }
13605 13601
@@ -13656,13 +13652,11 @@ redisplay_windows (Lisp_Object window)
13656 { 13652 {
13657 struct window *w = XWINDOW (window); 13653 struct window *w = XWINDOW (window);
13658 13654
13659 if (!NILP (w->hchild)) 13655 if (WINDOWP (w->contents))
13660 redisplay_windows (w->hchild); 13656 redisplay_windows (w->contents);
13661 else if (!NILP (w->vchild)) 13657 else if (BUFFERP (w->contents))
13662 redisplay_windows (w->vchild);
13663 else if (!NILP (w->buffer))
13664 { 13658 {
13665 displayed_buffer = XBUFFER (w->buffer); 13659 displayed_buffer = XBUFFER (w->contents);
13666 /* Use list_of_error, not Qerror, so that 13660 /* Use list_of_error, not Qerror, so that
13667 we catch only errors and don't run the debugger. */ 13661 we catch only errors and don't run the debugger. */
13668 internal_condition_case_1 (redisplay_window_0, window, 13662 internal_condition_case_1 (redisplay_window_0, window,
@@ -14309,7 +14303,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
14309 && !MATRIX_ROW_CONTINUATION_LINE_P (row) 14303 && !MATRIX_ROW_CONTINUATION_LINE_P (row)
14310 && row->x == 0) 14304 && row->x == 0)
14311 { 14305 {
14312 this_line_buffer = XBUFFER (w->buffer); 14306 this_line_buffer = XBUFFER (w->contents);
14313 14307
14314 CHARPOS (this_line_start_pos) 14308 CHARPOS (this_line_start_pos)
14315 = MATRIX_ROW_START_CHARPOS (row) + delta; 14309 = MATRIX_ROW_START_CHARPOS (row) + delta;
@@ -14345,7 +14339,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14345 struct window *w = XWINDOW (window); 14339 struct window *w = XWINDOW (window);
14346 SET_MARKER_FROM_TEXT_POS (w->start, startp); 14340 SET_MARKER_FROM_TEXT_POS (w->start, startp);
14347 14341
14348 if (current_buffer != XBUFFER (w->buffer)) 14342 if (current_buffer != XBUFFER (w->contents))
14349 emacs_abort (); 14343 emacs_abort ();
14350 14344
14351 if (!NILP (Vwindow_scroll_functions)) 14345 if (!NILP (Vwindow_scroll_functions))
@@ -14354,7 +14348,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14354 make_number (CHARPOS (startp))); 14348 make_number (CHARPOS (startp)));
14355 SET_TEXT_POS_FROM_MARKER (startp, w->start); 14349 SET_TEXT_POS_FROM_MARKER (startp, w->start);
14356 /* In case the hook functions switch buffers. */ 14350 /* In case the hook functions switch buffers. */
14357 set_buffer_internal (XBUFFER (w->buffer)); 14351 set_buffer_internal (XBUFFER (w->contents));
14358 } 14352 }
14359 14353
14360 return startp; 14354 return startp;
@@ -15005,7 +14999,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15005 must_scroll = 1; 14999 must_scroll = 1;
15006 } 15000 }
15007 else if (rc != CURSOR_MOVEMENT_SUCCESS 15001 else if (rc != CURSOR_MOVEMENT_SUCCESS
15008 && !NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) 15002 && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
15009 { 15003 {
15010 struct glyph_row *row1; 15004 struct glyph_row *row1;
15011 15005
@@ -15068,7 +15062,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15068 else if (scroll_p) 15062 else if (scroll_p)
15069 rc = CURSOR_MOVEMENT_MUST_SCROLL; 15063 rc = CURSOR_MOVEMENT_MUST_SCROLL;
15070 else if (rc != CURSOR_MOVEMENT_SUCCESS 15064 else if (rc != CURSOR_MOVEMENT_SUCCESS
15071 && !NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) 15065 && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
15072 { 15066 {
15073 /* With bidi-reordered rows, there could be more than 15067 /* With bidi-reordered rows, there could be more than
15074 one candidate row whose start and end positions 15068 one candidate row whose start and end positions
@@ -15175,7 +15169,7 @@ set_vertical_scroll_bar (struct window *w)
15175 || (w == XWINDOW (minibuf_window) 15169 || (w == XWINDOW (minibuf_window)
15176 && NILP (echo_area_buffer[0]))) 15170 && NILP (echo_area_buffer[0])))
15177 { 15171 {
15178 struct buffer *buf = XBUFFER (w->buffer); 15172 struct buffer *buf = XBUFFER (w->contents);
15179 whole = BUF_ZV (buf) - BUF_BEGV (buf); 15173 whole = BUF_ZV (buf) - BUF_BEGV (buf);
15180 start = marker_position (w->start) - BUF_BEGV (buf); 15174 start = marker_position (w->start) - BUF_BEGV (buf);
15181 /* I don't think this is guaranteed to be right. For the 15175 /* I don't think this is guaranteed to be right. For the
@@ -15209,7 +15203,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15209{ 15203{
15210 struct window *w = XWINDOW (window); 15204 struct window *w = XWINDOW (window);
15211 struct frame *f = XFRAME (w->frame); 15205 struct frame *f = XFRAME (w->frame);
15212 struct buffer *buffer = XBUFFER (w->buffer); 15206 struct buffer *buffer = XBUFFER (w->contents);
15213 struct buffer *old = current_buffer; 15207 struct buffer *old = current_buffer;
15214 struct text_pos lpoint, opoint, startp; 15208 struct text_pos lpoint, opoint, startp;
15215 int update_mode_line; 15209 int update_mode_line;
@@ -15231,12 +15225,14 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15231 SET_TEXT_POS (lpoint, PT, PT_BYTE); 15225 SET_TEXT_POS (lpoint, PT, PT_BYTE);
15232 opoint = lpoint; 15226 opoint = lpoint;
15233 15227
15234 /* W must be a leaf window here. */
15235 eassert (!NILP (w->buffer));
15236#ifdef GLYPH_DEBUG 15228#ifdef GLYPH_DEBUG
15237 *w->desired_matrix->method = 0; 15229 *w->desired_matrix->method = 0;
15238#endif 15230#endif
15239 15231
15232 /* Make sure that both W's markers are valid. */
15233 eassert (XMARKER (w->start)->buffer == buffer);
15234 eassert (XMARKER (w->pointm)->buffer == buffer);
15235
15240 restart: 15236 restart:
15241 reconsider_clip_changes (w, buffer); 15237 reconsider_clip_changes (w, buffer);
15242 15238
@@ -15262,10 +15258,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15262 else if ((w != XWINDOW (minibuf_window) 15258 else if ((w != XWINDOW (minibuf_window)
15263 || minibuf_level == 0) 15259 || minibuf_level == 0)
15264 /* When buffer is nonempty, redisplay window normally. */ 15260 /* When buffer is nonempty, redisplay window normally. */
15265 && BUF_Z (XBUFFER (w->buffer)) == BUF_BEG (XBUFFER (w->buffer)) 15261 && BUF_Z (XBUFFER (w->contents)) == BUF_BEG (XBUFFER (w->contents))
15266 /* Quail displays non-mini buffers in minibuffer window. 15262 /* Quail displays non-mini buffers in minibuffer window.
15267 In that case, redisplay the window normally. */ 15263 In that case, redisplay the window normally. */
15268 && !NILP (Fmemq (w->buffer, Vminibuffer_list))) 15264 && !NILP (Fmemq (w->contents, Vminibuffer_list)))
15269 { 15265 {
15270 /* W is a mini-buffer window, but it's not active, so clear 15266 /* W is a mini-buffer window, but it's not active, so clear
15271 it. */ 15267 it. */
@@ -15287,7 +15283,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15287 value. */ 15283 value. */
15288 /* Really select the buffer, for the sake of buffer-local 15284 /* Really select the buffer, for the sake of buffer-local
15289 variables. */ 15285 variables. */
15290 set_buffer_internal_1 (XBUFFER (w->buffer)); 15286 set_buffer_internal_1 (XBUFFER (w->contents));
15291 15287
15292 current_matrix_up_to_date_p 15288 current_matrix_up_to_date_p
15293 = (w->window_end_valid 15289 = (w->window_end_valid
@@ -15520,7 +15516,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15520 15516
15521 /* If we are highlighting the region, then we just changed 15517 /* If we are highlighting the region, then we just changed
15522 the region, so redisplay to show it. */ 15518 the region, so redisplay to show it. */
15523 if (0 <= markpos_of_region ()) 15519 if (markpos_of_region () >= 0)
15524 { 15520 {
15525 clear_glyph_matrix (w->desired_matrix); 15521 clear_glyph_matrix (w->desired_matrix);
15526 if (!try_window (window, startp, 0)) 15522 if (!try_window (window, startp, 0))
@@ -16221,7 +16217,7 @@ try_window_reusing_current_matrix (struct window *w)
16221 return 0; 16217 return 0;
16222 16218
16223 /* Can't do this if region may have changed. */ 16219 /* Can't do this if region may have changed. */
16224 if (0 <= markpos_of_region () 16220 if (markpos_of_region () >= 0
16225 || w->region_showing 16221 || w->region_showing
16226 || !NILP (Vshow_trailing_whitespace)) 16222 || !NILP (Vshow_trailing_whitespace))
16227 return 0; 16223 return 0;
@@ -16578,7 +16574,7 @@ try_window_reusing_current_matrix (struct window *w)
16578 bidi-reordered glyph rows. Let set_cursor_from_row 16574 bidi-reordered glyph rows. Let set_cursor_from_row
16579 figure out where to put the cursor, and if it fails, 16575 figure out where to put the cursor, and if it fails,
16580 give up. */ 16576 give up. */
16581 if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) 16577 if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
16582 { 16578 {
16583 if (!set_cursor_from_row (w, row, w->current_matrix, 16579 if (!set_cursor_from_row (w, row, w->current_matrix,
16584 0, 0, 0, 0)) 16580 0, 0, 0, 0))
@@ -16829,7 +16825,7 @@ sync_frame_with_window_matrix_rows (struct window *w)
16829 16825
16830 /* Preconditions: W must be a leaf window and full-width. Its frame 16826 /* Preconditions: W must be a leaf window and full-width. Its frame
16831 must have a frame matrix. */ 16827 must have a frame matrix. */
16832 eassert (NILP (w->hchild) && NILP (w->vchild)); 16828 eassert (BUFFERP (w->contents));
16833 eassert (WINDOW_FULL_WIDTH_P (w)); 16829 eassert (WINDOW_FULL_WIDTH_P (w));
16834 eassert (!FRAME_WINDOW_P (f)); 16830 eassert (!FRAME_WINDOW_P (f));
16835 16831
@@ -16871,7 +16867,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos,
16871{ 16867{
16872 struct glyph_row *row = start; 16868 struct glyph_row *row = start;
16873 struct glyph_row *best_row = NULL; 16869 struct glyph_row *best_row = NULL;
16874 ptrdiff_t mindif = BUF_ZV (XBUFFER (w->buffer)) + 1; 16870 ptrdiff_t mindif = BUF_ZV (XBUFFER (w->contents)) + 1;
16875 int last_y; 16871 int last_y;
16876 16872
16877 /* If we happen to start on a header-line, skip that. */ 16873 /* If we happen to start on a header-line, skip that. */
@@ -16907,7 +16903,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos,
16907 { 16903 {
16908 struct glyph *g; 16904 struct glyph *g;
16909 16905
16910 if (NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) 16906 if (NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
16911 || (!best_row && !row->continued_p)) 16907 || (!best_row && !row->continued_p))
16912 return row; 16908 return row;
16913 /* In bidi-reordered rows, there could be several rows 16909 /* In bidi-reordered rows, there could be several rows
@@ -17053,7 +17049,7 @@ try_window_id (struct window *w)
17053 17049
17054 /* Can't use this if highlighting a region because a cursor movement 17050 /* Can't use this if highlighting a region because a cursor movement
17055 will do more than just set the cursor. */ 17051 will do more than just set the cursor. */
17056 if (0 <= markpos_of_region ()) 17052 if (markpos_of_region () >= 0)
17057 GIVE_UP (9); 17053 GIVE_UP (9);
17058 17054
17059 /* Likewise if highlighting trailing whitespace. */ 17055 /* Likewise if highlighting trailing whitespace. */
@@ -17073,7 +17069,7 @@ try_window_id (struct window *w)
17073 wrapped line can change the wrap position, altering the line 17069 wrapped line can change the wrap position, altering the line
17074 above it. It might be worthwhile to handle this more 17070 above it. It might be worthwhile to handle this more
17075 intelligently, but for now just redisplay from scratch. */ 17071 intelligently, but for now just redisplay from scratch. */
17076 if (!NILP (BVAR (XBUFFER (w->buffer), word_wrap))) 17072 if (!NILP (BVAR (XBUFFER (w->contents), word_wrap)))
17077 GIVE_UP (21); 17073 GIVE_UP (21);
17078 17074
17079 /* Under bidi reordering, adding or deleting a character in the 17075 /* Under bidi reordering, adding or deleting a character in the
@@ -17084,8 +17080,8 @@ try_window_id (struct window *w)
17084 to find the paragraph limits and widen the range of redisplayed 17080 to find the paragraph limits and widen the range of redisplayed
17085 lines to that, but for now just give up this optimization and 17081 lines to that, but for now just give up this optimization and
17086 redisplay from scratch. */ 17082 redisplay from scratch. */
17087 if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) 17083 if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
17088 && NILP (BVAR (XBUFFER (w->buffer), bidi_paragraph_direction))) 17084 && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
17089 GIVE_UP (22); 17085 GIVE_UP (22);
17090 17086
17091 /* Make sure beg_unchanged and end_unchanged are up to date. Do it 17087 /* Make sure beg_unchanged and end_unchanged are up to date. Do it
@@ -17950,7 +17946,7 @@ glyphs in short form, otherwise show glyphs in long form. */)
17950 (Lisp_Object glyphs) 17946 (Lisp_Object glyphs)
17951{ 17947{
17952 struct window *w = XWINDOW (selected_window); 17948 struct window *w = XWINDOW (selected_window);
17953 struct buffer *buffer = XBUFFER (w->buffer); 17949 struct buffer *buffer = XBUFFER (w->contents);
17954 17950
17955 fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n", 17951 fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n",
17956 BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer)); 17952 BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer));
@@ -18056,7 +18052,7 @@ static struct glyph_row *
18056get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string) 18052get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string)
18057{ 18053{
18058 struct frame *f = XFRAME (WINDOW_FRAME (w)); 18054 struct frame *f = XFRAME (WINDOW_FRAME (w));
18059 struct buffer *buffer = XBUFFER (w->buffer); 18055 struct buffer *buffer = XBUFFER (w->contents);
18060 struct buffer *old = current_buffer; 18056 struct buffer *old = current_buffer;
18061 const unsigned char *arrow_string = SDATA (overlay_arrow_string); 18057 const unsigned char *arrow_string = SDATA (overlay_arrow_string);
18062 int arrow_len = SCHARS (overlay_arrow_string); 18058 int arrow_len = SCHARS (overlay_arrow_string);
@@ -19263,7 +19259,7 @@ display_line (struct it *it)
19263 row->glyphs[TEXT_AREA]->charpos = -1; 19259 row->glyphs[TEXT_AREA]->charpos = -1;
19264 row->displays_text_p = 0; 19260 row->displays_text_p = 0;
19265 19261
19266 if (!NILP (BVAR (XBUFFER (it->w->buffer), indicate_empty_lines)) 19262 if (!NILP (BVAR (XBUFFER (it->w->contents), indicate_empty_lines))
19267 && (!MINI_WINDOW_P (it->w) 19263 && (!MINI_WINDOW_P (it->w)
19268 || (minibuf_level && EQ (it->window, minibuf_window)))) 19264 || (minibuf_level && EQ (it->window, minibuf_window))))
19269 row->indicate_empty_line_p = 1; 19265 row->indicate_empty_line_p = 1;
@@ -19988,18 +19984,17 @@ display_menu_bar (struct window *w)
19988 return; 19984 return;
19989#endif /* HAVE_NS */ 19985#endif /* HAVE_NS */
19990 19986
19991#ifdef USE_X_TOOLKIT 19987#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
19992 eassert (!FRAME_WINDOW_P (f)); 19988 eassert (!FRAME_WINDOW_P (f));
19993 init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID); 19989 init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID);
19994 it.first_visible_x = 0; 19990 it.first_visible_x = 0;
19995 it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f); 19991 it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
19996#else /* not USE_X_TOOLKIT */ 19992#elif defined (HAVE_X_WINDOWS) /* X without toolkit. */
19997 if (FRAME_WINDOW_P (f)) 19993 if (FRAME_WINDOW_P (f))
19998 { 19994 {
19999 /* Menu bar lines are displayed in the desired matrix of the 19995 /* Menu bar lines are displayed in the desired matrix of the
20000 dummy window menu_bar_window. */ 19996 dummy window menu_bar_window. */
20001 struct window *menu_w; 19997 struct window *menu_w;
20002 eassert (WINDOWP (f->menu_bar_window));
20003 menu_w = XWINDOW (f->menu_bar_window); 19998 menu_w = XWINDOW (f->menu_bar_window);
20004 init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows, 19999 init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
20005 MENU_FACE_ID); 20000 MENU_FACE_ID);
@@ -20007,6 +20002,7 @@ display_menu_bar (struct window *w)
20007 it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f); 20002 it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
20008 } 20003 }
20009 else 20004 else
20005#endif /* not USE_X_TOOLKIT and not USE_GTK */
20010 { 20006 {
20011 /* This is a TTY frame, i.e. character hpos/vpos are used as 20007 /* This is a TTY frame, i.e. character hpos/vpos are used as
20012 pixel x/y. */ 20008 pixel x/y. */
@@ -20015,7 +20011,6 @@ display_menu_bar (struct window *w)
20015 it.first_visible_x = 0; 20011 it.first_visible_x = 0;
20016 it.last_visible_x = FRAME_COLS (f); 20012 it.last_visible_x = FRAME_COLS (f);
20017 } 20013 }
20018#endif /* not USE_X_TOOLKIT */
20019 20014
20020 /* FIXME: This should be controlled by a user option. See the 20015 /* FIXME: This should be controlled by a user option. See the
20021 comments in redisplay_tool_bar and display_mode_line about 20016 comments in redisplay_tool_bar and display_mode_line about
@@ -20079,10 +20074,8 @@ redisplay_mode_lines (Lisp_Object window, int force)
20079 { 20074 {
20080 struct window *w = XWINDOW (window); 20075 struct window *w = XWINDOW (window);
20081 20076
20082 if (WINDOWP (w->hchild)) 20077 if (WINDOWP (w->contents))
20083 nwindows += redisplay_mode_lines (w->hchild, force); 20078 nwindows += redisplay_mode_lines (w->contents, force);
20084 else if (WINDOWP (w->vchild))
20085 nwindows += redisplay_mode_lines (w->vchild, force);
20086 else if (force 20079 else if (force
20087 || FRAME_GARBAGED_P (XFRAME (w->frame)) 20080 || FRAME_GARBAGED_P (XFRAME (w->frame))
20088 || !MATRIX_MODE_LINE_ROW (w->current_matrix)->enabled_p) 20081 || !MATRIX_MODE_LINE_ROW (w->current_matrix)->enabled_p)
@@ -20092,7 +20085,7 @@ redisplay_mode_lines (Lisp_Object window, int force)
20092 20085
20093 /* Set the window's buffer for the mode line display. */ 20086 /* Set the window's buffer for the mode line display. */
20094 SET_TEXT_POS (lpoint, PT, PT_BYTE); 20087 SET_TEXT_POS (lpoint, PT, PT_BYTE);
20095 set_buffer_internal_1 (XBUFFER (w->buffer)); 20088 set_buffer_internal_1 (XBUFFER (w->contents));
20096 20089
20097 /* Point refers normally to the selected window. For any 20090 /* Point refers normally to the selected window. For any
20098 other window, set up appropriate value. */ 20091 other window, set up appropriate value. */
@@ -20874,7 +20867,7 @@ are the selected window and the WINDOW's buffer). */)
20874 XSETWINDOW (window, w); 20867 XSETWINDOW (window, w);
20875 20868
20876 if (NILP (buffer)) 20869 if (NILP (buffer))
20877 buffer = w->buffer; 20870 buffer = w->contents;
20878 CHECK_BUFFER (buffer); 20871 CHECK_BUFFER (buffer);
20879 20872
20880 /* Make formatting the modeline a non-op when noninteractive, otherwise 20873 /* Make formatting the modeline a non-op when noninteractive, otherwise
@@ -21009,7 +21002,7 @@ pint2hrstr (char *buf, int width, ptrdiff_t d)
21009 char * psuffix; 21002 char * psuffix;
21010 char * p; 21003 char * p;
21011 21004
21012 if (1000 <= quotient) 21005 if (quotient >= 1000)
21013 { 21006 {
21014 /* Scale to the appropriate EXPONENT. */ 21007 /* Scale to the appropriate EXPONENT. */
21015 do 21008 do
@@ -21018,13 +21011,13 @@ pint2hrstr (char *buf, int width, ptrdiff_t d)
21018 quotient /= 1000; 21011 quotient /= 1000;
21019 exponent++; 21012 exponent++;
21020 } 21013 }
21021 while (1000 <= quotient); 21014 while (quotient >= 1000);
21022 21015
21023 /* Round to nearest and decide whether to use TENTHS or not. */ 21016 /* Round to nearest and decide whether to use TENTHS or not. */
21024 if (quotient <= 9) 21017 if (quotient <= 9)
21025 { 21018 {
21026 tenths = remainder / 100; 21019 tenths = remainder / 100;
21027 if (50 <= remainder % 100) 21020 if (remainder % 100 >= 50)
21028 { 21021 {
21029 if (tenths < 9) 21022 if (tenths < 9)
21030 tenths++; 21023 tenths++;
@@ -21039,7 +21032,7 @@ pint2hrstr (char *buf, int width, ptrdiff_t d)
21039 } 21032 }
21040 } 21033 }
21041 else 21034 else
21042 if (500 <= remainder) 21035 if (remainder >= 500)
21043 { 21036 {
21044 if (quotient < 999) 21037 if (quotient < 999)
21045 quotient++; 21038 quotient++;
@@ -22180,7 +22173,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
22180 return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); 22173 return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w));
22181 } 22174 }
22182 22175
22183 prop = buffer_local_value_1 (prop, it->w->buffer); 22176 prop = buffer_local_value_1 (prop, it->w->contents);
22184 if (EQ (prop, Qunbound)) 22177 if (EQ (prop, Qunbound))
22185 prop = Qnil; 22178 prop = Qnil;
22186 } 22179 }
@@ -22232,7 +22225,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
22232 return OK_PIXELS (pixels); 22225 return OK_PIXELS (pixels);
22233 } 22226 }
22234 22227
22235 car = buffer_local_value_1 (car, it->w->buffer); 22228 car = buffer_local_value_1 (car, it->w->contents);
22236 if (EQ (car, Qunbound)) 22229 if (EQ (car, Qunbound))
22237 car = Qnil; 22230 car = Qnil;
22238 } 22231 }
@@ -22392,16 +22385,16 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
22392 XChar2b *char2b, int display_p) 22385 XChar2b *char2b, int display_p)
22393{ 22386{
22394 struct face *face = FACE_FROM_ID (f, face_id); 22387 struct face *face = FACE_FROM_ID (f, face_id);
22388 unsigned code = 0;
22395 22389
22396 if (face->font) 22390 if (face->font)
22397 { 22391 {
22398 unsigned code = face->font->driver->encode_char (face->font, c); 22392 code = face->font->driver->encode_char (face->font, c);
22399 22393
22400 if (code != FONT_INVALID_CODE) 22394 if (code == FONT_INVALID_CODE)
22401 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); 22395 code = 0;
22402 else
22403 STORE_XCHAR2B (char2b, 0, 0);
22404 } 22396 }
22397 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
22405 22398
22406 /* Make sure X resources of the face are allocated. */ 22399 /* Make sure X resources of the face are allocated. */
22407#ifdef HAVE_X_WINDOWS 22400#ifdef HAVE_X_WINDOWS
@@ -22425,31 +22418,30 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
22425 XChar2b *char2b, int *two_byte_p) 22418 XChar2b *char2b, int *two_byte_p)
22426{ 22419{
22427 struct face *face; 22420 struct face *face;
22421 unsigned code = 0;
22428 22422
22429 eassert (glyph->type == CHAR_GLYPH); 22423 eassert (glyph->type == CHAR_GLYPH);
22430 face = FACE_FROM_ID (f, glyph->face_id); 22424 face = FACE_FROM_ID (f, glyph->face_id);
22431 22425
22426 /* Make sure X resources of the face are allocated. */
22427 eassert (face != NULL);
22428 PREPARE_FACE_FOR_DISPLAY (f, face);
22429
22432 if (two_byte_p) 22430 if (two_byte_p)
22433 *two_byte_p = 0; 22431 *two_byte_p = 0;
22434 22432
22435 if (face->font) 22433 if (face->font)
22436 { 22434 {
22437 unsigned code;
22438
22439 if (CHAR_BYTE8_P (glyph->u.ch)) 22435 if (CHAR_BYTE8_P (glyph->u.ch))
22440 code = CHAR_TO_BYTE8 (glyph->u.ch); 22436 code = CHAR_TO_BYTE8 (glyph->u.ch);
22441 else 22437 else
22442 code = face->font->driver->encode_char (face->font, glyph->u.ch); 22438 code = face->font->driver->encode_char (face->font, glyph->u.ch);
22443 22439
22444 if (code != FONT_INVALID_CODE) 22440 if (code == FONT_INVALID_CODE)
22445 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); 22441 code = 0;
22446 else
22447 STORE_XCHAR2B (char2b, 0, 0);
22448 } 22442 }
22449 22443
22450 /* Make sure X resources of the face are allocated. */ 22444 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
22451 eassert (face != NULL);
22452 PREPARE_FACE_FOR_DISPLAY (f, face);
22453 return face; 22445 return face;
22454} 22446}
22455 22447
@@ -22759,9 +22751,12 @@ static struct font_metrics *
22759get_per_char_metric (struct font *font, XChar2b *char2b) 22751get_per_char_metric (struct font *font, XChar2b *char2b)
22760{ 22752{
22761 static struct font_metrics metrics; 22753 static struct font_metrics metrics;
22762 unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); 22754 unsigned code;
22763 22755
22764 if (! font || code == FONT_INVALID_CODE) 22756 if (! font)
22757 return NULL;
22758 code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
22759 if (code == FONT_INVALID_CODE)
22765 return NULL; 22760 return NULL;
22766 font->driver->text_extents (font, &code, 1, &metrics); 22761 font->driver->text_extents (font, &code, 1, &metrics);
22767 return &metrics; 22762 return &metrics;
@@ -24082,7 +24077,7 @@ produce_stretch_glyph (struct it *it)
24082 int n = width; 24077 int n = width;
24083 24078
24084 if (!STRINGP (object)) 24079 if (!STRINGP (object))
24085 object = it->w->buffer; 24080 object = it->w->contents;
24086#ifdef HAVE_WINDOW_SYSTEM 24081#ifdef HAVE_WINDOW_SYSTEM
24087 if (FRAME_WINDOW_P (it->f)) 24082 if (FRAME_WINDOW_P (it->f))
24088 append_stretch_glyph (it, object, width, height, ascent); 24083 append_stretch_glyph (it, object, width, height, ascent);
@@ -25478,7 +25473,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
25478 int *active_cursor) 25473 int *active_cursor)
25479{ 25474{
25480 struct frame *f = XFRAME (w->frame); 25475 struct frame *f = XFRAME (w->frame);
25481 struct buffer *b = XBUFFER (w->buffer); 25476 struct buffer *b = XBUFFER (w->contents);
25482 int cursor_type = DEFAULT_CURSOR; 25477 int cursor_type = DEFAULT_CURSOR;
25483 Lisp_Object alt_cursor; 25478 Lisp_Object alt_cursor;
25484 int non_selected = 0; 25479 int non_selected = 0;
@@ -26029,10 +26024,8 @@ update_cursor_in_window_tree (struct window *w, int on_p)
26029{ 26024{
26030 while (w) 26025 while (w)
26031 { 26026 {
26032 if (!NILP (w->hchild)) 26027 if (WINDOWP (w->contents))
26033 update_cursor_in_window_tree (XWINDOW (w->hchild), on_p); 26028 update_cursor_in_window_tree (XWINDOW (w->contents), on_p);
26034 else if (!NILP (w->vchild))
26035 update_cursor_in_window_tree (XWINDOW (w->vchild), on_p);
26036 else 26029 else
26037 update_window_cursor (w, on_p); 26030 update_window_cursor (w, on_p);
26038 26031
@@ -27278,7 +27271,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
27278 { 27271 {
27279 help_echo_string = help; 27272 help_echo_string = help;
27280 XSETWINDOW (help_echo_window, w); 27273 XSETWINDOW (help_echo_window, w);
27281 help_echo_object = w->buffer; 27274 help_echo_object = w->contents;
27282 help_echo_pos = charpos; 27275 help_echo_pos = charpos;
27283 } 27276 }
27284 } 27277 }
@@ -27314,7 +27307,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
27314 { 27307 {
27315 Lisp_Object default_help 27308 Lisp_Object default_help
27316 = buffer_local_value_1 (Qmode_line_default_help_echo, 27309 = buffer_local_value_1 (Qmode_line_default_help_echo,
27317 w->buffer); 27310 w->contents);
27318 27311
27319 if (STRINGP (default_help)) 27312 if (STRINGP (default_help))
27320 { 27313 {
@@ -27589,7 +27582,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
27589 27582
27590 /* Are we in a window whose display is up to date? 27583 /* Are we in a window whose display is up to date?
27591 And verify the buffer's text has not changed. */ 27584 And verify the buffer's text has not changed. */
27592 b = XBUFFER (w->buffer); 27585 b = XBUFFER (w->contents);
27593 if (part == ON_TEXT 27586 if (part == ON_TEXT
27594 && w->window_end_valid 27587 && w->window_end_valid
27595 && w->last_modified == BUF_MODIFF (b) 27588 && w->last_modified == BUF_MODIFF (b)
@@ -27798,8 +27791,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
27798 if (pos > 0) 27791 if (pos > 0)
27799 { 27792 {
27800 mouse_face = get_char_property_and_overlay 27793 mouse_face = get_char_property_and_overlay
27801 (make_number (pos), Qmouse_face, w->buffer, &overlay); 27794 (make_number (pos), Qmouse_face, w->contents, &overlay);
27802 buffer = w->buffer; 27795 buffer = w->contents;
27803 disp_string = object; 27796 disp_string = object;
27804 } 27797 }
27805 } 27798 }
@@ -27912,11 +27905,11 @@ note_mouse_highlight (struct frame *f, int x, int y)
27912 if (p > 0) 27905 if (p > 0)
27913 { 27906 {
27914 help = Fget_char_property (make_number (p), 27907 help = Fget_char_property (make_number (p),
27915 Qhelp_echo, w->buffer); 27908 Qhelp_echo, w->contents);
27916 if (!NILP (help)) 27909 if (!NILP (help))
27917 { 27910 {
27918 charpos = p; 27911 charpos = p;
27919 obj = w->buffer; 27912 obj = w->contents;
27920 } 27913 }
27921 } 27914 }
27922 } 27915 }
@@ -27967,7 +27960,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
27967 ptrdiff_t p = string_buffer_position (obj, start); 27960 ptrdiff_t p = string_buffer_position (obj, start);
27968 if (p > 0) 27961 if (p > 0)
27969 pointer = Fget_char_property (make_number (p), 27962 pointer = Fget_char_property (make_number (p),
27970 Qpointer, w->buffer); 27963 Qpointer, w->contents);
27971 } 27964 }
27972 } 27965 }
27973 else if (BUFFERP (obj) 27966 else if (BUFFERP (obj)
@@ -28410,12 +28403,9 @@ expose_window_tree (struct window *w, XRectangle *r)
28410 28403
28411 while (w && !FRAME_GARBAGED_P (f)) 28404 while (w && !FRAME_GARBAGED_P (f))
28412 { 28405 {
28413 if (!NILP (w->hchild)) 28406 if (WINDOWP (w->contents))
28414 mouse_face_overwritten_p
28415 |= expose_window_tree (XWINDOW (w->hchild), r);
28416 else if (!NILP (w->vchild))
28417 mouse_face_overwritten_p 28407 mouse_face_overwritten_p
28418 |= expose_window_tree (XWINDOW (w->vchild), r); 28408 |= expose_window_tree (XWINDOW (w->contents), r);
28419 else 28409 else
28420 mouse_face_overwritten_p |= expose_window (w, r); 28410 mouse_face_overwritten_p |= expose_window (w, r);
28421 28411
@@ -28480,11 +28470,11 @@ expose_frame (struct frame *f, int x, int y, int w, int h)
28480 28470
28481#ifdef HAVE_X_WINDOWS 28471#ifdef HAVE_X_WINDOWS
28482#ifndef MSDOS 28472#ifndef MSDOS
28483#ifndef USE_X_TOOLKIT 28473#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
28484 if (WINDOWP (f->menu_bar_window)) 28474 if (WINDOWP (f->menu_bar_window))
28485 mouse_face_overwritten_p 28475 mouse_face_overwritten_p
28486 |= expose_window (XWINDOW (f->menu_bar_window), &r); 28476 |= expose_window (XWINDOW (f->menu_bar_window), &r);
28487#endif /* not USE_X_TOOLKIT */ 28477#endif /* not USE_X_TOOLKIT and not USE_GTK */
28488#endif 28478#endif
28489#endif 28479#endif
28490 28480
diff --git a/src/xfaces.c b/src/xfaces.c
index eb33a38a491..9acaf6d6f52 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -231,7 +231,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
231#undef FRAME_X_DISPLAY_INFO 231#undef FRAME_X_DISPLAY_INFO
232#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO 232#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
233#define x_display_info w32_display_info 233#define x_display_info w32_display_info
234#define check_x check_w32
235#define GCGraphicsExposures 0 234#define GCGraphicsExposures 0
236#endif /* HAVE_NTGUI */ 235#endif /* HAVE_NTGUI */
237 236
@@ -239,7 +238,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
239#undef FRAME_X_DISPLAY_INFO 238#undef FRAME_X_DISPLAY_INFO
240#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO 239#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
241#define x_display_info ns_display_info 240#define x_display_info ns_display_info
242#define check_x check_ns
243#define GCGraphicsExposures 0 241#define GCGraphicsExposures 0
244#endif /* HAVE_NS */ 242#endif /* HAVE_NS */
245#endif /* HAVE_WINDOW_SYSTEM */ 243#endif /* HAVE_WINDOW_SYSTEM */
@@ -1636,7 +1634,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1636 struct frame *f; 1634 struct frame *f;
1637 int size, avgwidth IF_LINT (= 0); 1635 int size, avgwidth IF_LINT (= 0);
1638 1636
1639 check_x (); 1637 check_window_system ();
1640 CHECK_STRING (pattern); 1638 CHECK_STRING (pattern);
1641 1639
1642 if (! NILP (maximum)) 1640 if (! NILP (maximum))
@@ -3395,21 +3393,22 @@ set_font_frame_param (Lisp_Object frame, Lisp_Object lface)
3395 } 3393 }
3396} 3394}
3397 3395
3398
3399/* Get the value of X resource RESOURCE, class CLASS for the display
3400 of frame FRAME. This is here because ordinary `x-get-resource'
3401 doesn't take a frame argument. */
3402
3403DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, 3396DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource,
3404 Sinternal_face_x_get_resource, 3, 3, 0, doc: /* */) 3397 Sinternal_face_x_get_resource, 2, 3, 0,
3398 doc: /* Get the value of X resource RESOURCE, class CLASS.
3399Returned value is for the display of frame FRAME. If FRAME is not
3400specified or nil, use selected frame. This function exists because
3401ordinary `x-get-resource' doesn't take a frame argument. */)
3405 (Lisp_Object resource, Lisp_Object class, Lisp_Object frame) 3402 (Lisp_Object resource, Lisp_Object class, Lisp_Object frame)
3406{ 3403{
3407 Lisp_Object value = Qnil; 3404 Lisp_Object value = Qnil;
3405 struct frame *f;
3406
3408 CHECK_STRING (resource); 3407 CHECK_STRING (resource);
3409 CHECK_STRING (class); 3408 CHECK_STRING (class);
3410 CHECK_LIVE_FRAME (frame); 3409 f = decode_live_frame (frame);
3411 block_input (); 3410 block_input ();
3412 value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)), 3411 value = display_x_get_resource (FRAME_X_DISPLAY_INFO (f),
3413 resource, class, Qnil, Qnil); 3412 resource, class, Qnil, Qnil);
3414 unblock_input (); 3413 unblock_input ();
3415 return value; 3414 return value;
@@ -5963,7 +5962,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
5963 5962
5964 /* W must display the current buffer. We could write this function 5963 /* W must display the current buffer. We could write this function
5965 to use the frame and buffer of W, but right now it doesn't. */ 5964 to use the frame and buffer of W, but right now it doesn't. */
5966 /* eassert (XBUFFER (w->buffer) == current_buffer); */ 5965 /* eassert (XBUFFER (w->contents) == current_buffer); */
5967 5966
5968 XSETFASTINT (position, pos); 5967 XSETFASTINT (position, pos);
5969 5968
@@ -5973,9 +5972,9 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
5973 5972
5974 /* Get the `face' or `mouse_face' text property at POS, and 5973 /* Get the `face' or `mouse_face' text property at POS, and
5975 determine the next position at which the property changes. */ 5974 determine the next position at which the property changes. */
5976 prop = Fget_text_property (position, propname, w->buffer); 5975 prop = Fget_text_property (position, propname, w->contents);
5977 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); 5976 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
5978 end = Fnext_single_property_change (position, propname, w->buffer, limit1); 5977 end = Fnext_single_property_change (position, propname, w->contents, limit1);
5979 if (INTEGERP (end)) 5978 if (INTEGERP (end))
5980 endpos = XINT (end); 5979 endpos = XINT (end);
5981 5980
@@ -6071,7 +6070,7 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6071 6070
6072 /* W must display the current buffer. We could write this function 6071 /* W must display the current buffer. We could write this function
6073 to use the frame and buffer of W, but right now it doesn't. */ 6072 to use the frame and buffer of W, but right now it doesn't. */
6074 /* eassert (XBUFFER (w->buffer) == current_buffer); */ 6073 /* eassert (XBUFFER (w->contents) == current_buffer); */
6075 6074
6076 XSETFASTINT (position, pos); 6075 XSETFASTINT (position, pos);
6077 6076
@@ -6081,9 +6080,9 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6081 6080
6082 /* Get the `face' or `mouse_face' text property at POS, and 6081 /* Get the `face' or `mouse_face' text property at POS, and
6083 determine the next position at which the property changes. */ 6082 determine the next position at which the property changes. */
6084 prop = Fget_text_property (position, propname, w->buffer); 6083 prop = Fget_text_property (position, propname, w->contents);
6085 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); 6084 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
6086 end = Fnext_single_property_change (position, propname, w->buffer, limit1); 6085 end = Fnext_single_property_change (position, propname, w->contents, limit1);
6087 if (INTEGERP (end)) 6086 if (INTEGERP (end))
6088 endpos = XINT (end); 6087 endpos = XINT (end);
6089 6088
diff --git a/src/xfns.c b/src/xfns.c
index 488365561d3..8b8d94d4779 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -143,7 +143,7 @@ static struct x_display_info *x_display_info_for_name (Lisp_Object);
143/* Error if we are not connected to X. */ 143/* Error if we are not connected to X. */
144 144
145void 145void
146check_x (void) 146check_window_system (void)
147{ 147{
148 if (! x_in_use) 148 if (! x_in_use)
149 error ("X windows are not in use or not initialized"); 149 error ("X windows are not in use or not initialized");
@@ -4322,7 +4322,7 @@ no value of TYPE (always string in the MS Windows case). */)
4322 property and those are indeed in 32 bit quantities if format is 4322 property and those are indeed in 32 bit quantities if format is
4323 32. */ 4323 32. */
4324 4324
4325 if (32 < BITS_PER_LONG && actual_format == 32) 4325 if (BITS_PER_LONG > 32 && actual_format == 32)
4326 { 4326 {
4327 unsigned long i; 4327 unsigned long i;
4328 int *idata = (int *) tmp_data; 4328 int *idata = (int *) tmp_data;
@@ -4525,7 +4525,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4525 Lisp_Object buffer; 4525 Lisp_Object buffer;
4526 struct buffer *old_buffer; 4526 struct buffer *old_buffer;
4527 4527
4528 check_x (); 4528 check_window_system ();
4529 4529
4530 if (!dpyinfo->terminal->name) 4530 if (!dpyinfo->terminal->name)
4531 error ("Terminal is not live, can't create new frames on it"); 4531 error ("Terminal is not live, can't create new frames on it");
@@ -5043,7 +5043,7 @@ Text larger than the specified size is clipped. */)
5043 5043
5044 /* Display the tooltip text in a temporary buffer. */ 5044 /* Display the tooltip text in a temporary buffer. */
5045 old_buffer = current_buffer; 5045 old_buffer = current_buffer;
5046 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); 5046 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->contents));
5047 bset_truncate_lines (current_buffer, Qnil); 5047 bset_truncate_lines (current_buffer, Qnil);
5048 clear_glyph_matrix (w->desired_matrix); 5048 clear_glyph_matrix (w->desired_matrix);
5049 clear_glyph_matrix (w->current_matrix); 5049 clear_glyph_matrix (w->current_matrix);
@@ -5316,7 +5316,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5316 ptrdiff_t count = SPECPDL_INDEX (); 5316 ptrdiff_t count = SPECPDL_INDEX ();
5317 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5317 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5318 5318
5319 check_x (); 5319 check_window_system ();
5320 5320
5321 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); 5321 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5322 5322
@@ -5486,7 +5486,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5486 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5486 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5487 char *cdef_file; 5487 char *cdef_file;
5488 5488
5489 check_x (); 5489 check_window_system ();
5490 5490
5491 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); 5491 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5492 5492
@@ -5548,7 +5548,7 @@ nil, it defaults to the selected frame. */)
5548 struct gcpro gcpro1, gcpro2; 5548 struct gcpro gcpro1, gcpro2;
5549 ptrdiff_t count = SPECPDL_INDEX (); 5549 ptrdiff_t count = SPECPDL_INDEX ();
5550 5550
5551 check_x (); 5551 check_window_system ();
5552 5552
5553 if (popup_activated ()) 5553 if (popup_activated ())
5554 error ("Trying to use a menu from within a menu-entry"); 5554 error ("Trying to use a menu from within a menu-entry");
@@ -5591,7 +5591,7 @@ nil, it defaults to the selected frame. */)
5591 Keyboard 5591 Keyboard
5592 ***********************************************************************/ 5592 ***********************************************************************/
5593 5593
5594#ifdef HAVE_XKBGETKEYBOARD 5594#ifdef HAVE_XKB
5595#include <X11/XKBlib.h> 5595#include <X11/XKBlib.h>
5596#include <X11/keysym.h> 5596#include <X11/keysym.h>
5597#endif 5597#endif
@@ -5605,7 +5605,9 @@ usual X keysyms. Value is `lambda' if we cannot determine if both keys are
5605present and mapped to the usual X keysyms. */) 5605present and mapped to the usual X keysyms. */)
5606 (Lisp_Object frame) 5606 (Lisp_Object frame)
5607{ 5607{
5608#ifdef HAVE_XKBGETKEYBOARD 5608#ifndef HAVE_XKB
5609 return Qlambda;
5610#else
5609 XkbDescPtr kb; 5611 XkbDescPtr kb;
5610 struct frame *f = check_x_frame (frame); 5612 struct frame *f = check_x_frame (frame);
5611 Display *dpy = FRAME_X_DISPLAY (f); 5613 Display *dpy = FRAME_X_DISPLAY (f);
@@ -5683,9 +5685,7 @@ present and mapped to the usual X keysyms. */)
5683 } 5685 }
5684 unblock_input (); 5686 unblock_input ();
5685 return have_keys; 5687 return have_keys;
5686#else /* not HAVE_XKBGETKEYBOARD */ 5688#endif
5687 return Qlambda;
5688#endif /* not HAVE_XKBGETKEYBOARD */
5689} 5689}
5690 5690
5691 5691
@@ -5919,9 +5919,6 @@ When using Gtk+ tooltips, the tooltip face is not used. */);
5919 defsubr (&Sx_focus_frame); 5919 defsubr (&Sx_focus_frame);
5920 defsubr (&Sx_backspace_delete_keys_p); 5920 defsubr (&Sx_backspace_delete_keys_p);
5921 5921
5922 /* Setting callback functions for fontset handler. */
5923 check_window_system_func = check_x;
5924
5925 defsubr (&Sx_show_tip); 5922 defsubr (&Sx_show_tip);
5926 defsubr (&Sx_hide_tip); 5923 defsubr (&Sx_hide_tip);
5927 tip_timer = Qnil; 5924 tip_timer = Qnil;
diff --git a/src/xmenu.c b/src/xmenu.c
index 958cd220393..e6291edf7d6 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -223,7 +223,7 @@ for instance using the window manager, then this produces a quit and
223 FRAME_PTR f = NULL; 223 FRAME_PTR f = NULL;
224 Lisp_Object window; 224 Lisp_Object window;
225 225
226 check_x (); 226 check_window_system ();
227 227
228 /* Decode the first argument: find the window or frame to use. */ 228 /* Decode the first argument: find the window or frame to use. */
229 if (EQ (position, Qt) 229 if (EQ (position, Qt)
@@ -976,7 +976,7 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p)
976 if (! menubar_widget) 976 if (! menubar_widget)
977 previous_menu_items_used = 0; 977 previous_menu_items_used = 0;
978 978
979 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; 979 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
980 specbind (Qinhibit_quit, Qt); 980 specbind (Qinhibit_quit, Qt);
981 /* Don't let the debugger step into this code 981 /* Don't let the debugger step into this code
982 because it is not reentrant. */ 982 because it is not reentrant. */
@@ -1055,7 +1055,7 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p)
1055 wv->help = Qnil; 1055 wv->help = Qnil;
1056 first_wv = wv; 1056 first_wv = wv;
1057 1057
1058 for (i = 0; 0 <= submenu_start[i]; i++) 1058 for (i = 0; submenu_start[i] >= 0; i++)
1059 { 1059 {
1060 menu_items_n_panes = submenu_n_panes[i]; 1060 menu_items_n_panes = submenu_n_panes[i];
1061 wv = digest_single_submenu (submenu_start[i], submenu_end[i], 1061 wv = digest_single_submenu (submenu_start[i], submenu_end[i],
@@ -2479,7 +2479,7 @@ xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
2479#endif 2479#endif
2480 2480
2481 record_unwind_protect (pop_down_menu, 2481 record_unwind_protect (pop_down_menu,
2482 make_save_value ("pp", f, menu)); 2482 make_save_value (SAVE_TYPE_PTR_PTR, f, menu));
2483 2483
2484 /* Help display under X won't work because XMenuActivate contains 2484 /* Help display under X won't work because XMenuActivate contains
2485 a loop that doesn't give Emacs a chance to process it. */ 2485 a loop that doesn't give Emacs a chance to process it. */
diff --git a/src/xselect.c b/src/xselect.c
index 5b90d7def22..cca1a47212b 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1388,7 +1388,7 @@ x_get_window_property (Display *display, Window window, Atom property,
1388 data = data1; 1388 data = data1;
1389 } 1389 }
1390 1390
1391 if (32 < BITS_PER_LONG && *actual_format_ret == 32) 1391 if (BITS_PER_LONG > 32 && *actual_format_ret == 32)
1392 { 1392 {
1393 unsigned long i; 1393 unsigned long i;
1394 int *idata = (int *) (data + offset); 1394 int *idata = (int *) (data + offset);
@@ -2541,7 +2541,7 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event,
2541 function expects them to be of size int (i.e. 32). So to be able to 2541 function expects them to be of size int (i.e. 32). So to be able to
2542 use that function, put the data in the form it expects if format is 32. */ 2542 use that function, put the data in the form it expects if format is 32. */
2543 2543
2544 if (32 < BITS_PER_LONG && event->format == 32) 2544 if (BITS_PER_LONG > 32 && event->format == 32)
2545 { 2545 {
2546 for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ 2546 for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */
2547 idata[i] = event->data.l[i]; 2547 idata[i] = event->data.l[i];
@@ -2571,7 +2571,7 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event,
2571 return 1; 2571 return 1;
2572} 2572}
2573 2573
2574DEFUN ("x-send-client-message", Fx_send_client_event, 2574DEFUN ("x-send-client-message", Fx_send_client_message,
2575 Sx_send_client_message, 6, 6, 0, 2575 Sx_send_client_message, 6, 6, 0,
2576 doc: /* Send a client message of MESSAGE-TYPE to window DEST on DISPLAY. 2576 doc: /* Send a client message of MESSAGE-TYPE to window DEST on DISPLAY.
2577 2577
diff --git a/src/xterm.c b/src/xterm.c
index 88433b6c0b3..e4a681031ef 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -130,6 +130,10 @@ extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *);
130 130
131#include "bitmaps/gray.xbm" 131#include "bitmaps/gray.xbm"
132 132
133#ifdef HAVE_XKB
134#include <X11/XKBlib.h>
135#endif
136
133/* Default to using XIM if available. */ 137/* Default to using XIM if available. */
134#ifdef USE_XIM 138#ifdef USE_XIM
135int use_xim = 1; 139int use_xim = 1;
@@ -3218,7 +3222,11 @@ XTring_bell (struct frame *f)
3218 else 3222 else
3219 { 3223 {
3220 block_input (); 3224 block_input ();
3225#ifdef HAVE_XKB
3226 XkbBell (FRAME_X_DISPLAY (f), None, 0, None);
3227#else
3221 XBell (FRAME_X_DISPLAY (f), 0); 3228 XBell (FRAME_X_DISPLAY (f), 0);
3229#endif
3222 XFlush (FRAME_X_DISPLAY (f)); 3230 XFlush (FRAME_X_DISPLAY (f));
3223 unblock_input (); 3231 unblock_input ();
3224 } 3232 }
@@ -5076,7 +5084,7 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5076 5084
5077 /* Draw the empty space above the handle. Note that we can't clear 5085 /* Draw the empty space above the handle. Note that we can't clear
5078 zero-height areas; that means "clear to end of window." */ 5086 zero-height areas; that means "clear to end of window." */
5079 if (0 < start) 5087 if (start > 0)
5080 x_clear_area (FRAME_X_DISPLAY (f), w, 5088 x_clear_area (FRAME_X_DISPLAY (f), w,
5081 /* x, y, width, height, and exposures. */ 5089 /* x, y, width, height, and exposures. */
5082 VERTICAL_SCROLL_BAR_LEFT_BORDER, 5090 VERTICAL_SCROLL_BAR_LEFT_BORDER,
diff --git a/src/xterm.h b/src/xterm.h
index b241ff23559..6b64135927e 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -366,10 +366,6 @@ struct x_display_info
366extern int use_xim; 366extern int use_xim;
367#endif 367#endif
368 368
369/* This checks to make sure we have a display. */
370
371extern void check_x (void);
372
373extern struct frame *x_window_to_frame (struct x_display_info *, int); 369extern struct frame *x_window_to_frame (struct x_display_info *, int);
374extern struct frame *x_any_window_to_frame (struct x_display_info *, int); 370extern struct frame *x_any_window_to_frame (struct x_display_info *, int);
375extern struct frame *x_menubar_window_to_frame (struct x_display_info *, 371extern struct frame *x_menubar_window_to_frame (struct x_display_info *,