aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-10-14 16:56:21 +0000
committerKaroly Lorentey2006-10-14 16:56:21 +0000
commit3f87f67ee215ffeecbd2f53bd7f342cdf03f47df (patch)
tree16f2af9111af08a94d608d96a957f5c3ec5effcc /src
parent350e4fb815d7413ef6d339dd664014706f742927 (diff)
parent7a210b69c7f92650c524766d1b9d3f3eefdd67c7 (diff)
downloademacs-3f87f67ee215ffeecbd2f53bd7f342cdf03f47df.tar.gz
emacs-3f87f67ee215ffeecbd2f53bd7f342cdf03f47df.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-371 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-372 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-373 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-374 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-375 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-376 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-377 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-378 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-379 Merge from erc--emacs--21 * emacs@sv.gnu.org/emacs--devo--0--patch-380 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-381 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-382 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-383 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-384 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-385 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-386 Update from erc--emacs--22 * emacs@sv.gnu.org/emacs--devo--0--patch-387 Fix ERC bug introduced in last patch * emacs@sv.gnu.org/emacs--devo--0--patch-388 Update from erc--emacs--22 * emacs@sv.gnu.org/emacs--devo--0--patch-389 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-390 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-391 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-392 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-393 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-394 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-395 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-396 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-397 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-398 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-399 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-400 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-401 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-402 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-403 Rcirc update from Ryan Yeske * emacs@sv.gnu.org/emacs--devo--0--patch-404 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-405 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-406 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-407 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-408 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-409 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-410 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-411 Miscellaneous tq-related fixes. * emacs@sv.gnu.org/emacs--devo--0--patch-412 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-121 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-122 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-123 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-124 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-125 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-126 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-127 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-581
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit6
-rw-r--r--src/ChangeLog321
-rw-r--r--src/alloc.c73
-rw-r--r--src/buffer.c52
-rw-r--r--src/coding.c71
-rw-r--r--src/dired.c8
-rw-r--r--src/editfns.c67
-rw-r--r--src/fileio.c45
-rw-r--r--src/fns.c2
-rw-r--r--src/frame.c13
-rw-r--r--src/image.c2
-rw-r--r--src/keyboard.c245
-rw-r--r--src/mac.c22
-rw-r--r--src/macfns.c98
-rw-r--r--src/macselect.c42
-rw-r--r--src/macterm.c57
-rw-r--r--src/macterm.h17
-rw-r--r--src/print.c9
-rw-r--r--src/process.c16
-rw-r--r--src/puresize.h2
-rw-r--r--src/w32.c22
-rw-r--r--src/w32.h3
-rw-r--r--src/w32fns.c58
-rw-r--r--src/w32menu.c6
-rw-r--r--src/w32term.c40
-rw-r--r--src/window.c15
-rw-r--r--src/xdisp.c62
-rw-r--r--src/xfaces.c6
-rw-r--r--src/xfns.c11
-rw-r--r--src/xselect.c51
-rw-r--r--src/xterm.c64
-rw-r--r--src/xterm.h6
32 files changed, 1062 insertions, 450 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index acdb959a869..5dc126f8d36 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -164,6 +164,10 @@ define pitx
164 if ($it->current.pos.charpos != $it->current.pos.bytepos) 164 if ($it->current.pos.charpos != $it->current.pos.bytepos)
165 printf "[%d]", $it->current.pos.bytepos 165 printf "[%d]", $it->current.pos.bytepos
166 end 166 end
167 printf " pos=%d", $it->position.charpos
168 if ($it->position.charpos != $it->position.bytepos)
169 printf "[%d]", $it->position.bytepos
170 end
167 printf " start=%d", $it->start.pos.charpos 171 printf " start=%d", $it->start.pos.charpos
168 if ($it->start.pos.charpos != $it->start.pos.bytepos) 172 if ($it->start.pos.charpos != $it->start.pos.bytepos)
169 printf "[%d]", $it->start.pos.bytepos 173 printf "[%d]", $it->start.pos.bytepos
@@ -218,7 +222,7 @@ define pitx
218 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent 222 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent
219 printf "\n" 223 printf "\n"
220 set $i = 0 224 set $i = 0
221 while ($i < $it->sp) 225 while ($i < $it->sp && $i < 4)
222 set $e = $it->stack[$i] 226 set $e = $it->stack[$i]
223 printf "stack[%d]: ", $i 227 printf "stack[%d]: ", $i
224 output $e->method 228 output $e->method
diff --git a/src/ChangeLog b/src/ChangeLog
index 79271fe23fa..c7a065c091e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,308 @@
12006-08-27 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * alloc.c (BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Undo previous
4 change. Move mutex lock/unlock operations inside BLOCK_INPUT.
5
6 * dired.c (directory_files_internal_unwind, directory_files_internal)
7 (file_name_completion): Add BLOCK_INPUT around opendir/closedir.
8
9 * image.c [MAC_OS] (image_load_qt_1): Use ComponentResult instead
10 of OSErr.
11
12 * keyboard.c (in_sighandler): Remove variable.
13 (Fcurrent_idle_time): Add missing `doc:'.
14 (input_available_signal, init_keyboard): Undo previous change.
15
16 * keyboard.h (in_sighandler): Remove extern.
17
18 * mac.c (create_apple_event_from_event_ref, select)
19 (Fmac_get_file_creator, Fmac_get_file_type, Fmac_set_file_creator)
20 (Fmac_set_file_type, cfstring_create_normalized)
21 (mac_get_system_locale, select_and_poll_event, sys_select): Use
22 OSStatus instead of OSErr.
23
24 * macfns.c [TARGET_API_MAC_CARBON] (mac_update_proxy_icon): Don't
25 use FRAME_FILE_NAME. Use (FS)UpdateAlias.
26 (Fx_create_frame): Apply 2006-07-03 for xfns.c.
27
28 * macselect.c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
29 (put_scrap_private_timestamp, scrap_has_target_type, get_scrap_string)
30 (get_scrap_private_timestamp, get_scrap_target_type_list)
31 (x_own_selection, x_get_foreign_selection)
32 (Fx_disown_selection_internal, Fx_selection_owner_p)
33 (Fx_selection_exists_p): Use OSStatus instead of OSErr.
34
35 * macterm.c (mac_draw_string_common, mac_query_char_extents)
36 (x_iconify_frame, XLoadQueryFont, install_window_handler)
37 (mac_handle_command_event, init_command_handler, init_menu_bar):
38 Use OSStatus instead of OSErr.
39 (x_free_frame_resources) [TARGET_API_MAC_CARBON]: Don't use
40 FRAME_FILE_NAME.
41 (x_query_font): Apply 2006-08-04 change for xterm.c.
42 (Qhi_command): Rename from Qhicommand. All uses changed.
43
44 * macterm.h (struct mac_output) [TARGET_API_MAC_CARBON]: Remove member
45 file_name.
46 (FRAME_FILE_NAME): Remove macro.
47 (install_window_handler, create_apple_event_from_event_ref):
48 Return OSStatus instead of OSErr.
49
502006-08-26 Kim F. Storm <storm@cua.dk>
51
52 * buffer.c (Fset_buffer_multibyte):
53 * editfns.c (Fcurrent_time, Fget_internal_run_time):
54 * macfns.c (Fxw_color_values):
55 * w32fns.c (Fxw_color_values):
56 * xfns.c (Fxw_color_values): Simplify; use list3.
57
58 * fileio.c (Fmake_directory_internal, Fdelete_directory)
59 (Fdelete_file): Simplify; use list1.
60 (Frename_file, Fadd_name_to_file, Fmake_symbolic_link):
61 Simplify; remove NO_ARG_ARRAY stuff, use list2.
62
632006-08-25 Kim F. Storm <storm@cua.dk>
64
65 * keyboard.c (Fcurrent_idle_time): Simplify.
66
672006-08-25 Richard Stallman <rms@gnu.org>
68
69 * fns.c (sxhash_string): Rotate properly; don't lose bits.
70
712006-08-24 Francesc Rocher <francesc.rocher@gmail.com>
72
73 * xdisp.c (overline_margin): New variable.
74 (x_produce_glyphs): Use it.
75 (syms_of_xdisp): DEFVAR_INT it.
76
77 * xterm.c (x_underline_at_descent_line): New variable.
78 (syms_of_xterm): DEFVAR_BOOL it.
79 (x_draw_glyph_string): Use it.
80 Draw underline and overline up to the end of line if the face
81 extends to the end of line.
82
83 * macterm.c: Likewise.
84
85 * w32term.c: Likewise.
86
872006-08-24 Nick Roberts <nickrob@snap.net.nz>
88
89 * buffer.c (Fswitch_to_buffer): Move buffer to front of
90 buffer-alist if necessary.
91
922006-08-22 Kim F. Storm <storm@cua.dk>
93
94 * xdisp.c (update_tool_bar): Redisplay toolbar also when only
95 number of items changes.
96
972006-08-22 Stefan Monnier <monnier@iro.umontreal.ca>
98
99 * buffer.c (Fset_buffer_multibyte): Record proper undo entry.
100
1012006-08-21 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
102
103 * keyboard.c: Clarify difference between in_sighandler and
104 handling_signal.
105
1062006-08-21 Kim F. Storm <storm@cua.dk>
107
108 * macterm.c (x_draw_stretch_glyph_string):
109 * w32term.c (x_draw_stretch_glyph_string):
110 * xterm.c (x_draw_stretch_glyph_string): It is ok to draw a
111 stretch glyph in left marginal areas on header and mode lines.
112
1132006-08-21 Kenichi Handa <handa@m17n.org>
114
115 * keyboard.c (syms_of_keyboard): Docstring of
116 Vunread_post_input_method_events and Vunread_input_method_events
117 fixed.
118
1192006-08-20 Chong Yidong <cyd@stupidchicken.com>
120
121 * keyboard.c (show_help_echo): Preserve mouse movement flag if
122 tracking mouse.
123
1242006-08-20 Richard Stallman <rms@gnu.org>
125
126 * xfaces.c (load_pixmap): Add quotes in error message.
127
128 * keyboard.c (Fcurrent_idle_time): New function.
129 (syms_of_keyboard): defsubr it.
130
1312006-08-18 Nick Roberts <nickrob@snap.net.nz>
132
133 * window.c (Fset_window_fringes): Do nothing on a tty.
134 (Fwindow_fringes): Put ? operator after the line break.
135
1362006-08-16 Andreas Schwab <schwab@suse.de>
137
138 * print.c (debug_output_compilation_hack): Fix return type.
139
1402006-08-16 Richard Stallman <rms@gnu.org>
141
142 * print.c (debug_output_compilation_hack): New function.
143
1442006-08-16 Kenichi Handa <handa@m17n.org>
145
146 * fileio.c (choose_write_coding_system): Use LF for end-of-line
147 in auto-saving.
148
1492006-08-15 Chong Yidong <cyd@stupidchicken.com>
150
151 * keyboard.c (read_char): Don't change idle timer state at all if
152 end_time is supplied.
153
1542006-08-15 Kenichi Handa <handa@m17n.org>
155
156 * coding.c (ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC
157 is exhausted, return with RET.
158 (detect_coding_emacs_mule, detect_coding_iso2022)
159 (detect_coding_sjis, detect_coding_big5, detect_coding_utf_8)
160 (detect_coding_utf_16, detect_coding_ccl): Adjusted for the above
161 change.
162
1632006-08-14 Chong Yidong <cyd@stupidchicken.com>
164
165 * keyboard.c (read_char): Don't reset idle timers if a time limit
166 is supplied.
167
1682006-08-14 Kim F. Storm <storm@cua.dk>
169
170 * .gdbinit (pitx): Print iterator position.
171 Limit stack dump in case iterator is not initialized.
172
1732006-08-12 Eli Zaretskii <eliz@gnu.org>
174
175 * frame.c (Fmouse_position, Fmouse_pixel_position)
176 (Fset_mouse_position, Fset_mouse_pixel_position): Doc fix.
177
1782006-08-11 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
179
180 * xselect.c (Fx_register_dnd_atom): New function.
181 (syms_of_xselect): Defsubr it.
182 (x_handle_dnd_message): Check that message_type is in
183 dpyinfo->x_dnd_atoms before generating lisp event.
184
185 * xterm.h (struct x_display_info): Add x_dnd_atoms* to keep track
186 of drag and drop Atoms.
187
188 * xterm.c (x_term_init): Initialize dpyinfo->x_dnd_atoms*
189
190
1912006-08-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
192
193 * keyboard.c: Define in_sighandler.
194 (input_available_signal): Set in_sighandler.
195 (init_keyboard): Initialize in_sighandler.
196
197 * keyboard.h: Declare in_sighandler.
198
199 * alloc.c (UNBLOCK_INPUT_ALLOC, BLOCK_INPUT_ALLOC): Use in_sighandler
200 to check if mutex should be locked or not.
201
2022006-08-09 Richard Stallman <rms@gnu.org>
203
204 * keyboard.c (keyremap_step): No-op if fkey->parent = nil.
205 (read_key_sequence): Always start fkey.start and fkey.end at 0,
206 and likewise for keytran.
207
2082006-08-09 Kenichi Handa <handa@m17n.org>
209
210 * coding.c (syms_of_coding): Improve the docstring
211 file-coding-system-alist.
212
2132006-08-07 Andreas Schwab <schwab@suse.de>
214
215 * puresize.h (BASE_PURESIZE): Increase to 1120000.
216
2172006-08-06 Chong Yidong <cyd@stupidchicken.com>
218
219 * buffer.c (Vchange_major_mode_hook, Qchange_major_mode_hook): New vars.
220 (Fkill_all_local_variables): Use it.
221 (syms_of_buffer): Defvar it.
222
2232006-08-05 Eli Zaretskii <eliz@gnu.org>
224
225 * w32.c (w32_valid_pointer_p): New function.
226
227 * w32.h: Add prototype for w32_valid_pointer_p.
228
229 * alloc.c: Include w32.h.
230 (valid_lisp_object_p) [WINDOWSNT]: Call w32_valid_pointer_p to do
231 the job.
232
233 * keyboard.c (kbd_buffer_get_event): Return Qnil when current time
234 is exactly equal to end_time, not only when it is past that.
235
2362006-08-04 Chong Yidong <cyd@stupidchicken.com>
237
238 * keyboard.c (read_char): Rebalance specpdl after receiving jump.
239
240 * process.c: Reapply 2006-08-01 change.
241
2422006-08-04 Eli Zaretskii <eliz@gnu.org>
243
244 * w32fns.c (w32_query_font): Fix last change: use stricmp.
245
2462006-08-04 Stefan Monnier <monnier@iro.umontreal.ca>
247
248 * editfns.c (Fsubst_char_in_region): Redo the setup work after running
249 the before-change-functions since they may have altered the buffer.
250
2512006-08-04 Ralf Angeli <angeli@caeruleus.net>
252
253 * w32fns.c (w32_createwindow): Handle -geometry command line option
254 and the geometry settings in the Registry.
255
2562006-08-04 Kenichi Handa <handa@m17n.org>
257
258 * w32fns.c (w32_query_font): Compare names by ignoring case.
259
260 * xterm.c (x_query_font): Compare names by ignoring case.
261
2622006-08-03 Jason Rumney <jasonr@gnu.org>
263
264 * w32menu.c (w32_menu_show, w32_dialog_show): Call Fsignal to quit
265 when no option selected.
266
2672006-08-03 Chong Yidong <cyd@stupidchicken.com>
268
269 * process.c: Revert last change.
270
2712006-08-01 Kim F. Storm <storm@cua.dk>
272
273 * process.c (wait_reading_process_output_unwind): New function.
274 Restores waiting_for_user_input_p to saved value.
275 (wait_reading_process_output): Unwind protect waiting_for_user_input_p
276 instead of save/restore old value on stack.
277
2782006-07-30 Thien-Thi Nguyen <ttn@gnu.org>
279
280 * editfns.c: Undo 2006-06-27 change.
281
2822006-07-29 Eli Zaretskii <eliz@gnu.org>
283
284 * coding.c (Ffind_operation_coding_system): Revert the change from
285 2006-05-29.
286
287 * alloc.c [WINDOWSNT]: Include fcntl.h, to fix last change.
288
2892006-07-28 Richard Stallman <rms@gnu.org>
290
291 * xfaces.c (lookup_named_face, Fdisplay_supports_face_attributes_p):
292 Add conditional aborts for clarity.
293
294 * xdisp.c (update_menu_bar): New arg HOOKS_RUN. Callers changed.
295 Used to avoid running the hooks over and over for each frame.
296 (prepare_menu_bars): Pass value from update_menu_bar
297 as HOOKS_RUN of next call.
298
299 * keyboard.c (safe_run_hooks_1): Don't crash if Vrun_hooks is nil.
300
3012006-07-28 Kim F. Storm <storm@cua.dk>
302
303 * alloc.c (valid_pointer_p): New function (from valid_lisp_object_p).
304 (valid_lisp_object_p): Use it to check for valid SUBRP obj.
305
12006-07-26 Chong Yidong <cyd@stupidchicken.com> 3062006-07-26 Chong Yidong <cyd@stupidchicken.com>
2 307
3 * keyboard.c (read_char): New arg END_TIME specifying timeout. 308 * keyboard.c (read_char): New arg END_TIME specifying timeout.
@@ -177,6 +482,14 @@
177 (mac_initialize_display_info) [MAC_OSX]: Use CGDisplaySamplesPerPixel. 482 (mac_initialize_display_info) [MAC_OSX]: Use CGDisplaySamplesPerPixel.
178 (x_delete_display): Apply 2006-07-04 change for xterm.c. 483 (x_delete_display): Apply 2006-07-04 change for xterm.c.
179 484
4852006-07-17 Richard Stallman <rms@gnu.org>
486
487 * keyboard.c (Vcommand_error_function): New variable.
488 (syms_of_keyboard): Defvar it.
489 (cmd_error_internal): Simplify, and handle Vcommand_error_function.
490
491 * dispnew.c (init_display): Mention DISPLAY as well as TERM in err msg.
492
1802006-07-17 Kim F. Storm <storm@cua.dk> 4932006-07-17 Kim F. Storm <storm@cua.dk>
181 494
182 * xdisp.c (handle_single_display_spec): Ensure the right value of 495 * xdisp.c (handle_single_display_spec): Ensure the right value of
@@ -617,8 +930,8 @@
617 930
6182006-06-14 Chong Yidong <cyd@stupidchicken.com> 9312006-06-14 Chong Yidong <cyd@stupidchicken.com>
619 932
620 * xdisp.c (back_to_previous_visible_line_start): Reset 933 * xdisp.c (back_to_previous_visible_line_start):
621 it->continuation_lines_width. 934 Reset it->continuation_lines_width.
622 935
6232006-06-14 Richard Stallman <rms@gnu.org> 9362006-06-14 Richard Stallman <rms@gnu.org>
624 937
@@ -689,8 +1002,8 @@
689 1002
6902006-06-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 10032006-06-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
691 1004
692 * macterm.c [USE_MAC_TSM] (mac_handle_text_input_event): Exclude 1005 * macterm.c [USE_MAC_TSM] (mac_handle_text_input_event):
693 0x7f from ASCII range. 1006 Exclude 0x7f from ASCII range.
694 1007
6952006-06-05 Jason Rumney <jasonr@gnu.org> 10082006-06-05 Jason Rumney <jasonr@gnu.org>
696 1009
diff --git a/src/alloc.c b/src/alloc.c
index e3609292749..5cfcda2e1e0 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -78,6 +78,11 @@ extern POINTER_TYPE *sbrk ();
78#define O_WRONLY 1 78#define O_WRONLY 1
79#endif 79#endif
80 80
81#ifdef WINDOWSNT
82#include <fcntl.h>
83#include "w32.h"
84#endif
85
81#ifdef DOUG_LEA_MALLOC 86#ifdef DOUG_LEA_MALLOC
82 87
83#include <malloc.h> 88#include <malloc.h>
@@ -125,17 +130,17 @@ static pthread_mutex_t alloc_mutex;
125#define BLOCK_INPUT_ALLOC \ 130#define BLOCK_INPUT_ALLOC \
126 do \ 131 do \
127 { \ 132 { \
128 pthread_mutex_lock (&alloc_mutex); \ 133 if (pthread_self () == main_thread) \
129 if (pthread_self () == main_thread) \ 134 BLOCK_INPUT; \
130 BLOCK_INPUT; \ 135 pthread_mutex_lock (&alloc_mutex); \
131 } \ 136 } \
132 while (0) 137 while (0)
133#define UNBLOCK_INPUT_ALLOC \ 138#define UNBLOCK_INPUT_ALLOC \
134 do \ 139 do \
135 { \ 140 { \
136 if (pthread_self () == main_thread) \ 141 pthread_mutex_unlock (&alloc_mutex); \
137 UNBLOCK_INPUT; \ 142 if (pthread_self () == main_thread) \
138 pthread_mutex_unlock (&alloc_mutex); \ 143 UNBLOCK_INPUT; \
139 } \ 144 } \
140 while (0) 145 while (0)
141 146
@@ -4608,6 +4613,32 @@ mark_stack ()
4608#endif /* GC_MARK_STACK != 0 */ 4613#endif /* GC_MARK_STACK != 0 */
4609 4614
4610 4615
4616/* Determine whether it is safe to access memory at address P. */
4617int
4618valid_pointer_p (p)
4619 void *p;
4620{
4621#ifdef WINDOWSNT
4622 return w32_valid_pointer_p (p, 16);
4623#else
4624 int fd;
4625
4626 /* Obviously, we cannot just access it (we would SEGV trying), so we
4627 trick the o/s to tell us whether p is a valid pointer.
4628 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
4629 not validate p in that case. */
4630
4631 if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0)
4632 {
4633 int valid = (emacs_write (fd, (char *)p, 16) == 16);
4634 emacs_close (fd);
4635 unlink ("__Valid__Lisp__Object__");
4636 return valid;
4637 }
4638
4639 return -1;
4640#endif
4641}
4611 4642
4612/* Return 1 if OBJ is a valid lisp object. 4643/* Return 1 if OBJ is a valid lisp object.
4613 Return 0 if OBJ is NOT a valid lisp object. 4644 Return 0 if OBJ is NOT a valid lisp object.
@@ -4620,9 +4651,7 @@ valid_lisp_object_p (obj)
4620 Lisp_Object obj; 4651 Lisp_Object obj;
4621{ 4652{
4622 void *p; 4653 void *p;
4623#if !GC_MARK_STACK 4654#if GC_MARK_STACK
4624 int fd;
4625#else
4626 struct mem_node *m; 4655 struct mem_node *m;
4627#endif 4656#endif
4628 4657
@@ -4634,26 +4663,22 @@ valid_lisp_object_p (obj)
4634 return 1; 4663 return 1;
4635 4664
4636#if !GC_MARK_STACK 4665#if !GC_MARK_STACK
4637 /* We need to determine whether it is safe to access memory at 4666 return valid_pointer_p (p);
4638 address P. Obviously, we cannot just access it (we would SEGV
4639 trying), so we trick the o/s to tell us whether p is a valid
4640 pointer. Unfortunately, we cannot use NULL_DEVICE here, as
4641 emacs_write may not validate p in that case. */
4642 if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0)
4643 {
4644 int valid = (emacs_write (fd, (char *)p, 16) == 16);
4645 emacs_close (fd);
4646 unlink ("__Valid__Lisp__Object__");
4647 return valid;
4648 }
4649
4650 return -1;
4651#else 4667#else
4652 4668
4653 m = mem_find (p); 4669 m = mem_find (p);
4654 4670
4655 if (m == MEM_NIL) 4671 if (m == MEM_NIL)
4656 return 0; 4672 {
4673 int valid = valid_pointer_p (p);
4674 if (valid <= 0)
4675 return valid;
4676
4677 if (SUBRP (obj))
4678 return 1;
4679
4680 return 0;
4681 }
4657 4682
4658 switch (m->type) 4683 switch (m->type)
4659 { 4684 {
diff --git a/src/buffer.c b/src/buffer.c
index dc6bcd8f6d3..6a11569c85a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -146,6 +146,9 @@ Lisp_Object Vinhibit_read_only;
146Lisp_Object Vkill_buffer_query_functions; 146Lisp_Object Vkill_buffer_query_functions;
147Lisp_Object Qkill_buffer_query_functions; 147Lisp_Object Qkill_buffer_query_functions;
148 148
149/* Hook run before changing a major mode. */
150Lisp_Object Vchange_major_mode_hook, Qchange_major_mode_hook;
151
149/* List of functions to call before changing an unmodified buffer. */ 152/* List of functions to call before changing an unmodified buffer. */
150Lisp_Object Vfirst_change_hook; 153Lisp_Object Vfirst_change_hook;
151 154
@@ -1711,9 +1714,18 @@ the window-buffer correspondences. */)
1711 char *err; 1714 char *err;
1712 1715
1713 if (EQ (buffer, Fwindow_buffer (selected_window))) 1716 if (EQ (buffer, Fwindow_buffer (selected_window)))
1714 /* Basically a NOP. Avoid signalling an error if the selected window 1717 {
1715 is dedicated, or a minibuffer, ... */ 1718 /* Basically a NOP. Avoid signalling an error in the case where
1716 return Fset_buffer (buffer); 1719 the selected window is dedicated, or a minibuffer. */
1720
1721 /* But do put this buffer at the front of the buffer list,
1722 unless that has been inhibited. Note that even if
1723 BUFFER is at the front of the main buffer-list already,
1724 we still want to move it to the front of the frame's buffer list. */
1725 if (NILP (norecord))
1726 record_buffer (buffer);
1727 return Fset_buffer (buffer);
1728 }
1717 1729
1718 err = no_switch_window (selected_window); 1730 err = no_switch_window (selected_window);
1719 if (err) error (err); 1731 if (err) error (err);
@@ -2142,10 +2154,11 @@ current buffer is cleared. */)
2142{ 2154{
2143 struct Lisp_Marker *tail, *markers; 2155 struct Lisp_Marker *tail, *markers;
2144 struct buffer *other; 2156 struct buffer *other;
2145 int undo_enabled_p = !EQ (current_buffer->undo_list, Qt);
2146 int begv, zv; 2157 int begv, zv;
2147 int narrowed = (BEG != BEGV || Z != ZV); 2158 int narrowed = (BEG != BEGV || Z != ZV);
2148 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2159 int modified_p = !NILP (Fbuffer_modified_p (Qnil));
2160 Lisp_Object old_undo = current_buffer->undo_list;
2161 struct gcpro gcpro1;
2149 2162
2150 if (current_buffer->base_buffer) 2163 if (current_buffer->base_buffer)
2151 error ("Cannot do `set-buffer-multibyte' on an indirect buffer"); 2164 error ("Cannot do `set-buffer-multibyte' on an indirect buffer");
@@ -2154,10 +2167,11 @@ current buffer is cleared. */)
2154 if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters)) 2167 if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters))
2155 return flag; 2168 return flag;
2156 2169
2157 /* It would be better to update the list, 2170 GCPRO1 (old_undo);
2158 but this is good enough for now. */ 2171
2159 if (undo_enabled_p) 2172 /* Don't record these buffer changes. We will put a special undo entry
2160 current_buffer->undo_list = Qt; 2173 instead. */
2174 current_buffer->undo_list = Qt;
2161 2175
2162 /* If the cached position is for this buffer, clear it out. */ 2176 /* If the cached position is for this buffer, clear it out. */
2163 clear_charpos_cache (current_buffer); 2177 clear_charpos_cache (current_buffer);
@@ -2357,8 +2371,17 @@ current buffer is cleared. */)
2357 set_intervals_multibyte (1); 2371 set_intervals_multibyte (1);
2358 } 2372 }
2359 2373
2360 if (undo_enabled_p) 2374 if (!EQ (old_undo, Qt))
2361 current_buffer->undo_list = Qnil; 2375 {
2376 /* Represent all the above changes by a special undo entry. */
2377 extern Lisp_Object Qapply;
2378 current_buffer->undo_list = Fcons (list3 (Qapply,
2379 intern ("set-buffer-multibyte"),
2380 NILP (flag) ? Qt : Qnil),
2381 old_undo);
2382 }
2383
2384 UNGCPRO;
2362 2385
2363 /* Changing the multibyteness of a buffer means that all windows 2386 /* Changing the multibyteness of a buffer means that all windows
2364 showing that buffer must be updated thoroughly. */ 2387 showing that buffer must be updated thoroughly. */
@@ -2416,7 +2439,7 @@ the normal hook `change-major-mode-hook'. */)
2416 Lisp_Object oalist; 2439 Lisp_Object oalist;
2417 2440
2418 if (!NILP (Vrun_hooks)) 2441 if (!NILP (Vrun_hooks))
2419 call1 (Vrun_hooks, intern ("change-major-mode-hook")); 2442 call1 (Vrun_hooks, Qchange_major_mode_hook);
2420 oalist = current_buffer->local_var_alist; 2443 oalist = current_buffer->local_var_alist;
2421 2444
2422 /* Make sure none of the bindings in oalist 2445 /* Make sure none of the bindings in oalist
@@ -6028,6 +6051,13 @@ t means to use hollow box cursor. See `cursor-type' for other values. */);
6028 doc: /* List of functions called with no args to query before killing a buffer. */); 6051 doc: /* List of functions called with no args to query before killing a buffer. */);
6029 Vkill_buffer_query_functions = Qnil; 6052 Vkill_buffer_query_functions = Qnil;
6030 6053
6054 DEFVAR_LISP ("change-major-mode-hook", &Vchange_major_mode_hook,
6055 doc: /* Normal hook run before changing the major mode of a buffer.
6056The function `kill-all-local-variables' runs this before doing anything else. */);
6057 Vchange_major_mode_hook = Qnil;
6058 Qchange_major_mode_hook = intern ("change-major-mode-hook");
6059 staticpro (&Qchange_major_mode_hook);
6060
6031 defsubr (&Sbuffer_live_p); 6061 defsubr (&Sbuffer_live_p);
6032 defsubr (&Sbuffer_list); 6062 defsubr (&Sbuffer_list);
6033 defsubr (&Sget_buffer); 6063 defsubr (&Sget_buffer);
diff --git a/src/coding.c b/src/coding.c
index 5b067b9dd2f..53f37c580de 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -219,14 +219,15 @@ encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes)
219 219
220 220
221/* Like ONE_MORE_BYTE, but 8-bit bytes of data at SRC are in multibyte 221/* Like ONE_MORE_BYTE, but 8-bit bytes of data at SRC are in multibyte
222 form if MULTIBYTEP is nonzero. */ 222 form if MULTIBYTEP is nonzero. In addition, if SRC is not less
223 than SRC_END, return with RET. */
223 224
224#define ONE_MORE_BYTE_CHECK_MULTIBYTE(c1, multibytep) \ 225#define ONE_MORE_BYTE_CHECK_MULTIBYTE(c1, multibytep, ret) \
225 do { \ 226 do { \
226 if (src >= src_end) \ 227 if (src >= src_end) \
227 { \ 228 { \
228 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ 229 coding->result = CODING_FINISH_INSUFFICIENT_SRC; \
229 goto label_end_of_loop; \ 230 return ret; \
230 } \ 231 } \
231 c1 = *src++; \ 232 c1 = *src++; \
232 if (multibytep && c1 == LEADING_CODE_8_BIT_CONTROL) \ 233 if (multibytep && c1 == LEADING_CODE_8_BIT_CONTROL) \
@@ -628,15 +629,15 @@ detect_coding_emacs_mule (src, src_end, multibytep)
628 629
629 while (1) 630 while (1)
630 { 631 {
631 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 632 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep,
632 633 CODING_CATEGORY_MASK_EMACS_MULE);
633 if (composing) 634 if (composing)
634 { 635 {
635 if (c < 0xA0) 636 if (c < 0xA0)
636 composing = 0; 637 composing = 0;
637 else if (c == 0xA0) 638 else if (c == 0xA0)
638 { 639 {
639 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 640 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0);
640 c &= 0x7F; 641 c &= 0x7F;
641 } 642 }
642 else 643 else
@@ -665,8 +666,6 @@ detect_coding_emacs_mule (src, src_end, multibytep)
665 } 666 }
666 } 667 }
667 } 668 }
668 label_end_of_loop:
669 return CODING_CATEGORY_MASK_EMACS_MULE;
670} 669}
671 670
672 671
@@ -1421,9 +1420,9 @@ detect_coding_iso2022 (src, src_end, multibytep)
1421 Lisp_Object safe_chars; 1420 Lisp_Object safe_chars;
1422 1421
1423 reg[0] = CHARSET_ASCII, reg[1] = reg[2] = reg[3] = -1; 1422 reg[0] = CHARSET_ASCII, reg[1] = reg[2] = reg[3] = -1;
1424 while (mask && src < src_end) 1423 while (mask)
1425 { 1424 {
1426 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 1425 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found);
1427 retry: 1426 retry:
1428 switch (c) 1427 switch (c)
1429 { 1428 {
@@ -1431,11 +1430,11 @@ detect_coding_iso2022 (src, src_end, multibytep)
1431 if (inhibit_iso_escape_detection) 1430 if (inhibit_iso_escape_detection)
1432 break; 1431 break;
1433 single_shifting = 0; 1432 single_shifting = 0;
1434 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 1433 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found);
1435 if (c >= '(' && c <= '/') 1434 if (c >= '(' && c <= '/')
1436 { 1435 {
1437 /* Designation sequence for a charset of dimension 1. */ 1436 /* Designation sequence for a charset of dimension 1. */
1438 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); 1437 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, mask & mask_found);
1439 if (c1 < ' ' || c1 >= 0x80 1438 if (c1 < ' ' || c1 >= 0x80
1440 || (charset = iso_charset_table[0][c >= ','][c1]) < 0) 1439 || (charset = iso_charset_table[0][c >= ','][c1]) < 0)
1441 /* Invalid designation sequence. Just ignore. */ 1440 /* Invalid designation sequence. Just ignore. */
@@ -1445,13 +1444,14 @@ detect_coding_iso2022 (src, src_end, multibytep)
1445 else if (c == '$') 1444 else if (c == '$')
1446 { 1445 {
1447 /* Designation sequence for a charset of dimension 2. */ 1446 /* Designation sequence for a charset of dimension 2. */
1448 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 1447 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found);
1449 if (c >= '@' && c <= 'B') 1448 if (c >= '@' && c <= 'B')
1450 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ 1449 /* Designation for JISX0208.1978, GB2312, or JISX0208. */
1451 reg[0] = charset = iso_charset_table[1][0][c]; 1450 reg[0] = charset = iso_charset_table[1][0][c];
1452 else if (c >= '(' && c <= '/') 1451 else if (c >= '(' && c <= '/')
1453 { 1452 {
1454 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); 1453 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep,
1454 mask & mask_found);
1455 if (c1 < ' ' || c1 >= 0x80 1455 if (c1 < ' ' || c1 >= 0x80
1456 || (charset = iso_charset_table[1][c >= ','][c1]) < 0) 1456 || (charset = iso_charset_table[1][c >= ','][c1]) < 0)
1457 /* Invalid designation sequence. Just ignore. */ 1457 /* Invalid designation sequence. Just ignore. */
@@ -1626,7 +1626,8 @@ detect_coding_iso2022 (src, src_end, multibytep)
1626 c = -1; 1626 c = -1;
1627 while (src < src_end) 1627 while (src < src_end)
1628 { 1628 {
1629 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 1629 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep,
1630 mask & mask_found);
1630 if (c < 0xA0) 1631 if (c < 0xA0)
1631 break; 1632 break;
1632 i++; 1633 i++;
@@ -1644,7 +1645,6 @@ detect_coding_iso2022 (src, src_end, multibytep)
1644 break; 1645 break;
1645 } 1646 }
1646 } 1647 }
1647 label_end_of_loop:
1648 return (mask & mask_found); 1648 return (mask & mask_found);
1649} 1649}
1650 1650
@@ -2915,20 +2915,18 @@ detect_coding_sjis (src, src_end, multibytep)
2915 2915
2916 while (1) 2916 while (1)
2917 { 2917 {
2918 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 2918 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_SJIS);
2919 if (c < 0x80) 2919 if (c < 0x80)
2920 continue; 2920 continue;
2921 if (c == 0x80 || c == 0xA0 || c > 0xEF) 2921 if (c == 0x80 || c == 0xA0 || c > 0xEF)
2922 return 0; 2922 return 0;
2923 if (c <= 0x9F || c >= 0xE0) 2923 if (c <= 0x9F || c >= 0xE0)
2924 { 2924 {
2925 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 2925 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0);
2926 if (c < 0x40 || c == 0x7F || c > 0xFC) 2926 if (c < 0x40 || c == 0x7F || c > 0xFC)
2927 return 0; 2927 return 0;
2928 } 2928 }
2929 } 2929 }
2930 label_end_of_loop:
2931 return CODING_CATEGORY_MASK_SJIS;
2932} 2930}
2933 2931
2934/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 2932/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
@@ -2947,17 +2945,15 @@ detect_coding_big5 (src, src_end, multibytep)
2947 2945
2948 while (1) 2946 while (1)
2949 { 2947 {
2950 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 2948 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_BIG5);
2951 if (c < 0x80) 2949 if (c < 0x80)
2952 continue; 2950 continue;
2953 if (c < 0xA1 || c > 0xFE) 2951 if (c < 0xA1 || c > 0xFE)
2954 return 0; 2952 return 0;
2955 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 2953 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0);
2956 if (c < 0x40 || (c > 0x7F && c < 0xA1) || c > 0xFE) 2954 if (c < 0x40 || (c > 0x7F && c < 0xA1) || c > 0xFE)
2957 return 0; 2955 return 0;
2958 } 2956 }
2959 label_end_of_loop:
2960 return CODING_CATEGORY_MASK_BIG5;
2961} 2957}
2962 2958
2963/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 2959/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
@@ -2985,7 +2981,7 @@ detect_coding_utf_8 (src, src_end, multibytep)
2985 2981
2986 while (1) 2982 while (1)
2987 { 2983 {
2988 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 2984 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_UTF_8);
2989 if (UTF_8_1_OCTET_P (c)) 2985 if (UTF_8_1_OCTET_P (c))
2990 continue; 2986 continue;
2991 else if (UTF_8_2_OCTET_LEADING_P (c)) 2987 else if (UTF_8_2_OCTET_LEADING_P (c))
@@ -3003,16 +2999,13 @@ detect_coding_utf_8 (src, src_end, multibytep)
3003 2999
3004 do 3000 do
3005 { 3001 {
3006 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 3002 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0);
3007 if (!UTF_8_EXTRA_OCTET_P (c)) 3003 if (!UTF_8_EXTRA_OCTET_P (c))
3008 return 0; 3004 return 0;
3009 seq_maybe_bytes--; 3005 seq_maybe_bytes--;
3010 } 3006 }
3011 while (seq_maybe_bytes > 0); 3007 while (seq_maybe_bytes > 0);
3012 } 3008 }
3013
3014 label_end_of_loop:
3015 return CODING_CATEGORY_MASK_UTF_8;
3016} 3009}
3017 3010
3018/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 3011/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
@@ -3041,15 +3034,13 @@ detect_coding_utf_16 (src, src_end, multibytep)
3041 struct coding_system dummy_coding; 3034 struct coding_system dummy_coding;
3042 struct coding_system *coding = &dummy_coding; 3035 struct coding_system *coding = &dummy_coding;
3043 3036
3044 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); 3037 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, 0);
3045 ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep); 3038 ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep, 0);
3046 3039
3047 if ((c1 == 0xFF) && (c2 == 0xFE)) 3040 if ((c1 == 0xFF) && (c2 == 0xFE))
3048 return CODING_CATEGORY_MASK_UTF_16_LE; 3041 return CODING_CATEGORY_MASK_UTF_16_LE;
3049 else if ((c1 == 0xFE) && (c2 == 0xFF)) 3042 else if ((c1 == 0xFE) && (c2 == 0xFF))
3050 return CODING_CATEGORY_MASK_UTF_16_BE; 3043 return CODING_CATEGORY_MASK_UTF_16_BE;
3051
3052 label_end_of_loop:
3053 return 0; 3044 return 0;
3054} 3045}
3055 3046
@@ -3318,12 +3309,10 @@ detect_coding_ccl (src, src_end, multibytep)
3318 valid = coding_system_table[CODING_CATEGORY_IDX_CCL]->spec.ccl.valid_codes; 3309 valid = coding_system_table[CODING_CATEGORY_IDX_CCL]->spec.ccl.valid_codes;
3319 while (1) 3310 while (1)
3320 { 3311 {
3321 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); 3312 ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_CCL);
3322 if (! valid[c]) 3313 if (! valid[c])
3323 return 0; 3314 return 0;
3324 } 3315 }
3325 label_end_of_loop:
3326 return CODING_CATEGORY_MASK_CCL;
3327} 3316}
3328 3317
3329 3318
@@ -7547,7 +7536,10 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */)
7547 return Fcons (val, val); 7536 return Fcons (val, val);
7548 if (! NILP (Ffboundp (val))) 7537 if (! NILP (Ffboundp (val)))
7549 { 7538 {
7550 val = safe_call1 (val, Flist (nargs, args)); 7539 /* We use call1 rather than safe_call1
7540 so as to get bug reports about functions called here
7541 which don't handle the current interface. */
7542 val = call1 (val, Flist (nargs, args));
7551 if (CONSP (val)) 7543 if (CONSP (val))
7552 return val; 7544 return val;
7553 if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val))) 7545 if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val)))
@@ -7971,8 +7963,9 @@ the file contents.
7971If VAL is a cons of coding systems, the car part is used for decoding, 7963If VAL is a cons of coding systems, the car part is used for decoding,
7972and the cdr part is used for encoding. 7964and the cdr part is used for encoding.
7973If VAL is a function symbol, the function must return a coding system 7965If VAL is a function symbol, the function must return a coding system
7974or a cons of coding systems which are used as above. The function gets 7966or a cons of coding systems which are used as above. The function is
7975the arguments with which `find-operation-coding-system' was called. 7967called with an argument that is a list of the arguments with which
7968`find-operation-coding-system' was called.
7976 7969
7977See also the function `find-operation-coding-system' 7970See also the function `find-operation-coding-system'
7978and the variable `auto-coding-alist'. */); 7971and the variable `auto-coding-alist'. */);
diff --git a/src/dired.c b/src/dired.c
index 17a80a3ce4b..b469d682c41 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -134,7 +134,9 @@ directory_files_internal_unwind (dh)
134 Lisp_Object dh; 134 Lisp_Object dh;
135{ 135{
136 DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer; 136 DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer;
137 BLOCK_INPUT;
137 closedir (d); 138 closedir (d);
139 UNBLOCK_INPUT;
138 return Qnil; 140 return Qnil;
139} 141}
140 142
@@ -196,7 +198,9 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
196 /* Now *bufp is the compiled form of MATCH; don't call anything 198 /* Now *bufp is the compiled form of MATCH; don't call anything
197 which might compile a new regexp until we're done with the loop! */ 199 which might compile a new regexp until we're done with the loop! */
198 200
201 BLOCK_INPUT;
199 d = opendir (SDATA (dirfilename)); 202 d = opendir (SDATA (dirfilename));
203 UNBLOCK_INPUT;
200 if (d == NULL) 204 if (d == NULL)
201 report_file_error ("Opening directory", Fcons (directory, Qnil)); 205 report_file_error ("Opening directory", Fcons (directory, Qnil));
202 206
@@ -321,7 +325,9 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
321 } 325 }
322 } 326 }
323 327
328 BLOCK_INPUT;
324 closedir (d); 329 closedir (d);
330 UNBLOCK_INPUT;
325 331
326 /* Discard the unwind protect. */ 332 /* Discard the unwind protect. */
327 specpdl_ptr = specpdl + count; 333 specpdl_ptr = specpdl + count;
@@ -508,7 +514,9 @@ file_name_completion (file, dirname, all_flag, ver_flag)
508 { 514 {
509 int inner_count = SPECPDL_INDEX (); 515 int inner_count = SPECPDL_INDEX ();
510 516
517 BLOCK_INPUT;
511 d = opendir (SDATA (Fdirectory_file_name (encoded_dir))); 518 d = opendir (SDATA (Fdirectory_file_name (encoded_dir)));
519 UNBLOCK_INPUT;
512 if (!d) 520 if (!d)
513 report_file_error ("Opening directory", Fcons (dirname, Qnil)); 521 report_file_error ("Opening directory", Fcons (dirname, Qnil));
514 522
diff --git a/src/editfns.c b/src/editfns.c
index aea044db068..c43528c4863 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -629,10 +629,7 @@ find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end)
629DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0, 629DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0,
630 doc: /* Delete the field surrounding POS. 630 doc: /* Delete the field surrounding POS.
631A field is a region of text with the same `field' property. 631A field is a region of text with the same `field' property.
632If POS is nil, the value of point is used for POS. 632If POS is nil, the value of point is used for POS. */)
633
634An `args-out-of-range' error is signaled if POS is outside the
635buffer's accessible portion. */)
636 (pos) 633 (pos)
637 Lisp_Object pos; 634 Lisp_Object pos;
638{ 635{
@@ -646,10 +643,7 @@ buffer's accessible portion. */)
646DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0, 643DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0,
647 doc: /* Return the contents of the field surrounding POS as a string. 644 doc: /* Return the contents of the field surrounding POS as a string.
648A field is a region of text with the same `field' property. 645A field is a region of text with the same `field' property.
649If POS is nil, the value of point is used for POS. 646If POS is nil, the value of point is used for POS. */)
650
651An `args-out-of-range' error is signaled if POS is outside the
652buffer's accessible portion. */)
653 (pos) 647 (pos)
654 Lisp_Object pos; 648 Lisp_Object pos;
655{ 649{
@@ -661,10 +655,7 @@ buffer's accessible portion. */)
661DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0, 655DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0,
662 doc: /* Return the contents of the field around POS, without text-properties. 656 doc: /* Return the contents of the field around POS, without text-properties.
663A field is a region of text with the same `field' property. 657A field is a region of text with the same `field' property.
664If POS is nil, the value of point is used for POS. 658If POS is nil, the value of point is used for POS. */)
665
666An `args-out-of-range' error is signaled if POS is outside the
667buffer's accessible portion. */)
668 (pos) 659 (pos)
669 Lisp_Object pos; 660 Lisp_Object pos;
670{ 661{
@@ -680,10 +671,7 @@ If POS is nil, the value of point is used for POS.
680If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its 671If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its
681field, then the beginning of the *previous* field is returned. 672field, then the beginning of the *previous* field is returned.
682If LIMIT is non-nil, it is a buffer position; if the beginning of the field 673If LIMIT is non-nil, it is a buffer position; if the beginning of the field
683is before LIMIT, then LIMIT will be returned instead. 674is before LIMIT, then LIMIT will be returned instead. */)
684
685An `args-out-of-range' error is signaled if POS is outside the
686buffer's accessible portion. */)
687 (pos, escape_from_edge, limit) 675 (pos, escape_from_edge, limit)
688 Lisp_Object pos, escape_from_edge, limit; 676 Lisp_Object pos, escape_from_edge, limit;
689{ 677{
@@ -699,10 +687,7 @@ If POS is nil, the value of point is used for POS.
699If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, 687If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field,
700then the end of the *following* field is returned. 688then the end of the *following* field is returned.
701If LIMIT is non-nil, it is a buffer position; if the end of the field 689If LIMIT is non-nil, it is a buffer position; if the end of the field
702is after LIMIT, then LIMIT will be returned instead. 690is after LIMIT, then LIMIT will be returned instead. */)
703
704An `args-out-of-range' error is signaled if POS is outside the
705buffer's accessible portion. */)
706 (pos, escape_from_edge, limit) 691 (pos, escape_from_edge, limit)
707 Lisp_Object pos, escape_from_edge, limit; 692 Lisp_Object pos, escape_from_edge, limit;
708{ 693{
@@ -1450,14 +1435,11 @@ resolution finer than a second. */)
1450 () 1435 ()
1451{ 1436{
1452 EMACS_TIME t; 1437 EMACS_TIME t;
1453 Lisp_Object result[3];
1454 1438
1455 EMACS_GET_TIME (t); 1439 EMACS_GET_TIME (t);
1456 XSETINT (result[0], (EMACS_SECS (t) >> 16) & 0xffff); 1440 return list3 (make_number ((EMACS_SECS (t) >> 16) & 0xffff),
1457 XSETINT (result[1], (EMACS_SECS (t) >> 0) & 0xffff); 1441 make_number ((EMACS_SECS (t) >> 0) & 0xffff),
1458 XSETINT (result[2], EMACS_USECS (t)); 1442 make_number (EMACS_USECS (t)));
1459
1460 return Flist (3, result);
1461} 1443}
1462 1444
1463DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, 1445DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time,
@@ -1475,7 +1457,6 @@ systems that do not provide resolution finer than a second. */)
1475{ 1457{
1476#ifdef HAVE_GETRUSAGE 1458#ifdef HAVE_GETRUSAGE
1477 struct rusage usage; 1459 struct rusage usage;
1478 Lisp_Object result[3];
1479 int secs, usecs; 1460 int secs, usecs;
1480 1461
1481 if (getrusage (RUSAGE_SELF, &usage) < 0) 1462 if (getrusage (RUSAGE_SELF, &usage) < 0)
@@ -1491,11 +1472,9 @@ systems that do not provide resolution finer than a second. */)
1491 secs++; 1472 secs++;
1492 } 1473 }
1493 1474
1494 XSETINT (result[0], (secs >> 16) & 0xffff); 1475 return list3 (make_number ((secs >> 16) & 0xffff),
1495 XSETINT (result[1], (secs >> 0) & 0xffff); 1476 make_number ((secs >> 0) & 0xffff),
1496 XSETINT (result[2], usecs); 1477 make_number (usecs));
1497
1498 return Flist (3, result);
1499#else 1478#else
1500 return Fcurrent_time (); 1479 return Fcurrent_time ();
1501#endif 1480#endif
@@ -2706,6 +2685,10 @@ Both characters must have the same length of multi-byte form. */)
2706 Lisp_Object start, end, fromchar, tochar, noundo; 2685 Lisp_Object start, end, fromchar, tochar, noundo;
2707{ 2686{
2708 register int pos, pos_byte, stop, i, len, end_byte; 2687 register int pos, pos_byte, stop, i, len, end_byte;
2688 /* Keep track of the first change in the buffer:
2689 if 0 we haven't found it yet.
2690 if < 0 we've found it and we've run the before-change-function.
2691 if > 0 we've actually performed it and the value is its position. */
2709 int changed = 0; 2692 int changed = 0;
2710 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; 2693 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
2711 unsigned char *p; 2694 unsigned char *p;
@@ -2718,6 +2701,8 @@ Both characters must have the same length of multi-byte form. */)
2718 int last_changed = 0; 2701 int last_changed = 0;
2719 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); 2702 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
2720 2703
2704 restart:
2705
2721 validate_region (&start, &end); 2706 validate_region (&start, &end);
2722 CHECK_NUMBER (fromchar); 2707 CHECK_NUMBER (fromchar);
2723 CHECK_NUMBER (tochar); 2708 CHECK_NUMBER (tochar);
@@ -2755,7 +2740,7 @@ Both characters must have the same length of multi-byte form. */)
2755 That's faster than getting rid of things, 2740 That's faster than getting rid of things,
2756 and it prevents even the entry for a first change. 2741 and it prevents even the entry for a first change.
2757 Also inhibit locking the file. */ 2742 Also inhibit locking the file. */
2758 if (!NILP (noundo)) 2743 if (!changed && !NILP (noundo))
2759 { 2744 {
2760 record_unwind_protect (subst_char_in_region_unwind, 2745 record_unwind_protect (subst_char_in_region_unwind,
2761 current_buffer->undo_list); 2746 current_buffer->undo_list);
@@ -2789,10 +2774,14 @@ Both characters must have the same length of multi-byte form. */)
2789 && (len == 2 || (p[2] == fromstr[2] 2774 && (len == 2 || (p[2] == fromstr[2]
2790 && (len == 3 || p[3] == fromstr[3])))))) 2775 && (len == 3 || p[3] == fromstr[3]))))))
2791 { 2776 {
2792 if (! changed) 2777 if (changed < 0)
2778 /* We've already seen this and run the before-change-function;
2779 this time we only need to record the actual position. */
2780 changed = pos;
2781 else if (!changed)
2793 { 2782 {
2794 changed = pos; 2783 changed = -1;
2795 modify_region (current_buffer, changed, XINT (end)); 2784 modify_region (current_buffer, pos, XINT (end));
2796 2785
2797 if (! NILP (noundo)) 2786 if (! NILP (noundo))
2798 { 2787 {
@@ -2801,6 +2790,10 @@ Both characters must have the same length of multi-byte form. */)
2801 if (MODIFF - 1 == current_buffer->auto_save_modified) 2790 if (MODIFF - 1 == current_buffer->auto_save_modified)
2802 current_buffer->auto_save_modified++; 2791 current_buffer->auto_save_modified++;
2803 } 2792 }
2793
2794 /* The before-change-function may have moved the gap
2795 or even modified the buffer so we should start over. */
2796 goto restart;
2804 } 2797 }
2805 2798
2806 /* Take care of the case where the new character 2799 /* Take care of the case where the new character
@@ -2853,7 +2846,7 @@ Both characters must have the same length of multi-byte form. */)
2853 pos++; 2846 pos++;
2854 } 2847 }
2855 2848
2856 if (changed) 2849 if (changed > 0)
2857 { 2850 {
2858 signal_after_change (changed, 2851 signal_after_change (changed,
2859 last_changed - changed, last_changed - changed); 2852 last_changed - changed, last_changed - changed);
diff --git a/src/fileio.c b/src/fileio.c
index 8ac528cafb9..62d539dcfca 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2650,7 +2650,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal,
2650#else 2650#else
2651 if (mkdir (dir, 0777) != 0) 2651 if (mkdir (dir, 0777) != 0)
2652#endif 2652#endif
2653 report_file_error ("Creating directory", Flist (1, &directory)); 2653 report_file_error ("Creating directory", list1 (directory));
2654 2654
2655 return Qnil; 2655 return Qnil;
2656} 2656}
@@ -2676,7 +2676,7 @@ DEFUN ("delete-directory", Fdelete_directory, Sdelete_directory, 1, 1, "FDelete
2676 dir = SDATA (encoded_dir); 2676 dir = SDATA (encoded_dir);
2677 2677
2678 if (rmdir (dir) != 0) 2678 if (rmdir (dir) != 0)
2679 report_file_error ("Removing directory", Flist (1, &directory)); 2679 report_file_error ("Removing directory", list1 (directory));
2680 2680
2681 return Qnil; 2681 return Qnil;
2682} 2682}
@@ -2707,7 +2707,7 @@ If file has multiple names, it continues to exist with the other names. */)
2707 encoded_file = ENCODE_FILE (filename); 2707 encoded_file = ENCODE_FILE (filename);
2708 2708
2709 if (0 > unlink (SDATA (encoded_file))) 2709 if (0 > unlink (SDATA (encoded_file)))
2710 report_file_error ("Removing old name", Flist (1, &filename)); 2710 report_file_error ("Removing old name", list1 (filename));
2711 return Qnil; 2711 return Qnil;
2712} 2712}
2713 2713
@@ -2741,9 +2741,6 @@ This is what happens in interactive use with M-x. */)
2741 (file, newname, ok_if_already_exists) 2741 (file, newname, ok_if_already_exists)
2742 Lisp_Object file, newname, ok_if_already_exists; 2742 Lisp_Object file, newname, ok_if_already_exists;
2743{ 2743{
2744#ifdef NO_ARG_ARRAY
2745 Lisp_Object args[2];
2746#endif
2747 Lisp_Object handler; 2744 Lisp_Object handler;
2748 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 2745 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
2749 Lisp_Object encoded_file, encoded_newname, symlink_target; 2746 Lisp_Object encoded_file, encoded_newname, symlink_target;
@@ -2812,15 +2809,7 @@ This is what happens in interactive use with M-x. */)
2812 Fdelete_file (file); 2809 Fdelete_file (file);
2813 } 2810 }
2814 else 2811 else
2815#ifdef NO_ARG_ARRAY 2812 report_file_error ("Renaming", list2 (file, newname));
2816 {
2817 args[0] = file;
2818 args[1] = newname;
2819 report_file_error ("Renaming", Flist (2, args));
2820 }
2821#else
2822 report_file_error ("Renaming", Flist (2, &file));
2823#endif
2824 } 2813 }
2825 UNGCPRO; 2814 UNGCPRO;
2826 return Qnil; 2815 return Qnil;
@@ -2836,9 +2825,6 @@ This is what happens in interactive use with M-x. */)
2836 (file, newname, ok_if_already_exists) 2825 (file, newname, ok_if_already_exists)
2837 Lisp_Object file, newname, ok_if_already_exists; 2826 Lisp_Object file, newname, ok_if_already_exists;
2838{ 2827{
2839#ifdef NO_ARG_ARRAY
2840 Lisp_Object args[2];
2841#endif
2842 Lisp_Object handler; 2828 Lisp_Object handler;
2843 Lisp_Object encoded_file, encoded_newname; 2829 Lisp_Object encoded_file, encoded_newname;
2844 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 2830 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -2878,15 +2864,7 @@ This is what happens in interactive use with M-x. */)
2878 2864
2879 unlink (SDATA (newname)); 2865 unlink (SDATA (newname));
2880 if (0 > link (SDATA (encoded_file), SDATA (encoded_newname))) 2866 if (0 > link (SDATA (encoded_file), SDATA (encoded_newname)))
2881 { 2867 report_file_error ("Adding new name", list2 (file, newname));
2882#ifdef NO_ARG_ARRAY
2883 args[0] = file;
2884 args[1] = newname;
2885 report_file_error ("Adding new name", Flist (2, args));
2886#else
2887 report_file_error ("Adding new name", Flist (2, &file));
2888#endif
2889 }
2890 2868
2891 UNGCPRO; 2869 UNGCPRO;
2892 return Qnil; 2870 return Qnil;
@@ -2904,9 +2882,6 @@ This happens for interactive use with M-x. */)
2904 (filename, linkname, ok_if_already_exists) 2882 (filename, linkname, ok_if_already_exists)
2905 Lisp_Object filename, linkname, ok_if_already_exists; 2883 Lisp_Object filename, linkname, ok_if_already_exists;
2906{ 2884{
2907#ifdef NO_ARG_ARRAY
2908 Lisp_Object args[2];
2909#endif
2910 Lisp_Object handler; 2885 Lisp_Object handler;
2911 Lisp_Object encoded_filename, encoded_linkname; 2886 Lisp_Object encoded_filename, encoded_linkname;
2912 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 2887 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -2962,13 +2937,7 @@ This happens for interactive use with M-x. */)
2962 } 2937 }
2963 } 2938 }
2964 2939
2965#ifdef NO_ARG_ARRAY 2940 report_file_error ("Making symbolic link", list2 (filename, linkname));
2966 args[0] = filename;
2967 args[1] = linkname;
2968 report_file_error ("Making symbolic link", Flist (2, args));
2969#else
2970 report_file_error ("Making symbolic link", Flist (2, &filename));
2971#endif
2972 } 2941 }
2973 UNGCPRO; 2942 UNGCPRO;
2974 return Qnil; 2943 return Qnil;
@@ -4847,6 +4816,8 @@ choose_write_coding_system (start, end, filename,
4847 /* ... but with the special flag to indicate not to strip off 4816 /* ... but with the special flag to indicate not to strip off
4848 leading code of eight-bit-control chars. */ 4817 leading code of eight-bit-control chars. */
4849 coding->flags = 1; 4818 coding->flags = 1;
4819 /* We force LF for end-of-line because that is faster. */
4820 coding->eol_type = CODING_EOL_LF;
4850 goto done_setup_coding; 4821 goto done_setup_coding;
4851 } 4822 }
4852 else if (!NILP (Vcoding_system_for_write)) 4823 else if (!NILP (Vcoding_system_for_write))
diff --git a/src/fns.c b/src/fns.c
index 0054e6fc998..5fe429fcf8b 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5030,7 +5030,7 @@ sxhash_string (ptr, len)
5030 c = *p++; 5030 c = *p++;
5031 if (c >= 0140) 5031 if (c >= 0140)
5032 c -= 40; 5032 c -= 40;
5033 hash = ((hash << 3) + (hash >> 28) + c); 5033 hash = ((hash << 4) + (hash >> 28) + c);
5034 } 5034 }
5035 5035
5036 return hash & INTMASK; 5036 return hash & INTMASK;
diff --git a/src/frame.c b/src/frame.c
index fd10c3e273c..021e9bf604f 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1679,7 +1679,8 @@ The functions are run with one arg, the frame to be deleted. */)
1679DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0, 1679DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
1680 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. 1680 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1681The position is given in character cells, where (0, 0) is the 1681The position is given in character cells, where (0, 0) is the
1682upper-left corner. 1682upper-left corner of the frame, X is the horizontal offset, and Y is
1683the vertical offset.
1683If Emacs is running on a mouseless terminal or hasn't been programmed 1684If Emacs is running on a mouseless terminal or hasn't been programmed
1684to read the mouse position, it returns the selected frame for FRAME 1685to read the mouse position, it returns the selected frame for FRAME
1685and nil for X and Y. 1686and nil for X and Y.
@@ -1727,7 +1728,8 @@ DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
1727 Smouse_pixel_position, 0, 0, 0, 1728 Smouse_pixel_position, 0, 0, 0,
1728 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. 1729 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1729The position is given in pixel units, where (0, 0) is the 1730The position is given in pixel units, where (0, 0) is the
1730upper-left corner. 1731upper-left corner of the frame, X is the horizontal offset, and Y is
1732the vertical offset.
1731If Emacs is running on a mouseless terminal or hasn't been programmed 1733If Emacs is running on a mouseless terminal or hasn't been programmed
1732to read the mouse position, it returns the selected frame for FRAME 1734to read the mouse position, it returns the selected frame for FRAME
1733and nil for X and Y. */) 1735and nil for X and Y. */)
@@ -1760,6 +1762,10 @@ Coordinates are relative to the frame, not a window,
1760so the coordinates of the top left character in the frame 1762so the coordinates of the top left character in the frame
1761may be nonzero due to left-hand scroll bars or the menu bar. 1763may be nonzero due to left-hand scroll bars or the menu bar.
1762 1764
1765The position is given in character cells, where (0, 0) is the
1766upper-left corner of the frame, X is the horizontal offset, and Y is
1767the vertical offset.
1768
1763This function is a no-op for an X frame that is not visible. 1769This function is a no-op for an X frame that is not visible.
1764If you have just created a frame, you must wait for it to become visible 1770If you have just created a frame, you must wait for it to become visible
1765before calling this function on it, like this. 1771before calling this function on it, like this.
@@ -1792,6 +1798,9 @@ before calling this function on it, like this.
1792DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, 1798DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
1793 Sset_mouse_pixel_position, 3, 3, 0, 1799 Sset_mouse_pixel_position, 3, 3, 0,
1794 doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME. 1800 doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1801The position is given in pixels, where (0, 0) is the upper-left corner
1802of the frame, X is the horizontal offset, and Y is the vertical offset.
1803
1795Note, this is a no-op for an X frame that is not visible. 1804Note, this is a no-op for an X frame that is not visible.
1796If you have just created a frame, you must wait for it to become visible 1805If you have just created a frame, you must wait for it to become visible
1797before calling this function on it, like this. 1806before calling this function on it, like this.
diff --git a/src/image.c b/src/image.c
index 490ede60e35..a3ae6ceb3ce 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2398,7 +2398,7 @@ image_load_qt_1 (f, img, type, fss, dh)
2398 FSSpec *fss; 2398 FSSpec *fss;
2399 Handle dh; 2399 Handle dh;
2400{ 2400{
2401 OSErr err; 2401 ComponentResult err;
2402 GraphicsImportComponent gi; 2402 GraphicsImportComponent gi;
2403 Rect rect; 2403 Rect rect;
2404 int width, height; 2404 int width, height;
diff --git a/src/keyboard.c b/src/keyboard.c
index f1bfea0f18c..681018bbab9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1458,6 +1458,72 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0,
1458 return Qnil; 1458 return Qnil;
1459} 1459}
1460 1460
1461#ifdef HAVE_MOUSE
1462
1463/* Restore mouse tracking enablement. See Ftrack_mouse for the only use
1464 of this function. */
1465
1466static Lisp_Object
1467tracking_off (old_value)
1468 Lisp_Object old_value;
1469{
1470 do_mouse_tracking = old_value;
1471 if (NILP (old_value))
1472 {
1473 /* Redisplay may have been preempted because there was input
1474 available, and it assumes it will be called again after the
1475 input has been processed. If the only input available was
1476 the sort that we have just disabled, then we need to call
1477 redisplay. */
1478 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW))
1479 {
1480 redisplay_preserve_echo_area (6);
1481 get_input_pending (&input_pending,
1482 READABLE_EVENTS_DO_TIMERS_NOW);
1483 }
1484 }
1485 return Qnil;
1486}
1487
1488DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
1489 doc: /* Evaluate BODY with mouse movement events enabled.
1490Within a `track-mouse' form, mouse motion generates input events that
1491you can read with `read-event'.
1492Normally, mouse motion is ignored.
1493usage: (track-mouse BODY ...) */)
1494 (args)
1495 Lisp_Object args;
1496{
1497 int count = SPECPDL_INDEX ();
1498 Lisp_Object val;
1499
1500 record_unwind_protect (tracking_off, do_mouse_tracking);
1501
1502 do_mouse_tracking = Qt;
1503
1504 val = Fprogn (args);
1505 return unbind_to (count, val);
1506}
1507
1508/* If mouse has moved on some frame, return one of those frames.
1509 Return 0 otherwise. */
1510
1511static FRAME_PTR
1512some_mouse_moved ()
1513{
1514 Lisp_Object tail, frame;
1515
1516 FOR_EACH_FRAME (tail, frame)
1517 {
1518 if (XFRAME (frame)->mouse_moved)
1519 return XFRAME (frame);
1520 }
1521
1522 return 0;
1523}
1524
1525#endif /* HAVE_MOUSE */
1526
1461/* This is the actual command reading loop, 1527/* This is the actual command reading loop,
1462 sans error-handling encapsulation. */ 1528 sans error-handling encapsulation. */
1463 1529
@@ -2106,6 +2172,8 @@ static Lisp_Object
2106safe_run_hooks_1 (hook) 2172safe_run_hooks_1 (hook)
2107 Lisp_Object hook; 2173 Lisp_Object hook;
2108{ 2174{
2175 if (NILP (Vrun_hooks))
2176 return Qnil;
2109 return call1 (Vrun_hooks, Vinhibit_quit); 2177 return call1 (Vrun_hooks, Vinhibit_quit);
2110} 2178}
2111 2179
@@ -2388,7 +2456,17 @@ show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo)
2388 2456
2389#ifdef HAVE_MOUSE 2457#ifdef HAVE_MOUSE
2390 if (!noninteractive && STRINGP (help)) 2458 if (!noninteractive && STRINGP (help))
2391 help = call1 (Qmouse_fixup_help_message, help); 2459 {
2460 /* The mouse-fixup-help-message Lisp function can call
2461 mouse_position_hook, which resets the mouse_moved flags.
2462 This causes trouble if we are trying to read a mouse motion
2463 event (i.e., if we are inside a `track-mouse' form), so we
2464 restore the mouse_moved flag. */
2465 FRAME_PTR f = NILP (do_mouse_tracking) ? NULL : some_mouse_moved ();
2466 help = call1 (Qmouse_fixup_help_message, help);
2467 if (f)
2468 f->mouse_moved = 1;
2469 }
2392#endif 2470#endif
2393 2471
2394 if (STRINGP (help) || NILP (help)) 2472 if (STRINGP (help) || NILP (help))
@@ -2483,7 +2561,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
2483 EMACS_TIME *end_time; 2561 EMACS_TIME *end_time;
2484{ 2562{
2485 volatile Lisp_Object c; 2563 volatile Lisp_Object c;
2486 int count; 2564 int count, jmpcount;
2487 jmp_buf local_getcjmp; 2565 jmp_buf local_getcjmp;
2488 jmp_buf save_jump; 2566 jmp_buf save_jump;
2489 volatile int key_already_recorded = 0; 2567 volatile int key_already_recorded = 0;
@@ -2714,12 +2792,14 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
2714 around any call to sit_for or kbd_buffer_get_event; 2792 around any call to sit_for or kbd_buffer_get_event;
2715 it *must not* be in effect when we call redisplay. */ 2793 it *must not* be in effect when we call redisplay. */
2716 2794
2795 jmpcount = SPECPDL_INDEX ();
2717 if (_setjmp (local_getcjmp)) 2796 if (_setjmp (local_getcjmp))
2718 { 2797 {
2719 /* Handle quits while reading the keyboard. */ 2798 /* Handle quits while reading the keyboard. */
2720 /* We must have saved the outer value of getcjmp here, 2799 /* We must have saved the outer value of getcjmp here,
2721 so restore it now. */ 2800 so restore it now. */
2722 restore_getcjmp (save_jump); 2801 restore_getcjmp (save_jump);
2802 unbind_to (jmpcount, Qnil);
2723 XSETINT (c, quit_char); 2803 XSETINT (c, quit_char);
2724 internal_last_event_frame = selected_frame; 2804 internal_last_event_frame = selected_frame;
2725 Vlast_event_frame = internal_last_event_frame; 2805 Vlast_event_frame = internal_last_event_frame;
@@ -2760,7 +2840,12 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
2760 goto non_reread; 2840 goto non_reread;
2761 } 2841 }
2762 2842
2763 timer_start_idle (); 2843 /* Start idle timers if no time limit is supplied. We don't do it
2844 if a time limit is supplied to avoid an infinite recursion in the
2845 situation where an idle timer calls `sit-for'. */
2846
2847 if (!end_time)
2848 timer_start_idle ();
2764 2849
2765 /* If in middle of key sequence and minibuffer not active, 2850 /* If in middle of key sequence and minibuffer not active,
2766 start echoing if enough time elapses. */ 2851 start echoing if enough time elapses. */
@@ -2830,7 +2915,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
2830 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 2915 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
2831 2916
2832 /* Now that we have read an event, Emacs is not idle. */ 2917 /* Now that we have read an event, Emacs is not idle. */
2833 timer_stop_idle (); 2918 if (!end_time)
2919 timer_stop_idle ();
2834 2920
2835 goto exit; 2921 goto exit;
2836 } 2922 }
@@ -2973,7 +3059,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
2973 /* Actually read a character, waiting if necessary. */ 3059 /* Actually read a character, waiting if necessary. */
2974 save_getcjmp (save_jump); 3060 save_getcjmp (save_jump);
2975 restore_getcjmp (local_getcjmp); 3061 restore_getcjmp (local_getcjmp);
2976 timer_start_idle (); 3062 if (!end_time)
3063 timer_start_idle ();
2977 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); 3064 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
2978 restore_getcjmp (save_jump); 3065 restore_getcjmp (save_jump);
2979 3066
@@ -3025,7 +3112,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
3025 3112
3026 non_reread: 3113 non_reread:
3027 3114
3028 timer_stop_idle (); 3115 if (!end_time)
3116 timer_stop_idle ();
3029 RESUME_POLLING; 3117 RESUME_POLLING;
3030 3118
3031 if (NILP (c)) 3119 if (NILP (c))
@@ -3063,7 +3151,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
3063 last_input_char = c; 3151 last_input_char = c;
3064 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); 3152 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt);
3065 3153
3066 if (CONSP (c) && EQ (XCAR (c), Qselect_window)) 3154 if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time)
3067 /* We stopped being idle for this event; undo that. This 3155 /* We stopped being idle for this event; undo that. This
3068 prevents automatic window selection (under 3156 prevents automatic window selection (under
3069 mouse_autoselect_window from acting as a real input event, for 3157 mouse_autoselect_window from acting as a real input event, for
@@ -3272,7 +3360,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time)
3272 show_help_echo (help, window, object, position, 0); 3360 show_help_echo (help, window, object, position, 0);
3273 3361
3274 /* We stopped being idle for this event; undo that. */ 3362 /* We stopped being idle for this event; undo that. */
3275 timer_resume_idle (); 3363 if (!end_time)
3364 timer_resume_idle ();
3276 goto retry; 3365 goto retry;
3277 } 3366 }
3278 3367
@@ -3556,72 +3645,6 @@ restore_getcjmp (temp)
3556 bcopy (temp, getcjmp, sizeof getcjmp); 3645 bcopy (temp, getcjmp, sizeof getcjmp);
3557} 3646}
3558 3647
3559#ifdef HAVE_MOUSE
3560
3561/* Restore mouse tracking enablement. See Ftrack_mouse for the only use
3562 of this function. */
3563
3564static Lisp_Object
3565tracking_off (old_value)
3566 Lisp_Object old_value;
3567{
3568 do_mouse_tracking = old_value;
3569 if (NILP (old_value))
3570 {
3571 /* Redisplay may have been preempted because there was input
3572 available, and it assumes it will be called again after the
3573 input has been processed. If the only input available was
3574 the sort that we have just disabled, then we need to call
3575 redisplay. */
3576 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW))
3577 {
3578 redisplay_preserve_echo_area (6);
3579 get_input_pending (&input_pending,
3580 READABLE_EVENTS_DO_TIMERS_NOW);
3581 }
3582 }
3583 return Qnil;
3584}
3585
3586DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
3587 doc: /* Evaluate BODY with mouse movement events enabled.
3588Within a `track-mouse' form, mouse motion generates input events that
3589you can read with `read-event'.
3590Normally, mouse motion is ignored.
3591usage: (track-mouse BODY ...) */)
3592 (args)
3593 Lisp_Object args;
3594{
3595 int count = SPECPDL_INDEX ();
3596 Lisp_Object val;
3597
3598 record_unwind_protect (tracking_off, do_mouse_tracking);
3599
3600 do_mouse_tracking = Qt;
3601
3602 val = Fprogn (args);
3603 return unbind_to (count, val);
3604}
3605
3606/* If mouse has moved on some frame, return one of those frames.
3607 Return 0 otherwise. */
3608
3609static FRAME_PTR
3610some_mouse_moved ()
3611{
3612 Lisp_Object tail, frame;
3613
3614 FOR_EACH_FRAME (tail, frame)
3615 {
3616 if (XFRAME (frame)->mouse_moved)
3617 return XFRAME (frame);
3618 }
3619
3620 return 0;
3621}
3622
3623#endif /* HAVE_MOUSE */
3624
3625/* Low level keyboard/mouse input. 3648/* Low level keyboard/mouse input.
3626 kbd_buffer_store_event places events in kbd_buffer, and 3649 kbd_buffer_store_event places events in kbd_buffer, and
3627 kbd_buffer_get_event retrieves them. */ 3650 kbd_buffer_get_event retrieves them. */
@@ -4056,13 +4079,15 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
4056 { 4079 {
4057 EMACS_TIME duration; 4080 EMACS_TIME duration;
4058 EMACS_GET_TIME (duration); 4081 EMACS_GET_TIME (duration);
4059 EMACS_SUB_TIME (duration, *end_time, duration); 4082 if (EMACS_TIME_GE (duration, *end_time))
4060 if (EMACS_TIME_NEG_P (duration)) 4083 return Qnil; /* finished waiting */
4061 return Qnil;
4062 else 4084 else
4063 wait_reading_process_output (EMACS_SECS (duration), 4085 {
4064 EMACS_USECS (duration), 4086 EMACS_SUB_TIME (duration, *end_time, duration);
4065 -1, 1, Qnil, NULL, 0); 4087 wait_reading_process_output (EMACS_SECS (duration),
4088 EMACS_USECS (duration),
4089 -1, 1, Qnil, NULL, 0);
4090 }
4066 } 4091 }
4067 else 4092 else
4068 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); 4093 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0);
@@ -4635,6 +4660,32 @@ timer_check (do_it_now)
4635 UNGCPRO; 4660 UNGCPRO;
4636 return nexttime; 4661 return nexttime;
4637} 4662}
4663
4664DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0,
4665 doc: /* Return the current length of Emacs idleness.
4666The value is returned as a list of three integers. The first has the
4667most significant 16 bits of the seconds, while the second has the
4668least significant 16 bits. The third integer gives the microsecond
4669count.
4670
4671The microsecond count is zero on systems that do not provide
4672resolution finer than a second. */)
4673 ()
4674{
4675 if (! EMACS_TIME_NEG_P (timer_idleness_start_time))
4676 {
4677 EMACS_TIME now, idleness_now;
4678
4679 EMACS_GET_TIME (now);
4680 EMACS_SUB_TIME (idleness_now, now, timer_idleness_start_time);
4681
4682 return list3 (make_number ((EMACS_SECS (idleness_now) >> 16) & 0xffff),
4683 make_number ((EMACS_SECS (idleness_now) >> 0) & 0xffff),
4684 make_number (EMACS_USECS (idleness_now)));
4685 }
4686
4687 return Qnil;
4688}
4638 4689
4639/* Caches for modify_event_symbol. */ 4690/* Caches for modify_event_symbol. */
4640static Lisp_Object accent_key_syms; 4691static Lisp_Object accent_key_syms;
@@ -8565,7 +8616,15 @@ follow_key (key, nmaps, current, defs, next)
8565 such as Vfunction_key_map and Vkey_translation_map. */ 8616 such as Vfunction_key_map and Vkey_translation_map. */
8566typedef struct keyremap 8617typedef struct keyremap
8567{ 8618{
8568 Lisp_Object map, parent; 8619 /* This is the map originally specified for this use. */
8620 Lisp_Object parent;
8621 /* This is a submap reached by looking up, in PARENT,
8622 the events from START to END. */
8623 Lisp_Object map;
8624 /* Positions [START, END) in the key sequence buffer
8625 are the key that we have scanned so far.
8626 Those events are the ones that we will replace
8627 if PAREHT maps them into a key sequence. */
8569 int start, end; 8628 int start, end;
8570} keyremap; 8629} keyremap;
8571 8630
@@ -8638,7 +8697,11 @@ keyremap_step (keybuf, bufsize, fkey, input, doit, diff, prompt)
8638 Lisp_Object next, key; 8697 Lisp_Object next, key;
8639 8698
8640 key = keybuf[fkey->end++]; 8699 key = keybuf[fkey->end++];
8641 next = access_keymap_keyremap (fkey->map, key, prompt, doit); 8700
8701 if (KEYMAPP (fkey->parent))
8702 next = access_keymap_keyremap (fkey->map, key, prompt, doit);
8703 else
8704 next = Qnil;
8642 8705
8643 /* If keybuf[fkey->start..fkey->end] is bound in the 8706 /* If keybuf[fkey->start..fkey->end] is bound in the
8644 map and we're in a position to do the key remapping, replace it with 8707 map and we're in a position to do the key remapping, replace it with
@@ -8878,9 +8941,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8878 reinitialize fkey and keytran before each replay. */ 8941 reinitialize fkey and keytran before each replay. */
8879 fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map; 8942 fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map;
8880 keytran.map = keytran.parent = current_kboard->Vlocal_key_translation_map; 8943 keytran.map = keytran.parent = current_kboard->Vlocal_key_translation_map;
8881 /* If there is no translation map, turn off scanning. */ 8944 fkey.start = fkey.end = 0;
8882 fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; 8945 keytran.start = keytran.end = 0;
8883 keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1;
8884 8946
8885 starting_buffer = current_buffer; 8947 starting_buffer = current_buffer;
8886 first_unbound = bufsize + 1; 8948 first_unbound = bufsize + 1;
@@ -9687,8 +9749,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
9687 9749
9688 keybuf[t - 1] = new_key; 9750 keybuf[t - 1] = new_key;
9689 mock_input = max (t, mock_input); 9751 mock_input = max (t, mock_input);
9690 fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; 9752 fkey.start = fkey.end = 0;
9691 keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1; 9753 keytran.start = keytran.end = 0;
9692 9754
9693 goto replay_sequence; 9755 goto replay_sequence;
9694 } 9756 }
@@ -11494,6 +11556,7 @@ syms_of_keyboard ()
11494 menu_bar_items_vector = Qnil; 11556 menu_bar_items_vector = Qnil;
11495 staticpro (&menu_bar_items_vector); 11557 staticpro (&menu_bar_items_vector);
11496 11558
11559 defsubr (&Scurrent_idle_time);
11497 defsubr (&Sevent_convert_list); 11560 defsubr (&Sevent_convert_list);
11498 defsubr (&Sread_key_sequence); 11561 defsubr (&Sread_key_sequence);
11499 defsubr (&Sread_key_sequence_vector); 11562 defsubr (&Sread_key_sequence_vector);
@@ -11555,14 +11618,16 @@ These events are processed first, before actual keyboard input. */);
11555 11618
11556 DEFVAR_LISP ("unread-post-input-method-events", &Vunread_post_input_method_events, 11619 DEFVAR_LISP ("unread-post-input-method-events", &Vunread_post_input_method_events,
11557 doc: /* List of events to be processed as input by input methods. 11620 doc: /* List of events to be processed as input by input methods.
11558These events are processed after `unread-command-events', but 11621These events are processed before `unread-command-events'
11559before actual keyboard input. */); 11622and actual keyboard input without given to `input-method-function'. */);
11560 Vunread_post_input_method_events = Qnil; 11623 Vunread_post_input_method_events = Qnil;
11561 11624
11562 DEFVAR_LISP ("unread-input-method-events", &Vunread_input_method_events, 11625 DEFVAR_LISP ("unread-input-method-events", &Vunread_input_method_events,
11563 doc: /* List of events to be processed as input by input methods. 11626 doc: /* List of events to be processed as input by input methods.
11564These events are processed after `unread-command-events', but 11627These events are processed after `unread-command-events', but
11565before actual keyboard input. */); 11628before actual keyboard input.
11629If there's an active input method, the events are given to
11630`input-method-function'. */);
11566 Vunread_input_method_events = Qnil; 11631 Vunread_input_method_events = Qnil;
11567 11632
11568 DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, 11633 DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char,
diff --git a/src/mac.c b/src/mac.c
index 4652757fab3..67fd5e4f5e0 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -831,7 +831,7 @@ create_apple_event (class, id, result)
831 return err; 831 return err;
832} 832}
833 833
834OSErr 834OSStatus
835create_apple_event_from_event_ref (event, num_params, names, types, result) 835create_apple_event_from_event_ref (event, num_params, names, types, result)
836 EventRef event; 836 EventRef event;
837 UInt32 num_params; 837 UInt32 num_params;
@@ -839,7 +839,7 @@ create_apple_event_from_event_ref (event, num_params, names, types, result)
839 EventParamType *types; 839 EventParamType *types;
840 AppleEvent *result; 840 AppleEvent *result;
841{ 841{
842 OSErr err; 842 OSStatus err;
843 UInt32 i, size; 843 UInt32 i, size;
844 CFStringRef string; 844 CFStringRef string;
845 CFDataRef data; 845 CFDataRef data;
@@ -2424,7 +2424,7 @@ select (n, rfds, wfds, efds, timeout)
2424 SELECT_TYPE *efds; 2424 SELECT_TYPE *efds;
2425 struct timeval *timeout; 2425 struct timeval *timeout;
2426{ 2426{
2427 OSErr err; 2427 OSStatus err;
2428#if TARGET_API_MAC_CARBON 2428#if TARGET_API_MAC_CARBON
2429 EventTimeout timeout_sec = 2429 EventTimeout timeout_sec =
2430 (timeout 2430 (timeout
@@ -4192,7 +4192,7 @@ DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1,
4192 (filename) 4192 (filename)
4193 Lisp_Object filename; 4193 Lisp_Object filename;
4194{ 4194{
4195 OSErr status; 4195 OSStatus status;
4196#ifdef MAC_OSX 4196#ifdef MAC_OSX
4197 FSRef fref; 4197 FSRef fref;
4198#else 4198#else
@@ -4246,7 +4246,7 @@ DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0,
4246 (filename) 4246 (filename)
4247 Lisp_Object filename; 4247 Lisp_Object filename;
4248{ 4248{
4249 OSErr status; 4249 OSStatus status;
4250#ifdef MAC_OSX 4250#ifdef MAC_OSX
4251 FSRef fref; 4251 FSRef fref;
4252#else 4252#else
@@ -4302,7 +4302,7 @@ assumed. Return non-nil if successful. */)
4302 (filename, code) 4302 (filename, code)
4303 Lisp_Object filename, code; 4303 Lisp_Object filename, code;
4304{ 4304{
4305 OSErr status; 4305 OSStatus status;
4306#ifdef MAC_OSX 4306#ifdef MAC_OSX
4307 FSRef fref; 4307 FSRef fref;
4308#else 4308#else
@@ -4362,7 +4362,7 @@ CODE must be a 4-character string. Return non-nil if successful. */)
4362 (filename, code) 4362 (filename, code)
4363 Lisp_Object filename, code; 4363 Lisp_Object filename, code;
4364{ 4364{
4365 OSErr status; 4365 OSStatus status;
4366#ifdef MAC_OSX 4366#ifdef MAC_OSX
4367 FSRef fref; 4367 FSRef fref;
4368#else 4368#else
@@ -4775,7 +4775,7 @@ cfstring_create_normalized (str, symbol)
4775 UnicodeMapping map; 4775 UnicodeMapping map;
4776 CFIndex length; 4776 CFIndex length;
4777 UniChar *in_text, *buffer = NULL, *out_buf = NULL; 4777 UniChar *in_text, *buffer = NULL, *out_buf = NULL;
4778 OSErr err = noErr; 4778 OSStatus err = noErr;
4779 ByteCount out_read, out_size, out_len; 4779 ByteCount out_read, out_size, out_len;
4780 4780
4781 map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault, 4781 map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault,
@@ -4910,7 +4910,7 @@ On successful conversion, return the result string, else return nil. */)
4910static Lisp_Object 4910static Lisp_Object
4911mac_get_system_locale () 4911mac_get_system_locale ()
4912{ 4912{
4913 OSErr err; 4913 OSStatus err;
4914 LangCode lang; 4914 LangCode lang;
4915 RegionCode region; 4915 RegionCode region;
4916 LocaleRef locale; 4916 LocaleRef locale;
@@ -4987,7 +4987,7 @@ select_and_poll_event (n, rfds, wfds, efds, timeout)
4987 struct timeval *timeout; 4987 struct timeval *timeout;
4988{ 4988{
4989 int r; 4989 int r;
4990 OSErr err; 4990 OSStatus err;
4991 4991
4992 r = select (n, rfds, wfds, efds, timeout); 4992 r = select (n, rfds, wfds, efds, timeout);
4993 if (r != -1) 4993 if (r != -1)
@@ -5017,7 +5017,7 @@ sys_select (n, rfds, wfds, efds, timeout)
5017 SELECT_TYPE *efds; 5017 SELECT_TYPE *efds;
5018 struct timeval *timeout; 5018 struct timeval *timeout;
5019{ 5019{
5020 OSErr err; 5020 OSStatus err;
5021 int i, r; 5021 int i, r;
5022 EMACS_TIME select_timeout; 5022 EMACS_TIME select_timeout;
5023 5023
diff --git a/src/macfns.c b/src/macfns.c
index 8716f072411..2d004be9962 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1945,63 +1945,80 @@ static void
1945mac_update_proxy_icon (f) 1945mac_update_proxy_icon (f)
1946 struct frame *f; 1946 struct frame *f;
1947{ 1947{
1948 OSStatus err;
1948 Lisp_Object file_name = 1949 Lisp_Object file_name =
1949 XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename; 1950 XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename;
1950 Window w = FRAME_MAC_WINDOW (f); 1951 Window w = FRAME_MAC_WINDOW (f);
1951 1952 AliasHandle alias = NULL;
1952 if (FRAME_FILE_NAME (f) == NULL && !STRINGP (file_name))
1953 return;
1954 if (FRAME_FILE_NAME (f) && STRINGP (file_name)
1955 && strcmp (FRAME_FILE_NAME (f), SDATA (file_name)) == 0)
1956 return;
1957
1958 if (FRAME_FILE_NAME (f))
1959 {
1960 xfree (FRAME_FILE_NAME (f));
1961 FRAME_FILE_NAME (f) = NULL;
1962 }
1963 1953
1964 BLOCK_INPUT; 1954 BLOCK_INPUT;
1965 1955
1956 err = GetWindowProxyAlias (w, &alias);
1957 if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name))
1958 goto out;
1959
1966 if (STRINGP (file_name)) 1960 if (STRINGP (file_name))
1967 { 1961 {
1968 OSStatus err;
1969 AEDesc desc; 1962 AEDesc desc;
1963#ifdef MAC_OSX
1964 FSRef fref;
1965#else
1966 FSSpec fss;
1967#endif
1968 Boolean changed;
1970 Lisp_Object encoded_file_name = ENCODE_FILE (file_name); 1969 Lisp_Object encoded_file_name = ENCODE_FILE (file_name);
1971 1970
1972#ifdef MAC_OS8 1971#ifdef MAC_OSX
1972 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
1973 SBYTES (encoded_file_name), typeFSRef, &desc);
1974#else
1973 SetPortWindowPort (w); 1975 SetPortWindowPort (w);
1974#endif
1975 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name), 1976 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
1976 SBYTES (encoded_file_name), typeAlias, &desc); 1977 SBYTES (encoded_file_name), typeFSS, &desc);
1978#endif
1977 if (err == noErr) 1979 if (err == noErr)
1978 { 1980 {
1979 Size size = AEGetDescDataSize (&desc); 1981#ifdef MAC_OSX
1980 AliasHandle alias = (AliasHandle) NewHandle (size); 1982 err = AEGetDescData (&desc, &fref, sizeof (FSRef));
1981 1983#else
1982 if (alias == NULL) 1984 err = AEGetDescData (&desc, &fss, sizeof (FSSpec));
1983 err = memFullErr; 1985#endif
1984 else
1985 {
1986 HLock ((Handle) alias);
1987 err = AEGetDescData (&desc, *alias, size);
1988 HUnlock ((Handle) alias);
1989 if (err == noErr)
1990 err = SetWindowProxyAlias (w, alias);
1991 DisposeHandle ((Handle) alias);
1992 }
1993 AEDisposeDesc (&desc); 1986 AEDisposeDesc (&desc);
1994 } 1987 }
1995 if (err == noErr) 1988 if (err == noErr)
1996 { 1989 {
1997 FRAME_FILE_NAME (f) = xmalloc (SBYTES (file_name) + 1); 1990 if (alias)
1998 strcpy (FRAME_FILE_NAME (f), SDATA (file_name)); 1991 {
1992#ifdef MAC_OSX
1993 err = FSUpdateAlias (NULL, &fref, alias, &changed);
1994#else
1995 err = UpdateAlias (NULL, &fss, alias, &changed);
1996#endif
1997 }
1998 if (err != noErr || alias == NULL)
1999 {
2000 if (alias)
2001 DisposeHandle ((Handle) alias);
2002#ifdef MAC_OSX
2003 err = FSNewAliasMinimal (&fref, &alias);
2004#else
2005 err = NewAliasMinimal (&fss, &alias);
2006#endif
2007 changed = true;
2008 }
1999 } 2009 }
2010 if (err == noErr)
2011 if (changed)
2012 err = SetWindowProxyAlias (w, alias);
2000 } 2013 }
2001 2014
2002 if (FRAME_FILE_NAME (f) == NULL) 2015 if (alias)
2016 DisposeHandle ((Handle) alias);
2017
2018 if (err != noErr || !STRINGP (file_name))
2003 RemoveWindowProxy (w); 2019 RemoveWindowProxy (w);
2004 2020
2021 out:
2005 UNBLOCK_INPUT; 2022 UNBLOCK_INPUT;
2006} 2023}
2007#endif 2024#endif
@@ -2566,7 +2583,6 @@ This function is an internal primitive--use `make-frame' instead. */)
2566 f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); 2583 f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
2567 bzero (f->output_data.mac, sizeof (struct mac_output)); 2584 bzero (f->output_data.mac, sizeof (struct mac_output));
2568 FRAME_FONTSET (f) = -1; 2585 FRAME_FONTSET (f) = -1;
2569 record_unwind_protect (unwind_create_frame, frame);
2570 2586
2571 f->icon_name 2587 f->icon_name
2572 = mac_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING); 2588 = mac_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING);
@@ -2574,6 +2590,9 @@ This function is an internal primitive--use `make-frame' instead. */)
2574 f->icon_name = Qnil; 2590 f->icon_name = Qnil;
2575 2591
2576/* FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */ 2592/* FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */
2593
2594 /* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe. */
2595 record_unwind_protect (unwind_create_frame, frame);
2577#if GLYPH_DEBUG 2596#if GLYPH_DEBUG
2578 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; 2597 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
2579 dpyinfo_refcount = dpyinfo->reference_count; 2598 dpyinfo_refcount = dpyinfo->reference_count;
@@ -2876,14 +2895,9 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2876 CHECK_STRING (color); 2895 CHECK_STRING (color);
2877 2896
2878 if (mac_defined_color (f, SDATA (color), &foo, 0)) 2897 if (mac_defined_color (f, SDATA (color), &foo, 0))
2879 { 2898 return list3 (make_number (foo.red),
2880 Lisp_Object rgb[3]; 2899 make_number (foo.green),
2881 2900 make_number (foo.blue));
2882 rgb[0] = make_number (foo.red);
2883 rgb[1] = make_number (foo.green);
2884 rgb[2] = make_number (foo.blue);
2885 return Flist (3, rgb);
2886 }
2887 else 2901 else
2888 return Qnil; 2902 return Qnil;
2889} 2903}
diff --git a/src/macselect.c b/src/macselect.c
index 67a28cf9e64..fd72bd3cb14 100644
--- a/src/macselect.c
+++ b/src/macselect.c
@@ -31,15 +31,15 @@ typedef int ScrapRef;
31typedef ResType ScrapFlavorType; 31typedef ResType ScrapFlavorType;
32#endif /* !TARGET_API_MAC_CARBON */ 32#endif /* !TARGET_API_MAC_CARBON */
33 33
34static OSErr get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *)); 34static OSStatus get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *));
35static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object)); 35static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object));
36static int valid_scrap_target_type_p P_ ((Lisp_Object)); 36static int valid_scrap_target_type_p P_ ((Lisp_Object));
37static OSErr clear_scrap P_ ((ScrapRef *)); 37static OSStatus clear_scrap P_ ((ScrapRef *));
38static OSErr put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object)); 38static OSStatus put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object));
39static OSErr put_scrap_private_timestamp P_ ((ScrapRef, unsigned long)); 39static OSStatus put_scrap_private_timestamp P_ ((ScrapRef, unsigned long));
40static ScrapFlavorType scrap_has_target_type P_ ((ScrapRef, Lisp_Object)); 40static ScrapFlavorType scrap_has_target_type P_ ((ScrapRef, Lisp_Object));
41static Lisp_Object get_scrap_string P_ ((ScrapRef, Lisp_Object)); 41static Lisp_Object get_scrap_string P_ ((ScrapRef, Lisp_Object));
42static OSErr get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *)); 42static OSStatus get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *));
43static Lisp_Object get_scrap_target_type_list P_ ((ScrapRef)); 43static Lisp_Object get_scrap_target_type_list P_ ((ScrapRef));
44static void x_own_selection P_ ((Lisp_Object, Lisp_Object)); 44static void x_own_selection P_ ((Lisp_Object, Lisp_Object));
45static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int)); 45static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int));
@@ -108,13 +108,13 @@ static Lisp_Object Vmac_service_selection;
108 reference is set to *SCRAP, and it becomes NULL if there's no 108 reference is set to *SCRAP, and it becomes NULL if there's no
109 corresponding scrap. Clear the scrap if CLEAR_P is non-zero. */ 109 corresponding scrap. Clear the scrap if CLEAR_P is non-zero. */
110 110
111static OSErr 111static OSStatus
112get_scrap_from_symbol (sym, clear_p, scrap) 112get_scrap_from_symbol (sym, clear_p, scrap)
113 Lisp_Object sym; 113 Lisp_Object sym;
114 int clear_p; 114 int clear_p;
115 ScrapRef *scrap; 115 ScrapRef *scrap;
116{ 116{
117 OSErr err = noErr; 117 OSStatus err = noErr;
118 Lisp_Object str = Fget (sym, Qmac_scrap_name); 118 Lisp_Object str = Fget (sym, Qmac_scrap_name);
119 119
120 if (!STRINGP (str)) 120 if (!STRINGP (str))
@@ -172,7 +172,7 @@ valid_scrap_target_type_p (sym)
172 172
173/* Clear the scrap whose reference is *SCRAP. */ 173/* Clear the scrap whose reference is *SCRAP. */
174 174
175static INLINE OSErr 175static INLINE OSStatus
176clear_scrap (scrap) 176clear_scrap (scrap)
177 ScrapRef *scrap; 177 ScrapRef *scrap;
178{ 178{
@@ -190,7 +190,7 @@ clear_scrap (scrap)
190/* Put Lisp String STR to the scrap SCRAP. The target type is 190/* Put Lisp String STR to the scrap SCRAP. The target type is
191 specified by TYPE. */ 191 specified by TYPE. */
192 192
193static OSErr 193static OSStatus
194put_scrap_string (scrap, type, str) 194put_scrap_string (scrap, type, str)
195 ScrapRef scrap; 195 ScrapRef scrap;
196 Lisp_Object type, str; 196 Lisp_Object type, str;
@@ -211,7 +211,7 @@ put_scrap_string (scrap, type, str)
211/* Put TIMESTAMP to the scrap SCRAP. The timestamp is used for 211/* Put TIMESTAMP to the scrap SCRAP. The timestamp is used for
212 checking if the scrap is owned by the process. */ 212 checking if the scrap is owned by the process. */
213 213
214static INLINE OSErr 214static INLINE OSStatus
215put_scrap_private_timestamp (scrap, timestamp) 215put_scrap_private_timestamp (scrap, timestamp)
216 ScrapRef scrap; 216 ScrapRef scrap;
217 unsigned long timestamp; 217 unsigned long timestamp;
@@ -233,7 +233,7 @@ scrap_has_target_type (scrap, type)
233 ScrapRef scrap; 233 ScrapRef scrap;
234 Lisp_Object type; 234 Lisp_Object type;
235{ 235{
236 OSErr err; 236 OSStatus err;
237 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type); 237 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
238 238
239 if (flavor_type) 239 if (flavor_type)
@@ -264,7 +264,7 @@ get_scrap_string (scrap, type)
264 ScrapRef scrap; 264 ScrapRef scrap;
265 Lisp_Object type; 265 Lisp_Object type;
266{ 266{
267 OSErr err; 267 OSStatus err;
268 Lisp_Object result = Qnil; 268 Lisp_Object result = Qnil;
269 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type); 269 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
270#if TARGET_API_MAC_CARBON 270#if TARGET_API_MAC_CARBON
@@ -310,12 +310,12 @@ get_scrap_string (scrap, type)
310 310
311/* Get timestamp from the scrap SCRAP and set to *TIMPSTAMP. */ 311/* Get timestamp from the scrap SCRAP and set to *TIMPSTAMP. */
312 312
313static OSErr 313static OSStatus
314get_scrap_private_timestamp (scrap, timestamp) 314get_scrap_private_timestamp (scrap, timestamp)
315 ScrapRef scrap; 315 ScrapRef scrap;
316 unsigned long *timestamp; 316 unsigned long *timestamp;
317{ 317{
318 OSErr err = noErr; 318 OSStatus err = noErr;
319#if TARGET_API_MAC_CARBON 319#if TARGET_API_MAC_CARBON
320 ScrapFlavorFlags flags; 320 ScrapFlavorFlags flags;
321 321
@@ -365,7 +365,7 @@ get_scrap_target_type_list (scrap)
365{ 365{
366 Lisp_Object result = Qnil, rest, target_type; 366 Lisp_Object result = Qnil, rest, target_type;
367#if TARGET_API_MAC_CARBON 367#if TARGET_API_MAC_CARBON
368 OSErr err; 368 OSStatus err;
369 UInt32 count, i, type; 369 UInt32 count, i, type;
370 ScrapFlavorInfo *flavor_info = NULL; 370 ScrapFlavorInfo *flavor_info = NULL;
371 Lisp_Object strings = Qnil; 371 Lisp_Object strings = Qnil;
@@ -425,7 +425,7 @@ static void
425x_own_selection (selection_name, selection_value) 425x_own_selection (selection_name, selection_value)
426 Lisp_Object selection_name, selection_value; 426 Lisp_Object selection_name, selection_value;
427{ 427{
428 OSErr err; 428 OSStatus err;
429 ScrapRef scrap; 429 ScrapRef scrap;
430 struct gcpro gcpro1, gcpro2; 430 struct gcpro gcpro1, gcpro2;
431 Lisp_Object rest, handler_fn, value, type; 431 Lisp_Object rest, handler_fn, value, type;
@@ -671,7 +671,7 @@ static Lisp_Object
671x_get_foreign_selection (selection_symbol, target_type, time_stamp) 671x_get_foreign_selection (selection_symbol, target_type, time_stamp)
672 Lisp_Object selection_symbol, target_type, time_stamp; 672 Lisp_Object selection_symbol, target_type, time_stamp;
673{ 673{
674 OSErr err; 674 OSStatus err;
675 ScrapRef scrap; 675 ScrapRef scrap;
676 Lisp_Object result = Qnil; 676 Lisp_Object result = Qnil;
677 677
@@ -765,7 +765,7 @@ Disowning it means there is no such selection. */)
765 Lisp_Object selection; 765 Lisp_Object selection;
766 Lisp_Object time; 766 Lisp_Object time;
767{ 767{
768 OSErr err; 768 OSStatus err;
769 ScrapRef scrap; 769 ScrapRef scrap;
770 Lisp_Object local_selection_data; 770 Lisp_Object local_selection_data;
771 771
@@ -828,7 +828,7 @@ and t is the same as `SECONDARY'. */)
828 (selection) 828 (selection)
829 Lisp_Object selection; 829 Lisp_Object selection;
830{ 830{
831 OSErr err; 831 OSStatus err;
832 ScrapRef scrap; 832 ScrapRef scrap;
833 Lisp_Object result = Qnil, local_selection_data; 833 Lisp_Object result = Qnil, local_selection_data;
834 834
@@ -873,7 +873,7 @@ and t is the same as `SECONDARY'. */)
873 (selection) 873 (selection)
874 Lisp_Object selection; 874 Lisp_Object selection;
875{ 875{
876 OSErr err; 876 OSStatus err;
877 ScrapRef scrap; 877 ScrapRef scrap;
878 Lisp_Object result = Qnil, rest; 878 Lisp_Object result = Qnil, rest;
879 879
@@ -931,7 +931,7 @@ struct suspended_ae_info
931 struct suspended_ae_info *next; 931 struct suspended_ae_info *next;
932}; 932};
933 933
934/* List of deferred apple events at the startup time. */ 934/* List of apple events deferred at the startup time. */
935static struct suspended_ae_info *deferred_apple_events = NULL; 935static struct suspended_ae_info *deferred_apple_events = NULL;
936 936
937/* List of suspended apple events, in order of expiration_tick. */ 937/* List of suspended apple events, in order of expiration_tick. */
diff --git a/src/macterm.c b/src/macterm.c
index c0128b496d3..76efa80d606 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -902,7 +902,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
902#if USE_ATSUI 902#if USE_ATSUI
903 if (GC_FONT (gc)->mac_style) 903 if (GC_FONT (gc)->mac_style)
904 { 904 {
905 OSErr err; 905 OSStatus err;
906 ATSUTextLayout text_layout; 906 ATSUTextLayout text_layout;
907 907
908 xassert (bytes_per_char == 2); 908 xassert (bytes_per_char == 2);
@@ -1129,7 +1129,7 @@ mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width)
1129 the font of the current graphics port. If CG_GLYPH is not NULL, 1129 the font of the current graphics port. If CG_GLYPH is not NULL,
1130 *CG_GLYPH is set to the glyph ID or 0 if it cannot be obtained. */ 1130 *CG_GLYPH is set to the glyph ID or 0 if it cannot be obtained. */
1131 1131
1132static OSErr 1132static OSStatus
1133mac_query_char_extents (style, c, 1133mac_query_char_extents (style, c,
1134 font_ascent_return, font_descent_return, 1134 font_ascent_return, font_descent_return,
1135 overall_return, cg_glyph) 1135 overall_return, cg_glyph)
@@ -1147,7 +1147,7 @@ mac_query_char_extents (style, c,
1147 void *cg_glyph; 1147 void *cg_glyph;
1148#endif 1148#endif
1149{ 1149{
1150 OSErr err = noErr; 1150 OSStatus err = noErr;
1151 int width; 1151 int width;
1152 Rect char_bounds; 1152 Rect char_bounds;
1153 1153
@@ -1193,7 +1193,7 @@ mac_query_char_extents (style, c,
1193#if USE_CG_TEXT_DRAWING 1193#if USE_CG_TEXT_DRAWING
1194 if (err == noErr && cg_glyph) 1194 if (err == noErr && cg_glyph)
1195 { 1195 {
1196 OSErr err1; 1196 OSStatus err1;
1197 ATSUGlyphInfoArray glyph_info_array; 1197 ATSUGlyphInfoArray glyph_info_array;
1198 ByteCount count = sizeof (ATSUGlyphInfoArray); 1198 ByteCount count = sizeof (ATSUGlyphInfoArray);
1199 1199
@@ -3583,7 +3583,9 @@ x_draw_stretch_glyph_string (s)
3583 int background_width = s->background_width; 3583 int background_width = s->background_width;
3584 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); 3584 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
3585 3585
3586 if (x < left_x) 3586 /* Don't draw into left margin, fringe or scrollbar area
3587 except for header line and mode line. */
3588 if (x < left_x && !s->row->mode_line_p)
3587 { 3589 {
3588 background_width -= left_x - x; 3590 background_width -= left_x - x;
3589 x = left_x; 3591 x = left_x;
@@ -3677,14 +3679,14 @@ x_draw_glyph_string (s)
3677 3679
3678 if (s->face->underline_defaulted_p) 3680 if (s->face->underline_defaulted_p)
3679 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3681 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3680 s->width, h); 3682 s->background_width, h);
3681 else 3683 else
3682 { 3684 {
3683 XGCValues xgcv; 3685 XGCValues xgcv;
3684 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3686 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3685 XSetForeground (s->display, s->gc, s->face->underline_color); 3687 XSetForeground (s->display, s->gc, s->face->underline_color);
3686 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3688 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3687 s->width, h); 3689 s->background_width, h);
3688 XSetForeground (s->display, s->gc, xgcv.foreground); 3690 XSetForeground (s->display, s->gc, xgcv.foreground);
3689 } 3691 }
3690 } 3692 }
@@ -3696,14 +3698,14 @@ x_draw_glyph_string (s)
3696 3698
3697 if (s->face->overline_color_defaulted_p) 3699 if (s->face->overline_color_defaulted_p)
3698 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3700 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3699 s->width, h); 3701 s->background_width, h);
3700 else 3702 else
3701 { 3703 {
3702 XGCValues xgcv; 3704 XGCValues xgcv;
3703 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3705 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3704 XSetForeground (s->display, s->gc, s->face->overline_color); 3706 XSetForeground (s->display, s->gc, s->face->overline_color);
3705 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3707 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3706 s->width, h); 3708 s->background_width, h);
3707 XSetForeground (s->display, s->gc, xgcv.foreground); 3709 XSetForeground (s->display, s->gc, xgcv.foreground);
3708 } 3710 }
3709 } 3711 }
@@ -6312,7 +6314,7 @@ void
6312x_iconify_frame (f) 6314x_iconify_frame (f)
6313 struct frame *f; 6315 struct frame *f;
6314{ 6316{
6315 OSErr err; 6317 OSStatus err;
6316 6318
6317 /* A deactivate event does not occur when the last visible frame is 6319 /* A deactivate event does not occur when the last visible frame is
6318 iconified. So if we clear the highlight here, it will not be 6320 iconified. So if we clear the highlight here, it will not be
@@ -6376,11 +6378,6 @@ x_free_frame_resources (f)
6376 if (FRAME_SIZE_HINTS (f)) 6378 if (FRAME_SIZE_HINTS (f))
6377 xfree (FRAME_SIZE_HINTS (f)); 6379 xfree (FRAME_SIZE_HINTS (f));
6378 6380
6379#if TARGET_API_MAC_CARBON
6380 if (FRAME_FILE_NAME (f))
6381 xfree (FRAME_FILE_NAME (f));
6382#endif
6383
6384 xfree (f->output_data.mac); 6381 xfree (f->output_data.mac);
6385 f->output_data.mac = NULL; 6382 f->output_data.mac = NULL;
6386 6383
@@ -7198,7 +7195,7 @@ init_font_name_table ()
7198 if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode), 7195 if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode),
7199 text_encoding_info_alist))) 7196 text_encoding_info_alist)))
7200 { 7197 {
7201 OSErr err; 7198 OSStatus err;
7202 struct Lisp_Hash_Table *h; 7199 struct Lisp_Hash_Table *h;
7203 unsigned hash_code; 7200 unsigned hash_code;
7204 ItemCount nfonts, i; 7201 ItemCount nfonts, i;
@@ -7780,7 +7777,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
7780#if USE_ATSUI 7777#if USE_ATSUI
7781 if (strcmp (charset, "iso10646-1") == 0) /* XXX */ 7778 if (strcmp (charset, "iso10646-1") == 0) /* XXX */
7782 { 7779 {
7783 OSErr err; 7780 OSStatus err;
7784 ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag, 7781 ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag,
7785 kATSUQDBoldfaceTag, kATSUQDItalicTag}; 7782 kATSUQDBoldfaceTag, kATSUQDItalicTag};
7786 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), 7783 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed),
@@ -7863,7 +7860,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
7863#if USE_ATSUI 7860#if USE_ATSUI
7864 if (font->mac_style) 7861 if (font->mac_style)
7865 { 7862 {
7866 OSErr err; 7863 OSStatus err;
7867 UniChar c; 7864 UniChar c;
7868 7865
7869 font->min_byte1 = 0; 7866 font->min_byte1 = 0;
@@ -8342,8 +8339,8 @@ x_query_font (f, fontname)
8342 8339
8343 for (i = 0; i < dpyinfo->n_fonts; i++) 8340 for (i = 0; i < dpyinfo->n_fonts; i++)
8344 if (dpyinfo->font_table[i].name 8341 if (dpyinfo->font_table[i].name
8345 && (!strcmp (dpyinfo->font_table[i].name, fontname) 8342 && (!xstricmp (dpyinfo->font_table[i].name, fontname)
8346 || !strcmp (dpyinfo->font_table[i].full_name, fontname))) 8343 || !xstricmp (dpyinfo->font_table[i].full_name, fontname)))
8347 return (dpyinfo->font_table + i); 8344 return (dpyinfo->font_table + i);
8348 return NULL; 8345 return NULL;
8349} 8346}
@@ -8537,7 +8534,7 @@ Point saved_menu_event_location;
8537 8534
8538/* Apple Events */ 8535/* Apple Events */
8539#if USE_CARBON_EVENTS 8536#if USE_CARBON_EVENTS
8540static Lisp_Object Qhicommand; 8537static Lisp_Object Qhi_command;
8541#ifdef MAC_OSX 8538#ifdef MAC_OSX
8542extern Lisp_Object Qwindow; 8539extern Lisp_Object Qwindow;
8543static Lisp_Object Qtoolbar_switch_mode; 8540static Lisp_Object Qtoolbar_switch_mode;
@@ -8579,7 +8576,7 @@ static Lisp_Object Qservice, Qpaste, Qperform;
8579static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, 8576static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
8580 EventRef, void *); 8577 EventRef, void *);
8581#endif 8578#endif
8582OSErr install_window_handler (WindowPtr); 8579OSStatus install_window_handler (WindowPtr);
8583 8580
8584extern void init_emacs_passwd_dir (); 8581extern void init_emacs_passwd_dir ();
8585extern int emacs_main (int, char **, char **); 8582extern int emacs_main (int, char **, char **);
@@ -9380,15 +9377,15 @@ mac_handle_command_event (next_handler, event, data)
9380 if (err != noErr || command.commandID == 0) 9377 if (err != noErr || command.commandID == 0)
9381 return eventNotHandledErr; 9378 return eventNotHandledErr;
9382 9379
9383 /* A HICommand event is mapped to an Apple event whose event class 9380 /* A HI command event is mapped to an Apple event whose event class
9384 symbol is `hicommand' and event ID is its command ID. */ 9381 symbol is `hi-command' and event ID is its command ID. */
9385 err = mac_store_event_ref_as_apple_event (0, command.commandID, 9382 err = mac_store_event_ref_as_apple_event (0, command.commandID,
9386 Qhicommand, Qnil, 9383 Qhi_command, Qnil,
9387 event, num_params, names, types); 9384 event, num_params, names, types);
9388 return err == noErr ? noErr : eventNotHandledErr; 9385 return err == noErr ? noErr : eventNotHandledErr;
9389} 9386}
9390 9387
9391static OSErr 9388static OSStatus
9392init_command_handler () 9389init_command_handler ()
9393{ 9390{
9394 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; 9391 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}};
@@ -9889,11 +9886,11 @@ mac_store_service_event (event)
9889#endif /* USE_CARBON_EVENTS */ 9886#endif /* USE_CARBON_EVENTS */
9890 9887
9891 9888
9892OSErr 9889OSStatus
9893install_window_handler (window) 9890install_window_handler (window)
9894 WindowPtr window; 9891 WindowPtr window;
9895{ 9892{
9896 OSErr err = noErr; 9893 OSStatus err = noErr;
9897#if USE_CARBON_EVENTS 9894#if USE_CARBON_EVENTS
9898 EventTypeSpec specs_window[] = 9895 EventTypeSpec specs_window[] =
9899 {{kEventClassWindow, kEventWindowUpdate}, 9896 {{kEventClassWindow, kEventWindowUpdate},
@@ -11327,7 +11324,7 @@ static void
11327init_menu_bar () 11324init_menu_bar ()
11328{ 11325{
11329#ifdef MAC_OSX 11326#ifdef MAC_OSX
11330 OSErr err; 11327 OSStatus err;
11331 MenuRef menu; 11328 MenuRef menu;
11332 MenuItemIndex menu_index; 11329 MenuItemIndex menu_index;
11333 11330
@@ -11511,7 +11508,7 @@ syms_of_macterm ()
11511 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); 11508 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
11512 11509
11513#if USE_CARBON_EVENTS 11510#if USE_CARBON_EVENTS
11514 Qhicommand = intern ("hicommand"); staticpro (&Qhicommand); 11511 Qhi_command = intern ("hi-command"); staticpro (&Qhi_command);
11515#ifdef MAC_OSX 11512#ifdef MAC_OSX
11516 Qtoolbar_switch_mode = intern ("toolbar-switch-mode"); 11513 Qtoolbar_switch_mode = intern ("toolbar-switch-mode");
11517 staticpro (&Qtoolbar_switch_mode); 11514 staticpro (&Qtoolbar_switch_mode);
diff --git a/src/macterm.h b/src/macterm.h
index fd71e36d28d..659a13bbb17 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -335,11 +335,6 @@ struct mac_output {
335 /* Hints for the size and the position of a window. */ 335 /* Hints for the size and the position of a window. */
336 XSizeHints *size_hints; 336 XSizeHints *size_hints;
337 337
338#if TARGET_API_MAC_CARBON
339 /* File name for the proxy icon of this frame. Might be NULL. */
340 char *file_name;
341#endif
342
343#if USE_CG_DRAWING 338#if USE_CG_DRAWING
344 /* Quartz 2D graphics context. */ 339 /* Quartz 2D graphics context. */
345 CGContextRef cg_context; 340 CGContextRef cg_context;
@@ -362,8 +357,6 @@ typedef struct mac_output mac_output;
362 357
363#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints) 358#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints)
364 359
365#define FRAME_FILE_NAME(f) ((f)->output_data.mac->file_name)
366
367/* This gives the mac_display_info structure for the display F is on. */ 360/* This gives the mac_display_info structure for the display F is on. */
368#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info) 361#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info)
369#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info) 362#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info)
@@ -631,7 +624,7 @@ extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
631extern int mac_font_panel_visible_p P_ ((void)); 624extern int mac_font_panel_visible_p P_ ((void));
632extern OSStatus mac_show_hide_font_panel P_ ((void)); 625extern OSStatus mac_show_hide_font_panel P_ ((void));
633extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int)); 626extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int));
634extern OSErr install_window_handler P_ ((WindowPtr)); 627extern OSStatus install_window_handler P_ ((WindowPtr));
635extern void remove_window_handler P_ ((WindowPtr)); 628extern void remove_window_handler P_ ((WindowPtr));
636extern void do_menu_choice P_ ((SInt32)); 629extern void do_menu_choice P_ ((SInt32));
637extern OSStatus mac_post_mouse_moved_event P_ ((void)); 630extern OSStatus mac_post_mouse_moved_event P_ ((void));
@@ -672,10 +665,10 @@ extern void mac_clear_font_name_table P_ ((void));
672extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *)); 665extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *));
673extern OSErr mac_ae_put_lisp P_ ((AEDescList *, UInt32, Lisp_Object)); 666extern OSErr mac_ae_put_lisp P_ ((AEDescList *, UInt32, Lisp_Object));
674#if TARGET_API_MAC_CARBON 667#if TARGET_API_MAC_CARBON
675extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32, 668extern OSStatus create_apple_event_from_event_ref P_ ((EventRef, UInt32,
676 EventParamName *, 669 EventParamName *,
677 EventParamType *, 670 EventParamType *,
678 AppleEvent *)); 671 AppleEvent *));
679extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32, 672extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32,
680 FlavorType *, 673 FlavorType *,
681 AppleEvent *)); 674 AppleEvent *));
diff --git a/src/print.c b/src/print.c
index 5f42683753d..d5ff1be6b31 100644
--- a/src/print.c
+++ b/src/print.c
@@ -924,6 +924,15 @@ to make it write to the debugging output. */)
924 return character; 924 return character;
925} 925}
926 926
927/* This function is never called. Its purpose is to prevent
928 print_output_debug_flag from being optimized away. */
929
930void
931debug_output_compilation_hack (x)
932 int x;
933{
934 print_output_debug_flag = x;
935}
927 936
928#if defined(GNU_LINUX) 937#if defined(GNU_LINUX)
929 938
diff --git a/src/process.c b/src/process.c
index 9dadc1ab4ab..f8ae50e8652 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4163,6 +4163,14 @@ server_accept_connection (server, channel)
4163 when not inside wait_reading_process_output. */ 4163 when not inside wait_reading_process_output. */
4164static int waiting_for_user_input_p; 4164static int waiting_for_user_input_p;
4165 4165
4166static Lisp_Object
4167wait_reading_process_output_unwind (data)
4168 Lisp_Object data;
4169{
4170 waiting_for_user_input_p = XINT (data);
4171 return Qnil;
4172}
4173
4166/* This is here so breakpoints can be put on it. */ 4174/* This is here so breakpoints can be put on it. */
4167static void 4175static void
4168wait_reading_process_output_1 () 4176wait_reading_process_output_1 ()
@@ -4245,9 +4253,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4245 EMACS_TIME timeout, end_time; 4253 EMACS_TIME timeout, end_time;
4246 int wait_channel = -1; 4254 int wait_channel = -1;
4247 int got_some_input = 0; 4255 int got_some_input = 0;
4248 /* Either nil or a cons cell, the car of which is of interest and 4256 int count = SPECPDL_INDEX ();
4249 may be changed outside of this routine. */
4250 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4251 4257
4252 FD_ZERO (&Available); 4258 FD_ZERO (&Available);
4253#ifdef NON_BLOCKING_CONNECT 4259#ifdef NON_BLOCKING_CONNECT
@@ -4258,6 +4264,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4258 if (wait_proc != NULL) 4264 if (wait_proc != NULL)
4259 wait_channel = XINT (wait_proc->infd); 4265 wait_channel = XINT (wait_proc->infd);
4260 4266
4267 record_unwind_protect (wait_reading_process_output_unwind,
4268 make_number (waiting_for_user_input_p));
4261 waiting_for_user_input_p = read_kbd; 4269 waiting_for_user_input_p = read_kbd;
4262 4270
4263 /* Since we may need to wait several times, 4271 /* Since we may need to wait several times,
@@ -4884,7 +4892,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4884 } /* end for each file descriptor */ 4892 } /* end for each file descriptor */
4885 } /* end while exit conditions not met */ 4893 } /* end while exit conditions not met */
4886 4894
4887 waiting_for_user_input_p = saved_waiting_for_user_input_p; 4895 unbind_to (count, Qnil);
4888 4896
4889 /* If calling from keyboard input, do not quit 4897 /* If calling from keyboard input, do not quit
4890 since we want to return C-g as an input character. 4898 since we want to return C-g as an input character.
diff --git a/src/puresize.h b/src/puresize.h
index 5d39be5a541..d5a33e3cda5 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -43,7 +43,7 @@ Boston, MA 02110-1301, USA. */
43#endif 43#endif
44 44
45#ifndef BASE_PURESIZE 45#ifndef BASE_PURESIZE
46#define BASE_PURESIZE (1126000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) 46#define BASE_PURESIZE (1130000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA)
47#endif 47#endif
48 48
49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ 49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */
diff --git a/src/w32.c b/src/w32.c
index c093eab599e..0da908ff932 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -323,6 +323,28 @@ w32_strerror (int error_no)
323 return buf; 323 return buf;
324} 324}
325 325
326/* Return 1 if P is a valid pointer to an object of size SIZE. Return
327 0 if P is NOT a valid pointer. Return -1 if we cannot validate P.
328
329 This is called from alloc.c:valid_pointer_p. */
330int
331w32_valid_pointer_p (void *p, int size)
332{
333 SIZE_T done;
334 HANDLE h = OpenProcess (PROCESS_VM_READ, FALSE, GetCurrentProcessId ());
335
336 if (h)
337 {
338 unsigned char *buf = alloca (size);
339 int retval = ReadProcessMemory (h, p, buf, size, &done);
340
341 CloseHandle (h);
342 return retval;
343 }
344 else
345 return -1;
346}
347
326static char startup_dir[MAXPATHLEN]; 348static char startup_dir[MAXPATHLEN];
327 349
328/* Get the current working directory. */ 350/* Get the current working directory. */
diff --git a/src/w32.h b/src/w32.h
index 1d5dbee6d40..6ba25a42403 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -110,6 +110,9 @@ extern void delete_child (child_process *cp);
110/* Equivalent of strerror for W32 error codes. */ 110/* Equivalent of strerror for W32 error codes. */
111extern char * w32_strerror (int error_no); 111extern char * w32_strerror (int error_no);
112 112
113/* Validate a pointer. */
114extern int w32_valid_pointer_p (void *, int);
115
113/* Get long (aka "true") form of file name, if it exists. */ 116/* Get long (aka "true") form of file name, if it exists. */
114extern BOOL w32_get_long_filename (char * name, char * buf, int size); 117extern BOOL w32_get_long_filename (char * name, char * buf, int size);
115 118
diff --git a/src/w32fns.c b/src/w32fns.c
index 68fcced88c2..8c6a60d47bf 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2066,7 +2066,8 @@ w32_createwindow (f)
2066{ 2066{
2067 HWND hwnd; 2067 HWND hwnd;
2068 RECT rect; 2068 RECT rect;
2069 Lisp_Object top, left; 2069 Lisp_Object top = Qunbound;
2070 Lisp_Object left = Qunbound;
2070 2071
2071 rect.left = rect.top = 0; 2072 rect.left = rect.top = 0;
2072 rect.right = FRAME_PIXEL_WIDTH (f); 2073 rect.right = FRAME_PIXEL_WIDTH (f);
@@ -2079,13 +2080,41 @@ w32_createwindow (f)
2079 2080
2080 if (!hprevinst) 2081 if (!hprevinst)
2081 { 2082 {
2083 Lisp_Object ifa;
2084
2082 w32_init_class (hinst); 2085 w32_init_class (hinst);
2086
2087 /* Handle the -geometry command line option and the geometry
2088 settings in the registry. They are decoded and put into
2089 initial-frame-alist by w32-win.el:x-handle-geometry. */
2090 ifa = Fsymbol_value (intern ("initial-frame-alist"));
2091 if (CONSP (ifa))
2092 {
2093 Lisp_Object lt = Fassq (Qleft, ifa);
2094 Lisp_Object tp = Fassq (Qtop, ifa);
2095
2096 if (!NILP (lt))
2097 {
2098 lt = XCDR (lt);
2099 if (INTEGERP (lt))
2100 left = lt;
2101 }
2102 if (!NILP (tp))
2103 {
2104 tp = XCDR (tp);
2105 if (INTEGERP (tp))
2106 top = tp;
2107 }
2108 }
2083 } 2109 }
2084 2110
2085 /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero 2111 if (EQ (left, Qunbound) && EQ (top, Qunbound))
2086 for anything that is not a number and is not Qunbound. */ 2112 {
2087 left = w32_get_arg (Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER); 2113 /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero
2088 top = w32_get_arg (Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER); 2114 for anything that is not a number and is not Qunbound. */
2115 left = w32_get_arg (Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
2116 top = w32_get_arg (Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
2117 }
2089 2118
2090 FRAME_W32_WINDOW (f) = hwnd 2119 FRAME_W32_WINDOW (f) = hwnd
2091 = CreateWindow (EMACS_CLASS, 2120 = CreateWindow (EMACS_CLASS,
@@ -6207,7 +6236,7 @@ w32_query_font (struct frame *f, char *fontname)
6207 6236
6208 for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++) 6237 for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++)
6209 { 6238 {
6210 if (strcmp(pfi->name, fontname) == 0) return pfi; 6239 if (stricmp(pfi->name, fontname) == 0) return pfi;
6211 } 6240 }
6212 6241
6213 return NULL; 6242 return NULL;
@@ -6326,17 +6355,12 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
6326 CHECK_STRING (color); 6355 CHECK_STRING (color);
6327 6356
6328 if (w32_defined_color (f, SDATA (color), &foo, 0)) 6357 if (w32_defined_color (f, SDATA (color), &foo, 0))
6329 { 6358 return list3 (make_number ((GetRValue (foo.pixel) << 8)
6330 Lisp_Object rgb[3]; 6359 | GetRValue (foo.pixel)),
6331 6360 make_number ((GetGValue (foo.pixel) << 8)
6332 rgb[0] = make_number ((GetRValue (foo.pixel) << 8) 6361 | GetGValue (foo.pixel)),
6333 | GetRValue (foo.pixel)); 6362 make_number ((GetBValue (foo.pixel) << 8)
6334 rgb[1] = make_number ((GetGValue (foo.pixel) << 8) 6363 | GetBValue (foo.pixel)));
6335 | GetGValue (foo.pixel));
6336 rgb[2] = make_number ((GetBValue (foo.pixel) << 8)
6337 | GetBValue (foo.pixel));
6338 return Flist (3, rgb);
6339 }
6340 else 6364 else
6341 return Qnil; 6365 return Qnil;
6342} 6366}
diff --git a/src/w32menu.c b/src/w32menu.c
index 389e6c5b856..11af1d66b6f 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1994,6 +1994,9 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error)
1994 } 1994 }
1995 } 1995 }
1996 } 1996 }
1997 else if (!for_click)
1998 /* Make "Cancel" equivalent to C-g. */
1999 Fsignal (Qquit, Qnil);
1997 2000
1998 return Qnil; 2001 return Qnil;
1999} 2002}
@@ -2186,6 +2189,9 @@ w32_dialog_show (f, keymaps, title, header, error)
2186 } 2189 }
2187 } 2190 }
2188 } 2191 }
2192 else
2193 /* Make "Cancel" equivalent to C-g. */
2194 Fsignal (Qquit, Qnil);
2189 2195
2190 return Qnil; 2196 return Qnil;
2191} 2197}
diff --git a/src/w32term.c b/src/w32term.c
index b564ed3bd2b..2870955b94f 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -91,6 +91,10 @@ static Lisp_Object last_window;
91 (Not yet supported, see TODO in x_draw_glyph_string.) */ 91 (Not yet supported, see TODO in x_draw_glyph_string.) */
92int x_use_underline_position_properties; 92int x_use_underline_position_properties;
93 93
94/* Non-zero means to draw the underline at the same place as the descent line. */
95
96int x_underline_at_descent_line;
97
94extern unsigned int msh_mousewheel; 98extern unsigned int msh_mousewheel;
95 99
96extern void free_frame_menubar (); 100extern void free_frame_menubar ();
@@ -2418,7 +2422,9 @@ x_draw_stretch_glyph_string (s)
2418 int background_width = s->background_width; 2422 int background_width = s->background_width;
2419 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); 2423 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
2420 2424
2421 if (x < left_x) 2425 /* Don't draw into left margin, fringe or scrollbar area
2426 except for header line and mode line. */
2427 if (x < left_x && !s->row->mode_line_p)
2422 { 2428 {
2423 background_width -= left_x - x; 2429 background_width -= left_x - x;
2424 x = left_x; 2430 x = left_x;
@@ -2507,21 +2513,27 @@ x_draw_glyph_string (s)
2507 && (s->font->bdf || !s->font->tm.tmUnderlined)) 2513 && (s->font->bdf || !s->font->tm.tmUnderlined))
2508 { 2514 {
2509 unsigned long h = 1; 2515 unsigned long h = 1;
2510 unsigned long dy = s->height - h; 2516 unsigned long dy = 0;
2511 2517
2512 /* TODO: Use font information for positioning and thickness 2518 if (x_underline_at_descent_line)
2513 of underline. See OUTLINETEXTMETRIC, and xterm.c. 2519 dy = s->height - h;
2514 Note: If you make this work, don't forget to change the 2520 else
2515 doc string of x-use-underline-position-properties below. */ 2521 {
2522 /* TODO: Use font information for positioning and thickness of
2523 underline. See OUTLINETEXTMETRIC, and xterm.c. Note: If
2524 you make this work, don't forget to change the doc string of
2525 x-use-underline-position-properties below. */
2526 dy = s->height - h;
2527 }
2516 if (s->face->underline_defaulted_p) 2528 if (s->face->underline_defaulted_p)
2517 { 2529 {
2518 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, 2530 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x,
2519 s->y + dy, s->width, 1); 2531 s->y + dy, s->background_width, 1);
2520 } 2532 }
2521 else 2533 else
2522 { 2534 {
2523 w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, 2535 w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x,
2524 s->y + dy, s->width, 1); 2536 s->y + dy, s->background_width, 1);
2525 } 2537 }
2526 } 2538 }
2527 2539
@@ -2533,12 +2545,12 @@ x_draw_glyph_string (s)
2533 if (s->face->overline_color_defaulted_p) 2545 if (s->face->overline_color_defaulted_p)
2534 { 2546 {
2535 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, 2547 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x,
2536 s->y + dy, s->width, h); 2548 s->y + dy, s->background_width, h);
2537 } 2549 }
2538 else 2550 else
2539 { 2551 {
2540 w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x, 2552 w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x,
2541 s->y + dy, s->width, h); 2553 s->y + dy, s->background_width, h);
2542 } 2554 }
2543 } 2555 }
2544 2556
@@ -6509,6 +6521,14 @@ to 4.1, set this to nil.
6509NOTE: Not supported on MS-Windows yet. */); 6521NOTE: Not supported on MS-Windows yet. */);
6510 x_use_underline_position_properties = 0; 6522 x_use_underline_position_properties = 0;
6511 6523
6524 DEFVAR_BOOL ("x-underline-at-descent-line",
6525 &x_underline_at_descent_line,
6526 doc: /* *Non-nil means to draw the underline at the same place as the descent line.
6527nil means to draw the underline according to the value of the variable
6528`x-use-underline-position-properties', which is usually at the baseline
6529level. The default value is nil. */);
6530 x_underline_at_descent_line = 0;
6531
6512 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 6532 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
6513 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 6533 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
6514 Vx_toolkit_scroll_bars = Qt; 6534 Vx_toolkit_scroll_bars = Qt;
diff --git a/src/window.c b/src/window.c
index 879777d25e1..a3e7b93e878 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6658,10 +6658,12 @@ display marginal areas and the text area. */)
6658 CHECK_NATNUM (left_width); 6658 CHECK_NATNUM (left_width);
6659 if (!NILP (right_width)) 6659 if (!NILP (right_width))
6660 CHECK_NATNUM (right_width); 6660 CHECK_NATNUM (right_width);
6661 6661
6662 if (!EQ (w->left_fringe_width, left_width) 6662 /* Do nothing on a tty. */
6663 || !EQ (w->right_fringe_width, right_width) 6663 if (FRAME_WINDOW_P (WINDOW_XFRAME (w))
6664 || !EQ (w->fringes_outside_margins, outside_margins)) 6664 && (!EQ (w->left_fringe_width, left_width)
6665 || !EQ (w->right_fringe_width, right_width)
6666 || !EQ (w->fringes_outside_margins, outside_margins)))
6665 { 6667 {
6666 w->left_fringe_width = left_width; 6668 w->left_fringe_width = left_width;
6667 w->right_fringe_width = right_width; 6669 w->right_fringe_width = right_width;
@@ -6689,10 +6691,11 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6689 Lisp_Object window; 6691 Lisp_Object window;
6690{ 6692{
6691 struct window *w = decode_window (window); 6693 struct window *w = decode_window (window);
6694
6692 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)), 6695 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)),
6693 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)), 6696 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)),
6694 Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) ? 6697 Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
6695 Qt : Qnil), Qnil))); 6698 ? Qt : Qnil), Qnil)));
6696} 6699}
6697 6700
6698 6701
diff --git a/src/xdisp.c b/src/xdisp.c
index 76ab430386c..7e65b91fd13 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -701,6 +701,10 @@ Lisp_Object Vresize_mini_windows;
701 701
702struct buffer *displayed_buffer; 702struct buffer *displayed_buffer;
703 703
704/* Space between overline and text. */
705
706EMACS_INT overline_margin;
707
704/* Value returned from text property handlers (see below). */ 708/* Value returned from text property handlers (see below). */
705 709
706enum prop_handled 710enum prop_handled
@@ -887,7 +891,7 @@ static void redisplay_window P_ ((Lisp_Object, int));
887static Lisp_Object redisplay_window_error (); 891static Lisp_Object redisplay_window_error ();
888static Lisp_Object redisplay_window_0 P_ ((Lisp_Object)); 892static Lisp_Object redisplay_window_0 P_ ((Lisp_Object));
889static Lisp_Object redisplay_window_1 P_ ((Lisp_Object)); 893static Lisp_Object redisplay_window_1 P_ ((Lisp_Object));
890static void update_menu_bar P_ ((struct frame *, int)); 894static int update_menu_bar P_ ((struct frame *, int, int));
891static int try_window_reusing_current_matrix P_ ((struct window *)); 895static int try_window_reusing_current_matrix P_ ((struct window *));
892static int try_window_id P_ ((struct window *)); 896static int try_window_id P_ ((struct window *));
893static int display_line P_ ((struct it *)); 897static int display_line P_ ((struct it *));
@@ -9038,6 +9042,9 @@ prepare_menu_bars ()
9038 { 9042 {
9039 Lisp_Object tail, frame; 9043 Lisp_Object tail, frame;
9040 int count = SPECPDL_INDEX (); 9044 int count = SPECPDL_INDEX ();
9045 /* 1 means that update_menu_bar has run its hooks
9046 so any further calls to update_menu_bar shouldn't do so again. */
9047 int menu_bar_hooks_run = 0;
9041 9048
9042 record_unwind_save_match_data (); 9049 record_unwind_save_match_data ();
9043 9050
@@ -9069,7 +9076,7 @@ prepare_menu_bars ()
9069 } 9076 }
9070 9077
9071 GCPRO1 (tail); 9078 GCPRO1 (tail);
9072 update_menu_bar (f, 0); 9079 menu_bar_hooks_run = update_menu_bar (f, 0, menu_bar_hooks_run);
9073#ifdef HAVE_WINDOW_SYSTEM 9080#ifdef HAVE_WINDOW_SYSTEM
9074 update_tool_bar (f, 0); 9081 update_tool_bar (f, 0);
9075#ifdef MAC_OS 9082#ifdef MAC_OS
@@ -9084,7 +9091,7 @@ prepare_menu_bars ()
9084 else 9091 else
9085 { 9092 {
9086 struct frame *sf = SELECTED_FRAME (); 9093 struct frame *sf = SELECTED_FRAME ();
9087 update_menu_bar (sf, 1); 9094 update_menu_bar (sf, 1, 0);
9088#ifdef HAVE_WINDOW_SYSTEM 9095#ifdef HAVE_WINDOW_SYSTEM
9089 update_tool_bar (sf, 1); 9096 update_tool_bar (sf, 1);
9090#ifdef MAC_OS 9097#ifdef MAC_OS
@@ -9105,12 +9112,18 @@ prepare_menu_bars ()
9105 before we start to fill in any display lines, because it can call 9112 before we start to fill in any display lines, because it can call
9106 eval. 9113 eval.
9107 9114
9108 If SAVE_MATCH_DATA is non-zero, we must save and restore it here. */ 9115 If SAVE_MATCH_DATA is non-zero, we must save and restore it here.
9109 9116
9110static void 9117 If HOOKS_RUN is 1, that means a previous call to update_menu_bar
9111update_menu_bar (f, save_match_data) 9118 already ran the menu bar hooks for this redisplay, so there
9119 is no need to run them again. The return value is the
9120 updated value of this flag, to pass to the next call. */
9121
9122static int
9123update_menu_bar (f, save_match_data, hooks_run)
9112 struct frame *f; 9124 struct frame *f;
9113 int save_match_data; 9125 int save_match_data;
9126 int hooks_run;
9114{ 9127{
9115 Lisp_Object window; 9128 Lisp_Object window;
9116 register struct window *w; 9129 register struct window *w;
@@ -9175,15 +9188,21 @@ update_menu_bar (f, save_match_data)
9175 specbind (Qoverriding_local_map, Qnil); 9188 specbind (Qoverriding_local_map, Qnil);
9176 } 9189 }
9177 9190
9178 /* Run the Lucid hook. */ 9191 if (!hooks_run)
9179 safe_run_hooks (Qactivate_menubar_hook); 9192 {
9193 /* Run the Lucid hook. */
9194 safe_run_hooks (Qactivate_menubar_hook);
9180 9195
9181 /* If it has changed current-menubar from previous value, 9196 /* If it has changed current-menubar from previous value,
9182 really recompute the menu-bar from the value. */ 9197 really recompute the menu-bar from the value. */
9183 if (! NILP (Vlucid_menu_bar_dirty_flag)) 9198 if (! NILP (Vlucid_menu_bar_dirty_flag))
9184 call0 (Qrecompute_lucid_menubar); 9199 call0 (Qrecompute_lucid_menubar);
9200
9201 safe_run_hooks (Qmenu_bar_update_hook);
9202
9203 hooks_run = 1;
9204 }
9185 9205
9186 safe_run_hooks (Qmenu_bar_update_hook);
9187 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); 9206 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
9188 9207
9189 /* Redisplay the menu bar in case we changed it. */ 9208 /* Redisplay the menu bar in case we changed it. */
@@ -9212,6 +9231,8 @@ update_menu_bar (f, save_match_data)
9212 set_buffer_internal_1 (prev); 9231 set_buffer_internal_1 (prev);
9213 } 9232 }
9214 } 9233 }
9234
9235 return hooks_run;
9215} 9236}
9216 9237
9217 9238
@@ -9376,7 +9397,8 @@ update_tool_bar (f, save_match_data)
9376 &new_n_tool_bar); 9397 &new_n_tool_bar);
9377 9398
9378 /* Redisplay the tool-bar if we changed it. */ 9399 /* Redisplay the tool-bar if we changed it. */
9379 if (NILP (Fequal (new_tool_bar, f->tool_bar_items))) 9400 if (new_n_tool_bar != f->n_tool_bar_items
9401 || NILP (Fequal (new_tool_bar, f->tool_bar_items)))
9380 { 9402 {
9381 /* Redisplay that happens asynchronously due to an expose event 9403 /* Redisplay that happens asynchronously due to an expose event
9382 may access f->tool_bar_items. Make sure we update both 9404 may access f->tool_bar_items. Make sure we update both
@@ -20354,7 +20376,7 @@ x_produce_glyphs (it)
20354 /* If face has an overline, add the height of the overline 20376 /* If face has an overline, add the height of the overline
20355 (1 pixel) and a 1 pixel margin to the character height. */ 20377 (1 pixel) and a 1 pixel margin to the character height. */
20356 if (face->overline_p) 20378 if (face->overline_p)
20357 it->ascent += 2; 20379 it->ascent += overline_margin;
20358 20380
20359 if (it->constrain_row_ascent_descent_p) 20381 if (it->constrain_row_ascent_descent_p)
20360 { 20382 {
@@ -20556,7 +20578,7 @@ x_produce_glyphs (it)
20556 /* If face has an overline, add the height of the overline 20578 /* If face has an overline, add the height of the overline
20557 (1 pixel) and a 1 pixel margin to the character height. */ 20579 (1 pixel) and a 1 pixel margin to the character height. */
20558 if (face->overline_p) 20580 if (face->overline_p)
20559 it->ascent += 2; 20581 it->ascent += overline_margin;
20560 20582
20561 take_vertical_position_into_account (it); 20583 take_vertical_position_into_account (it);
20562 20584
@@ -20831,7 +20853,7 @@ x_produce_glyphs (it)
20831 /* If face has an overline, add the height of the overline 20853 /* If face has an overline, add the height of the overline
20832 (1 pixel) and a 1 pixel margin to the character height. */ 20854 (1 pixel) and a 1 pixel margin to the character height. */
20833 if (face->overline_p) 20855 if (face->overline_p)
20834 it->ascent += 2; 20856 it->ascent += overline_margin;
20835 20857
20836 take_vertical_position_into_account (it); 20858 take_vertical_position_into_account (it);
20837 20859
@@ -24108,6 +24130,12 @@ whose contents depend on various data. */);
24108 doc: /* Inhibit try_cursor_movement display optimization. */); 24130 doc: /* Inhibit try_cursor_movement display optimization. */);
24109 inhibit_try_cursor_movement = 0; 24131 inhibit_try_cursor_movement = 0;
24110#endif /* GLYPH_DEBUG */ 24132#endif /* GLYPH_DEBUG */
24133
24134 DEFVAR_INT ("overline-margin", &overline_margin,
24135 doc: /* *Space between overline and text, in pixels.
24136The default value is 2: the height of the overline (1 pixel) plus 1 pixel
24137margin to the caracter height. */);
24138 overline_margin = 2;
24111} 24139}
24112 24140
24113 24141
diff --git a/src/xfaces.c b/src/xfaces.c
index 18e5d9a6119..6373100484a 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1192,7 +1192,7 @@ load_pixmap (f, name, w_ptr, h_ptr)
1192 1192
1193 if (bitmap_id < 0) 1193 if (bitmap_id < 0)
1194 { 1194 {
1195 add_to_log ("Invalid or undefined bitmap %s", name, Qnil); 1195 add_to_log ("Invalid or undefined bitmap `%s'", name, Qnil);
1196 bitmap_id = 0; 1196 bitmap_id = 0;
1197 1197
1198 if (w_ptr) 1198 if (w_ptr)
@@ -5734,6 +5734,8 @@ lookup_named_face (f, symbol, c, signal_p)
5734 if (!realize_basic_faces (f)) 5734 if (!realize_basic_faces (f))
5735 return -1; 5735 return -1;
5736 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 5736 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
5737 if (default_face == NULL)
5738 abort (); /* realize_basic_faces must have set it up */
5737 } 5739 }
5738 5740
5739 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p)) 5741 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p))
@@ -6238,6 +6240,8 @@ face for italic. */)
6238 if (! realize_basic_faces (f)) 6240 if (! realize_basic_faces (f))
6239 error ("Cannot realize default face"); 6241 error ("Cannot realize default face");
6240 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 6242 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6243 if (def_face == NULL)
6244 abort (); /* realize_basic_faces must have set it up */
6241 } 6245 }
6242 6246
6243 /* Dispatch to the appropriate handler. */ 6247 /* Dispatch to the appropriate handler. */
diff --git a/src/xfns.c b/src/xfns.c
index 3cadc8504f4..d5b8a01cf20 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3495,14 +3495,9 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
3495 CHECK_STRING (color); 3495 CHECK_STRING (color);
3496 3496
3497 if (x_defined_color (f, SDATA (color), &foo, 0)) 3497 if (x_defined_color (f, SDATA (color), &foo, 0))
3498 { 3498 return list3 (make_number (foo.red),
3499 Lisp_Object rgb[3]; 3499 make_number (foo.green),
3500 3500 make_number (foo.blue));
3501 rgb[0] = make_number (foo.red);
3502 rgb[1] = make_number (foo.green);
3503 rgb[2] = make_number (foo.blue);
3504 return Flist (3, rgb);
3505 }
3506 else 3501 else
3507 return Qnil; 3502 return Qnil;
3508} 3503}
diff --git a/src/xselect.c b/src/xselect.c
index 211d207bac4..cd49e05171b 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2709,8 +2709,48 @@ If the value is 0 or the atom is not known, return the empty string. */)
2709 return ret; 2709 return ret;
2710} 2710}
2711 2711
2712/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. 2712DEFUN ("x-register-dnd-atom", Fx_register_dnd_atom,
2713 TODO: Check if this client event really is a DND event? */ 2713 Sx_register_dnd_atom, 1, 2, 0,
2714 doc: /* Request that dnd events are made for ClientMessages with ATOM.
2715ATOM can be a symbol or a string. The ATOM is interned on the display that
2716FRAME is on. If FRAME is nil, the selected frame is used. */)
2717 (atom, frame)
2718 Lisp_Object atom, frame;
2719{
2720 Atom x_atom;
2721 struct frame *f = check_x_frame (frame);
2722 size_t i;
2723 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2724
2725
2726 if (SYMBOLP (atom))
2727 x_atom = symbol_to_x_atom (dpyinfo, FRAME_X_DISPLAY (f), atom);
2728 else if (STRINGP (atom))
2729 {
2730 BLOCK_INPUT;
2731 x_atom = XInternAtom (FRAME_X_DISPLAY (f), (char *) SDATA (atom), False);
2732 UNBLOCK_INPUT;
2733 }
2734 else
2735 error ("ATOM must be a symbol or a string");
2736
2737 for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i)
2738 if (dpyinfo->x_dnd_atoms[i] == x_atom)
2739 return Qnil;
2740
2741 if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size)
2742 {
2743 dpyinfo->x_dnd_atoms_size *= 2;
2744 dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms,
2745 sizeof (*dpyinfo->x_dnd_atoms)
2746 * dpyinfo->x_dnd_atoms_size);
2747 }
2748
2749 dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom;
2750 return Qnil;
2751}
2752
2753/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */
2714 2754
2715int 2755int
2716x_handle_dnd_message (f, event, dpyinfo, bufp) 2756x_handle_dnd_message (f, event, dpyinfo, bufp)
@@ -2726,6 +2766,12 @@ x_handle_dnd_message (f, event, dpyinfo, bufp)
2726 int x, y; 2766 int x, y;
2727 unsigned char *data = (unsigned char *) event->data.b; 2767 unsigned char *data = (unsigned char *) event->data.b;
2728 int idata[5]; 2768 int idata[5];
2769 size_t i;
2770
2771 for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i)
2772 if (dpyinfo->x_dnd_atoms[i] == event->message_type) break;
2773
2774 if (i == dpyinfo->x_dnd_atoms_length) return 0;
2729 2775
2730 XSETFRAME (frame, f); 2776 XSETFRAME (frame, f);
2731 2777
@@ -2899,6 +2945,7 @@ syms_of_xselect ()
2899 2945
2900 defsubr (&Sx_get_atom_name); 2946 defsubr (&Sx_get_atom_name);
2901 defsubr (&Sx_send_client_message); 2947 defsubr (&Sx_send_client_message);
2948 defsubr (&Sx_register_dnd_atom);
2902 2949
2903 reading_selection_reply = Fcons (Qnil, Qnil); 2950 reading_selection_reply = Fcons (Qnil, Qnil);
2904 staticpro (&reading_selection_reply); 2951 staticpro (&reading_selection_reply);
diff --git a/src/xterm.c b/src/xterm.c
index 5df7896a2b3..466037c75a2 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -181,6 +181,10 @@ static Lisp_Object last_window;
181 181
182int x_use_underline_position_properties; 182int x_use_underline_position_properties;
183 183
184/* Non-zero means to draw the underline at the same place as the descent line. */
185
186int x_underline_at_descent_line;
187
184/* This is a chain of structures for all the X displays currently in 188/* This is a chain of structures for all the X displays currently in
185 use. */ 189 use. */
186 190
@@ -2601,7 +2605,9 @@ x_draw_stretch_glyph_string (s)
2601 int background_width = s->background_width; 2605 int background_width = s->background_width;
2602 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); 2606 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
2603 2607
2604 if (x < left_x) 2608 /* Don't draw into left margin, fringe or scrollbar area
2609 except for header line and mode line. */
2610 if (x < left_x && !s->row->mode_line_p)
2605 { 2611 {
2606 background_width -= left_x - x; 2612 background_width -= left_x - x;
2607 x = left_x; 2613 x = left_x;
@@ -2695,32 +2701,35 @@ x_draw_glyph_string (s)
2695 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h)) 2701 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
2696 h = 1; 2702 h = 1;
2697 2703
2698 /* Get the underline position. This is the recommended 2704 if (x_underline_at_descent_line)
2699 vertical offset in pixels from the baseline to the top of
2700 the underline. This is a signed value according to the
2701 specs, and its default is
2702
2703 ROUND ((maximum descent) / 2), with
2704 ROUND(x) = floor (x + 0.5) */
2705
2706 if (x_use_underline_position_properties
2707 && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
2708 y = s->ybase + (long) tem;
2709 else if (s->face->font)
2710 y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
2711 else
2712 y = s->y + s->height - h; 2705 y = s->y + s->height - h;
2706 else
2707 {
2708 /* Get the underline position. This is the recommended
2709 vertical offset in pixels from the baseline to the top of
2710 the underline. This is a signed value according to the
2711 specs, and its default is
2712
2713 ROUND ((maximum descent) / 2), with
2714 ROUND(x) = floor (x + 0.5) */
2715
2716 if (x_use_underline_position_properties
2717 && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
2718 y = s->ybase + (long) tem;
2719 else if (s->face->font)
2720 y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
2721 }
2713 2722
2714 if (s->face->underline_defaulted_p) 2723 if (s->face->underline_defaulted_p)
2715 XFillRectangle (s->display, s->window, s->gc, 2724 XFillRectangle (s->display, s->window, s->gc,
2716 s->x, y, s->width, h); 2725 s->x, y, s->background_width, h);
2717 else 2726 else
2718 { 2727 {
2719 XGCValues xgcv; 2728 XGCValues xgcv;
2720 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 2729 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2721 XSetForeground (s->display, s->gc, s->face->underline_color); 2730 XSetForeground (s->display, s->gc, s->face->underline_color);
2722 XFillRectangle (s->display, s->window, s->gc, 2731 XFillRectangle (s->display, s->window, s->gc,
2723 s->x, y, s->width, h); 2732 s->x, y, s->background_width, h);
2724 XSetForeground (s->display, s->gc, xgcv.foreground); 2733 XSetForeground (s->display, s->gc, xgcv.foreground);
2725 } 2734 }
2726 } 2735 }
@@ -2732,14 +2741,14 @@ x_draw_glyph_string (s)
2732 2741
2733 if (s->face->overline_color_defaulted_p) 2742 if (s->face->overline_color_defaulted_p)
2734 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 2743 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
2735 s->width, h); 2744 s->background_width, h);
2736 else 2745 else
2737 { 2746 {
2738 XGCValues xgcv; 2747 XGCValues xgcv;
2739 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 2748 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2740 XSetForeground (s->display, s->gc, s->face->overline_color); 2749 XSetForeground (s->display, s->gc, s->face->overline_color);
2741 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 2750 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
2742 s->width, h); 2751 s->background_width, h);
2743 XSetForeground (s->display, s->gc, xgcv.foreground); 2752 XSetForeground (s->display, s->gc, xgcv.foreground);
2744 } 2753 }
2745 } 2754 }
@@ -10096,8 +10105,8 @@ x_query_font (f, fontname)
10096 10105
10097 for (i = 0; i < dpyinfo->n_fonts; i++) 10106 for (i = 0; i < dpyinfo->n_fonts; i++)
10098 if (dpyinfo->font_table[i].name 10107 if (dpyinfo->font_table[i].name
10099 && (!strcmp (dpyinfo->font_table[i].name, fontname) 10108 && (!strcasecmp (dpyinfo->font_table[i].name, fontname)
10100 || !strcmp (dpyinfo->font_table[i].full_name, fontname))) 10109 || !strcasecmp (dpyinfo->font_table[i].full_name, fontname)))
10101 return (dpyinfo->font_table + i); 10110 return (dpyinfo->font_table + i);
10102 return NULL; 10111 return NULL;
10103} 10112}
@@ -10644,6 +10653,11 @@ x_term_init (display_name, xrm_option, resource_name)
10644 10653
10645 dpyinfo->cut_buffers_initialized = 0; 10654 dpyinfo->cut_buffers_initialized = 0;
10646 10655
10656 dpyinfo->x_dnd_atoms_size = 8;
10657 dpyinfo->x_dnd_atoms_length = 0;
10658 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms)
10659 * dpyinfo->x_dnd_atoms_size);
10660
10647 connection = ConnectionNumber (dpyinfo->display); 10661 connection = ConnectionNumber (dpyinfo->display);
10648 dpyinfo->connection = connection; 10662 dpyinfo->connection = connection;
10649 10663
@@ -11104,6 +11118,14 @@ UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
11104to 4.1, set this to nil. */); 11118to 4.1, set this to nil. */);
11105 x_use_underline_position_properties = 1; 11119 x_use_underline_position_properties = 1;
11106 11120
11121 DEFVAR_BOOL ("x-underline-at-descent-line",
11122 &x_underline_at_descent_line,
11123 doc: /* *Non-nil means to draw the underline at the same place as the descent line.
11124nil means to draw the underline according to the value of the variable
11125`x-use-underline-position-properties', which is usually at the baseline
11126level. The default value is nil. */);
11127 x_underline_at_descent_line = 0;
11128
11107 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position", 11129 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
11108 &x_mouse_click_focus_ignore_position, 11130 &x_mouse_click_focus_ignore_position,
11109 doc: /* Non-nil means that a mouse click to focus a frame does not move point. 11131 doc: /* Non-nil means that a mouse click to focus a frame does not move point.
diff --git a/src/xterm.h b/src/xterm.h
index 6bbcdc6389d..8f7055d95d5 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -389,6 +389,12 @@ struct x_display_info
389 X_WMTYPE_A, 389 X_WMTYPE_A,
390 X_WMTYPE_B 390 X_WMTYPE_B
391 } wm_type; 391 } wm_type;
392
393
394 /* Atoms that are drag and drop atoms */
395 Atom *x_dnd_atoms;
396 size_t x_dnd_atoms_size;
397 size_t x_dnd_atoms_length;
392}; 398};
393 399
394#ifdef HAVE_X_I18N 400#ifdef HAVE_X_I18N