aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-06-13 01:00:15 -0700
committerPaul Eggert2011-06-13 01:00:15 -0700
commit01103c441a5c97c734c087fa074a941082fd0adb (patch)
tree697132e71abee8762913d4c58015945439cd2c3c /src
parent5efd304be978e2c0b3b1ac0c39b303b8d094ab66 (diff)
parent873e858a931f3af4b318473e052fb7acd35f7b53 (diff)
downloademacs-01103c441a5c97c734c087fa074a941082fd0adb.tar.gz
emacs-01103c441a5c97c734c087fa074a941082fd0adb.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog139
-rw-r--r--src/buffer.c452
-rw-r--r--src/frame.c14
-rw-r--r--src/frame.h1
-rw-r--r--src/image.c151
-rw-r--r--src/keyboard.h2
-rw-r--r--src/lisp.h5
-rw-r--r--src/makefile.w32-in7
-rw-r--r--src/menu.c3
-rw-r--r--src/process.c4
-rw-r--r--src/widget.c13
-rw-r--r--src/widgetprv.h5
-rw-r--r--src/window.c795
-rw-r--r--src/window.h7
-rw-r--r--src/xmenu.c4
-rw-r--r--src/xterm.c4
-rw-r--r--src/xterm.h6
17 files changed, 725 insertions, 887 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 125028297d1..6bac6f00a3f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -29,8 +29,8 @@
29 GLYPH_CODE_FACE returns EMACS_INT, not int. 29 GLYPH_CODE_FACE returns EMACS_INT, not int.
30 * dispextern.h (merge_faces): 30 * dispextern.h (merge_faces):
31 * xfaces.c (merge_faces): 31 * xfaces.c (merge_faces):
32 * xdisp.c (get_next_display_element): 32 * xdisp.c (get_next_display_element, next_element_from_display_vector):
33 (next_element_from_display_vector): Don't assume EMACS_INT fits in int. 33 Don't assume EMACS_INT fits in int.
34 34
35 * character.h (CHAR_VALID_P): Remove unused parameter. 35 * character.h (CHAR_VALID_P): Remove unused parameter.
36 * fontset.c, lisp.h, xdisp.c: All uses changed. 36 * fontset.c, lisp.h, xdisp.c: All uses changed.
@@ -85,7 +85,7 @@
85 arguments are no wider than unsigned, as a compile-time check 85 arguments are no wider than unsigned, as a compile-time check
86 to prevent future regressions in this area. 86 to prevent future regressions in this area.
87 * data.c (Faset): 87 * data.c (Faset):
88 * editfns.c (Fchar_to_string, general_insert_function, Finsert_char): 88 * editfns.c (Fchar_to_string, general_insert_function, Finsert_char)
89 (Fsubst_char_in_region): 89 (Fsubst_char_in_region):
90 * fns.c (concat): 90 * fns.c (concat):
91 * xdisp.c (decode_mode_spec_coding): 91 * xdisp.c (decode_mode_spec_coding):
@@ -95,8 +95,6 @@
95 characters. Without this test, these functions did the wrong 95 characters. Without this test, these functions did the wrong
96 thing with wildly out-of-range values on 64-bit hosts. 96 thing with wildly out-of-range values on 64-bit hosts.
97 97
982011-06-12 Paul Eggert <eggert@cs.ucla.edu>
99
100 Remove incorrect casts to 'unsigned' that lose info on 64-bit hosts. 98 Remove incorrect casts to 'unsigned' that lose info on 64-bit hosts.
101 These casts should not be needed on 32-bit hosts, either. 99 These casts should not be needed on 32-bit hosts, either.
102 * keyboard.c (read_char): 100 * keyboard.c (read_char):
@@ -106,14 +104,12 @@
106 This fixes comparison bugs on 64-bit hosts. 104 This fixes comparison bugs on 64-bit hosts.
107 (ASCII_CHAR_P): Use it. 105 (ASCII_CHAR_P): Use it.
108 * casefiddle.c (casify_object): 106 * casefiddle.c (casify_object):
109 * character.h (ASCII_BYTE_P, CHAR_VALID_P): 107 * character.h (ASCII_BYTE_P, CHAR_VALID_P)
110 (SINGLE_BYTE_CHAR_P, CHAR_STRING): 108 (SINGLE_BYTE_CHAR_P, CHAR_STRING):
111 * composite.h (COMPOSITION_ENCODE_RULE_VALID): 109 * composite.h (COMPOSITION_ENCODE_RULE_VALID):
112 * dispextern.h (FACE_FROM_ID): 110 * dispextern.h (FACE_FROM_ID):
113 * keyboard.c (read_char): Use UNSIGNED_CMP. 111 * keyboard.c (read_char): Use UNSIGNED_CMP.
114 112
1152011-06-11 Paul Eggert <eggert@cs.ucla.edu>
116
117 * xmenu.c (dialog_selection_callback) [!USE_GTK]: Cast to intptr_t, 113 * xmenu.c (dialog_selection_callback) [!USE_GTK]: Cast to intptr_t,
118 not to EMACS_INT, to avoid GCC warning. 114 not to EMACS_INT, to avoid GCC warning.
119 115
@@ -123,7 +119,8 @@
123 The cast incorrectly truncated 64-bit byte offsets to 32 bits, and 119 The cast incorrectly truncated 64-bit byte offsets to 32 bits, and
124 isn't needed on 32-bit machines. 120 isn't needed on 32-bit machines.
125 121
126 * buffer.c (Fgenerate_new_buffer_name): Use EMACS_INT for count, not int. 122 * buffer.c (Fgenerate_new_buffer_name):
123 Use EMACS_INT for count, not int.
127 (advance_to_char_boundary): Return EMACS_INT, not int. 124 (advance_to_char_boundary): Return EMACS_INT, not int.
128 125
129 * data.c (Qcompiled_function): Now static. 126 * data.c (Qcompiled_function): Now static.
@@ -143,8 +140,8 @@
143 * alloc.c: Use EMACS_INT, not int, to count objects. 140 * alloc.c: Use EMACS_INT, not int, to count objects.
144 (total_conses, total_markers, total_symbols, total_vector_size) 141 (total_conses, total_markers, total_symbols, total_vector_size)
145 (total_free_conses, total_free_markers, total_free_symbols) 142 (total_free_conses, total_free_markers, total_free_symbols)
146 (total_free_floats, total_floats, total_free_intervals, total_intervals) 143 (total_free_floats, total_floats, total_free_intervals)
147 (total_strings, total_free_strings): 144 (total_intervals, total_strings, total_free_strings):
148 Now EMACS_INT, not int. All uses changed. 145 Now EMACS_INT, not int. All uses changed.
149 (Fgarbage_collect): Compute overall total using a double, so that 146 (Fgarbage_collect): Compute overall total using a double, so that
150 integer overflow is less likely to be a problem. Check for overflow 147 integer overflow is less likely to be a problem. Check for overflow
@@ -184,6 +181,126 @@
184 181
185 * alloc.c (Fmake_string): Check for out-of-range init. 182 * alloc.c (Fmake_string): Check for out-of-range init.
186 183
1842011-06-12 Martin Rudalics <rudalics@gmx.at>
185
186 * frame.c (make_frame): Call other_buffer_safely instead of
187 other_buffer.
188
189 * window.c (temp_output_buffer_show): Call display_buffer with
190 second argument Vtemp_buffer_show_specifiers and reset latter
191 immediately after the call.
192 (Vtemp_buffer_show_specifiers): New variable.
193 (auto_window_vscroll_p, next_screen_context_lines)
194 (Vscroll_preserve_screen_position): Remove leading asterisks from
195 doc-strings.
196
1972011-06-12 Paul Eggert <eggert@cs.ucla.edu>
198
199 Fix minor problems found by GCC 4.6.0 static checking.
200 * buffer.c (Qclone_number): Remove for now, as it's unused.
201 (record_buffer, Funrecord_buffer): Rename local to avoid shadowing.
202 (record_buffer): Remove unused local.
203 * frame.c (other_visible_frames, frame_buffer_list): Now static.
204 (set_frame_buffer_list): Remove; unused.
205 * frame.h (other_visible_frames): Remove decl.
206 * keyboard.h (menu_items_inuse): Declare only if USE_GTK || USE_MOTIF.
207 * lisp.h (frame_buffer_list, set_frame_buffer_list): Remove decls.
208 (add_gpm_wait_descriptor, delete_gpm_wait_descriptor): Declare only
209 if HAVE_GPM.
210 * menu.c (menu_items_inuse): Now static unless USE_GTK || USE_MOTIF.
211 * process.c (add_gpm_wait_descriptor, delete_gpm_wait_descriptor):
212 Define only if HAVE_GPM.
213 * widget.c (EmacsFrameResize, emacsFrameClassRec): Now static.
214 (update_hints_inhibit): Remove; never set. All uses removed.
215 * widgetprv.h (emacsFrameClassRec): Remove decl.
216 * window.c (delete_deletable_window): Now returns void, since it
217 wasn't returning anything.
218 (compare_window_configurations): Remove unused locals.
219 * xfns.c (x_set_scroll_bar_default_width): Remove unused locals.
220 * xmenu.c (x_menu_set_in_use): Define only if USE_GTK || USE_MOTIF.
221 (dialog_selection_callback) [!USE_GTK]: Prefer intptr_t for integers
222 the same widths as pointers. This follows up on the 2011-05-06 patch.
223 * xterm.c (x_alloc_lighter_color_for_widget): Define only if USE_LUCID.
224 * xterm.h: Likewise.
225 (x_menu_set_in_use): Declare only if USE_GTK || USE_MOTIF.
226
2272011-06-12 Juanma Barranquero <lekktu@gmail.com>
228
229 * makefile.w32-in: Update dependencies.
230 (LISP_H): Add lib/intprops.h.
231
2322011-06-11 Chong Yidong <cyd@stupidchicken.com>
233
234 * image.c (gif_load): Add animation frame delay to the metadata.
235 (syms_of_image): Use DEFSYM. New symbol `delay'.
236
2372011-06-11 Martin Rudalics <rudalics@gmx.at>
238
239 * window.c (delete_deletable_window): Re-add.
240 (Fset_window_configuration): Rewrite to handle dead buffers and
241 consequently deletable windows.
242 (window_tree, Fwindow_tree): Remove. Supply functionality in
243 window.el.
244 (compare_window_configurations): Simplify code.
245
2462011-06-11 Andreas Schwab <schwab@linux-m68k.org>
247
248 * image.c (imagemagick_load_image): Fix type mismatch.
249 (Fimagemagick_types): Likewise.
250
251 * window.h (replace_buffer_in_windows): Declare.
252
2532011-06-11 Martin Rudalics <rudalics@gmx.at>
254
255 * buffer.c: New Lisp objects Qbuffer_list_update_hook and
256 Qclone_number. Remove external declaration of Qdelete_window.
257 (Fbuffer_list): Rewrite doc-string. Minor restructuring of
258 code.
259 (Fget_buffer_create, Fmake_indirect_buffer, Frename_buffer): Run
260 Qbuffer_list_update_hook if allowed.
261 (Fother_buffer): Rewrite doc-string. Major rewrite for new
262 buffer list implementation.
263 (other_buffer_safely): New function.
264 (Fkill_buffer): Replace call to replace_buffer_in_all_windows by
265 calls to replace_buffer_in_windows and
266 replace_buffer_in_windows_safely. Run Qbuffer_list_update_hook
267 if allowed.
268 (record_buffer): Inhibit quitting and rewrite using quittable
269 functions. Run Qbuffer_list_update_hook if allowed.
270 (Frecord_buffer, Funrecord_buffer): New functions.
271 (switch_to_buffer_1, Fswitch_to_buffer): Remove. Move
272 switch-to-buffer to window.el.
273 (bury-buffer): Move to window.el.
274 (Vbuffer_list_update_hook): New variable.
275
276 * lisp.h (other_buffer_safely): Add prototype in buffer.c
277 section.
278
279 * window.h (resize_frame_windows): Move up in code.
280 (Fwindow_frame): Remove EXFUN.
281 (replace_buffer_in_all_windows): Remove prototype.
282 (replace_buffer_in_windows_safely): Add prototype.
283
284 * window.c: Declare Qdelete_window static again. Move down
285 declaration of select_count.
286 (Fnext_window, Fprevious_window): Rewrite doc-strings.
287 (Fother_window): Move to window.el.
288 (window_loop): Remove DELETE_BUFFER_WINDOWS and UNSHOW_BUFFER
289 cases. Add REPLACE_BUFFER_IN_WINDOWS_SAFELY case.
290 (Fdelete_windows_on, Freplace_buffer_in_windows): Move to
291 window.el.
292 (replace_buffer_in_windows): Implement by calling
293 Qreplace_buffer_in_windows.
294 (replace_buffer_in_all_windows): Remove with some functionality
295 moved into replace_buffer_in_windows_safely.
296 (replace_buffer_in_windows_safely): New function.
297 (select_window_norecord, select_frame_norecord): Move in front
298 of run_window_configuration_change_hook. Remove now obsolete
299 declarations.
300 (Fset_window_buffer): Rewrite doc-string. Call
301 Qrecord_window_buffer.
302 (keys_of_window): Move binding for other-window to window.el.
303
1872011-06-11 Chong Yidong <cyd@stupidchicken.com> 3042011-06-11 Chong Yidong <cyd@stupidchicken.com>
188 305
189 * dispextern.h (struct image): Replace data member, whose int_val 306 * dispextern.h (struct image): Replace data member, whose int_val
diff --git a/src/buffer.c b/src/buffer.c
index 0c4cdb544a5..d7adf63c98b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -131,12 +131,14 @@ static Lisp_Object Qprotected_field;
131static Lisp_Object QSFundamental; /* A string "Fundamental" */ 131static Lisp_Object QSFundamental; /* A string "Fundamental" */
132 132
133static Lisp_Object Qkill_buffer_hook; 133static Lisp_Object Qkill_buffer_hook;
134static Lisp_Object Qbuffer_list_update_hook;
134 135
135static Lisp_Object Qget_file_buffer; 136static Lisp_Object Qget_file_buffer;
136 137
137static Lisp_Object Qoverlayp; 138static Lisp_Object Qoverlayp;
138 139
139Lisp_Object Qpriority, Qbefore_string, Qafter_string; 140Lisp_Object Qpriority, Qbefore_string, Qafter_string;
141
140static Lisp_Object Qevaporate; 142static Lisp_Object Qevaporate;
141 143
142Lisp_Object Qmodification_hooks; 144Lisp_Object Qmodification_hooks;
@@ -171,9 +173,9 @@ Value is nil if OBJECT is not a buffer or if it has been killed. */)
171 173
172DEFUN ("buffer-list", Fbuffer_list, Sbuffer_list, 0, 1, 0, 174DEFUN ("buffer-list", Fbuffer_list, Sbuffer_list, 0, 1, 0,
173 doc: /* Return a list of all existing live buffers. 175 doc: /* Return a list of all existing live buffers.
174If the optional arg FRAME is a frame, we return the buffer list 176If the optional arg FRAME is a frame, we return the buffer list in the
175in the proper order for that frame: the buffers in FRAME's `buffer-list' 177proper order for that frame: the buffers show in FRAME come first,
176frame parameter come first, followed by the rest of the buffers. */) 178followed by the rest of the buffers. */)
177 (Lisp_Object frame) 179 (Lisp_Object frame)
178{ 180{
179 Lisp_Object general; 181 Lisp_Object general;
@@ -185,9 +187,9 @@ frame parameter come first, followed by the rest of the buffers. */)
185 Lisp_Object args[3]; 187 Lisp_Object args[3];
186 188
187 CHECK_FRAME (frame); 189 CHECK_FRAME (frame);
188
189 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list); 190 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list);
190 prevlist = Fnreverse (Fcopy_sequence (XFRAME (frame)->buried_buffer_list)); 191 prevlist = Fnreverse (Fcopy_sequence
192 (XFRAME (frame)->buried_buffer_list));
191 193
192 /* Remove from GENERAL any buffer that duplicates one in 194 /* Remove from GENERAL any buffer that duplicates one in
193 FRAMELIST or PREVLIST. */ 195 FRAMELIST or PREVLIST. */
@@ -209,8 +211,8 @@ frame parameter come first, followed by the rest of the buffers. */)
209 args[2] = prevlist; 211 args[2] = prevlist;
210 return Fnconc (3, args); 212 return Fnconc (3, args);
211 } 213 }
212 214 else
213 return general; 215 return general;
214} 216}
215 217
216/* Like Fassoc, but use Fstring_equal to compare 218/* Like Fassoc, but use Fstring_equal to compare
@@ -384,6 +386,9 @@ even if it is dead. The return value is never nil. */)
384 /* Put this in the alist of all live buffers. */ 386 /* Put this in the alist of all live buffers. */
385 XSETBUFFER (buffer, b); 387 XSETBUFFER (buffer, b);
386 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buffer), Qnil)); 388 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buffer), Qnil));
389 /* And run buffer-list-update-hook. */
390 if (!NILP (Vrun_hooks))
391 call1 (Vrun_hooks, Qbuffer_list_update_hook);
387 392
388 /* An error in calling the function here (should someone redefine it) 393 /* An error in calling the function here (should someone redefine it)
389 can lead to infinite regress until you run out of stack. rms 394 can lead to infinite regress until you run out of stack. rms
@@ -659,6 +664,10 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
659 set_buffer_internal_1 (old_b); 664 set_buffer_internal_1 (old_b);
660 } 665 }
661 666
667 /* Run buffer-list-update-hook. */
668 if (!NILP (Vrun_hooks))
669 call1 (Vrun_hooks, Qbuffer_list_update_hook);
670
662 return buf; 671 return buf;
663} 672}
664 673
@@ -1262,81 +1271,119 @@ This does not change the name of the visited file (if any). */)
1262 if (NILP (BVAR (current_buffer, filename)) 1271 if (NILP (BVAR (current_buffer, filename))
1263 && !NILP (BVAR (current_buffer, auto_save_file_name))) 1272 && !NILP (BVAR (current_buffer, auto_save_file_name)))
1264 call0 (intern ("rename-auto-save-file")); 1273 call0 (intern ("rename-auto-save-file"));
1274
1275 /* Run buffer-list-update-hook. */
1276 if (!NILP (Vrun_hooks))
1277 call1 (Vrun_hooks, Qbuffer_list_update_hook);
1278
1265 /* Refetch since that last call may have done GC. */ 1279 /* Refetch since that last call may have done GC. */
1266 return BVAR (current_buffer, name); 1280 return BVAR (current_buffer, name);
1267} 1281}
1268 1282
1269DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, 1283DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0,
1270 doc: /* Return most recently selected buffer other than BUFFER. 1284 doc: /* Return most recently selected buffer other than BUFFER.
1271Buffers not visible in windows are preferred to visible buffers, 1285Buffers not visible in windows are preferred to visible buffers, unless
1272unless optional second argument VISIBLE-OK is non-nil. 1286optional second argument VISIBLE-OK is non-nil. Ignore the argument
1273If the optional third argument FRAME is non-nil, use that frame's 1287BUFFER unless it denotes a live buffer. If the optional third argument
1274buffer list instead of the selected frame's buffer list. 1288FRAME is non-nil, use that frame's buffer list instead of the selected
1275If no other buffer exists, the buffer `*scratch*' is returned. 1289frame's buffer list.
1276If BUFFER is omitted or nil, some interesting buffer is returned. */) 1290
1291The buffer is found by scanning the selected or specified frame's buffer
1292list first, followed by the list of all buffers. If no other buffer
1293exists, return the buffer `*scratch*' (creating it if necessary). */)
1277 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) 1294 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
1278{ 1295{
1279 register Lisp_Object tail, buf, notsogood, tem, pred, add_ons; 1296 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1280 notsogood = Qnil; 1297 Lisp_Object tail, buf, pred;
1298 Lisp_Object notsogood = Qnil;
1281 1299
1282 if (NILP (frame)) 1300 if (NILP (frame))
1283 frame = selected_frame; 1301 frame = selected_frame;
1284 1302
1285 CHECK_FRAME (frame); 1303 CHECK_FRAME (frame);
1286 1304
1287 tail = Vbuffer_alist;
1288 pred = frame_buffer_predicate (frame); 1305 pred = frame_buffer_predicate (frame);
1289 1306 /* Consider buffers that have been seen in the frame first. */
1290 /* Consider buffers that have been seen in the selected frame 1307 tail = XFRAME (frame)->buffer_list;
1291 before other buffers. */ 1308 for (; CONSP (tail); tail = XCDR (tail))
1292
1293 tem = frame_buffer_list (frame);
1294 add_ons = Qnil;
1295 while (CONSP (tem))
1296 { 1309 {
1297 if (BUFFERP (XCAR (tem))) 1310 buf = XCAR (tail);
1298 add_ons = Fcons (Fcons (Qnil, XCAR (tem)), add_ons); 1311 if (BUFFERP (buf) && !EQ (buf, buffer)
1299 tem = XCDR (tem); 1312 && !NILP (BVAR (XBUFFER (buf), name))
1313 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
1314 /* If the frame has a buffer_predicate, disregard buffers that
1315 don't fit the predicate. */
1316 && (NILP (pred) || !NILP (call1 (pred, buf))))
1317 {
1318 if (!NILP (visible_ok)
1319 || NILP (Fget_buffer_window (buf, Qvisible)))
1320 return buf;
1321 else if (NILP (notsogood))
1322 notsogood = buf;
1323 }
1300 } 1324 }
1301 tail = nconc2 (Fnreverse (add_ons), tail);
1302 1325
1326 /* Consider alist of all buffers next. */
1327 tail = Vbuffer_alist;
1303 for (; CONSP (tail); tail = XCDR (tail)) 1328 for (; CONSP (tail); tail = XCDR (tail))
1304 { 1329 {
1305 buf = Fcdr (XCAR (tail)); 1330 buf = Fcdr (XCAR (tail));
1306 if (EQ (buf, buffer)) 1331 if (BUFFERP (buf) && !EQ (buf, buffer)
1307 continue; 1332 && !NILP (BVAR (XBUFFER (buf), name))
1333 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
1334 /* If the frame has a buffer_predicate, disregard buffers that
1335 don't fit the predicate. */
1336 && (NILP (pred) || !NILP (call1 (pred, buf))))
1337 {
1338 if (!NILP (visible_ok)
1339 || NILP (Fget_buffer_window (buf, Qvisible)))
1340 return buf;
1341 else if (NILP (notsogood))
1342 notsogood = buf;
1343 }
1344 }
1345
1346 if (!NILP (notsogood))
1347 return notsogood;
1348 else
1349 {
1350 buf = Fget_buffer (build_string ("*scratch*"));
1308 if (NILP (buf)) 1351 if (NILP (buf))
1309 continue;
1310 if (NILP (BVAR (XBUFFER (buf), name)))
1311 continue;
1312 if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ')
1313 continue;
1314 /* If the selected frame has a buffer_predicate,
1315 disregard buffers that don't fit the predicate. */
1316 if (!NILP (pred))
1317 { 1352 {
1318 tem = call1 (pred, buf); 1353 buf = Fget_buffer_create (build_string ("*scratch*"));
1319 if (NILP (tem)) 1354 Fset_buffer_major_mode (buf);
1320 continue;
1321 } 1355 }
1356 return buf;
1357 }
1358}
1322 1359
1323 if (NILP (visible_ok)) 1360/* The following function is a safe variant of Fother_buffer: It doesn't
1324 tem = Fget_buffer_window (buf, Qvisible); 1361 pay attention to any frame-local buffer lists, doesn't care about
1325 else 1362 visibility of buffers, and doesn't evaluate any frame predicates. */
1326 tem = Qnil; 1363
1327 if (NILP (tem)) 1364Lisp_Object
1365other_buffer_safely (Lisp_Object buffer)
1366{
1367 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1368 Lisp_Object tail, buf;
1369
1370 tail = Vbuffer_alist;
1371 for (; CONSP (tail); tail = XCDR (tail))
1372 {
1373 buf = Fcdr (XCAR (tail));
1374 if (BUFFERP (buf) && !EQ (buf, buffer)
1375 && !NILP (BVAR (XBUFFER (buf), name))
1376 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' '))
1328 return buf; 1377 return buf;
1329 if (NILP (notsogood))
1330 notsogood = buf;
1331 } 1378 }
1332 if (!NILP (notsogood)) 1379
1333 return notsogood;
1334 buf = Fget_buffer (build_string ("*scratch*")); 1380 buf = Fget_buffer (build_string ("*scratch*"));
1335 if (NILP (buf)) 1381 if (NILP (buf))
1336 { 1382 {
1337 buf = Fget_buffer_create (build_string ("*scratch*")); 1383 buf = Fget_buffer_create (build_string ("*scratch*"));
1338 Fset_buffer_major_mode (buf); 1384 Fset_buffer_major_mode (buf);
1339 } 1385 }
1386
1340 return buf; 1387 return buf;
1341} 1388}
1342 1389
@@ -1509,13 +1556,20 @@ with SIGHUP. */)
1509 if (NILP (BVAR (b, name))) 1556 if (NILP (BVAR (b, name)))
1510 return Qnil; 1557 return Qnil;
1511 1558
1559 /* These may run Lisp code and into infinite loops (if someone
1560 insisted on circular lists) so allow quitting here. */
1561 replace_buffer_in_windows (buffer);
1562 frames_discard_buffer (buffer);
1563
1512 clear_charpos_cache (b); 1564 clear_charpos_cache (b);
1513 1565
1514 tem = Vinhibit_quit; 1566 tem = Vinhibit_quit;
1515 Vinhibit_quit = Qt; 1567 Vinhibit_quit = Qt;
1516 replace_buffer_in_all_windows (buffer); 1568 /* Remove the buffer from the list of all buffers. */
1517 Vbuffer_alist = Fdelq (Frassq (buffer, Vbuffer_alist), Vbuffer_alist); 1569 Vbuffer_alist = Fdelq (Frassq (buffer, Vbuffer_alist), Vbuffer_alist);
1518 frames_discard_buffer (buffer); 1570 /* If replace_buffer_in_windows didn't do its job correctly fix that
1571 now. */
1572 replace_buffer_in_windows_safely (buffer);
1519 Vinhibit_quit = tem; 1573 Vinhibit_quit = tem;
1520 1574
1521 /* Delete any auto-save file, if we saved it in this session. 1575 /* Delete any auto-save file, if we saved it in this session.
@@ -1589,83 +1643,102 @@ with SIGHUP. */)
1589 UNBLOCK_INPUT; 1643 UNBLOCK_INPUT;
1590 BVAR (b, undo_list) = Qnil; 1644 BVAR (b, undo_list) = Qnil;
1591 1645
1646 /* Run buffer-list-update-hook. */
1647 if (!NILP (Vrun_hooks))
1648 call1 (Vrun_hooks, Qbuffer_list_update_hook);
1649
1592 return Qt; 1650 return Qt;
1593} 1651}
1594 1652
1595/* Move the assoc for buffer BUF to the front of buffer-alist. Since 1653/* Move association for BUFFER to the front of buffer (a)lists. Since
1596 we do this each time BUF is selected visibly, the more recently 1654 we do this each time BUFFER is selected visibly, the more recently
1597 selected buffers are always closer to the front of the list. This 1655 selected buffers are always closer to the front of those lists. This
1598 means that other_buffer is more likely to choose a relevant buffer. */ 1656 means that other_buffer is more likely to choose a relevant buffer.
1657
1658 Note that this moves BUFFER to the front of the buffer lists of the
1659 selected frame even if BUFFER is not shown there. If BUFFER is not
1660 shown in the selected frame, consider the present behavior a feature.
1661 `select-window' gets this right since it shows BUFFER in the selected
1662 window when calling us. */
1599 1663
1600void 1664void
1601record_buffer (Lisp_Object buf) 1665record_buffer (Lisp_Object buffer)
1602{ 1666{
1603 register Lisp_Object list, prev; 1667 Lisp_Object aelt, aelt_cons, tem;
1604 Lisp_Object frame; 1668 register struct frame *f = XFRAME (selected_frame);
1605 frame = selected_frame;
1606 1669
1607 prev = Qnil; 1670 CHECK_BUFFER (buffer);
1608 for (list = Vbuffer_alist; CONSP (list); list = XCDR (list))
1609 {
1610 if (EQ (XCDR (XCAR (list)), buf))
1611 break;
1612 prev = list;
1613 }
1614 1671
1615 /* Effectively do Vbuffer_alist = Fdelq (list, Vbuffer_alist); 1672 /* Update Vbuffer_alist (we know that it has an entry for BUFFER).
1616 we cannot use Fdelq itself here because it allows quitting. */ 1673 Don't allow quitting since this might leave the buffer list in an
1674 inconsistent state. */
1675 tem = Vinhibit_quit;
1676 Vinhibit_quit = Qt;
1677 aelt = Frassq (buffer, Vbuffer_alist);
1678 aelt_cons = Fmemq (aelt, Vbuffer_alist);
1679 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist);
1680 XSETCDR (aelt_cons, Vbuffer_alist);
1681 Vbuffer_alist = aelt_cons;
1682 Vinhibit_quit = tem;
1617 1683
1618 if (NILP (prev)) 1684 /* Update buffer list of selected frame. */
1619 Vbuffer_alist = XCDR (Vbuffer_alist); 1685 f->buffer_list = Fcons (buffer, Fdelq (buffer, f->buffer_list));
1620 else 1686 f->buried_buffer_list = Fdelq (buffer, f->buried_buffer_list);
1621 XSETCDR (prev, XCDR (XCDR (prev)));
1622 1687
1623 XSETCDR (list, Vbuffer_alist); 1688 /* Run buffer-list-update-hook. */
1624 Vbuffer_alist = list; 1689 if (!NILP (Vrun_hooks))
1690 call1 (Vrun_hooks, Qbuffer_list_update_hook);
1691}
1625 1692
1626 /* Effectively do a delq on buried_buffer_list. */ 1693DEFUN ("record-buffer", Frecord_buffer, Srecord_buffer, 1, 1, 0,
1694 doc: /* Move BUFFER to the front of the buffer list.
1695Return BUFFER. */)
1696 (Lisp_Object buffer)
1697{
1698 CHECK_BUFFER (buffer);
1627 1699
1628 prev = Qnil; 1700 record_buffer (buffer);
1629 for (list = XFRAME (frame)->buried_buffer_list; CONSP (list);
1630 list = XCDR (list))
1631 {
1632 if (EQ (XCAR (list), buf))
1633 {
1634 if (NILP (prev))
1635 XFRAME (frame)->buried_buffer_list = XCDR (list);
1636 else
1637 XSETCDR (prev, XCDR (XCDR (prev)));
1638 break;
1639 }
1640 prev = list;
1641 }
1642 1701
1643 /* Now move this buffer to the front of frame_buffer_list also. */ 1702 return buffer;
1703}
1644 1704
1645 prev = Qnil; 1705 /* Move BUFFER to the end of the buffer (a)lists. Do nothing if the
1646 for (list = frame_buffer_list (frame); CONSP (list); 1706 buffer is killed. For the selected frame's buffer list this moves
1647 list = XCDR (list)) 1707 BUFFER to its end even if it was never shown in that frame. If
1648 { 1708 this happens we have a feature, hence `unrecord-buffer' should be
1649 if (EQ (XCAR (list), buf)) 1709 called only when BUFFER was shown in the selected frame. */
1650 break;
1651 prev = list;
1652 }
1653 1710
1654 /* Effectively do delq. */ 1711DEFUN ("unrecord-buffer", Funrecord_buffer, Sunrecord_buffer, 1, 1, 0,
1712 doc: /* Move BUFFER to the end of the buffer list.
1713Return BUFFER. */)
1714 (Lisp_Object buffer)
1715{
1716 Lisp_Object aelt, aelt_cons, tem;
1717 register struct frame *f = XFRAME (selected_frame);
1655 1718
1656 if (CONSP (list)) 1719 CHECK_BUFFER (buffer);
1657 {
1658 if (NILP (prev))
1659 set_frame_buffer_list (frame,
1660 XCDR (frame_buffer_list (frame)));
1661 else
1662 XSETCDR (prev, XCDR (XCDR (prev)));
1663 1720
1664 XSETCDR (list, frame_buffer_list (frame)); 1721 /* Update Vbuffer_alist (we know that it has an entry for BUFFER).
1665 set_frame_buffer_list (frame, list); 1722 Don't allow quitting since this might leave the buffer list in an
1666 } 1723 inconsistent state. */
1667 else 1724 tem = Vinhibit_quit;
1668 set_frame_buffer_list (frame, Fcons (buf, frame_buffer_list (frame))); 1725 Vinhibit_quit = Qt;
1726 aelt = Frassq (buffer, Vbuffer_alist);
1727 aelt_cons = Fmemq (aelt, Vbuffer_alist);
1728 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist);
1729 XSETCDR (aelt_cons, Qnil);
1730 Vbuffer_alist = nconc2 (Vbuffer_alist, aelt_cons);
1731 Vinhibit_quit = tem;
1732
1733 /* Update buffer lists of selected frame. */
1734 f->buffer_list = Fdelq (buffer, f->buffer_list);
1735 f->buried_buffer_list = Fcons (buffer, Fdelq (buffer, f->buried_buffer_list));
1736
1737 /* Run buffer-list-update-hook. */
1738 if (!NILP (Vrun_hooks))
1739 call1 (Vrun_hooks, Qbuffer_list_update_hook);
1740
1741 return buffer;
1669} 1742}
1670 1743
1671DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, 1744DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0,
@@ -1708,86 +1781,6 @@ the current buffer's major mode. */)
1708 return unbind_to (count, Qnil); 1781 return unbind_to (count, Qnil);
1709} 1782}
1710 1783
1711/* Switch to buffer BUFFER in the selected window.
1712 If NORECORD is non-nil, don't call record_buffer. */
1713
1714static Lisp_Object
1715switch_to_buffer_1 (Lisp_Object buffer_or_name, Lisp_Object norecord)
1716{
1717 register Lisp_Object buffer;
1718
1719 if (NILP (buffer_or_name))
1720 buffer = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil);
1721 else
1722 {
1723 buffer = Fget_buffer (buffer_or_name);
1724 if (NILP (buffer))
1725 {
1726 buffer = Fget_buffer_create (buffer_or_name);
1727 Fset_buffer_major_mode (buffer);
1728 }
1729 }
1730 Fset_buffer (buffer);
1731 if (NILP (norecord))
1732 record_buffer (buffer);
1733
1734 Fset_window_buffer (EQ (selected_window, minibuf_window)
1735 ? Fnext_window (minibuf_window, Qnil, Qnil)
1736 : selected_window,
1737 buffer, Qnil);
1738
1739 return buffer;
1740}
1741
1742DEFUN ("switch-to-buffer", Fswitch_to_buffer, Sswitch_to_buffer, 1, 2,
1743 "(list (read-buffer-to-switch \"Switch to buffer: \"))",
1744 doc: /* Make BUFFER-OR-NAME current and display it in selected window.
1745BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or
1746nil. Return the buffer switched to.
1747
1748If BUFFER-OR-NAME is a string and does not identify an existing
1749buffer, create a new buffer with that name. Interactively, if
1750`confirm-nonexistent-file-or-buffer' is non-nil, request
1751confirmation before creating a new buffer. If BUFFER-OR-NAME is
1752nil, switch to buffer returned by `other-buffer'.
1753
1754Optional second arg NORECORD non-nil means do not put this buffer
1755at the front of the list of recently selected ones. This
1756function returns the buffer it switched to as a Lisp object.
1757
1758If the selected window is the minibuffer window or dedicated to
1759its buffer, use `pop-to-buffer' for displaying the buffer.
1760
1761WARNING: This is NOT the way to work on another buffer temporarily
1762within a Lisp program! Use `set-buffer' instead. That avoids
1763messing with the window-buffer correspondences. */)
1764 (Lisp_Object buffer_or_name, Lisp_Object norecord)
1765{
1766 if (EQ (buffer_or_name, Fwindow_buffer (selected_window)))
1767 {
1768 /* Basically a NOP. Avoid signalling an error in the case where
1769 the selected window is dedicated, or a minibuffer. */
1770
1771 /* But do put this buffer at the front of the buffer list, unless
1772 that has been inhibited. Note that even if BUFFER-OR-NAME is
1773 at the front of the main buffer-list already, we still want to
1774 move it to the front of the frame's buffer list. */
1775 if (NILP (norecord))
1776 record_buffer (buffer_or_name);
1777 return Fset_buffer (buffer_or_name);
1778 }
1779 else if (EQ (minibuf_window, selected_window)
1780 /* If `dedicated' is neither nil nor t, it means it's
1781 dedicatedness can be overridden by an explicit request
1782 such as a call to switch-to-buffer. */
1783 || EQ (Fwindow_dedicated_p (selected_window), Qt))
1784 /* We can't use the selected window so let `pop-to-buffer' try some
1785 other window. */
1786 return call3 (intern ("pop-to-buffer"), buffer_or_name, Qnil, norecord);
1787 else
1788 return switch_to_buffer_1 (buffer_or_name, norecord);
1789}
1790
1791DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0, 1784DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
1792 doc: /* Return the current buffer as a Lisp object. */) 1785 doc: /* Return the current buffer as a Lisp object. */)
1793 (void) 1786 (void)
@@ -1937,70 +1930,6 @@ DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only,
1937 xsignal1 (Qbuffer_read_only, Fcurrent_buffer ()); 1930 xsignal1 (Qbuffer_read_only, Fcurrent_buffer ());
1938 return Qnil; 1931 return Qnil;
1939} 1932}
1940
1941extern Lisp_Object Qdelete_window;
1942
1943DEFUN ("bury-buffer", Fbury_buffer, Sbury_buffer, 0, 1, "",
1944 doc: /* Put BUFFER-OR-NAME at the end of the list of all buffers.
1945There it is the least likely candidate for `other-buffer' to return;
1946thus, the least likely buffer for \\[switch-to-buffer] to select by
1947default.
1948
1949The argument may be a buffer name or an actual buffer object. If
1950BUFFER-OR-NAME is nil or omitted, bury the current buffer and remove it
1951from the selected window if it is displayed there. If the selected
1952window is dedicated to its buffer, delete that window if there are other
1953windows on the same frame. If the selected window is the only window on
1954its frame, iconify that frame. */)
1955 (register Lisp_Object buffer_or_name)
1956{
1957 Lisp_Object buffer;
1958
1959 /* Figure out what buffer we're going to bury. */
1960 if (NILP (buffer_or_name))
1961 {
1962 Lisp_Object tem;
1963 XSETBUFFER (buffer, current_buffer);
1964
1965 tem = Fwindow_buffer (selected_window);
1966 /* If we're burying the current buffer, unshow it. */
1967 if (EQ (buffer, tem))
1968 {
1969 if (NILP (Fwindow_dedicated_p (selected_window)))
1970 Fswitch_to_buffer (Fother_buffer (buffer, Qnil, Qnil), Qnil);
1971 else if (NILP (XWINDOW (selected_window)->parent))
1972 Ficonify_frame (Fwindow_frame (selected_window));
1973 else
1974 call1 (Qdelete_window, selected_window);
1975 }
1976 }
1977 else
1978 {
1979 buffer = Fget_buffer (buffer_or_name);
1980 if (NILP (buffer))
1981 nsberror (buffer_or_name);
1982 }
1983
1984 /* Move buffer to the end of the buffer list. Do nothing if the
1985 buffer is killed. */
1986 if (!NILP (BVAR (XBUFFER (buffer), name)))
1987 {
1988 Lisp_Object aelt, list;
1989
1990 aelt = Frassq (buffer, Vbuffer_alist);
1991 list = Fmemq (aelt, Vbuffer_alist);
1992 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist);
1993 XSETCDR (list, Qnil);
1994 Vbuffer_alist = nconc2 (Vbuffer_alist, list);
1995
1996 XFRAME (selected_frame)->buffer_list
1997 = Fdelq (buffer, XFRAME (selected_frame)->buffer_list);
1998 XFRAME (selected_frame)->buried_buffer_list
1999 = Fcons (buffer, Fdelq (buffer, XFRAME (selected_frame)->buried_buffer_list));
2000 }
2001
2002 return Qnil;
2003}
2004 1933
2005DEFUN ("erase-buffer", Ferase_buffer, Serase_buffer, 0, 0, "*", 1934DEFUN ("erase-buffer", Ferase_buffer, Serase_buffer, 0, 0, "*",
2006 doc: /* Delete the entire contents of the current buffer. 1935 doc: /* Delete the entire contents of the current buffer.
@@ -6101,6 +6030,15 @@ The function `kill-all-local-variables' runs this before doing anything else. *
6101 Qchange_major_mode_hook = intern_c_string ("change-major-mode-hook"); 6030 Qchange_major_mode_hook = intern_c_string ("change-major-mode-hook");
6102 staticpro (&Qchange_major_mode_hook); 6031 staticpro (&Qchange_major_mode_hook);
6103 6032
6033 DEFVAR_LISP ("buffer-list-update-hook", Vbuffer_list_update_hook,
6034 doc: /* Hook run when the buffer list changes.
6035Functions running this hook are `get-buffer-create',
6036`make-indirect-buffer', `rename-buffer', `kill-buffer',
6037`record-buffer' and `unrecord-buffer'. */);
6038 Vbuffer_list_update_hook = Qnil;
6039 Qbuffer_list_update_hook = intern_c_string ("buffer-list-update-hook");
6040 staticpro (&Qbuffer_list_update_hook);
6041
6104 defsubr (&Sbuffer_live_p); 6042 defsubr (&Sbuffer_live_p);
6105 defsubr (&Sbuffer_list); 6043 defsubr (&Sbuffer_list);
6106 defsubr (&Sget_buffer); 6044 defsubr (&Sget_buffer);
@@ -6122,12 +6060,12 @@ The function `kill-all-local-variables' runs this before doing anything else. *
6122 defsubr (&Sother_buffer); 6060 defsubr (&Sother_buffer);
6123 defsubr (&Sbuffer_enable_undo); 6061 defsubr (&Sbuffer_enable_undo);
6124 defsubr (&Skill_buffer); 6062 defsubr (&Skill_buffer);
6063 defsubr (&Srecord_buffer);
6064 defsubr (&Sunrecord_buffer);
6125 defsubr (&Sset_buffer_major_mode); 6065 defsubr (&Sset_buffer_major_mode);
6126 defsubr (&Sswitch_to_buffer);
6127 defsubr (&Scurrent_buffer); 6066 defsubr (&Scurrent_buffer);
6128 defsubr (&Sset_buffer); 6067 defsubr (&Sset_buffer);
6129 defsubr (&Sbarf_if_buffer_read_only); 6068 defsubr (&Sbarf_if_buffer_read_only);
6130 defsubr (&Sbury_buffer);
6131 defsubr (&Serase_buffer); 6069 defsubr (&Serase_buffer);
6132 defsubr (&Sbuffer_swap_text); 6070 defsubr (&Sbuffer_swap_text);
6133 defsubr (&Sset_buffer_multibyte); 6071 defsubr (&Sset_buffer_multibyte);
diff --git a/src/frame.c b/src/frame.c
index 6baf2d0e671..34474417efa 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -370,7 +370,7 @@ make_frame (int mini_p)
370 /* If buf is a 'hidden' buffer (i.e. one whose name starts with 370 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
371 a space), try to find another one. */ 371 a space), try to find another one. */
372 if (SREF (Fbuffer_name (buf), 0) == ' ') 372 if (SREF (Fbuffer_name (buf), 0) == ' ')
373 buf = Fother_buffer (buf, Qnil, Qnil); 373 buf = other_buffer_safely (buf);
374 374
375 /* Use set_window_buffer, not Fset_window_buffer, and don't let 375 /* Use set_window_buffer, not Fset_window_buffer, and don't let
376 hooks be run by it. The reason is that the whole frame/window 376 hooks be run by it. The reason is that the whole frame/window
@@ -1115,7 +1115,7 @@ Otherwise, include all frames. */)
1115 0 if all frames aside from F are invisible. 1115 0 if all frames aside from F are invisible.
1116 (Exception: if F is the terminal frame, and we are using X, return 1.) */ 1116 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1117 1117
1118int 1118static int
1119other_visible_frames (FRAME_PTR f) 1119other_visible_frames (FRAME_PTR f)
1120{ 1120{
1121 /* We know the selected frame is visible, 1121 /* We know the selected frame is visible,
@@ -2012,20 +2012,12 @@ frame_buffer_predicate (Lisp_Object frame)
2012 2012
2013/* Return the buffer-list of the selected frame. */ 2013/* Return the buffer-list of the selected frame. */
2014 2014
2015Lisp_Object 2015static Lisp_Object
2016frame_buffer_list (Lisp_Object frame) 2016frame_buffer_list (Lisp_Object frame)
2017{ 2017{
2018 return XFRAME (frame)->buffer_list; 2018 return XFRAME (frame)->buffer_list;
2019} 2019}
2020 2020
2021/* Set the buffer-list of the selected frame. */
2022
2023void
2024set_frame_buffer_list (Lisp_Object frame, Lisp_Object list)
2025{
2026 XFRAME (frame)->buffer_list = list;
2027}
2028
2029/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ 2021/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2030 2022
2031void 2023void
diff --git a/src/frame.h b/src/frame.h
index db57b1be980..8dccfb8540a 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -844,7 +844,6 @@ extern struct frame *make_frame_without_minibuffer (Lisp_Object,
844 struct kboard *, 844 struct kboard *,
845 Lisp_Object); 845 Lisp_Object);
846#endif /* HAVE_WINDOW_SYSTEM */ 846#endif /* HAVE_WINDOW_SYSTEM */
847extern int other_visible_frames (struct frame *);
848extern void frame_make_pointer_invisible (void); 847extern void frame_make_pointer_invisible (void);
849extern void frame_make_pointer_visible (void); 848extern void frame_make_pointer_visible (void);
850extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object); 849extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
diff --git a/src/image.c b/src/image.c
index b755d741443..495bfdc0eef 100644
--- a/src/image.c
+++ b/src/image.c
@@ -564,7 +564,6 @@ static Lisp_Object Qxbm;
564/* Keywords. */ 564/* Keywords. */
565 565
566Lisp_Object QCascent, QCmargin, QCrelief; 566Lisp_Object QCascent, QCmargin, QCrelief;
567static Lisp_Object Qcount, Qextension_data;
568Lisp_Object QCconversion; 567Lisp_Object QCconversion;
569static Lisp_Object QCheuristic_mask; 568static Lisp_Object QCheuristic_mask;
570static Lisp_Object QCcolor_symbols; 569static Lisp_Object QCcolor_symbols;
@@ -573,6 +572,7 @@ static Lisp_Object QCcrop, QCrotation;
573 572
574/* Other symbols. */ 573/* Other symbols. */
575 574
575static Lisp_Object Qcount, Qextension_data, Qdelay;
576static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic; 576static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
577 577
578/* Function prototypes. */ 578/* Function prototypes. */
@@ -7315,16 +7315,31 @@ gif_load (struct frame *f, struct image *img)
7315 img->lisp_data = Qnil; 7315 img->lisp_data = Qnil;
7316 if (gif->SavedImages[idx].ExtensionBlockCount > 0) 7316 if (gif->SavedImages[idx].ExtensionBlockCount > 0)
7317 { 7317 {
7318 unsigned int delay = 0;
7318 ExtensionBlock *ext = gif->SavedImages[idx].ExtensionBlocks; 7319 ExtensionBlock *ext = gif->SavedImages[idx].ExtensionBlocks;
7319 for (i = 0; i < gif->SavedImages[idx].ExtensionBlockCount; i++, ext++) 7320 for (i = 0; i < gif->SavedImages[idx].ExtensionBlockCount; i++, ext++)
7320 /* Append (... FUNCTION "BYTES") */ 7321 /* Append (... FUNCTION "BYTES") */
7321 img->lisp_data = Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount), 7322 {
7322 Fcons (make_number (ext->Function), 7323 img->lisp_data
7323 img->lisp_data)); 7324 = Fcons (make_number (ext->Function),
7325 Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount),
7326 img->lisp_data));
7327 if (ext->Function == GIF_LOCAL_DESCRIPTOR_EXTENSION
7328 && ext->ByteCount == 4)
7329 {
7330 delay = ext->Bytes[2] << CHAR_BIT;
7331 delay |= ext->Bytes[1];
7332 }
7333 }
7324 img->lisp_data = Fcons (Qextension_data, 7334 img->lisp_data = Fcons (Qextension_data,
7325 Fcons (Fnreverse (img->lisp_data), 7335 Fcons (img->lisp_data, Qnil));
7326 Qnil)); 7336 if (delay)
7337 img->lisp_data
7338 = Fcons (Qdelay,
7339 Fcons (make_float (((double) delay) * 0.01),
7340 img->lisp_data));
7327 } 7341 }
7342
7328 if (gif->ImageCount > 1) 7343 if (gif->ImageCount > 1)
7329 img->lisp_data = Fcons (Qcount, 7344 img->lisp_data = Fcons (Qcount,
7330 Fcons (make_number (gif->ImageCount), 7345 Fcons (make_number (gif->ImageCount),
@@ -7480,8 +7495,8 @@ imagemagick_load_image (struct frame *f, struct image *img,
7480 unsigned char *contents, unsigned int size, 7495 unsigned char *contents, unsigned int size,
7481 char *filename) 7496 char *filename)
7482{ 7497{
7483 unsigned long width; 7498 size_t width;
7484 unsigned long height; 7499 size_t height;
7485 7500
7486 MagickBooleanType status; 7501 MagickBooleanType status;
7487 7502
@@ -7858,7 +7873,7 @@ recognize as images, such as C. See `imagemagick-types-inhibit'. */)
7858 (void) 7873 (void)
7859{ 7874{
7860 Lisp_Object typelist = Qnil; 7875 Lisp_Object typelist = Qnil;
7861 unsigned long numf = 0; 7876 size_t numf = 0;
7862 ExceptionInfo ex; 7877 ExceptionInfo ex;
7863 char **imtypes = GetMagickList ("*", &numf, &ex); 7878 char **imtypes = GetMagickList ("*", &numf, &ex);
7864 int i; 7879 int i;
@@ -8688,75 +8703,49 @@ as a ratio to the frame height and width. If the value is
8688non-numeric, there is no explicit limit on the size of images. */); 8703non-numeric, there is no explicit limit on the size of images. */);
8689 Vmax_image_size = make_float (MAX_IMAGE_SIZE); 8704 Vmax_image_size = make_float (MAX_IMAGE_SIZE);
8690 8705
8691 Qpbm = intern_c_string ("pbm"); 8706 DEFSYM (Qpbm, "pbm");
8692 staticpro (&Qpbm);
8693 ADD_IMAGE_TYPE (Qpbm); 8707 ADD_IMAGE_TYPE (Qpbm);
8694 8708
8695 Qxbm = intern_c_string ("xbm"); 8709 DEFSYM (Qxbm, "xbm");
8696 staticpro (&Qxbm);
8697 ADD_IMAGE_TYPE (Qxbm); 8710 ADD_IMAGE_TYPE (Qxbm);
8698 8711
8699 define_image_type (&xbm_type, 1); 8712 define_image_type (&xbm_type, 1);
8700 define_image_type (&pbm_type, 1); 8713 define_image_type (&pbm_type, 1);
8701 8714
8702 Qcount = intern_c_string ("count"); 8715 DEFSYM (Qcount, "count");
8703 staticpro (&Qcount); 8716 DEFSYM (Qextension_data, "extension-data");
8704 Qextension_data = intern_c_string ("extension-data"); 8717 DEFSYM (Qdelay, "delay");
8705 staticpro (&Qextension_data); 8718
8706 8719 DEFSYM (QCascent, ":ascent");
8707 QCascent = intern_c_string (":ascent"); 8720 DEFSYM (QCmargin, ":margin");
8708 staticpro (&QCascent); 8721 DEFSYM (QCrelief, ":relief");
8709 QCmargin = intern_c_string (":margin"); 8722 DEFSYM (QCconversion, ":conversion");
8710 staticpro (&QCmargin); 8723 DEFSYM (QCcolor_symbols, ":color-symbols");
8711 QCrelief = intern_c_string (":relief"); 8724 DEFSYM (QCheuristic_mask, ":heuristic-mask");
8712 staticpro (&QCrelief); 8725 DEFSYM (QCindex, ":index");
8713 QCconversion = intern_c_string (":conversion"); 8726 DEFSYM (QCgeometry, ":geometry");
8714 staticpro (&QCconversion); 8727 DEFSYM (QCcrop, ":crop");
8715 QCcolor_symbols = intern_c_string (":color-symbols"); 8728 DEFSYM (QCrotation, ":rotation");
8716 staticpro (&QCcolor_symbols); 8729 DEFSYM (QCmatrix, ":matrix");
8717 QCheuristic_mask = intern_c_string (":heuristic-mask"); 8730 DEFSYM (QCcolor_adjustment, ":color-adjustment");
8718 staticpro (&QCheuristic_mask); 8731 DEFSYM (QCmask, ":mask");
8719 QCindex = intern_c_string (":index"); 8732
8720 staticpro (&QCindex); 8733 DEFSYM (Qlaplace, "laplace");
8721 QCgeometry = intern_c_string (":geometry"); 8734 DEFSYM (Qemboss, "emboss");
8722 staticpro (&QCgeometry); 8735 DEFSYM (Qedge_detection, "edge-detection");
8723 QCcrop = intern_c_string (":crop"); 8736 DEFSYM (Qheuristic, "heuristic");
8724 staticpro (&QCcrop); 8737
8725 QCrotation = intern_c_string (":rotation"); 8738 DEFSYM (Qpostscript, "postscript");
8726 staticpro (&QCrotation);
8727 QCmatrix = intern_c_string (":matrix");
8728 staticpro (&QCmatrix);
8729 QCcolor_adjustment = intern_c_string (":color-adjustment");
8730 staticpro (&QCcolor_adjustment);
8731 QCmask = intern_c_string (":mask");
8732 staticpro (&QCmask);
8733
8734 Qlaplace = intern_c_string ("laplace");
8735 staticpro (&Qlaplace);
8736 Qemboss = intern_c_string ("emboss");
8737 staticpro (&Qemboss);
8738 Qedge_detection = intern_c_string ("edge-detection");
8739 staticpro (&Qedge_detection);
8740 Qheuristic = intern_c_string ("heuristic");
8741 staticpro (&Qheuristic);
8742
8743 Qpostscript = intern_c_string ("postscript");
8744 staticpro (&Qpostscript);
8745#ifdef HAVE_GHOSTSCRIPT 8739#ifdef HAVE_GHOSTSCRIPT
8746 ADD_IMAGE_TYPE (Qpostscript); 8740 ADD_IMAGE_TYPE (Qpostscript);
8747 QCloader = intern_c_string (":loader"); 8741 DEFSYM (QCloader, ":loader");
8748 staticpro (&QCloader); 8742 DEFSYM (QCbounding_box, ":bounding-box");
8749 QCbounding_box = intern_c_string (":bounding-box"); 8743 DEFSYM (QCpt_width, ":pt-width");
8750 staticpro (&QCbounding_box); 8744 DEFSYM (QCpt_height, ":pt-height");
8751 QCpt_width = intern_c_string (":pt-width");
8752 staticpro (&QCpt_width);
8753 QCpt_height = intern_c_string (":pt-height");
8754 staticpro (&QCpt_height);
8755#endif /* HAVE_GHOSTSCRIPT */ 8745#endif /* HAVE_GHOSTSCRIPT */
8756 8746
8757#ifdef HAVE_NTGUI 8747#ifdef HAVE_NTGUI
8758 Qlibpng_version = intern_c_string ("libpng-version"); 8748 DEFSYM (Qlibpng_version, "libpng-version");
8759 staticpro (&Qlibpng_version);
8760 Fset (Qlibpng_version, 8749 Fset (Qlibpng_version,
8761#if HAVE_PNG 8750#if HAVE_PNG
8762 make_number (PNG_LIBPNG_VER) 8751 make_number (PNG_LIBPNG_VER)
@@ -8767,53 +8756,43 @@ non-numeric, there is no explicit limit on the size of images. */);
8767#endif 8756#endif
8768 8757
8769#if defined (HAVE_XPM) || defined (HAVE_NS) 8758#if defined (HAVE_XPM) || defined (HAVE_NS)
8770 Qxpm = intern_c_string ("xpm"); 8759 DEFSYM (Qxpm, "xpm");
8771 staticpro (&Qxpm);
8772 ADD_IMAGE_TYPE (Qxpm); 8760 ADD_IMAGE_TYPE (Qxpm);
8773#endif 8761#endif
8774 8762
8775#if defined (HAVE_JPEG) || defined (HAVE_NS) 8763#if defined (HAVE_JPEG) || defined (HAVE_NS)
8776 Qjpeg = intern_c_string ("jpeg"); 8764 DEFSYM (Qjpeg, "jpeg");
8777 staticpro (&Qjpeg);
8778 ADD_IMAGE_TYPE (Qjpeg); 8765 ADD_IMAGE_TYPE (Qjpeg);
8779#endif 8766#endif
8780 8767
8781#if defined (HAVE_TIFF) || defined (HAVE_NS) 8768#if defined (HAVE_TIFF) || defined (HAVE_NS)
8782 Qtiff = intern_c_string ("tiff"); 8769 DEFSYM (Qtiff, "tiff");
8783 staticpro (&Qtiff);
8784 ADD_IMAGE_TYPE (Qtiff); 8770 ADD_IMAGE_TYPE (Qtiff);
8785#endif 8771#endif
8786 8772
8787#if defined (HAVE_GIF) || defined (HAVE_NS) 8773#if defined (HAVE_GIF) || defined (HAVE_NS)
8788 Qgif = intern_c_string ("gif"); 8774 DEFSYM (Qgif, "gif");
8789 staticpro (&Qgif);
8790 ADD_IMAGE_TYPE (Qgif); 8775 ADD_IMAGE_TYPE (Qgif);
8791#endif 8776#endif
8792 8777
8793#if defined (HAVE_PNG) || defined (HAVE_NS) 8778#if defined (HAVE_PNG) || defined (HAVE_NS)
8794 Qpng = intern_c_string ("png"); 8779 DEFSYM (Qpng, "png");
8795 staticpro (&Qpng);
8796 ADD_IMAGE_TYPE (Qpng); 8780 ADD_IMAGE_TYPE (Qpng);
8797#endif 8781#endif
8798 8782
8799#if defined (HAVE_IMAGEMAGICK) 8783#if defined (HAVE_IMAGEMAGICK)
8800 Qimagemagick = intern_c_string ("imagemagick"); 8784 DEFSYM (Qimagemagick, "imagemagick");
8801 staticpro (&Qimagemagick);
8802 ADD_IMAGE_TYPE (Qimagemagick); 8785 ADD_IMAGE_TYPE (Qimagemagick);
8803#endif 8786#endif
8804 8787
8805#if defined (HAVE_RSVG) 8788#if defined (HAVE_RSVG)
8806 Qsvg = intern_c_string ("svg"); 8789 DEFSYM (Qsvg, "svg");
8807 staticpro (&Qsvg);
8808 ADD_IMAGE_TYPE (Qsvg); 8790 ADD_IMAGE_TYPE (Qsvg);
8809#ifdef HAVE_NTGUI 8791#ifdef HAVE_NTGUI
8810 /* Other libraries used directly by svg code. */ 8792 /* Other libraries used directly by svg code. */
8811 Qgdk_pixbuf = intern_c_string ("gdk-pixbuf"); 8793 DEFSYM (Qgdk_pixbuf, "gdk-pixbuf");
8812 staticpro (&Qgdk_pixbuf); 8794 DEFSYM (Qglib, "glib");
8813 Qglib = intern_c_string ("glib"); 8795 DEFSYM (Qgobject, "gobject");
8814 staticpro (&Qglib);
8815 Qgobject = intern_c_string ("gobject");
8816 staticpro (&Qgobject);
8817#endif /* HAVE_NTGUI */ 8796#endif /* HAVE_NTGUI */
8818#endif /* HAVE_RSVG */ 8797#endif /* HAVE_RSVG */
8819 8798
diff --git a/src/keyboard.h b/src/keyboard.h
index 802c99edb5e..20763c35f3a 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -268,7 +268,9 @@ extern Lisp_Object menu_items;
268 268
269/* If non-nil, means that the global vars defined here are already in use. 269/* If non-nil, means that the global vars defined here are already in use.
270 Used to detect cases where we try to re-enter this non-reentrant code. */ 270 Used to detect cases where we try to re-enter this non-reentrant code. */
271#if defined USE_GTK || defined USE_MOTIF
271extern Lisp_Object menu_items_inuse; 272extern Lisp_Object menu_items_inuse;
273#endif
272 274
273/* Number of slots currently allocated in menu_items. */ 275/* Number of slots currently allocated in menu_items. */
274extern int menu_items_allocated; 276extern int menu_items_allocated;
diff --git a/src/lisp.h b/src/lisp.h
index 389762a07e5..3f6a84f8fa3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3043,6 +3043,7 @@ extern Lisp_Object set_buffer_if_live (Lisp_Object);
3043EXFUN (Fbarf_if_buffer_read_only, 0); 3043EXFUN (Fbarf_if_buffer_read_only, 0);
3044EXFUN (Fcurrent_buffer, 0); 3044EXFUN (Fcurrent_buffer, 0);
3045EXFUN (Fother_buffer, 3); 3045EXFUN (Fother_buffer, 3);
3046extern Lisp_Object other_buffer_safely (Lisp_Object);
3046EXFUN (Foverlay_get, 2); 3047EXFUN (Foverlay_get, 2);
3047EXFUN (Fbuffer_modified_p, 1); 3048EXFUN (Fbuffer_modified_p, 1);
3048EXFUN (Fset_buffer_modified_p, 1); 3049EXFUN (Fset_buffer_modified_p, 1);
@@ -3253,9 +3254,7 @@ EXFUN (Fframe_parameter, 2);
3253EXFUN (Fmodify_frame_parameters, 2); 3254EXFUN (Fmodify_frame_parameters, 2);
3254EXFUN (Fraise_frame, 1); 3255EXFUN (Fraise_frame, 1);
3255EXFUN (Fredirect_frame_focus, 2); 3256EXFUN (Fredirect_frame_focus, 2);
3256extern Lisp_Object frame_buffer_list (Lisp_Object);
3257extern void frames_discard_buffer (Lisp_Object); 3257extern void frames_discard_buffer (Lisp_Object);
3258extern void set_frame_buffer_list (Lisp_Object, Lisp_Object);
3259extern void syms_of_frame (void); 3258extern void syms_of_frame (void);
3260 3259
3261/* Defined in emacs.c */ 3260/* Defined in emacs.c */
@@ -3312,8 +3311,10 @@ extern int wait_reading_process_output (int, int, int, int,
3312 int); 3311 int);
3313extern void add_keyboard_wait_descriptor (int); 3312extern void add_keyboard_wait_descriptor (int);
3314extern void delete_keyboard_wait_descriptor (int); 3313extern void delete_keyboard_wait_descriptor (int);
3314#ifdef HAVE_GPM
3315extern void add_gpm_wait_descriptor (int); 3315extern void add_gpm_wait_descriptor (int);
3316extern void delete_gpm_wait_descriptor (int); 3316extern void delete_gpm_wait_descriptor (int);
3317#endif
3317extern void close_process_descs (void); 3318extern void close_process_descs (void);
3318extern void init_process (void); 3319extern void init_process (void);
3319extern void syms_of_process (void); 3320extern void syms_of_process (void);
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 8da589a7115..d4fafcfc047 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -388,6 +388,7 @@ CONFIG_H = $(EMACS_ROOT)/src/s/ms-w32.h \
388 $(EMACS_ROOT)/nt/inc/sys/stat.h 388 $(EMACS_ROOT)/nt/inc/sys/stat.h
389LISP_H = $(SRC)/lisp.h \ 389LISP_H = $(SRC)/lisp.h \
390 $(SRC)/globals.h \ 390 $(SRC)/globals.h \
391 $(EMACS_ROOT)/lib/intprops.h \
391 $(EMACS_ROOT)/nt/inc/inttypes.h \ 392 $(EMACS_ROOT)/nt/inc/inttypes.h \
392 $(EMACS_ROOT)/nt/inc/stdint.h 393 $(EMACS_ROOT)/nt/inc/stdint.h
393PROCESS_H = $(SRC)/process.h \ 394PROCESS_H = $(SRC)/process.h \
@@ -566,7 +567,6 @@ $(BLD)/ccl.$(O) : \
566$(BLD)/character.$(O) : \ 567$(BLD)/character.$(O) : \
567 $(SRC)/character.c \ 568 $(SRC)/character.c \
568 $(CONFIG_H) \ 569 $(CONFIG_H) \
569 $(EMACS_ROOT)/lib/intprops.h \
570 $(LISP_H) \ 570 $(LISP_H) \
571 $(SRC)/buffer.h \ 571 $(SRC)/buffer.h \
572 $(SRC)/character.h \ 572 $(SRC)/character.h \
@@ -654,7 +654,6 @@ $(BLD)/data.$(O) : \
654 $(SRC)/data.c \ 654 $(SRC)/data.c \
655 $(CONFIG_H) \ 655 $(CONFIG_H) \
656 $(EMACS_ROOT)/nt/inc/sys/time.h \ 656 $(EMACS_ROOT)/nt/inc/sys/time.h \
657 $(EMACS_ROOT)/lib/intprops.h \
658 $(LISP_H) \ 657 $(LISP_H) \
659 $(SRC)/buffer.h \ 658 $(SRC)/buffer.h \
660 $(SRC)/ccl.h \ 659 $(SRC)/ccl.h \
@@ -752,7 +751,6 @@ $(BLD)/editfns.$(O) : \
752 $(EMACS_ROOT)/nt/inc/pwd.h \ 751 $(EMACS_ROOT)/nt/inc/pwd.h \
753 $(EMACS_ROOT)/nt/inc/unistd.h \ 752 $(EMACS_ROOT)/nt/inc/unistd.h \
754 $(EMACS_ROOT)/nt/inc/sys/time.h \ 753 $(EMACS_ROOT)/nt/inc/sys/time.h \
755 $(EMACS_ROOT)/lib/intprops.h \
756 $(EMACS_ROOT)/lib/strftime.h \ 754 $(EMACS_ROOT)/lib/strftime.h \
757 $(EMACS_ROOT)/lib/verify.h \ 755 $(EMACS_ROOT)/lib/verify.h \
758 $(LISP_H) \ 756 $(LISP_H) \
@@ -1034,7 +1032,6 @@ $(BLD)/insdel.$(O) : \
1034 $(SRC)/insdel.c \ 1032 $(SRC)/insdel.c \
1035 $(CONFIG_H) \ 1033 $(CONFIG_H) \
1036 $(EMACS_ROOT)/nt/inc/sys/time.h \ 1034 $(EMACS_ROOT)/nt/inc/sys/time.h \
1037 $(EMACS_ROOT)/lib/intprops.h \
1038 $(LISP_H) \ 1035 $(LISP_H) \
1039 $(SRC)/atimer.h \ 1036 $(SRC)/atimer.h \
1040 $(SRC)/blockinput.h \ 1037 $(SRC)/blockinput.h \
@@ -1052,7 +1049,6 @@ $(BLD)/intervals.$(O) : \
1052 $(SRC)/intervals.c \ 1049 $(SRC)/intervals.c \
1053 $(CONFIG_H) \ 1050 $(CONFIG_H) \
1054 $(EMACS_ROOT)/nt/inc/sys/time.h \ 1051 $(EMACS_ROOT)/nt/inc/sys/time.h \
1055 $(EMACS_ROOT)/lib/intprops.h \
1056 $(LISP_H) \ 1052 $(LISP_H) \
1057 $(SRC)/buffer.h \ 1053 $(SRC)/buffer.h \
1058 $(SRC)/coding.h \ 1054 $(SRC)/coding.h \
@@ -1305,7 +1301,6 @@ $(BLD)/print.$(O) : \
1305 $(EMACS_ROOT)/nt/inc/unistd.h \ 1301 $(EMACS_ROOT)/nt/inc/unistd.h \
1306 $(EMACS_ROOT)/nt/inc/sys/time.h \ 1302 $(EMACS_ROOT)/nt/inc/sys/time.h \
1307 $(EMACS_ROOT)/lib/ftoastr.h \ 1303 $(EMACS_ROOT)/lib/ftoastr.h \
1308 $(EMACS_ROOT)/lib/intprops.h \
1309 $(LISP_H) \ 1304 $(LISP_H) \
1310 $(PROCESS_H) \ 1305 $(PROCESS_H) \
1311 $(SRC)/atimer.h \ 1306 $(SRC)/atimer.h \
diff --git a/src/menu.c b/src/menu.c
index 7eda4c6ebb5..fa31c8a51c1 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -67,6 +67,9 @@ Lisp_Object menu_items;
67 67
68/* If non-nil, means that the global vars defined here are already in use. 68/* If non-nil, means that the global vars defined here are already in use.
69 Used to detect cases where we try to re-enter this non-reentrant code. */ 69 Used to detect cases where we try to re-enter this non-reentrant code. */
70#if ! (defined USE_GTK || defined USE_MOTIF)
71static
72#endif
70Lisp_Object menu_items_inuse; 73Lisp_Object menu_items_inuse;
71 74
72/* Number of slots currently allocated in menu_items. */ 75/* Number of slots currently allocated in menu_items. */
diff --git a/src/process.c b/src/process.c
index 51deb1c933f..9ff7dd198dd 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6593,6 +6593,8 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6593 6593
6594 6594
6595 6595
6596# ifdef HAVE_GPM
6597
6596void 6598void
6597add_gpm_wait_descriptor (int desc) 6599add_gpm_wait_descriptor (int desc)
6598{ 6600{
@@ -6605,6 +6607,8 @@ delete_gpm_wait_descriptor (int desc)
6605 delete_keyboard_wait_descriptor (desc); 6607 delete_keyboard_wait_descriptor (desc);
6606} 6608}
6607 6609
6610# endif
6611
6608# ifdef SIGIO 6612# ifdef SIGIO
6609 6613
6610/* Return nonzero if *MASK has a bit set 6614/* Return nonzero if *MASK has a bit set
diff --git a/src/widget.c b/src/widget.c
index daea382d654..6d871ad7cb2 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -78,7 +78,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
78static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2); 78static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2);
79static void EmacsFrameDestroy (Widget widget); 79static void EmacsFrameDestroy (Widget widget);
80static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs); 80static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs);
81void EmacsFrameResize (Widget widget); 81static void EmacsFrameResize (Widget widget);
82static Boolean EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2); 82static Boolean EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2);
83static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result); 83static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result);
84 84
@@ -137,7 +137,7 @@ emacsFrameTranslations [] = "\
137"; 137";
138*/ 138*/
139 139
140EmacsFrameClassRec emacsFrameClassRec = { 140static EmacsFrameClassRec emacsFrameClassRec = {
141 { /* core fields */ 141 { /* core fields */
142 /* superclass */ &widgetClassRec, 142 /* superclass */ &widgetClassRec,
143 /* class_name */ "EmacsFrame", 143 /* class_name */ "EmacsFrame",
@@ -463,10 +463,6 @@ set_frame_size (EmacsFrame ew)
463 } 463 }
464} 464}
465 465
466/* Nonzero tells update_wm_hints not to do anything
467 (the caller should call update_wm_hints explicitly later.) */
468int update_hints_inhibit;
469
470static void 466static void
471update_wm_hints (EmacsFrame ew) 467update_wm_hints (EmacsFrame ew)
472{ 468{
@@ -481,9 +477,6 @@ update_wm_hints (EmacsFrame ew)
481 int base_height; 477 int base_height;
482 int min_rows = 0, min_cols = 0; 478 int min_rows = 0, min_cols = 0;
483 479
484 if (update_hints_inhibit)
485 return;
486
487#if 0 480#if 0
488 check_frame_size (ew->emacs_frame.frame, &min_rows, &min_cols); 481 check_frame_size (ew->emacs_frame.frame, &min_rows, &min_cols);
489#endif 482#endif
@@ -699,7 +692,7 @@ EmacsFrameDestroy (Widget widget)
699 UNBLOCK_INPUT; 692 UNBLOCK_INPUT;
700} 693}
701 694
702void 695static void
703EmacsFrameResize (Widget widget) 696EmacsFrameResize (Widget widget)
704{ 697{
705 EmacsFrame ew = (EmacsFrame)widget; 698 EmacsFrame ew = (EmacsFrame)widget;
diff --git a/src/widgetprv.h b/src/widgetprv.h
index 5df0976f879..997a70e026c 100644
--- a/src/widgetprv.h
+++ b/src/widgetprv.h
@@ -70,9 +70,4 @@ typedef struct _EmacsFrameClassRec { /* full class record declaration */
70 EmacsFrameClassPart emacs_frame_class; 70 EmacsFrameClassPart emacs_frame_class;
71} EmacsFrameClassRec; 71} EmacsFrameClassRec;
72 72
73extern EmacsFrameClassRec emacsFrameClassRec; /* class pointer */
74
75
76
77#endif /* _EmacsFrameP_h */ 73#endif /* _EmacsFrameP_h */
78
diff --git a/src/window.c b/src/window.c
index 7a026b3a1c7..65df9f26e64 100644
--- a/src/window.c
+++ b/src/window.c
@@ -50,9 +50,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#include "nsterm.h" 50#include "nsterm.h"
51#endif 51#endif
52 52
53Lisp_Object Qwindowp, Qwindow_live_p, Qdelete_window; 53Lisp_Object Qwindowp, Qwindow_live_p;
54static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; 54static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
55static Lisp_Object Qwindow_deletable_p, Qdisplay_buffer; 55static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
56static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; 56static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
57static Lisp_Object Qresize_root_window, Qresize_root_window_vertically; 57static Lisp_Object Qresize_root_window, Qresize_root_window_vertically;
58static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 58static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
@@ -310,6 +310,8 @@ selected windows appears and to which many commands apply. */)
310 return selected_window; 310 return selected_window;
311} 311}
312 312
313int window_select_count;
314
313/* If select_window is called with inhibit_point_swap non-zero it will 315/* If select_window is called with inhibit_point_swap non-zero it will
314 not store point of the old selected window's buffer back into that 316 not store point of the old selected window's buffer back into that
315 window's pointm slot. This is needed by Fset_window_configuration to 317 window's pointm slot. This is needed by Fset_window_configuration to
@@ -1972,6 +1974,14 @@ recombine_windows (Lisp_Object window)
1972 } 1974 }
1973 } 1975 }
1974} 1976}
1977
1978/* If WINDOW can be deleted, delete it. */
1979static void
1980delete_deletable_window (Lisp_Object window)
1981{
1982 if (!NILP (call1 (Qwindow_deletable_p, window)))
1983 call1 (Qdelete_window, window);
1984}
1975 1985
1976/*********************************************************************** 1986/***********************************************************************
1977 Window List 1987 Window List
@@ -2210,35 +2220,32 @@ next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames, in
2210 2220
2211DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0, 2221DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0,
2212 doc: /* Return window following WINDOW in cyclic ordering of windows. 2222 doc: /* Return window following WINDOW in cyclic ordering of windows.
2213WINDOW defaults to the selected window. The optional arguments 2223WINDOW must be a live window and defaults to the selected one. The
2214MINIBUF and ALL-FRAMES specify the set of windows to consider. 2224optional arguments MINIBUF and ALL-FRAMES specify the set of windows to
2215 2225consider.
2216MINIBUF t means consider the minibuffer window even if the 2226
2217minibuffer is not active. MINIBUF nil or omitted means consider 2227MINIBUF nil or omitted means consider the minibuffer window only if the
2218the minibuffer window only if the minibuffer is active. Any 2228minibuffer is active. MINIBUF t means consider the minibuffer window
2219other value means do not consider the minibuffer window even if 2229even if the minibuffer is not active. Any other value means do not
2220the minibuffer is active. 2230consider the minibuffer window even if the minibuffer is active.
2221 2231
2222Several frames may share a single minibuffer; if the minibuffer 2232ALL-FRAMES nil or omitted means consider all windows on WINDOW's frame,
2223is active, all windows on all frames that share that minibuffer 2233plus the minibuffer window if specified by the MINIBUF argument. If the
2224are considered too. Therefore, if you are using a separate 2234minibuffer counts, consider all windows on all frames that share that
2225minibuffer frame and the minibuffer is active and MINIBUF says it 2235minibuffer too. The following non-nil values of ALL-FRAMES have special
2226counts, `next-window' considers the windows in the frame from 2236meanings:
2227which you entered the minibuffer, as well as the minibuffer 2237
2228window. 2238- t means consider all windows on all existing frames.
2239
2240- `visible' means consider all windows on all visible frames.
2241
2242- 0 (the number zero) means consider all windows on all visible and
2243 iconified frames.
2244
2245- A frame means consider all windows on that frame only.
2229 2246
2230ALL-FRAMES nil or omitted means consider all windows on WINDOW's
2231 frame, plus the minibuffer window if specified by the MINIBUF
2232 argument, see above. If the minibuffer counts, consider all
2233 windows on all frames that share that minibuffer too.
2234ALL-FRAMES t means consider all windows on all existing frames.
2235ALL-FRAMES `visible' means consider all windows on all visible
2236 frames on the current terminal.
2237ALL-FRAMES 0 means consider all windows on all visible and
2238 iconified frames on the current terminal.
2239ALL-FRAMES a frame means consider all windows on that frame only.
2240Anything else means consider all windows on WINDOW's frame and no 2247Anything else means consider all windows on WINDOW's frame and no
2241 others. 2248others.
2242 2249
2243If you use consistent values for MINIBUF and ALL-FRAMES, you can use 2250If you use consistent values for MINIBUF and ALL-FRAMES, you can use
2244`next-window' to iterate through the entire cycle of acceptable 2251`next-window' to iterate through the entire cycle of acceptable
@@ -2252,9 +2259,32 @@ windows, eventually ending up back at the window you started with.
2252 2259
2253DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0, 2260DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0,
2254 doc: /* Return window preceding WINDOW in cyclic ordering of windows. 2261 doc: /* Return window preceding WINDOW in cyclic ordering of windows.
2255WINDOW defaults to the selected window. The optional arguments 2262WINDOW must be a live window and defaults to the selected one. The
2256MINIBUF and ALL-FRAMES specify the set of windows to consider. 2263optional arguments MINIBUF and ALL-FRAMES specify the set of windows to
2257For the precise meaning of these arguments see `next-window'. 2264consider.
2265
2266MINIBUF nil or omitted means consider the minibuffer window only if the
2267minibuffer is active. MINIBUF t means consider the minibuffer window
2268even if the minibuffer is not active. Any other value means do not
2269consider the minibuffer window even if the minibuffer is active.
2270
2271ALL-FRAMES nil or omitted means consider all windows on WINDOW's frame,
2272plus the minibuffer window if specified by the MINIBUF argument. If the
2273minibuffer counts, consider all windows on all frames that share that
2274minibuffer too. The following non-nil values of ALL-FRAMES have special
2275meanings:
2276
2277- t means consider all windows on all existing frames.
2278
2279- `visible' means consider all windows on all visible frames.
2280
2281- 0 (the number zero) means consider all windows on all visible and
2282 iconified frames.
2283
2284- A frame means consider all windows on that frame only.
2285
2286Anything else means consider all windows on WINDOW's frame and no
2287others.
2258 2288
2259If you use consistent values for MINIBUF and ALL-FRAMES, you can 2289If you use consistent values for MINIBUF and ALL-FRAMES, you can
2260use `previous-window' to iterate through the entire cycle of 2290use `previous-window' to iterate through the entire cycle of
@@ -2267,37 +2297,6 @@ reverse order. */)
2267} 2297}
2268 2298
2269 2299
2270DEFUN ("other-window", Fother_window, Sother_window, 1, 2, "p",
2271 doc: /* Select another window in cyclic ordering of windows.
2272COUNT specifies the number of windows to skip, starting with the
2273selected window, before making the selection. If COUNT is
2274positive, skip COUNT windows forwards. If COUNT is negative,
2275skip -COUNT windows backwards. COUNT zero means do not skip any
2276window, so select the selected window. In an interactive call,
2277COUNT is the numeric prefix argument. Return nil.
2278
2279This function uses `next-window' for finding the window to select.
2280The argument ALL-FRAMES has the same meaning as in `next-window',
2281but the MINIBUF argument of `next-window' is always effectively
2282nil. */)
2283 (Lisp_Object count, Lisp_Object all_frames)
2284{
2285 Lisp_Object window;
2286 int i;
2287
2288 CHECK_NUMBER (count);
2289 window = selected_window;
2290
2291 for (i = XINT (count); i > 0; --i)
2292 window = Fnext_window (window, Qnil, all_frames);
2293 for (; i < 0; ++i)
2294 window = Fprevious_window (window, Qnil, all_frames);
2295
2296 Fselect_window (window, Qnil);
2297 return Qnil;
2298}
2299
2300
2301/* Return a list of windows in cyclic ordering. Arguments are like 2300/* Return a list of windows in cyclic ordering. Arguments are like
2302 for `next-window'. */ 2301 for `next-window'. */
2303 2302
@@ -2397,10 +2396,9 @@ be listed first but no error is signalled. */)
2397enum window_loop 2396enum window_loop
2398{ 2397{
2399 WINDOW_LOOP_UNUSED, 2398 WINDOW_LOOP_UNUSED,
2400 GET_BUFFER_WINDOW, /* Arg is buffer */ 2399 GET_BUFFER_WINDOW, /* Arg is buffer */
2401 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ 2400 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */
2402 UNSHOW_BUFFER, /* Arg is buffer */ 2401 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */
2403 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */
2404 CHECK_ALL_WINDOWS 2402 CHECK_ALL_WINDOWS
2405}; 2403};
2406 2404
@@ -2408,6 +2406,7 @@ static Lisp_Object
2408window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frames) 2406window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frames)
2409{ 2407{
2410 Lisp_Object window, windows, best_window, frame_arg; 2408 Lisp_Object window, windows, best_window, frame_arg;
2409 int frame_best_window_flag = 0;
2411 struct frame *f; 2410 struct frame *f;
2412 struct gcpro gcpro1; 2411 struct gcpro gcpro1;
2413 2412
@@ -2457,110 +2456,51 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2457 is visible, since Fwindow_list skips non-visible frames if 2456 is visible, since Fwindow_list skips non-visible frames if
2458 that is desired, under the control of frame_arg. */ 2457 that is desired, under the control of frame_arg. */
2459 if (!MINI_WINDOW_P (w) 2458 if (!MINI_WINDOW_P (w)
2460 /* For UNSHOW_BUFFER, we must always consider all windows. */ 2459 /* For REPLACE_BUFFER_IN_WINDOWS_SAFELY, we must always
2461 || type == UNSHOW_BUFFER 2460 consider all windows. */
2461 || type == REPLACE_BUFFER_IN_WINDOWS_SAFELY
2462 || (mini && minibuf_level > 0)) 2462 || (mini && minibuf_level > 0))
2463 switch (type) 2463 switch (type)
2464 { 2464 {
2465 case GET_BUFFER_WINDOW: 2465 case GET_BUFFER_WINDOW:
2466 if (EQ (w->buffer, obj) 2466 if (EQ (w->buffer, obj)
2467 /* Don't find any minibuffer window 2467 /* Don't find any minibuffer window except the one that
2468 except the one that is currently in use. */ 2468 is currently in use. */
2469 && (MINI_WINDOW_P (w) 2469 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1))
2470 ? EQ (window, minibuf_window)
2471 : 1))
2472 { 2470 {
2473 if (NILP (best_window)) 2471 if (EQ (window, selected_window))
2474 best_window = window; 2472 /* Preferably return the selected window. */
2475 else if (EQ (window, selected_window))
2476 /* Prefer to return selected-window. */
2477 RETURN_UNGCPRO (window); 2473 RETURN_UNGCPRO (window);
2478 else if (EQ (Fwindow_frame (window), selected_frame)) 2474 else if (EQ (XWINDOW (window)->frame, selected_frame)
2479 /* Prefer windows on the current frame. */ 2475 && !frame_best_window_flag)
2480 best_window = window; 2476 /* Prefer windows on the current frame (but don't
2481 } 2477 choose another one if we have one already). */
2482 break;
2483
2484 case DELETE_BUFFER_WINDOWS:
2485 if (EQ (w->buffer, obj))
2486 {
2487 struct frame *fr = XFRAME (WINDOW_FRAME (w));
2488
2489 /* If this window is dedicated, and in a frame of its own,
2490 kill the frame. */
2491 if (EQ (window, FRAME_ROOT_WINDOW (fr))
2492 && !NILP (w->dedicated)
2493 && other_visible_frames (fr))
2494 {
2495 /* Skip the other windows on this frame.
2496 There might be one, the minibuffer! */
2497 while (CONSP (XCDR (windows))
2498 && EQ (XWINDOW (XCAR (windows))->frame,
2499 XWINDOW (XCAR (XCDR (windows)))->frame))
2500 windows = XCDR (windows);
2501
2502 /* Now we can safely delete the frame. */
2503 delete_frame (w->frame, Qnil);
2504 }
2505 else if (NILP (w->parent))
2506 { 2478 {
2507 /* If we're deleting the buffer displayed in the 2479 best_window = window;
2508 only window on the frame, find a new buffer to 2480 frame_best_window_flag = 1;
2509 display there. */
2510 Lisp_Object buffer;
2511 buffer = Fother_buffer (obj, Qnil, w->frame);
2512 /* Reset dedicated state of window. */
2513 w->dedicated = Qnil;
2514 Fset_window_buffer (window, buffer, Qnil);
2515 if (EQ (window, selected_window))
2516 Fset_buffer (w->buffer);
2517 } 2481 }
2518 else 2482 else if (NILP (best_window))
2519 call1 (Qdelete_window, window); 2483 best_window = window;
2520 } 2484 }
2521 break; 2485 break;
2522 2486
2523 case UNSHOW_BUFFER: 2487 case REPLACE_BUFFER_IN_WINDOWS_SAFELY:
2488 /* We could simply check whether the buffer shown by window
2489 is live, and show another buffer in case it isn't. */
2524 if (EQ (w->buffer, obj)) 2490 if (EQ (w->buffer, obj))
2525 { 2491 {
2526 Lisp_Object buffer; 2492 /* Undedicate WINDOW. */
2527 struct frame *fr = XFRAME (w->frame); 2493 w->dedicated = Qnil;
2528 2494 /* Make WINDOW show the buffer returned by
2529 /* Find another buffer to show in this window. */ 2495 other_buffer_safely, don't run any hooks. */
2530 buffer = Fother_buffer (obj, Qnil, w->frame); 2496 set_window_buffer
2531 2497 (window, other_buffer_safely (w->buffer), 0, 0);
2532 /* If this window is dedicated, and in a frame of its own, 2498 /* If WINDOW is the selected window, make its buffer
2533 kill the frame. */ 2499 current. But do so only if the window shows the
2534 if (EQ (window, FRAME_ROOT_WINDOW (fr)) 2500 current buffer (Bug#6454). */
2535 && !NILP (w->dedicated) 2501 if (EQ (window, selected_window)
2536 && other_visible_frames (fr)) 2502 && XBUFFER (w->buffer) == current_buffer)
2537 { 2503 Fset_buffer (w->buffer);
2538 /* Skip the other windows on this frame.
2539 There might be one, the minibuffer! */
2540 while (CONSP (XCDR (windows))
2541 && EQ (XWINDOW (XCAR (windows))->frame,
2542 XWINDOW (XCAR (XCDR (windows)))->frame))
2543 windows = XCDR (windows);
2544
2545 /* Now we can safely delete the frame. */
2546 delete_frame (w->frame, Qnil);
2547 }
2548 else if (!NILP (w->dedicated) && !NILP (w->parent))
2549 {
2550 Lisp_Object window_to_delete;
2551 XSETWINDOW (window_to_delete, w);
2552 /* If this window is dedicated and not the only window
2553 in its frame, then kill it. */
2554 call1 (Qdelete_window, window_to_delete);
2555 }
2556 else
2557 {
2558 /* Otherwise show a different buffer in the window. */
2559 w->dedicated = Qnil;
2560 Fset_window_buffer (window, buffer, Qnil);
2561 if (EQ (window, selected_window))
2562 Fset_buffer (w->buffer);
2563 }
2564 } 2504 }
2565 break; 2505 break;
2566 2506
@@ -2875,85 +2815,26 @@ window-start value is reasonable when this function is called. */)
2875} 2815}
2876 2816
2877 2817
2878DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on, 2818void
2879 0, 2, "bDelete windows on (buffer): ", 2819replace_buffer_in_windows (Lisp_Object buffer)
2880 doc: /* Delete all windows showing BUFFER-OR-NAME.
2881BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
2882defaults to the current buffer.
2883
2884Optional second argument FRAME controls which frames are affected.
2885If optional argument FRAME is `visible', search all visible frames.
2886If FRAME is 0, search all visible and iconified frames.
2887If FRAME is nil, search all frames.
2888If FRAME is t, search only the selected frame.
2889If FRAME is a frame, search only that frame.
2890When a window showing BUFFER-OR-NAME is dedicated and the only window of
2891its frame, that frame is deleted when there are other frames left. */)
2892 (Lisp_Object buffer_or_name, Lisp_Object frame)
2893{ 2820{
2894 Lisp_Object buffer; 2821 call1 (Qreplace_buffer_in_windows, buffer);
2895
2896 /* FRAME uses t and nil to mean the opposite of what window_loop
2897 expects. */
2898 if (NILP (frame))
2899 frame = Qt;
2900 else if (EQ (frame, Qt))
2901 frame = Qnil;
2902
2903 if (NILP (buffer_or_name))
2904 buffer = Fcurrent_buffer ();
2905 else
2906 {
2907 buffer = Fget_buffer (buffer_or_name);
2908 CHECK_BUFFER (buffer);
2909 }
2910
2911 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame);
2912
2913 return Qnil;
2914} 2822}
2915 2823
2916DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows,
2917 Sreplace_buffer_in_windows,
2918 0, 1, "bReplace buffer in windows: ",
2919 doc: /* Replace BUFFER-OR-NAME with some other buffer in all windows showing it.
2920BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
2921defaults to the current buffer.
2922
2923When a window showing BUFFER-OR-NAME is dedicated that window is
2924deleted. If that window is the only window on its frame, that frame is
2925deleted too when there are other frames left. If there are no other
2926frames left, some other buffer is displayed in that window. */)
2927 (Lisp_Object buffer_or_name)
2928{
2929 Lisp_Object buffer;
2930
2931 if (NILP (buffer_or_name))
2932 buffer = Fcurrent_buffer ();
2933 else
2934 {
2935 buffer = Fget_buffer (buffer_or_name);
2936 CHECK_BUFFER (buffer);
2937 }
2938
2939 window_loop (UNSHOW_BUFFER, buffer, 0, Qt);
2940
2941 return Qnil;
2942}
2943 2824
2944/* Replace BUFFER with some other buffer in all windows 2825/* Safely replace BUFFER with some other buffer in all windows of all
2945 of all frames, even those on other keyboards. */ 2826 frames, even those on other keyboards. */
2946 2827
2947void 2828void
2948replace_buffer_in_all_windows (Lisp_Object buffer) 2829replace_buffer_in_windows_safely (Lisp_Object buffer)
2949{ 2830{
2950 Lisp_Object tail, frame; 2831 Lisp_Object tail, frame;
2951 2832
2952 /* A single call to window_loop won't do the job 2833 /* A single call to window_loop won't do the job because it only
2953 because it only considers frames on the current keyboard. 2834 considers frames on the current keyboard. So loop manually over
2954 So loop manually over frames, and handle each one. */ 2835 frames, and handle each one. */
2955 FOR_EACH_FRAME (tail, frame) 2836 FOR_EACH_FRAME (tail, frame)
2956 window_loop (UNSHOW_BUFFER, buffer, 1, frame); 2837 window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame);
2957} 2838}
2958 2839
2959/* If *ROWS or *COLS are too small a size for FRAME, set them to the 2840/* If *ROWS or *COLS are too small a size for FRAME, set them to the
@@ -3014,8 +2895,6 @@ adjust_window_margins (struct window *w)
3014 return 1; 2895 return 1;
3015} 2896}
3016 2897
3017int window_select_count;
3018
3019static Lisp_Object Fset_window_margins (Lisp_Object, Lisp_Object, Lisp_Object); 2898static Lisp_Object Fset_window_margins (Lisp_Object, Lisp_Object, Lisp_Object);
3020static Lisp_Object Fset_window_fringes (Lisp_Object, Lisp_Object, Lisp_Object, 2899static Lisp_Object Fset_window_fringes (Lisp_Object, Lisp_Object, Lisp_Object,
3021 Lisp_Object); 2900 Lisp_Object);
@@ -3023,6 +2902,8 @@ static Lisp_Object Fset_window_scroll_bars (Lisp_Object, Lisp_Object,
3023 Lisp_Object, Lisp_Object); 2902 Lisp_Object, Lisp_Object);
3024static Lisp_Object Fset_window_vscroll (Lisp_Object, Lisp_Object, Lisp_Object); 2903static Lisp_Object Fset_window_vscroll (Lisp_Object, Lisp_Object, Lisp_Object);
3025 2904
2905/* The following three routines are needed for running a window's
2906 configuration change hook. */
3026static void 2907static void
3027run_funs (Lisp_Object funs) 2908run_funs (Lisp_Object funs)
3028{ 2909{
@@ -3031,8 +2912,19 @@ run_funs (Lisp_Object funs)
3031 call0 (XCAR (funs)); 2912 call0 (XCAR (funs));
3032} 2913}
3033 2914
3034static Lisp_Object select_window_norecord (Lisp_Object window); 2915static Lisp_Object
3035static Lisp_Object select_frame_norecord (Lisp_Object frame); 2916select_window_norecord (Lisp_Object window)
2917{
2918 return WINDOW_LIVE_P (window)
2919 ? Fselect_window (window, Qt) : selected_window;
2920}
2921
2922static Lisp_Object
2923select_frame_norecord (Lisp_Object frame)
2924{
2925 return FRAME_LIVE_P (XFRAME (frame))
2926 ? Fselect_frame (frame, Qt) : selected_frame;
2927}
3036 2928
3037void 2929void
3038run_window_configuration_change_hook (struct frame *f) 2930run_window_configuration_change_hook (struct frame *f)
@@ -3209,11 +3101,13 @@ WINDOW can be any window and defaults to the selected one. */)
3209 3101
3210DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, 3102DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
3211 doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. 3103 doc: /* Make WINDOW display BUFFER-OR-NAME as its contents.
3212WINDOW defaults to the selected window. BUFFER-OR-NAME must be a buffer 3104WINDOW has to be a live window and defaults to the selected one.
3213or the name of an existing buffer. Optional third argument KEEP-MARGINS 3105BUFFER-OR-NAME must be a buffer or the name of an existing buffer.
3214non-nil means that WINDOW's current display margins, fringe widths, and 3106
3215scroll bar settings are preserved; the default is to reset these from 3107Optional third argument KEEP-MARGINS non-nil means that WINDOW's current
3216the local settings for BUFFER-OR-NAME or the frame defaults. Return nil. 3108display margins, fringe widths, and scroll bar settings are preserved;
3109the default is to reset these from the local settings for BUFFER-OR-NAME
3110or the frame defaults. Return nil.
3217 3111
3218This function throws an error when WINDOW is strongly dedicated to its 3112This function throws an error when WINDOW is strongly dedicated to its
3219buffer (that is `window-dedicated-p' returns t for WINDOW) and does not 3113buffer (that is `window-dedicated-p' returns t for WINDOW) and does not
@@ -3238,32 +3132,26 @@ This function runs `window-scroll-functions' before running
3238 else if (!EQ (tem, Qt)) 3132 else if (!EQ (tem, Qt))
3239 /* w->buffer is t when the window is first being set up. */ 3133 /* w->buffer is t when the window is first being set up. */
3240 { 3134 {
3241 if (EQ (tem, buffer)) 3135 if (!EQ (tem, buffer))
3242 return Qnil; 3136 {
3243 else if (EQ (w->dedicated, Qt)) 3137 if (EQ (w->dedicated, Qt))
3244 error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem), name))); 3138 /* WINDOW is strongly dedicated to its buffer, signal an
3245 else 3139 error. */
3246 w->dedicated = Qnil; 3140 error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem), name)));
3141 else
3142 /* WINDOW is weakly dedicated to its buffer, reset
3143 dedicatedness. */
3144 w->dedicated = Qnil;
3145
3146 call1 (Qrecord_window_buffer, window);
3147 }
3247 3148
3248 unshow_buffer (w); 3149 unshow_buffer (w);
3249 } 3150 }
3250 3151
3251 set_window_buffer (window, buffer, 1, !NILP (keep_margins)); 3152 set_window_buffer (window, buffer, 1, !NILP (keep_margins));
3252 return Qnil;
3253}
3254 3153
3255static Lisp_Object 3154 return Qnil;
3256select_window_norecord (Lisp_Object window)
3257{
3258 return WINDOW_LIVE_P (window)
3259 ? Fselect_window (window, Qt) : selected_window;
3260}
3261
3262static Lisp_Object
3263select_frame_norecord (Lisp_Object frame)
3264{
3265 return FRAME_LIVE_P (XFRAME (frame))
3266 ? Fselect_frame (frame, Qt) : selected_frame;
3267} 3155}
3268 3156
3269static Lisp_Object 3157static Lisp_Object
@@ -3336,7 +3224,10 @@ temp_output_buffer_show (register Lisp_Object buf)
3336 call1 (Vtemp_buffer_show_function, buf); 3224 call1 (Vtemp_buffer_show_function, buf);
3337 else 3225 else
3338 { 3226 {
3339 window = display_buffer (buf, Qnil, Qnil); 3227 window = display_buffer (buf, Vtemp_buffer_show_specifiers, Qnil);
3228 /* Reset Vtemp_buffer_show_specifiers immediately so it won't
3229 affect subsequent calls. */
3230 Vtemp_buffer_show_specifiers = Qnil;
3340 3231
3341 if (!EQ (XWINDOW (window)->frame, selected_frame)) 3232 if (!EQ (XWINDOW (window)->frame, selected_frame))
3342 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); 3233 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
@@ -3799,7 +3690,7 @@ resize_frame_windows (struct frame *f, int size, int horflag)
3799DEFUN ("split-window-internal", Fsplit_window_internal, Ssplit_window_internal, 4, 4, 0, 3690DEFUN ("split-window-internal", Fsplit_window_internal, Ssplit_window_internal, 4, 4, 0,
3800 doc: /* Split window OLD. 3691 doc: /* Split window OLD.
3801Second argument TOTAL-SIZE specifies the number of lines or columns of the 3692Second argument TOTAL-SIZE specifies the number of lines or columns of the
3802new window. In any case TOTAL-SIZE must be a positive integer 3693new window. In any case TOTAL-SIZE must be a positive integer.
3803 3694
3804Third argument SIDE nil (or `below') specifies that the new window shall 3695Third argument SIDE nil (or `below') specifies that the new window shall
3805be located below WINDOW. SIDE `above' means the new window shall be 3696be located below WINDOW. SIDE `above' means the new window shall be
@@ -4280,7 +4171,6 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4280 else error ("Failed to resize minibuffer window"); 4171 else error ("Failed to resize minibuffer window");
4281} 4172}
4282 4173
4283
4284/* Mark window cursors off for all windows in the window tree rooted 4174/* Mark window cursors off for all windows in the window tree rooted
4285 at W by setting their phys_cursor_on_p flag to zero. Called from 4175 at W by setting their phys_cursor_on_p flag to zero. Called from
4286 xterm.c, e.g. when a frame is cleared and thereby all cursors on 4176 xterm.c, e.g. when a frame is cleared and thereby all cursors on
@@ -5337,7 +5227,6 @@ and redisplay normally--don't erase and redraw the frame. */)
5337 return Qnil; 5227 return Qnil;
5338} 5228}
5339 5229
5340
5341DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, 5230DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height,
5342 0, 1, 0, 5231 0, 1, 0,
5343 doc: /* Return the height in lines of the text display area of WINDOW. 5232 doc: /* Return the height in lines of the text display area of WINDOW.
@@ -5510,6 +5399,7 @@ the return value is nil. Otherwise the value is t. */)
5510 struct Lisp_Vector *saved_windows; 5399 struct Lisp_Vector *saved_windows;
5511 Lisp_Object new_current_buffer; 5400 Lisp_Object new_current_buffer;
5512 Lisp_Object frame; 5401 Lisp_Object frame;
5402 Lisp_Object auto_buffer_name;
5513 FRAME_PTR f; 5403 FRAME_PTR f;
5514 EMACS_INT old_point = -1; 5404 EMACS_INT old_point = -1;
5515 5405
@@ -5565,6 +5455,8 @@ the return value is nil. Otherwise the value is t. */)
5565 However, there is other stuff we should still try to do below. */ 5455 However, there is other stuff we should still try to do below. */
5566 if (FRAME_LIVE_P (f)) 5456 if (FRAME_LIVE_P (f))
5567 { 5457 {
5458 Lisp_Object window;
5459 Lisp_Object dead_windows = Qnil;
5568 register struct window *w; 5460 register struct window *w;
5569 register struct saved_window *p; 5461 register struct saved_window *p;
5570 struct window *root_window; 5462 struct window *root_window;
@@ -5641,7 +5533,8 @@ the return value is nil. Otherwise the value is t. */)
5641 for (k = 0; k < saved_windows->header.size; k++) 5533 for (k = 0; k < saved_windows->header.size; k++)
5642 { 5534 {
5643 p = SAVED_WINDOW_N (saved_windows, k); 5535 p = SAVED_WINDOW_N (saved_windows, k);
5644 w = XWINDOW (p->window); 5536 window = p->window;
5537 w = XWINDOW (window);
5645 w->next = Qnil; 5538 w->next = Qnil;
5646 5539
5647 if (!NILP (p->parent)) 5540 if (!NILP (p->parent))
@@ -5704,55 +5597,70 @@ the return value is nil. Otherwise the value is t. */)
5704 5597
5705 /* Reinstall the saved buffer and pointers into it. */ 5598 /* Reinstall the saved buffer and pointers into it. */
5706 if (NILP (p->buffer)) 5599 if (NILP (p->buffer))
5600 /* An internal window. */
5707 w->buffer = p->buffer; 5601 w->buffer = p->buffer;
5602 else if (!NILP (BVAR (XBUFFER (p->buffer), name)))
5603 /* If saved buffer is alive, install it. */
5604 {
5605 w->buffer = p->buffer;
5606 w->start_at_line_beg = p->start_at_line_beg;
5607 set_marker_restricted (w->start, p->start, w->buffer);
5608 set_marker_restricted (w->pointm, p->pointm, w->buffer);
5609 Fset_marker (BVAR (XBUFFER (w->buffer), mark),
5610 p->mark, w->buffer);
5611
5612 /* As documented in Fcurrent_window_configuration, don't
5613 restore the location of point in the buffer which was
5614 current when the window configuration was recorded. */
5615 if (!EQ (p->buffer, new_current_buffer)
5616 && XBUFFER (p->buffer) == current_buffer)
5617 Fgoto_char (w->pointm);
5618 }
5619 else if (!NILP (w->buffer) && !NILP (BVAR (XBUFFER (w->buffer), name)))
5620 /* Keep window's old buffer; make sure the markers are
5621 real. */
5622 {
5623 /* Set window markers at start of visible range. */
5624 if (XMARKER (w->start)->buffer == 0)
5625 set_marker_restricted (w->start, make_number (0),
5626 w->buffer);
5627 if (XMARKER (w->pointm)->buffer == 0)
5628 set_marker_restricted_both (w->pointm, w->buffer,
5629 BUF_PT (XBUFFER (w->buffer)),
5630 BUF_PT_BYTE (XBUFFER (w->buffer)));
5631 w->start_at_line_beg = Qt;
5632 }
5633 else if (STRINGP (auto_buffer_name =
5634 Fwindow_parameter (window, Qauto_buffer_name))
5635 && SCHARS (auto_buffer_name) != 0
5636 && !NILP (w->buffer = Fget_buffer_create (auto_buffer_name)))
5637 {
5638 set_marker_restricted (w->start, make_number (0), w->buffer);
5639 set_marker_restricted (w->pointm, make_number (0), w->buffer);
5640 w->start_at_line_beg = Qt;
5641 }
5708 else 5642 else
5643 /* Window has no live buffer, get one. */
5709 { 5644 {
5710 if (!NILP (BVAR (XBUFFER (p->buffer), name))) 5645 /* Get the buffer via other_buffer_safely in order to
5711 /* If saved buffer is alive, install it. */ 5646 avoid showing an unimportant buffer and, if necessary, to
5712 { 5647 recreate *scratch* in the course (part of Juanma's bs-show
5713 w->buffer = p->buffer; 5648 scenario from March 2011). */
5714 w->start_at_line_beg = p->start_at_line_beg; 5649 w->buffer = other_buffer_safely (Fcurrent_buffer ());
5715 set_marker_restricted (w->start, p->start, w->buffer); 5650 /* This will set the markers to beginning of visible
5716 set_marker_restricted (w->pointm, p->pointm, w->buffer); 5651 range. */
5717 Fset_marker (BVAR (XBUFFER (w->buffer), mark), 5652 set_marker_restricted (w->start, make_number (0), w->buffer);
5718 p->mark, w->buffer); 5653 set_marker_restricted (w->pointm, make_number (0), w->buffer);
5719 5654 w->start_at_line_beg = Qt;
5720 /* As documented in Fcurrent_window_configuration, don't 5655 if (!NILP (w->dedicated))
5721 restore the location of point in the buffer which was 5656 /* Record this window as dead. */
5722 current when the window configuration was recorded. */ 5657 dead_windows = Fcons (window, dead_windows);
5723 if (!EQ (p->buffer, new_current_buffer) 5658 /* Make sure window is no more dedicated. */
5724 && XBUFFER (p->buffer) == current_buffer) 5659 w->dedicated = Qnil;
5725 Fgoto_char (w->pointm);
5726 }
5727 else if (NILP (w->buffer) || NILP (BVAR (XBUFFER (w->buffer), name)))
5728 /* Else unless window has a live buffer, get one. */
5729 {
5730 w->buffer = Fcdr (Fcar (Vbuffer_alist));
5731 /* This will set the markers to beginning of visible
5732 range. */
5733 set_marker_restricted (w->start, make_number (0), w->buffer);
5734 set_marker_restricted (w->pointm, make_number (0),w->buffer);
5735 w->start_at_line_beg = Qt;
5736 }
5737 else
5738 /* Keeping window's old buffer; make sure the markers
5739 are real. */
5740 {
5741 /* Set window markers at start of visible range. */
5742 if (XMARKER (w->start)->buffer == 0)
5743 set_marker_restricted (w->start, make_number (0),
5744 w->buffer);
5745 if (XMARKER (w->pointm)->buffer == 0)
5746 set_marker_restricted_both (w->pointm, w->buffer,
5747 BUF_PT (XBUFFER (w->buffer)),
5748 BUF_PT_BYTE (XBUFFER (w->buffer)));
5749 w->start_at_line_beg = Qt;
5750 }
5751 } 5660 }
5752 } 5661 }
5753 5662
5754 FRAME_ROOT_WINDOW (f) = data->root_window; 5663 FRAME_ROOT_WINDOW (f) = data->root_window;
5755
5756 /* Arrange *not* to restore point in the buffer that was 5664 /* Arrange *not* to restore point in the buffer that was
5757 current when the window configuration was saved. */ 5665 current when the window configuration was saved. */
5758 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5666 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer))
@@ -5760,10 +5668,10 @@ the return value is nil. Otherwise the value is t. */)
5760 make_number (old_point), 5668 make_number (old_point),
5761 XWINDOW (data->current_window)->buffer); 5669 XWINDOW (data->current_window)->buffer);
5762 5670
5763 /* In the following call to `select-window, prevent "swapping 5671 /* In the following call to `select-window', prevent "swapping out
5764 out point" in the old selected window using the buffer that 5672 point" in the old selected window using the buffer that has
5765 has been restored into it. We already swapped out that point 5673 been restored into it. We already swapped out that point from
5766 from that window's old buffer. */ 5674 that window's old buffer. */
5767 select_window (data->current_window, Qnil, 1); 5675 select_window (data->current_window, Qnil, 1);
5768 BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window) 5676 BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window)
5769 = selected_window; 5677 = selected_window;
@@ -5804,9 +5712,16 @@ the return value is nil. Otherwise the value is t. */)
5804 } 5712 }
5805 5713
5806 adjust_glyphs (f); 5714 adjust_glyphs (f);
5807
5808 UNBLOCK_INPUT; 5715 UNBLOCK_INPUT;
5809 5716
5717 /* Scan dead buffer windows. */
5718 for (; CONSP (dead_windows); dead_windows = XCDR (dead_windows))
5719 {
5720 window = XCAR (dead_windows);
5721 if (WINDOW_LIVE_P (window) && !EQ (window, FRAME_ROOT_WINDOW (f)))
5722 delete_deletable_window (window);
5723 }
5724
5810 /* Fselect_window will have made f the selected frame, so we 5725 /* Fselect_window will have made f the selected frame, so we
5811 reselect the proper frame here. Fhandle_switch_frame will change the 5726 reselect the proper frame here. Fhandle_switch_frame will change the
5812 selected window too, but that doesn't make the call to 5727 selected window too, but that doesn't make the call to
@@ -6052,82 +5967,6 @@ redirection (see `redirect-frame-focus'). */)
6052 XSETWINDOW_CONFIGURATION (tem, data); 5967 XSETWINDOW_CONFIGURATION (tem, data);
6053 return (tem); 5968 return (tem);
6054} 5969}
6055
6056
6057/***********************************************************************
6058 Window Split Tree
6059 ***********************************************************************/
6060
6061static Lisp_Object
6062window_tree (struct window *w)
6063{
6064 Lisp_Object tail = Qnil;
6065 Lisp_Object result = Qnil;
6066
6067 while (w)
6068 {
6069 Lisp_Object wn;
6070
6071 XSETWINDOW (wn, w);
6072 if (!NILP (w->hchild))
6073 wn = Fcons (Qnil, Fcons (Fwindow_edges (wn),
6074 window_tree (XWINDOW (w->hchild))));
6075 else if (!NILP (w->vchild))
6076 wn = Fcons (Qt, Fcons (Fwindow_edges (wn),
6077 window_tree (XWINDOW (w->vchild))));
6078
6079 if (NILP (result))
6080 {
6081 result = tail = Fcons (wn, Qnil);
6082 }
6083 else
6084 {
6085 XSETCDR (tail, Fcons (wn, Qnil));
6086 tail = XCDR (tail);
6087 }
6088
6089 w = NILP (w->next) ? 0 : XWINDOW (w->next);
6090 }
6091
6092 return result;
6093}
6094
6095
6096
6097DEFUN ("window-tree", Fwindow_tree, Swindow_tree,
6098 0, 1, 0,
6099 doc: /* Return the window tree for frame FRAME.
6100
6101The return value is a list of the form (ROOT MINI), where ROOT
6102represents the window tree of the frame's root window, and MINI
6103is the frame's minibuffer window.
6104
6105If the root window is not split, ROOT is the root window itself.
6106Otherwise, ROOT is a list (DIR EDGES W1 W2 ...) where DIR is nil for a
6107horizontal split, and t for a vertical split, EDGES gives the combined
6108size and position of the subwindows in the split, and the rest of the
6109elements are the subwindows in the split. Each of the subwindows may
6110again be a window or a list representing a window split, and so on.
6111EDGES is a list \(LEFT TOP RIGHT BOTTOM) as returned by `window-edges'.
6112
6113If FRAME is nil or omitted, return information on the currently
6114selected frame. */)
6115 (Lisp_Object frame)
6116{
6117 FRAME_PTR f;
6118
6119 if (NILP (frame))
6120 frame = selected_frame;
6121
6122 CHECK_FRAME (frame);
6123 f = XFRAME (frame);
6124
6125 if (!FRAME_LIVE_P (f))
6126 return Qnil;
6127
6128 return window_tree (XWINDOW (FRAME_ROOT_WINDOW (f)));
6129}
6130
6131 5970
6132/*********************************************************************** 5971/***********************************************************************
6133 Marginal Areas 5972 Marginal Areas
@@ -6487,116 +6326,81 @@ freeze_window_starts (struct frame *f, int freeze_p)
6487 Initialization 6326 Initialization
6488 ***********************************************************************/ 6327 ***********************************************************************/
6489 6328
6490/* Return 1 if window configurations C1 and C2 6329/* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2
6491 describe the same state of affairs. This is used by Fequal. */ 6330 describe the same state of affairs. This is used by Fequal.
6331
6332 ignore_positions non-zero means ignore non-matching scroll positions
6333 and the like.
6334
6335 This ignores a couple of things like the dedicatedness status of
6336 window, splits, nest and the like. This might have to be fixed. */
6492 6337
6493int 6338int
6494compare_window_configurations (Lisp_Object c1, Lisp_Object c2, int ignore_positions) 6339compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions)
6495{ 6340{
6496 register struct save_window_data *d1, *d2; 6341 register struct save_window_data *d1, *d2;
6497 struct Lisp_Vector *sw1, *sw2; 6342 struct Lisp_Vector *sws1, *sws2;
6498 int i; 6343 int i;
6499 6344
6500 CHECK_WINDOW_CONFIGURATION (c1); 6345 CHECK_WINDOW_CONFIGURATION (configuration1);
6501 CHECK_WINDOW_CONFIGURATION (c2); 6346 CHECK_WINDOW_CONFIGURATION (configuration2);
6502 6347
6503 d1 = (struct save_window_data *) XVECTOR (c1); 6348 d1 = (struct save_window_data *) XVECTOR (configuration1);
6504 d2 = (struct save_window_data *) XVECTOR (c2); 6349 d2 = (struct save_window_data *) XVECTOR (configuration2);
6505 sw1 = XVECTOR (d1->saved_windows); 6350 sws1 = XVECTOR (d1->saved_windows);
6506 sw2 = XVECTOR (d2->saved_windows); 6351 sws2 = XVECTOR (d2->saved_windows);
6507 6352
6508 if (d1->frame_cols != d2->frame_cols) 6353 /* Frame settings must match. */
6509 return 0; 6354 if (d1->frame_cols != d2->frame_cols
6510 if (d1->frame_lines != d2->frame_lines) 6355 || d1->frame_lines != d2->frame_lines
6511 return 0; 6356 || d1->frame_menu_bar_lines != d2->frame_menu_bar_lines
6512 if (d1->frame_menu_bar_lines != d2->frame_menu_bar_lines) 6357 || !EQ (d1->selected_frame, d2->selected_frame)
6513 return 0; 6358 || !EQ (d1->current_buffer, d2->current_buffer)
6514 if (! EQ (d1->selected_frame, d2->selected_frame)) 6359 || (!ignore_positions
6515 return 0; 6360 && (!EQ (d1->minibuf_scroll_window, d2->minibuf_scroll_window)
6516 /* Don't compare the current_window field directly. 6361 || !EQ (d1->minibuf_selected_window, d2->minibuf_selected_window)))
6517 Instead see w1_is_current and w2_is_current, below. */ 6362 || !EQ (d1->focus_frame, d2->focus_frame)
6518 if (! EQ (d1->current_buffer, d2->current_buffer)) 6363 /* Verify that the two configurations have the same number of windows. */
6519 return 0; 6364 || sws1->header.size != sws2->header.size)
6520 if (! ignore_positions)
6521 {
6522 if (! EQ (d1->minibuf_scroll_window, d2->minibuf_scroll_window))
6523 return 0;
6524 if (! EQ (d1->minibuf_selected_window, d2->minibuf_selected_window))
6525 return 0;
6526 }
6527 /* Don't compare the root_window field.
6528 We don't require the two configurations
6529 to use the same window object,
6530 and the two root windows must be equivalent
6531 if everything else compares equal. */
6532 if (! EQ (d1->focus_frame, d2->focus_frame))
6533 return 0;
6534
6535 /* Verify that the two confis have the same number of windows. */
6536 if (sw1->header.size != sw2->header.size)
6537 return 0; 6365 return 0;
6538 6366
6539 for (i = 0; i < sw1->header.size; i++) 6367 for (i = 0; i < sws1->header.size; i++)
6540 { 6368 {
6541 struct saved_window *p1, *p2; 6369 struct saved_window *sw1, *sw2;
6542 int w1_is_current, w2_is_current; 6370
6543 6371 sw1 = SAVED_WINDOW_N (sws1, i);
6544 p1 = SAVED_WINDOW_N (sw1, i); 6372 sw2 = SAVED_WINDOW_N (sws2, i);
6545 p2 = SAVED_WINDOW_N (sw2, i); 6373
6546 6374 if (
6547 /* Verify that the current windows in the two 6375 /* The "current" windows in the two configurations must
6548 configurations correspond to each other. */ 6376 correspond to each other. */
6549 w1_is_current = EQ (d1->current_window, p1->window); 6377 EQ (d1->current_window, sw1->window)
6550 w2_is_current = EQ (d2->current_window, p2->window); 6378 != EQ (d2->current_window, sw2->window)
6551 6379 /* Windows' buffers must match. */
6552 if (w1_is_current != w2_is_current) 6380 || !EQ (sw1->buffer, sw2->buffer)
6553 return 0; 6381 || !EQ (sw1->left_col, sw2->left_col)
6554 6382 || !EQ (sw1->top_line, sw2->top_line)
6555 /* Verify that the corresponding windows do match. */ 6383 || !EQ (sw1->total_cols, sw2->total_cols)
6556 if (! EQ (p1->buffer, p2->buffer)) 6384 || !EQ (sw1->total_lines, sw2->total_lines)
6557 return 0; 6385 || !EQ (sw1->display_table, sw2->display_table)
6558 if (! EQ (p1->left_col, p2->left_col)) 6386 /* The next two disjuncts check the window structure for
6559 return 0; 6387 equality. */
6560 if (! EQ (p1->top_line, p2->top_line)) 6388 || !EQ (sw1->parent, sw2->parent)
6561 return 0; 6389 || !EQ (sw1->prev, sw2->prev)
6562 if (! EQ (p1->total_cols, p2->total_cols)) 6390 || (!ignore_positions
6563 return 0; 6391 && (!EQ (sw1->hscroll, sw2->hscroll)
6564 if (! EQ (p1->total_lines, p2->total_lines)) 6392 || !EQ (sw1->min_hscroll, sw2->min_hscroll)
6565 return 0; 6393 || !EQ (sw1->start_at_line_beg, sw2->start_at_line_beg)
6566 if (! EQ (p1->display_table, p2->display_table)) 6394 || NILP (Fequal (sw1->start, sw2->start))
6567 return 0; 6395 || NILP (Fequal (sw1->pointm, sw2->pointm))
6568 if (! EQ (p1->parent, p2->parent)) 6396 || NILP (Fequal (sw1->mark, sw2->mark))))
6569 return 0; 6397 || !EQ (sw1->left_margin_cols, sw2->left_margin_cols)
6570 if (! EQ (p1->prev, p2->prev)) 6398 || !EQ (sw1->right_margin_cols, sw2->right_margin_cols)
6571 return 0; 6399 || !EQ (sw1->left_fringe_width, sw2->left_fringe_width)
6572 if (! ignore_positions) 6400 || !EQ (sw1->right_fringe_width, sw2->right_fringe_width)
6573 { 6401 || !EQ (sw1->fringes_outside_margins, sw2->fringes_outside_margins)
6574 if (! EQ (p1->hscroll, p2->hscroll)) 6402 || !EQ (sw1->scroll_bar_width, sw2->scroll_bar_width)
6575 return 0; 6403 || !EQ (sw1->vertical_scroll_bar_type, sw2->vertical_scroll_bar_type))
6576 if (!EQ (p1->min_hscroll, p2->min_hscroll))
6577 return 0;
6578 if (! EQ (p1->start_at_line_beg, p2->start_at_line_beg))
6579 return 0;
6580 if (NILP (Fequal (p1->start, p2->start)))
6581 return 0;
6582 if (NILP (Fequal (p1->pointm, p2->pointm)))
6583 return 0;
6584 if (NILP (Fequal (p1->mark, p2->mark)))
6585 return 0;
6586 }
6587 if (! EQ (p1->left_margin_cols, p2->left_margin_cols))
6588 return 0;
6589 if (! EQ (p1->right_margin_cols, p2->right_margin_cols))
6590 return 0;
6591 if (! EQ (p1->left_fringe_width, p2->left_fringe_width))
6592 return 0;
6593 if (! EQ (p1->right_fringe_width, p2->right_fringe_width))
6594 return 0;
6595 if (! EQ (p1->fringes_outside_margins, p2->fringes_outside_margins))
6596 return 0;
6597 if (! EQ (p1->scroll_bar_width, p2->scroll_bar_width))
6598 return 0;
6599 if (! EQ (p1->vertical_scroll_bar_type, p2->vertical_scroll_bar_type))
6600 return 0; 6404 return 0;
6601 } 6405 }
6602 6406
@@ -6719,6 +6523,16 @@ If this function is used, then it must do the entire job of showing
6719the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */); 6523the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */);
6720 Vtemp_buffer_show_function = Qnil; 6524 Vtemp_buffer_show_function = Qnil;
6721 6525
6526 DEFVAR_LISP ("temp-buffer-show-specifiers", Vtemp_buffer_show_specifiers,
6527 doc: /* Buffer display specifiers used by `with-output-to-temp-buffer'.
6528These specifiers are passed by `with-output-to-temp-buffer' as second
6529argument to `display-buffer'. Applications should only let-bind this
6530around a call to `with-output-to-temp-buffer'.
6531
6532For a description of buffer display specifiers see the variable
6533`display-buffer-alist'. */);
6534 Vtemp_buffer_show_specifiers = Qnil;
6535
6722 DEFVAR_LISP ("minibuffer-scroll-window", Vminibuf_scroll_window, 6536 DEFVAR_LISP ("minibuffer-scroll-window", Vminibuf_scroll_window,
6723 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */); 6537 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
6724 Vminibuf_scroll_window = Qnil; 6538 Vminibuf_scroll_window = Qnil;
@@ -6734,16 +6548,16 @@ is displayed in the `mode-line' face. */);
6734 Vother_window_scroll_buffer = Qnil; 6548 Vother_window_scroll_buffer = Qnil;
6735 6549
6736 DEFVAR_BOOL ("auto-window-vscroll", auto_window_vscroll_p, 6550 DEFVAR_BOOL ("auto-window-vscroll", auto_window_vscroll_p,
6737 doc: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */); 6551 doc: /* Non-nil means to automatically adjust `window-vscroll' to view tall lines. */);
6738 auto_window_vscroll_p = 1; 6552 auto_window_vscroll_p = 1;
6739 6553
6740 DEFVAR_INT ("next-screen-context-lines", next_screen_context_lines, 6554 DEFVAR_INT ("next-screen-context-lines", next_screen_context_lines,
6741 doc: /* *Number of lines of continuity when scrolling by screenfuls. */); 6555 doc: /* Number of lines of continuity when scrolling by screenfuls. */);
6742 next_screen_context_lines = 2; 6556 next_screen_context_lines = 2;
6743 6557
6744 DEFVAR_LISP ("scroll-preserve-screen-position", 6558 DEFVAR_LISP ("scroll-preserve-screen-position",
6745 Vscroll_preserve_screen_position, 6559 Vscroll_preserve_screen_position,
6746 doc: /* *Controls if scroll commands move point to keep its screen position unchanged. 6560 doc: /* Controls if scroll commands move point to keep its screen position unchanged.
6747A value of nil means point does not keep its screen position except 6561A value of nil means point does not keep its screen position except
6748at the scroll margin or window boundary respectively. 6562at the scroll margin or window boundary respectively.
6749A value of t means point keeps its screen position if the scroll 6563A value of t means point keeps its screen position if the scroll
@@ -6865,10 +6679,7 @@ function `window-nest' and altered by the function `set-window-nest'. */);
6865 defsubr (&Sset_window_display_table); 6679 defsubr (&Sset_window_display_table);
6866 defsubr (&Snext_window); 6680 defsubr (&Snext_window);
6867 defsubr (&Sprevious_window); 6681 defsubr (&Sprevious_window);
6868 defsubr (&Sother_window);
6869 defsubr (&Sget_buffer_window); 6682 defsubr (&Sget_buffer_window);
6870 defsubr (&Sdelete_windows_on);
6871 defsubr (&Sreplace_buffer_in_windows);
6872 defsubr (&Sdelete_other_windows_internal); 6683 defsubr (&Sdelete_other_windows_internal);
6873 defsubr (&Sdelete_window_internal); 6684 defsubr (&Sdelete_window_internal);
6874 defsubr (&Sresize_mini_window_internal); 6685 defsubr (&Sresize_mini_window_internal);
@@ -6893,7 +6704,6 @@ function `window-nest' and altered by the function `set-window-nest'. */);
6893 defsubr (&Swindow_configuration_frame); 6704 defsubr (&Swindow_configuration_frame);
6894 defsubr (&Sset_window_configuration); 6705 defsubr (&Sset_window_configuration);
6895 defsubr (&Scurrent_window_configuration); 6706 defsubr (&Scurrent_window_configuration);
6896 defsubr (&Swindow_tree);
6897 defsubr (&Sset_window_margins); 6707 defsubr (&Sset_window_margins);
6898 defsubr (&Swindow_margins); 6708 defsubr (&Swindow_margins);
6899 defsubr (&Sset_window_fringes); 6709 defsubr (&Sset_window_fringes);
@@ -6917,7 +6727,6 @@ function `window-nest' and altered by the function `set-window-nest'. */);
6917void 6727void
6918keys_of_window (void) 6728keys_of_window (void)
6919{ 6729{
6920 initial_define_key (control_x_map, 'o', "other-window");
6921 initial_define_key (control_x_map, '<', "scroll-left"); 6730 initial_define_key (control_x_map, '<', "scroll-left");
6922 initial_define_key (control_x_map, '>', "scroll-right"); 6731 initial_define_key (control_x_map, '>', "scroll-right");
6923 6732
diff --git a/src/window.h b/src/window.h
index 1ebc99055a5..c3f59e4b116 100644
--- a/src/window.h
+++ b/src/window.h
@@ -827,6 +827,7 @@ extern Lisp_Object make_window (void);
827extern Lisp_Object window_from_coordinates (struct frame *, int, int, 827extern Lisp_Object window_from_coordinates (struct frame *, int, int,
828 enum window_part *, int); 828 enum window_part *, int);
829EXFUN (Fwindow_dedicated_p, 1); 829EXFUN (Fwindow_dedicated_p, 1);
830extern void resize_frame_windows (struct frame *, int, int);
830extern void delete_all_subwindows (Lisp_Object); 831extern void delete_all_subwindows (Lisp_Object);
831extern void freeze_window_starts (struct frame *, int); 832extern void freeze_window_starts (struct frame *, int);
832extern void grow_mini_window (struct window *, int); 833extern void grow_mini_window (struct window *, int);
@@ -902,7 +903,6 @@ extern Lisp_Object Qwindowp, Qwindow_live_p;
902extern Lisp_Object Vwindow_list; 903extern Lisp_Object Vwindow_list;
903 904
904EXFUN (Fwindow_buffer, 1); 905EXFUN (Fwindow_buffer, 1);
905EXFUN (Fwindow_frame, 1);
906EXFUN (Fget_buffer_window, 2); 906EXFUN (Fget_buffer_window, 2);
907EXFUN (Fwindow_minibuffer_p, 1); 907EXFUN (Fwindow_minibuffer_p, 1);
908EXFUN (Fselected_window, 0); 908EXFUN (Fselected_window, 0);
@@ -918,12 +918,11 @@ extern int window_internal_height (struct window *);
918extern int window_body_cols (struct window *w); 918extern int window_body_cols (struct window *w);
919EXFUN (Frecenter, 1); 919EXFUN (Frecenter, 1);
920extern void temp_output_buffer_show (Lisp_Object); 920extern void temp_output_buffer_show (Lisp_Object);
921extern void replace_buffer_in_all_windows (Lisp_Object); 921extern void replace_buffer_in_windows (Lisp_Object);
922extern void replace_buffer_in_windows_safely (Lisp_Object);
922extern void init_window_once (void); 923extern void init_window_once (void);
923extern void init_window (void); 924extern void init_window (void);
924extern void syms_of_window (void); 925extern void syms_of_window (void);
925extern void keys_of_window (void); 926extern void keys_of_window (void);
926extern void resize_frame_windows (struct frame *, int, int);
927
928 927
929#endif /* not WINDOW_H_INCLUDED */ 928#endif /* not WINDOW_H_INCLUDED */
diff --git a/src/xmenu.c b/src/xmenu.c
index 0aad8f454af..1cb71187c0c 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -347,6 +347,8 @@ for instance using the window manager, then this produces a quit and
347 347
348#ifndef MSDOS 348#ifndef MSDOS
349 349
350#if defined USE_GTK || defined USE_MOTIF
351
350/* Set menu_items_inuse so no other popup menu or dialog is created. */ 352/* Set menu_items_inuse so no other popup menu or dialog is created. */
351 353
352void 354void
@@ -360,6 +362,8 @@ x_menu_set_in_use (int in_use)
360#endif 362#endif
361} 363}
362 364
365#endif
366
363/* Wait for an X event to arrive or for a timer to expire. */ 367/* Wait for an X event to arrive or for a timer to expire. */
364 368
365#ifndef USE_MOTIF 369#ifndef USE_MOTIF
diff --git a/src/xterm.c b/src/xterm.c
index 1c1c8e3f107..914cdc429d6 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1446,6 +1446,8 @@ x_frame_of_widget (Widget widget)
1446} 1446}
1447 1447
1448 1448
1449#ifdef USE_LUCID
1450
1449/* Allocate a color which is lighter or darker than *PIXEL by FACTOR 1451/* Allocate a color which is lighter or darker than *PIXEL by FACTOR
1450 or DELTA. Try a color with RGB values multiplied by FACTOR first. 1452 or DELTA. Try a color with RGB values multiplied by FACTOR first.
1451 If this produces the same color as PIXEL, try a color where all RGB 1453 If this produces the same color as PIXEL, try a color where all RGB
@@ -1461,6 +1463,8 @@ x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap
1461 return x_alloc_lighter_color (f, display, cmap, pixel, factor, delta); 1463 return x_alloc_lighter_color (f, display, cmap, pixel, factor, delta);
1462} 1464}
1463 1465
1466#endif
1467
1464 1468
1465/* Structure specifying which arguments should be passed by Xt to 1469/* Structure specifying which arguments should be passed by Xt to
1466 cvt_string_to_pixel. We want the widget's screen and colormap. */ 1470 cvt_string_to_pixel. We want the widget's screen and colormap. */
diff --git a/src/xterm.h b/src/xterm.h
index 2938de9b339..47d7e533769 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -973,10 +973,12 @@ extern void x_delete_terminal (struct terminal *terminal);
973extern unsigned long x_copy_color (struct frame *, unsigned long); 973extern unsigned long x_copy_color (struct frame *, unsigned long);
974#ifdef USE_X_TOOLKIT 974#ifdef USE_X_TOOLKIT
975extern XtAppContext Xt_app_con; 975extern XtAppContext Xt_app_con;
976extern void x_activate_timeout_atimer (void);
977#endif
978#ifdef USE_LUCID
976extern int x_alloc_lighter_color_for_widget (Widget, Display *, Colormap, 979extern int x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
977 unsigned long *, 980 unsigned long *,
978 double, int); 981 double, int);
979extern void x_activate_timeout_atimer (void);
980#endif 982#endif
981extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *); 983extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *);
982extern void x_query_colors (struct frame *f, XColor *, int); 984extern void x_query_colors (struct frame *f, XColor *, int);
@@ -1069,7 +1071,9 @@ extern void x_free_dpy_colors (Display *, Screen *, Colormap,
1069 1071
1070/* Defined in xmenu.c */ 1072/* Defined in xmenu.c */
1071 1073
1074#if defined USE_GTK || defined USE_MOTIF
1072extern void x_menu_set_in_use (int); 1075extern void x_menu_set_in_use (int);
1076#endif
1073#ifdef USE_MOTIF 1077#ifdef USE_MOTIF
1074extern void x_menu_wait_for_event (void *data); 1078extern void x_menu_wait_for_event (void *data);
1075#endif 1079#endif