aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2004-06-28 07:56:49 +0000
committerMiles Bader2004-06-28 07:56:49 +0000
commit327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801 (patch)
tree21de188e13b5e41a79bb50040933072ae0235217 /src
parent852f73b7fa7b71910282eacb6263b3ecfd4ee783 (diff)
parent376de73927383d6062483db10b8a82448505f52b (diff)
downloademacs-327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801.tar.gz
emacs-327719ee8a3fcdb36ed6acaf6d8cb5fbdf0bd801.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/.arch-inventory9
-rw-r--r--src/.gdbinit22
-rw-r--r--src/ChangeLog1257
-rw-r--r--src/abbrev.c2
-rw-r--r--src/alloc.c132
-rw-r--r--src/atimer.c2
-rw-r--r--src/atimer.h2
-rw-r--r--src/blockinput.h5
-rw-r--r--src/buffer.c45
-rw-r--r--src/buffer.h21
-rw-r--r--src/callint.c4
-rw-r--r--src/callproc.c4
-rw-r--r--src/casefiddle.c13
-rw-r--r--src/ccl.c37
-rw-r--r--src/charset.c8
-rw-r--r--src/data.c42
-rw-r--r--src/dispextern.h61
-rw-r--r--src/dispnew.c24
-rw-r--r--src/doc.c2
-rw-r--r--src/editfns.c41
-rw-r--r--src/emacs.c10
-rw-r--r--src/eval.c26
-rw-r--r--src/fileio.c92
-rw-r--r--src/fns.c74
-rw-r--r--src/fontset.c64
-rw-r--r--src/gtkutil.c188
-rw-r--r--src/image.c790
-rw-r--r--src/indent.c3
-rw-r--r--src/insdel.c4
-rw-r--r--src/intervals.c12
-rw-r--r--src/keyboard.c133
-rw-r--r--src/keymap.c233
-rw-r--r--src/keymap.h5
-rw-r--r--src/lisp.h92
-rw-r--r--src/lread.c21
-rw-r--r--src/macfns.c401
-rw-r--r--src/macgui.h15
-rw-r--r--src/macmenu.c21
-rw-r--r--src/macterm.c1542
-rw-r--r--src/macterm.h14
-rw-r--r--src/makefile.nt1232
-rw-r--r--src/makefile.w32-in74
-rw-r--r--src/mem-limits.h6
-rw-r--r--src/minibuf.c91
-rw-r--r--src/msdos.c55
-rw-r--r--src/print.c68
-rw-r--r--src/process.c108
-rw-r--r--src/regex.c170
-rw-r--r--src/regex.h43
-rw-r--r--src/search.c10
-rw-r--r--src/syntax.c196
-rw-r--r--src/syntax.h24
-rw-r--r--src/syssignal.h3
-rw-r--r--src/textprop.c23
-rw-r--r--src/undo.c22
-rw-r--r--src/w32.c14
-rw-r--r--src/w32console.c130
-rw-r--r--src/w32fns.c267
-rw-r--r--src/w32heap.c3
-rw-r--r--src/w32inevt.c12
-rw-r--r--src/w32menu.c14
-rw-r--r--src/w32proc.c10
-rw-r--r--src/w32select.c11
-rw-r--r--src/w32term.c198
-rw-r--r--src/w32term.h7
-rw-r--r--src/window.c126
-rw-r--r--src/window.h8
-rw-r--r--src/xdisp.c512
-rw-r--r--src/xfaces.c969
-rw-r--r--src/xfns.c7
-rw-r--r--src/xselect.c4
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c163
-rw-r--r--src/xterm.h5
74 files changed, 6044 insertions, 4016 deletions
diff --git a/src/.arch-inventory b/src/.arch-inventory
new file mode 100644
index 00000000000..a98d4c9932f
--- /dev/null
+++ b/src/.arch-inventory
@@ -0,0 +1,9 @@
1# Source files which don't match the usual naming conventions, mostly dot files
2source ^\.(gdbinit|dbxinit)$
3
4# Auto-generated files, which ignore
5precious ^(config\.stamp|config\.h|epaths\.h)$
6
7backup ^(stamp-oldxmenu|prefix-args|temacs|emacs|emacs-[0-9.]*)$
8
9# arch-tag: 277cc7ae-b3f5-44af-abf1-84c073164543
diff --git a/src/.gdbinit b/src/.gdbinit
index 9e4e674c740..943481d419e 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -81,7 +81,7 @@ end
81define xvectype 81define xvectype
82 xgetptr $ 82 xgetptr $
83 set $size = ((struct Lisp_Vector *) $ptr)->size 83 set $size = ((struct Lisp_Vector *) $ptr)->size
84 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size 84 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
85 echo \n 85 echo \n
86end 86end
87document xvectype 87document xvectype
@@ -186,9 +186,10 @@ Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value
186end 186end
187 187
188define xsymbol 188define xsymbol
189 xgetptr $ 189 set $sym = $
190 xgetptr $sym
190 print (struct Lisp_Symbol *) $ptr 191 print (struct Lisp_Symbol *) $ptr
191 xprintsym $ 192 xprintsym $sym
192 echo \n 193 echo \n
193end 194end
194document xsymbol 195document xsymbol
@@ -199,7 +200,7 @@ end
199define xstring 200define xstring
200 xgetptr $ 201 xgetptr $
201 print (struct Lisp_String *) $ptr 202 print (struct Lisp_String *) $ptr
202 output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte) 203 xprintstr $
203 echo \n 204 echo \n
204end 205end
205document xstring 206document xstring
@@ -210,7 +211,7 @@ end
210define xvector 211define xvector
211 xgetptr $ 212 xgetptr $
212 print (struct Lisp_Vector *) $ptr 213 print (struct Lisp_Vector *) $ptr
213 output ($->size > 50) ? 0 : ($->contents[0])@($->size) 214 output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag)
214echo \n 215echo \n
215end 216end
216document xvector 217document xvector
@@ -289,7 +290,7 @@ end
289define xboolvector 290define xboolvector
290 xgetptr $ 291 xgetptr $
291 print (struct Lisp_Bool_Vector *) $ptr 292 print (struct Lisp_Bool_Vector *) $ptr
292 output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8) 293 output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8)
293 echo \n 294 echo \n
294end 295end
295document xboolvector 296document xboolvector
@@ -372,12 +373,17 @@ document xscrollbar
372Print $ as a scrollbar pointer. 373Print $ as a scrollbar pointer.
373end 374end
374 375
376define xprintstr
377 set $data = $arg0->data
378 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
379end
380
375define xprintsym 381define xprintsym
376 xgetptr $arg0 382 xgetptr $arg0
377 set $sym = (struct Lisp_Symbol *) $ptr 383 set $sym = (struct Lisp_Symbol *) $ptr
378 xgetptr $sym->xname 384 xgetptr $sym->xname
379 set $sym_name = (struct Lisp_String *) $ptr 385 set $sym_name = (struct Lisp_String *) $ptr
380 output ($sym_name->data[0])@($sym_name->size_byte < 0 ? $sym_name->size : $sym_name->size_byte) 386 xprintstr $sym_name
381end 387end
382document xprintsym 388document xprintsym
383 Print argument as a symbol. 389 Print argument as a symbol.
@@ -418,7 +424,7 @@ define xbacktrace
418 if $type == Lisp_Vectorlike 424 if $type == Lisp_Vectorlike
419 xgetptr (*$bt->function) 425 xgetptr (*$bt->function)
420 set $size = ((struct Lisp_Vector *) $ptr)->size 426 set $size = ((struct Lisp_Vector *) $ptr)->size
421 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size 427 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
422 else 428 else
423 printf "Lisp type %d", $type 429 printf "Lisp type %d", $type
424 end 430 end
diff --git a/src/ChangeLog b/src/ChangeLog
index c9cf12dc159..00822d9d277 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,1130 @@
12004-06-20 Richard M. Stallman <rms@gnu.org>
2
3 * xfaces.c (Finternal_copy_lisp_face): Small cleanup; doc fix.
4
5 * search.c (match_limit): Cleaner err msg when no match data available.
6
7 * window.c (syms_of_window): Doc fix.
8
9 * keyboard.c (command_loop_1): Handle values `only' and `identity'
10 for Vtransient_mark_mode.
11
12 * buffer.c (syms_of_buffer): Doc fix.
13
142004-06-21 David Kastrup <dak@gnu.org>
15
16 * minibuf.c (Ftry_completion, Fall_completions): Do lazy binding
17 and unbinding of `case-fold-search' according to
18 `completion-ignore-case' around calls of string-match and
19 predicates, respectively. Should give satisfactory performance
20 in all relevant cases.
21
222004-06-17 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
23
24 * xterm.c (x_draw_image_foreground_1): Subtract slice.x/y from
25 clip_x/y_origin.
26
27 * fns.c (string_to_multibyte): Use xmalloc/xfree instead of alloca.
28
29 * macfns.c (Fx_display_color_cells): Do not limit return value to 256.
30
31 * macterm.c (mac_initialize_display_info): Initialize n_planes correctly
32 on Mac OSX.
33
342004-06-16 Luc Teirlinck <teirllm@auburn.edu>
35
36 * buffer.c (syms_of_buffer): Clarify `fill-column' docstring.
37
382004-06-16 Kim F. Storm <storm@cua.dk>
39
40 * dispextern.h (Vimage_types): Remove extern.
41
422004-06-16 Miles Bader <miles@gnu.org>
43
44 * image.c (lookup_image_type): Initialize image type if necessary.
45
462004-06-15 Kim F. Storm <storm@cua.dk>
47
48 * xdisp.c (try_cursor_movement): Exclude header line from scroll
49 margin at top of window.
50 (try_window_reusing_current_matrix): Calculate proper cursor position
51 after scrolling up with non-zero scroll margin, as the old cursor
52 position corresponds to value of PT before executing this command.
53 (try_window_id): Consider scroll margin at bottom of window too;
54 otherwise we fail to scroll when hl-line-mode is enabled.
55
56 * syntax.c (skip_chars): Only recognize [:class:] when it has the
57 proper format and class is a lower-case word.
58
592004-06-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
60
61 * gtkutil.c (xg_get_image_for_pixmap): New function.
62 (xg_get_gdk_pixmap_and_mask): Removed.
63 (update_frame_tool_bar): Call xg_get_image_for_pixmap instead of
64 xg_get_gdk_pixmap_and_mask.
65
66 * xterm.h (struct x_display_info): Typo in comment fixed.
67
682004-06-14 Juanma Barranquero <lektu@terra.es>
69
70 * dispextern.h (Vimage_types): Make it conditional on
71 HAVE_WINDOW_SYSTEM.
72
73 * image.c (Vimage_types): Move from xdisp.c.
74 (Vimage_type_cache): New variable.
75 (define_image_type): New argument indicating whether an image
76 library was loaded; cache loaded status and return t on success,
77 nil otherwise.
78 (CACHE_IMAGE_TYPE, ADD_IMAGE_TYPE): New macros.
79 (w32_delayed_load): New function to load an image library from a
80 list of possible filenames.
81 (init_xpm_functions, init_png_functions, init_jpeg_functions)
82 (init_tiff_functions, init_gif_functions): Use `w32_delayed_load'.
83 (CHECK_LIB_AVAILABLE): Call `define_image_library' with new
84 argument.
85 (Finit_image_library): New function, extracted from `init_image'.
86 Try to initialize an image library on demand and cache whether we
87 were successful or not.
88 (syms_of_image): Initialize `Vimage_types' and
89 `Vimage_type_cache'. Add recognized image types to Vimage_types.
90 Export `init-image-library'.
91 (init_image): Remove initialization of all image types, except xbm
92 and pbm.
93
94 * xdisp.c (Vimage_types): Delete (moved to image.c).
95
962004-06-14 Andreas Schwab <schwab@suse.de>
97
98 * minibuf.c (Ftry_completion, Fall_completions, Ftest_completion):
99 Avoid calling specbind when completion-regexp-list is empty.
100
1012004-06-13 Richard M. Stallman <rms@gnu.org>
102
103 * regex.h (CHAR_CLASS_MAX_LENGTH, re_wctype_t, re_wchar_t)
104 (re_wctype, re_iswctype, re_wctype_to_bit):
105 Non-function definitions moved here from regex.c.
106
107 * regex.c (re_wctype, re_iswctype): Function defs longer static.
108 (CHAR_CLASS_MAX_LENGTH, re_wctype_t, re_wchar_t)
109 (re_wctype, re_iswctype, re_wctype_to_bit):
110 Non-function definitions moved to regex.h.
111
112 * window.c (Fselect_window): Doc fix.
113
114 * syntax.c: Include regex.h.
115 (skip_chars): New arg HANDLE_ISO_CLASSES. Callers changed.
116 If requested, make a list of classes, then check the scanned
117 chars for membership in them.
118 (in_classes): New function.
119 Doc fix.
120
121 * keyboard.c (cmd_error): Don't call any_kboard_state
122 if inside a recursive edit level.
123
1242004-06-13 Lorentey K,Aa(Broly <lorentey@elte.hu>
125
126 * keyboard.c (command_loop): Call any_kboard_state before
127 command_loop_2 when at top level.
128
1292004-06-13 Andreas Schwab <schwab@suse.de>
130
131 * print.c (print_object): Always use %ld for printing EMACS_INT.
132
133 * keyboard.c (cancel_hourglass_unwind): Return a value.
134 (modify_event_symbol): Always use %ld for printing EMACS_INT.
135 (Fexecute_extended_command): Likewise.
136
137 * syntax.h (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
138 avoid clashes.
139 (SYNTAX): Likewise.
140 (SYNTAX_WITH_FLAGS): Likewise.
141 (SYNTAX_MATCH): Likewise.
142
143 * syntax.c (char_quoted): Avoid warning about undefined operation.
144 (find_defun_start): Likewise.
145 (scan_lists): Likewise.
146 (INC_FROM): Likewise.
147 (scan_sexps_forward): Likewise.
148
149 * image.c: Include <ctype.h>.
150
151 * xfaces.c (face_attr_equal_p): Declare parameters.
152
1532004-06-13 Kenichi Handa <handa@m17n.org>
154
155 * ccl.c (CCL_READ_CHAR): If hit EOF, set REG to -1.
156
1572004-06-12 Matthew Mundell <matt@mundell.ukfsn.org>
158
159 * eval.c (Fdefun): Signal an error if NAME is not a symbol.
160
1612004-06-12 Kenichi Handa <handa@m17n.org>
162
163 * ccl.c (CCL_CALL_FOR_MAP_INSTRUCTION): Save eof_ic in
164 ccl_prog_stack_struct and update it.
165 (CCL_INVALID_CMD): If CCL_DEBUG is defined, call ccl_debug_hook.
166 (CCL_READ_CHAR): Get instruction counter from eof_ic, not from
167 ccl->eof_ic on EOF.
168 (ccl_debug_hook): New function.
169 (struct ccl_prog_stack): New member eof_ic.
170 (ccl_driver): Handle EOF in subrountine call correctly.
171
1722004-06-11 Kenichi Handa <handa@m17n.org>
173
174 * coding.c (decode_coding_string): Check CODING_FINISH_INTERRUPT.
175
1762004-06-11 Kim F. Storm <storm@cua.dk>
177
178 * emacs.c (shut_down_emacs): Inhibit redisplay during shutdown.
179
1802004-06-11 Juanma Barranquero <lektu@terra.es>
181
182 * keyboard.c (Fposn_at_point): Doc fix.
183
1842004-06-11 David Kastrup <dak@gnu.org>
185
186 * search.c (match_limit): Don't flag an error if match-data
187 exceeding the allocated search_regs.num_regs gets requested, just
188 return Qnil.
189
1902004-06-08 Miles Bader <miles@gnu.org>
191
192 * xfaces.c (push_named_merge_point): Return 0 when a cycle is detected.
193
1942004-06-07 Juanma Barranquero <lektu@terra.es>
195
196 * editfns.c (Fuser_login_name, Ffloat_time, Fencode_time)
197 (Fcurrent_time_string, Fcurrent_time_zone)
198 (Finsert_buffer_substring, Ftranspose_regions): Doc fixes.
199
2002004-06-07 Miles Bader <miles@gnu.org>
201
202 * xfaces.c (struct named_merge_point): New type.
203 (push_named_merge_point): New function.
204 (merge_named_face): New function.
205 (merge_face_ref, face_at_buffer_position, face_at_string_position):
206 Use `merge_named_face'.
207 (merge_face_inheritance): Function removed.
208 (merge_face_ref): Renamed from `merge_face_vector_with_property'.
209 Add new `err_msgs' and `named_merge_points' args. Return error
210 status. Only print error messages if ERR_MSGS is true. Don't try to
211 do :inherit attribute validation.
212 (merge_face_heights): Handle `unspecified' in both directions.
213 (merge_face_vectors): Rename `cycle_check' arg to `named_merge_points'.
214 Call `merge_face_ref' instead of `merge_face_inheritance'.
215 (Fdisplay_supports_face_attributes_p, Fface_attributes_as_vector)
216 (compute_char_face, face_at_buffer_position)
217 (face_at_string_position): Call `merge_face_ref' instead of
218 `merge_face_vector_with_property'.
219
2202004-06-07 Kenichi Handa <handa@m17n.org>
221
222 * coding.c (find_safe_codings): Check NILP (safe_codings) only at
223 the necessary places.
224
2252004-06-07 Kim F. Storm <storm@cua.dk>
226
227 * process.c (Fdelete_process): Undo 2004-05-28 change.
228 Instead, call status_notify also for network process.
229 (status_message): Use process instead of status as arg.
230 Give messages "deleted" or "connection broken by remote peer" for
231 an exited network process.
232 (status_notify): Change call to status_message.
233 (read_process_output): Increase readmax to 4096. Do not increase
234 buffer size for datagram channels (default is now large enough).
235
2362004-06-06 Steven Tamm <tamm@Steven-Tamms-Computer.local>
237
238 * macfns.c (x_create_tip_frame): Fix Mac OS X 10.1 compilation
239 problem due to newly defined variable.
240
2412004-06-06 Miles Bader <miles@gnu.org>
242
243 * xfaces.c (Fdisplay_supports_face_attributes_p): Give up
244 immediately if non-interactive or not initialized.
245
2462004-06-05 Richard M. Stallman <rms@gnu.org>
247
248 * minibuf.c (Fcompleting_read): Doc fix.
249
2502004-06-05 Andreas Schwab <schwab@suse.de>
251
252 * macfns.c (x_create_tip_frame): Fix declaration after statement.
253
2542004-06-05 Juanma Barranquero <lektu@terra.es>
255
256 * keymap.c (Fdescribe_vector): Fix docstring.
257 (Fkey_description, Fglobal_key_binding): Fix typo in docstring.
258
2592004-06-05 Miles Bader <miles@gnu.org>
260
261 * xfaces.c (tty_supports_face_attributes_p): Make sure the specified
262 attributes have different values than the default face.
263
2642004-06-04 Eli Zaretskii <eliz@gnu.org>
265
266 * xfaces.c (x_supports_face_attributes_p): Make this function
267 conditional on HAVE_WINDOW_SYSTEM.
268 (Fdisplay_supports_face_attributes_p) [HAVE_WINDOW_SYSTEM]: Don't
269 call x_supports_face_attributes_p if it was not compiled in.
270
2712004-06-04 Miles Bader <miles@gnu.org>
272
273 * xfaces.c (tty_supports_face_attributes_p): New function, mostly
274 from Ftty_supports_face_attributes_p.
275 (x_supports_face_attributes_p): New function.
276 (Ftty_supports_face_attributes_p): Function deleted.
277 (Fdisplay_supports_face_attributes_p): New function.
278 (syms_of_xfaces): Initialize Sdisplay_supports_face_attributes_p.
279 (face_attr_equal_p): New function.
280 (lface_equal_p): Use it.
281
2822004-06-03 Juanma Barranquero <lektu@terra.es>
283
284 * w32fns.c (Fx_display_grayscale_p, Fw32_send_sys_command)
285 (Vw32_color_map): Fix typo in docstring.
286 (Fx_create_frame, Fw32_find_bdf_fonts, Fx_show_tip)
287 (Fw32_unregister_hot_key, Fw32_reconstruct_hot_key):
288 Make argument names match their use in docstring.
289
2902004-06-02 Juanma Barranquero <lektu@terra.es>
291
292 Work around bugs/problems with MinGW builds of graphics libraries
293 called from MSVC builds of Emacs.
294
295 * image.c (lookup_image): Make pointer to img static.
296 (png_read_from_memory): Disable "global" optimization.
297
2982004-06-01 Stefan Monnier <monnier@iro.umontreal.ca>
299
300 * mem-limits.h (EXCEEDS_LISP_PTR) [USE_LSB_TAG]: Never true.
301
3022004-05-29 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
303
304 * macfns.c: Don't include ccl.h.
305 [MAC_OSX]: Don't include QuickTime/QuickTime.h.
306 [!MAC_OSX]: Don't include alloca.h, Windows.h, Gestalt.h, or
307 TextUtils.h.
308 (Fx_create_frame): Sync with xfns.c. Initialize cursor
309 descriptors.
310 (Fx_display_mm_height, Fx_display_mm_width): Calculate length from
311 display height/width.
312 (compute_tip_xy, Vx_max_tooltip_size): Declare.
313 (unwind_create_tip_frame, compute_tip_xy): New functions.
314 (x_create_tip_frame, Fx_show_tip, Fx_hide_tip): Sync with xfns.c.
315 (syms_of_macfns): Initialize Qcancel_timer, Vx_max_tooltip_size,
316 and last_show_tip_args.
317
318 * macgui.h [!MAC_OSX]: Include Gestalt.h.
319 (Cursor, No_Cursor): New defines.
320 [!TARGET_API_MAC_CARBON] (SetPortWindowPort): New compatibility
321 macro.
322 [!TARGET_API_MAC_CARBON] (arrow_cursor): Declare.
323
324 * macmenu.c (mac_menu_show, mac_dialog): Use SetPortWindowPort.
325
326 * macterm.c: Don't include Gestalt.h.
327 (enum mouse_tracking_type, mouse_tracking_in_progress): Remove.
328 (XDrawLine, XClearArea, XClearWindow, mac_draw_bitmap)
329 (mac_set_clip_rectangle, mac_reset_clipping, XCreatePixmap)
330 (XFillRectangle, mac_draw_rectangle, mac_draw_string_common)
331 (mac_copy_area, mac_copy_area_with_mask, x_update_end)
332 (construct_mouse_click, XTmouse_position)
333 (x_scroll_bar_report_motion, x_calc_absolute_position)
334 (do_mouse_moved, do_zoom_window, mac_do_receive_drag)
335 (XTread_socket, make_mac_frame): Use SetPortWindowPort.
336 (note_mouse_movement): Clear the mouse face and reset the pointer
337 shape when the pointer goes outside the frame without grabbing.
338 (mac_front_window): New function.
339 (mac_window_to_frame): New macro.
340 (XTmouse_position, x_scroll_bar_report_motion, do_window_update)
341 (do_window_activate, do_window_deactivate, do_app_resume)
342 (do_app_suspend, do_mouse_moved, do_menu_choice, do_grow_window)
343 (do_zoom_window, mac_do_receive_drag, XTread_socket)
344 (mac_check_for_quit_char): Use mac_front_window and/or
345 mac_window_to_frame.
346 (x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a
347 scroll-bar click event.
348 (mac_define_frame_cursor): Change the pointer shape.
349 (x_free_frame_resources): Reset tip_window to NULL when it is
350 disposed.
351 [!TARGET_API_MAC_CARBON] (arrow_cursor): New variable.
352 [!TARGET_API_MAC_CARBON] (do_init_managers): Initialize
353 arrow_cursor.
354 (do_window_update): Don't do anything if the updated window is the
355 tooltip window.
356 (do_mouse_moved): Handle mouse movement events here (previously in
357 XTread_socket). Clear the mouse face if
358 dpyinfo->mouse_face_hidden is set.
359 (do_os_event, do_events): Remove (now in XTread_socket).
360 (XTread_socket): Immediately return if interrupt_input_blocked.
361 Loop until all the events in the queue are processed. Rearrange
362 codes for mouse grabbing. Add tooltip support. Include the
363 contents of do_os_event and do_events. Remove mouse movement
364 handling (now in do_mouse_moved). Add the case where
365 Vmouse_highlight has an integer value.
366 (NewMacWindow): Remove.
367 (make_mac_frame): Do what NewMacWindow previously did. Don't do
368 excess initializations.
369 (make_mac_terminal_frame): Previous initializations in
370 make_mac_frame are moved here.
371 (mac_initialize_display_info): Initialize
372 dpyinfo->mouse_face_overlay and dpyinfo->mouse_face_hidden.
373
374 * xdisp.c [MAC_OS] (No_Cursor): Remove variable.
375 (define_frame_cursor1): Don't treat HAVE_CARBON as a special case.
376
3772004-05-29 Richard M. Stallman <rms@gnu.org>
378
379 * lisp.h (truncate_undo_list): Update decl.
380
381 * alloc.c (undo_outer_limit): New variable.
382 (syms_of_alloc): Defvar it.
383 (Fgarbage_collect): Pass undo_outer_limit to truncate_undo_list.
384
385 * undo.c (truncate_undo_list): New arg LIMITSIZE.
386
387 * alloc.c (lisp_align_malloc): Check for base == 0
388 regardless of HAVE_POSIX_MEMALIGN.
389 Clean up HAVE_POSIX_MEMALIGN handling of `err'.
390
3912004-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
392
393 * alloc.c: Undo Kim's recent changes and fix the same bug differently.
394 (marker_blocks_pending_free): Remove.
395 (Fgarbage_collect): Sweep after cleaning up undo-lists.
396 Mark the undo lists after claning them up.
397 Don't free block in marker_blocks_pending_free.
398 (mark_buffer): Don't mark undo_list.
399 (gc_sweep): Sweep hash-tables and strings first.
400 Do free marker blocks that are empty.
401
4022004-05-28 Jim Blandy <jimb@redhat.com>
403
404 * regex.c (print_partial_compiled_pattern): Add missing 'break'
405 after 'case wordend'. For symbeg and symend, print to stderr,
406 like the other cases.
407
4082004-05-28 Noah Friedman <friedman@splode.com>
409
410 * process.c (Fdelete_process): Do not call remove_process.
411
4122004-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
413
414 * alloc.c (struct backtrace): Remove.
415 (Fgarbage_collect): Use the new mark_backtrace.
416
417 * eval.c (mark_backtrace): New function.
418
419 * minibuf.c (run_exit_minibuf_hook): New function.
420 (read_minibuf_unwind): Don't run exit-minibuffer-hook any more.
421 (read_minibuf): Use separate unwind handler to run exit-minibuf-hook.
422
4232004-05-27 Kim F. Storm <storm@cua.dk>
424
425 * xdisp.c (back_to_previous_visible_line_start): Skip backwards
426 over display properties, e.g. images, that replace buffer text.
427
4282004-05-25 Kim F. Storm <storm@cua.dk>
429
430 * alloc.c (marker_blocks_pending_free): New var.
431 (gc_sweep): Store free marker blocks on that list.
432 (Fgarbage_collect): Free them after undo-list cleanup.
433
434 * process.c (wait_reading_process_input): Check connect_wait_mask
435 before actually accepting connection in case it has already been
436 accepted due to recursion.
437
4382004-05-23 K,Ba(Broly L,Bu(Brentey <lorentey@elte.hu> (tiny change)
439
440 * coding.c (Fset_safe_terminal_coding_system_internal):
441 Set suppress_error in safe_terminal_coding, not terminal_coding.
442
4432004-05-22 Richard M. Stallman <rms@gnu.org>
444
445 * alloc.c (Fmake_string): Doc fix.
446
447 * buffer.c (clone_per_buffer_values): Copy the alist of local vars,
448 and the alist pairs too.
449
450 * casefiddle.c (casify_object): Return OBJ unchanged if not real char.
451
452 * emacs.c (main): Update copyright year.
453
454 * fileio.c (Fread_file_name): Expand DIR if not absolute.
455
456 * insdel.c (del_range_2, replace_range): Don't write an anchor
457 if the gap is empty.
458
459 * xdisp.c (try_scrolling): If scroll-up-aggressively or
460 scroll-down-aggressively is small but positive, put point
461 near the screen edge.
462
4632004-05-22 Juanma Barranquero <lektu@terra.es>
464
465 * keymap.c (Fdefine_key): Doc fix.
466
4672004-05-22 Kim F. Storm <storm@cua.dk>
468
469 * alloc.c (struct backtrace): Add debug_on_exit member.
470 (Fgarbage_collect): Clear out buffer undo_list markers after gc_sweep.
471 Identify those markers as Lisp_Misc_Free objects. Clear car and cdr of
472 the removed cons cells.
473 (mark_object): Undo previous change - disallow Lisp_Misc_Free objects.
474 (gc_sweep): Clear cons_blocks before sweeping strings, so we don't have
475 any cons cells pointing to unallocated stings.
476 Do not lisp_free any marker blocks, as there may still be pointers
477 to them from buffer undo lists at this stage of GC.
478
479 * keyboard.c (struct backtrace): Add debug_on_exit member.
480 (Fcommand_execute): Clear it.
481
4822004-05-20 Luc Teirlinck <teirllm@auburn.edu>
483
484 * intervals.c (lookup_char_property): Do not prematurely return nil.
485
4862004-05-19 Jim Blandy <jimb@redhat.com>
487
488 Add support for new '\_<' and '\_>' regexp operators, matching the
489 beginning and end of symbols.
490
491 * regex.c (enum syntaxcode): Add Ssymbol.
492 (init_syntax_once): Set the syntax for '_' to Ssymbol, not Sword.
493 (re_opcode_t): New opcodes `symbeg' and `symend'.
494 (print_partial_compiled_pattern): Print the new opcodes properly.
495 (regex_compile): Parse the new operators.
496 (analyse_first): Skip sym(beg|end) (they match only the empty string).
497 (mutually_exclusive_p): `symend' is mutually exclusive with \s_ and
498 \sw; `symbeg' is mutually exclusive with \S_ and \Sw.
499 (re_match_2_internal): Match symbeg and symend.
500
501 * search.c (trivial_regexp_p): \_ is no longer a trivial regexp.
502
5032004-05-19 Kim F. Storm <storm@cua.dk>
504
505 * .gdbinit (xsymbol): Fix last change.
506
5072004-05-18 Stefan Monnier <monnier@iro.umontreal.ca>
508
509 * .gdbinit (xprintstr): New fun.
510 (xstring, xprintsym): Use it.
511
512 * w32proc.c (create_child): Use INTMASK.
513
514 * alloc.c (Fgarbage_collect): Do all the marking before flushing
515 unmarked elements of the undo list.
516
5172004-05-18 David Ponce <david@dponce.com>
518
519 * print.c (print): Reset print_depth before to call print_object.
520
5212004-05-18 Jason Rumney <jasonr@gnu.org>
522
523 * w32console.c: Prefix RIF functions with w32con_ to avoid
524 namespace clash with functions in term.c and w32term.c.
525
526 * w32menu.c (add_menu_item, w32_menu_display_help)
527 [USE_LISP_UNION_TYPE]: Cast from Lisp_Object using i member.
528
529 * w32term.h (display_x_get_resource, vga_stdcolor_name): Add prototype.
530
5312004-05-18 Eli Zaretskii <eliz@gnu.org>
532
533 * lisp.h (DECL_ALIGN): Remove restriction on MS-DOS systems.
534
535 * msdos.c (syms_of_msdos): Initialize dos-unsupported-char-glyph
536 with make_number.
537 (IT_write_glyphs): Extract glyph from dos-unsupported-char-glyph
538 with XINT.
539
5402004-05-18 Kim F. Storm <storm@cua.dk>
541
542 * blockinput.h (INPUT_BLOCKED_P): New macros.
543
544 * keyboard.c (Frecursive_edit): Return immediately if input blocked.
545 (Ftop_level): Unblock input if blocked.
546
547 * buffer.h (GET_OVERLAYS_AT): New macro.
548 * msdos.c (IT_note_mouse_highlight): Use it.
549 * textprop.c (get_char_property_and_overlay): Use it.
550 * xdisp.c (next_overlay_change, note_mouse_highlight): Use it.
551 * xfaces.c (face_at_buffer_position): Use it.
552
553 * print.c (print_object): Increase buf size.
554
5552004-05-17 Jason Rumney <jasonr@gnu.org>
556
557 * w32fns.c (Fw32_register_hot_key, Fw32_unregister_hot_key)
558 (Fw32_toggle_lock_key) [USE_LISP_UNION_TYPE]: Cast from
559 Lisp_Object using i member.
560 (w32_quit_key): Rename from Vw32_quit_key, and make an int.
561 (syms_of_w32fns, globals_of_w32fns): Use Lisp_Object and int
562 consistently.
563
564 * w32proc.c (create_child): Use make_number instead of masking pid.
565
566 * w32fns.c (w32_color_map_lookup): Return a Lisp_Object.
567 (x_to_w32_charset, w32_to_x_charset, w32_to_all_x_charsets):
568 Use EQ to compare Lisp_Objects.
569 (w32_parse_hot_key): Use int for lisp_modifiers consistently.
570
571 * w32term.c (w32_num_mouse_buttons): Rename from
572 Vw32_num_mouse_buttons and make it an int.
573
574 * w32.c (init_environment): Use it.
575
576 * w32fns.c (w32_wnd_proc): Likewise.
577
578 * w32proc.c (w32_pipe_read_delay): Rename from
579 Vw32_pipe_read_delay and make it an int.
580
581 * w32.c (_sys_read_ahead): Use it.
582
583 * lisp.h (egetenv) [USE_CRT_DLL]: Remove condition.
584
585 * w32proc.c (create_child) [USE_LSB_TAG]: Don't try to mask pid.
586
587 * w32inevt.c (w32_console_mouse_position, do_mouse_event)
588 (key_event): Don't mix Lisp_Object and int.
589
590 * w32heap.c (init_heap) [USE_LSB_TAG]: Don't check heap location.
591
592 * keyboard.c (kbd_buffer_get_event): Don't use event->code and
593 modifiers in language change event.
594
5952004-05-17 Kim F. Storm <storm@cua.dk>
596
597 * alloc.c (mark_object): Ignore Lisp_Misc_Free objects.
598 Such objects may be freed markers which still exist on an undo list.
599
6002004-05-16 Juanma Barranquero <lektu@terra.es>
601
602 * data.c (Fset_default): Make argument names match their use in
603 docstring.
604
6052004-05-15 Andreas Schwab <schwab@suse.de>
606
607 * emacs.c (gdb_array_mark_flag): Define.
608 * .gdbinit: Mask off gdb_array_mark_flag from vector sizes.
609
6102004-05-15 Eli Zaretskii <eliz@gnu.org>
611
612 * lisp.h (DECL_ALIGN) [MSDOS]: Don't define DECL_ALIGN to use
613 __attribute__((__aligned__)), so that USE_LSB_TAG would not become
614 defined for the MS-DOS build.
615
6162004-05-14 Stefan Monnier <monnier@iro.umontreal.ca>
617
618 * w32fns.c (Fw32_define_rgb_color): Avoid XSET.
619
6202004-05-14 Kenichi Handa <handa@m17n.org>
621
622 * ccl.c (Fccl_execute_on_string): Fix setting elements of STATUS.
623
6242004-05-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
625
626 * lisp.h (Vx_resource_name, Vx_resource_class): Move from xfns.c
627 section to frame.c section.
628 (Fxw_display_color_p, Fx_file_dialog): Declare if
629 HAVE_WINDOW_SYSTEM defined.
630
631 * macfns.c (Fx_create_frame): Fix int/Lisp_Object mixup.
632
633 * macmenu.c (set_frame_menubar): Use NILP to test a lisp value.
634
635 * macterm.c (mac_get_emulated_btn, mac_event_to_emacs_modifiers)
636 (mac_get_mouse_btn): Use NILP and EQ to test/compare lisp values.
637 (XTread_socket): Fix int/Lisp_Object mixup.
638 (mac_check_for_quit_char): Fix pointer/Lisp_Object mixup.
639
640 * macterm.h (struct frame, struct face, struct image)
641 (display_x_get_resource, Fx_display_color_p)
642 (Fx_display_grayscale_p, Fx_display_planes, x_free_gcs):
643 Add prototypes.
644
6452004-05-14 Kim F. Storm <storm@cua.dk>
646
647 * process.c (wait_reading_process_input): Make reentrant.
648 Make Available and Connecting non-static. Save and restore value
649 of waiting_for_user_input_p.
650
6512004-05-13 Kim F. Storm <storm@cua.dk>
652
653 * keyboard.c (mark_kboards): Don't mark x and y members
654 that are overloaded in selection request events.
655
6562004-05-13 Stefan Monnier <monnier@iro.umontreal.ca>
657
658 * lisp.h (USE_LSB_TAG): Make it the default when it is known to work.
659
6602004-05-13 Glenn Morris <gmorris@ast.cam.ac.uk>
661
662 * window.c (Fdisplay_buffer, Fsplit_window)
663 (split-height-threshold): Doc fix.
664
6652004-05-13 Juanma Barranquero <lektu@terra.es>
666
667 * xfaces.c (Ftty_supports_face_attributes_p)
668 (Finternal_copy_lisp_face): Fix typo in docstring.
669 (Finternal_get_lisp_face_attribute): Fix docstring.
670
6712004-05-12 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
672
673 * xfns.c (syms_of_xfns): Provide x-toolkit also for GTK.
674
6752004-05-11 Steven Tamm <steventamm@mac.com>
676
677 * macfns.c (Fx_create_frame): Default to using tool-bar by
678 setting tool-bar-lines to 1 in default-frame-alist.
679
6802004-05-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
681
682 * image.c (xpm_scan, xpm_make_color_table_v, xpm_put_color_table_v)
683 (xpm_get_color_table_v, xpm_make_color_table_h)
684 (xpm_put_color_table_h, xpm_get_color_table_h)
685 (xpm_str_to_color_key, xpm_load_image, xpm_load)
686 (syms_of_image): Support XPM on Carbon Emacs. Does not
687 depend on libXpm, but only supports XPM version 3 without extensions.
688
6892004-05-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
690
691 * macterm.c (x_flush, XTframe_up_to_date): Use FRAME_MAC_P
692 instead of FRAME_X_P
693
6942004-05-11 Kim F. Storm <storm@cua.dk>
695
696 * process.c (read_process_output): Grow decoding_buf when needed;
697 this could cause a crash in allocate_string and compact_small_strings.
698
6992004-04-29 Jim Blandy <jimb@redhat.com>
700
701 * regex.c (mutually_exclusive_p): In 'case wordbeg', compare op2
702 against proper opcode.
703
7042004-05-10 Juanma Barranquero <lektu@terra.es>
705
706 * process.c (Fstart_process): Fix docstring.
707
708 * charset.c (Fget_unused_iso_final_char): Fix typos in docstring.
709 (Fchar_bytes, Fchar_width, Fstring_width, Fchar_direction)
710 (Fsplit_char, Fchar_charset): Make argument names match their use
711 in docstring.
712
7132004-05-10 Richard M. Stallman <rms@gnu.org>
714
715 * print.c (print_preprocess): Use being_printed, loop_count and
716 halftail to detect overdeep nesting and cyclic cdr chains.
717
7182004-05-10 Andreas Schwab <schwab@suse.de>
719
720 * lisp.h: Declare Fmake_symbolic_link.
721
722 * fileio.c (Frename_file): Remove extra argument in call to
723 Fmake_symbolic_link.
724
7252004-05-10 Kim F. Storm <storm@cua.dk>
726
727 * xdisp.c (calc_line_height_property): Use string position when
728 object is a string.
729
7302004-05-10 Kenichi Handa <handa@m17n.org>
731
732 * print.c (temp_output_buffer_setup): Bind inhibit-read-only and
733 inhibit-modification-hooks to t temporarily before calling
734 Ferase_buffer.
735
736 * xfns.c (x_create_tip_frame): Bind inhibit-read-only and
737 inhibit-modification-hooks to t temporarily before calling
738 Ferase_buffer.
739
740 * w32fns.c (x_create_tip_frame): Bind inhibit-read-only and
741 inhibit-modification-hooks to t temporarily before calling
742 Ferase_buffer.
743
744 * fns.c (count_combining): Delete it.
745 (concat): Don't check combining bytes.
746
7472004-05-09 Jason Rumney <jasonr@gnu.org>
748
749 * w32fns.c (Vw32_ansi_code_page): New Lisp variable.
750 (globals_of_w32fns): Set it.
751
7522004-05-09 Piet van Oostrum <piet@cs.uu.nl> (tiny change)
753
754 * data.c (Fquo): Simplify.
755
7562004-05-08 Peter Whaite <emacs@whaite.ca> (tiny change)
757
758 * data.c (Fquo): If any argument is float, do the computation in
759 floating point.
760
7612004-05-08 Juanma Barranquero <lektu@terra.es>
762
763 * process.c (Fwaiting_for_user_input_p, Fmake_network_process)
764 (Fset_process_query_on_exit_flag, Vprocess_adaptive_read_buffering):
765 Fix spelling of Emacs on docstring.
766 (Fset_process_coding_system, Fprocess_coding_system)
767 (Fset_process_filter_multibyte, Fprocess_filter_multibyte_p):
768 Make argument names match their use in docstring.
769 (Fprocess_id, Fprocess_query_on_exit_flag, Finterrupt_process):
770 Fix docstring.
771
772 * editfns.c (Finsert_buffer_substring): Make argument names match their
773 use in docstring.
774
775 * syntax.c (Fmodify_syntax_entry): Fix docstring.
776
7772004-05-07 Steven Tamm <steventamm@mac.com>
778
779 * macterm.c (mac_check_for_quit_char): Adding BLOCK_INPUT
780 around call to ReceiveEvent to avoid certain crashes.
781
7822004-05-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
783
784 * macterm.c (mac_draw_line_to_pixmap, XCreatePixmapFromBitmapData)
785 (mac_fill_rectangle_to_pixmap, mac_draw_rectangle_to_pixmap)
786 (mac_copy_area_to_pixmap, mac_copy_area_with_mask_to_pixmap):
787 Save/restore the current graphics port and device handle when
788 drawing into an offscreen graphics world.
789
790 * image.c [MAC_OS] (XPutPixel, XGetPixel, image_load_qt_1)
791 (gif_load): Likewise.
792
7932004-05-07 Juanma Barranquero <lektu@terra.es>
794
795 * window.c (Fset_window_buffer): Fix docstring.
796
7972004-05-06 Thien-Thi Nguyen <ttn@gnu.org>
798
799 * emacs.c (main) [VMS]: Fix var ref.
800
8012004-05-06 Romain Francoise <romain@orebokech.com> (tiny change)
802
803 * data.c (Fsetq_default): Fix docstring.
804
8052004-05-06 Jason Rumney <jasonr@gnu.org>
806
807 * image.c (Display) [HAVE_NTGUI]: Redefine while loading xpm.h
808 to avoid name clash.
809
8102004-05-04 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
811
812 * fileio.c (barf_or_query_if_file_exists): Use lstat.
813 (Frename_file): Handle renaming of symlinks across file systems.
814 (Frename_file): Put symlink handling inside #ifdef S_IFLNK.
815
8162004-05-04 Kim F. Storm <storm@cua.dk>
817
818 * xdisp.c (Qtotal): New var.
819 (syms_of_xdisp): Intern and staticpro it.
820 (calc_line_height_property): New arg total. Set it if
821 line-spacing property has format (total . VALUE).
822 (x_produce_glyphs): Ignore line-spacing if line-height is 0.
823 Handle total line-spacing property.
824
8252004-05-03 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
826
827 * gtkutil.c (xg_update_scrollbar_pos): Call XClearWindow to clear
828 "under" scroll bar when size/position changes.
829
8302004-05-03 Jason Rumney <jasonr@gnu.org>
831
832 * makefile.nt: Remove.
833
8342004-05-02 Eli Zaretskii <eliz@gnu.org>
835
836 * syntax.h (SET_RAW_SYNTAX_ENTRY, SYNTAX_ENTRY_INT):
837 Avoid compiler warnings.
838
839 * Makefile.in (region-cache.o): Depend on config.h.
840
8412004-05-02 Romain Francoise <romain@orebokech.com> (tiny change)
842
843 * indent.c (compute_motion): Save vpos in prev_vpos when dealing
844 with continuation lines, too.
845
8462004-05-02 Thien-Thi Nguyen <ttn@gnu.org>
847
848 * syssignal.h (init_signals): Move decl outside `#ifdef POSIX_SIGNALS'.
849
8502004-05-01 Stefan Monnier <monnier@iro.umontreal.ca>
851
852 * xdisp.c (calc_line_height_property): YAILOM (yet another
853 int/Lisp_Object mixup).
854
8552004-05-01 Eli Zaretskii <eliz@gnu.org>
856
857 * msdos.c (top-level): Add "#pragma pack(0)" after <dir.h>, to
858 undo bad effect of pack(4) in some versions of system headers.
859
8602004-05-01 Jason Rumney <jasonr@gnu.org>
861
862 * w32term.c (x_draw_hollow_cursor): Sync with xterm.c
863
8642004-04-30 Kim F. Storm <storm@cua.dk>
865
866 * buffer.c (syms_of_buffer) <line-spacing>: Allow float value.
867 (syms_of_buffer) <cursor-type>: Doc fix.
868
869 * dispextern.h (struct it): Remove member use_default_face.
870 Add members override_ascent, override_descent, override_boff.
871
872 * xdisp.c (init_iterator): Handle line-spacing float value.
873 Initialize override_ascent member.
874 (append_space_for_newline): Reset override_ascent.
875 Remove use_default_face.
876 (calc_line_height_property): New function to calculate value of
877 line-height and line-spacing properties. Look at overlays, too.
878 Set override_ascent, override_descent, override_boff members when
879 using another face than the current face. Float values are now
880 relative to the frame default font, by default; accept a cons
881 of ratio and face name to specify value relative to a specific face.
882 (x_produce_glyphs): Use calc_line_height_property.
883 Use override_ascent etc. when set to handle different face heights.
884 A negative line-spacing property value is interpreted as a total
885 line height, rather than inter-line spacing.
886 (note_mouse_highlight): Allocate room for 40 overlays initially.
887
8882004-04-29 Stefan Monnier <monnier@iro.umontreal.ca>
889
890 * data.c (Fsubr_name): New fun.
891 (syms_of_data): Defsubr it.
892
8932004-04-29 Kim F. Storm <storm@cua.dk>
894
895 * xdisp.c (null_glyph_slice): New var.
896 (append_glyph, append_composite_glyph, append_stretch_glyph):
897 Use it to initialize glyph slice.
898
8992004-04-27 Stefan Monnier <monnier@iro.umontreal.ca>
900
901 * xdisp.c (x_produce_glyphs): Fix the proverbial int/Lisp_Object mixup.
902 (on_hot_spot_p): Make sure we always return a value.
903 (Flookup_image_map): Remove unused var ix and iy.
904 (note_mode_line_or_margin_highlight): Remove unused var `image'.
905
9062004-04-27 Eli Zaretskii <eliz@gnu.org>
907
908 * msdos.c (init_environment): If one of the TMP... environment
909 variables is set to a drive letter without a trailing slash,
910 append a slash.
911
9122004-04-27 Matthew Mundell <matt@mundell.ukfsn.org>
913
914 * editfns.c (lisp_time_argument): Provide externally.
915
916 * fileio.c (Fset_file_times): New function.
917 (syms_of_fileio): Intern and staticpro it.
918
9192004-04-27 Kim F. Storm <storm@cua.dk>
920
921 * xdisp.c (x_produce_glyphs): Fix last change; handle newline in
922 header line strings.
923
924 * dispextern.h (struct it): New member use_default_face.
925
926 * xdisp.c (Qline_height): New variable.
927 (syms_of_xdisp): Intern and staticpro it.
928 (append_space_for_newline): Partially undo 2004-04-25 change;
929 add default_face_p arg, and restore callers.
930 Clear it->use_default_face after use.
931 (x_produce_glyphs): Set default font for ascii char if
932 it->use_default_font is set. Change line-spacing property to set
933 just extra line spacing. Handle new line-height property.
934
9352004-04-26 Andreas Schwab <schwab@suse.de>
936
937 * print.c (print_object): Print non-ascii characters in bool
938 vector representation as octal escapes.
939
940 * lisp.h (BOOL_VECTOR_BITS_PER_CHAR): Define.
941 * print.c (print_object): Use it instead of BITS_PER_CHAR for
942 bool vectors.
943 * lread.c (read1): Likewise.
944 * alloc.c (Fmake_bool_vector): Likewise.
945 * data.c (Faref, Faset): Likewise.
946 * fns.c (Fcopy_sequence, concat, internal_equal, Ffillarray)
947 (mapcar1): Likewise.
948
9492004-04-26 Steven Tamm <tamm@Steven-Tamms-Computer.local>
950
951 * lread.c (init_lread): Fixing typo HAVE_CARBON test logic
952
9532004-04-26 Miles Bader <miles@gnu.org>
954
955 * lisp.h (CYCLE_CHECK): Macro moved from xfaces.c.
956
9572004-04-26 Juanma Barranquero <lektu@terra.es>
958
959 * buffer.c (Fpop_to_buffer): Fix docstring.
960
9612004-04-26 Steven Tamm <steventamm@mac.com>
962
963 * lread.c (init_lread): Don't display missing lisp directory
964 warnings with Carbon Emacs because self-contained bundled Emacs
965 may be built without correct installation path.
966
9672004-04-25 Kim F. Storm <storm@cua.dk>
968
969 * macterm.c (x_draw_hollow_cursor): Fix height of box for narrow lines.
970
971 * xterm.c (x_draw_hollow_cursor): Fix height of box for narrow lines.
972
973 * xdisp.c (append_space_for_newline): Rename from append_space.
974 Remove DEFAULT_FACE_P arg; always use current face. Callers changed.
975 (x_produce_glyphs): Handle line-spacing property on newline char.
976 If value is t, adjust ascent and descent to fit current row height.
977 If value is an integer or float, set extra_line_spacing to integer
978 value, or to float value x current line height.
979
9802004-04-23 Kenichi Handa <handa@m17n.org>
981
982 * fontset.c (Finternal_char_font): If POSITION is nil, return
983 font for displaying CH with the default face.
984
9852004-04-23 Juanma Barranquero <lektu@terra.es>
986
987 * makefile.w32-in: Add "-*- makefile -*-" mode tag.
988
9892004-04-21 Stefan Monnier <monnier@iro.umontreal.ca>
990
991 * lisp.h (XINT) [EXPLICIT_SIGN_EXTEND && !NO_UNION_TYPE]:
992 Don't make assumptions about the relative place of i and val.
993 (EQ) [!NO_UNION_TYPE]: Don't forget to check the type match as well.
994
9952004-04-21 Kim F. Storm <storm@cua.dk>
996
997 * dispextern.h (struct glyph_slice): New struct.
998 (struct glyph): New member slice.
999 (GLYPH_SLICE_EQUAL_P): New macro.
1000 (GLYPH_EQUAL_P): Use it.
1001 (struct glyph_string): New member slice.
1002 (struct it_slice): New struct.
1003 (struct it): New member slice, add member to stack too.
1004 New member constrain_row_ascent_descent_p.
1005 (image_ascent): Add prototype.
1006
1007 * dispnew.c (buffer_posn_from_coords): Return full image width
1008 and height even for image slices (posn is relative to full image).
1009 (marginal_area_string): Adjust x0,y0 for image slice.
1010
1011 * image.c (image_ascent): Add slice arg; calculate ascent for
1012 image slice (or full image).
1013
1014 * keyboard.c (Fposn_at_x_y, Fposn_at_point): New defuns.
1015 (syms_of_keyboard): Defsubr them.
1016
1017 * lisp.h (pos_visible_p): Fix prototype.
1018
1019 * macterm.c (x_draw_relief_rect): Add top_p and bot_p args.
1020 (x_draw_glyph_string_box): Fix call to x_draw_relief_rect.
1021 (x_draw_image_foreground, x_draw_image_relief)
1022 (x_draw_image_foreground_1, x_draw_image_glyph_string):
1023 Draw sliced images.
1024
1025 * w32term.c (w32_draw_relief_rect): Add top_p and bot_p args.
1026 (x_draw_glyph_string_box): Fix call to x_draw_relief_rect.
1027 (x_draw_image_foreground, x_draw_image_relief)
1028 (w32_draw_image_foreground_1, x_draw_image_glyph_string):
1029 Draw sliced images.
1030
1031 * w32term.h (image_ascent): Remove prototype.
1032
1033 * window.c (Fpos_visible_in_window_p): Return pixel position if
1034 PARTIALLY arg is non-nil. Simplify. Doc fix.
1035 (Fwindow_vscroll, Fset_window_vscroll): Add optional PIXEL_P arg
1036 to return/set vscroll in pixels.
1037
1038 * window.h (Fwindow_vscroll, Fset_window_vscroll): Fix EXFUN.
1039
1040 * xdisp.c (Qslice): New variable.
1041 (syms_of_xdisp): Intern and staticpro it.
1042 (pos_visible_p): Return pixel position in new x and y args.
1043 (init_iterator): Reset it->slice info.
1044 (handle_display_prop): Parse (slice ...) property.
1045 (push_it, pop_it): Save/restore slice info.
1046 (make_cursor_line_fully_visible): Fix 2004-04-14 change. Do not
1047 force repositioning of tall row if window is vscrolled, as that
1048 would reset vscroll.
1049 (append_space): Set it->constrain_row_ascent_descent_p to avoid
1050 increasing row height if row is non-empty.
1051 (fill_image_glyph_string): Copy slice info.
1052 (take_vertical_position_into_account): Simplify.
1053 (produce_image_glyph): Handle iterator slice info, setup glyph
1054 slice info. Do not force minimum line height.
1055 (x_produce_glyphs): If it->constrain_row_ascent_descent_p is set,
1056 do not increase height (ascent/descent) of non-empty row when
1057 adding normal character glyph; instead reduce glyph ascent/descent
1058 appropriately; if row is higher than current glyph, adjust glyph
1059 descent/ascent to reposition glyph within the existing row.
1060 Likewise, when char is newline, only set ascent/descent if row is
1061 currently empty.
1062 (note_mouse_highlight): Handle hotspots with sliced image.
1063
1064 * xterm.c (x_draw_relief_rect): Add top_p and bot_p args.
1065 (x_draw_glyph_string_box): Fix call to x_draw_relief_rect.
1066 (x_draw_image_foreground, x_draw_image_relief)
1067 (x_draw_image_foreground_1, x_draw_image_glyph_string):
1068 Draw sliced images.
1069
1070 * xterm.h (image_ascent): Remove prototype.
1071
10722004-04-20 Stefan Monnier <monnier@iro.umontreal.ca>
1073
1074 * keymap.c (Fkey_description): Fix the usual int/Lisp_Object mixup.
1075
10762004-04-20 John Paul Wallington <jpw@gnu.org>
1077
1078 * fns.c (Fassoc, Feql): Fix indentation.
1079
1080 * fontset.c (regularize_fontname): Rename from regulalize_fontname.
1081
10822004-04-19 John Paul Wallington <jpw@gnu.org>
1083
1084 * fns.c (Feql): New function.
1085 (syms_of_fns): Defsubr it.
1086
10872004-04-18 Jason Rumney <jasonr@gnu.org>
1088
1089 * w32select.c (Fw32_set_clipboard_data): Get sequence number
1090 after closing the clipboard.
1091
10922004-04-16 Luc Teirlinck <teirllm@auburn.edu>
1093
1094 * buffer.c (Fbuffer_base_buffer): Doc fix.
1095
10962004-04-17 Kim F. Storm <storm@cua.dk>
1097
1098 * keymap.c (Fkey_description): Add optional PREFIX arg.
1099 Combine prefix with KEYS to make up the full key sequence to describe.
1100 Correlate meta_prefix_char and following (simple) key to describe
1101 as meta modifier. All callers changed.
1102 (describe_map): Rename arg `keys' to `prefix'. Remove local
1103 `elt_prefix' var. Use Fkey_description with prefix instead of
1104 elt_prefix combined with Fsingle_key_description.
1105 (describe_vector): Declare static. Replace arg `elt_prefix' with
1106 `prefix'. Add KEYMAP_P arg. Add local var `elt_prefix'; use it
1107 if !KEYMAP_P. Use Fkey_description with prefix instead of
1108 Fsingle_key_description.
1109
1110 * keymap.h (Fkey_description): Fix prototype.
1111 (describe_vector): Remove prototype.
1112
1113 * xdisp.c (update_overlay_arrows): Fix handling of up_to_date < 0.
1114
1115 * image.c (PNG_BG_COLOR_SHIFT): Remove.
1116 (png_load): Fix calculation of transparent background color on X
1117 and W32 platforms.
1118
11192004-04-16 Juanma Barranquero <lektu@terra.es>
1120
1121 * xdisp.c (try_scrolling): Make sure `scroll-conservatively' is
1122 not too large before computing how much to scroll.
1123
11242004-04-15 Stefan Monnier <monnier@iro.umontreal.ca>
1125
1126 * dired.c (Ffile_attributes): Don't pass extra nil arg to file-handler.
1127
12004-04-14 Luc Teirlinck <teirllm@auburn.edu> 11282004-04-14 Luc Teirlinck <teirllm@auburn.edu>
2 1129
3 * fileio.c (Fverify_visited_file_modtime, Fvisited_file_modtime): 1130 * fileio.c (Fverify_visited_file_modtime, Fvisited_file_modtime):
@@ -30,6 +1157,11 @@
30 centering_position = 0. 1157 centering_position = 0.
31 Clear desired matrix before retrying with centering_position = 0. 1158 Clear desired matrix before retrying with centering_position = 0.
32 1159
11602004-04-13 Stefan Monnier <monnier@iro.umontreal.ca>
1161
1162 * syntax.c (scan_lists): Simplify backward string scan.
1163 Fix off-by-one boundary check for string and comment fences.
1164
332004-04-13 Joe Buehler <jbuehler@hekimian.com> 11652004-04-13 Joe Buehler <jbuehler@hekimian.com>
34 1166
35 * sheap.c, unexcw.c: New files. 1167 * sheap.c, unexcw.c: New files.
@@ -573,7 +1705,7 @@
573 1705
574 * macterm.c (XTread_socket): Remove bufp_r and 1706 * macterm.c (XTread_socket): Remove bufp_r and
575 numcharsp args. Add hold_quit arg. 1707 numcharsp args. Add hold_quit arg.
576 Rework to use just one, local, inev input_event. Store inev 1708 Rework to use just one, local, inev input_event. Store inev
577 directly in fifo using kbd_buffer_store_event_hold. 1709 directly in fifo using kbd_buffer_store_event_hold.
578 1710
579 * sysdep.c (BUFFER_SIZE_FACTOR): Remove. 1711 * sysdep.c (BUFFER_SIZE_FACTOR): Remove.
@@ -589,14 +1721,14 @@
589 1721
590 * w32inevt.c (w32_console_read_socket): Remove bufp_r and 1722 * w32inevt.c (w32_console_read_socket): Remove bufp_r and
591 numcharsp args. Add hold_quit arg. 1723 numcharsp args. Add hold_quit arg.
592 Rework to use just one, local, inev input_event. Store inev 1724 Rework to use just one, local, inev input_event. Store inev
593 directly in fifo using kbd_buffer_store_event_hold. 1725 directly in fifo using kbd_buffer_store_event_hold.
594 1726
595 * w32inevt.h (w32_console_mouse_position): Fix prototype. 1727 * w32inevt.h (w32_console_mouse_position): Fix prototype.
596 1728
597 * w32term.c (w32_read_socket): Remove bufp_r and numcharsp args. 1729 * w32term.c (w32_read_socket): Remove bufp_r and numcharsp args.
598 Add hold_quit arg. Rework to use just one, local, inev 1730 Add hold_quit arg. Rework to use just one, local, inev
599 input_event. Store inev directly in fifo using 1731 input_event. Store inev directly in fifo using
600 kbd_buffer_store_event_hold. Update count in one place. 1732 kbd_buffer_store_event_hold. Update count in one place.
601 Postpone call to gen_help_event until inev is stored; use new 1733 Postpone call to gen_help_event until inev is stored; use new
602 local do_help for this. 1734 local do_help for this.
@@ -615,8 +1747,8 @@
615 (current_hold_quit) [USE_GTK]: Add. 1747 (current_hold_quit) [USE_GTK]: Add.
616 (event_handler_gdk): Adapt to new handle_one_xevent. 1748 (event_handler_gdk): Adapt to new handle_one_xevent.
617 (handle_one_xevent): Remove bufp_r and numcharsp args. 1749 (handle_one_xevent): Remove bufp_r and numcharsp args.
618 Add hold_quit arg. Rework to use just one, local, inev 1750 Add hold_quit arg. Rework to use just one, local, inev
619 input_event. Store inev directly in fifo using 1751 input_event. Store inev directly in fifo using
620 kbd_buffer_store_event_hold. Update count in one place. 1752 kbd_buffer_store_event_hold. Update count in one place.
621 Postpone call to gen_help_event until inev is stored; use new 1753 Postpone call to gen_help_event until inev is stored; use new
622 local do_help for this. 1754 local do_help for this.
@@ -628,7 +1760,7 @@
628 `goto done' to clarify code flow in deeply nested blocks. 1760 `goto done' to clarify code flow in deeply nested blocks.
629 (x_dispatch_event): Simplify as handle_one_xevent now calls 1761 (x_dispatch_event): Simplify as handle_one_xevent now calls
630 kbd_buffer_store_event itself. 1762 kbd_buffer_store_event itself.
631 (XTread_socket): Remove bufp_r and numcharsp args. Add hold_quit 1763 (XTread_socket): Remove bufp_r and numcharsp args. Add hold_quit
632 arg. Call handle_one_xevent with new arglist. Store event from 1764 arg. Call handle_one_xevent with new arglist. Store event from
633 x_session_check_input in fifo. 1765 x_session_check_input in fifo.
634 [USE_GTK]: Setup current_hold_quit. 1766 [USE_GTK]: Setup current_hold_quit.
@@ -1047,7 +2179,7 @@
1047 2179
10482004-02-09 Sam Steingold <sds@gnu.org> 21802004-02-09 Sam Steingold <sds@gnu.org>
1049 2181
1050 * w32term.c (w32_draw_fringe_bitmap): Fixed a typo in the last patch. 2182 * w32term.c (w32_draw_fringe_bitmap): Fix a typo in the last patch.
1051 2183
10522004-02-09 Kim F. Storm <storm@cua.dk> 21842004-02-09 Kim F. Storm <storm@cua.dk>
1053 2185
@@ -1181,7 +2313,7 @@
1181 completion-regexp-list. Define Qcase_fold_search and staticpro it. 2313 completion-regexp-list. Define Qcase_fold_search and staticpro it.
1182 (read_minibuf): Fix initial comment. 2314 (read_minibuf): Fix initial comment.
1183 (Ftry_completion, Fall_completions, Ftest_completion): Bind 2315 (Ftry_completion, Fall_completions, Ftest_completion): Bind
1184 case-fold-serach to the value of completion-ignore-case when 2316 case-fold-search to the value of completion-ignore-case when
1185 checking completion-regexp-list. 2317 checking completion-regexp-list.
1186 (Fdisplay_completion_list): Make it handle arguments that are 2318 (Fdisplay_completion_list): Make it handle arguments that are
1187 symbols. Doc fix. 2319 symbols. Doc fix.
@@ -1557,7 +2689,7 @@
1557 (marginal_area_string): Fix prototypes. 2689 (marginal_area_string): Fix prototypes.
1558 2690
1559 * keyboard.h (POSN_POSN, POSN_SET_POSN): Rename macros from 2691 * keyboard.h (POSN_POSN, POSN_SET_POSN): Rename macros from
1560 POSN_BUFFER_POSN and POSN_SET_BUFFER_POSN. All uses changed. 2692 POSN_BUFFER_POSN and POSN_SET_BUFFER_POSN. All uses changed.
1561 (POSN_INBUFFER_P, POSN_BUFFER_POSN): New macros. 2693 (POSN_INBUFFER_P, POSN_BUFFER_POSN): New macros.
1562 2694
1563 * keyboard.c (make_lispy_position): Use modified mode_line_string, 2695 * keyboard.c (make_lispy_position): Use modified mode_line_string,
@@ -1724,7 +2856,7 @@
1724 control frame pointer shape. Detect image hot-spots for pointer 2856 control frame pointer shape. Detect image hot-spots for pointer
1725 and help_echo properties. Use define_frame_cursor1. 2857 and help_echo properties. Use define_frame_cursor1.
1726 (note_mouse_highlight): Use Vvoid_text_area_pointer. 2858 (note_mouse_highlight): Use Vvoid_text_area_pointer.
1727 (syms_of_xdisp): Defsubr new defun. Intern and staticpro new variables. 2859 (syms_of_xdisp): Defsubr new defun. Intern and staticpro new variables.
1728 DEFVAR_LISP Vvoid_text_area_pointer instead of Vshow_text_cursor_in_void. 2860 DEFVAR_LISP Vvoid_text_area_pointer instead of Vshow_text_cursor_in_void.
1729 2861
1730 * xfaces.c (cache_face): Abort if c->size exceeds MAX_FACE_ID. 2862 * xfaces.c (cache_face): Abort if c->size exceeds MAX_FACE_ID.
@@ -1845,7 +2977,7 @@
1845 (glyph_to_pixel_coords): Don't use negative hpos. 2977 (glyph_to_pixel_coords): Don't use negative hpos.
1846 (x_y_to_hpos_vpos): Fix for partially visible first glyph. 2978 (x_y_to_hpos_vpos): Fix for partially visible first glyph.
1847 (append_stretch_glyph): Change ascent arg to be actual value 2979 (append_stretch_glyph): Change ascent arg to be actual value
1848 in pixels rather than ratio to height. Callers changed. 2980 in pixels rather than ratio to height. Callers changed.
1849 (calc_pixel_width_or_height): New aux function, implementing 2981 (calc_pixel_width_or_height): New aux function, implementing
1850 pixel based artihmetic for glyph widths and heights. 2982 pixel based artihmetic for glyph widths and heights.
1851 (produce_stretch_glyph): Use calc_pixel_width_or_height for 2983 (produce_stretch_glyph): Use calc_pixel_width_or_height for
@@ -2047,7 +3179,7 @@
2047 x_display_info_for_display instead. Use Display in xev instead 3179 x_display_info_for_display instead. Use Display in xev instead
2048 of GDK_DISPLAY. 3180 of GDK_DISPLAY.
2049 (x_dispatch_event): Call x_display_info_for_display. 3181 (x_dispatch_event): Call x_display_info_for_display.
2050 (XTread_socket): Move GTK part out of loop. current_dpyinfo removed. 3182 (XTread_socket): Move GTK part out of loop. current_dpyinfo removed.
2051 (x_connection_closed): Call xg_display_close for GTK. 3183 (x_connection_closed): Call xg_display_close for GTK.
2052 (x_term_init): Call xg_display_open for additional displays. 3184 (x_term_init): Call xg_display_open for additional displays.
2053 Initiate dpyinfo->xg_cursor with call to xg_create_default_cursor 3185 Initiate dpyinfo->xg_cursor with call to xg_create_default_cursor
@@ -2954,7 +4086,7 @@
2954 4086
29552003-07-09 Kim F. Storm <storm@cua.dk> 40872003-07-09 Kim F. Storm <storm@cua.dk>
2956 4088
2957 * xterm.c (use_xim) [!USE_XIM]: Default to disable XIM if emacs 4089 * xterm.c (use_xim) [!USE_XIM]: Default to disable XIM if Emacs
2958 was configured with --without-xim. 4090 was configured with --without-xim.
2959 (x_term_init) [!USE_XIM]: Use `useXIM' resource to turn on XIM. 4091 (x_term_init) [!USE_XIM]: Use `useXIM' resource to turn on XIM.
2960 4092
@@ -3549,7 +4681,7 @@
3549 from x/w32/macterm.h files. All uses changed. Also change code 4681 from x/w32/macterm.h files. All uses changed. Also change code
3550 which referred to f->output_data...->pixel_height. 4682 which referred to f->output_data...->pixel_height.
3551 (FRAME_PIXEL_WIDTH): Renamed from PIXEL_WIDTH and moved 4683 (FRAME_PIXEL_WIDTH): Renamed from PIXEL_WIDTH and moved
3552 from x/w32/macterm.h files. All uses changed. Also change code 4684 from x/w32/macterm.h files. All uses changed. Also change code
3553 which referred to f->output_data...->pixel_width. 4685 which referred to f->output_data...->pixel_width.
3554 (FRAME_LINES): Renamed from FRAME_HEIGHT. All uses changed. 4686 (FRAME_LINES): Renamed from FRAME_HEIGHT. All uses changed.
3555 Also change code which referred to f->height. 4687 Also change code which referred to f->height.
@@ -3811,7 +4943,7 @@
3811 window to only preserve the display margins in one of the windows. 4943 window to only preserve the display margins in one of the windows.
3812 When splitting horizontally, call adjust_window_margins on both 4944 When splitting horizontally, call adjust_window_margins on both
3813 windows to ensure that the text area of the new windows is non too 4945 windows to ensure that the text area of the new windows is non too
3814 narrow. This fixes a bug which could cause emacs to trap if the 4946 narrow. This fixes a bug which could cause Emacs to trap if the
3815 width of the split window was less than the width of the display 4947 width of the split window was less than the width of the display
3816 margins. 4948 margins.
3817 (window_box_text_cols): Renamed from window_internal_width. 4949 (window_box_text_cols): Renamed from window_internal_width.
@@ -3842,7 +4974,7 @@
3842 (Fset_window_margins): Do nothing if display margins are not 4974 (Fset_window_margins): Do nothing if display margins are not
3843 really changed. Otherwise, call adjust_window_margins to ensure 4975 really changed. Otherwise, call adjust_window_margins to ensure
3844 the text area doesn't get too narrow. This fixes a bug which 4976 the text area doesn't get too narrow. This fixes a bug which
3845 could cause emacs to trap if setting display margins wider than 4977 could cause Emacs to trap if setting display margins wider than
3846 the width of the window. 4978 the width of the window.
3847 (Fset_window_fringes): New defun to allow user to specifically set 4979 (Fset_window_fringes): New defun to allow user to specifically set
3848 this window's fringe widths and position vs. display margins. 4980 this window's fringe widths and position vs. display margins.
@@ -3859,7 +4991,7 @@
3859 * xdisp.c: Make (many) trivial substitutions for renamed and 4991 * xdisp.c: Make (many) trivial substitutions for renamed and
3860 new macros in dispextern.h, frame.h and window.h. 4992 new macros in dispextern.h, frame.h and window.h.
3861 (window_box_width): Adapt to per-window fringes and scroll bars, 4993 (window_box_width): Adapt to per-window fringes and scroll bars,
3862 and new fringe vs. display margin position. Note that returned 4994 and new fringe vs. display margin position. Note that returned
3863 value is no longer guaranteed to be a whole multiple of the frame 4995 value is no longer guaranteed to be a whole multiple of the frame
3864 column width, since per-window fringes may now be any width. 4996 column width, since per-window fringes may now be any width.
3865 (window_box_left_offset): New function like window_box_left, but 4997 (window_box_left_offset): New function like window_box_left, but
@@ -4609,7 +5741,7 @@
4609 5741
4610 * xfns.c (Qauto_raise, Qauto_lower, ...): Remove vars for frame 5742 * xfns.c (Qauto_raise, Qauto_lower, ...): Remove vars for frame
4611 parameters now defined in frame.h and frame.c. 5743 parameters now defined in frame.h and frame.c.
4612 (Vx_resource_name): Remove. Use generic var. 5744 (Vx_resource_name): Remove. Use generic var.
4613 (enum x_frame_parms): Remove (bogus, unused enum). 5745 (enum x_frame_parms): Remove (bogus, unused enum).
4614 (check_x_display_info): Make non-static (for frame.c). 5746 (check_x_display_info): Make non-static (for frame.c).
4615 (struct x_frame_parm_table, x_frame_parms): Remove. 5747 (struct x_frame_parm_table, x_frame_parms): Remove.
@@ -4629,7 +5761,7 @@
4629 (syms_of_xfns): Don't intern/staticpro removed vars. 5761 (syms_of_xfns): Don't intern/staticpro removed vars.
4630 5762
4631 * xterm.c: Remove unnecessary extern declarations. 5763 * xterm.c: Remove unnecessary extern declarations.
4632 (x_fullscreen_adjust): Remove. Use generic instead. 5764 (x_fullscreen_adjust): Remove. Use generic instead.
4633 (x_redisplay_interface): Add x_frame_parm_handlers member. 5765 (x_redisplay_interface): Add x_frame_parm_handlers member.
4634 5766
4635 * w32gui.h (XrmDatabase): New (dummy) typedef. 5767 * w32gui.h (XrmDatabase): New (dummy) typedef.
@@ -4641,7 +5773,7 @@
4641 5773
4642 * w32fns.c (Qauto_raise, Qauto_lower, ...): Remove vars for frame 5774 * w32fns.c (Qauto_raise, Qauto_lower, ...): Remove vars for frame
4643 parameters now defined in frame.h and frame.c. 5775 parameters now defined in frame.h and frame.c.
4644 (Vx_resource_name): Remove. Use generic var. 5776 (Vx_resource_name): Remove. Use generic var.
4645 (enum x_frame_parms): Remove (bogus, unused enum). 5777 (enum x_frame_parms): Remove (bogus, unused enum).
4646 (check_x_display_info): Make non-static (for frame.c). 5778 (check_x_display_info): Make non-static (for frame.c).
4647 (struct x_frame_parm_table, x_frame_parms): Remove. 5779 (struct x_frame_parm_table, x_frame_parms): Remove.
@@ -4674,7 +5806,7 @@
4674 5806
4675 * macfns.c (Qauto_raise, Qauto_lower, ...): Remove vars for frame 5807 * macfns.c (Qauto_raise, Qauto_lower, ...): Remove vars for frame
4676 parameters now defined in frame.h and frame.c. 5808 parameters now defined in frame.h and frame.c.
4677 (Vx_resource_name): Remove. Use generic var. 5809 (Vx_resource_name): Remove. Use generic var.
4678 (check_x_display_info): Make non-static (for frame.c). 5810 (check_x_display_info): Make non-static (for frame.c).
4679 (struct x_frame_parm_table, x_frame_parms): Remove. 5811 (struct x_frame_parm_table, x_frame_parms): Remove.
4680 (init_x_parm_symbols, x_set_frame_parameters, x_report_frame_params) 5812 (init_x_parm_symbols, x_set_frame_parameters, x_report_frame_params)
@@ -5655,7 +6787,7 @@
5655 [HAVE_XPM]: Avoid clashes with XColor, XImage and Pixel 6787 [HAVE_XPM]: Avoid clashes with XColor, XImage and Pixel
5656 definitions in xpm.h. 6788 definitions in xpm.h.
5657 (init_xpm_functions): New function. 6789 (init_xpm_functions): New function.
5658 (xpm_load): Sync with xfns.c. Adapt for Windows version of libXpm. 6790 (xpm_load): Sync with xfns.c. Adapt for Windows version of libXpm.
5659 (init_external_image_libraries): Try to load libXpm.dll. 6791 (init_external_image_libraries): Try to load libXpm.dll.
5660 6792
5661 * fileio.c (Fcopy_file) [WINDOWSNT]: Reverse logic for setting 6793 * fileio.c (Fcopy_file) [WINDOWSNT]: Reverse logic for setting
@@ -5684,8 +6816,8 @@
5684 * w32fns.c (DrawText): Kludge to avoid a redefinition on Windows 6816 * w32fns.c (DrawText): Kludge to avoid a redefinition on Windows
5685 when including gif_lib.h. 6817 when including gif_lib.h.
5686 (init_gif_functions, init_tiff_functions): New functions. 6818 (init_gif_functions, init_tiff_functions): New functions.
5687 (gif_load, tiff_load): Sync with xfns.c version. Adjust colors for 6819 (gif_load, tiff_load): Sync with xfns.c version. Adjust colors for
5688 Windows. Disable color table lookups. Call library functions 6820 Windows. Disable color table lookups. Call library functions
5689 through pointers determined at runtime. 6821 through pointers determined at runtime.
5690 (init_external_image_libraries): Try to load libungif.dll and 6822 (init_external_image_libraries): Try to load libungif.dll and
5691 libtiff.dll. 6823 libtiff.dll.
@@ -5751,8 +6883,8 @@
5751 6883
5752 * w32fns.c (init_jpeg_functions, jpeg_resync_to_restart_wrapper): 6884 * w32fns.c (init_jpeg_functions, jpeg_resync_to_restart_wrapper):
5753 New functions. 6885 New functions.
5754 (jpeg_load): Sync with xfns.c version. Adjust colors for Windows. 6886 (jpeg_load): Sync with xfns.c version. Adjust colors for Windows.
5755 Disable color table lookups. Call jpeg library functions 6887 Disable color table lookups. Call jpeg library functions
5756 through pointers determined at runtime. 6888 through pointers determined at runtime.
5757 (init_external_image_libraries): Try to load jpeg.dll. 6889 (init_external_image_libraries): Try to load jpeg.dll.
5758 6890
@@ -5789,8 +6921,8 @@
5789 6921
5790 * w32fns.c (XPutPixel): Handle monochrome images; used for masks. 6922 * w32fns.c (XPutPixel): Handle monochrome images; used for masks.
5791 [HAVE_PNG]: Sync with xfns.c version. 6923 [HAVE_PNG]: Sync with xfns.c version.
5792 (png_load): Adjust colors for Windows. Use Windows 6924 (png_load): Adjust colors for Windows. Use Windows
5793 bitmaps. Disable color table lookups. 6925 bitmaps. Disable color table lookups.
5794 (DEF_IMGLIB_FN, LOAD_IMGLIB_FN): New macros. 6926 (DEF_IMGLIB_FN, LOAD_IMGLIB_FN): New macros.
5795 (init_png_functions): New function. 6927 (init_png_functions): New function.
5796 (png_read_from_memory, png_load): Call png library functions 6928 (png_read_from_memory, png_load): Call png library functions
@@ -5887,7 +7019,7 @@
58872003-01-21 David Ponce <david@dponce.com> 70192003-01-21 David Ponce <david@dponce.com>
5888 7020
5889 * w32term.c (w32_encode_char): For DIM=1 charset, set 7021 * w32term.c (w32_encode_char): For DIM=1 charset, set
5890 ccl->reg[2] to -1 before calling ccl_driver. (Sync. with xterm.c 7022 ccl->reg[2] to -1 before calling ccl_driver. (Sync. with xterm.c
5891 x_encode_char change by Kenichi Handa <handa@m17n.org> on 7023 x_encode_char change by Kenichi Handa <handa@m17n.org> on
5892 2002-09-30.) 7024 2002-09-30.)
5893 (w32_draw_relief_rect): Declare all args. 7025 (w32_draw_relief_rect): Declare all args.
@@ -6420,7 +7552,7 @@
6420 only if g_b_init_get_sid_identifier_authority is equal to 0. 7552 only if g_b_init_get_sid_identifier_authority is equal to 0.
6421 On initialization set g_b_init_get_sid_identifier_authority equal to 1. 7553 On initialization set g_b_init_get_sid_identifier_authority equal to 1.
6422 7554
6423 * w32fns.c (globals_of_w32fns): New function. Used to initialize 7555 * w32fns.c (globals_of_w32fns): New function. Used to initialize
6424 those global variables that must always be initialized on startup 7556 those global variables that must always be initialized on startup
6425 even when the global variable initialized is non zero. 7557 even when the global variable initialized is non zero.
6426 Its primary purpose at this time is to initialize the global variable 7558 Its primary purpose at this time is to initialize the global variable
@@ -6431,7 +7563,7 @@
6431 7563
6432 * w32fns.c (syms_of_w32fns): Call globals_of_w32fns. 7564 * w32fns.c (syms_of_w32fns): Call globals_of_w32fns.
6433 7565
6434 * w32menu.c (globals_of_w32menu): New function. Used to 7566 * w32menu.c (globals_of_w32menu): New function. Used to
6435 initialize those global variables that must always be initialized 7567 initialize those global variables that must always be initialized
6436 on startup even when the global variable initialized is non zero. 7568 on startup even when the global variable initialized is non zero.
6437 Its primary purpose at this time is to initialize the global 7569 Its primary purpose at this time is to initialize the global
@@ -7116,7 +8248,7 @@
7116 * process.c (Fformat_network_address): New function. 8248 * process.c (Fformat_network_address): New function.
7117 (syms_of_process): Defsubr it. 8249 (syms_of_process): Defsubr it.
7118 (list_processes_1): Use it to format :local/:remote address if 8250 (list_processes_1): Use it to format :local/:remote address if
7119 service/host is not set; before emacs would crash in that case. 8251 service/host is not set; before Emacs would crash in that case.
7120 (Fmake_network_process): Don't use Ffind_operation_coding_system 8252 (Fmake_network_process): Don't use Ffind_operation_coding_system
7121 to setup coding system if host or service is not set. 8253 to setup coding system if host or service is not set.
7122 8254
@@ -7779,7 +8911,7 @@
7779 8911
7780 * msdos.c (croak): Add `void' to definition. 8912 * msdos.c (croak): Add `void' to definition.
7781 8913
7782 * sysdep.c [MSDOS] (request_sigio, unrequest_sigio): 8914 * sysdep.c (request_sigio, unrequest_sigio) [MSDOS]:
7783 Don't define them, they are defined in msdos.c. 8915 Don't define them, they are defined in msdos.c.
7784 8916
7785 * mem-limits.h [MSDOS]: Declare etext. 8917 * mem-limits.h [MSDOS]: Declare etext.
@@ -7789,7 +8921,7 @@
7789 8921
77902002-08-19 Kim F. Storm <storm@cua.dk> 89222002-08-19 Kim F. Storm <storm@cua.dk>
7791 8923
7792 * keyboard.c (Fclear_this_command_keys): Added optional arg 8924 * keyboard.c (Fclear_this_command_keys): Add optional arg
7793 KEEP-RECORD to avoid clearing lossage when we just want to clear 8925 KEEP-RECORD to avoid clearing lossage when we just want to clear
7794 the current key sequence (kmacro needs this). 8926 the current key sequence (kmacro needs this).
7795 8927
@@ -8181,12 +9313,11 @@
8181 9313
81822002-07-19 Juanma Barranquero <lektu@terra.es> 93142002-07-19 Juanma Barranquero <lektu@terra.es>
8183 9315
8184 * fileio.c (Ffile_name_as_directory): Fix argument name in docstring.
8185 (file_name_as_directory): Use literal '/' instead of DIRECTORY_SEP.
8186
8187 * xdisp.c (syms_of_xdisp): Remove redundant deprecation info. 9316 * xdisp.c (syms_of_xdisp): Remove redundant deprecation info.
8188 9317
8189 * fileio.c (syms_of_fileio): Likewise. 9318 * fileio.c (syms_of_fileio): Likewise.
9319 (Ffile_name_as_directory): Fix argument name in docstring.
9320 (file_name_as_directory): Use literal '/' instead of DIRECTORY_SEP.
8190 9321
81912002-07-18 Richard M. Stallman <rms@gnu.org> 93222002-07-18 Richard M. Stallman <rms@gnu.org>
8192 9323
@@ -8423,8 +9554,8 @@
8423 9554
84242002-07-10 Juanma Barranquero <lektu@terra.es> 95552002-07-10 Juanma Barranquero <lektu@terra.es>
8425 9556
8426 * lisp.h (SPECPDL_INDEX): Rename from BINDING_STACK_SIZE. All callers 9557 * lisp.h (SPECPDL_INDEX): Rename from BINDING_STACK_SIZE.
8427 changed. 9558 All callers changed.
8428 9559
84292002-07-09 Stefan Monnier <monnier@cs.yale.edu> 95602002-07-09 Stefan Monnier <monnier@cs.yale.edu>
8430 9561
@@ -8654,7 +9785,7 @@
86542002-06-21 Pavel Jan,Am(Bk <Pavel@Janik.cz> 97852002-06-21 Pavel Jan,Am(Bk <Pavel@Janik.cz>
8655 9786
8656 * m/pmax.h (START_FILES): Define START_FILES for NetBSD and 9787 * m/pmax.h (START_FILES): Define START_FILES for NetBSD and
8657 OpenBSD. Add support for mipseb-*-netbsd* machines. 9788 OpenBSD. Add support for mipseb-*-netbsd* machines.
8658 9789
86592002-06-17 Andrew Choi <akochoi@shaw.ca> 97902002-06-17 Andrew Choi <akochoi@shaw.ca>
8660 9791
@@ -10056,7 +11187,7 @@
10056 (server_accept_connection): New function. 11187 (server_accept_connection): New function.
10057 (wait_reading_process_input): Use it to handle incoming connects. 11188 (wait_reading_process_input): Use it to handle incoming connects.
10058 Do not enable input on a new connection if process is stopped. 11189 Do not enable input on a new connection if process is stopped.
10059 (read_process_output): Handle datagram sockets. Use 2k buffer for them. 11190 (read_process_output): Handle datagram sockets. Use 2k buffer for them.
10060 (send_process): Handle datagram sockets. 11191 (send_process): Handle datagram sockets.
10061 (Fstop_process, Fcontinue_process): Apply to network processes. A stopped 11192 (Fstop_process, Fcontinue_process): Apply to network processes. A stopped
10062 network process is indicated by setting command field to t . 11193 network process is indicated by setting command field to t .
@@ -11442,7 +12573,7 @@
114422001-12-14 Andrew Innes <andrewi@gnu.org> 125732001-12-14 Andrew Innes <andrewi@gnu.org>
11443 12574
11444 * makefile.w32-in (EMACSLOADPATH): Define. 12575 * makefile.w32-in (EMACSLOADPATH): Define.
11445 ($(EMACS)): Run `list-load-path-shadows' after dumping emacs. 12576 ($(EMACS)): Run `list-load-path-shadows' after dumping Emacs.
11446 (bootstrap-temacs): Remove dependency on bootstrap-clean. 12577 (bootstrap-temacs): Remove dependency on bootstrap-clean.
11447 12578
114482001-12-13 Eli Zaretskii <eliz@is.elta.co.il> 125792001-12-13 Eli Zaretskii <eliz@is.elta.co.il>
@@ -11642,7 +12773,7 @@
11642 12773
116432001-12-01 Jason Rumney <jasonr@gnu.org> 127742001-12-01 Jason Rumney <jasonr@gnu.org>
11644 12775
11645 * window.c (Qleft_fringe, Qright_fringe): Remove. Now in frame.c. 12776 * window.c (Qleft_fringe, Qright_fringe): Remove. Now in frame.c.
11646 12777
11647 * w32term.h (WM_MOUSELEAVE, TME_LEAVE, TRACKMOUSEEVENT) 12778 * w32term.h (WM_MOUSELEAVE, TME_LEAVE, TRACKMOUSEEVENT)
11648 [!WM_MOUSELEAVE]: Define. 12779 [!WM_MOUSELEAVE]: Define.
@@ -11694,7 +12825,7 @@
11694 12825
11695 * xterm.c (zv_height, zv_bits, zv_period): Changed zv bitmap to 12826 * xterm.c (zv_height, zv_bits, zv_period): Changed zv bitmap to
11696 fill fringe evenly with small dashes. 12827 fill fringe evenly with small dashes.
11697 (x_draw_fringe_bitmap): Clear background if necessary. Align and 12828 (x_draw_fringe_bitmap): Clear background if necessary. Align and
11698 clip the new ZV bitmap to avoid jitter between rows. 12829 clip the new ZV bitmap to avoid jitter between rows.
11699 (x_draw_row_fringe_bitmaps): Rely on x_draw_fringe_bitmap to clear 12830 (x_draw_row_fringe_bitmaps): Rely on x_draw_fringe_bitmap to clear
11700 background. Don't draw fringe bitmaps if fringe width is zero. 12831 background. Don't draw fringe bitmaps if fringe width is zero.
@@ -11759,7 +12890,7 @@
11759 menu items. From David Ponce <dponce@wanadoo.fr>. 12890 menu items. From David Ponce <dponce@wanadoo.fr>.
11760 (w32_dialog_show) [HAVE_DIALOGS]: Compile whole function 12891 (w32_dialog_show) [HAVE_DIALOGS]: Compile whole function
11761 conditionally. 12892 conditionally.
11762 (w32_menu_display_help): New argument OWNER. Rewritten to store a 12893 (w32_menu_display_help): New argument OWNER. Rewritten to store a
11763 help event in the owner frame's keyboard buffer. 12894 help event in the owner frame's keyboard buffer.
11764 12895
11765 * w32fns.c (w32_wnd_proc) <WM_MENUSELECT>: Display help directly. 12896 * w32fns.c (w32_wnd_proc) <WM_MENUSELECT>: Display help directly.
@@ -11836,9 +12967,9 @@
11836 12967
11837 * abbrev.c (Fexpand_abbrev): Use Frun_hooks instead of Vrun_hooks. 12968 * abbrev.c (Fexpand_abbrev): Use Frun_hooks instead of Vrun_hooks.
11838 12969
11839 * buffer.c (Fkill_buffer): Use Frun_hooks, not Vrun_hooks. 12970 * buffer.c (Fkill_buffer): Likewise.
11840 12971
11841 * print.c (temp_output_buffer_setup): Use Frun_hooks, not Vrun_hooks. 12972 * print.c (temp_output_buffer_setup): Likewise.
11842 12973
118432001-11-25 Stefan Monnier <monnier@cs.yale.edu> 129742001-11-25 Stefan Monnier <monnier@cs.yale.edu>
11844 12975
@@ -11875,7 +13006,7 @@
11875 (my_create_tip_window): Assign tip_window. 13006 (my_create_tip_window): Assign tip_window.
11876 (x_create_tip_frame): Use same defaults as X. 13007 (x_create_tip_frame): Use same defaults as X.
11877 (compute_tip_xy): Remove unused variable. Use full screen width. 13008 (compute_tip_xy): Remove unused variable. Use full screen width.
11878 (Fx_show_tip): Do not double height. Call ShowWindow directly. 13009 (Fx_show_tip): Do not double height. Call ShowWindow directly.
11879 13010
11880 * w32term.c (x_after_update_window_line): Doc fix. 13011 * w32term.c (x_after_update_window_line): Doc fix.
11881 (w32_read_socket): Doc fix. Avoid SET_FRAME_GARBAGED for tip 13012 (w32_read_socket): Doc fix. Avoid SET_FRAME_GARBAGED for tip
@@ -12112,9 +13243,9 @@
12112 `bitmaps': 13243 `bitmaps':
12113 13244
12114 * dispextern.h (FRINGE_FACE_ID): Renamed from BITMAP_AREA_FACE_ID. 13245 * dispextern.h (FRINGE_FACE_ID): Renamed from BITMAP_AREA_FACE_ID.
12115 Comments fixed. Use renamed symbols. 13246 Comments fixed. Use renamed symbols.
12116 13247
12117 * dispnew.c: Comment fix. Use renamed symbols. 13248 * dispnew.c: Comment fix. Use renamed symbols.
12118 13249
12119 * frame.h (FRAME_FRINGE_COLS): Renamed from FRAME_FLAGS_AREA_COLS. 13250 * frame.h (FRAME_FRINGE_COLS): Renamed from FRAME_FLAGS_AREA_COLS.
12120 (FRAME_FRINGE_WIDTH): Renamed from FRAME_FLAGS_AREA_WIDTH. 13251 (FRAME_FRINGE_WIDTH): Renamed from FRAME_FLAGS_AREA_WIDTH.
@@ -12124,13 +13255,13 @@
12124 13255
12125 * w32fns.c: Use renamed symbols. 13256 * w32fns.c: Use renamed symbols.
12126 13257
12127 * w32term.c: Comment fixes. Use renamed symbols. 13258 * w32term.c: Comment fixes. Use renamed symbols.
12128 (fringe_bitmap_type): Renamed from bitmap_type. 13259 (fringe_bitmap_type): Renamed from bitmap_type.
12129 (NO_FRINGE_BITMAP): Renamed from NO_BITMAP. 13260 (NO_FRINGE_BITMAP): Renamed from NO_BITMAP.
12130 (w32_draw_fringe_bitmap): Renamed from w32_draw_bitmap. 13261 (w32_draw_fringe_bitmap): Renamed from w32_draw_bitmap.
12131 (x_draw_row_fringe_bitmaps): Renamed from x_draw_row_bitmaps. 13262 (x_draw_row_fringe_bitmaps): Renamed from x_draw_row_bitmaps.
12132 13263
12133 * w32term.h: Comment fixes. Use renamed symbols. 13264 * w32term.h: Comment fixes. Use renamed symbols.
12134 (fringes_extra): Renamed from flags_areas_extra. 13265 (fringes_extra): Renamed from flags_areas_extra.
12135 (FRAME_FRINGE_BITMAP_WIDTH): Renamed from FRAME_FLAGS_BITMAP_WIDTH. 13266 (FRAME_FRINGE_BITMAP_WIDTH): Renamed from FRAME_FLAGS_BITMAP_WIDTH.
12136 (FRAME_FRINGE_BITMAP_HEIGHT): Renamed from FRAME_FLAGS_BITMAP_HEIGHT. 13267 (FRAME_FRINGE_BITMAP_HEIGHT): Renamed from FRAME_FLAGS_BITMAP_HEIGHT.
@@ -12143,22 +13274,22 @@
12143 13274
12144 * widget.c: Use renamed symbols. 13275 * widget.c: Use renamed symbols.
12145 13276
12146 * window.c: Comment fixes. Use renamed symbols. 13277 * window.c: Comment fixes. Use renamed symbols.
12147 (coordinates-in-window-p): Doc fix. 13278 (coordinates-in-window-p): Doc fix.
12148 13279
12149 * xdisp.c: Comment fixes. Use renamed symbols. 13280 * xdisp.c: Comment fixes. Use renamed symbols.
12150 13281
12151 * xfaces.c (realize_basic_faces): Use FRINGE_FACE_ID. 13282 * xfaces.c (realize_basic_faces): Use FRINGE_FACE_ID.
12152 13283
12153 * xfns.c: Use renamed symbols. 13284 * xfns.c: Use renamed symbols.
12154 13285
12155 * xterm.c: Comment fixes. Use renamed symbols. 13286 * xterm.c: Comment fixes. Use renamed symbols.
12156 (fringe_bitmap_type): Renamed from bitmap_type. 13287 (fringe_bitmap_type): Renamed from bitmap_type.
12157 (NO_FRINGE_BITMAP): Renamed from NO_BITMAP. 13288 (NO_FRINGE_BITMAP): Renamed from NO_BITMAP.
12158 (x_draw_fringe_bitmap): Renamed from x_draw_bitmap. 13289 (x_draw_fringe_bitmap): Renamed from x_draw_bitmap.
12159 (x_draw_row_fringe_bitmaps): Renamed from x_draw_row_bitmaps. 13290 (x_draw_row_fringe_bitmaps): Renamed from x_draw_row_bitmaps.
12160 13291
12161 * xterm.h: Comment fixes. Use renamed symbols. 13292 * xterm.h: Comment fixes. Use renamed symbols.
12162 (fringes_extra): Renamed from flags_areas_extra. 13293 (fringes_extra): Renamed from flags_areas_extra.
12163 (FRAME_FRINGE_BITMAP_WIDTH): Renamed from FRAME_FLAGS_BITMAP_WIDTH. 13294 (FRAME_FRINGE_BITMAP_WIDTH): Renamed from FRAME_FLAGS_BITMAP_WIDTH.
12164 (FRAME_FRINGE_BITMAP_HEIGHT): Renamed from FRAME_FLAGS_BITMAP_HEIGHT. 13295 (FRAME_FRINGE_BITMAP_HEIGHT): Renamed from FRAME_FLAGS_BITMAP_HEIGHT.
@@ -12276,8 +13407,8 @@
122762001-11-12 Jason Rumney <jasonr@gnu.org> 134072001-11-12 Jason Rumney <jasonr@gnu.org>
12277 13408
12278 * w32console.c, w32fns.c, w32menu.c, w32proc.c, w32select.c, 13409 * w32console.c, w32fns.c, w32menu.c, w32proc.c, w32select.c,
12279 * w32term.c: Change doc-string comments to `new style'. 13410 * w32term.c: Change doc-string comments to `new style'
12280 [w/`doc:' keyword]. Doc fixes. 13411 [w/`doc:' keyword]. Doc fixes.
12281 13412
12282 * w32fns.c: Don't define max. 13413 * w32fns.c: Don't define max.
12283 (Fx_open_connection): Only execute once. 13414 (Fx_open_connection): Only execute once.
@@ -12312,7 +13443,7 @@
123122001-11-10 Jason Rumney <jasonr@gnu.org> 134432001-11-10 Jason Rumney <jasonr@gnu.org>
12313 13444
12314 * w32fns.c (enum_font_cb2): Use leading @ on face name to detect 13445 * w32fns.c (enum_font_cb2): Use leading @ on face name to detect
12315 vertical fonts. Allow them if face name is explicitly specified. 13446 vertical fonts. Allow them if face name is explicitly specified.
12316 Do not give up if we find a font that cannot be converted to an xlfd. 13447 Do not give up if we find a font that cannot be converted to an xlfd.
12317 13448
123182001-11-10 Gerd Moellmann <gerd@gnu.org> 134492001-11-10 Gerd Moellmann <gerd@gnu.org>
@@ -12739,7 +13870,7 @@
12739 13870
127402001-10-28 Pavel Jan,Am(Bk <Pavel@Janik.cz> 138712001-10-28 Pavel Jan,Am(Bk <Pavel@Janik.cz>
12741 13872
12742 * emacs.c: Use argv[0] instead of emacs when -t was specified. 13873 * emacs.c: Use argv[0] instead of "emacs" when -t was specified.
12743 13874
12744 * keyboard.c: Change doc-string comments to `new style' [w/`doc:' 13875 * keyboard.c: Change doc-string comments to `new style' [w/`doc:'
12745 keyword]. 13876 keyword].
@@ -13122,7 +14253,7 @@
13122 full-width rows. 14253 full-width rows.
13123 (x_dump_glyph_string): Put in #if GLYPH_DEBUG. 14254 (x_dump_glyph_string): Put in #if GLYPH_DEBUG.
13124 (w32_draw_relief_rect): Extend left shadow to the bottom and left; 14255 (w32_draw_relief_rect): Extend left shadow to the bottom and left;
13125 change bottom shadow accordingly. Some cleanup. 14256 change bottom shadow accordingly. Some cleanup.
13126 (x_update_window_end): Handle overwritten mouse face 14257 (x_update_window_end): Handle overwritten mouse face
13127 also for tool bar windows. 14258 also for tool bar windows.
13128 (show_mouse_face): Set the glyph row's mouse_face_p flag also when 14259 (show_mouse_face): Set the glyph row's mouse_face_p flag also when
@@ -13168,7 +14299,7 @@
13168 (Fv_max_tooltip_size): New variable. 14299 (Fv_max_tooltip_size): New variable.
13169 (syns_of_xfns): DEFVAR_LISP it. 14300 (syns_of_xfns): DEFVAR_LISP it.
13170 (Fx_show_tip): Add parameter TEXT. Set the tip frame's root 14301 (Fx_show_tip): Add parameter TEXT. Set the tip frame's root
13171 window buffer to *tip* right after creating the frame. Set frame's 14302 window buffer to *tip* right after creating the frame. Set frame's
13172 window_width. Use a maximum tooltip size specified by 14303 window_width. Use a maximum tooltip size specified by
13173 Vx_max_tooltip_size, if that has valid contents. 14304 Vx_max_tooltip_size, if that has valid contents.
13174 (compute_tip_xy): Add parameters WIDTH and HEIGHT. 14305 (compute_tip_xy): Add parameters WIDTH and HEIGHT.
diff --git a/src/abbrev.c b/src/abbrev.c
index 54ea8f1128e..086a58021fb 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -1,5 +1,5 @@
1/* Primitives for word-abbrev mode. 1/* Primitives for word-abbrev mode.
2 Copyright (C) 1985, 1986, 1993, 1996, 1998, 2001 2 Copyright (C) 1985, 1986, 1993, 1996, 1998, 2001,02,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
diff --git a/src/alloc.c b/src/alloc.c
index e427c1f5676..ea7886dd4dc 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -155,6 +155,7 @@ int malloc_sbrk_unused;
155 155
156EMACS_INT undo_limit; 156EMACS_INT undo_limit;
157EMACS_INT undo_strong_limit; 157EMACS_INT undo_strong_limit;
158EMACS_INT undo_outer_limit;
158 159
159/* Number of live and free conses etc. */ 160/* Number of live and free conses etc. */
160 161
@@ -256,6 +257,7 @@ EMACS_INT gcs_done; /* accumulated GCs */
256 257
257static void mark_buffer P_ ((Lisp_Object)); 258static void mark_buffer P_ ((Lisp_Object));
258extern void mark_kboards P_ ((void)); 259extern void mark_kboards P_ ((void));
260extern void mark_backtrace P_ ((void));
259static void gc_sweep P_ ((void)); 261static void gc_sweep P_ ((void));
260static void mark_glyph_matrix P_ ((struct glyph_matrix *)); 262static void mark_glyph_matrix P_ ((struct glyph_matrix *));
261static void mark_face_cache P_ ((struct face_cache *)); 263static void mark_face_cache P_ ((struct face_cache *));
@@ -753,17 +755,20 @@ lisp_align_malloc (nbytes, type)
753#ifdef HAVE_POSIX_MEMALIGN 755#ifdef HAVE_POSIX_MEMALIGN
754 { 756 {
755 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); 757 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
756 abase = err ? (base = NULL) : base; 758 if (err)
759 base = NULL;
760 abase = base;
757 } 761 }
758#else 762#else
759 base = malloc (ABLOCKS_BYTES); 763 base = malloc (ABLOCKS_BYTES);
760 abase = ALIGN (base, BLOCK_ALIGN); 764 abase = ALIGN (base, BLOCK_ALIGN);
765#endif
766
761 if (base == 0) 767 if (base == 0)
762 { 768 {
763 UNBLOCK_INPUT; 769 UNBLOCK_INPUT;
764 memory_full (); 770 memory_full ();
765 } 771 }
766#endif
767 772
768 aligned = (base == abase); 773 aligned = (base == abase);
769 if (!aligned) 774 if (!aligned)
@@ -844,7 +849,7 @@ lisp_align_free (block)
844 free_ablock = ablock; 849 free_ablock = ablock;
845 /* Update busy count. */ 850 /* Update busy count. */
846 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase)); 851 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase));
847 852
848 if (2 > (long) ABLOCKS_BUSY (abase)) 853 if (2 > (long) ABLOCKS_BUSY (abase))
849 { /* All the blocks are free. */ 854 { /* All the blocks are free. */
850 int i = 0, aligned = (long) ABLOCKS_BUSY (abase); 855 int i = 0, aligned = (long) ABLOCKS_BUSY (abase);
@@ -1893,8 +1898,9 @@ compact_small_strings ()
1893 1898
1894 1899
1895DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, 1900DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
1896 doc: /* Return a newly created string of length LENGTH, with each element being INIT. 1901 doc: /* Return a newly created string of length LENGTH, with INIT in each element.
1897Both LENGTH and INIT must be numbers. */) 1902LENGTH must be an integer.
1903INIT must be an integer that represents a character. */)
1898 (length, init) 1904 (length, init)
1899 Lisp_Object length, init; 1905 Lisp_Object length, init;
1900{ 1906{
@@ -1949,10 +1955,11 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
1949 1955
1950 CHECK_NATNUM (length); 1956 CHECK_NATNUM (length);
1951 1957
1952 bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR; 1958 bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR;
1953 1959
1954 length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; 1960 length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value;
1955 length_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) / BITS_PER_CHAR); 1961 length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1)
1962 / BOOL_VECTOR_BITS_PER_CHAR);
1956 1963
1957 /* We must allocate one more elements than LENGTH_IN_ELTS for the 1964 /* We must allocate one more elements than LENGTH_IN_ELTS for the
1958 slot `size' of the struct Lisp_Bool_Vector. */ 1965 slot `size' of the struct Lisp_Bool_Vector. */
@@ -1969,9 +1976,9 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
1969 p->data[i] = real_init; 1976 p->data[i] = real_init;
1970 1977
1971 /* Clear the extraneous bits in the last byte. */ 1978 /* Clear the extraneous bits in the last byte. */
1972 if (XINT (length) != length_in_chars * BITS_PER_CHAR) 1979 if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR)
1973 XBOOL_VECTOR (val)->data[length_in_chars - 1] 1980 XBOOL_VECTOR (val)->data[length_in_chars - 1]
1974 &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; 1981 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
1975 1982
1976 return val; 1983 return val;
1977} 1984}
@@ -2333,7 +2340,6 @@ free_cons (ptr)
2333 cons_free_list = ptr; 2340 cons_free_list = ptr;
2334} 2341}
2335 2342
2336
2337DEFUN ("cons", Fcons, Scons, 2, 2, 0, 2343DEFUN ("cons", Fcons, Scons, 2, 2, 0,
2338 doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) 2344 doc: /* Create a new cons, give it CAR and CDR as components, and return it. */)
2339 (car, cdr) 2345 (car, cdr)
@@ -4233,18 +4239,6 @@ struct catchtag
4233 struct catchtag *next; 4239 struct catchtag *next;
4234}; 4240};
4235 4241
4236struct backtrace
4237{
4238 struct backtrace *next;
4239 Lisp_Object *function;
4240 Lisp_Object *args; /* Points to vector of args. */
4241 int nargs; /* Length of vector. */
4242 /* If nargs is UNEVALLED, args points to slot holding list of
4243 unevalled args. */
4244 char evalargs;
4245};
4246
4247
4248 4242
4249/*********************************************************************** 4243/***********************************************************************
4250 Protection from GC 4244 Protection from GC
@@ -4279,7 +4273,6 @@ returns nil, because real GC can't be done. */)
4279 register struct specbinding *bind; 4273 register struct specbinding *bind;
4280 struct catchtag *catch; 4274 struct catchtag *catch;
4281 struct handler *handler; 4275 struct handler *handler;
4282 register struct backtrace *backlist;
4283 char stack_top_variable; 4276 char stack_top_variable;
4284 register int i; 4277 register int i;
4285 int message_p; 4278 int message_p;
@@ -4348,7 +4341,7 @@ returns nil, because real GC can't be done. */)
4348 if (! EQ (nextb->undo_list, Qt)) 4341 if (! EQ (nextb->undo_list, Qt))
4349 nextb->undo_list 4342 nextb->undo_list
4350 = truncate_undo_list (nextb->undo_list, undo_limit, 4343 = truncate_undo_list (nextb->undo_list, undo_limit,
4351 undo_strong_limit); 4344 undo_strong_limit, undo_outer_limit);
4352 4345
4353 /* Shrink buffer gaps, but skip indirect and dead buffers. */ 4346 /* Shrink buffer gaps, but skip indirect and dead buffers. */
4354 if (nextb->base_buffer == 0 && !NILP (nextb->name)) 4347 if (nextb->base_buffer == 0 && !NILP (nextb->name))
@@ -4408,20 +4401,23 @@ returns nil, because real GC can't be done. */)
4408 mark_object (handler->handler); 4401 mark_object (handler->handler);
4409 mark_object (handler->var); 4402 mark_object (handler->var);
4410 } 4403 }
4411 for (backlist = backtrace_list; backlist; backlist = backlist->next) 4404 mark_backtrace ();
4412 {
4413 mark_object (*backlist->function);
4414
4415 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
4416 i = 0;
4417 else
4418 i = backlist->nargs - 1;
4419 for (; i >= 0; i--)
4420 mark_object (backlist->args[i]);
4421 }
4422 mark_kboards (); 4405 mark_kboards ();
4423 4406
4424 /* Look thru every buffer's undo list 4407#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
4408 mark_stack ();
4409#endif
4410
4411#ifdef USE_GTK
4412 {
4413 extern void xg_mark_data ();
4414 xg_mark_data ();
4415 }
4416#endif
4417
4418 /* Everything is now marked, except for the things that require special
4419 finalization, i.e. the undo_list.
4420 Look thru every buffer's undo list
4425 for elements that update markers that were not marked, 4421 for elements that update markers that were not marked,
4426 and delete them. */ 4422 and delete them. */
4427 { 4423 {
@@ -4459,22 +4455,14 @@ returns nil, because real GC can't be done. */)
4459 } 4455 }
4460 } 4456 }
4461 } 4457 }
4458 /* Now that we have stripped the elements that need not be in the
4459 undo_list any more, we can finally mark the list. */
4460 mark_object (nextb->undo_list);
4462 4461
4463 nextb = nextb->next; 4462 nextb = nextb->next;
4464 } 4463 }
4465 } 4464 }
4466 4465
4467#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
4468 mark_stack ();
4469#endif
4470
4471#ifdef USE_GTK
4472 {
4473 extern void xg_mark_data ();
4474 xg_mark_data ();
4475 }
4476#endif
4477
4478 gc_sweep (); 4466 gc_sweep ();
4479 4467
4480 /* Clear the mark bits that we set in certain root slots. */ 4468 /* Clear the mark bits that we set in certain root slots. */
@@ -5043,41 +5031,9 @@ mark_buffer (buf)
5043 5031
5044 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); 5032 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer));
5045 5033
5046 if (CONSP (buffer->undo_list)) 5034 /* For now, we just don't mark the undo_list. It's done later in
5047 { 5035 a special way just before the sweep phase, and after stripping
5048 Lisp_Object tail; 5036 some of its elements that are not needed any more. */
5049 tail = buffer->undo_list;
5050
5051 /* We mark the undo list specially because
5052 its pointers to markers should be weak. */
5053
5054 while (CONSP (tail))
5055 {
5056 register struct Lisp_Cons *ptr = XCONS (tail);
5057
5058 if (CONS_MARKED_P (ptr))
5059 break;
5060 CONS_MARK (ptr);
5061 if (GC_CONSP (ptr->car)
5062 && !CONS_MARKED_P (XCONS (ptr->car))
5063 && GC_MARKERP (XCAR (ptr->car)))
5064 {
5065 CONS_MARK (XCONS (ptr->car));
5066 mark_object (XCDR (ptr->car));
5067 }
5068 else
5069 mark_object (ptr->car);
5070
5071 if (CONSP (ptr->cdr))
5072 tail = ptr->cdr;
5073 else
5074 break;
5075 }
5076
5077 mark_object (XCDR (tail));
5078 }
5079 else
5080 mark_object (buffer->undo_list);
5081 5037
5082 if (buffer->overlays_before) 5038 if (buffer->overlays_before)
5083 { 5039 {
@@ -5671,12 +5627,20 @@ which includes both saved text and other data. */);
5671 5627
5672 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, 5628 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
5673 doc: /* Don't keep more than this much size of undo information. 5629 doc: /* Don't keep more than this much size of undo information.
5674A command which pushes past this size is itself forgotten. 5630A previous command which pushes the undo list past this size
5675This limit is applied when garbage collection happens. 5631is entirely forgotten when GC happens.
5676The size is counted as the number of bytes occupied, 5632The size is counted as the number of bytes occupied,
5677which includes both saved text and other data. */); 5633which includes both saved text and other data. */);
5678 undo_strong_limit = 30000; 5634 undo_strong_limit = 30000;
5679 5635
5636 DEFVAR_INT ("undo-outer-limit", &undo_outer_limit,
5637 doc: /* Don't keep more than this much size of undo information.
5638If the current command has produced more than this much undo information,
5639GC discards it. This is a last-ditch limit to prevent memory overflow.
5640The size is counted as the number of bytes occupied,
5641which includes both saved text and other data. */);
5642 undo_outer_limit = 300000;
5643
5680 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, 5644 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
5681 doc: /* Non-nil means display messages at start and end of garbage collection. */); 5645 doc: /* Non-nil means display messages at start and end of garbage collection. */);
5682 garbage_collection_messages = 0; 5646 garbage_collection_messages = 0;
diff --git a/src/atimer.c b/src/atimer.c
index 2ddc7427f56..7e78bdad9c0 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -1,5 +1,5 @@
1/* Asynchronous timers. 1/* Asynchronous timers.
2 Copyright (C) 2000 Free Software Foundation, Inc. 2 Copyright (C) 2000, 2004 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/atimer.h b/src/atimer.h
index 3ecc97e5511..f987a47a6bd 100644
--- a/src/atimer.h
+++ b/src/atimer.h
@@ -1,5 +1,5 @@
1/* Asynchronous timers. 1/* Asynchronous timers.
2 Copyright (C) 2000 Free Software Foundation, Inc. 2 Copyright (C) 2000, 2003 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/blockinput.h b/src/blockinput.h
index eba192c9863..a4c8a9b9c22 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -1,5 +1,5 @@
1/* blockinput.h - interface to blocking complicated interrupt-driven input. 1/* blockinput.h - interface to blocking complicated interrupt-driven input.
2 Copyright (C) 1989, 1993 Free Software Foundation, Inc. 2 Copyright (C) 1989, 1993, 2004 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -97,6 +97,9 @@ extern int pending_atimers;
97#define TOTALLY_UNBLOCK_INPUT (interrupt_input_blocked = 0) 97#define TOTALLY_UNBLOCK_INPUT (interrupt_input_blocked = 0)
98#define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT 98#define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
99 99
100/* In critical section ? */
101#define INPUT_BLOCKED_P (interrupt_input_blocked > 0)
102
100/* Defined in keyboard.c */ 103/* Defined in keyboard.c */
101/* Don't use a prototype here; it causes trouble in some files. */ 104/* Don't use a prototype here; it causes trouble in some files. */
102extern void reinvoke_input_signal (); 105extern void reinvoke_input_signal ();
diff --git a/src/buffer.c b/src/buffer.c
index 4c7e709adb5..bd4e061b05f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -488,7 +488,7 @@ static void
488clone_per_buffer_values (from, to) 488clone_per_buffer_values (from, to)
489 struct buffer *from, *to; 489 struct buffer *from, *to;
490{ 490{
491 Lisp_Object to_buffer; 491 Lisp_Object to_buffer, tem;
492 int offset; 492 int offset;
493 493
494 XSETBUFFER (to_buffer, to); 494 XSETBUFFER (to_buffer, to);
@@ -515,6 +515,14 @@ clone_per_buffer_values (from, to)
515 515
516 to->overlays_before = copy_overlays (to, from->overlays_before); 516 to->overlays_before = copy_overlays (to, from->overlays_before);
517 to->overlays_after = copy_overlays (to, from->overlays_after); 517 to->overlays_after = copy_overlays (to, from->overlays_after);
518
519 /* Copy the alist of local variables,
520 and all the alist elements too. */
521 to->local_var_alist
522 = Fcopy_sequence (from->local_var_alist);
523 for (tem = to->local_var_alist; CONSP (tem);
524 tem = XCDR (tem))
525 XSETCAR (tem, Fcons (XCAR (XCAR (tem)), XCDR (XCAR (tem))));
518} 526}
519 527
520 528
@@ -833,7 +841,8 @@ No argument or nil as argument means use the current buffer. */)
833DEFUN ("buffer-base-buffer", Fbuffer_base_buffer, Sbuffer_base_buffer, 841DEFUN ("buffer-base-buffer", Fbuffer_base_buffer, Sbuffer_base_buffer,
834 0, 1, 0, 842 0, 1, 0,
835 doc: /* Return the base buffer of indirect buffer BUFFER. 843 doc: /* Return the base buffer of indirect buffer BUFFER.
836If BUFFER is not indirect, return nil. */) 844If BUFFER is not indirect, return nil.
845BUFFER defaults to the current buffer. */)
837 (buffer) 846 (buffer)
838 register Lisp_Object buffer; 847 register Lisp_Object buffer;
839{ 848{
@@ -1683,7 +1692,7 @@ DEFUN ("pop-to-buffer", Fpop_to_buffer, Spop_to_buffer, 1, 3, 0,
1683 doc: /* Select buffer BUFFER in some window, preferably a different one. 1692 doc: /* Select buffer BUFFER in some window, preferably a different one.
1684If BUFFER is nil, then some other buffer is chosen. 1693If BUFFER is nil, then some other buffer is chosen.
1685If `pop-up-windows' is non-nil, windows can be split to do this. 1694If `pop-up-windows' is non-nil, windows can be split to do this.
1686If optional second arg OTHER-WINDOW is nil, insist on finding another 1695If optional second arg OTHER-WINDOW is non-nil, insist on finding another
1687window even if BUFFER is already visible in the selected window, 1696window even if BUFFER is already visible in the selected window,
1688and ignore `same-window-regexps' and `same-window-buffer-names'. 1697and ignore `same-window-regexps' and `same-window-buffer-names'.
1689This uses the function `display-buffer' as a subroutine; see the documentation 1698This uses the function `display-buffer' as a subroutine; see the documentation
@@ -2145,7 +2154,7 @@ current buffer is cleared. */)
2145 GPT = GPT_BYTE; 2154 GPT = GPT_BYTE;
2146 TEMP_SET_PT_BOTH (PT_BYTE, PT_BYTE); 2155 TEMP_SET_PT_BOTH (PT_BYTE, PT_BYTE);
2147 2156
2148 2157
2149 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) 2158 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
2150 tail->charpos = tail->bytepos; 2159 tail->charpos = tail->bytepos;
2151 2160
@@ -3354,7 +3363,7 @@ fix_start_end_in_overlays (start, end)
3354 3363
3355 if (endpos < start) 3364 if (endpos < start)
3356 break; 3365 break;
3357 3366
3358 if (endpos < end 3367 if (endpos < end
3359 || (startpos >= start && startpos < end)) 3368 || (startpos >= start && startpos < end))
3360 { 3369 {
@@ -3397,7 +3406,7 @@ fix_start_end_in_overlays (start, end)
3397 { 3406 {
3398 startpos = endpos; 3407 startpos = endpos;
3399 Fset_marker (OVERLAY_START (overlay), make_number (startpos), 3408 Fset_marker (OVERLAY_START (overlay), make_number (startpos),
3400 Qnil); 3409 Qnil);
3401 } 3410 }
3402 3411
3403 if (startpos >= end) 3412 if (startpos >= end)
@@ -4208,7 +4217,7 @@ report_overlay_modification (start, end, after, arg1, arg2, arg3)
4208 add_overlay_mod_hooklist (prop, overlay); 4217 add_overlay_mod_hooklist (prop, overlay);
4209 } 4218 }
4210 } 4219 }
4211 4220
4212 for (tail = current_buffer->overlays_after; tail; tail = tail->next) 4221 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
4213 { 4222 {
4214 int startpos, endpos; 4223 int startpos, endpos;
@@ -5444,7 +5453,7 @@ nil here means use current buffer's major mode. */);
5444 DEFVAR_PER_BUFFER ("fill-column", &current_buffer->fill_column, 5453 DEFVAR_PER_BUFFER ("fill-column", &current_buffer->fill_column,
5445 make_number (Lisp_Int), 5454 make_number (Lisp_Int),
5446 doc: /* *Column beyond which automatic line-wrapping should happen. 5455 doc: /* *Column beyond which automatic line-wrapping should happen.
5447Interactively, you can set this using \\[set-fill-column]. */); 5456Interactively, you can set the buffer local value using \\[set-fill-column]. */);
5448 5457
5449 DEFVAR_PER_BUFFER ("left-margin", &current_buffer->left_margin, 5458 DEFVAR_PER_BUFFER ("left-margin", &current_buffer->left_margin,
5450 make_number (Lisp_Int), 5459 make_number (Lisp_Int),
@@ -5854,7 +5863,11 @@ If the buffer has never been shown in a window, the value is nil. */);
5854 doc: /* *Non-nil means deactivate the mark when the buffer contents change. 5863 doc: /* *Non-nil means deactivate the mark when the buffer contents change.
5855Non-nil also enables highlighting of the region whenever the mark is active. 5864Non-nil also enables highlighting of the region whenever the mark is active.
5856The variable `highlight-nonselected-windows' controls whether to highlight 5865The variable `highlight-nonselected-windows' controls whether to highlight
5857all windows or just the selected window. */); 5866all windows or just the selected window.
5867
5868If the value is `lambda', that enables Transient Mark mode temporarily
5869until the next buffer modification. If a command sets the value to `only',
5870that enables Transient Mark mode for the following command only. */);
5858 Vtransient_mark_mode = Qnil; 5871 Vtransient_mark_mode = Qnil;
5859 5872
5860 DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only, 5873 DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only,
@@ -5871,9 +5884,13 @@ Values are interpreted as follows:
5871 5884
5872 t use the cursor specified for the frame 5885 t use the cursor specified for the frame
5873 nil don't display a cursor 5886 nil don't display a cursor
5874 bar display a bar cursor with default width 5887 box display a filled box cursor
5875 (bar . WIDTH) display a bar cursor with width WIDTH 5888 hollow display a hollow box cursor
5876 ANYTHING ELSE display a box cursor. 5889 bar display a vertical bar cursor with default width
5890 (bar . WIDTH) display a vertical bar cursor with width WIDTH
5891 hbar display a horisontal bar cursor with default width
5892 (hbar . WIDTH) display a horisontal bar cursor with width WIDTH
5893 ANYTHING ELSE display a hollow box cursor.
5877 5894
5878When the buffer is displayed in a nonselected window, 5895When the buffer is displayed in a nonselected window,
5879this variable has no effect; the cursor appears as a hollow box. */); 5896this variable has no effect; the cursor appears as a hollow box. */);
@@ -5881,7 +5898,9 @@ this variable has no effect; the cursor appears as a hollow box. */);
5881 DEFVAR_PER_BUFFER ("line-spacing", 5898 DEFVAR_PER_BUFFER ("line-spacing",
5882 &current_buffer->extra_line_spacing, Qnil, 5899 &current_buffer->extra_line_spacing, Qnil,
5883 doc: /* Additional space to put between lines when displaying a buffer. 5900 doc: /* Additional space to put between lines when displaying a buffer.
5884The space is measured in pixels, and put below lines on window systems. */); 5901The space is measured in pixels, and put below lines on window systems.
5902If value is a floating point number, it specifies the spacing relative
5903to the default frame line height. */);
5885 5904
5886 DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions, 5905 DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions,
5887 doc: /* List of functions called with no args to query before killing a buffer. */); 5906 doc: /* List of functions called with no args to query before killing a buffer. */);
diff --git a/src/buffer.h b/src/buffer.h
index 0755db25f9f..47f00560824 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,5 +1,5 @@
1/* Header file for the buffer manipulation primitives. 1/* Header file for the buffer manipulation primitives.
2 Copyright (C) 1985, 86, 93, 94, 95, 97, 1998, 1999, 2000, 01, 2003 2 Copyright (C) 1985,86,93,94,95,97,98,99,2000,01,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -827,6 +827,25 @@ extern void buffer_slot_type_mismatch P_ ((int));
827extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT)); 827extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT));
828extern void mmap_set_vars P_ ((int)); 828extern void mmap_set_vars P_ ((int));
829 829
830/* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements.
831 If NEXTP is non-NULL, return next overlay there.
832 See overlay_at arg CHANGE_REQ for meaning of CHRQ arg. */
833
834#define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \
835 do { \
836 int maxlen = 40; \
837 overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \
838 noverlays = overlays_at (posn, 0, &overlays, &maxlen, \
839 nextp, NULL, chrq); \
840 if (noverlays > maxlen) \
841 { \
842 maxlen = noverlays; \
843 overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \
844 noverlays = overlays_at (posn, 0, &overlays, &maxlen, \
845 nextp, NULL, chrq); \
846 } \
847 } while (0)
848
830EXFUN (Fbuffer_live_p, 1); 849EXFUN (Fbuffer_live_p, 1);
831EXFUN (Fbuffer_name, 1); 850EXFUN (Fbuffer_name, 1);
832EXFUN (Fget_file_buffer, 1); 851EXFUN (Fget_file_buffer, 1);
diff --git a/src/callint.c b/src/callint.c
index 50090db8b28..a3e4984fd16 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -612,7 +612,7 @@ supply if the command inquires which events were used to invoke it. */)
612 Qnil, Qnil, Qnil, Qnil); 612 Qnil, Qnil, Qnil, Qnil);
613 unbind_to (speccount1, Qnil); 613 unbind_to (speccount1, Qnil);
614 teml = args[i]; 614 teml = args[i];
615 visargs[i] = Fkey_description (teml); 615 visargs[i] = Fkey_description (teml, Qnil);
616 616
617 /* If the key sequence ends with a down-event, 617 /* If the key sequence ends with a down-event,
618 discard the following up-event. */ 618 discard the following up-event. */
@@ -639,7 +639,7 @@ supply if the command inquires which events were used to invoke it. */)
639 args[i] = Fread_key_sequence (build_string (callint_message), 639 args[i] = Fread_key_sequence (build_string (callint_message),
640 Qnil, Qt, Qnil, Qnil); 640 Qnil, Qt, Qnil, Qnil);
641 teml = args[i]; 641 teml = args[i];
642 visargs[i] = Fkey_description (teml); 642 visargs[i] = Fkey_description (teml, Qnil);
643 unbind_to (speccount1, Qnil); 643 unbind_to (speccount1, Qnil);
644 644
645 /* If the key sequence ends with a down-event, 645 /* If the key sequence ends with a down-event,
diff --git a/src/callproc.c b/src/callproc.c
index 2b610d53a1d..7632d491944 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1,5 +1,5 @@
1/* Synchronous subprocess invocation for GNU Emacs. 1/* Synchronous subprocess invocation for GNU Emacs.
2 Copyright (C) 1985,86,87,88,93,94,95,99, 2000, 2001 2 Copyright (C) 1985,86,87,88,93,94,95,99, 2000,01,02,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -222,7 +222,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
222 register int pid; 222 register int pid;
223 char buf[16384]; 223 char buf[16384];
224 char *bufptr = buf; 224 char *bufptr = buf;
225 int bufsize = 16384; 225 int bufsize = sizeof buf;
226 int count = SPECPDL_INDEX (); 226 int count = SPECPDL_INDEX ();
227 227
228 register const unsigned char **new_argv 228 register const unsigned char **new_argv
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 341e3b313a3..4b38e441cf3 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -1,5 +1,6 @@
1/* GNU Emacs case conversion functions. 1/* GNU Emacs case conversion functions.
2 Copyright (C) 1985, 1994, 1997 Free Software Foundation, Inc. 2 Copyright (C) 1985,94,97,98,99, 2001, 2002, 2004
3 Free Software Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -53,11 +54,19 @@ casify_object (flag, obj)
53 int flags = XINT (obj) & flagbits; 54 int flags = XINT (obj) & flagbits;
54 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 55 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
55 56
57 /* If the character has higher bits set
58 above the flags, return it unchanged.
59 It is not a real character. */
60 if ((unsigned) XFASTINT (obj) > (unsigned) flagbits)
61 return obj;
62
56 c1 = XFASTINT (obj) & ~flagbits; 63 c1 = XFASTINT (obj) & ~flagbits;
57 if (! multibyte) 64 if (! multibyte)
58 MAKE_CHAR_MULTIBYTE (c1); 65 MAKE_CHAR_MULTIBYTE (c1);
59 c = DOWNCASE (c1); 66 c = DOWNCASE (c1);
60 if (inword || c == c1) 67 if (inword)
68 XSETFASTINT (obj, c | flags);
69 else if (c == (XFASTINT (obj) & ~flagbits))
61 { 70 {
62 if (! inword) 71 if (! inword)
63 c = UPCASE1 (c1); 72 c = UPCASE1 (c1);
diff --git a/src/ccl.c b/src/ccl.c
index 5eac485bf2c..71a08fdf7c7 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -634,14 +634,17 @@ do \
634 { \ 634 { \
635 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \ 635 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \
636 ic = ccl_prog_stack_struct[0].ic; \ 636 ic = ccl_prog_stack_struct[0].ic; \
637 eof_ic = ccl_prog_stack_struct[0].eof_ic; \
637 } \ 638 } \
638 CCL_INVALID_CMD; \ 639 CCL_INVALID_CMD; \
639 } \ 640 } \
640 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \ 641 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \
641 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \ 642 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \
643 ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic; \
642 stack_idx++; \ 644 stack_idx++; \
643 ccl_prog = called_ccl.prog; \ 645 ccl_prog = called_ccl.prog; \
644 ic = CCL_HEADER_MAIN; \ 646 ic = CCL_HEADER_MAIN; \
647 eof_ic = XFASTINT (ccl_prog[CCL_HEADER_EOF]); \
645 goto ccl_repeat; \ 648 goto ccl_repeat; \
646 } \ 649 } \
647while (0) 650while (0)
@@ -718,14 +721,29 @@ while (0)
718 721
719/* Terminate CCL program because of invalid command. Should not occur 722/* Terminate CCL program because of invalid command. Should not occur
720 in the normal case. */ 723 in the normal case. */
724#ifndef CCL_DEBUG
725
726#define CCL_INVALID_CMD \
727do \
728 { \
729 ccl->status = CCL_STAT_INVALID_CMD; \
730 goto ccl_error_handler; \
731 } \
732while(0)
733
734#else
735
721#define CCL_INVALID_CMD \ 736#define CCL_INVALID_CMD \
722do \ 737do \
723 { \ 738 { \
739 ccl_debug_hook (this_ic); \
724 ccl->status = CCL_STAT_INVALID_CMD; \ 740 ccl->status = CCL_STAT_INVALID_CMD; \
725 goto ccl_error_handler; \ 741 goto ccl_error_handler; \
726 } \ 742 } \
727while(0) 743while(0)
728 744
745#endif
746
729/* Encode one character CH to multibyte form and write to the current 747/* Encode one character CH to multibyte form and write to the current
730 output buffer. If CH is less than 256, CH is written as is. */ 748 output buffer. If CH is less than 256, CH is written as is. */
731#define CCL_WRITE_CHAR(ch) \ 749#define CCL_WRITE_CHAR(ch) \
@@ -762,6 +780,7 @@ while(0)
762 r = *src++; \ 780 r = *src++; \
763 else if (ccl->last_block) \ 781 else if (ccl->last_block) \
764 { \ 782 { \
783 r = -1; \
765 ic = ccl->eof_ic; \ 784 ic = ccl->eof_ic; \
766 goto ccl_repeat; \ 785 goto ccl_repeat; \
767 } \ 786 } \
@@ -807,12 +826,20 @@ while(0)
807#define CCL_DEBUG_BACKTRACE_LEN 256 826#define CCL_DEBUG_BACKTRACE_LEN 256
808int ccl_backtrace_table[CCL_DEBUG_BACKTRACE_LEN]; 827int ccl_backtrace_table[CCL_DEBUG_BACKTRACE_LEN];
809int ccl_backtrace_idx; 828int ccl_backtrace_idx;
829
830int
831ccl_debug_hook (int ic)
832{
833 return ic;
834}
835
810#endif 836#endif
811 837
812struct ccl_prog_stack 838struct ccl_prog_stack
813 { 839 {
814 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */ 840 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
815 int ic; /* Instruction Counter. */ 841 int ic; /* Instruction Counter. */
842 int eof_ic; /* Instruction Counter to jump on EOF. */
816 }; 843 };
817 844
818/* For the moment, we only support depth 256 of stack. */ 845/* For the moment, we only support depth 256 of stack. */
@@ -837,8 +864,10 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
837 /* Instruction counter of the current CCL code. */ 864 /* Instruction counter of the current CCL code. */
838 int this_ic = 0; 865 int this_ic = 0;
839 struct charset *charset; 866 struct charset *charset;
867 int eof_ic = ccl->eof_ic;
868 int eof_hit = 0;
840 869
841 if (ic >= ccl->eof_ic) 870 if (ic >= eof_ic)
842 ic = CCL_HEADER_MAIN; 871 ic = CCL_HEADER_MAIN;
843 872
844 if (ccl->buf_magnification == 0) /* We can't read/produce any bytes. */ 873 if (ccl->buf_magnification == 0) /* We can't read/produce any bytes. */
@@ -1042,15 +1071,18 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
1042 { 1071 {
1043 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; 1072 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
1044 ic = ccl_prog_stack_struct[0].ic; 1073 ic = ccl_prog_stack_struct[0].ic;
1074 eof_ic = ccl_prog_stack_struct[0].eof_ic;
1045 } 1075 }
1046 CCL_INVALID_CMD; 1076 CCL_INVALID_CMD;
1047 } 1077 }
1048 1078
1049 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; 1079 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
1050 ccl_prog_stack_struct[stack_idx].ic = ic; 1080 ccl_prog_stack_struct[stack_idx].ic = ic;
1081 ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic;
1051 stack_idx++; 1082 stack_idx++;
1052 ccl_prog = XVECTOR (AREF (slot, 1))->contents; 1083 ccl_prog = XVECTOR (AREF (slot, 1))->contents;
1053 ic = CCL_HEADER_MAIN; 1084 ic = CCL_HEADER_MAIN;
1085 eof_ic = XFASTINT (ccl_prog[CCL_HEADER_EOF]);
1054 } 1086 }
1055 break; 1087 break;
1056 1088
@@ -1080,6 +1112,9 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
1080 stack_idx--; 1112 stack_idx--;
1081 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog; 1113 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
1082 ic = ccl_prog_stack_struct[stack_idx].ic; 1114 ic = ccl_prog_stack_struct[stack_idx].ic;
1115 eof_ic = ccl_prog_stack_struct[stack_idx].eof_ic;
1116 if (eof_hit)
1117 ic = eof_ic;
1083 break; 1118 break;
1084 } 1119 }
1085 if (src) 1120 if (src)
diff --git a/src/charset.c b/src/charset.c
index a4967c65a9a..97f1c701cf8 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1,8 +1,8 @@
1/* Basic character set support. 1/* Basic character set support.
2 Copyright (C) 1995, 97, 98, 2000, 2001 Electrotechnical Laboratory, JAPAN. 2 Copyright (C) 1995, 97, 98, 2000, 2001 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation. 3 Licensed to the Free Software Foundation.
4 Copyright (C) 2001 Free Software Foundation, Inc. 4 Copyright (C) 2001, 2004 Free Software Foundation, Inc.
5 Copyright (C) 2003 5 Copyright (C) 2003, 2004
6 National Institute of Advanced Industrial Science and Technology (AIST) 6 National Institute of Advanced Industrial Science and Technology (AIST)
7 Registration Number H13PRO009 7 Registration Number H13PRO009
8 8
@@ -1267,7 +1267,7 @@ Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET. */)
1267DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char, 1267DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char,
1268 Sget_unused_iso_final_char, 2, 2, 0, 1268 Sget_unused_iso_final_char, 2, 2, 0,
1269 doc: /* 1269 doc: /*
1270Return an unsed ISO final char for a charset of DIMENISION and CHARS. 1270Return an unused ISO final char for a charset of DIMENISION and CHARS.
1271DIMENSION is the number of bytes to represent a character: 1 or 2. 1271DIMENSION is the number of bytes to represent a character: 1 or 2.
1272CHARS is the number of characters in a dimension: 94 or 96. 1272CHARS is the number of characters in a dimension: 94 or 96.
1273 1273
@@ -1873,7 +1873,7 @@ CHAR in the charset. */)
1873 1873
1874 1874
1875DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 1, 0, 1875DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 1, 0,
1876 doc: /* Return the charset of highest priority that contains CHAR. */) 1876 doc: /* Return the charset of highest priority that contains CH. */)
1877 (ch) 1877 (ch)
1878 Lisp_Object ch; 1878 Lisp_Object ch;
1879{ 1879{
diff --git a/src/data.c b/src/data.c
index 92e1c75dee4..935c4348bb7 100644
--- a/src/data.c
+++ b/src/data.c
@@ -761,6 +761,19 @@ function with `&rest' args, or `unevalled' for a special form. */)
761 return Fcons (make_number (minargs), make_number (maxargs)); 761 return Fcons (make_number (minargs), make_number (maxargs));
762} 762}
763 763
764DEFUN ("subr-name", Fsubr_name, Ssubr_name, 1, 1, 0,
765 doc: /* Return name of subroutine SUBR.
766SUBR must be a built-in function. */)
767 (subr)
768 Lisp_Object subr;
769{
770 const char *name;
771 if (!SUBRP (subr))
772 wrong_type_argument (Qsubrp, subr);
773 name = XSUBR (subr)->symbol_name;
774 return make_string (name, strlen (name));
775}
776
764DEFUN ("interactive-form", Finteractive_form, Sinteractive_form, 1, 1, 0, 777DEFUN ("interactive-form", Finteractive_form, Sinteractive_form, 1, 1, 0,
765 doc: /* Return the interactive form of CMD or nil if none. 778 doc: /* Return the interactive form of CMD or nil if none.
766CMD must be a command. Value, if non-nil, is a list 779CMD must be a command. Value, if non-nil, is a list
@@ -1394,7 +1407,7 @@ local bindings in certain buffers. */)
1394} 1407}
1395 1408
1396DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0, 1409DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0,
1397 doc: /* Set SYMBOL's default value to VAL. SYMBOL and VAL are evaluated. 1410 doc: /* Set SYMBOL's default value to VALUE. SYMBOL and VALUE are evaluated.
1398The default value is seen in buffers that do not have their own values 1411The default value is seen in buffers that do not have their own values
1399for this variable. */) 1412for this variable. */)
1400 (symbol, value) 1413 (symbol, value)
@@ -1455,11 +1468,11 @@ The default value of a variable is seen in buffers
1455that do not have their own values for the variable. 1468that do not have their own values for the variable.
1456 1469
1457More generally, you can use multiple variables and values, as in 1470More generally, you can use multiple variables and values, as in
1458 (setq-default SYMBOL VALUE SYMBOL VALUE...) 1471 (setq-default VAR VALUE VAR VALUE...)
1459This sets each SYMBOL's default value to the corresponding VALUE. 1472This sets each VAR's default value to the corresponding VALUE.
1460The VALUE for the Nth SYMBOL can refer to the new default values 1473The VALUE for the Nth VAR can refer to the new default values
1461of previous SYMs. 1474of previous VARs.
1462usage: (setq-default SYMBOL VALUE [SYMBOL VALUE...]) */) 1475usage: (setq-default VAR VALUE [VAR VALUE...]) */)
1463 (args) 1476 (args)
1464 Lisp_Object args; 1477 Lisp_Object args;
1465{ 1478{
@@ -1946,8 +1959,8 @@ or a byte-code object. IDX starts at 0. */)
1946 if (idxval < 0 || idxval >= XBOOL_VECTOR (array)->size) 1959 if (idxval < 0 || idxval >= XBOOL_VECTOR (array)->size)
1947 args_out_of_range (array, idx); 1960 args_out_of_range (array, idx);
1948 1961
1949 val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BITS_PER_CHAR]; 1962 val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR];
1950 return (val & (1 << (idxval % BITS_PER_CHAR)) ? Qt : Qnil); 1963 return (val & (1 << (idxval % BOOL_VECTOR_BITS_PER_CHAR)) ? Qt : Qnil);
1951 } 1964 }
1952 else if (CHAR_TABLE_P (array)) 1965 else if (CHAR_TABLE_P (array))
1953 { 1966 {
@@ -2005,13 +2018,13 @@ bool-vector. IDX starts at 0. */)
2005 if (idxval < 0 || idxval >= XBOOL_VECTOR (array)->size) 2018 if (idxval < 0 || idxval >= XBOOL_VECTOR (array)->size)
2006 args_out_of_range (array, idx); 2019 args_out_of_range (array, idx);
2007 2020
2008 val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BITS_PER_CHAR]; 2021 val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR];
2009 2022
2010 if (! NILP (newelt)) 2023 if (! NILP (newelt))
2011 val |= 1 << (idxval % BITS_PER_CHAR); 2024 val |= 1 << (idxval % BOOL_VECTOR_BITS_PER_CHAR);
2012 else 2025 else
2013 val &= ~(1 << (idxval % BITS_PER_CHAR)); 2026 val &= ~(1 << (idxval % BOOL_VECTOR_BITS_PER_CHAR));
2014 XBOOL_VECTOR (array)->data[idxval / BITS_PER_CHAR] = val; 2027 XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR] = val;
2015 } 2028 }
2016 else if (CHAR_TABLE_P (array)) 2029 else if (CHAR_TABLE_P (array))
2017 { 2030 {
@@ -2581,6 +2594,10 @@ usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */)
2581 int nargs; 2594 int nargs;
2582 Lisp_Object *args; 2595 Lisp_Object *args;
2583{ 2596{
2597 int argnum;
2598 for (argnum = 2; argnum < nargs; argnum++)
2599 if (FLOATP (args[argnum]))
2600 return float_arith_driver (0, 0, Adiv, nargs, args);
2584 return arith_driver (Adiv, nargs, args); 2601 return arith_driver (Adiv, nargs, args);
2585} 2602}
2586 2603
@@ -3215,6 +3232,7 @@ syms_of_data ()
3215 defsubr (&Slognot); 3232 defsubr (&Slognot);
3216 defsubr (&Sbyteorder); 3233 defsubr (&Sbyteorder);
3217 defsubr (&Ssubr_arity); 3234 defsubr (&Ssubr_arity);
3235 defsubr (&Ssubr_name);
3218 3236
3219 XSYMBOL (Qwholenump)->function = XSYMBOL (Qnatnump)->function; 3237 XSYMBOL (Qwholenump)->function = XSYMBOL (Qnatnump)->function;
3220 3238
diff --git a/src/dispextern.h b/src/dispextern.h
index f2cd03e968a..11395cb7f00 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1,5 +1,5 @@
1/* Interface definitions for display code. 1/* Interface definitions for display code.
2 Copyright (C) 1985, 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003 2 Copyright (C) 1985,93,94,97,98,99, 2000,01,02,03, 2004
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -274,6 +274,17 @@ enum glyph_type
274}; 274};
275 275
276 276
277/* Structure describing how to use partial glyphs (images slicing) */
278
279struct glyph_slice
280{
281 unsigned x : 16;
282 unsigned y : 16;
283 unsigned width : 16;
284 unsigned height : 16;
285};
286
287
277/* Glyphs. 288/* Glyphs.
278 289
279 Be extra careful when changing this structure! Esp. make sure that 290 Be extra careful when changing this structure! Esp. make sure that
@@ -352,6 +363,8 @@ struct glyph
352 w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */ 363 w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */
353 unsigned font_type : 3; 364 unsigned font_type : 3;
354 365
366 struct glyph_slice slice;
367
355 /* A union of sub-structures for different glyph types. */ 368 /* A union of sub-structures for different glyph types. */
356 union 369 union
357 { 370 {
@@ -390,11 +403,20 @@ struct glyph
390#define CHAR_GLYPH_SPACE_P(GLYPH) \ 403#define CHAR_GLYPH_SPACE_P(GLYPH) \
391 (GLYPH_FROM_CHAR_GLYPH ((GLYPH)) == SPACEGLYPH) 404 (GLYPH_FROM_CHAR_GLYPH ((GLYPH)) == SPACEGLYPH)
392 405
406/* Are glyph slices of glyphs *X and *Y equal */
407
408#define GLYPH_SLICE_EQUAL_P(X, Y) \
409 ((X)->slice.x == (Y)->slice.x \
410 && (X)->slice.y == (Y)->slice.y \
411 && (X)->slice.width == (Y)->slice.width \
412 && (X)->slice.height == (Y)->slice.height)
413
393/* Are glyphs *X and *Y displayed equal? */ 414/* Are glyphs *X and *Y displayed equal? */
394 415
395#define GLYPH_EQUAL_P(X, Y) \ 416#define GLYPH_EQUAL_P(X, Y) \
396 ((X)->type == (Y)->type \ 417 ((X)->type == (Y)->type \
397 && (X)->u.val == (Y)->u.val \ 418 && (X)->u.val == (Y)->u.val \
419 && GLYPH_SLICE_EQUAL_P (X, Y) \
398 && (X)->face_id == (Y)->face_id \ 420 && (X)->face_id == (Y)->face_id \
399 && (X)->padding_p == (Y)->padding_p \ 421 && (X)->padding_p == (Y)->padding_p \
400 && (X)->left_box_line_p == (Y)->left_box_line_p \ 422 && (X)->left_box_line_p == (Y)->left_box_line_p \
@@ -1143,6 +1165,9 @@ struct glyph_string
1143 /* Image, if any. */ 1165 /* Image, if any. */
1144 struct image *img; 1166 struct image *img;
1145 1167
1168 /* Slice */
1169 struct glyph_slice slice;
1170
1146 struct glyph_string *next, *prev; 1171 struct glyph_string *next, *prev;
1147}; 1172};
1148 1173
@@ -1604,7 +1629,7 @@ extern int face_change_count;
1604 width and height of the bitmap, DH is the height adjustment (if 1629 width and height of the bitmap, DH is the height adjustment (if
1605 bitmap is periodic). X and Y are frame coordinates of the area to 1630 bitmap is periodic). X and Y are frame coordinates of the area to
1606 display the bitmap, DY is relative offset of the bitmap into that 1631 display the bitmap, DY is relative offset of the bitmap into that
1607 area. BX, NX, BY, NY specifies the area to clear if the bitmap 1632 area. BX, NX, BY, NY specifies the area to clear if the bitmap
1608 does not fill the entire area. FACE is the fringe face. */ 1633 does not fill the entire area. FACE is the fringe face. */
1609 1634
1610struct draw_fringe_bitmap_params 1635struct draw_fringe_bitmap_params
@@ -1716,6 +1741,15 @@ enum prop_idx
1716}; 1741};
1717 1742
1718 1743
1744struct it_slice
1745{
1746 Lisp_Object x;
1747 Lisp_Object y;
1748 Lisp_Object width;
1749 Lisp_Object height;
1750};
1751
1752
1719struct it 1753struct it
1720{ 1754{
1721 /* The window in which we iterate over current_buffer (or a string). */ 1755 /* The window in which we iterate over current_buffer (or a string). */
@@ -1828,6 +1862,7 @@ struct it
1828 unsigned multibyte_p : 1; 1862 unsigned multibyte_p : 1;
1829 unsigned string_from_display_prop_p : 1; 1863 unsigned string_from_display_prop_p : 1;
1830 unsigned display_ellipsis_p : 1; 1864 unsigned display_ellipsis_p : 1;
1865 struct it_slice slice;
1831 Lisp_Object space_width; 1866 Lisp_Object space_width;
1832 short voffset; 1867 short voffset;
1833 Lisp_Object font_height; 1868 Lisp_Object font_height;
@@ -1882,6 +1917,10 @@ struct it
1882 skipped due to selective display. */ 1917 skipped due to selective display. */
1883 unsigned face_before_selective_p : 1; 1918 unsigned face_before_selective_p : 1;
1884 1919
1920 /* If 1, adjust current glyph so it does not increase current row
1921 descent/ascent (line-height property). Reset after this glyph. */
1922 unsigned constrain_row_ascent_descent_p : 1;
1923
1885 /* The ID of the default face to use. One of DEFAULT_FACE_ID, 1924 /* The ID of the default face to use. One of DEFAULT_FACE_ID,
1886 MODE_LINE_FACE_ID, etc, depending on what we are displaying. */ 1925 MODE_LINE_FACE_ID, etc, depending on what we are displaying. */
1887 int base_face_id; 1926 int base_face_id;
@@ -1907,6 +1946,9 @@ struct it
1907 /* If what == IT_IMAGE, the id of the image to display. */ 1946 /* If what == IT_IMAGE, the id of the image to display. */
1908 int image_id; 1947 int image_id;
1909 1948
1949 /* Values from `slice' property. */
1950 struct it_slice slice;
1951
1910 /* Value of the `space-width' property, if any; nil if none. */ 1952 /* Value of the `space-width' property, if any; nil if none. */
1911 Lisp_Object space_width; 1953 Lisp_Object space_width;
1912 1954
@@ -1945,6 +1987,10 @@ struct it
1945 only.) */ 1987 only.) */
1946 int extra_line_spacing; 1988 int extra_line_spacing;
1947 1989
1990 /* Override font height information for this glyph.
1991 Used if override_ascent >= 0. Cleared after this glyph. */
1992 int override_ascent, override_descent, override_boff;
1993
1948 /* If non-null, glyphs are produced in glyph_row with each call to 1994 /* If non-null, glyphs are produced in glyph_row with each call to
1949 produce_glyphs. */ 1995 produce_glyphs. */
1950 struct glyph_row *glyph_row; 1996 struct glyph_row *glyph_row;
@@ -2176,7 +2222,7 @@ struct redisplay_interface
2176 struct charset *charset, 2222 struct charset *charset,
2177 int *two_byte_p)); 2223 int *two_byte_p));
2178 2224
2179/* Compute left and right overhang of glyph string S. 2225/* Compute left and right overhang of glyph string S.
2180 A NULL pointer if platform does not support this. */ 2226 A NULL pointer if platform does not support this. */
2181 void (*compute_glyph_string_overhangs) P_ ((struct glyph_string *s)); 2227 void (*compute_glyph_string_overhangs) P_ ((struct glyph_string *s));
2182 2228
@@ -2204,7 +2250,7 @@ struct redisplay_interface
2204 void (*draw_vertical_window_border) P_ ((struct window *w, 2250 void (*draw_vertical_window_border) P_ ((struct window *w,
2205 int x, int y0, int y1)); 2251 int x, int y0, int y1));
2206 2252
2207/* Shift display of frame F to make room for inserted glyphs. 2253/* Shift display of frame F to make room for inserted glyphs.
2208 The area at pixel (X,Y) of width WIDTH and height HEIGHT is 2254 The area at pixel (X,Y) of width WIDTH and height HEIGHT is
2209 shifted right by SHIFT_BY pixels. */ 2255 shifted right by SHIFT_BY pixels. */
2210 void (*shift_glyphs_for_insert) P_ ((struct frame *f, 2256 void (*shift_glyphs_for_insert) P_ ((struct frame *f,
@@ -2518,12 +2564,11 @@ extern Lisp_Object Qtool_bar;
2518extern Lisp_Object Vshow_trailing_whitespace; 2564extern Lisp_Object Vshow_trailing_whitespace;
2519extern int mode_line_in_non_selected_windows; 2565extern int mode_line_in_non_selected_windows;
2520extern int redisplaying_p; 2566extern int redisplaying_p;
2521extern Lisp_Object Vimage_types;
2522extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object)); 2567extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object));
2523extern int help_echo_showing_p; 2568extern int help_echo_showing_p;
2524extern int current_mode_line_height, current_header_line_height; 2569extern int current_mode_line_height, current_header_line_height;
2525extern Lisp_Object help_echo_string, help_echo_window; 2570extern Lisp_Object help_echo_string, help_echo_window;
2526extern Lisp_Object help_echo_object, previous_help_echo_string; 2571extern Lisp_Object help_echo_object, previous_help_echo_string;
2527extern int help_echo_pos; 2572extern int help_echo_pos;
2528extern struct frame *last_mouse_frame; 2573extern struct frame *last_mouse_frame;
2529extern int last_tool_bar_item; 2574extern int last_tool_bar_item;
@@ -2633,6 +2678,8 @@ unsigned long image_background P_ ((struct image *, struct frame *,
2633int image_background_transparent P_ ((struct image *, struct frame *, 2678int image_background_transparent P_ ((struct image *, struct frame *,
2634 XImagePtr_or_DC mask)); 2679 XImagePtr_or_DC mask));
2635 2680
2681int image_ascent P_ ((struct image *, struct face *, struct glyph_slice *));
2682
2636#endif 2683#endif
2637 2684
2638/* Defined in sysdep.c */ 2685/* Defined in sysdep.c */
@@ -2741,7 +2788,7 @@ extern int required_matrix_height P_ ((struct window *));
2741extern Lisp_Object buffer_posn_from_coords P_ ((struct window *, 2788extern Lisp_Object buffer_posn_from_coords P_ ((struct window *,
2742 int *, int *, 2789 int *, int *,
2743 struct display_pos *, 2790 struct display_pos *,
2744 Lisp_Object *, 2791 Lisp_Object *,
2745 int *, int *, int *, int *)); 2792 int *, int *, int *, int *));
2746extern Lisp_Object mode_line_string P_ ((struct window *, enum window_part, 2793extern Lisp_Object mode_line_string P_ ((struct window *, enum window_part,
2747 int *, int *, int *, 2794 int *, int *, int *,
diff --git a/src/dispnew.c b/src/dispnew.c
index f06a54164d6..8edc8993a05 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5716,6 +5716,9 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
5716 struct text_pos startp; 5716 struct text_pos startp;
5717 Lisp_Object string; 5717 Lisp_Object string;
5718 struct glyph_row *row; 5718 struct glyph_row *row;
5719#ifdef HAVE_WINDOW_SYSTEM
5720 struct image *img = 0;
5721#endif
5719 int x0, x1; 5722 int x0, x1;
5720 5723
5721 current_buffer = XBUFFER (w->buffer); 5724 current_buffer = XBUFFER (w->buffer);
@@ -5741,7 +5744,6 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
5741#ifdef HAVE_WINDOW_SYSTEM 5744#ifdef HAVE_WINDOW_SYSTEM
5742 if (it.what == IT_IMAGE) 5745 if (it.what == IT_IMAGE)
5743 { 5746 {
5744 struct image *img;
5745 if ((img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL 5747 if ((img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL
5746 && !NILP (img->spec)) 5748 && !NILP (img->spec))
5747 *object = img->spec; 5749 *object = img->spec;
@@ -5754,12 +5756,22 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height)
5754 if (it.hpos < row->used[TEXT_AREA]) 5756 if (it.hpos < row->used[TEXT_AREA])
5755 { 5757 {
5756 struct glyph *glyph = row->glyphs[TEXT_AREA] + it.hpos; 5758 struct glyph *glyph = row->glyphs[TEXT_AREA] + it.hpos;
5757 *width = glyph->pixel_width;
5758 *height = glyph->ascent + glyph->descent;
5759#ifdef HAVE_WINDOW_SYSTEM 5759#ifdef HAVE_WINDOW_SYSTEM
5760 if (glyph->type == IMAGE_GLYPH) 5760 if (img)
5761 *dy -= row->ascent - glyph->ascent; 5761 {
5762 *dy -= row->ascent - glyph->ascent;
5763 *dx += glyph->slice.x;
5764 *dy += glyph->slice.y;
5765 /* Image slices positions are still relative to the entire image */
5766 *width = img->width;
5767 *height = img->height;
5768 }
5769 else
5762#endif 5770#endif
5771 {
5772 *width = glyph->pixel_width;
5773 *height = glyph->ascent + glyph->descent;
5774 }
5763 } 5775 }
5764 else 5776 else
5765 { 5777 {
@@ -5925,6 +5937,8 @@ marginal_area_string (w, part, x, y, charpos, object, dx, dy, width, height)
5925 if (img != NULL) 5937 if (img != NULL)
5926 *object = img->spec; 5938 *object = img->spec;
5927 y0 -= row->ascent - glyph->ascent; 5939 y0 -= row->ascent - glyph->ascent;
5940 x0 += glyph->slice.x;
5941 y0 += glyph->slice.y;
5928 } 5942 }
5929#endif 5943#endif
5930 } 5944 }
diff --git a/src/doc.c b/src/doc.c
index e670ad1797a..2e66c5cea46 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -808,7 +808,7 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
808 } 808 }
809 else 809 else
810 { /* function is on a key */ 810 { /* function is on a key */
811 tem = Fkey_description (tem); 811 tem = Fkey_description (tem, Qnil);
812 goto subst_string; 812 goto subst_string;
813 } 813 }
814 } 814 }
diff --git a/src/editfns.c b/src/editfns.c
index e7a01b24b76..130dffa77de 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -73,7 +73,7 @@ static int tm_diff P_ ((struct tm *, struct tm *));
73static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *)); 73static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *));
74static void update_buffer_properties P_ ((int, int)); 74static void update_buffer_properties P_ ((int, int));
75static Lisp_Object region_limit P_ ((int)); 75static Lisp_Object region_limit P_ ((int));
76static int lisp_time_argument P_ ((Lisp_Object, time_t *, int *)); 76int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
77static size_t emacs_memftimeu P_ ((char *, size_t, const char *, 77static size_t emacs_memftimeu P_ ((char *, size_t, const char *,
78 size_t, const struct tm *, int)); 78 size_t, const struct tm *, int));
79static void general_insert_function P_ ((void (*) (const unsigned char *, int), 79static void general_insert_function P_ ((void (*) (const unsigned char *, int),
@@ -1213,7 +1213,7 @@ If POS is out of range, the value is nil. */)
1213DEFUN ("user-login-name", Fuser_login_name, Suser_login_name, 0, 1, 0, 1213DEFUN ("user-login-name", Fuser_login_name, Suser_login_name, 0, 1, 0,
1214 doc: /* Return the name under which the user logged in, as a string. 1214 doc: /* Return the name under which the user logged in, as a string.
1215This is based on the effective uid, not the real uid. 1215This is based on the effective uid, not the real uid.
1216Also, if the environment variable LOGNAME or USER is set, 1216Also, if the environment variables LOGNAME or USER are set,
1217that determines the value of this function. 1217that determines the value of this function.
1218 1218
1219If optional argument UID is an integer, return the login name of the user 1219If optional argument UID is an integer, return the login name of the user
@@ -1372,7 +1372,7 @@ resolution finer than a second. */)
1372} 1372}
1373 1373
1374 1374
1375static int 1375int
1376lisp_time_argument (specified_time, result, usec) 1376lisp_time_argument (specified_time, result, usec)
1377 Lisp_Object specified_time; 1377 Lisp_Object specified_time;
1378 time_t *result; 1378 time_t *result;
@@ -1425,7 +1425,7 @@ lisp_time_argument (specified_time, result, usec)
1425 1425
1426DEFUN ("float-time", Ffloat_time, Sfloat_time, 0, 1, 0, 1426DEFUN ("float-time", Ffloat_time, Sfloat_time, 0, 1, 0,
1427 doc: /* Return the current time, as a float number of seconds since the epoch. 1427 doc: /* Return the current time, as a float number of seconds since the epoch.
1428If an argument is given, it specifies a time to convert to float 1428If SPECIFIED-TIME is given, it is the time to convert to float
1429instead of the current time. The argument should have the forms: 1429instead of the current time. The argument should have the forms:
1430 (HIGH . LOW) or (HIGH LOW USEC) or (HIGH LOW . USEC). 1430 (HIGH . LOW) or (HIGH LOW USEC) or (HIGH LOW . USEC).
1431Thus, you can use times obtained from `current-time' 1431Thus, you can use times obtained from `current-time'
@@ -1655,7 +1655,7 @@ are used as SECOND through YEAR, and the *last* argument is used as ZONE.
1655The intervening arguments are ignored. 1655The intervening arguments are ignored.
1656This feature lets (apply 'encode-time (decode-time ...)) work. 1656This feature lets (apply 'encode-time (decode-time ...)) work.
1657 1657
1658Out-of-range values for SEC, MINUTE, HOUR, DAY, or MONTH are allowed; 1658Out-of-range values for SECOND, MINUTE, HOUR, DAY, or MONTH are allowed;
1659for example, a DAY of 0 means the day preceding the given month. 1659for example, a DAY of 0 means the day preceding the given month.
1660Year numbers less than 100 are treated just like other year numbers. 1660Year numbers less than 100 are treated just like other year numbers.
1661If you want them to stand for years in this century, you must do that yourself. 1661If you want them to stand for years in this century, you must do that yourself.
@@ -1740,8 +1740,8 @@ The format is `Sun Sep 16 01:03:52 1973'.
1740However, see also the functions `decode-time' and `format-time-string' 1740However, see also the functions `decode-time' and `format-time-string'
1741which provide a much more powerful and general facility. 1741which provide a much more powerful and general facility.
1742 1742
1743If an argument is given, it specifies a time to format 1743If SPECIFIED-TIME is given, it is a time to format instead
1744instead of the current time. The argument should have the form: 1744of the current time. The argument should have the form:
1745 (HIGH . LOW) 1745 (HIGH . LOW)
1746or the form: 1746or the form:
1747 (HIGH LOW . IGNORED). 1747 (HIGH LOW . IGNORED).
@@ -1796,7 +1796,7 @@ This returns a list of the form (OFFSET NAME).
1796OFFSET is an integer number of seconds ahead of UTC (east of Greenwich). 1796OFFSET is an integer number of seconds ahead of UTC (east of Greenwich).
1797 A negative value means west of Greenwich. 1797 A negative value means west of Greenwich.
1798NAME is a string giving the name of the time zone. 1798NAME is a string giving the name of the time zone.
1799If an argument is given, it specifies when the time zone offset is determined 1799If SPECIFIED-TIME is given, the time zone offset is determined from it
1800instead of using the current time. The argument should have the form: 1800instead of using the current time. The argument should have the form:
1801 (HIGH . LOW) 1801 (HIGH . LOW)
1802or the form: 1802or the form:
@@ -2365,21 +2365,21 @@ of the buffer. */)
2365 2365
2366DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring, 2366DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
2367 1, 3, 0, 2367 1, 3, 0,
2368 doc: /* Insert before point a substring of the contents of buffer BUFFER. 2368 doc: /* Insert before point a substring of the contents of BUFFER.
2369BUFFER may be a buffer or a buffer name. 2369BUFFER may be a buffer or a buffer name.
2370Arguments START and END are character numbers specifying the substring. 2370Arguments START and END are character positions specifying the substring.
2371They default to the beginning and the end of BUFFER. */) 2371They default to the values of (point-min) and (point-max) in BUFFER. */)
2372 (buf, start, end) 2372 (buffer, start, end)
2373 Lisp_Object buf, start, end; 2373 Lisp_Object buffer, start, end;
2374{ 2374{
2375 register int b, e, temp; 2375 register int b, e, temp;
2376 register struct buffer *bp, *obuf; 2376 register struct buffer *bp, *obuf;
2377 Lisp_Object buffer; 2377 Lisp_Object buf;
2378 2378
2379 buffer = Fget_buffer (buf); 2379 buf = Fget_buffer (buffer);
2380 if (NILP (buffer)) 2380 if (NILP (buf))
2381 nsberror (buf); 2381 nsberror (buffer);
2382 bp = XBUFFER (buffer); 2382 bp = XBUFFER (buf);
2383 if (NILP (bp->name)) 2383 if (NILP (bp->name))
2384 error ("Selecting deleted buffer"); 2384 error ("Selecting deleted buffer");
2385 2385
@@ -2983,6 +2983,7 @@ It returns the number of characters changed. */)
2983 2983
2984DEFUN ("delete-region", Fdelete_region, Sdelete_region, 2, 2, "r", 2984DEFUN ("delete-region", Fdelete_region, Sdelete_region, 2, 2, "r",
2985 doc: /* Delete the text between point and mark. 2985 doc: /* Delete the text between point and mark.
2986
2986When called from a program, expects two arguments, 2987When called from a program, expects two arguments,
2987positions (integers or markers) specifying the stretch to be deleted. */) 2988positions (integers or markers) specifying the stretch to be deleted. */)
2988 (start, end) 2989 (start, end)
@@ -4043,11 +4044,11 @@ transpose_markers (start1, end1, start2, end2,
4043} 4044}
4044 4045
4045DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, 0, 4046DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, 0,
4046 doc: /* Transpose region START1 to END1 with START2 to END2. 4047 doc: /* Transpose region STARTR1 to ENDR1 with STARTR2 to ENDR2.
4047The regions may not be overlapping, because the size of the buffer is 4048The regions may not be overlapping, because the size of the buffer is
4048never changed in a transposition. 4049never changed in a transposition.
4049 4050
4050Optional fifth arg LEAVE_MARKERS, if non-nil, means don't update 4051Optional fifth arg LEAVE-MARKERS, if non-nil, means don't update
4051any markers that happen to be located in the regions. 4052any markers that happen to be located in the regions.
4052 4053
4053Transposing beyond buffer boundaries is an error. */) 4054Transposing beyond buffer boundaries is an error. */)
diff --git a/src/emacs.c b/src/emacs.c
index b27b460fba0..d348eb86d29 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -104,6 +104,7 @@ EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS;
104EMACS_INT gdb_data_seg_bits = 0; 104EMACS_INT gdb_data_seg_bits = 0;
105#endif 105#endif
106EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG; 106EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG;
107EMACS_INT gdb_array_mark_flag = ARRAY_MARK_FLAG;
107 108
108/* Command line args from shell, as list of strings. */ 109/* Command line args from shell, as list of strings. */
109Lisp_Object Vcommand_line_args; 110Lisp_Object Vcommand_line_args;
@@ -205,6 +206,8 @@ extern Lisp_Object Vwindow_system;
205 206
206extern Lisp_Object Vauto_save_list_file_name; 207extern Lisp_Object Vauto_save_list_file_name;
207 208
209extern Lisp_Object Vinhibit_redisplay;
210
208#ifdef USG_SHARED_LIBRARIES 211#ifdef USG_SHARED_LIBRARIES
209/* If nonzero, this is the place to put the end of the writable segment 212/* If nonzero, this is the place to put the end of the writable segment
210 at startup. */ 213 at startup. */
@@ -847,7 +850,7 @@ main (argc, argv
847 else 850 else
848 { 851 {
849 printf ("GNU Emacs %s\n", SDATA (tem)); 852 printf ("GNU Emacs %s\n", SDATA (tem));
850 printf ("Copyright (C) 2002 Free Software Foundation, Inc.\n"); 853 printf ("Copyright (C) 2004 Free Software Foundation, Inc.\n");
851 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n"); 854 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
852 printf ("You may redistribute copies of Emacs\n"); 855 printf ("You may redistribute copies of Emacs\n");
853 printf ("under the terms of the GNU General Public License.\n"); 856 printf ("under the terms of the GNU General Public License.\n");
@@ -894,7 +897,7 @@ main (argc, argv
894 /* If -map specified, map the data file in. */ 897 /* If -map specified, map the data file in. */
895 { 898 {
896 char *file; 899 char *file;
897 if (argmatch (argv, argc, "-map", "--map-data", 3, &mapin_file, &skip_args)) 900 if (argmatch (argv, argc, "-map", "--map-data", 3, &file, &skip_args))
898 mapin_data (file); 901 mapin_data (file);
899 } 902 }
900 903
@@ -2016,6 +2019,9 @@ shut_down_emacs (sig, no_x, stuff)
2016 /* Prevent running of hooks from now on. */ 2019 /* Prevent running of hooks from now on. */
2017 Vrun_hooks = Qnil; 2020 Vrun_hooks = Qnil;
2018 2021
2022 /* Don't update display from now on. */
2023 Vinhibit_redisplay = Qt;
2024
2019 /* If we are controlling the terminal, reset terminal modes. */ 2025 /* If we are controlling the terminal, reset terminal modes. */
2020#ifdef EMACS_HAVE_TTY_PGRP 2026#ifdef EMACS_HAVE_TTY_PGRP
2021 { 2027 {
diff --git a/src/eval.c b/src/eval.c
index 0326a828a81..096755f9c77 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -617,6 +617,7 @@ usage: (defun NAME ARGLIST [DOCSTRING] BODY...) */)
617 register Lisp_Object defn; 617 register Lisp_Object defn;
618 618
619 fn_name = Fcar (args); 619 fn_name = Fcar (args);
620 CHECK_SYMBOL (fn_name);
620 defn = Fcons (Qlambda, Fcdr (args)); 621 defn = Fcons (Qlambda, Fcdr (args));
621 if (!NILP (Vpurify_flag)) 622 if (!NILP (Vpurify_flag))
622 defn = Fpurecopy (defn); 623 defn = Fpurecopy (defn);
@@ -1220,7 +1221,7 @@ VAR may be nil; then you do not get access to the signal information.
1220 1221
1221The value of the last BODY form is returned from the condition-case. 1222The value of the last BODY form is returned from the condition-case.
1222See also the function `signal' for more info. 1223See also the function `signal' for more info.
1223usage: (condition-case VAR BODYFORM HANDLERS...) */) 1224usage: (condition-case VAR BODYFORM &rest HANDLERS) */)
1224 (args) 1225 (args)
1225 Lisp_Object args; 1226 Lisp_Object args;
1226{ 1227{
@@ -1235,10 +1236,10 @@ usage: (condition-case VAR BODYFORM HANDLERS...) */)
1235 handlers = Fcdr (Fcdr (args)); 1236 handlers = Fcdr (Fcdr (args));
1236 CHECK_SYMBOL (var); 1237 CHECK_SYMBOL (var);
1237 1238
1238 for (val = handlers; ! NILP (val); val = Fcdr (val)) 1239 for (val = handlers; CONSP (val); val = XCDR (val))
1239 { 1240 {
1240 Lisp_Object tem; 1241 Lisp_Object tem;
1241 tem = Fcar (val); 1242 tem = XCAR (val);
1242 if (! (NILP (tem) 1243 if (! (NILP (tem)
1243 || (CONSP (tem) 1244 || (CONSP (tem)
1244 && (SYMBOLP (XCAR (tem)) 1245 && (SYMBOLP (XCAR (tem))
@@ -3243,6 +3244,25 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3243 3244
3244 3245
3245void 3246void
3247mark_backtrace ()
3248{
3249 register struct backtrace *backlist;
3250 register int i;
3251
3252 for (backlist = backtrace_list; backlist; backlist = backlist->next)
3253 {
3254 mark_object (*backlist->function);
3255
3256 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
3257 i = 0;
3258 else
3259 i = backlist->nargs - 1;
3260 for (; i >= 0; i--)
3261 mark_object (backlist->args[i]);
3262 }
3263}
3264
3265void
3246syms_of_eval () 3266syms_of_eval ()
3247{ 3267{
3248 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size, 3268 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
diff --git a/src/fileio.c b/src/fileio.c
index 722370ea5ce..42f3949c917 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1,5 +1,5 @@
1/* File IO for GNU Emacs. 1/* File IO for GNU Emacs.
2 Copyright (C) 1985,86,87,88,93,94,95,96,97,98,99,2000,01,2003 2 Copyright (C) 1985,86,87,88,93,94,95,96,97,98,99,2000,01,03,2004
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -324,6 +324,7 @@ Lisp_Object Qfile_regular_p;
324Lisp_Object Qfile_accessible_directory_p; 324Lisp_Object Qfile_accessible_directory_p;
325Lisp_Object Qfile_modes; 325Lisp_Object Qfile_modes;
326Lisp_Object Qset_file_modes; 326Lisp_Object Qset_file_modes;
327Lisp_Object Qset_file_times;
327Lisp_Object Qfile_newer_than_file_p; 328Lisp_Object Qfile_newer_than_file_p;
328Lisp_Object Qinsert_file_contents; 329Lisp_Object Qinsert_file_contents;
329Lisp_Object Qwrite_region; 330Lisp_Object Qwrite_region;
@@ -2349,7 +2350,7 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick)
2349 2350
2350 /* stat is a good way to tell whether the file exists, 2351 /* stat is a good way to tell whether the file exists,
2351 regardless of what access permissions it has. */ 2352 regardless of what access permissions it has. */
2352 if (stat (SDATA (encoded_filename), &statbuf) >= 0) 2353 if (lstat (SDATA (encoded_filename), &statbuf) >= 0)
2353 { 2354 {
2354 if (! interactive) 2355 if (! interactive)
2355 Fsignal (Qfile_already_exists, 2356 Fsignal (Qfile_already_exists,
@@ -2684,11 +2685,11 @@ This is what happens in interactive use with M-x. */)
2684 Lisp_Object args[2]; 2685 Lisp_Object args[2];
2685#endif 2686#endif
2686 Lisp_Object handler; 2687 Lisp_Object handler;
2687 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 2688 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
2688 Lisp_Object encoded_file, encoded_newname; 2689 Lisp_Object encoded_file, encoded_newname, symlink_target;
2689 2690
2690 encoded_file = encoded_newname = Qnil; 2691 symlink_target = encoded_file = encoded_newname = Qnil;
2691 GCPRO4 (file, newname, encoded_file, encoded_newname); 2692 GCPRO5 (file, newname, encoded_file, encoded_newname, symlink_target);
2692 CHECK_STRING (file); 2693 CHECK_STRING (file);
2693 CHECK_STRING (newname); 2694 CHECK_STRING (newname);
2694 file = Fexpand_file_name (file, Qnil); 2695 file = Fexpand_file_name (file, Qnil);
@@ -2725,10 +2726,17 @@ This is what happens in interactive use with M-x. */)
2725 { 2726 {
2726 if (errno == EXDEV) 2727 if (errno == EXDEV)
2727 { 2728 {
2728 Fcopy_file (file, newname, 2729#ifdef S_IFLNK
2729 /* We have already prompted if it was an integer, 2730 symlink_target = Ffile_symlink_p (file);
2730 so don't have copy-file prompt again. */ 2731 if (! NILP (symlink_target))
2731 NILP (ok_if_already_exists) ? Qnil : Qt, Qt); 2732 Fmake_symbolic_link (symlink_target, newname,
2733 NILP (ok_if_already_exists) ? Qnil : Qt);
2734 else
2735#endif
2736 Fcopy_file (file, newname,
2737 /* We have already prompted if it was an integer,
2738 so don't have copy-file prompt again. */
2739 NILP (ok_if_already_exists) ? Qnil : Qt, Qt);
2732 Fdelete_file (file); 2740 Fdelete_file (file);
2733 } 2741 }
2734 else 2742 else
@@ -3439,7 +3447,59 @@ The value is an integer. */)
3439 XSETINT (value, (~ realmask) & 0777); 3447 XSETINT (value, (~ realmask) & 0777);
3440 return value; 3448 return value;
3441} 3449}
3450
3451extern int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
3452
3453DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
3454 doc: /* Set times of file FILENAME to TIME.
3455Set both access and modification times.
3456Return t on success, else nil.
3457Use the current time if TIME is nil. TIME is in the format of
3458`current-time'. */)
3459 (filename, time)
3460 Lisp_Object filename, time;
3461{
3462 Lisp_Object absname, encoded_absname;
3463 Lisp_Object handler;
3464 time_t sec;
3465 int usec;
3466
3467 if (! lisp_time_argument (time, &sec, &usec))
3468 error ("Invalid time specification");
3469
3470 absname = Fexpand_file_name (filename, current_buffer->directory);
3471
3472 /* If the file name has special constructs in it,
3473 call the corresponding file handler. */
3474 handler = Ffind_file_name_handler (absname, Qset_file_times);
3475 if (!NILP (handler))
3476 return call3 (handler, Qset_file_times, absname, time);
3477
3478 encoded_absname = ENCODE_FILE (absname);
3479
3480 {
3481 EMACS_TIME t;
3482
3483 EMACS_SET_SECS (t, sec);
3484 EMACS_SET_USECS (t, usec);
3485
3486 if (set_file_times (SDATA (encoded_absname), t, t))
3487 {
3488#ifdef DOS_NT
3489 struct stat st;
3490
3491 /* Setting times on a directory always fails. */
3492 if (stat (SDATA (encoded_absname), &st) == 0
3493 && (st.st_mode & S_IFMT) == S_IFDIR)
3494 return Qnil;
3495#endif
3496 report_file_error ("Setting file times", Fcons (absname, Qnil));
3497 return Qnil;
3498 }
3499 }
3442 3500
3501 return Qt;
3502}
3443 3503
3444#ifdef __NetBSD__ 3504#ifdef __NetBSD__
3445#define unix 42 3505#define unix 42
@@ -6051,10 +6111,13 @@ provides a file dialog box. */)
6051 6111
6052 if (NILP (dir)) 6112 if (NILP (dir))
6053 dir = current_buffer->directory; 6113 dir = current_buffer->directory;
6114 if (NILP (Ffile_name_absolute_p (dir)))
6115 dir = Fexpand_file_name (dir, Qnil);
6054 if (NILP (default_filename)) 6116 if (NILP (default_filename))
6055 default_filename = !NILP (initial) 6117 default_filename
6056 ? Fexpand_file_name (initial, dir) 6118 = (!NILP (initial)
6057 : current_buffer->filename; 6119 ? Fexpand_file_name (initial, dir)
6120 : current_buffer->filename);
6058 6121
6059 /* If dir starts with user's homedir, change that to ~. */ 6122 /* If dir starts with user's homedir, change that to ~. */
6060 homedir = (char *) egetenv ("HOME"); 6123 homedir = (char *) egetenv ("HOME");
@@ -6255,6 +6318,7 @@ syms_of_fileio ()
6255 Qfile_accessible_directory_p = intern ("file-accessible-directory-p"); 6318 Qfile_accessible_directory_p = intern ("file-accessible-directory-p");
6256 Qfile_modes = intern ("file-modes"); 6319 Qfile_modes = intern ("file-modes");
6257 Qset_file_modes = intern ("set-file-modes"); 6320 Qset_file_modes = intern ("set-file-modes");
6321 Qset_file_times = intern ("set-file-times");
6258 Qfile_newer_than_file_p = intern ("file-newer-than-file-p"); 6322 Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
6259 Qinsert_file_contents = intern ("insert-file-contents"); 6323 Qinsert_file_contents = intern ("insert-file-contents");
6260 Qwrite_region = intern ("write-region"); 6324 Qwrite_region = intern ("write-region");
@@ -6288,6 +6352,7 @@ syms_of_fileio ()
6288 staticpro (&Qfile_accessible_directory_p); 6352 staticpro (&Qfile_accessible_directory_p);
6289 staticpro (&Qfile_modes); 6353 staticpro (&Qfile_modes);
6290 staticpro (&Qset_file_modes); 6354 staticpro (&Qset_file_modes);
6355 staticpro (&Qset_file_times);
6291 staticpro (&Qfile_newer_than_file_p); 6356 staticpro (&Qfile_newer_than_file_p);
6292 staticpro (&Qinsert_file_contents); 6357 staticpro (&Qinsert_file_contents);
6293 staticpro (&Qwrite_region); 6358 staticpro (&Qwrite_region);
@@ -6511,6 +6576,7 @@ a non-nil value. */);
6511 defsubr (&Sfile_regular_p); 6576 defsubr (&Sfile_regular_p);
6512 defsubr (&Sfile_modes); 6577 defsubr (&Sfile_modes);
6513 defsubr (&Sset_file_modes); 6578 defsubr (&Sset_file_modes);
6579 defsubr (&Sset_file_times);
6514 defsubr (&Sset_default_file_modes); 6580 defsubr (&Sset_default_file_modes);
6515 defsubr (&Sdefault_file_modes); 6581 defsubr (&Sdefault_file_modes);
6516 defsubr (&Sfile_newer_than_file_p); 6582 defsubr (&Sfile_newer_than_file_p);
diff --git a/src/fns.c b/src/fns.c
index 017f8124013..5e20687494c 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1,5 +1,5 @@
1/* Random utility Lisp functions. 1/* Random utility Lisp functions.
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 98, 99, 2000, 2001, 02, 2003 2 Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 98, 99, 2000, 2001, 02, 03, 2004
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -473,7 +473,8 @@ with the original. */)
473 { 473 {
474 Lisp_Object val; 474 Lisp_Object val;
475 int size_in_chars 475 int size_in_chars
476 = (XBOOL_VECTOR (arg)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; 476 = ((XBOOL_VECTOR (arg)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
477 / BOOL_VECTOR_BITS_PER_CHAR);
477 478
478 val = Fmake_bool_vector (Flength (arg), Qnil); 479 val = Fmake_bool_vector (Flength (arg), Qnil);
479 bcopy (XBOOL_VECTOR (arg)->data, XBOOL_VECTOR (val)->data, 480 bcopy (XBOOL_VECTOR (arg)->data, XBOOL_VECTOR (val)->data,
@@ -486,29 +487,6 @@ with the original. */)
486 return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0); 487 return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0);
487} 488}
488 489
489#if 0 /* unused */
490/* In string STR of length LEN, see if bytes before STR[I] combine
491 with bytes after STR[I] to form a single character. If so, return
492 the number of bytes after STR[I] which combine in this way.
493 Otherwize, return 0. */
494
495static int
496count_combining (str, len, i)
497 unsigned char *str;
498 int len, i;
499{
500 int j = i - 1, bytes;
501
502 if (i == 0 || i == len || CHAR_HEAD_P (str[i]))
503 return 0;
504 while (j >= 0 && !CHAR_HEAD_P (str[j])) j--;
505 if (j < 0 || ! BASE_LEADING_CODE_P (str[j]))
506 return 0;
507 PARSE_MULTIBYTE_SEQ (str + j, len - j, bytes);
508 return (bytes <= i - j ? 0 : bytes - (i - j));
509}
510#endif
511
512/* This structure holds information of an argument of `concat' that is 490/* This structure holds information of an argument of `concat' that is
513 a string and has text properties to be copied. */ 491 a string and has text properties to be copied. */
514struct textprop_rec 492struct textprop_rec
@@ -682,6 +660,7 @@ concat (nargs, args, target_type, last_special)
682 } 660 }
683 toindex_byte += thislen_byte; 661 toindex_byte += thislen_byte;
684 toindex += thisleni; 662 toindex += thisleni;
663 STRING_SET_CHARS (val, SCHARS (val));
685 } 664 }
686 /* Copy a single-byte string to a multibyte string. */ 665 /* Copy a single-byte string to a multibyte string. */
687 else if (STRINGP (this) && STRINGP (val)) 666 else if (STRINGP (this) && STRINGP (val))
@@ -735,8 +714,8 @@ concat (nargs, args, target_type, last_special)
735 else if (BOOL_VECTOR_P (this)) 714 else if (BOOL_VECTOR_P (this))
736 { 715 {
737 int byte; 716 int byte;
738 byte = XBOOL_VECTOR (this)->data[thisindex / BITS_PER_CHAR]; 717 byte = XBOOL_VECTOR (this)->data[thisindex / BOOL_VECTOR_BITS_PER_CHAR];
739 if (byte & (1 << (thisindex % BITS_PER_CHAR))) 718 if (byte & (1 << (thisindex % BOOL_VECTOR_BITS_PER_CHAR)))
740 elt = Qt; 719 elt = Qt;
741 else 720 else
742 elt = Qnil; 721 elt = Qnil;
@@ -993,16 +972,24 @@ string_make_unibyte (string)
993 Lisp_Object string; 972 Lisp_Object string;
994{ 973{
995 unsigned char *buf; 974 unsigned char *buf;
975 Lisp_Object ret;
996 976
997 if (! STRING_MULTIBYTE (string)) 977 if (! STRING_MULTIBYTE (string))
998 return string; 978 return string;
999 979
1000 buf = (unsigned char *) alloca (SCHARS (string)); 980 /* We can not use alloca here, because string might be very long.
981 For example when selecting megabytes of text and then pasting it to
982 another application. */
983 buf = (unsigned char *) xmalloc (SCHARS (string));
1001 984
1002 copy_text (SDATA (string), buf, SBYTES (string), 985 copy_text (SDATA (string), buf, SBYTES (string),
1003 1, 0); 986 1, 0);
1004 987
1005 return make_unibyte_string (buf, SCHARS (string)); 988 ret = make_unibyte_string (buf, SCHARS (string));
989
990 xfree (buf);
991
992 return ret;
1006} 993}
1007 994
1008DEFUN ("string-make-multibyte", Fstring_make_multibyte, Sstring_make_multibyte, 995DEFUN ("string-make-multibyte", Fstring_make_multibyte, Sstring_make_multibyte,
@@ -1475,7 +1462,7 @@ assq_no_quit (key, list)
1475DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0, 1462DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0,
1476 doc: /* Return non-nil if KEY is `equal' to the car of an element of LIST. 1463 doc: /* Return non-nil if KEY is `equal' to the car of an element of LIST.
1477The value is actually the first element of LIST whose car equals KEY. */) 1464The value is actually the first element of LIST whose car equals KEY. */)
1478 (key, list) 1465 (key, list)
1479 Lisp_Object key, list; 1466 Lisp_Object key, list;
1480{ 1467{
1481 Lisp_Object result, car; 1468 Lisp_Object result, car;
@@ -2050,6 +2037,18 @@ The PLIST is modified by side effects. */)
2050 return plist; 2037 return plist;
2051} 2038}
2052 2039
2040DEFUN ("eql", Feql, Seql, 2, 2, 0,
2041 doc: /* Return t if the two args are the same Lisp object.
2042Floating-point numbers of equal value are `eql', but they may not be `eq'. */)
2043 (obj1, obj2)
2044 Lisp_Object obj1, obj2;
2045{
2046 if (FLOATP (obj1))
2047 return internal_equal (obj1, obj2, 0, 0) ? Qt : Qnil;
2048 else
2049 return EQ (obj1, obj2) ? Qt : Qnil;
2050}
2051
2053DEFUN ("equal", Fequal, Sequal, 2, 2, 0, 2052DEFUN ("equal", Fequal, Sequal, 2, 2, 0,
2054 doc: /* Return t if two Lisp objects have similar structure and contents. 2053 doc: /* Return t if two Lisp objects have similar structure and contents.
2055They must have the same data type. 2054They must have the same data type.
@@ -2148,7 +2147,8 @@ internal_equal (o1, o2, depth, props)
2148 if (BOOL_VECTOR_P (o1)) 2147 if (BOOL_VECTOR_P (o1))
2149 { 2148 {
2150 int size_in_chars 2149 int size_in_chars
2151 = (XBOOL_VECTOR (o1)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; 2150 = ((XBOOL_VECTOR (o1)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
2151 / BOOL_VECTOR_BITS_PER_CHAR);
2152 2152
2153 if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size) 2153 if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size)
2154 return 0; 2154 return 0;
@@ -2260,7 +2260,8 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2260 { 2260 {
2261 register unsigned char *p = XBOOL_VECTOR (array)->data; 2261 register unsigned char *p = XBOOL_VECTOR (array)->data;
2262 int size_in_chars 2262 int size_in_chars
2263 = (XBOOL_VECTOR (array)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; 2263 = ((XBOOL_VECTOR (array)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
2264 / BOOL_VECTOR_BITS_PER_CHAR);
2264 2265
2265 charval = (! NILP (item) ? -1 : 0); 2266 charval = (! NILP (item) ? -1 : 0);
2266 for (index = 0; index < size_in_chars - 1; index++) 2267 for (index = 0; index < size_in_chars - 1; index++)
@@ -2268,8 +2269,8 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2268 if (index < size_in_chars) 2269 if (index < size_in_chars)
2269 { 2270 {
2270 /* Mask out bits beyond the vector size. */ 2271 /* Mask out bits beyond the vector size. */
2271 if (XBOOL_VECTOR (array)->size % BITS_PER_CHAR) 2272 if (XBOOL_VECTOR (array)->size % BOOL_VECTOR_BITS_PER_CHAR)
2272 charval &= (1 << (XBOOL_VECTOR (array)->size % BITS_PER_CHAR)) - 1; 2273 charval &= (1 << (XBOOL_VECTOR (array)->size % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
2273 p[index] = charval; 2274 p[index] = charval;
2274 } 2275 }
2275 } 2276 }
@@ -2398,8 +2399,8 @@ mapcar1 (leni, vals, fn, seq)
2398 for (i = 0; i < leni; i++) 2399 for (i = 0; i < leni; i++)
2399 { 2400 {
2400 int byte; 2401 int byte;
2401 byte = XBOOL_VECTOR (seq)->data[i / BITS_PER_CHAR]; 2402 byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR];
2402 if (byte & (1 << (i % BITS_PER_CHAR))) 2403 if (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR)))
2403 dummy = Qt; 2404 dummy = Qt;
2404 else 2405 else
2405 dummy = Qnil; 2406 dummy = Qnil;
@@ -5203,6 +5204,7 @@ used if both `use-dialog-box' and this variable are non-nil. */);
5203 defsubr (&Sput); 5204 defsubr (&Sput);
5204 defsubr (&Slax_plist_get); 5205 defsubr (&Slax_plist_get);
5205 defsubr (&Slax_plist_put); 5206 defsubr (&Slax_plist_put);
5207 defsubr (&Seql);
5206 defsubr (&Sequal); 5208 defsubr (&Sequal);
5207 defsubr (&Sequal_including_properties); 5209 defsubr (&Sequal_including_properties);
5208 defsubr (&Sfillarray); 5210 defsubr (&Sfillarray);
diff --git a/src/fontset.c b/src/fontset.c
index 4212a40541e..016c62f0e50 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1712,7 +1712,10 @@ If the named font is not yet loaded, return nil. */)
1712/* Return a cons (FONT-NAME . GLYPH-CODE). 1712/* Return a cons (FONT-NAME . GLYPH-CODE).
1713 FONT-NAME is the font name for the character at POSITION in the current 1713 FONT-NAME is the font name for the character at POSITION in the current
1714 buffer. This is computed from all the text properties and overlays 1714 buffer. This is computed from all the text properties and overlays
1715 that apply to POSITION. 1715 that apply to POSITION. POSTION may be nil, in which case,
1716 FONT-NAME is the font name for display the character CH with the
1717 default face.
1718
1716 GLYPH-CODE is the glyph code in the font to use for the character. 1719 GLYPH-CODE is the glyph code in the font to use for the character.
1717 1720
1718 If the 2nd optional arg CH is non-nil, it is a character to check 1721 If the 2nd optional arg CH is non-nil, it is a character to check
@@ -1725,7 +1728,8 @@ If the named font is not yet loaded, return nil. */)
1725 1728
1726 (2) The character code is invalid. 1729 (2) The character code is invalid.
1727 1730
1728 (3) The current buffer is not displayed in any window. 1731 (3) If POSITION is not nil, and the current buffer is not displayed
1732 in any window.
1729 1733
1730 In addition, the returned font name may not take into account of 1734 In addition, the returned font name may not take into account of
1731 such redisplay engine hooks as what used in jit-lock-mode if 1735 such redisplay engine hooks as what used in jit-lock-mode if
@@ -1740,39 +1744,53 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
1740 int pos, pos_byte, dummy; 1744 int pos, pos_byte, dummy;
1741 int face_id; 1745 int face_id;
1742 int c; 1746 int c;
1743 Lisp_Object window;
1744 struct window *w;
1745 struct frame *f; 1747 struct frame *f;
1746 struct face *face; 1748 struct face *face;
1747 Lisp_Object charset, rfont_def; 1749 Lisp_Object charset, rfont_def;
1748 int charset_id; 1750 int id;
1749 1751
1750 CHECK_NUMBER_COERCE_MARKER (position); 1752 if (NILP (position))
1751 pos = XINT (position);
1752 if (pos < BEGV || pos >= ZV)
1753 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
1754 pos_byte = CHAR_TO_BYTE (pos);
1755 if (NILP (ch))
1756 c = FETCH_CHAR (pos_byte);
1757 else
1758 { 1753 {
1759 CHECK_CHARACTER (ch); 1754 CHECK_CHARACTER (ch);
1760 c = XINT (ch); 1755 c = XINT (ch);
1756 f = XFRAME (selected_frame);
1757 face_id = DEFAULT_FACE_ID;
1758 pos = -1;
1759 }
1760 else
1761 {
1762 Lisp_Object window;
1763 struct window *w;
1764
1765 CHECK_NUMBER_COERCE_MARKER (position);
1766 pos = XINT (position);
1767 if (pos < BEGV || pos >= ZV)
1768 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
1769 pos_byte = CHAR_TO_BYTE (pos);
1770 if (NILP (ch))
1771 c = FETCH_CHAR (pos_byte);
1772 else
1773 {
1774 CHECK_NATNUM (ch);
1775 c = XINT (ch);
1776 }
1777 window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
1778 if (NILP (window))
1779 return Qnil;
1780 w = XWINDOW (window);
1781 f = XFRAME (w->frame);
1782 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0);
1761 } 1783 }
1762 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); 1784 if (! CHAR_VALID_P (c, 0))
1763 if (NILP (window))
1764 return Qnil; 1785 return Qnil;
1765 w = XWINDOW (window); 1786 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
1766 f = XFRAME (w->frame);
1767 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0);
1768 face = FACE_FROM_ID (f, face_id); 1787 face = FACE_FROM_ID (f, face_id);
1769 charset = Fget_char_property (position, Qcharset, Qnil); 1788 charset = Fget_char_property (position, Qcharset, Qnil);
1770 if (CHARSETP (charset)) 1789 if (CHARSETP (charset))
1771 charset_id = XINT (CHARSET_SYMBOL_ID (charset)); 1790 id = XINT (CHARSET_SYMBOL_ID (charset));
1772 else 1791 else
1773 charset_id = -1; 1792 id = -1;
1774 rfont_def = fontset_font (FONTSET_FROM_ID (face->fontset), 1793 rfont_def = fontset_font (FONTSET_FROM_ID (face->fontset), c, face, id);
1775 c, face, charset_id);
1776 if (VECTORP (rfont_def) && STRINGP (AREF (rfont_def, 3))) 1794 if (VECTORP (rfont_def) && STRINGP (AREF (rfont_def, 3)))
1777 { 1795 {
1778 Lisp_Object font_def; 1796 Lisp_Object font_def;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 4d0b50573f7..84aa9f46d4d 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -229,23 +229,100 @@ xg_create_default_cursor (dpy)
229 return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR); 229 return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR);
230} 230}
231 231
232/* For the image defined in IMG, make and return a GdkPixmap for 232/* For the image defined in IMG, make and return a GtkImage. For displays with
233 the pixmap in *GPIX, and a GdkBitmap for the mask in *GMASK. 233 8 planes or less we must make a GdkPixbuf and apply the mask manually.
234 If IMG has no mask, *GMASK is set to NULL. 234 Otherwise the highlightning and dimming the tool bar code in GTK does
235 The image is defined on the display where frame F is. */ 235 will look bad. For display with more than 8 planes we just use the
236static void 236 pixmap and mask directly. For monochrome displays, GTK doesn't seem
237xg_get_gdk_pixmap_and_mask (f, img, gpix, gmask) 237 able to use external pixmaps, it looks bad whatever we do.
238 The image is defined on the display where frame F is.
239 WIDGET is used to find the GdkColormap to use for the GdkPixbuf.
240 If OLD_WIDGET is NULL, a new widget is constructed and returned.
241 If OLD_WIDGET is not NULL, that widget is modified. */
242static GtkWidget *
243xg_get_image_for_pixmap (f, img, widget, old_widget)
238 FRAME_PTR f; 244 FRAME_PTR f;
239 struct image *img; 245 struct image *img;
240 GdkPixmap **gpix; 246 GtkWidget *widget;
241 GdkBitmap **gmask; 247 GtkImage *old_widget;
242{ 248{
249 GdkPixmap *gpix;
250 GdkPixmap *gmask;
243 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); 251 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
244 252
245 *gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); 253 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap);
246 *gmask = img->mask ? 254 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0;
247 (GdkBitmap*) gdk_pixmap_foreign_new_for_display (gdpy, img->mask) 255
248 : 0; 256 if (x_screen_planes (f) > 8 || x_screen_planes (f) == 1)
257 {
258 if (! old_widget)
259 old_widget = GTK_IMAGE (gtk_image_new_from_pixmap (gpix, gmask));
260 else
261 gtk_image_set_from_pixmap (old_widget, gpix, gmask);
262 }
263 else
264 {
265 int x, y, width, height, rowstride, mask_rowstride;
266 GdkPixbuf *icon_buf, *tmp_buf;
267 guchar *pixels;
268 guchar *mask_pixels;
269
270 gdk_drawable_get_size (gpix, &width, &height);
271 tmp_buf = gdk_pixbuf_get_from_drawable (NULL,
272 gpix,
273 gtk_widget_get_colormap (widget),
274 0, 0, 0, 0, width, height);
275 icon_buf = gdk_pixbuf_add_alpha (tmp_buf, FALSE, 0, 0, 0);
276 g_object_unref (G_OBJECT (tmp_buf));
277
278 if (gmask)
279 {
280 GdkPixbuf *mask_buf = gdk_pixbuf_get_from_drawable (NULL,
281 gmask,
282 NULL,
283 0, 0, 0, 0,
284 width, height);
285 guchar *pixels = gdk_pixbuf_get_pixels (icon_buf);
286 guchar *mask_pixels = gdk_pixbuf_get_pixels (mask_buf);
287 int rowstride = gdk_pixbuf_get_rowstride (icon_buf);
288 int mask_rowstride = gdk_pixbuf_get_rowstride (mask_buf);
289 int y;
290
291 for (y = 0; y < height; ++y)
292 {
293 guchar *iconptr, *maskptr;
294 int x;
295
296 iconptr = pixels + y * rowstride;
297 maskptr = mask_pixels + y * mask_rowstride;
298
299 for (x = 0; x < width; ++x)
300 {
301 /* In a bitmap, RGB is either 255/255/255 or 0/0/0. Checking
302 just R is sufficient. */
303 if (maskptr[0] == 0)
304 iconptr[3] = 0; /* 0, 1, 2 is R, G, B. 3 is alpha. */
305
306 iconptr += rowstride/width;
307 maskptr += mask_rowstride/width;
308 }
309 }
310
311 g_object_unref (G_OBJECT (gmask));
312 g_object_unref (G_OBJECT (mask_buf));
313 }
314
315 g_object_unref (G_OBJECT (gpix));
316
317 if (! old_widget)
318 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf));
319 else
320 gtk_image_set_from_pixbuf (old_widget, icon_buf);
321
322 g_object_unref (G_OBJECT (icon_buf));
323 }
324
325 return GTK_WIDGET (old_widget);
249} 326}
250 327
251 328
@@ -2760,18 +2837,16 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height,
2760 if (wscroll) 2837 if (wscroll)
2761 { 2838 {
2762 GtkWidget *wfixed = f->output_data.x->edit_widget; 2839 GtkWidget *wfixed = f->output_data.x->edit_widget;
2763 int winextra = canon_width > width ? (canon_width - width) / 2 : 0;
2764 int bottom = top + height;
2765 2840
2766 gint slider_width; 2841 gtk_container_set_reallocate_redraws (GTK_CONTAINER (wfixed), TRUE);
2767 int oldtop, oldleft, oldbottom;
2768 GtkRequisition req;
2769 2842
2770 /* Get old values. */ 2843 /* Move and resize to new values. */
2771 xg_find_top_left_in_fixed (wscroll, wfixed, &oldleft, &oldtop); 2844 gtk_fixed_move (GTK_FIXED (wfixed), wscroll, left, top);
2772 gtk_widget_size_request (wscroll, &req); 2845 gtk_widget_set_size_request (wscroll, width, height);
2773 oldbottom = oldtop + req.height;
2774 2846
2847 /* Must force out update so changed scroll bars gets redrawn. */
2848 gdk_window_process_all_updates ();
2849
2775 /* Scroll bars in GTK has a fixed width, so if we say width 16, it 2850 /* Scroll bars in GTK has a fixed width, so if we say width 16, it
2776 will only be its fixed width (14 is default) anyway, the rest is 2851 will only be its fixed width (14 is default) anyway, the rest is
2777 blank. We are drawing the mode line across scroll bars when 2852 blank. We are drawing the mode line across scroll bars when
@@ -2799,62 +2874,7 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height,
2799 the scroll bar and the edge of the window and between the scroll 2874 the scroll bar and the edge of the window and between the scroll
2800 bar and the fringe. */ 2875 bar and the fringe. */
2801 2876
2802 if (oldtop != -1 && oldleft != -1) 2877 XClearWindow (FRAME_X_DISPLAY (f), GTK_WIDGET_TO_X_WIN (wscroll));
2803 {
2804 int gtkextral, gtkextrah;
2805 int xl, xr, wbl, wbr;
2806 int bottomdiff, topdiff;
2807
2808 gtk_widget_style_get (wscroll, "slider_width", &slider_width, NULL);
2809 gtkextral = width > slider_width ? (width - slider_width) / 2 : 0;
2810 gtkextrah = gtkextral ? (width - slider_width - gtkextral) : 0;
2811
2812 xl = real_left;
2813 wbl = gtkextral + winextra;
2814 wbr = gtkextrah + winextra;
2815 xr = left + gtkextral + slider_width;
2816 bottomdiff = abs (oldbottom - bottom);
2817 topdiff = abs (oldtop - top);
2818
2819 if (oldleft != left)
2820 {
2821 gdk_window_clear_area (wfixed->window, xl, top, wbl, height);
2822 gdk_window_clear_area (wfixed->window, xr, top, wbr, height);
2823 }
2824
2825 if (oldtop > top)
2826 {
2827 gdk_window_clear_area (wfixed->window, xl, top, wbl, topdiff);
2828 gdk_window_clear_area (wfixed->window, xr, top, wbr, topdiff);
2829 }
2830 else if (oldtop < top)
2831 {
2832 gdk_window_clear_area (wfixed->window, xl, oldtop, wbl, topdiff);
2833 gdk_window_clear_area (wfixed->window, xr, oldtop, wbr, topdiff);
2834 }
2835
2836 if (oldbottom > bottom)
2837 {
2838 gdk_window_clear_area (wfixed->window, xl, bottom, wbl,
2839 bottomdiff);
2840 gdk_window_clear_area (wfixed->window, xr, bottom, wbr,
2841 bottomdiff);
2842 }
2843 else if (oldbottom < bottom)
2844 {
2845 gdk_window_clear_area (wfixed->window, xl, oldbottom, wbl,
2846 bottomdiff);
2847 gdk_window_clear_area (wfixed->window, xr, oldbottom, wbr,
2848 bottomdiff);
2849 }
2850 }
2851
2852 /* Move and resize to new values. */
2853 gtk_fixed_move (GTK_FIXED (wfixed), wscroll, left, top);
2854 gtk_widget_set_size_request (wscroll, width, height);
2855
2856 /* Must force out update so changed scroll bars gets redrawn. */
2857 gdk_window_process_all_updates ();
2858 2878
2859 SET_FRAME_GARBAGED (f); 2879 SET_FRAME_GARBAGED (f);
2860 cancel_mouse_face (f); 2880 cancel_mouse_face (f);
@@ -3262,12 +3282,8 @@ update_frame_tool_bar (f)
3262 3282
3263 if (! wicon) 3283 if (! wicon)
3264 { 3284 {
3265 GdkPixmap *gpix; 3285 GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
3266 GdkBitmap *gmask;
3267 GtkWidget *w;
3268 3286
3269 xg_get_gdk_pixmap_and_mask (f, img, &gpix, &gmask);
3270 w = gtk_image_new_from_pixmap (gpix, gmask);
3271 gtk_toolbar_append_item (GTK_TOOLBAR (x->toolbar_widget), 3287 gtk_toolbar_append_item (GTK_TOOLBAR (x->toolbar_widget),
3272 0, 0, 0, 3288 0, 0, 0,
3273 w, 3289 w,
@@ -3324,13 +3340,7 @@ update_frame_tool_bar (f)
3324 g_list_free (chlist); 3340 g_list_free (chlist);
3325 3341
3326 if (old_img != img->pixmap) 3342 if (old_img != img->pixmap)
3327 { 3343 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage);
3328 GdkPixmap *gpix;
3329 GdkBitmap *gmask;
3330
3331 xg_get_gdk_pixmap_and_mask (f, img, &gpix, &gmask);
3332 gtk_image_set_from_pixmap (wimage, gpix, gmask);
3333 }
3334 3344
3335 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, 3345 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
3336 (gpointer)img->pixmap); 3346 (gpointer)img->pixmap);
diff --git a/src/image.c b/src/image.c
index 34db5e53367..438e132807f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. */
23#include <signal.h> 23#include <signal.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <math.h> 25#include <math.h>
26#include <ctype.h>
26 27
27#ifdef HAVE_UNISTD_H 28#ifdef HAVE_UNISTD_H
28#include <unistd.h> 29#include <unistd.h>
@@ -51,7 +52,6 @@ Boston, MA 02111-1307, USA. */
51typedef struct x_bitmap_record Bitmap_Record; 52typedef struct x_bitmap_record Bitmap_Record;
52#define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) 53#define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y)
53#define NO_PIXMAP None 54#define NO_PIXMAP None
54#define PNG_BG_COLOR_SHIFT 0
55 55
56#define RGB_PIXEL_COLOR unsigned long 56#define RGB_PIXEL_COLOR unsigned long
57 57
@@ -69,7 +69,6 @@ typedef struct x_bitmap_record Bitmap_Record;
69typedef struct w32_bitmap_record Bitmap_Record; 69typedef struct w32_bitmap_record Bitmap_Record;
70#define GET_PIXEL(ximg, x, y) GetPixel(ximg, x, y) 70#define GET_PIXEL(ximg, x, y) GetPixel(ximg, x, y)
71#define NO_PIXMAP 0 71#define NO_PIXMAP 0
72#define PNG_BG_COLOR_SHIFT 0
73 72
74#define RGB_PIXEL_COLOR COLORREF 73#define RGB_PIXEL_COLOR COLORREF
75 74
@@ -104,7 +103,6 @@ typedef struct mac_bitmap_record Bitmap_Record;
104 103
105#define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) 104#define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y)
106#define NO_PIXMAP 0 105#define NO_PIXMAP 0
107#define PNG_BG_COLOR_SHIFT 8
108 106
109#define RGB_PIXEL_COLOR unsigned long 107#define RGB_PIXEL_COLOR unsigned long
110 108
@@ -177,14 +175,19 @@ XPutPixel (ximage, x, y, pixel)
177 int x, y; 175 int x, y;
178 unsigned long pixel; 176 unsigned long pixel;
179{ 177{
178 CGrafPtr old_port;
179 GDHandle old_gdh;
180 RGBColor color; 180 RGBColor color;
181 181
182 GetGWorld (&old_port, &old_gdh);
182 SetGWorld (ximage, NULL); 183 SetGWorld (ximage, NULL);
183 184
184 color.red = RED16_FROM_ULONG (pixel); 185 color.red = RED16_FROM_ULONG (pixel);
185 color.green = GREEN16_FROM_ULONG (pixel); 186 color.green = GREEN16_FROM_ULONG (pixel);
186 color.blue = BLUE16_FROM_ULONG (pixel); 187 color.blue = BLUE16_FROM_ULONG (pixel);
187 SetCPixel (x, y, &color); 188 SetCPixel (x, y, &color);
189
190 SetGWorld (old_port, old_gdh);
188} 191}
189 192
190static unsigned long 193static unsigned long
@@ -192,11 +195,16 @@ XGetPixel (ximage, x, y)
192 XImagePtr ximage; 195 XImagePtr ximage;
193 int x, y; 196 int x, y;
194{ 197{
198 CGrafPtr old_port;
199 GDHandle old_gdh;
195 RGBColor color; 200 RGBColor color;
196 201
202 GetGWorld (&old_port, &old_gdh);
197 SetGWorld (ximage, NULL); 203 SetGWorld (ximage, NULL);
198 204
199 GetCPixel (x, y, &color); 205 GetCPixel (x, y, &color);
206
207 SetGWorld (old_port, old_gdh);
200 return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); 208 return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8);
201} 209}
202 210
@@ -206,7 +214,7 @@ XDestroyImage (ximg)
206{ 214{
207 UnlockPixels (GetGWorldPixMap (ximg)); 215 UnlockPixels (GetGWorldPixMap (ximg));
208} 216}
209#endif 217#endif /* MAC_OS */
210 218
211 219
212/* Functions to access the contents of a bitmap, given an id. */ 220/* Functions to access the contents of a bitmap, given an id. */
@@ -598,6 +606,14 @@ x_create_bitmap_mask (f, id)
598 606
599static struct image_type *image_types; 607static struct image_type *image_types;
600 608
609/* A list of symbols, one for each supported image type. */
610
611Lisp_Object Vimage_types;
612
613/* Cache for delayed-loading image types. */
614
615static Lisp_Object Vimage_type_cache;
616
601/* The symbol `xbm' which is used as the type symbol for XBM images. */ 617/* The symbol `xbm' which is used as the type symbol for XBM images. */
602 618
603Lisp_Object Qxbm; 619Lisp_Object Qxbm;
@@ -622,7 +638,7 @@ Lisp_Object Vimage_cache_eviction_delay;
622 638
623/* Function prototypes. */ 639/* Function prototypes. */
624 640
625static void define_image_type P_ ((struct image_type *type)); 641static Lisp_Object define_image_type P_ ((struct image_type *type, int loaded));
626static struct image_type *lookup_image_type P_ ((Lisp_Object symbol)); 642static struct image_type *lookup_image_type P_ ((Lisp_Object symbol));
627static void image_error P_ ((char *format, Lisp_Object, Lisp_Object)); 643static void image_error P_ ((char *format, Lisp_Object, Lisp_Object));
628static void x_laplace P_ ((struct frame *, struct image *)); 644static void x_laplace P_ ((struct frame *, struct image *));
@@ -630,21 +646,37 @@ static void x_emboss P_ ((struct frame *, struct image *));
630static int x_build_heuristic_mask P_ ((struct frame *, struct image *, 646static int x_build_heuristic_mask P_ ((struct frame *, struct image *,
631 Lisp_Object)); 647 Lisp_Object));
632 648
649#define CACHE_IMAGE_TYPE(type, status) \
650 do { Vimage_type_cache = Fcons (Fcons (type, status), Vimage_type_cache); } while (0)
651
652#define ADD_IMAGE_TYPE(type) \
653 do { Vimage_types = Fcons (type, Vimage_types); } while (0)
633 654
634/* Define a new image type from TYPE. This adds a copy of TYPE to 655/* Define a new image type from TYPE. This adds a copy of TYPE to
635 image_types and adds the symbol *TYPE->type to Vimage_types. */ 656 image_types and caches the loading status of TYPE. */
636 657
637static void 658static Lisp_Object
638define_image_type (type) 659define_image_type (type, loaded)
639 struct image_type *type; 660 struct image_type *type;
661 int loaded;
640{ 662{
641 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. 663 Lisp_Object success;
642 The initialized data segment is read-only. */ 664
643 struct image_type *p = (struct image_type *) xmalloc (sizeof *p); 665 if (!loaded)
644 bcopy (type, p, sizeof *p); 666 success = Qnil;
645 p->next = image_types; 667 else
646 image_types = p; 668 {
647 Vimage_types = Fcons (*p->type, Vimage_types); 669 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
670 The initialized data segment is read-only. */
671 struct image_type *p = (struct image_type *) xmalloc (sizeof *p);
672 bcopy (type, p, sizeof *p);
673 p->next = image_types;
674 image_types = p;
675 success = Qt;
676 }
677
678 CACHE_IMAGE_TYPE(*type->type, success);
679 return success;
648} 680}
649 681
650 682
@@ -657,6 +689,10 @@ lookup_image_type (symbol)
657{ 689{
658 struct image_type *type; 690 struct image_type *type;
659 691
692 /* We must initialize the image-type if it hasn't been already. */
693 if (NILP (Finit_image_library (symbol)))
694 return 0; /* unimplemented */
695
660 for (type = image_types; type; type = type->next) 696 for (type = image_types; type; type = type->next)
661 if (EQ (symbol, *type->type)) 697 if (EQ (symbol, *type->type))
662 break; 698 break;
@@ -1079,13 +1115,21 @@ prepare_image_for_display (f, img)
1079 drawn in face FACE. */ 1115 drawn in face FACE. */
1080 1116
1081int 1117int
1082image_ascent (img, face) 1118image_ascent (img, face, slice)
1083 struct image *img; 1119 struct image *img;
1084 struct face *face; 1120 struct face *face;
1121 struct glyph_slice *slice;
1085{ 1122{
1086 int height = img->height + img->vmargin; 1123 int height;
1087 int ascent; 1124 int ascent;
1088 1125
1126 if (slice->height == img->height)
1127 height = img->height + img->vmargin;
1128 else if (slice->y == 0)
1129 height = slice->height + img->vmargin;
1130 else
1131 height = slice->height;
1132
1089 if (img->ascent == CENTERED_IMAGE_ASCENT) 1133 if (img->ascent == CENTERED_IMAGE_ASCENT)
1090 { 1134 {
1091 if (face->font) 1135 if (face->font)
@@ -1172,7 +1216,7 @@ four_corners_best (ximg, width, height)
1172/* Return the `background' field of IMG. If IMG doesn't have one yet, 1216/* Return the `background' field of IMG. If IMG doesn't have one yet,
1173 it is guessed heuristically. If non-zero, XIMG is an existing 1217 it is guessed heuristically. If non-zero, XIMG is an existing
1174 XImage object (or device context with the image selected on W32) to 1218 XImage object (or device context with the image selected on W32) to
1175 use for the heuristic. */ 1219 use for the heuristic. */
1176 1220
1177RGB_PIXEL_COLOR 1221RGB_PIXEL_COLOR
1178image_background (img, f, ximg) 1222image_background (img, f, ximg)
@@ -1205,7 +1249,7 @@ image_background (img, f, ximg)
1205 1249
1206 if (free_ximg) 1250 if (free_ximg)
1207 Destroy_Image (ximg, prev); 1251 Destroy_Image (ximg, prev);
1208 1252
1209 img->background_valid = 1; 1253 img->background_valid = 1;
1210 } 1254 }
1211 1255
@@ -1581,6 +1625,11 @@ lookup_image (f, spec)
1581 Lisp_Object spec; 1625 Lisp_Object spec;
1582{ 1626{
1583 struct image_cache *c = FRAME_X_IMAGE_CACHE (f); 1627 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
1628#ifdef _MSC_VER
1629 /* Work around a problem with MinGW builds of graphics libraries
1630 not honoring calling conventions. */
1631 static
1632#endif
1584 struct image *img; 1633 struct image *img;
1585 int i; 1634 int i;
1586 unsigned hash; 1635 unsigned hash;
@@ -1768,6 +1817,33 @@ forall_images_in_image_cache (f, fn)
1768 if (!fn_##func) return 0; \ 1817 if (!fn_##func) return 0; \
1769 } 1818 }
1770 1819
1820/* Load a DLL implementing an image type.
1821 The `image-library-alist' variable associates a symbol,
1822 identifying an image type, to a list of possible filenames.
1823 The function returns NULL if no library could be loaded for
1824 the given image type, or if the library was previously loaded;
1825 else the handle of the DLL. */
1826static HMODULE
1827w32_delayed_load (Lisp_Object libraries, Lisp_Object type)
1828{
1829 HMODULE library = NULL;
1830
1831 if (CONSP (libraries) && NILP (Fassq (type, Vimage_type_cache)))
1832 {
1833 Lisp_Object dlls = Fassq (type, libraries);
1834
1835 if (CONSP (dlls))
1836 for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
1837 {
1838 CHECK_STRING_CAR (dlls);
1839 if (library = LoadLibrary (SDATA (XCAR (dlls))))
1840 break;
1841 }
1842 }
1843
1844 return library;
1845}
1846
1771#endif /* HAVE_NTGUI */ 1847#endif /* HAVE_NTGUI */
1772 1848
1773static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, 1849static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int,
@@ -2191,6 +2267,10 @@ image_load_qt_1 (f, img, type, fss, dh)
2191 goto error; 2267 goto error;
2192 if (draw_all_pixels != graphicsImporterDrawsAllPixels) 2268 if (draw_all_pixels != graphicsImporterDrawsAllPixels)
2193 { 2269 {
2270 CGrafPtr old_port;
2271 GDHandle old_gdh;
2272
2273 GetGWorld (&old_port, &old_gdh);
2194 SetGWorld (ximg, NULL); 2274 SetGWorld (ximg, NULL);
2195 bg_color.red = color.red; 2275 bg_color.red = color.red;
2196 bg_color.green = color.green; 2276 bg_color.green = color.green;
@@ -2202,6 +2282,7 @@ image_load_qt_1 (f, img, type, fss, dh)
2202#else 2282#else
2203 EraseRect (&(ximg->portRect)); 2283 EraseRect (&(ximg->portRect));
2204#endif 2284#endif
2285 SetGWorld (old_port, old_gdh);
2205 } 2286 }
2206 GraphicsImportSetGWorld (gi, ximg, NULL); 2287 GraphicsImportSetGWorld (gi, ximg, NULL);
2207 GraphicsImportDraw (gi); 2288 GraphicsImportDraw (gi);
@@ -2990,7 +3071,7 @@ xbm_load_image (f, img, contents, end)
2990 non_default_colors = 1; 3071 non_default_colors = 1;
2991 } 3072 }
2992 3073
2993 Create_Pixmap_From_Bitmap_Data (f, img, data, 3074 Create_Pixmap_From_Bitmap_Data (f, img, data,
2994 foreground, background, 3075 foreground, background,
2995 non_default_colors); 3076 non_default_colors);
2996 xfree (data); 3077 xfree (data);
@@ -3164,28 +3245,36 @@ xbm_load (f, img)
3164 XPM images 3245 XPM images
3165 ***********************************************************************/ 3246 ***********************************************************************/
3166 3247
3167#ifdef HAVE_XPM 3248#if defined (HAVE_XPM) || defined (MAC_OS)
3168 3249
3169static int xpm_image_p P_ ((Lisp_Object object)); 3250static int xpm_image_p P_ ((Lisp_Object object));
3170static int xpm_load P_ ((struct frame *f, struct image *img)); 3251static int xpm_load P_ ((struct frame *f, struct image *img));
3171static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); 3252static int xpm_valid_color_symbols_p P_ ((Lisp_Object));
3172 3253
3254#endif /* HAVE_XPM || MAC_OS */
3255
3256#ifdef HAVE_XPM
3173#ifdef HAVE_NTGUI 3257#ifdef HAVE_NTGUI
3174/* Indicate to xpm.h that we don't have Xlib. */ 3258/* Indicate to xpm.h that we don't have Xlib. */
3175#define FOR_MSW 3259#define FOR_MSW
3176/* simx.h in xpm defines XColor and XImage differently than Emacs. */ 3260/* simx.h in xpm defines XColor and XImage differently than Emacs. */
3261/* It also defines Display the same way as Emacs, but gcc 3.3 still barfs. */
3177#define XColor xpm_XColor 3262#define XColor xpm_XColor
3178#define XImage xpm_XImage 3263#define XImage xpm_XImage
3264#define Display xpm_Display
3179#define PIXEL_ALREADY_TYPEDEFED 3265#define PIXEL_ALREADY_TYPEDEFED
3180#include "X11/xpm.h" 3266#include "X11/xpm.h"
3181#undef FOR_MSW 3267#undef FOR_MSW
3182#undef XColor 3268#undef XColor
3183#undef XImage 3269#undef XImage
3270#undef Display
3184#undef PIXEL_ALREADY_TYPEDEFED 3271#undef PIXEL_ALREADY_TYPEDEFED
3185#else 3272#else
3186#include "X11/xpm.h" 3273#include "X11/xpm.h"
3187#endif /* HAVE_NTGUI */ 3274#endif /* HAVE_NTGUI */
3275#endif /* HAVE_XPM */
3188 3276
3277#if defined (HAVE_XPM) || defined (MAC_OS)
3189/* The symbol `xpm' identifying XPM-format images. */ 3278/* The symbol `xpm' identifying XPM-format images. */
3190 3279
3191Lisp_Object Qxpm; 3280Lisp_Object Qxpm;
@@ -3455,13 +3544,12 @@ DEF_IMGLIB_FN (XpmCreateImageFromBuffer);
3455DEF_IMGLIB_FN (XpmReadFileToImage); 3544DEF_IMGLIB_FN (XpmReadFileToImage);
3456DEF_IMGLIB_FN (XImageFree); 3545DEF_IMGLIB_FN (XImageFree);
3457 3546
3458
3459static int 3547static int
3460init_xpm_functions (void) 3548init_xpm_functions (Lisp_Object libraries)
3461{ 3549{
3462 HMODULE library; 3550 HMODULE library;
3463 3551
3464 if (!(library = LoadLibrary ("libXpm.dll"))) 3552 if (!(library = w32_delayed_load (libraries, Qxpm)))
3465 return 0; 3553 return 0;
3466 3554
3467 LOAD_IMGLIB_FN (library, XpmFreeAttributes); 3555 LOAD_IMGLIB_FN (library, XpmFreeAttributes);
@@ -3513,10 +3601,13 @@ xpm_image_p (object)
3513 || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))); 3601 || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value)));
3514} 3602}
3515 3603
3604#endif /* HAVE_XPM || MAC_OS */
3516 3605
3517/* Load image IMG which will be displayed on frame F. Value is 3606/* Load image IMG which will be displayed on frame F. Value is
3518 non-zero if successful. */ 3607 non-zero if successful. */
3519 3608
3609#ifdef HAVE_XPM
3610
3520static int 3611static int
3521xpm_load (f, img) 3612xpm_load (f, img)
3522 struct frame *f; 3613 struct frame *f;
@@ -3748,6 +3839,467 @@ xpm_load (f, img)
3748 3839
3749#endif /* HAVE_XPM */ 3840#endif /* HAVE_XPM */
3750 3841
3842#ifdef MAC_OS
3843
3844/* XPM support functions for Mac OS where libxpm is not available.
3845 Only XPM version 3 (without any extensions) is supported. */
3846
3847static int xpm_scan P_ ((unsigned char **, unsigned char *,
3848 unsigned char **, int *));
3849static Lisp_Object xpm_make_color_table_v
3850 P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),
3851 Lisp_Object (**) (Lisp_Object, unsigned char *, int)));
3852static void xpm_put_color_table_v P_ ((Lisp_Object, unsigned char *,
3853 int, Lisp_Object));
3854static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object,
3855 unsigned char *, int));
3856static Lisp_Object xpm_make_color_table_h
3857 P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),
3858 Lisp_Object (**) (Lisp_Object, unsigned char *, int)));
3859static void xpm_put_color_table_h P_ ((Lisp_Object, unsigned char *,
3860 int, Lisp_Object));
3861static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object,
3862 unsigned char *, int));
3863static int xpm_str_to_color_key P_ ((char *));
3864static int xpm_load_image P_ ((struct frame *, struct image *,
3865 unsigned char *, unsigned char *));
3866
3867/* Tokens returned from xpm_scan. */
3868
3869enum xpm_token
3870{
3871 XPM_TK_IDENT = 256,
3872 XPM_TK_STRING,
3873 XPM_TK_EOF
3874};
3875
3876/* Scan an XPM data and return a character (< 256) or a token defined
3877 by enum xpm_token above. *S and END are the start (inclusive) and
3878 the end (exclusive) addresses of the data, respectively. Advance
3879 *S while scanning. If token is either XPM_TK_IDENT or
3880 XPM_TK_STRING, *BEG and *LEN are set to the start address and the
3881 length of the corresponding token, respectively. */
3882
3883static int
3884xpm_scan (s, end, beg, len)
3885 unsigned char **s, *end, **beg;
3886 int *len;
3887{
3888 int c;
3889
3890 while (*s < end)
3891 {
3892 /* Skip white-space. */
3893 while (*s < end && (c = *(*s)++, isspace (c)))
3894 ;
3895
3896 /* gnus-pointer.xpm uses '-' in its identifier.
3897 sb-dir-plus.xpm uses '+' in its identifier. */
3898 if (isalpha (c) || c == '_' || c == '-' || c == '+')
3899 {
3900 *beg = *s - 1;
3901 while (*s < end &&
3902 (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+'))
3903 ++*s;
3904 *len = *s - *beg;
3905 return XPM_TK_IDENT;
3906 }
3907 else if (c == '"')
3908 {
3909 *beg = *s;
3910 while (*s < end && **s != '"')
3911 ++*s;
3912 *len = *s - *beg;
3913 if (*s < end)
3914 ++*s;
3915 return XPM_TK_STRING;
3916 }
3917 else if (c == '/')
3918 {
3919 if (*s < end && **s == '*')
3920 {
3921 /* C-style comment. */
3922 ++*s;
3923 do
3924 {
3925 while (*s < end && *(*s)++ != '*')
3926 ;
3927 }
3928 while (*s < end && **s != '/');
3929 if (*s < end)
3930 ++*s;
3931 }
3932 else
3933 return c;
3934 }
3935 else
3936 return c;
3937 }
3938
3939 return XPM_TK_EOF;
3940}
3941
3942/* Functions for color table lookup in XPM data. A Key is a string
3943 specifying the color of each pixel in XPM data. A value is either
3944 an integer that specifies a pixel color, Qt that specifies
3945 transparency, or Qnil for the unspecified color. If the length of
3946 the key string is one, a vector is used as a table. Otherwise, a
3947 hash table is used. */
3948
3949static Lisp_Object
3950xpm_make_color_table_v (put_func, get_func)
3951 void (**put_func) (Lisp_Object, unsigned char *, int, Lisp_Object);
3952 Lisp_Object (**get_func) (Lisp_Object, unsigned char *, int);
3953{
3954 *put_func = xpm_put_color_table_v;
3955 *get_func = xpm_get_color_table_v;
3956 return Fmake_vector (make_number (256), Qnil);
3957}
3958
3959static void
3960xpm_put_color_table_v (color_table, chars_start, chars_len, color)
3961 Lisp_Object color_table;
3962 unsigned char *chars_start;
3963 int chars_len;
3964 Lisp_Object color;
3965{
3966 XVECTOR (color_table)->contents[*chars_start] = color;
3967}
3968
3969static Lisp_Object
3970xpm_get_color_table_v (color_table, chars_start, chars_len)
3971 Lisp_Object color_table;
3972 unsigned char *chars_start;
3973 int chars_len;
3974{
3975 return XVECTOR (color_table)->contents[*chars_start];
3976}
3977
3978static Lisp_Object
3979xpm_make_color_table_h (put_func, get_func)
3980 void (**put_func) (Lisp_Object, unsigned char *, int, Lisp_Object);
3981 Lisp_Object (**get_func) (Lisp_Object, unsigned char *, int);
3982{
3983 *put_func = xpm_put_color_table_h;
3984 *get_func = xpm_get_color_table_h;
3985 return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
3986 make_float (DEFAULT_REHASH_SIZE),
3987 make_float (DEFAULT_REHASH_THRESHOLD),
3988 Qnil, Qnil, Qnil);
3989}
3990
3991static void
3992xpm_put_color_table_h (color_table, chars_start, chars_len, color)
3993 Lisp_Object color_table;
3994 unsigned char *chars_start;
3995 int chars_len;
3996 Lisp_Object color;
3997{
3998 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
3999 unsigned hash_code;
4000 Lisp_Object chars = make_unibyte_string (chars_start, chars_len);
4001
4002 hash_lookup (table, chars, &hash_code);
4003 hash_put (table, chars, color, hash_code);
4004}
4005
4006static Lisp_Object
4007xpm_get_color_table_h (color_table, chars_start, chars_len)
4008 Lisp_Object color_table;
4009 unsigned char *chars_start;
4010 int chars_len;
4011{
4012 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
4013 int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),
4014 NULL);
4015
4016 return i >= 0 ? HASH_VALUE (table, i) : Qnil;
4017}
4018
4019enum xpm_color_key {
4020 XPM_COLOR_KEY_S,
4021 XPM_COLOR_KEY_M,
4022 XPM_COLOR_KEY_G4,
4023 XPM_COLOR_KEY_G,
4024 XPM_COLOR_KEY_C
4025};
4026
4027static char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"};
4028
4029static int
4030xpm_str_to_color_key (s)
4031 char *s;
4032{
4033 int i;
4034
4035 for (i = 0;
4036 i < sizeof xpm_color_key_strings / sizeof xpm_color_key_strings[0];
4037 i++)
4038 if (strcmp (xpm_color_key_strings[i], s) == 0)
4039 return i;
4040 return -1;
4041}
4042
4043static int
4044xpm_load_image (f, img, contents, end)
4045 struct frame *f;
4046 struct image *img;
4047 unsigned char *contents, *end;
4048{
4049 unsigned char *s = contents, *beg, *str;
4050 unsigned char buffer[BUFSIZ];
4051 int width, height, x, y;
4052 int num_colors, chars_per_pixel;
4053 int len, LA1;
4054 void (*put_color_table) (Lisp_Object, unsigned char *, int, Lisp_Object);
4055 Lisp_Object (*get_color_table) (Lisp_Object, unsigned char *, int);
4056 Lisp_Object frame, color_symbols, color_table;
4057 int best_key, have_mask = 0;
4058 XImagePtr ximg = NULL, mask_img = NULL;
4059
4060#define match() \
4061 LA1 = xpm_scan (&s, end, &beg, &len)
4062
4063#define expect(TOKEN) \
4064 if (LA1 != (TOKEN)) \
4065 goto failure; \
4066 else \
4067 match ()
4068
4069#define expect_ident(IDENT) \
4070 if (LA1 == XPM_TK_IDENT \
4071 && strlen ((IDENT)) == len && memcmp ((IDENT), beg, len) == 0) \
4072 match (); \
4073 else \
4074 goto failure
4075
4076 if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0))
4077 goto failure;
4078 s += 9;
4079 match();
4080 expect_ident ("static");
4081 expect_ident ("char");
4082 expect ('*');
4083 expect (XPM_TK_IDENT);
4084 expect ('[');
4085 expect (']');
4086 expect ('=');
4087 expect ('{');
4088 expect (XPM_TK_STRING);
4089 if (len >= BUFSIZ)
4090 goto failure;
4091 memcpy (buffer, beg, len);
4092 buffer[len] = '\0';
4093 if (sscanf (buffer, "%d %d %d %d", &width, &height,
4094 &num_colors, &chars_per_pixel) != 4
4095 || width <= 0 || height <= 0
4096 || num_colors <= 0 || chars_per_pixel <= 0)
4097 goto failure;
4098 expect (',');
4099
4100 XSETFRAME (frame, f);
4101 if (!NILP (Fxw_display_color_p (frame)))
4102 best_key = XPM_COLOR_KEY_C;
4103 else if (!NILP (Fx_display_grayscale_p (frame)))
4104 best_key = (XFASTINT (Fx_display_planes (frame)) > 2
4105 ? XPM_COLOR_KEY_G : XPM_COLOR_KEY_G4);
4106 else
4107 best_key = XPM_COLOR_KEY_M;
4108
4109 color_symbols = image_spec_value (img->spec, QCcolor_symbols, NULL);
4110 if (chars_per_pixel == 1)
4111 color_table = xpm_make_color_table_v (&put_color_table,
4112 &get_color_table);
4113 else
4114 color_table = xpm_make_color_table_h (&put_color_table,
4115 &get_color_table);
4116
4117 while (num_colors-- > 0)
4118 {
4119 unsigned char *color, *max_color;
4120 int key, next_key, max_key = 0;
4121 Lisp_Object symbol_color = Qnil, color_val;
4122 XColor cdef;
4123
4124 expect (XPM_TK_STRING);
4125 if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
4126 goto failure;
4127 memcpy (buffer, beg + chars_per_pixel, len - chars_per_pixel);
4128 buffer[len - chars_per_pixel] = '\0';
4129
4130 str = strtok (buffer, " \t");
4131 if (str == NULL)
4132 goto failure;
4133 key = xpm_str_to_color_key (str);
4134 if (key < 0)
4135 goto failure;
4136 do
4137 {
4138 color = strtok (NULL, " \t");
4139 if (color == NULL)
4140 goto failure;
4141
4142 while (str = strtok (NULL, " \t"))
4143 {
4144 next_key = xpm_str_to_color_key (str);
4145 if (next_key >= 0)
4146 break;
4147 color[strlen (color)] = ' ';
4148 }
4149
4150 if (key == XPM_COLOR_KEY_S)
4151 {
4152 if (NILP (symbol_color))
4153 symbol_color = build_string (color);
4154 }
4155 else if (max_key < key && key <= best_key)
4156 {
4157 max_key = key;
4158 max_color = color;
4159 }
4160 key = next_key;
4161 }
4162 while (str);
4163
4164 color_val = Qnil;
4165 if (!NILP (color_symbols) && !NILP (symbol_color))
4166 {
4167 Lisp_Object specified_color = Fassoc (symbol_color, color_symbols);
4168
4169 if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
4170 if (xstricmp (SDATA (XCDR (specified_color)), "None") == 0)
4171 color_val = Qt;
4172 else if (x_defined_color (f, SDATA (XCDR (specified_color)),
4173 &cdef, 0))
4174 color_val = make_number (cdef.pixel);
4175 }
4176 if (NILP (color_val) && max_key > 0)
4177 if (xstricmp (max_color, "None") == 0)
4178 color_val = Qt;
4179 else if (x_defined_color (f, max_color, &cdef, 0))
4180 color_val = make_number (cdef.pixel);
4181 if (!NILP (color_val))
4182 (*put_color_table) (color_table, beg, chars_per_pixel, color_val);
4183
4184 expect (',');
4185 }
4186
4187 if (!x_create_x_image_and_pixmap (f, width, height, 0,
4188 &ximg, &img->pixmap)
4189 || !x_create_x_image_and_pixmap (f, width, height, 1,
4190 &mask_img, &img->mask))
4191 {
4192 image_error ("Out of memory (%s)", img->spec, Qnil);
4193 goto error;
4194 }
4195
4196 for (y = 0; y < height; y++)
4197 {
4198 expect (XPM_TK_STRING);
4199 str = beg;
4200 if (len < width * chars_per_pixel)
4201 goto failure;
4202 for (x = 0; x < width; x++, str += chars_per_pixel)
4203 {
4204 Lisp_Object color_val =
4205 (*get_color_table) (color_table, str, chars_per_pixel);
4206
4207 XPutPixel (ximg, x, y,
4208 (INTEGERP (color_val) ? XINT (color_val)
4209 : FRAME_FOREGROUND_PIXEL (f)));
4210 XPutPixel (mask_img, x, y,
4211 (!EQ (color_val, Qt) ? PIX_MASK_DRAW (f)
4212 : (have_mask = 1, PIX_MASK_RETAIN (f))));
4213 }
4214 if (y + 1 < height)
4215 expect (',');
4216 }
4217
4218 img->width = width;
4219 img->height = height;
4220
4221 x_put_x_image (f, ximg, img->pixmap, width, height);
4222 x_destroy_x_image (ximg);
4223 if (have_mask)
4224 {
4225 x_put_x_image (f, mask_img, img->mask, width, height);
4226 x_destroy_x_image (mask_img);
4227 }
4228 else
4229 {
4230 x_destroy_x_image (mask_img);
4231 Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
4232 img->mask = NO_PIXMAP;
4233 }
4234
4235 return 1;
4236
4237 failure:
4238 image_error ("Invalid XPM file (%s)", img->spec, Qnil);
4239 error:
4240 x_destroy_x_image (ximg);
4241 x_destroy_x_image (mask_img);
4242 x_clear_image (f, img);
4243 return 0;
4244
4245#undef match
4246#undef expect
4247#undef expect_ident
4248}
4249
4250static int
4251xpm_load (f, img)
4252 struct frame *f;
4253 struct image *img;
4254{
4255 int success_p = 0;
4256 Lisp_Object file_name;
4257
4258 /* If IMG->spec specifies a file name, create a non-file spec from it. */
4259 file_name = image_spec_value (img->spec, QCfile, NULL);
4260 if (STRINGP (file_name))
4261 {
4262 Lisp_Object file;
4263 unsigned char *contents;
4264 int size;
4265 struct gcpro gcpro1;
4266
4267 file = x_find_image_file (file_name);
4268 GCPRO1 (file);
4269 if (!STRINGP (file))
4270 {
4271 image_error ("Cannot find image file `%s'", file_name, Qnil);
4272 UNGCPRO;
4273 return 0;
4274 }
4275
4276 contents = slurp_file (SDATA (file), &size);
4277 if (contents == NULL)
4278 {
4279 image_error ("Error loading XPM image `%s'", img->spec, Qnil);
4280 UNGCPRO;
4281 return 0;
4282 }
4283
4284 success_p = xpm_load_image (f, img, contents, contents + size);
4285 xfree (contents);
4286 UNGCPRO;
4287 }
4288 else
4289 {
4290 Lisp_Object data;
4291
4292 data = image_spec_value (img->spec, QCdata, NULL);
4293 success_p = xpm_load_image (f, img, SDATA (data),
4294 SDATA (data) + SBYTES (data));
4295 }
4296
4297 return success_p;
4298}
4299
4300#endif /* MAC_OS */
4301
4302
3751 4303
3752/*********************************************************************** 4304/***********************************************************************
3753 Color table 4305 Color table
@@ -3857,7 +4409,7 @@ lookup_rgb_color (f, r, g, b)
3857 /* Assemble the pixel color. */ 4409 /* Assemble the pixel color. */
3858 return pr | pg | pb; 4410 return pr | pg | pb;
3859 } 4411 }
3860 4412
3861 for (p = ct_table[i]; p; p = p->next) 4413 for (p = ct_table[i]; p; p = p->next)
3862 if (p->r == r && p->g == g && p->b == b) 4414 if (p->r == r && p->g == g && p->b == b)
3863 break; 4415 break;
@@ -4968,7 +5520,7 @@ pbm_load (f, img)
4968 x_destroy_x_image (ximg); 5520 x_destroy_x_image (ximg);
4969 5521
4970 /* X and W32 versions did it here, MAC version above. ++kfs 5522 /* X and W32 versions did it here, MAC version above. ++kfs
4971 img->width = width; 5523 img->width = width;
4972 img->height = height; */ 5524 img->height = height; */
4973 5525
4974 UNGCPRO; 5526 UNGCPRO;
@@ -5091,21 +5643,12 @@ DEF_IMGLIB_FN (png_read_end);
5091DEF_IMGLIB_FN (png_error); 5643DEF_IMGLIB_FN (png_error);
5092 5644
5093static int 5645static int
5094init_png_functions (void) 5646init_png_functions (Lisp_Object libraries)
5095{ 5647{
5096 HMODULE library; 5648 HMODULE library;
5097 5649
5098 /* Ensure zlib is loaded. Try debug version first. */
5099 if (!LoadLibrary ("zlibd.dll")
5100 && !LoadLibrary ("zlib.dll"))
5101 return 0;
5102
5103 /* Try loading libpng under probable names. */ 5650 /* Try loading libpng under probable names. */
5104 if (!(library = LoadLibrary ("libpng13d.dll")) 5651 if (!(library = w32_delayed_load (libraries, Qpng)))
5105 && !(library = LoadLibrary ("libpng13.dll"))
5106 && !(library = LoadLibrary ("libpng12d.dll"))
5107 && !(library = LoadLibrary ("libpng12.dll"))
5108 && !(library = LoadLibrary ("libpng.dll")))
5109 return 0; 5652 return 0;
5110 5653
5111 LOAD_IMGLIB_FN (library, png_get_io_ptr); 5654 LOAD_IMGLIB_FN (library, png_get_io_ptr);
@@ -5196,6 +5739,12 @@ struct png_memory_storage
5196 PNG_PTR is a pointer to the PNG control structure. Copy LENGTH 5739 PNG_PTR is a pointer to the PNG control structure. Copy LENGTH
5197 bytes from the input to DATA. */ 5740 bytes from the input to DATA. */
5198 5741
5742#ifdef _MSC_VER
5743 /* Work around a problem with MinGW builds of graphics libraries
5744 not honoring calling conventions. */
5745#pragma optimize("g", off)
5746#endif
5747
5199static void 5748static void
5200png_read_from_memory (png_ptr, data, length) 5749png_read_from_memory (png_ptr, data, length)
5201 png_structp png_ptr; 5750 png_structp png_ptr;
@@ -5212,6 +5761,11 @@ png_read_from_memory (png_ptr, data, length)
5212 tbr->index = tbr->index + length; 5761 tbr->index = tbr->index + length;
5213} 5762}
5214 5763
5764#ifdef _MSC_VER
5765/* Restore normal optimization, as specified on the command line. */
5766#pragma optimize("", on)
5767#endif
5768
5215/* Load PNG image IMG for use on frame F. Value is non-zero if 5769/* Load PNG image IMG for use on frame F. Value is non-zero if
5216 successful. */ 5770 successful. */
5217 5771
@@ -5412,9 +5966,9 @@ png_load (f, img)
5412 png_color_16 user_bg; 5966 png_color_16 user_bg;
5413 5967
5414 bzero (&user_bg, sizeof user_bg); 5968 bzero (&user_bg, sizeof user_bg);
5415 user_bg.red = color.red >> PNG_BG_COLOR_SHIFT; 5969 user_bg.red = color.red >> 8;
5416 user_bg.green = color.green >> PNG_BG_COLOR_SHIFT; 5970 user_bg.green = color.green >> 8;
5417 user_bg.blue = color.blue >> PNG_BG_COLOR_SHIFT; 5971 user_bg.blue = color.blue >> 8;
5418 5972
5419 fn_png_set_background (png_ptr, &user_bg, 5973 fn_png_set_background (png_ptr, &user_bg,
5420 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 5974 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
@@ -5438,9 +5992,9 @@ png_load (f, img)
5438 x_query_color (f, &color); 5992 x_query_color (f, &color);
5439 5993
5440 bzero (&frame_background, sizeof frame_background); 5994 bzero (&frame_background, sizeof frame_background);
5441 frame_background.red = color.red; 5995 frame_background.red = color.red >> 8;
5442 frame_background.green = color.green; 5996 frame_background.green = color.green >> 8;
5443 frame_background.blue = color.blue; 5997 frame_background.blue = color.blue >> 8;
5444#endif /* HAVE_X_WINDOWS */ 5998#endif /* HAVE_X_WINDOWS */
5445 5999
5446#ifdef HAVE_NTGUI 6000#ifdef HAVE_NTGUI
@@ -5451,9 +6005,9 @@ png_load (f, img)
5451 x_query_color (f, &color); 6005 x_query_color (f, &color);
5452#endif 6006#endif
5453 bzero (&frame_background, sizeof frame_background); 6007 bzero (&frame_background, sizeof frame_background);
5454 frame_background.red = 256 * GetRValue (color); 6008 frame_background.red = GetRValue (color);
5455 frame_background.green = 256 * GetGValue (color); 6009 frame_background.green = GetGValue (color);
5456 frame_background.blue = 256 * GetBValue (color); 6010 frame_background.blue = GetBValue (color);
5457#endif /* HAVE_NTGUI */ 6011#endif /* HAVE_NTGUI */
5458 6012
5459#ifdef MAC_OS 6013#ifdef MAC_OS
@@ -5738,13 +6292,11 @@ DEF_IMGLIB_FN (jpeg_std_error);
5738DEF_IMGLIB_FN (jpeg_resync_to_restart); 6292DEF_IMGLIB_FN (jpeg_resync_to_restart);
5739 6293
5740static int 6294static int
5741init_jpeg_functions (void) 6295init_jpeg_functions (Lisp_Object libraries)
5742{ 6296{
5743 HMODULE library; 6297 HMODULE library;
5744 6298
5745 if (!(library = LoadLibrary ("libjpeg.dll")) 6299 if (!(library = w32_delayed_load (libraries, Qjpeg)))
5746 && !(library = LoadLibrary ("jpeg-62.dll"))
5747 && !(library = LoadLibrary ("jpeg.dll")))
5748 return 0; 6300 return 0;
5749 6301
5750 LOAD_IMGLIB_FN (library, jpeg_finish_decompress); 6302 LOAD_IMGLIB_FN (library, jpeg_finish_decompress);
@@ -6175,11 +6727,11 @@ DEF_IMGLIB_FN (TIFFReadRGBAImage);
6175DEF_IMGLIB_FN (TIFFClose); 6727DEF_IMGLIB_FN (TIFFClose);
6176 6728
6177static int 6729static int
6178init_tiff_functions (void) 6730init_tiff_functions (Lisp_Object libraries)
6179{ 6731{
6180 HMODULE library; 6732 HMODULE library;
6181 6733
6182 if (!(library = LoadLibrary ("libtiff.dll"))) 6734 if (!(library = w32_delayed_load (libraries, Qtiff)))
6183 return 0; 6735 return 0;
6184 6736
6185 LOAD_IMGLIB_FN (library, TIFFSetErrorHandler); 6737 LOAD_IMGLIB_FN (library, TIFFSetErrorHandler);
@@ -6595,11 +7147,11 @@ DEF_IMGLIB_FN (DGifOpen);
6595DEF_IMGLIB_FN (DGifOpenFileName); 7147DEF_IMGLIB_FN (DGifOpenFileName);
6596 7148
6597static int 7149static int
6598init_gif_functions (void) 7150init_gif_functions (Lisp_Object libraries)
6599{ 7151{
6600 HMODULE library; 7152 HMODULE library;
6601 7153
6602 if (!(library = LoadLibrary ("libungif.dll"))) 7154 if (!(library = w32_delayed_load (libraries, Qgif)))
6603 return 0; 7155 return 0;
6604 7156
6605 LOAD_IMGLIB_FN (library, DGifCloseFile); 7157 LOAD_IMGLIB_FN (library, DGifCloseFile);
@@ -6875,6 +7427,8 @@ gif_load (f, img)
6875 TimeValue time; 7427 TimeValue time;
6876 struct gcpro gcpro1; 7428 struct gcpro gcpro1;
6877 int ino; 7429 int ino;
7430 CGrafPtr old_port;
7431 GDHandle old_gdh;
6878 7432
6879 specified_file = image_spec_value (img->spec, QCfile, NULL); 7433 specified_file = image_spec_value (img->spec, QCfile, NULL);
6880 specified_data = image_spec_value (img->spec, QCdata, NULL); 7434 specified_data = image_spec_value (img->spec, QCdata, NULL);
@@ -6992,11 +7546,13 @@ gif_load (f, img)
6992 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 7546 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6993 goto error; 7547 goto error;
6994 7548
7549 GetGWorld (&old_port, &old_gdh);
6995 SetGWorld (ximg, NULL); 7550 SetGWorld (ximg, NULL);
6996 bg_color.red = color.red; 7551 bg_color.red = color.red;
6997 bg_color.green = color.green; 7552 bg_color.green = color.green;
6998 bg_color.blue = color.blue; 7553 bg_color.blue = color.blue;
6999 RGBBackColor (&bg_color); 7554 RGBBackColor (&bg_color);
7555 SetGWorld (old_port, old_gdh);
7000 SetMovieActive (movie, TRUE); 7556 SetMovieActive (movie, TRUE);
7001 SetMovieGWorld (movie, ximg, NULL); 7557 SetMovieGWorld (movie, ximg, NULL);
7002 SampleNumToMediaTime (media, ino + 1, &time, NULL); 7558 SampleNumToMediaTime (media, ino + 1, &time, NULL);
@@ -7368,9 +7924,81 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
7368 Initialization 7924 Initialization
7369 ***********************************************************************/ 7925 ***********************************************************************/
7370 7926
7927#ifdef HAVE_NTGUI
7928/* Image types that rely on external libraries are loaded dynamically
7929 if the library is available. */
7930#define CHECK_LIB_AVAILABLE(image_type, init_lib_fn) \
7931 define_image_type (image_type, init_lib_fn (libraries))
7932#else
7933#define CHECK_LIB_AVAILABLE(image_type, init_lib_fn) \
7934 define_image_type (image_type, TRUE)
7935#endif /* HAVE_NTGUI */
7936
7937DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0,
7938 doc: /* Initialize image library implementing image type TYPE.
7939Return non-nil if TYPE is a supported image type.
7940
7941Image types pbm and xbm are prebuilt; other types are loaded here.
7942Libraries to load are specified in alist LIBRARIES (usually, the value
7943of `image-library-alist', which see. */)
7944 (type, libraries)
7945{
7946 Lisp_Object tested;
7947
7948 /* Don't try to reload the library. */
7949 tested = Fassq (type, Vimage_type_cache);
7950 if (CONSP (tested))
7951 return XCDR (tested);
7952
7953#if defined (HAVE_XPM) || defined (MAC_OS)
7954 if (EQ (type, Qxpm))
7955 return CHECK_LIB_AVAILABLE(&xpm_type, init_xpm_functions);
7956#endif
7957
7958#if defined (HAVE_JPEG) || defined (MAC_OS)
7959 if (EQ (type, Qjpeg))
7960 return CHECK_LIB_AVAILABLE(&jpeg_type, init_jpeg_functions);
7961#endif
7962
7963#if defined (HAVE_TIFF) || defined (MAC_OS)
7964 if (EQ (type, Qtiff))
7965 return CHECK_LIB_AVAILABLE(&tiff_type, init_tiff_functions);
7966#endif
7967
7968#if defined (HAVE_GIF) || defined (MAC_OS)
7969 if (EQ (type, Qgif))
7970 return CHECK_LIB_AVAILABLE(&gif_type, init_gif_functions);
7971#endif
7972
7973#if defined (HAVE_PNG) || defined (MAC_OS)
7974 if (EQ (type, Qpng))
7975 return CHECK_LIB_AVAILABLE(&png_type, init_png_functions);
7976#endif
7977
7978#ifdef HAVE_GHOSTSCRIPT
7979 if (EQ (type, Qpostscript))
7980 return CHECK_LIB_AVAILABLE(&gs_type, init_gs_functions);
7981#endif
7982
7983 /* If the type is not recognized, avoid testing it ever again. */
7984 CACHE_IMAGE_TYPE(type, Qnil);
7985 return Qnil;
7986}
7987
7371void 7988void
7372syms_of_image () 7989syms_of_image ()
7373{ 7990{
7991 /* Must be defined now becase we're going to update it below, while
7992 defining the supported image types. */
7993 DEFVAR_LISP ("image-types", &Vimage_types,
7994 doc: /* List of potentially supported image types.
7995Each element of the list is a symbol for a image type, like 'jpeg or 'png.
7996To check whether it is really supported, use `image-type-available-p'. */);
7997 Vimage_types = Qnil;
7998
7999 Vimage_type_cache = Qnil;
8000 staticpro (&Vimage_type_cache);
8001
7374 QCascent = intern (":ascent"); 8002 QCascent = intern (":ascent");
7375 staticpro (&QCascent); 8003 staticpro (&QCascent);
7376 QCmargin = intern (":margin"); 8004 QCmargin = intern (":margin");
@@ -7404,6 +8032,7 @@ syms_of_image ()
7404 Qpostscript = intern ("postscript"); 8032 Qpostscript = intern ("postscript");
7405 staticpro (&Qpostscript); 8033 staticpro (&Qpostscript);
7406#ifdef HAVE_GHOSTSCRIPT 8034#ifdef HAVE_GHOSTSCRIPT
8035 ADD_IMAGE_TYPE(Qpostscript);
7407 QCloader = intern (":loader"); 8036 QCloader = intern (":loader");
7408 staticpro (&QCloader); 8037 staticpro (&QCloader);
7409 QCbounding_box = intern (":bounding-box"); 8038 QCbounding_box = intern (":bounding-box");
@@ -7416,35 +8045,43 @@ syms_of_image ()
7416 8045
7417 Qpbm = intern ("pbm"); 8046 Qpbm = intern ("pbm");
7418 staticpro (&Qpbm); 8047 staticpro (&Qpbm);
8048 ADD_IMAGE_TYPE(Qpbm);
7419 8049
7420 Qxbm = intern ("xbm"); 8050 Qxbm = intern ("xbm");
7421 staticpro (&Qxbm); 8051 staticpro (&Qxbm);
8052 ADD_IMAGE_TYPE(Qxbm);
7422 8053
7423#ifdef HAVE_XPM 8054#if defined (HAVE_XPM) || defined (MAC_OS)
7424 Qxpm = intern ("xpm"); 8055 Qxpm = intern ("xpm");
7425 staticpro (&Qxpm); 8056 staticpro (&Qxpm);
8057 ADD_IMAGE_TYPE(Qxpm);
7426#endif 8058#endif
7427 8059
7428#if defined (HAVE_JPEG) || defined (MAC_OS) 8060#if defined (HAVE_JPEG) || defined (MAC_OS)
7429 Qjpeg = intern ("jpeg"); 8061 Qjpeg = intern ("jpeg");
7430 staticpro (&Qjpeg); 8062 staticpro (&Qjpeg);
8063 ADD_IMAGE_TYPE(Qjpeg);
7431#endif 8064#endif
7432 8065
7433#if defined (HAVE_TIFF) || defined (MAC_OS) 8066#if defined (HAVE_TIFF) || defined (MAC_OS)
7434 Qtiff = intern ("tiff"); 8067 Qtiff = intern ("tiff");
7435 staticpro (&Qtiff); 8068 staticpro (&Qtiff);
8069 ADD_IMAGE_TYPE(Qtiff);
7436#endif 8070#endif
7437 8071
7438#if defined (HAVE_GIF) || defined (MAC_OS) 8072#if defined (HAVE_GIF) || defined (MAC_OS)
7439 Qgif = intern ("gif"); 8073 Qgif = intern ("gif");
7440 staticpro (&Qgif); 8074 staticpro (&Qgif);
8075 ADD_IMAGE_TYPE(Qgif);
7441#endif 8076#endif
7442 8077
7443#if defined (HAVE_PNG) || defined (MAC_OS) 8078#if defined (HAVE_PNG) || defined (MAC_OS)
7444 Qpng = intern ("png"); 8079 Qpng = intern ("png");
7445 staticpro (&Qpng); 8080 staticpro (&Qpng);
8081 ADD_IMAGE_TYPE(Qpng);
7446#endif 8082#endif
7447 8083
8084 defsubr (&Sinit_image_library);
7448 defsubr (&Sclear_image_cache); 8085 defsubr (&Sclear_image_cache);
7449 defsubr (&Simage_size); 8086 defsubr (&Simage_size);
7450 defsubr (&Simage_mask_p); 8087 defsubr (&Simage_mask_p);
@@ -7472,52 +8109,13 @@ meaning don't clear the cache. */);
7472 Vimage_cache_eviction_delay = make_number (30 * 60); 8109 Vimage_cache_eviction_delay = make_number (30 * 60);
7473} 8110}
7474 8111
7475
7476#ifdef HAVE_NTGUI
7477/* Image types that rely on external libraries are loaded dynamically
7478 if the library is available. */
7479#define IF_LIB_AVAILABLE(init_lib_fn) if (init_lib_fn())
7480#else
7481#define IF_LIB_AVAILABLE(init_func) /* Load unconditionally */
7482#endif /* HAVE_NTGUI */
7483
7484void 8112void
7485init_image () 8113init_image ()
7486{ 8114{
7487 image_types = NULL; 8115 image_types = NULL;
7488 Vimage_types = Qnil;
7489
7490 define_image_type (&xbm_type);
7491 define_image_type (&pbm_type);
7492 8116
7493#ifdef HAVE_XPM 8117 define_image_type (&xbm_type, TRUE);
7494 IF_LIB_AVAILABLE(init_xpm_functions) 8118 define_image_type (&pbm_type, TRUE);
7495 define_image_type (&xpm_type);
7496#endif
7497
7498#if defined (HAVE_JPEG) || defined (MAC_OS)
7499 IF_LIB_AVAILABLE(init_jpeg_functions)
7500 define_image_type (&jpeg_type);
7501#endif
7502
7503#if defined (HAVE_TIFF) || defined (MAC_OS)
7504 IF_LIB_AVAILABLE(init_tiff_functions)
7505 define_image_type (&tiff_type);
7506#endif
7507
7508#if defined (HAVE_GIF) || defined (MAC_OS)
7509 IF_LIB_AVAILABLE(init_gif_functions)
7510 define_image_type (&gif_type);
7511#endif
7512
7513#if defined (HAVE_PNG) || defined (MAC_OS)
7514 IF_LIB_AVAILABLE(init_png_functions)
7515 define_image_type (&png_type);
7516#endif
7517
7518#ifdef HAVE_GHOSTSCRIPT
7519 define_image_type (&gs_type);
7520#endif
7521 8119
7522#ifdef MAC_OS 8120#ifdef MAC_OS
7523 /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ 8121 /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */
diff --git a/src/indent.c b/src/indent.c
index 15e433b03d9..a5de1431e4b 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1,5 +1,5 @@
1/* Indentation functions. 1/* Indentation functions.
2 Copyright (C) 1985,86,87,88,93,94,95,98,2000,01,02,2003 2 Copyright (C) 1985,86,87,88,93,94,95,98,2000,01,02,03,2004
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -1407,6 +1407,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
1407 vpos++; 1407 vpos++;
1408 contin_hpos = prev_hpos; 1408 contin_hpos = prev_hpos;
1409 prev_hpos = 0; 1409 prev_hpos = 0;
1410 prev_vpos = vpos;
1410 } 1411 }
1411 } 1412 }
1412 1413
diff --git a/src/insdel.c b/src/insdel.c
index b1ba5a554a8..5a4dc5b64a8 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1589,7 +1589,7 @@ replace_range (from, to, new, prepare, inherit, markers)
1589 Z_BYTE -= nbytes_del; 1589 Z_BYTE -= nbytes_del;
1590 GPT = from; 1590 GPT = from;
1591 GPT_BYTE = from_byte; 1591 GPT_BYTE = from_byte;
1592 *(GPT_ADDR) = 0; /* Put an anchor. */ 1592 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
1593 1593
1594 if (GPT_BYTE < GPT) 1594 if (GPT_BYTE < GPT)
1595 abort (); 1595 abort ();
@@ -1872,7 +1872,7 @@ del_range_2 (from, from_byte, to, to_byte, ret_string)
1872 Z -= nchars_del; 1872 Z -= nchars_del;
1873 GPT = from; 1873 GPT = from;
1874 GPT_BYTE = from_byte; 1874 GPT_BYTE = from_byte;
1875 *(GPT_ADDR) = 0; /* Put an anchor. */ 1875 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
1876 1876
1877 if (GPT_BYTE < GPT) 1877 if (GPT_BYTE < GPT)
1878 abort (); 1878 abort ();
diff --git a/src/intervals.c b/src/intervals.c
index d87b361a223..ade15360c9f 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1899,11 +1899,13 @@ lookup_char_property (plist, prop, textprop)
1899 return fallback; 1899 return fallback;
1900 /* Check for alternative properties */ 1900 /* Check for alternative properties */
1901 tail = Fassq (prop, Vchar_property_alias_alist); 1901 tail = Fassq (prop, Vchar_property_alias_alist);
1902 if (NILP (tail)) 1902 if (! NILP (tail))
1903 return tail; 1903 {
1904 tail = XCDR (tail); 1904 tail = XCDR (tail);
1905 for (; NILP (fallback) && CONSP (tail); tail = XCDR (tail)) 1905 for (; NILP (fallback) && CONSP (tail); tail = XCDR (tail))
1906 fallback = Fplist_get (plist, XCAR (tail)); 1906 fallback = Fplist_get (plist, XCAR (tail));
1907 }
1908
1907 if (textprop && NILP (fallback) && CONSP (Vdefault_text_properties)) 1909 if (textprop && NILP (fallback) && CONSP (Vdefault_text_properties))
1908 fallback = Fplist_get (Vdefault_text_properties, prop); 1910 fallback = Fplist_get (Vdefault_text_properties, prop);
1909 return fallback; 1911 return fallback;
diff --git a/src/keyboard.c b/src/keyboard.c
index 62017cec7b3..469b15fb683 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -117,6 +117,8 @@ struct backtrace
117 args points to slot holding list of 117 args points to slot holding list of
118 unevalled args */ 118 unevalled args */
119 char evalargs; 119 char evalargs;
120 /* Nonzero means call value of debugger when done with this operation. */
121 char debug_on_exit;
120 }; 122 };
121 123
122#ifdef MULTI_KBOARD 124#ifdef MULTI_KBOARD
@@ -679,6 +681,8 @@ static SIGTYPE interrupt_signal P_ ((int signalnum));
679 to support it. */ 681 to support it. */
680static int cannot_suspend; 682static int cannot_suspend;
681 683
684extern Lisp_Object Qidentity, Qonly;
685
682/* Install the string STR as the beginning of the string of echoing, 686/* Install the string STR as the beginning of the string of echoing,
683 so that it serves as a prompt for the next character. 687 so that it serves as a prompt for the next character.
684 Also start echoing. */ 688 Also start echoing. */
@@ -996,6 +1000,11 @@ This function is called by the editor initialization to begin editing. */)
996 int count = SPECPDL_INDEX (); 1000 int count = SPECPDL_INDEX ();
997 Lisp_Object buffer; 1001 Lisp_Object buffer;
998 1002
1003 /* If we enter while input is blocked, don't lock up here.
1004 This may happen through the debugger during redisplay. */
1005 if (INPUT_BLOCKED_P)
1006 return Qnil;
1007
999 command_loop_level++; 1008 command_loop_level++;
1000 update_mode_lines = 1; 1009 update_mode_lines = 1;
1001 1010
@@ -1151,7 +1160,8 @@ cmd_error (data)
1151 1160
1152 Vinhibit_quit = Qnil; 1161 Vinhibit_quit = Qnil;
1153#ifdef MULTI_KBOARD 1162#ifdef MULTI_KBOARD
1154 any_kboard_state (); 1163 if (command_loop_level == 0 && minibuf_level == 0)
1164 any_kboard_state ();
1155#endif 1165#endif
1156 1166
1157 return make_number (0); 1167 return make_number (0);
@@ -1240,6 +1250,10 @@ command_loop ()
1240 while (1) 1250 while (1)
1241 { 1251 {
1242 internal_catch (Qtop_level, top_level_1, Qnil); 1252 internal_catch (Qtop_level, top_level_1, Qnil);
1253 /* Reset single_kboard in case top-level set it while
1254 evaluating an -f option, or we are stuck there for some
1255 other reason. */
1256 any_kboard_state ();
1243 internal_catch (Qtop_level, command_loop_2, Qnil); 1257 internal_catch (Qtop_level, command_loop_2, Qnil);
1244 executing_macro = Qnil; 1258 executing_macro = Qnil;
1245 1259
@@ -1294,6 +1308,12 @@ DEFUN ("top-level", Ftop_level, Stop_level, 0, 0, "",
1294 if (display_hourglass_p) 1308 if (display_hourglass_p)
1295 cancel_hourglass (); 1309 cancel_hourglass ();
1296#endif 1310#endif
1311
1312 /* Unblock input if we enter with input blocked. This may happen if
1313 redisplay traps e.g. during tool-bar update with input blocked. */
1314 while (INPUT_BLOCKED_P)
1315 UNBLOCK_INPUT;
1316
1297 return Fthrow (Qtop_level, Qnil); 1317 return Fthrow (Qtop_level, Qnil);
1298} 1318}
1299 1319
@@ -1804,6 +1824,16 @@ command_loop_1 ()
1804 call1 (Vrun_hooks, intern ("activate-mark-hook")); 1824 call1 (Vrun_hooks, intern ("activate-mark-hook"));
1805 } 1825 }
1806 1826
1827 /* Setting transient-mark-mode to `only' is a way of
1828 turning it on for just one command. */
1829 if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks))
1830 {
1831 if (EQ (Vtransient_mark_mode, Qidentity))
1832 Vtransient_mark_mode = Qnil;
1833 if (EQ (Vtransient_mark_mode, Qonly))
1834 Vtransient_mark_mode = Qidentity;
1835 }
1836
1807 finalize: 1837 finalize:
1808 1838
1809 if (current_buffer == prev_buffer 1839 if (current_buffer == prev_buffer
@@ -3967,9 +3997,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
3967 else if (event->kind == LANGUAGE_CHANGE_EVENT) 3997 else if (event->kind == LANGUAGE_CHANGE_EVENT)
3968 { 3998 {
3969 /* Make an event (language-change (FRAME CHARSET LCID)). */ 3999 /* Make an event (language-change (FRAME CHARSET LCID)). */
3970 obj = Fcons (event->modifiers, Qnil); 4000 obj = Fcons (event->frame_or_window, Qnil);
3971 obj = Fcons (event->code, obj);
3972 obj = Fcons (event->frame_or_window, obj);
3973 obj = Fcons (Qlanguage_change, Fcons (obj, Qnil)); 4001 obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
3974 kbd_fetch_ptr = event + 1; 4002 kbd_fetch_ptr = event + 1;
3975 } 4003 }
@@ -6245,14 +6273,8 @@ modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist_or_stem,
6245 { 6273 {
6246 int len = SBYTES (name_alist_or_stem); 6274 int len = SBYTES (name_alist_or_stem);
6247 char *buf = (char *) alloca (len + 50); 6275 char *buf = (char *) alloca (len + 50);
6248 if (sizeof (int) == sizeof (EMACS_INT)) 6276 sprintf (buf, "%s-%ld", SDATA (name_alist_or_stem),
6249 sprintf (buf, "%s-%d", SDATA (name_alist_or_stem), 6277 (long) XINT (symbol_int) + 1);
6250 XINT (symbol_int) + 1);
6251 else if (sizeof (long) == sizeof (EMACS_INT))
6252 sprintf (buf, "%s-%ld", SDATA (name_alist_or_stem),
6253 XINT (symbol_int) + 1);
6254 else
6255 abort ();
6256 value = intern (buf); 6278 value = intern (buf);
6257 } 6279 }
6258 else if (name_table != 0 && name_table[symbol_num]) 6280 else if (name_table != 0 && name_table[symbol_num])
@@ -7409,7 +7431,7 @@ parse_menu_item (item, notreal, inmenubar)
7409 newcache = chkcache; 7431 newcache = chkcache;
7410 if (chkcache) 7432 if (chkcache)
7411 { 7433 {
7412 tem = Fkey_description (tem); 7434 tem = Fkey_description (tem, Qnil);
7413 if (CONSP (prefix)) 7435 if (CONSP (prefix))
7414 { 7436 {
7415 if (STRINGP (XCAR (prefix))) 7437 if (STRINGP (XCAR (prefix)))
@@ -9667,6 +9689,7 @@ a special event, so ignore the prefix argument and don't clear it. */)
9667 backtrace.args = &cmd; 9689 backtrace.args = &cmd;
9668 backtrace.nargs = 1; 9690 backtrace.nargs = 1;
9669 backtrace.evalargs = 0; 9691 backtrace.evalargs = 0;
9692 backtrace.debug_on_exit = 0;
9670 9693
9671 tem = Fcall_interactively (cmd, record_flag, keys); 9694 tem = Fcall_interactively (cmd, record_flag, keys);
9672 9695
@@ -9703,23 +9726,9 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
9703 else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4) 9726 else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4)
9704 strcpy (buf, "C-u "); 9727 strcpy (buf, "C-u ");
9705 else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg))) 9728 else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg)))
9706 { 9729 sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg)));
9707 if (sizeof (int) == sizeof (EMACS_INT))
9708 sprintf (buf, "%d ", XINT (XCAR (prefixarg)));
9709 else if (sizeof (long) == sizeof (EMACS_INT))
9710 sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg)));
9711 else
9712 abort ();
9713 }
9714 else if (INTEGERP (prefixarg)) 9730 else if (INTEGERP (prefixarg))
9715 { 9731 sprintf (buf, "%ld ", (long) XINT (prefixarg));
9716 if (sizeof (int) == sizeof (EMACS_INT))
9717 sprintf (buf, "%d ", XINT (prefixarg));
9718 else if (sizeof (long) == sizeof (EMACS_INT))
9719 sprintf (buf, "%ld ", (long) XINT (prefixarg));
9720 else
9721 abort ();
9722 }
9723 9732
9724 /* This isn't strictly correct if execute-extended-command 9733 /* This isn't strictly correct if execute-extended-command
9725 is bound to anything else. Perhaps it should use 9734 is bound to anything else. Perhaps it should use
@@ -9807,7 +9816,7 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
9807 int count = SPECPDL_INDEX (); 9816 int count = SPECPDL_INDEX ();
9808 9817
9809 record_unwind_protect (pop_message_unwind, Qnil); 9818 record_unwind_protect (pop_message_unwind, Qnil);
9810 binding = Fkey_description (bindings); 9819 binding = Fkey_description (bindings, Qnil);
9811 9820
9812 newmessage 9821 newmessage
9813 = (char *) alloca (SCHARS (SYMBOL_NAME (function)) 9822 = (char *) alloca (SCHARS (SYMBOL_NAME (function))
@@ -10490,6 +10499,61 @@ The elements of this list correspond to the arguments of
10490 return Flist (sizeof (val) / sizeof (val[0]), val); 10499 return Flist (sizeof (val) / sizeof (val[0]), val);
10491} 10500}
10492 10501
10502DEFUN ("posn-at-x-y", Fposn_at_x_y, Sposn_at_x_y, 2, 3, 0,
10503 doc: /* Return position information for pixel coordinates X and Y.
10504By default, X and Y are relative to text area of the selected window.
10505Optional third arg FRAME_OR_WINDOW non-nil specifies frame or window.
10506
10507The return value is similar to a mouse click position:
10508 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW)
10509 IMAGE (DX . DY) (WIDTH . HEIGHT))
10510The `posn-' functions access elements of such lists. */)
10511 (x, y, frame_or_window)
10512 Lisp_Object x, y, frame_or_window;
10513{
10514 if (NILP (frame_or_window))
10515 frame_or_window = selected_window;
10516
10517 if (WINDOWP (frame_or_window))
10518 {
10519 struct window *w;
10520
10521 CHECK_LIVE_WINDOW (frame_or_window);
10522
10523 w = XWINDOW (frame_or_window);
10524 XSETINT (x, (WINDOW_TO_FRAME_PIXEL_X (w, XINT (x))
10525 + window_box_left_offset (w, TEXT_AREA)));
10526 XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XINT (y)));
10527 frame_or_window = w->frame;
10528 }
10529
10530 CHECK_LIVE_FRAME (frame_or_window);
10531
10532 return make_lispy_position (XFRAME (frame_or_window), &x, &y, 0);
10533}
10534
10535DEFUN ("posn-at-point", Fposn_at_point, Sposn_at_point, 0, 2, 0,
10536 doc: /* Return position information for buffer POS in WINDOW.
10537POS defaults to point in WINDOW; WINDOW defaults to the selected window.
10538
10539Return nil if position is not visible in window. Otherwise,
10540the return value is similar to that returned by `event-start' for
10541a mouse click at the upper left corner of the glyph corresponding
10542to the given buffer position:
10543 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW)
10544 IMAGE (DX . DY) (WIDTH . HEIGHT))
10545The `posn-' functions access elements of such lists. */*/)
10546 (pos, window)
10547 Lisp_Object pos, window;
10548{
10549 Lisp_Object tem;
10550
10551 tem = Fpos_visible_in_window_p (pos, window, Qt);
10552 if (!NILP (tem))
10553 tem = Fposn_at_x_y (XCAR (tem), XCAR (XCDR (tem)), window);
10554 return tem;
10555}
10556
10493 10557
10494/* 10558/*
10495 * Set up a new kboard object with reasonable initial values. 10559 * Set up a new kboard object with reasonable initial values.
@@ -10913,6 +10977,8 @@ syms_of_keyboard ()
10913 defsubr (&Sset_input_mode); 10977 defsubr (&Sset_input_mode);
10914 defsubr (&Scurrent_input_mode); 10978 defsubr (&Scurrent_input_mode);
10915 defsubr (&Sexecute_extended_command); 10979 defsubr (&Sexecute_extended_command);
10980 defsubr (&Sposn_at_point);
10981 defsubr (&Sposn_at_x_y);
10916 10982
10917 DEFVAR_LISP ("last-command-char", &last_command_char, 10983 DEFVAR_LISP ("last-command-char", &last_command_char,
10918 doc: /* Last input event that was part of a command. */); 10984 doc: /* Last input event that was part of a command. */);
@@ -11357,8 +11423,11 @@ mark_kboards ()
11357 { 11423 {
11358 if (event == kbd_buffer + KBD_BUFFER_SIZE) 11424 if (event == kbd_buffer + KBD_BUFFER_SIZE)
11359 event = kbd_buffer; 11425 event = kbd_buffer;
11360 mark_object (event->x); 11426 if (event->kind != SELECTION_REQUEST_EVENT)
11361 mark_object (event->y); 11427 {
11428 mark_object (event->x);
11429 mark_object (event->y);
11430 }
11362 mark_object (event->frame_or_window); 11431 mark_object (event->frame_or_window);
11363 mark_object (event->arg); 11432 mark_object (event->arg);
11364 } 11433 }
diff --git a/src/keymap.c b/src/keymap.c
index 62ea237b85c..fbf1263a71b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -122,6 +122,9 @@ static void describe_translation P_ ((Lisp_Object, Lisp_Object));
122static void describe_map P_ ((Lisp_Object, Lisp_Object, 122static void describe_map P_ ((Lisp_Object, Lisp_Object,
123 void (*) P_ ((Lisp_Object, Lisp_Object)), 123 void (*) P_ ((Lisp_Object, Lisp_Object)),
124 int, Lisp_Object, Lisp_Object*, int)); 124 int, Lisp_Object, Lisp_Object*, int));
125static void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
126 void (*) (Lisp_Object, Lisp_Object), int,
127 Lisp_Object, Lisp_Object, int *, int, int));
125static void silly_event_symbol_error P_ ((Lisp_Object)); 128static void silly_event_symbol_error P_ ((Lisp_Object));
126 129
127/* Keymap object support - constructors and predicates. */ 130/* Keymap object support - constructors and predicates. */
@@ -1098,15 +1101,15 @@ event type that has no other definition in this keymap.
1098 1101
1099DEF is anything that can be a key's definition: 1102DEF is anything that can be a key's definition:
1100 nil (means key is undefined in this keymap), 1103 nil (means key is undefined in this keymap),
1101 a command (a Lisp function suitable for interactive calling) 1104 a command (a Lisp function suitable for interactive calling),
1102 a string (treated as a keyboard macro), 1105 a string (treated as a keyboard macro),
1103 a keymap (to define a prefix key), 1106 a keymap (to define a prefix key),
1104 a symbol. When the key is looked up, the symbol will stand for its 1107 a symbol (when the key is looked up, the symbol will stand for its
1105 function definition, which should at that time be one of the above, 1108 function definition, which should at that time be one of the above,
1106 or another symbol whose function definition is used, etc. 1109 or another symbol whose function definition is used, etc.),
1107 a cons (STRING . DEFN), meaning that DEFN is the definition 1110 a cons (STRING . DEFN), meaning that DEFN is the definition
1108 (DEFN should be a valid definition in its own right), 1111 (DEFN should be a valid definition in its own right),
1109 or a cons (KEYMAP . CHAR), meaning use definition of CHAR in map KEYMAP. 1112 or a cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP.
1110 1113
1111If KEYMAP is a sparse keymap with a binding for KEY, the existing 1114If KEYMAP is a sparse keymap with a binding for KEY, the existing
1112binding is altered. If there is no binding for KEY, the new pair 1115binding is altered. If there is no binding for KEY, the new pair
@@ -1193,7 +1196,7 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1193 /* We must use Fkey_description rather than just passing key to 1196 /* We must use Fkey_description rather than just passing key to
1194 error; key might be a vector, not a string. */ 1197 error; key might be a vector, not a string. */
1195 error ("Key sequence %s uses invalid prefix characters", 1198 error ("Key sequence %s uses invalid prefix characters",
1196 SDATA (Fkey_description (key))); 1199 SDATA (Fkey_description (key, Qnil)));
1197 } 1200 }
1198} 1201}
1199 1202
@@ -1653,7 +1656,7 @@ DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 2, 0,
1653 doc: /* Return the binding for command KEYS in current global keymap only. 1656 doc: /* Return the binding for command KEYS in current global keymap only.
1654KEYS is a string, a sequence of keystrokes. 1657KEYS is a string, a sequence of keystrokes.
1655The binding is probably a symbol with a function definition. 1658The binding is probably a symbol with a function definition.
1656This function's return values are the same as those of lookup-key 1659This function's return values are the same as those of `lookup-key'
1657\(which see). 1660\(which see).
1658 1661
1659If optional argument ACCEPT-DEFAULT is non-nil, recognize default 1662If optional argument ACCEPT-DEFAULT is non-nil, recognize default
@@ -1974,78 +1977,109 @@ Lisp_Object Qsingle_key_description, Qkey_description;
1974 1977
1975/* This function cannot GC. */ 1978/* This function cannot GC. */
1976 1979
1977DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0, 1980DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0,
1978 doc: /* Return a pretty description of key-sequence KEYS. 1981 doc: /* Return a pretty description of key-sequence KEYS.
1979Control characters turn into "C-foo" sequences, meta into "M-foo" 1982Optional arg PREFIX is the sequence of keys leading up to KEYS.
1983Control characters turn into "C-foo" sequences, meta into "M-foo",
1980spaces are put between sequence elements, etc. */) 1984spaces are put between sequence elements, etc. */)
1981 (keys) 1985 (keys, prefix)
1982 Lisp_Object keys; 1986 Lisp_Object keys, prefix;
1983{ 1987{
1984 int len = 0; 1988 int len = 0;
1985 int i, i_byte; 1989 int i, i_byte;
1986 Lisp_Object sep; 1990 Lisp_Object *args;
1987 Lisp_Object *args = NULL; 1991 int size = XINT (Flength (keys));
1992 Lisp_Object list;
1993 Lisp_Object sep = build_string (" ");
1994 Lisp_Object key;
1995 int add_meta = 0;
1996
1997 if (!NILP (prefix))
1998 size += XINT (Flength (prefix));
1999
2000 /* This has one extra element at the end that we don't pass to Fconcat. */
2001 args = (Lisp_Object *) alloca (size * 4 * sizeof (Lisp_Object));
1988 2002
1989 if (STRINGP (keys)) 2003 /* In effect, this computes
2004 (mapconcat 'single-key-description keys " ")
2005 but we shouldn't use mapconcat because it can do GC. */
2006
2007 next_list:
2008 if (!NILP (prefix))
2009 list = prefix, prefix = Qnil;
2010 else if (!NILP (keys))
2011 list = keys, keys = Qnil;
2012 else
1990 { 2013 {
1991 Lisp_Object vector; 2014 if (add_meta)
1992 vector = Fmake_vector (Flength (keys), Qnil);
1993 for (i = 0, i_byte = 0; i < SCHARS (keys); )
1994 { 2015 {
1995 int c; 2016 args[len] = Fsingle_key_description (meta_prefix_char, Qnil);
1996 int i_before = i; 2017 len += 2;
1997
1998 FETCH_STRING_CHAR_ADVANCE (c, keys, i, i_byte);
1999 if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
2000 c ^= 0200 | meta_modifier;
2001 XSETFASTINT (AREF (vector, i_before), c);
2002 } 2018 }
2003 keys = vector; 2019 else if (len == 0)
2020 return empty_string;
2021 return Fconcat (len - 1, args);
2004 } 2022 }
2005 2023
2006 if (VECTORP (keys)) 2024 if (STRINGP (list))
2007 { 2025 size = SCHARS (list);
2008 /* In effect, this computes 2026 else if (VECTORP (list))
2009 (mapconcat 'single-key-description keys " ") 2027 size = XVECTOR (list)->size;
2010 but we shouldn't use mapconcat because it can do GC. */ 2028 else if (CONSP (list))
2029 size = XINT (Flength (list));
2030 else
2031 wrong_type_argument (Qarrayp, list);
2011 2032
2012 len = XVECTOR (keys)->size; 2033 i = i_byte = 0;
2013 sep = build_string (" ");
2014 /* This has one extra element at the end that we don't pass to Fconcat. */
2015 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
2016 2034
2017 for (i = 0; i < len; i++) 2035 while (i < size)
2036 {
2037 if (STRINGP (list))
2018 { 2038 {
2019 args[i * 2] = Fsingle_key_description (AREF (keys, i), Qnil); 2039 int c;
2020 args[i * 2 + 1] = sep; 2040 FETCH_STRING_CHAR_ADVANCE (c, list, i, i_byte);
2041 if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
2042 c ^= 0200 | meta_modifier;
2043 XSETFASTINT (key, c);
2044 }
2045 else if (VECTORP (list))
2046 {
2047 key = AREF (list, i++);
2048 }
2049 else
2050 {
2051 key = XCAR (list);
2052 list = XCDR (list);
2053 i++;
2021 } 2054 }
2022 }
2023 else if (CONSP (keys))
2024 {
2025 /* In effect, this computes
2026 (mapconcat 'single-key-description keys " ")
2027 but we shouldn't use mapconcat because it can do GC. */
2028
2029 len = XFASTINT (Flength (keys));
2030 sep = build_string (" ");
2031 /* This has one extra element at the end that we don't pass to Fconcat. */
2032 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
2033 2055
2034 for (i = 0; i < len; i++) 2056 if (add_meta)
2057 {
2058 if (!INTEGERP (key)
2059 || EQ (key, meta_prefix_char)
2060 || (XINT (key) & meta_modifier))
2061 {
2062 args[len++] = Fsingle_key_description (meta_prefix_char, Qnil);
2063 args[len++] = sep;
2064 if (EQ (key, meta_prefix_char))
2065 continue;
2066 }
2067 else
2068 XSETINT (key, (XINT (key) | meta_modifier) & ~0x80);
2069 add_meta = 0;
2070 }
2071 else if (EQ (key, meta_prefix_char))
2035 { 2072 {
2036 args[i * 2] = Fsingle_key_description (XCAR (keys), Qnil); 2073 add_meta = 1;
2037 args[i * 2 + 1] = sep; 2074 continue;
2038 keys = XCDR (keys);
2039 } 2075 }
2076 args[len++] = Fsingle_key_description (key, Qnil);
2077 args[len++] = sep;
2040 } 2078 }
2041 else 2079 goto next_list;
2042 keys = wrong_type_argument (Qarrayp, keys);
2043
2044 if (len == 0)
2045 return empty_string;
2046 return Fconcat (len * 2 - 1, args);
2047} 2080}
2048 2081
2082
2049char * 2083char *
2050push_key_description (c, p, force_multibyte) 2084push_key_description (c, p, force_multibyte)
2051 register unsigned int c; 2085 register unsigned int c;
@@ -2926,7 +2960,7 @@ key binding\n\
2926 if (!NILP (prefix)) 2960 if (!NILP (prefix))
2927 { 2961 {
2928 insert_string (" Starting With "); 2962 insert_string (" Starting With ");
2929 insert1 (Fkey_description (prefix)); 2963 insert1 (Fkey_description (prefix, Qnil));
2930 } 2964 }
2931 insert_string (":\n"); 2965 insert_string (":\n");
2932 } 2966 }
@@ -3051,7 +3085,7 @@ describe_translation (definition, args)
3051 } 3085 }
3052 else if (STRINGP (definition) || VECTORP (definition)) 3086 else if (STRINGP (definition) || VECTORP (definition))
3053 { 3087 {
3054 insert1 (Fkey_description (definition)); 3088 insert1 (Fkey_description (definition, Qnil));
3055 insert_string ("\n"); 3089 insert_string ("\n");
3056 } 3090 }
3057 else if (KEYMAPP (definition)) 3091 else if (KEYMAPP (definition))
@@ -3061,20 +3095,19 @@ describe_translation (definition, args)
3061} 3095}
3062 3096
3063/* Describe the contents of map MAP, assuming that this map itself is 3097/* Describe the contents of map MAP, assuming that this map itself is
3064 reached by the sequence of prefix keys KEYS (a string or vector). 3098 reached by the sequence of prefix keys PREFIX (a string or vector).
3065 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ 3099 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */
3066 3100
3067static void 3101static void
3068describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) 3102describe_map (map, prefix, elt_describer, partial, shadow, seen, nomenu)
3069 register Lisp_Object map; 3103 register Lisp_Object map;
3070 Lisp_Object keys; 3104 Lisp_Object prefix;
3071 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); 3105 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object));
3072 int partial; 3106 int partial;
3073 Lisp_Object shadow; 3107 Lisp_Object shadow;
3074 Lisp_Object *seen; 3108 Lisp_Object *seen;
3075 int nomenu; 3109 int nomenu;
3076{ 3110{
3077 Lisp_Object elt_prefix;
3078 Lisp_Object tail, definition, event; 3111 Lisp_Object tail, definition, event;
3079 Lisp_Object tem; 3112 Lisp_Object tem;
3080 Lisp_Object suppress; 3113 Lisp_Object suppress;
@@ -3084,15 +3117,6 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3084 3117
3085 suppress = Qnil; 3118 suppress = Qnil;
3086 3119
3087 if (!NILP (keys) && XFASTINT (Flength (keys)) > 0)
3088 {
3089 /* Call Fkey_description first, to avoid GC bug for the other string. */
3090 tem = Fkey_description (keys);
3091 elt_prefix = concat2 (tem, build_string (" "));
3092 }
3093 else
3094 elt_prefix = Qnil;
3095
3096 if (partial) 3120 if (partial)
3097 suppress = intern ("suppress-keymap"); 3121 suppress = intern ("suppress-keymap");
3098 3122
@@ -3102,7 +3126,7 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3102 kludge = Fmake_vector (make_number (1), Qnil); 3126 kludge = Fmake_vector (make_number (1), Qnil);
3103 definition = Qnil; 3127 definition = Qnil;
3104 3128
3105 GCPRO3 (elt_prefix, definition, kludge); 3129 GCPRO3 (prefix, definition, kludge);
3106 3130
3107 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3131 for (tail = map; CONSP (tail); tail = XCDR (tail))
3108 { 3132 {
@@ -3111,13 +3135,13 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3111 if (VECTORP (XCAR (tail)) 3135 if (VECTORP (XCAR (tail))
3112 || CHAR_TABLE_P (XCAR (tail))) 3136 || CHAR_TABLE_P (XCAR (tail)))
3113 describe_vector (XCAR (tail), 3137 describe_vector (XCAR (tail),
3114 elt_prefix, Qnil, elt_describer, partial, shadow, map, 3138 prefix, Qnil, elt_describer, partial, shadow, map,
3115 (int *)0, 0); 3139 (int *)0, 0, 1);
3116 else if (CONSP (XCAR (tail))) 3140 else if (CONSP (XCAR (tail)))
3117 { 3141 {
3118 event = XCAR (XCAR (tail)); 3142 event = XCAR (XCAR (tail));
3119 3143
3120 /* Ignore bindings whose "keys" are not really valid events. 3144 /* Ignore bindings whose "prefix" are not really valid events.
3121 (We get these in the frames and buffers menu.) */ 3145 (We get these in the frames and buffers menu.) */
3122 if (!(SYMBOLP (event) || INTEGERP (event))) 3146 if (!(SYMBOLP (event) || INTEGERP (event)))
3123 continue; 3147 continue;
@@ -3156,11 +3180,8 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3156 first = 0; 3180 first = 0;
3157 } 3181 }
3158 3182
3159 if (!NILP (elt_prefix))
3160 insert1 (elt_prefix);
3161
3162 /* THIS gets the string to describe the character EVENT. */ 3183 /* THIS gets the string to describe the character EVENT. */
3163 insert1 (Fsingle_key_description (event, Qnil)); 3184 insert1 (Fkey_description (kludge, prefix));
3164 3185
3165 /* Print a description of the definition of this character. 3186 /* Print a description of the definition of this character.
3166 elt_describer will take care of spacing out far enough 3187 elt_describer will take care of spacing out far enough
@@ -3173,9 +3194,9 @@ describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
3173 using an inherited keymap. So skip anything we've already 3194 using an inherited keymap. So skip anything we've already
3174 encountered. */ 3195 encountered. */
3175 tem = Fassq (tail, *seen); 3196 tem = Fassq (tail, *seen);
3176 if (CONSP (tem) && !NILP (Fequal (XCAR (tem), keys))) 3197 if (CONSP (tem) && !NILP (Fequal (XCAR (tem), prefix)))
3177 break; 3198 break;
3178 *seen = Fcons (Fcons (tail, keys), *seen); 3199 *seen = Fcons (Fcons (tail, prefix), *seen);
3179 } 3200 }
3180 } 3201 }
3181 3202
@@ -3193,7 +3214,8 @@ describe_vector_princ (elt, fun)
3193 3214
3194DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0, 3215DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0,
3195 doc: /* Insert a description of contents of VECTOR. 3216 doc: /* Insert a description of contents of VECTOR.
3196This is text showing the elements of vector matched against indices. */) 3217This is text showing the elements of vector matched against indices.
3218DESCRIBER is the output function used; nil means use `princ'. */)
3197 (vector, describer) 3219 (vector, describer)
3198 Lisp_Object vector, describer; 3220 Lisp_Object vector, describer;
3199{ 3221{
@@ -3203,7 +3225,7 @@ This is text showing the elements of vector matched against indices. */)
3203 specbind (Qstandard_output, Fcurrent_buffer ()); 3225 specbind (Qstandard_output, Fcurrent_buffer ());
3204 CHECK_VECTOR_OR_CHAR_TABLE (vector); 3226 CHECK_VECTOR_OR_CHAR_TABLE (vector);
3205 describe_vector (vector, Qnil, describer, describe_vector_princ, 0, 3227 describe_vector (vector, Qnil, describer, describe_vector_princ, 0,
3206 Qnil, Qnil, (int *)0, 0); 3228 Qnil, Qnil, (int *)0, 0, 0);
3207 3229
3208 return unbind_to (count, Qnil); 3230 return unbind_to (count, Qnil);
3209} 3231}
@@ -3237,42 +3259,60 @@ This is text showing the elements of vector matched against indices. */)
3237 ARGS is simply passed as the second argument to ELT_DESCRIBER. 3259 ARGS is simply passed as the second argument to ELT_DESCRIBER.
3238 3260
3239 INDICES and CHAR_TABLE_DEPTH are ignored. They will be removed in 3261 INDICES and CHAR_TABLE_DEPTH are ignored. They will be removed in
3240 the near future. */ 3262 the near future.
3241 3263
3242void 3264 KEYMAP_P is 1 if vector is known to be a keymap, so map ESC to M-.
3243describe_vector (vector, elt_prefix, args, elt_describer, 3265
3266 ARGS is simply passed as the second argument to ELT_DESCRIBER. */
3267
3268static void
3269describe_vector (vector, prefix, args, elt_describer,
3244 partial, shadow, entire_map, 3270 partial, shadow, entire_map,
3245 indices, char_table_depth) 3271 indices, char_table_depth, keymap_p)
3246 register Lisp_Object vector; 3272 register Lisp_Object vector;
3247 Lisp_Object elt_prefix, args; 3273 Lisp_Object prefix, args;
3248 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); 3274 void (*elt_describer) P_ ((Lisp_Object, Lisp_Object));
3249 int partial; 3275 int partial;
3250 Lisp_Object shadow; 3276 Lisp_Object shadow;
3251 Lisp_Object entire_map; 3277 Lisp_Object entire_map;
3252 int *indices; 3278 int *indices;
3253 int char_table_depth; 3279 int char_table_depth;
3280 int keymap_p;
3254{ 3281{
3255 Lisp_Object definition; 3282 Lisp_Object definition;
3256 Lisp_Object tem2; 3283 Lisp_Object tem2;
3284 Lisp_Object elt_prefix = Qnil;
3257 int i; 3285 int i;
3258 Lisp_Object suppress; 3286 Lisp_Object suppress;
3259 Lisp_Object kludge; 3287 Lisp_Object kludge;
3260 struct gcpro gcpro1, gcpro2, gcpro3; 3288 int first = 1;
3289 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3261 /* Range of elements to be handled. */ 3290 /* Range of elements to be handled. */
3262 int from, to; 3291 int from, to;
3263 Lisp_Object character; 3292 Lisp_Object character;
3264 int starting_i; 3293 int starting_i;
3265 int first = 1;
3266 3294
3267 suppress = Qnil; 3295 suppress = Qnil;
3268 3296
3269 definition = Qnil; 3297 definition = Qnil;
3270 3298
3299 if (!keymap_p)
3300 {
3301 /* Call Fkey_description first, to avoid GC bug for the other string. */
3302 if (!NILP (prefix) && XFASTINT (Flength (prefix)) > 0)
3303 {
3304 Lisp_Object tem;
3305 tem = Fkey_description (prefix, Qnil);
3306 elt_prefix = concat2 (tem, build_string (" "));
3307 }
3308 prefix = Qnil;
3309 }
3310
3271 /* This vector gets used to present single keys to Flookup_key. Since 3311 /* This vector gets used to present single keys to Flookup_key. Since
3272 that is done once per vector element, we don't want to cons up a 3312 that is done once per vector element, we don't want to cons up a
3273 fresh vector every time. */ 3313 fresh vector every time. */
3274 kludge = Fmake_vector (make_number (1), Qnil); 3314 kludge = Fmake_vector (make_number (1), Qnil);
3275 GCPRO3 (elt_prefix, definition, kludge); 3315 GCPRO4 (elt_prefix, prefix, definition, kludge);
3276 3316
3277 if (partial) 3317 if (partial)
3278 suppress = intern ("suppress-keymap"); 3318 suppress = intern ("suppress-keymap");
@@ -3308,13 +3348,13 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3308 } 3348 }
3309 3349
3310 character = make_number (starting_i); 3350 character = make_number (starting_i);
3351 ASET (kludge, 0, character);
3311 3352
3312 /* If this binding is shadowed by some other map, ignore it. */ 3353 /* If this binding is shadowed by some other map, ignore it. */
3313 if (!NILP (shadow)) 3354 if (!NILP (shadow))
3314 { 3355 {
3315 Lisp_Object tem; 3356 Lisp_Object tem;
3316 3357
3317 ASET (kludge, 0, character);
3318 tem = shadow_lookup (shadow, kludge, Qt); 3358 tem = shadow_lookup (shadow, kludge, Qt);
3319 3359
3320 if (!NILP (tem)) continue; 3360 if (!NILP (tem)) continue;
@@ -3326,7 +3366,6 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3326 { 3366 {
3327 Lisp_Object tem; 3367 Lisp_Object tem;
3328 3368
3329 ASET (kludge, 0, character);
3330 tem = Flookup_key (entire_map, kludge, Qt); 3369 tem = Flookup_key (entire_map, kludge, Qt);
3331 3370
3332 if (!EQ (tem, definition)) 3371 if (!EQ (tem, definition))
@@ -3343,7 +3382,7 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3343 if (!NILP (elt_prefix)) 3382 if (!NILP (elt_prefix))
3344 insert1 (elt_prefix); 3383 insert1 (elt_prefix);
3345 3384
3346 insert1 (Fsingle_key_description (character, Qnil)); 3385 insert1 (Fkey_description (kludge, prefix));
3347 3386
3348 /* Find all consecutive characters or rows that have the same 3387 /* Find all consecutive characters or rows that have the same
3349 definition. But, for elements of a top level char table, if 3388 definition. But, for elements of a top level char table, if
@@ -3371,10 +3410,12 @@ describe_vector (vector, elt_prefix, args, elt_describer,
3371 { 3410 {
3372 insert (" .. ", 4); 3411 insert (" .. ", 4);
3373 3412
3413 ASET (kludge, 0, make_number (i));
3414
3374 if (!NILP (elt_prefix)) 3415 if (!NILP (elt_prefix))
3375 insert1 (elt_prefix); 3416 insert1 (elt_prefix);
3376 3417
3377 insert1 (Fsingle_key_description (make_number (i), Qnil)); 3418 insert1 (Fkey_description (kludge, prefix));
3378 } 3419 }
3379 3420
3380 /* Print a description of the definition of this character. 3421 /* Print a description of the definition of this character.
diff --git a/src/keymap.h b/src/keymap.h
index 2a34061593f..214ba605c76 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -30,15 +30,12 @@ EXFUN (Fdefine_key, 3);
30EXFUN (Flookup_key, 3); 30EXFUN (Flookup_key, 3);
31EXFUN (Fcommand_remapping, 1); 31EXFUN (Fcommand_remapping, 1);
32EXFUN (Fkey_binding, 3); 32EXFUN (Fkey_binding, 3);
33EXFUN (Fkey_description, 1); 33EXFUN (Fkey_description, 2);
34EXFUN (Fsingle_key_description, 2); 34EXFUN (Fsingle_key_description, 2);
35EXFUN (Fwhere_is_internal, 5); 35EXFUN (Fwhere_is_internal, 5);
36extern Lisp_Object access_keymap P_ ((Lisp_Object, Lisp_Object, int, int, int)); 36extern Lisp_Object access_keymap P_ ((Lisp_Object, Lisp_Object, int, int, int));
37extern Lisp_Object get_keyelt P_ ((Lisp_Object, int)); 37extern Lisp_Object get_keyelt P_ ((Lisp_Object, int));
38extern Lisp_Object get_keymap P_ ((Lisp_Object, int, int)); 38extern Lisp_Object get_keymap P_ ((Lisp_Object, int, int));
39extern void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
40 void (*) (Lisp_Object, Lisp_Object), int,
41 Lisp_Object, Lisp_Object, int *, int));
42extern void describe_map_tree P_ ((Lisp_Object, int, Lisp_Object, Lisp_Object, 39extern void describe_map_tree P_ ((Lisp_Object, int, Lisp_Object, Lisp_Object,
43 char *, int, int, int)); 40 char *, int, int, int));
44extern int current_minor_maps P_ ((Lisp_Object **, Lisp_Object **)); 41extern int current_minor_maps P_ ((Lisp_Object **, Lisp_Object **));
diff --git a/src/lisp.h b/src/lisp.h
index 6f248df0a3c..7e39313a7fc 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -279,26 +279,57 @@ enum pvec_type
279 279
280/* For convenience, we also store the number of elements in these bits. */ 280/* For convenience, we also store the number of elements in these bits. */
281#define PSEUDOVECTOR_SIZE_MASK 0x1ff 281#define PSEUDOVECTOR_SIZE_MASK 0x1ff
282
283/* Number of bits to put in each character in the internal representation
284 of bool vectors. This should not vary across implementations. */
285#define BOOL_VECTOR_BITS_PER_CHAR 8
282 286
283/***** Select the tagging scheme. *****/ 287/***** Select the tagging scheme. *****/
288/* There are basically two options that control the tagging scheme:
289 - NO_UNION_TYPE says that Lisp_Object should be an integer instead
290 of a union.
291 - USE_LSB_TAG means that we can assume the least 3 bits of pointers are
292 always 0, and we can thus use them to hold tag bits, without
293 restricting our addressing space.
294
295 If USE_LSB_TAG is not set, then we use the top 3 bits for tagging, thus
296 restricting our possible address range. Currently USE_LSB_TAG is not
297 allowed together with a union. This is not due to any fundamental
298 technical (or political ;-) problem: nobody wrote the code to do it yet.
299
300 USE_LSB_TAG not only requires the least 3 bits of pointers returned by
301 malloc to be 0 but also needs to be able to impose a mult-of-8 alignment
302 on the few static Lisp_Objects used: all the defsubr as well
303 as the two special buffers buffer_defaults and buffer_local_symbols. */
284 304
285/* First, try and define DECL_ALIGN(type,var) which declares a static 305/* First, try and define DECL_ALIGN(type,var) which declares a static
286 variable VAR of type TYPE with the added requirement that it be 306 variable VAR of type TYPE with the added requirement that it be
287 TYPEBITS-aligned. */ 307 TYPEBITS-aligned. */
288#if defined USE_LSB_TAG && !defined DECL_ALIGN 308#ifndef DECL_ALIGN
289/* What compiler directive should we use for non-gcc compilers? -stef */ 309/* What compiler directive should we use for non-gcc compilers? -stef */
290# if defined (__GNUC__) 310# if defined (__GNUC__)
291# define DECL_ALIGN(type, var) \ 311# define DECL_ALIGN(type, var) \
292 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var 312 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
293# else
294# error "USE_LSB_TAG used without defining DECL_ALIGN"
295# endif 313# endif
296#endif 314#endif
297 315
298#ifndef USE_LSB_TAG 316/* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8. */
317#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined MAC_OSX
318/* We also need to be able to specify mult-of-8 alignment on static vars. */
319# if defined DECL_ALIGN
320/* We currently do not support USE_LSB_TAG with a union Lisp_Object. */
321# if defined NO_UNION_TYPE
322# define USE_LSB_TAG
323# endif
324# endif
325#endif
326
299/* Just remove the alignment annotation if we don't use it. */ 327/* Just remove the alignment annotation if we don't use it. */
300#undef DECL_ALIGN 328#ifndef DECL_ALIGN
301#define DECL_ALIGN(type, var) type var 329# ifdef USE_LSB_TAG
330# error "USE_LSB_TAG used without defining DECL_ALIGN"
331# endif
332# define DECL_ALIGN(type, var) type var
302#endif 333#endif
303 334
304 335
@@ -383,7 +414,7 @@ enum pvec_type
383 414
384#ifdef EXPLICIT_SIGN_EXTEND 415#ifdef EXPLICIT_SIGN_EXTEND
385/* Make sure we sign-extend; compilers have been known to fail to do so. */ 416/* Make sure we sign-extend; compilers have been known to fail to do so. */
386#define XINT(a) (((a).i << (BITS_PER_EMACS_INT - VALBITS)) \ 417#define XINT(a) (((a).s.val << (BITS_PER_EMACS_INT - VALBITS)) \
387 >> (BITS_PER_EMACS_INT - VALBITS)) 418 >> (BITS_PER_EMACS_INT - VALBITS))
388#else 419#else
389#define XINT(a) ((a).s.val) 420#define XINT(a) ((a).s.val)
@@ -401,7 +432,7 @@ enum pvec_type
401extern Lisp_Object make_number (); 432extern Lisp_Object make_number ();
402#endif 433#endif
403 434
404#define EQ(x, y) ((x).s.val == (y).s.val) 435#define EQ(x, y) ((x).s.val == (y).s.val && (x).s.type == (y).s.type)
405 436
406#endif /* NO_UNION_TYPE */ 437#endif /* NO_UNION_TYPE */
407 438
@@ -2408,7 +2439,8 @@ void set_frame_cursor_types P_ ((struct frame *, Lisp_Object));
2408extern void syms_of_xdisp P_ ((void)); 2439extern void syms_of_xdisp P_ ((void));
2409extern void init_xdisp P_ ((void)); 2440extern void init_xdisp P_ ((void));
2410extern Lisp_Object safe_eval P_ ((Lisp_Object)); 2441extern Lisp_Object safe_eval P_ ((Lisp_Object));
2411extern int pos_visible_p P_ ((struct window *, int, int *, int)); 2442extern int pos_visible_p P_ ((struct window *, int, int *,
2443 int *, int *, int));
2412 2444
2413/* Defined in vm-limit.c. */ 2445/* Defined in vm-limit.c. */
2414extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ())); 2446extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ()));
@@ -2779,6 +2811,7 @@ extern void syms_of_fileio P_ ((void));
2779EXFUN (Fmake_temp_name, 1); 2811EXFUN (Fmake_temp_name, 1);
2780extern void init_fileio_once P_ ((void)); 2812extern void init_fileio_once P_ ((void));
2781extern Lisp_Object make_temp_name P_ ((Lisp_Object, int)); 2813extern Lisp_Object make_temp_name P_ ((Lisp_Object, int));
2814EXFUN (Fmake_symbolic_link, 3);
2782 2815
2783/* Defined in abbrev.c */ 2816/* Defined in abbrev.c */
2784 2817
@@ -2892,6 +2925,10 @@ extern int indented_beyond_p P_ ((int, int, double));
2892extern void syms_of_indent P_ ((void)); 2925extern void syms_of_indent P_ ((void));
2893 2926
2894/* defined in frame.c */ 2927/* defined in frame.c */
2928#ifdef HAVE_WINDOW_SYSTEM
2929extern Lisp_Object Vx_resource_name;
2930extern Lisp_Object Vx_resource_class;
2931#endif /* HAVE_WINDOW_SYSTEM */
2895extern Lisp_Object Qvisible; 2932extern Lisp_Object Qvisible;
2896extern void store_frame_param P_ ((struct frame *, Lisp_Object, Lisp_Object)); 2933extern void store_frame_param P_ ((struct frame *, Lisp_Object, Lisp_Object));
2897extern void store_in_alist P_ ((Lisp_Object *, Lisp_Object, Lisp_Object)); 2934extern void store_in_alist P_ ((Lisp_Object *, Lisp_Object, Lisp_Object));
@@ -3013,7 +3050,7 @@ extern void syms_of_macros P_ ((void));
3013/* defined in undo.c */ 3050/* defined in undo.c */
3014extern Lisp_Object Qinhibit_read_only; 3051extern Lisp_Object Qinhibit_read_only;
3015EXFUN (Fundo_boundary, 0); 3052EXFUN (Fundo_boundary, 0);
3016extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int)); 3053extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int, int));
3017extern void record_marker_adjustment P_ ((Lisp_Object, int)); 3054extern void record_marker_adjustment P_ ((Lisp_Object, int));
3018extern void record_insert P_ ((int, int)); 3055extern void record_insert P_ ((int, int));
3019extern void record_delete P_ ((int, Lisp_Object)); 3056extern void record_delete P_ ((int, Lisp_Object));
@@ -3115,11 +3152,12 @@ extern int getloadavg P_ ((double *, int));
3115#ifdef HAVE_X_WINDOWS 3152#ifdef HAVE_X_WINDOWS
3116/* Defined in xfns.c */ 3153/* Defined in xfns.c */
3117extern void syms_of_xfns P_ ((void)); 3154extern void syms_of_xfns P_ ((void));
3118extern Lisp_Object Vx_resource_name; 3155#endif /* HAVE_X_WINDOWS */
3119extern Lisp_Object Vx_resource_class; 3156#ifdef HAVE_WINDOW_SYSTEM
3157/* Defined in xfns.c, w32fns.c, or macfns.c */
3120EXFUN (Fxw_display_color_p, 1); 3158EXFUN (Fxw_display_color_p, 1);
3121EXFUN (Fx_file_dialog, 4); 3159EXFUN (Fx_file_dialog, 4);
3122#endif /* HAVE_X_WINDOWS */ 3160#endif /* HAVE_WINDOW_SYSTEM */
3123 3161
3124/* Defined in xsmfns.c */ 3162/* Defined in xsmfns.c */
3125extern void syms_of_xsmfns P_ ((void)); 3163extern void syms_of_xsmfns P_ ((void));
@@ -3145,9 +3183,7 @@ extern void xfree P_ ((POINTER_TYPE *));
3145 3183
3146extern char *xstrdup P_ ((const char *)); 3184extern char *xstrdup P_ ((const char *));
3147 3185
3148#ifndef USE_CRT_DLL
3149extern char *egetenv P_ ((char *)); 3186extern char *egetenv P_ ((char *));
3150#endif
3151 3187
3152/* Set up the name of the machine we're running on. */ 3188/* Set up the name of the machine we're running on. */
3153extern void init_system_name P_ ((void)); 3189extern void init_system_name P_ ((void));
@@ -3228,6 +3264,32 @@ extern Lisp_Object Vdirectory_sep_char;
3228 ? make_float (val) \ 3264 ? make_float (val) \
3229 : make_number ((EMACS_INT)(val))) 3265 : make_number ((EMACS_INT)(val)))
3230 3266
3267
3268/* Checks the `cycle check' variable CHECK to see if it indicates that
3269 EL is part of a cycle; CHECK must be either Qnil or a value returned
3270 by an earlier use of CYCLE_CHECK. SUSPICIOUS is the number of
3271 elements after which a cycle might be suspected; after that many
3272 elements, this macro begins consing in order to keep more precise
3273 track of elements.
3274
3275 Returns nil if a cycle was detected, otherwise a new value for CHECK
3276 that includes EL.
3277
3278 CHECK is evaluated multiple times, EL and SUSPICIOUS 0 or 1 times, so
3279 the caller should make sure that's ok. */
3280
3281#define CYCLE_CHECK(check, el, suspicious) \
3282 (NILP (check) \
3283 ? make_number (0) \
3284 : (INTEGERP (check) \
3285 ? (XFASTINT (check) < (suspicious) \
3286 ? make_number (XFASTINT (check) + 1) \
3287 : Fcons (el, Qnil)) \
3288 : (!NILP (Fmemq ((el), (check))) \
3289 ? Qnil \
3290 : Fcons ((el), (check)))))
3291
3292
3231#endif /* EMACS_LISP_H */ 3293#endif /* EMACS_LISP_H */
3232 3294
3233/* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e 3295/* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e
diff --git a/src/lread.c b/src/lread.c
index dd6e3f322a6..d3014eb7eb6 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2122,8 +2122,9 @@ read1 (readcharfun, pch, first_in_list)
2122 if (c == '"') 2122 if (c == '"')
2123 { 2123 {
2124 Lisp_Object tmp, val; 2124 Lisp_Object tmp, val;
2125 int size_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) 2125 int size_in_chars
2126 / BITS_PER_CHAR); 2126 = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1)
2127 / BOOL_VECTOR_BITS_PER_CHAR);
2127 2128
2128 UNREAD (c); 2129 UNREAD (c);
2129 tmp = read1 (readcharfun, pch, first_in_list); 2130 tmp = read1 (readcharfun, pch, first_in_list);
@@ -2134,7 +2135,7 @@ read1 (readcharfun, pch, first_in_list)
2134 Accept such input in case it came from an old 2135 Accept such input in case it came from an old
2135 version. */ 2136 version. */
2136 && ! (XFASTINT (length) 2137 && ! (XFASTINT (length)
2137 == (SCHARS (tmp) - 1) * BITS_PER_CHAR))) 2138 == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR)))
2138 Fsignal (Qinvalid_read_syntax, 2139 Fsignal (Qinvalid_read_syntax,
2139 Fcons (make_string ("#&...", 5), Qnil)); 2140 Fcons (make_string ("#&...", 5), Qnil));
2140 2141
@@ -2142,9 +2143,9 @@ read1 (readcharfun, pch, first_in_list)
2142 bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data, 2143 bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data,
2143 size_in_chars); 2144 size_in_chars);
2144 /* Clear the extraneous bits in the last byte. */ 2145 /* Clear the extraneous bits in the last byte. */
2145 if (XINT (length) != size_in_chars * BITS_PER_CHAR) 2146 if (XINT (length) != size_in_chars * BOOL_VECTOR_BITS_PER_CHAR)
2146 XBOOL_VECTOR (val)->data[size_in_chars - 1] 2147 XBOOL_VECTOR (val)->data[size_in_chars - 1]
2147 &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; 2148 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
2148 return val; 2149 return val;
2149 } 2150 }
2150 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5), 2151 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5),
@@ -3814,11 +3815,15 @@ init_lread ()
3814 } 3815 }
3815#endif 3816#endif
3816 3817
3817#ifndef WINDOWSNT 3818#if (!(defined(WINDOWSNT) || (defined(HAVE_CARBON))))
3818 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is 3819 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
3819 almost never correct, thereby causing a warning to be printed out that 3820 almost never correct, thereby causing a warning to be printed out that
3820 confuses users. Since PATH_LOADSEARCH is always overridden by the 3821 confuses users. Since PATH_LOADSEARCH is always overridden by the
3821 EMACSLOADPATH environment variable below, disable the warning on NT. */ 3822 EMACSLOADPATH environment variable below, disable the warning on NT.
3823 Also, when using the "self-contained" option for Carbon Emacs for MacOSX,
3824 the "standard" paths may not exist and would be overridden by
3825 EMACSLOADPATH as on NT. Since this depends on how the executable
3826 was build and packaged, turn off the warnings in general */
3822 3827
3823 /* Warn if dirs in the *standard* path don't exist. */ 3828 /* Warn if dirs in the *standard* path don't exist. */
3824 if (!turn_off_warning) 3829 if (!turn_off_warning)
@@ -3840,7 +3845,7 @@ init_lread ()
3840 } 3845 }
3841 } 3846 }
3842 } 3847 }
3843#endif /* WINDOWSNT */ 3848#endif /* !(WINDOWSNT || HAVE_CARBON) */
3844 3849
3845 /* If the EMACSLOADPATH environment variable is set, use its value. 3850 /* If the EMACSLOADPATH environment variable is set, use its value.
3846 This doesn't apply if we're dumping. */ 3851 This doesn't apply if we're dumping. */
diff --git a/src/macfns.c b/src/macfns.c
index dbb8adb3fe1..ec014e772e3 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1,5 +1,5 @@
1/* Graphical user interface functions for Mac OS. 1/* Graphical user interface functions for Mac OS.
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc. 2 Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */
42#include "epaths.h" 42#include "epaths.h"
43#include "termhooks.h" 43#include "termhooks.h"
44#include "coding.h" 44#include "coding.h"
45#include "ccl.h"
46#include "systime.h" 45#include "systime.h"
47 46
48/* #include "bitmaps/gray.xbm" */ 47/* #include "bitmaps/gray.xbm" */
@@ -59,17 +58,6 @@ static unsigned char gray_bits[] = {
59 58
60#include <stdlib.h> 59#include <stdlib.h>
61#include <string.h> 60#include <string.h>
62#ifndef MAC_OSX
63#include <alloca.h>
64#endif
65
66#ifdef MAC_OSX
67#include <QuickTime/QuickTime.h>
68#else /* not MAC_OSX */
69#include <Windows.h>
70#include <Gestalt.h>
71#include <TextUtils.h>
72#endif /* not MAC_OSX */
73 61
74/*extern void free_frame_menubar (); 62/*extern void free_frame_menubar ();
75extern double atof (); 63extern double atof ();
@@ -2580,8 +2568,6 @@ This function is an internal primitive--use `make-frame' instead. */)
2580 f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); 2568 f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
2581 bzero (f->output_data.mac, sizeof (struct mac_output)); 2569 bzero (f->output_data.mac, sizeof (struct mac_output));
2582 FRAME_FONTSET (f) = -1; 2570 FRAME_FONTSET (f) = -1;
2583 f->output_data.mac->scroll_bar_foreground_pixel = -1;
2584 f->output_data.mac->scroll_bar_background_pixel = -1;
2585 record_unwind_protect (unwind_create_frame, frame); 2571 record_unwind_protect (unwind_create_frame, frame);
2586 2572
2587 f->icon_name 2573 f->icon_name
@@ -2598,7 +2584,7 @@ This function is an internal primitive--use `make-frame' instead. */)
2598 2584
2599 if (!NILP (parent)) 2585 if (!NILP (parent))
2600 { 2586 {
2601 f->output_data.mac->parent_desc = (Window) parent; 2587 f->output_data.mac->parent_desc = (Window) XFASTINT (parent);
2602 f->output_data.mac->explicit_parent = 1; 2588 f->output_data.mac->explicit_parent = 1;
2603 } 2589 }
2604 else 2590 else
@@ -2708,7 +2694,7 @@ This function is an internal primitive--use `make-frame' instead. */)
2708 2694
2709 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), 2695 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
2710 "menuBar", "MenuBar", RES_TYPE_NUMBER); 2696 "menuBar", "MenuBar", RES_TYPE_NUMBER);
2711 x_default_parameter (f, parms, Qtool_bar_lines, make_number (0), 2697 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
2712 "toolBar", "ToolBar", RES_TYPE_NUMBER); 2698 "toolBar", "ToolBar", RES_TYPE_NUMBER);
2713 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, 2699 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
2714 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); 2700 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
@@ -2717,25 +2703,32 @@ This function is an internal primitive--use `make-frame' instead. */)
2717 2703
2718 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; 2704 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2719 2705
2720 /* MAC_TODO: specify 1 below when toolbars are implemented. */ 2706#if TARGET_API_MAC_CARBON
2721 window_prompting = x_figure_window_size (f, parms, 0); 2707 f->output_data.mac->text_cursor = kThemeIBeamCursor;
2708 f->output_data.mac->nontext_cursor = kThemeArrowCursor;
2709 f->output_data.mac->modeline_cursor = kThemeArrowCursor;
2710 f->output_data.mac->hand_cursor = kThemePointingHandCursor;
2711 f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
2712 f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
2713#else
2714 f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
2715 f->output_data.mac->nontext_cursor = &arrow_cursor;
2716 f->output_data.mac->modeline_cursor = &arrow_cursor;
2717 f->output_data.mac->hand_cursor = &arrow_cursor;
2718 f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
2719 f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
2720#endif
2721
2722 /* Compute the size of the window. */
2723 window_prompting = x_figure_window_size (f, parms, 1);
2722 2724
2723 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 2725 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
2724 f->no_split = minibuffer_only || EQ (tem, Qt); 2726 f->no_split = minibuffer_only || EQ (tem, Qt);
2725 2727
2726 /* Create the window. Add the tool-bar height to the initial frame
2727 height so that the user gets a text display area of the size he
2728 specified with -g or via the registry. Later changes of the
2729 tool-bar height don't change the frame size. This is done so that
2730 users can create tall Emacs frames without having to guess how
2731 tall the tool-bar will get. */
2732 FRAME_LINES (f) += FRAME_TOOL_BAR_LINES (f);
2733
2734 /* mac_window (f, window_prompting, minibuffer_only); */ 2728 /* mac_window (f, window_prompting, minibuffer_only); */
2735 make_mac_frame (f); 2729 make_mac_frame (f);
2736 2730
2737 x_icon (f, parms); 2731 x_icon (f, parms);
2738
2739 x_make_gc (f); 2732 x_make_gc (f);
2740 2733
2741 /* Now consider the frame official. */ 2734 /* Now consider the frame official. */
@@ -2754,7 +2747,8 @@ This function is an internal primitive--use `make-frame' instead. */)
2754 x_default_parameter (f, parms, Qcursor_type, Qbox, 2747 x_default_parameter (f, parms, Qcursor_type, Qbox,
2755 "cursorType", "CursorType", RES_TYPE_SYMBOL); 2748 "cursorType", "CursorType", RES_TYPE_SYMBOL);
2756 x_default_parameter (f, parms, Qscroll_bar_width, Qnil, 2749 x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
2757 "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); 2750 "scrollBarWidth", "ScrollBarWidth",
2751 RES_TYPE_NUMBER);
2758 2752
2759 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. 2753 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
2760 Change will not be effected unless different from the current 2754 Change will not be effected unless different from the current
@@ -2762,13 +2756,10 @@ This function is an internal primitive--use `make-frame' instead. */)
2762 width = FRAME_COLS (f); 2756 width = FRAME_COLS (f);
2763 height = FRAME_LINES (f); 2757 height = FRAME_LINES (f);
2764 2758
2765 FRAME_LINES (f) = 0;
2766 SET_FRAME_COLS (f, 0); 2759 SET_FRAME_COLS (f, 0);
2760 FRAME_LINES (f) = 0;
2767 change_frame_size (f, height, width, 1, 0, 0); 2761 change_frame_size (f, height, width, 1, 0, 0);
2768 2762
2769 /* Set up faces after all frame parameters are known. */
2770 call1 (Qface_set_after_frame_default, frame);
2771
2772#if 0 /* MAC_TODO: when we have window manager hints */ 2763#if 0 /* MAC_TODO: when we have window manager hints */
2773 /* Tell the server what size and position, etc, we want, and how 2764 /* Tell the server what size and position, etc, we want, and how
2774 badly we want them. This should be done after we have the menu 2765 badly we want them. This should be done after we have the menu
@@ -2948,8 +2939,8 @@ If omitted or nil, that stands for the selected frame's display. */)
2948{ 2939{
2949 struct mac_display_info *dpyinfo = check_x_display_info (display); 2940 struct mac_display_info *dpyinfo = check_x_display_info (display);
2950 2941
2951 /* MAC_TODO: check whether this is right */ 2942 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
2952 return make_number (dpyinfo->n_planes >= 8 ? 256 : 1 << dpyinfo->n_planes - 1); 2943 return make_number (1 << min (dpyinfo->n_planes, 24));
2953} 2944}
2954 2945
2955DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 2946DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
@@ -3025,11 +3016,8 @@ If omitted or nil, that stands for the selected frame's display. */)
3025 /* MAC_TODO: this is an approximation, and only of the main display */ 3016 /* MAC_TODO: this is an approximation, and only of the main display */
3026 3017
3027 struct mac_display_info *dpyinfo = check_x_display_info (display); 3018 struct mac_display_info *dpyinfo = check_x_display_info (display);
3028 short h, v;
3029 3019
3030 ScreenRes (&h, &v); 3020 return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy));
3031
3032 return make_number ((int) (v / 72.0 * 25.4));
3033} 3021}
3034 3022
3035DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 3023DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -3043,11 +3031,8 @@ If omitted or nil, that stands for the selected frame's display. */)
3043 /* MAC_TODO: this is an approximation, and only of the main display */ 3031 /* MAC_TODO: this is an approximation, and only of the main display */
3044 3032
3045 struct mac_display_info *dpyinfo = check_x_display_info (display); 3033 struct mac_display_info *dpyinfo = check_x_display_info (display);
3046 short h, v;
3047
3048 ScreenRes (&h, &v);
3049 3034
3050 return make_number ((int) (h / 72.0 * 25.4)); 3035 return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx));
3051} 3036}
3052 3037
3053DEFUN ("x-display-backing-store", Fx_display_backing_store, 3038DEFUN ("x-display-backing-store", Fx_display_backing_store,
@@ -3595,9 +3580,11 @@ hide_hourglass ()
3595 ***********************************************************************/ 3580 ***********************************************************************/
3596 3581
3597static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *, 3582static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
3598 Lisp_Object)); 3583 Lisp_Object, Lisp_Object));
3584static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
3585 Lisp_Object, int, int, int *, int *));
3599 3586
3600/* The frame of a currently visible tooltip, or null. */ 3587/* The frame of a currently visible tooltip. */
3601 3588
3602Lisp_Object tip_frame; 3589Lisp_Object tip_frame;
3603 3590
@@ -3612,15 +3599,42 @@ Window tip_window;
3612 3599
3613Lisp_Object last_show_tip_args; 3600Lisp_Object last_show_tip_args;
3614 3601
3602/* Maximum size for tooltips; a cons (COLUMNS . ROWS). */
3603
3604Lisp_Object Vx_max_tooltip_size;
3605
3606
3607static Lisp_Object
3608unwind_create_tip_frame (frame)
3609 Lisp_Object frame;
3610{
3611 Lisp_Object deleted;
3612
3613 deleted = unwind_create_frame (frame);
3614 if (EQ (deleted, Qt))
3615 {
3616 tip_window = NULL;
3617 tip_frame = Qnil;
3618 }
3619
3620 return deleted;
3621}
3622
3623
3615/* Create a frame for a tooltip on the display described by DPYINFO. 3624/* Create a frame for a tooltip on the display described by DPYINFO.
3616 PARMS is a list of frame parameters. Value is the frame. */ 3625 PARMS is a list of frame parameters. TEXT is the string to
3626 display in the tip frame. Value is the frame.
3627
3628 Note that functions called here, esp. x_default_parameter can
3629 signal errors, for instance when a specified color name is
3630 undefined. We have to make sure that we're in a consistent state
3631 when this happens. */
3617 3632
3618static Lisp_Object 3633static Lisp_Object
3619x_create_tip_frame (dpyinfo, parms) 3634x_create_tip_frame (dpyinfo, parms, text)
3620 struct mac_display_info *dpyinfo; 3635 struct mac_display_info *dpyinfo;
3621 Lisp_Object parms; 3636 Lisp_Object parms, text;
3622{ 3637{
3623#if 0 /* MAC_TODO : Mac version */
3624 struct frame *f; 3638 struct frame *f;
3625 Lisp_Object frame, tem; 3639 Lisp_Object frame, tem;
3626 Lisp_Object name; 3640 Lisp_Object name;
@@ -3629,8 +3643,11 @@ x_create_tip_frame (dpyinfo, parms)
3629 int count = SPECPDL_INDEX (); 3643 int count = SPECPDL_INDEX ();
3630 struct gcpro gcpro1, gcpro2, gcpro3; 3644 struct gcpro gcpro1, gcpro2, gcpro3;
3631 struct kboard *kb; 3645 struct kboard *kb;
3646 int face_change_count_before = face_change_count;
3647 Lisp_Object buffer;
3648 struct buffer *old_buffer;
3632 3649
3633 check_x (); 3650 check_mac ();
3634 3651
3635 /* Use this general default value to start with until we know if 3652 /* Use this general default value to start with until we know if
3636 this frame has a specified name. */ 3653 this frame has a specified name. */
@@ -3643,7 +3660,7 @@ x_create_tip_frame (dpyinfo, parms)
3643#endif 3660#endif
3644 3661
3645 /* Get the name of the frame to use for resource lookup. */ 3662 /* Get the name of the frame to use for resource lookup. */
3646 name = w32_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); 3663 name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
3647 if (!STRINGP (name) 3664 if (!STRINGP (name)
3648 && !EQ (name, Qunbound) 3665 && !EQ (name, Qunbound)
3649 && !NILP (name)) 3666 && !NILP (name))
@@ -3652,31 +3669,50 @@ x_create_tip_frame (dpyinfo, parms)
3652 3669
3653 frame = Qnil; 3670 frame = Qnil;
3654 GCPRO3 (parms, name, frame); 3671 GCPRO3 (parms, name, frame);
3655 tip_frame = f = make_frame (1); 3672 f = make_frame (1);
3656 XSETFRAME (frame, f); 3673 XSETFRAME (frame, f);
3674
3675 buffer = Fget_buffer_create (build_string (" *tip*"));
3676 Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
3677 old_buffer = current_buffer;
3678 set_buffer_internal_1 (XBUFFER (buffer));
3679 current_buffer->truncate_lines = Qnil;
3680 specbind (Qinhibit_read_only, Qt);
3681 specbind (Qinhibit_modification_hooks, Qt);
3682 Ferase_buffer ();
3683 Finsert (1, &text);
3684 set_buffer_internal_1 (old_buffer);
3685
3657 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 3686 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3687 record_unwind_protect (unwind_create_tip_frame, frame);
3658 3688
3659 f->output_method = output_w32; 3689 /* By setting the output method, we're essentially saying that
3660 f->output_data.w32 = 3690 the frame is live, as per FRAME_LIVE_P. If we get a signal
3661 (struct w32_output *) xmalloc (sizeof (struct w32_output)); 3691 from this point on, x_destroy_window might screw up reference
3662 bzero (f->output_data.w32, sizeof (struct w32_output)); 3692 counts etc. */
3663#if 0 3693 f->output_method = output_mac;
3664 f->output_data.w32->icon_bitmap = -1; 3694 f->output_data.mac =
3665#endif 3695 (struct mac_output *) xmalloc (sizeof (struct mac_output));
3666 FRAME_FONTSET (f) = -1; 3696 bzero (f->output_data.mac, sizeof (struct mac_output));
3697
3698 FRAME_FONTSET (f) = -1;
3667 f->icon_name = Qnil; 3699 f->icon_name = Qnil;
3668 3700
3701#if 0 /* GLYPH_DEBUG TODO: image support. */
3702 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
3703 dpyinfo_refcount = dpyinfo->reference_count;
3704#endif /* GLYPH_DEBUG */
3669#ifdef MULTI_KBOARD 3705#ifdef MULTI_KBOARD
3670 FRAME_KBOARD (f) = kb; 3706 FRAME_KBOARD (f) = kb;
3671#endif 3707#endif
3672 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; 3708 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3673 f->output_data.w32->explicit_parent = 0; 3709 f->output_data.mac->explicit_parent = 0;
3674 3710
3675 /* Set the name; the functions to which we pass f expect the name to 3711 /* Set the name; the functions to which we pass f expect the name to
3676 be set. */ 3712 be set. */
3677 if (EQ (name, Qunbound) || NILP (name)) 3713 if (EQ (name, Qunbound) || NILP (name))
3678 { 3714 {
3679 f->name = build_string (dpyinfo->x_id_name); 3715 f->name = build_string (dpyinfo->mac_id_name);
3680 f->explicit_name = 0; 3716 f->explicit_name = 0;
3681 } 3717 }
3682 else 3718 else
@@ -3687,12 +3723,12 @@ x_create_tip_frame (dpyinfo, parms)
3687 specbind (Qx_resource_name, name); 3723 specbind (Qx_resource_name, name);
3688 } 3724 }
3689 3725
3690 /* Extract the window parameters from the supplied values 3726 /* Extract the window parameters from the supplied values that are
3691 that are needed to determine window geometry. */ 3727 needed to determine window geometry. */
3692 { 3728 {
3693 Lisp_Object font; 3729 Lisp_Object font;
3694 3730
3695 font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING); 3731 font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
3696 3732
3697 BLOCK_INPUT; 3733 BLOCK_INPUT;
3698 /* First, try whatever font the caller has specified. */ 3734 /* First, try whatever font the caller has specified. */
@@ -3706,22 +3742,16 @@ x_create_tip_frame (dpyinfo, parms)
3706 } 3742 }
3707 3743
3708 /* Try out a font which we hope has bold and italic variations. */ 3744 /* Try out a font which we hope has bold and italic variations. */
3709 if (!STRINGP (font))
3710 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
3711 if (!STRINGP (font))
3712 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3713 if (! STRINGP (font))
3714 font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3715 if (! STRINGP (font)) 3745 if (! STRINGP (font))
3716 /* This was formerly the first thing tried, but it finds too many fonts 3746 font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
3717 and takes too long. */
3718 font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3719 /* If those didn't work, look for something which will at least work. */ 3747 /* If those didn't work, look for something which will at least work. */
3720 if (! STRINGP (font)) 3748 if (! STRINGP (font))
3721 font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1"); 3749 font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
3750 if (! STRINGP (font))
3751 font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
3722 UNBLOCK_INPUT; 3752 UNBLOCK_INPUT;
3723 if (! STRINGP (font)) 3753 if (! STRINGP (font))
3724 font = build_string ("fixed"); 3754 error ("Cannot find any usable font");
3725 3755
3726 x_default_parameter (f, parms, Qfont, font, 3756 x_default_parameter (f, parms, Qfont, font,
3727 "font", "Font", RES_TYPE_STRING); 3757 "font", "Font", RES_TYPE_STRING);
@@ -3737,7 +3767,7 @@ x_create_tip_frame (dpyinfo, parms)
3737 { 3767 {
3738 Lisp_Object value; 3768 Lisp_Object value;
3739 3769
3740 value = w32_get_arg (parms, Qinternal_border_width, 3770 value = mac_get_arg (parms, Qinternal_border_width,
3741 "internalBorder", "internalBorder", RES_TYPE_NUMBER); 3771 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
3742 if (! EQ (value, Qunbound)) 3772 if (! EQ (value, Qunbound))
3743 parms = Fcons (Fcons (Qinternal_border_width, value), 3773 parms = Fcons (Fcons (Qinternal_border_width, value),
@@ -3768,34 +3798,28 @@ x_create_tip_frame (dpyinfo, parms)
3768 happen. */ 3798 happen. */
3769 init_frame_faces (f); 3799 init_frame_faces (f);
3770 3800
3771 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; 3801 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3772 3802
3773 window_prompting = x_figure_window_size (f, parms, 0); 3803 window_prompting = x_figure_window_size (f, parms, 0);
3774 3804
3775 { 3805 {
3776 XSetWindowAttributes attrs; 3806 Rect r;
3777 unsigned long mask;
3778 3807
3779 BLOCK_INPUT; 3808 BLOCK_INPUT;
3780 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask; 3809 SetRect (&r, 0, 0, 1, 1);
3781 /* Window managers looks at the override-redirect flag to 3810 if (CreateNewWindow (kHelpWindowClass,
3782 determine whether or net to give windows a decoration (Xlib 3811#ifdef MAC_OS_X_VERSION_10_2
3783 3.2.8). */ 3812 kWindowIgnoreClicksAttribute |
3784 attrs.override_redirect = True; 3813#endif
3785 attrs.save_under = True; 3814 kWindowNoActivatesAttribute,
3786 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f); 3815 &r, &tip_window) == noErr)
3787 /* Arrange for getting MapNotify and UnmapNotify events. */ 3816 {
3788 attrs.event_mask = StructureNotifyMask; 3817 FRAME_MAC_WINDOW (f) = tip_window;
3789 tip_window 3818 SetWRefCon (tip_window, (long) f->output_data.mac);
3790 = FRAME_W32_WINDOW (f) 3819 /* so that update events can find this mac_output struct */
3791 = XCreateWindow (FRAME_W32_DISPLAY (f), 3820 f->output_data.mac->mFP = f;
3792 FRAME_W32_DISPLAY_INFO (f)->root_window, 3821 ShowWindow (tip_window);
3793 /* x, y, width, height */ 3822 }
3794 0, 0, 1, 1,
3795 /* Border. */
3796 1,
3797 CopyFromParent, InputOutput, CopyFromParent,
3798 mask, &attrs);
3799 UNBLOCK_INPUT; 3823 UNBLOCK_INPUT;
3800 } 3824 }
3801 3825
@@ -3813,8 +3837,8 @@ x_create_tip_frame (dpyinfo, parms)
3813 FRAME_LINES (f). */ 3837 FRAME_LINES (f). */
3814 width = FRAME_COLS (f); 3838 width = FRAME_COLS (f);
3815 height = FRAME_LINES (f); 3839 height = FRAME_LINES (f);
3816 FRAME_LINES (f) = 0;
3817 SET_FRAME_COLS (f, 0); 3840 SET_FRAME_COLS (f, 0);
3841 FRAME_LINES (f) = 0;
3818 change_frame_size (f, height, width, 1, 0, 0); 3842 change_frame_size (f, height, width, 1, 0, 0);
3819 3843
3820 /* Add `tooltip' frame parameter's default value. */ 3844 /* Add `tooltip' frame parameter's default value. */
@@ -3822,6 +3846,26 @@ x_create_tip_frame (dpyinfo, parms)
3822 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt), 3846 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
3823 Qnil)); 3847 Qnil));
3824 3848
3849 /* Set up faces after all frame parameters are known. This call
3850 also merges in face attributes specified for new frames.
3851
3852 Frame parameters may be changed if .Xdefaults contains
3853 specifications for the default font. For example, if there is an
3854 `Emacs.default.attributeBackground: pink', the `background-color'
3855 attribute of the frame get's set, which let's the internal border
3856 of the tooltip frame appear in pink. Prevent this. */
3857 {
3858 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
3859
3860 /* Set tip_frame here, so that */
3861 tip_frame = frame;
3862 call1 (Qface_set_after_frame_default, frame);
3863
3864 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
3865 Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
3866 Qnil));
3867 }
3868
3825 f->no_split = 1; 3869 f->no_split = 1;
3826 3870
3827 UNGCPRO; 3871 UNGCPRO;
@@ -3833,17 +3877,80 @@ x_create_tip_frame (dpyinfo, parms)
3833 3877
3834 /* Now that the frame is official, it counts as a reference to 3878 /* Now that the frame is official, it counts as a reference to
3835 its display. */ 3879 its display. */
3836 FRAME_W32_DISPLAY_INFO (f)->reference_count++; 3880 FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
3837 3881
3882 /* Setting attributes of faces of the tooltip frame from resources
3883 and similar will increment face_change_count, which leads to the
3884 clearing of all current matrices. Since this isn't necessary
3885 here, avoid it by resetting face_change_count to the value it
3886 had before we created the tip frame. */
3887 face_change_count = face_change_count_before;
3888
3889 /* Discard the unwind_protect. */
3838 return unbind_to (count, frame); 3890 return unbind_to (count, frame);
3839#endif /* MAC_TODO */ 3891}
3840 return Qnil; 3892
3893
3894/* Compute where to display tip frame F. PARMS is the list of frame
3895 parameters for F. DX and DY are specified offsets from the current
3896 location of the mouse. WIDTH and HEIGHT are the width and height
3897 of the tooltip. Return coordinates relative to the root window of
3898 the display in *ROOT_X, and *ROOT_Y. */
3899
3900static void
3901compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
3902 struct frame *f;
3903 Lisp_Object parms, dx, dy;
3904 int width, height;
3905 int *root_x, *root_y;
3906{
3907 Lisp_Object left, top;
3908
3909 /* User-specified position? */
3910 left = Fcdr (Fassq (Qleft, parms));
3911 top = Fcdr (Fassq (Qtop, parms));
3912
3913 /* Move the tooltip window where the mouse pointer is. Resize and
3914 show it. */
3915 if (!INTEGERP (left) || !INTEGERP (top))
3916 {
3917 Point mouse_pos;
3918
3919 BLOCK_INPUT;
3920 GetMouse (&mouse_pos);
3921 LocalToGlobal (&mouse_pos);
3922 *root_x = mouse_pos.h;
3923 *root_y = mouse_pos.v;
3924 UNBLOCK_INPUT;
3925 }
3926
3927 if (INTEGERP (top))
3928 *root_y = XINT (top);
3929 else if (*root_y + XINT (dy) - height < 0)
3930 *root_y -= XINT (dy);
3931 else
3932 {
3933 *root_y -= height;
3934 *root_y += XINT (dy);
3935 }
3936
3937 if (INTEGERP (left))
3938 *root_x = XINT (left);
3939 else if (*root_x + XINT (dx) + width <= FRAME_MAC_DISPLAY_INFO (f)->width)
3940 /* It fits to the right of the pointer. */
3941 *root_x += XINT (dx);
3942 else if (width + XINT (dx) <= *root_x)
3943 /* It fits to the left of the pointer. */
3944 *root_x -= width + XINT (dx);
3945 else
3946 /* Put it left-justified on the screen -- it ought to fit that way. */
3947 *root_x = 0;
3841} 3948}
3842 3949
3843 3950
3844DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, 3951DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
3845 doc : /* Show STRING in a "tooltip" window on frame FRAME. 3952 doc: /* Show STRING in a "tooltip" window on frame FRAME.
3846A tooltip window is a small window displaying a string. 3953A tooltip window is a small X window displaying a string.
3847 3954
3848FRAME nil or omitted means use the selected frame. 3955FRAME nil or omitted means use the selected frame.
3849 3956
@@ -3859,19 +3966,19 @@ displayed at the mouse position, with offset DX added (default is 5 if
3859DX isn't specified). Likewise for the y-position; if a `top' frame 3966DX isn't specified). Likewise for the y-position; if a `top' frame
3860parameter is specified, it determines the y-position of the tooltip 3967parameter is specified, it determines the y-position of the tooltip
3861window, otherwise it is displayed at the mouse position, with offset 3968window, otherwise it is displayed at the mouse position, with offset
3862DY added (default is 10). */) 3969DY added (default is -10).
3863 (string, frame, parms, timeout, dx, dy) 3970
3971A tooltip's maximum size is specified by `x-max-tooltip-size'.
3972Text larger than the specified size is clipped. */)
3973 (string, frame, parms, timeout, dx, dy)
3864 Lisp_Object string, frame, parms, timeout, dx, dy; 3974 Lisp_Object string, frame, parms, timeout, dx, dy;
3865{ 3975{
3866 struct frame *f; 3976 struct frame *f;
3867 struct window *w; 3977 struct window *w;
3868 Window root, child; 3978 int root_x, root_y;
3869 Lisp_Object buffer, top, left;
3870 struct buffer *old_buffer; 3979 struct buffer *old_buffer;
3871 struct text_pos pos; 3980 struct text_pos pos;
3872 int i, width, height; 3981 int i, width, height;
3873 int root_x, root_y, win_x, win_y;
3874 unsigned pmask;
3875 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 3982 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3876 int old_windows_or_buffers_changed = windows_or_buffers_changed; 3983 int old_windows_or_buffers_changed = windows_or_buffers_changed;
3877 int count = SPECPDL_INDEX (); 3984 int count = SPECPDL_INDEX ();
@@ -3920,13 +4027,11 @@ DY added (default is 10). */)
3920 call1 (Qcancel_timer, timer); 4027 call1 (Qcancel_timer, timer);
3921 } 4028 }
3922 4029
3923#if 0 /* MAC_TODO : Mac specifics */
3924 BLOCK_INPUT; 4030 BLOCK_INPUT;
3925 compute_tip_xy (f, parms, dx, dy, &root_x, &root_y); 4031 compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
3926 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4032 FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
3927 root_x, root_y - FRAME_PIXEL_HEIGHT (f)); 4033 MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
3928 UNBLOCK_INPUT; 4034 UNBLOCK_INPUT;
3929#endif /* MAC_TODO */
3930 goto start_timer; 4035 goto start_timer;
3931 } 4036 }
3932 } 4037 }
@@ -3953,26 +4058,36 @@ DY added (default is 10). */)
3953 4058
3954 /* Create a frame for the tooltip, and record it in the global 4059 /* Create a frame for the tooltip, and record it in the global
3955 variable tip_frame. */ 4060 variable tip_frame. */
3956 frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms); 4061 frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms, string);
3957 f = XFRAME (frame); 4062 f = XFRAME (frame);
3958 4063
3959 /* Set up the frame's root window. Currently we use a size of 80 4064 /* Set up the frame's root window. */
3960 columns x 40 lines. If someone wants to show a larger tip, he
3961 will loose. I don't think this is a realistic case. */
3962 w = XWINDOW (FRAME_ROOT_WINDOW (f)); 4065 w = XWINDOW (FRAME_ROOT_WINDOW (f));
3963 w->left_col = w->top_line = make_number (0); 4066 w->left_col = w->top_line = make_number (0);
3964 w->total_cols = make_number (80); 4067
3965 w->total_lines = make_number (40); 4068 if (CONSP (Vx_max_tooltip_size)
4069 && INTEGERP (XCAR (Vx_max_tooltip_size))
4070 && XINT (XCAR (Vx_max_tooltip_size)) > 0
4071 && INTEGERP (XCDR (Vx_max_tooltip_size))
4072 && XINT (XCDR (Vx_max_tooltip_size)) > 0)
4073 {
4074 w->total_cols = XCAR (Vx_max_tooltip_size);
4075 w->total_lines = XCDR (Vx_max_tooltip_size);
4076 }
4077 else
4078 {
4079 w->total_cols = make_number (80);
4080 w->total_lines = make_number (40);
4081 }
4082
4083 FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
3966 adjust_glyphs (f); 4084 adjust_glyphs (f);
3967 w->pseudo_window_p = 1; 4085 w->pseudo_window_p = 1;
3968 4086
3969 /* Display the tooltip text in a temporary buffer. */ 4087 /* Display the tooltip text in a temporary buffer. */
3970 buffer = Fget_buffer_create (build_string (" *tip*"));
3971 Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
3972 old_buffer = current_buffer; 4088 old_buffer = current_buffer;
3973 set_buffer_internal_1 (XBUFFER (buffer)); 4089 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer));
3974 Ferase_buffer (); 4090 current_buffer->truncate_lines = Qnil;
3975 Finsert (1, &string);
3976 clear_glyph_matrix (w->desired_matrix); 4091 clear_glyph_matrix (w->desired_matrix);
3977 clear_glyph_matrix (w->current_matrix); 4092 clear_glyph_matrix (w->current_matrix);
3978 SET_TEXT_POS (pos, BEGV, BEGV_BYTE); 4093 SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
@@ -3993,7 +4108,7 @@ DY added (default is 10). */)
3993 /* Let the row go over the full width of the frame. */ 4108 /* Let the row go over the full width of the frame. */
3994 row->full_width_p = 1; 4109 row->full_width_p = 1;
3995 4110
3996 /* There's a glyph at the end of rows that is use to place 4111 /* There's a glyph at the end of rows that is used to place
3997 the cursor there. Don't include the width of this glyph. */ 4112 the cursor there. Don't include the width of this glyph. */
3998 if (row->used[TEXT_AREA]) 4113 if (row->used[TEXT_AREA])
3999 { 4114 {
@@ -4014,17 +4129,13 @@ DY added (default is 10). */)
4014 4129
4015 /* Move the tooltip window where the mouse pointer is. Resize and 4130 /* Move the tooltip window where the mouse pointer is. Resize and
4016 show it. */ 4131 show it. */
4017#if 0 /* TODO : Mac specifics */ 4132 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
4018 compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
4019 4133
4020 BLOCK_INPUT; 4134 BLOCK_INPUT;
4021 XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window, 4135 MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4022 &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask); 4136 SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
4023 XMoveResizeWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), 4137 BringToFront (FRAME_MAC_WINDOW (f));
4024 root_x + 5, root_y - height - 5, width, height);
4025 XMapRaised (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));
4026 UNBLOCK_INPUT; 4138 UNBLOCK_INPUT;
4027#endif /* MAC_TODO */
4028 4139
4029 /* Draw into the window. */ 4140 /* Draw into the window. */
4030 w->must_be_updated_p = 1; 4141 w->must_be_updated_p = 1;
@@ -4046,8 +4157,8 @@ DY added (default is 10). */)
4046 4157
4047DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, 4158DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
4048 doc: /* Hide the current tooltip window, if there is any. 4159 doc: /* Hide the current tooltip window, if there is any.
4049Value is t is tooltip was open, nil otherwise. */) 4160Value is t if tooltip was open, nil otherwise. */)
4050 () 4161 ()
4051{ 4162{
4052 int count; 4163 int count;
4053 Lisp_Object deleted, frame, timer; 4164 Lisp_Object deleted, frame, timer;
@@ -4249,7 +4360,8 @@ syms_of_macfns ()
4249 staticpro (&Qsuppress_icon); 4360 staticpro (&Qsuppress_icon);
4250 Qundefined_color = intern ("undefined-color"); 4361 Qundefined_color = intern ("undefined-color");
4251 staticpro (&Qundefined_color); 4362 staticpro (&Qundefined_color);
4252 /* This is the end of symbol initialization. */ 4363 Qcancel_timer = intern ("cancel-timer");
4364 staticpro (&Qcancel_timer);
4253 4365
4254 Qhyper = intern ("hyper"); 4366 Qhyper = intern ("hyper");
4255 staticpro (&Qhyper); 4367 staticpro (&Qhyper);
@@ -4265,6 +4377,7 @@ syms_of_macfns ()
4265 staticpro (&Qcontrol); 4377 staticpro (&Qcontrol);
4266 Qshift = intern ("shift"); 4378 Qshift = intern ("shift");
4267 staticpro (&Qshift); 4379 staticpro (&Qshift);
4380 /* This is the end of symbol initialization. */
4268 4381
4269 /* Text property `display' should be nonsticky by default. */ 4382 /* Text property `display' should be nonsticky by default. */
4270 Vtext_property_default_nonsticky 4383 Vtext_property_default_nonsticky
@@ -4314,6 +4427,11 @@ or when you set the mouse color. */);
4314 doc: /* A string indicating the foreground color of the cursor box. */); 4427 doc: /* A string indicating the foreground color of the cursor box. */);
4315 Vx_cursor_fore_pixel = Qnil; 4428 Vx_cursor_fore_pixel = Qnil;
4316 4429
4430 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
4431 doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
4432Text larger than this is clipped. */);
4433 Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
4434
4317 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, 4435 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
4318 doc: /* Non-nil if no window manager is in use. 4436 doc: /* Non-nil if no window manager is in use.
4319Emacs doesn't try to figure this out; this is always nil 4437Emacs doesn't try to figure this out; this is always nil
@@ -4386,6 +4504,9 @@ Chinese, Japanese, and Korean. */);
4386 tip_frame = Qnil; 4504 tip_frame = Qnil;
4387 staticpro (&tip_frame); 4505 staticpro (&tip_frame);
4388 4506
4507 last_show_tip_args = Qnil;
4508 staticpro (&last_show_tip_args);
4509
4389#if 0 /* MAC_TODO */ 4510#if 0 /* MAC_TODO */
4390 defsubr (&Sx_file_dialog); 4511 defsubr (&Sx_file_dialog);
4391#endif 4512#endif
diff --git a/src/macgui.h b/src/macgui.h
index 2bb346e9d30..58081df52b4 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -57,16 +57,27 @@ typedef unsigned long Time;
57#undef init_process 57#undef init_process
58#define init_process emacs_init_process 58#define init_process emacs_init_process
59#undef INFINITY 59#undef INFINITY
60typedef struct OpaqueWindowPtr* Window;
61#else 60#else
62#include <QuickDraw.h> /* for WindowPtr */ 61#include <QuickDraw.h> /* for WindowPtr */
63#include <QDOffscreen.h> /* for GWorldPtr */ 62#include <QDOffscreen.h> /* for GWorldPtr */
64#include <Controls.h> /* for ControlHandle in xdisp.c */ 63#include <Controls.h> /* for ControlHandle in xdisp.c */
65typedef WindowPtr Window; 64#include <Gestalt.h>
66#endif 65#endif
67 66
68typedef GWorldPtr Pixmap; 67typedef GWorldPtr Pixmap;
69 68
69#if TARGET_API_MAC_CARBON
70typedef struct OpaqueWindowPtr *Window;
71#define Cursor ThemeCursor
72#define No_Cursor (-1)
73#else
74typedef WindowPtr Window;
75#define SetPortWindowPort(w) SetPort(w)
76#define Cursor CursHandle
77#define No_Cursor (0)
78extern CursPtr arrow_cursor;
79#endif
80
70#define FACE_DEFAULT (~0) 81#define FACE_DEFAULT (~0)
71 82
72 83
diff --git a/src/macmenu.c b/src/macmenu.c
index 06b1b16cf41..d205ee3b877 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -1424,7 +1424,8 @@ set_frame_menubar (f, first_time, deep_p)
1424 1424
1425 for (i = 0; i < previous_menu_items_used; i++) 1425 for (i = 0; i < previous_menu_items_used; i++)
1426 if (menu_items_used == i 1426 if (menu_items_used == i
1427 || (!Fequal (previous_items[i], XVECTOR (menu_items)->contents[i]))) 1427 || (NILP (Fequal (previous_items[i],
1428 XVECTOR (menu_items)->contents[i]))))
1428 break; 1429 break;
1429 if (i == menu_items_used && i == previous_menu_items_used && i != 0) 1430 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
1430 { 1431 {
@@ -1783,11 +1784,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
1783 pos.h = x; 1784 pos.h = x;
1784 pos.v = y; 1785 pos.v = y;
1785 1786
1786#if TARGET_API_MAC_CARBON 1787 SetPortWindowPort (FRAME_MAC_WINDOW (f));
1787 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
1788#else
1789 SetPort (FRAME_MAC_WINDOW (f));
1790#endif
1791 1788
1792 LocalToGlobal (&pos); 1789 LocalToGlobal (&pos);
1793 1790
@@ -1941,11 +1938,7 @@ mac_dialog (widget_value *wv)
1941 1938
1942 window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1); 1939 window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1);
1943 1940
1944#if TARGET_API_MAC_CARBON 1941 SetPortWindowPort (window_ptr);
1945 SetPort (GetWindowPort (window_ptr));
1946#else
1947 SetPort (window_ptr);
1948#endif
1949 1942
1950 TextFont (0); 1943 TextFont (0);
1951 /* Left and right margins in the dialog are 13 pixels each.*/ 1944 /* Left and right margins in the dialog are 13 pixels each.*/
@@ -1963,11 +1956,7 @@ mac_dialog (widget_value *wv)
1963 SizeWindow (window_ptr, dialog_width, 78, 0); 1956 SizeWindow (window_ptr, dialog_width, 78, 0);
1964 ShowWindow (window_ptr); 1957 ShowWindow (window_ptr);
1965 1958
1966#if TARGET_API_MAC_CARBON 1959 SetPortWindowPort (window_ptr);
1967 SetPort (GetWindowPort (window_ptr));
1968#else
1969 SetPort (window_ptr);
1970#endif
1971 1960
1972 TextFont (0); 1961 TextFont (0);
1973 1962
diff --git a/src/macterm.c b/src/macterm.c
index 44029032bbd..360dccd4f16 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -53,7 +53,6 @@ Boston, MA 02111-1307, USA. */
53#if defined (__MRC__) || (__MSL__ >= 0x6000) 53#if defined (__MRC__) || (__MSL__ >= 0x6000)
54#include <ControlDefinitions.h> 54#include <ControlDefinitions.h>
55#endif 55#endif
56#include <Gestalt.h>
57 56
58#if __profile__ 57#if __profile__
59#include <profiler.h> 58#include <profiler.h>
@@ -196,14 +195,6 @@ static Lisp_Object last_mouse_scroll_bar;
196 195
197static Time last_mouse_movement_time; 196static Time last_mouse_movement_time;
198 197
199enum mouse_tracking_type {
200 mouse_tracking_none,
201 mouse_tracking_mouse_movement,
202 mouse_tracking_scroll_bar
203};
204
205enum mouse_tracking_type mouse_tracking_in_progress = mouse_tracking_none;
206
207struct scroll_bar *tracked_scroll_bar = NULL; 198struct scroll_bar *tracked_scroll_bar = NULL;
208 199
209/* Incremented by XTread_socket whenever it really tries to read 200/* Incremented by XTread_socket whenever it really tries to read
@@ -294,7 +285,6 @@ void deactivate_scroll_bars (FRAME_PTR);
294 285
295static int is_emacs_window (WindowPtr); 286static int is_emacs_window (WindowPtr);
296 287
297extern int image_ascent (struct image *, struct face *);
298int x_bitmap_icon (struct frame *, Lisp_Object); 288int x_bitmap_icon (struct frame *, Lisp_Object);
299void x_make_frame_visible (struct frame *); 289void x_make_frame_visible (struct frame *);
300 290
@@ -311,7 +301,7 @@ XFreePixmap (display, pixmap)
311 Display *display; /* not used */ 301 Display *display; /* not used */
312 Pixmap pixmap; 302 Pixmap pixmap;
313{ 303{
314 DisposeGWorld (pixmap); 304 DisposeGWorld (pixmap);
315} 305}
316 306
317 307
@@ -365,11 +355,7 @@ XDrawLine (display, w, gc, x1, y1, x2, y2)
365 GC gc; 355 GC gc;
366 int x1, y1, x2, y2; 356 int x1, y1, x2, y2;
367{ 357{
368#if TARGET_API_MAC_CARBON 358 SetPortWindowPort (w);
369 SetPort (GetWindowPort (w));
370#else
371 SetPort (w);
372#endif
373 359
374 mac_set_colors (gc); 360 mac_set_colors (gc);
375 361
@@ -384,6 +370,10 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
384 GC gc; 370 GC gc;
385 int x1, y1, x2, y2; 371 int x1, y1, x2, y2;
386{ 372{
373 CGrafPtr old_port;
374 GDHandle old_gdh;
375
376 GetGWorld (&old_port, &old_gdh);
387 SetGWorld (p, NULL); 377 SetGWorld (p, NULL);
388 378
389 mac_set_colors (gc); 379 mac_set_colors (gc);
@@ -392,6 +382,8 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
392 MoveTo (x1, y1); 382 MoveTo (x1, y1);
393 LineTo (x2, y2); 383 LineTo (x2, y2);
394 UnlockPixels (GetGWorldPixMap (p)); 384 UnlockPixels (GetGWorldPixMap (p));
385
386 SetGWorld (old_port, old_gdh);
395} 387}
396 388
397/* Mac version of XClearArea. */ 389/* Mac version of XClearArea. */
@@ -411,11 +403,7 @@ XClearArea (display, w, x, y, width, height, exposures)
411 xgc.foreground = mwp->x_compatible.foreground_pixel; 403 xgc.foreground = mwp->x_compatible.foreground_pixel;
412 xgc.background = mwp->x_compatible.background_pixel; 404 xgc.background = mwp->x_compatible.background_pixel;
413 405
414#if TARGET_API_MAC_CARBON 406 SetPortWindowPort (w);
415 SetPort (GetWindowPort (w));
416#else
417 SetPort (w);
418#endif
419 407
420 mac_set_colors (&xgc); 408 mac_set_colors (&xgc);
421 SetRect (&r, x, y, x + width, y + height); 409 SetRect (&r, x, y, x + width, y + height);
@@ -436,11 +424,7 @@ XClearWindow (display, w)
436 xgc.foreground = mwp->x_compatible.foreground_pixel; 424 xgc.foreground = mwp->x_compatible.foreground_pixel;
437 xgc.background = mwp->x_compatible.background_pixel; 425 xgc.background = mwp->x_compatible.background_pixel;
438 426
439#if TARGET_API_MAC_CARBON 427 SetPortWindowPort (w);
440 SetPort (GetWindowPort (w));
441#else
442 SetPort (w);
443#endif
444 428
445 mac_set_colors (&xgc); 429 mac_set_colors (&xgc);
446 430
@@ -475,11 +459,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
475 bitmap.baseAddr = (char *)bits; 459 bitmap.baseAddr = (char *)bits;
476 SetRect (&(bitmap.bounds), 0, 0, width, height); 460 SetRect (&(bitmap.bounds), 0, 0, width, height);
477 461
478#if TARGET_API_MAC_CARBON 462 SetPortWindowPort (w);
479 SetPort (GetWindowPort (w));
480#else
481 SetPort (w);
482#endif
483 463
484 mac_set_colors (gc); 464 mac_set_colors (gc);
485 SetRect (&r, x, y, x + width, y + height); 465 SetRect (&r, x, y, x + width, y + height);
@@ -504,11 +484,7 @@ mac_set_clip_rectangle (display, w, r)
504 WindowPtr w; 484 WindowPtr w;
505 Rect *r; 485 Rect *r;
506{ 486{
507#if TARGET_API_MAC_CARBON 487 SetPortWindowPort (w);
508 SetPort (GetWindowPort (w));
509#else
510 SetPort (w);
511#endif
512 488
513 ClipRect (r); 489 ClipRect (r);
514} 490}
@@ -523,11 +499,7 @@ mac_reset_clipping (display, w)
523{ 499{
524 Rect r; 500 Rect r;
525 501
526#if TARGET_API_MAC_CARBON 502 SetPortWindowPort (w);
527 SetPort (GetWindowPort (w));
528#else
529 SetPort (w);
530#endif
531 503
532 SetRect (&r, -32767, -32767, 32767, 32767); 504 SetRect (&r, -32767, -32767, 32767, 32767);
533 ClipRect (&r); 505 ClipRect (&r);
@@ -596,11 +568,7 @@ XCreatePixmap (display, w, width, height, depth)
596 Rect r; 568 Rect r;
597 QDErr err; 569 QDErr err;
598 570
599#if TARGET_API_MAC_CARBON 571 SetPortWindowPort (w);
600 SetPort (GetWindowPort (w));
601#else
602 SetPort (w);
603#endif
604 572
605 SetRect (&r, 0, 0, width, height); 573 SetRect (&r, 0, 0, width, height);
606 err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0); 574 err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0);
@@ -621,11 +589,14 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
621{ 589{
622 Pixmap pixmap; 590 Pixmap pixmap;
623 BitMap bitmap; 591 BitMap bitmap;
592 CGrafPtr old_port;
593 GDHandle old_gdh;
624 594
625 pixmap = XCreatePixmap (display, w, width, height, depth); 595 pixmap = XCreatePixmap (display, w, width, height, depth);
626 if (pixmap == NULL) 596 if (pixmap == NULL)
627 return NULL; 597 return NULL;
628 598
599 GetGWorld (&old_port, &old_gdh);
629 SetGWorld (pixmap, NULL); 600 SetGWorld (pixmap, NULL);
630 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); 601 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
631 mac_set_forecolor (fg); 602 mac_set_forecolor (fg);
@@ -639,6 +610,7 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
639 &bitmap.bounds, &bitmap.bounds, srcCopy, 0); 610 &bitmap.bounds, &bitmap.bounds, srcCopy, 0);
640#endif /* not TARGET_API_MAC_CARBON */ 611#endif /* not TARGET_API_MAC_CARBON */
641 UnlockPixels (GetGWorldPixMap (pixmap)); 612 UnlockPixels (GetGWorldPixMap (pixmap));
613 SetGWorld (old_port, old_gdh);
642 mac_free_bitmap (&bitmap); 614 mac_free_bitmap (&bitmap);
643 615
644 return pixmap; 616 return pixmap;
@@ -657,11 +629,7 @@ XFillRectangle (display, w, gc, x, y, width, height)
657{ 629{
658 Rect r; 630 Rect r;
659 631
660#if TARGET_API_MAC_CARBON 632 SetPortWindowPort (w);
661 SetPort (GetWindowPort (w));
662#else
663 SetPort (w);
664#endif
665 633
666 mac_set_colors (gc); 634 mac_set_colors (gc);
667 SetRect (&r, x, y, x + width, y + height); 635 SetRect (&r, x, y, x + width, y + height);
@@ -678,8 +646,11 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
678 int x, y; 646 int x, y;
679 unsigned int width, height; 647 unsigned int width, height;
680{ 648{
649 CGrafPtr old_port;
650 GDHandle old_gdh;
681 Rect r; 651 Rect r;
682 652
653 GetGWorld (&old_port, &old_gdh);
683 SetGWorld (p, NULL); 654 SetGWorld (p, NULL);
684 mac_set_colors (gc); 655 mac_set_colors (gc);
685 SetRect (&r, x, y, x + width, y + height); 656 SetRect (&r, x, y, x + width, y + height);
@@ -687,6 +658,8 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
687 LockPixels (GetGWorldPixMap (p)); 658 LockPixels (GetGWorldPixMap (p));
688 PaintRect (&r); /* using foreground color of gc */ 659 PaintRect (&r); /* using foreground color of gc */
689 UnlockPixels (GetGWorldPixMap (p)); 660 UnlockPixels (GetGWorldPixMap (p));
661
662 SetGWorld (old_port, old_gdh);
690} 663}
691 664
692 665
@@ -702,11 +675,7 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
702{ 675{
703 Rect r; 676 Rect r;
704 677
705#if TARGET_API_MAC_CARBON 678 SetPortWindowPort (w);
706 SetPort (GetWindowPort (w));
707#else
708 SetPort (w);
709#endif
710 679
711 mac_set_colors (gc); 680 mac_set_colors (gc);
712 SetRect (&r, x, y, x + width + 1, y + height + 1); 681 SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -725,8 +694,11 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
725 int x, y; 694 int x, y;
726 unsigned int width, height; 695 unsigned int width, height;
727{ 696{
697 CGrafPtr old_port;
698 GDHandle old_gdh;
728 Rect r; 699 Rect r;
729 700
701 GetGWorld (&old_port, &old_gdh);
730 SetGWorld (p, NULL); 702 SetGWorld (p, NULL);
731 mac_set_colors (gc); 703 mac_set_colors (gc);
732 SetRect (&r, x, y, x + width + 1, y + height + 1); 704 SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -734,6 +706,8 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
734 LockPixels (GetGWorldPixMap (p)); 706 LockPixels (GetGWorldPixMap (p));
735 FrameRect (&r); /* using foreground color of gc */ 707 FrameRect (&r); /* using foreground color of gc */
736 UnlockPixels (GetGWorldPixMap (p)); 708 UnlockPixels (GetGWorldPixMap (p));
709
710 SetGWorld (old_port, old_gdh);
737} 711}
738 712
739 713
@@ -747,11 +721,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
747 char *buf; 721 char *buf;
748 int nchars, mode, bytes_per_char; 722 int nchars, mode, bytes_per_char;
749{ 723{
750#if TARGET_API_MAC_CARBON 724 SetPortWindowPort (w);
751 SetPort (GetWindowPort (w));
752#else
753 SetPort (w);
754#endif
755 725
756 mac_set_colors (gc); 726 mac_set_colors (gc);
757 727
@@ -842,11 +812,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
842{ 812{
843 Rect src_r, dest_r; 813 Rect src_r, dest_r;
844 814
845#if TARGET_API_MAC_CARBON 815 SetPortWindowPort (dest);
846 SetPort (GetWindowPort (dest));
847#else
848 SetPort (dest);
849#endif
850 816
851 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 817 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
852 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 818 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -882,11 +848,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
882{ 848{
883 Rect src_r, dest_r; 849 Rect src_r, dest_r;
884 850
885#if TARGET_API_MAC_CARBON 851 SetPortWindowPort (dest);
886 SetPort (GetWindowPort (dest));
887#else
888 SetPort (dest);
889#endif
890 852
891 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 853 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
892 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 854 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -946,7 +908,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
946 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 908 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
947 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 909 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
948 910
949 SetPort (GetWindowPort (w)); 911 SetPortWindowPort (w);
950 912
951 ForeColor (blackColor); 913 ForeColor (blackColor);
952 BackColor (whiteColor); 914 BackColor (whiteColor);
@@ -1004,8 +966,11 @@ mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
1004 unsigned int width, height; 966 unsigned int width, height;
1005 int dest_x, dest_y; 967 int dest_x, dest_y;
1006{ 968{
969 CGrafPtr old_port;
970 GDHandle old_gdh;
1007 Rect src_r, dest_r; 971 Rect src_r, dest_r;
1008 972
973 GetGWorld (&old_port, &old_gdh);
1009 SetGWorld (dest, NULL); 974 SetGWorld (dest, NULL);
1010 ForeColor (blackColor); 975 ForeColor (blackColor);
1011 BackColor (whiteColor); 976 BackColor (whiteColor);
@@ -1024,6 +989,8 @@ mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
1024#endif /* not TARGET_API_MAC_CARBON */ 989#endif /* not TARGET_API_MAC_CARBON */
1025 UnlockPixels (GetGWorldPixMap (dest)); 990 UnlockPixels (GetGWorldPixMap (dest));
1026 UnlockPixels (GetGWorldPixMap (src)); 991 UnlockPixels (GetGWorldPixMap (src));
992
993 SetGWorld (old_port, old_gdh);
1027} 994}
1028 995
1029 996
@@ -1037,8 +1004,11 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1037 unsigned int width, height; 1004 unsigned int width, height;
1038 int dest_x, dest_y; 1005 int dest_x, dest_y;
1039{ 1006{
1007 CGrafPtr old_port;
1008 GDHandle old_gdh;
1040 Rect src_r, dest_r; 1009 Rect src_r, dest_r;
1041 1010
1011 GetGWorld (&old_port, &old_gdh);
1042 SetGWorld (dest, NULL); 1012 SetGWorld (dest, NULL);
1043 ForeColor (blackColor); 1013 ForeColor (blackColor);
1044 BackColor (whiteColor); 1014 BackColor (whiteColor);
@@ -1059,6 +1029,8 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1059 UnlockPixels (GetGWorldPixMap (dest)); 1029 UnlockPixels (GetGWorldPixMap (dest));
1060 UnlockPixels (GetGWorldPixMap (mask)); 1030 UnlockPixels (GetGWorldPixMap (mask));
1061 UnlockPixels (GetGWorldPixMap (src)); 1031 UnlockPixels (GetGWorldPixMap (src));
1032
1033 SetGWorld (old_port, old_gdh);
1062} 1034}
1063 1035
1064 1036
@@ -1181,7 +1153,7 @@ x_flush (f)
1181 FOR_EACH_FRAME (rest, frame) 1153 FOR_EACH_FRAME (rest, frame)
1182 x_flush (XFRAME (frame)); 1154 x_flush (XFRAME (frame));
1183 } 1155 }
1184 else if (FRAME_X_P (f)) 1156 else if (FRAME_MAC_P (f))
1185 XFlush (FRAME_MAC_DISPLAY (f)); 1157 XFlush (FRAME_MAC_DISPLAY (f));
1186 UNBLOCK_INPUT; 1158 UNBLOCK_INPUT;
1187#endif /* TARGET_API_MAC_CARBON */ 1159#endif /* TARGET_API_MAC_CARBON */
@@ -1261,7 +1233,7 @@ x_update_window_begin (w)
1261 { 1233 {
1262 int i; 1234 int i;
1263 1235
1264 for (i = 0; i < w->desired_matrix->nrows; ++i) 1236 for (i = 0; i < w->desired_matrix->nrows; ++i)
1265 if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) 1237 if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))
1266 break; 1238 break;
1267 1239
@@ -1283,7 +1255,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1283 int x, y0, y1; 1255 int x, y0, y1;
1284{ 1256{
1285 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1257 struct frame *f = XFRAME (WINDOW_FRAME (w));
1286 1258
1287 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1259 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1288 f->output_data.mac->normal_gc, x, y0, x, y1); 1260 f->output_data.mac->normal_gc, x, y0, x, y1);
1289} 1261}
@@ -1356,11 +1328,7 @@ x_update_end (f)
1356 /* Reset the background color of Mac OS Window to that of the frame after 1328 /* Reset the background color of Mac OS Window to that of the frame after
1357 update so that it is used by Mac Toolbox to clear the update region before 1329 update so that it is used by Mac Toolbox to clear the update region before
1358 an update event is generated. */ 1330 an update event is generated. */
1359#if TARGET_API_MAC_CARBON 1331 SetPortWindowPort (FRAME_MAC_WINDOW (f));
1360 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
1361#else
1362 SetPort (FRAME_MAC_WINDOW (f));
1363#endif
1364 1332
1365 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); 1333 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1366 1334
@@ -1381,7 +1349,7 @@ static void
1381XTframe_up_to_date (f) 1349XTframe_up_to_date (f)
1382 struct frame *f; 1350 struct frame *f;
1383{ 1351{
1384 if (FRAME_X_P (f)) 1352 if (FRAME_MAC_P (f))
1385 { 1353 {
1386 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 1354 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
1387 1355
@@ -1525,7 +1493,7 @@ x_draw_fringe_bitmap (w, row, p)
1525 : face->foreground); 1493 : face->foreground);
1526 gcv.background = face->background; 1494 gcv.background = face->background;
1527 1495
1528 mac_draw_bitmap (display, window, &gcv, p->x, p->y, 1496 mac_draw_bitmap (display, window, &gcv, p->x, p->y,
1529 p->wd, p->h, bits, p->overlay_p); 1497 p->wd, p->h, bits, p->overlay_p);
1530 } 1498 }
1531 1499
@@ -1759,7 +1727,8 @@ static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap));
1759static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 1727static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
1760 int, int, int)); 1728 int, int, int));
1761static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, 1729static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
1762 int, int, int, int, Rect *)); 1730 int, int, int, int, int, int,
1731 Rect *));
1763static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 1732static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
1764 int, int, int, Rect *)); 1733 int, int, int, Rect *));
1765 1734
@@ -2483,9 +2452,10 @@ x_setup_relief_colors (s)
2483 2452
2484static void 2453static void
2485x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, 2454x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2486 raised_p, left_p, right_p, clip_rect) 2455 raised_p, top_p, bot_p, left_p, right_p, clip_rect)
2487 struct frame *f; 2456 struct frame *f;
2488 int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p; 2457 int left_x, top_y, right_x, bottom_y, width;
2458 int top_p, bot_p, left_p, right_p, raised_p;
2489 Rect *clip_rect; 2459 Rect *clip_rect;
2490{ 2460{
2491 Display *dpy = FRAME_MAC_DISPLAY (f); 2461 Display *dpy = FRAME_MAC_DISPLAY (f);
@@ -2500,10 +2470,11 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2500 mac_set_clip_rectangle (dpy, window, clip_rect); 2470 mac_set_clip_rectangle (dpy, window, clip_rect);
2501 2471
2502 /* Top. */ 2472 /* Top. */
2503 for (i = 0; i < width; ++i) 2473 if (top_p)
2504 XDrawLine (dpy, window, gc, 2474 for (i = 0; i < width; ++i)
2505 left_x + i * left_p, top_y + i, 2475 XDrawLine (dpy, window, gc,
2506 right_x - i * right_p, top_y + i); 2476 left_x + i * left_p, top_y + i,
2477 right_x - i * right_p, top_y + i);
2507 2478
2508 /* Left. */ 2479 /* Left. */
2509 if (left_p) 2480 if (left_p)
@@ -2520,10 +2491,11 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2520 clip_rect); 2491 clip_rect);
2521 2492
2522 /* Bottom. */ 2493 /* Bottom. */
2523 for (i = 0; i < width; ++i) 2494 if (bot_p)
2524 XDrawLine (dpy, window, gc, 2495 for (i = 0; i < width; ++i)
2525 left_x + i * left_p, bottom_y - i, 2496 XDrawLine (dpy, window, gc,
2526 right_x - i * right_p, bottom_y - i); 2497 left_x + i * left_p, bottom_y - i,
2498 right_x - i * right_p, bottom_y - i);
2527 2499
2528 /* Right. */ 2500 /* Right. */
2529 if (right_p) 2501 if (right_p)
@@ -2629,7 +2601,7 @@ x_draw_glyph_string_box (s)
2629 { 2601 {
2630 x_setup_relief_colors (s); 2602 x_setup_relief_colors (s);
2631 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, 2603 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
2632 width, raised_p, left_p, right_p, &clip_rect); 2604 width, raised_p, 1, 1, left_p, right_p, &clip_rect);
2633 } 2605 }
2634} 2606}
2635 2607
@@ -2640,21 +2612,22 @@ static void
2640x_draw_image_foreground (s) 2612x_draw_image_foreground (s)
2641 struct glyph_string *s; 2613 struct glyph_string *s;
2642{ 2614{
2643 int x; 2615 int x = s->x;
2644 int y = s->ybase - image_ascent (s->img, s->face); 2616 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2645 2617
2646 /* If first glyph of S has a left box line, start drawing it to the 2618 /* If first glyph of S has a left box line, start drawing it to the
2647 right of that line. */ 2619 right of that line. */
2648 if (s->face->box != FACE_NO_BOX 2620 if (s->face->box != FACE_NO_BOX
2649 && s->first_glyph->left_box_line_p) 2621 && s->first_glyph->left_box_line_p
2650 x = s->x + abs (s->face->box_line_width); 2622 && s->slice.x == 0)
2651 else 2623 x += abs (s->face->box_line_width);
2652 x = s->x;
2653 2624
2654 /* If there is a margin around the image, adjust x- and y-position 2625 /* If there is a margin around the image, adjust x- and y-position
2655 by that margin. */ 2626 by that margin. */
2656 x += s->img->hmargin; 2627 if (s->slice.x == 0)
2657 y += s->img->vmargin; 2628 x += s->img->hmargin;
2629 if (s->slice.y == 0)
2630 y += s->img->vmargin;
2658 2631
2659 if (s->img->pixmap) 2632 if (s->img->pixmap)
2660 { 2633 {
@@ -2667,11 +2640,12 @@ x_draw_image_foreground (s)
2667 CONVERT_TO_XRECT (clip_rect, nr); 2640 CONVERT_TO_XRECT (clip_rect, nr);
2668 image_rect.x = x; 2641 image_rect.x = x;
2669 image_rect.y = y; 2642 image_rect.y = y;
2670 image_rect.width = s->img->width; 2643 image_rect.width = s->slice.width;
2671 image_rect.height = s->img->height; 2644 image_rect.height = s->slice.height;
2672 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2645 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2673 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, 2646 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
2674 s->window, s->gc, r.x - x, r.y - y, 2647 s->window, s->gc,
2648 s->slice.x + r.x - x, s->slice.y + r.y - y,
2675 r.width, r.height, r.x, r.y); 2649 r.width, r.height, r.x, r.y);
2676 } 2650 }
2677 else 2651 else
@@ -2683,11 +2657,12 @@ x_draw_image_foreground (s)
2683 CONVERT_TO_XRECT (clip_rect, nr); 2657 CONVERT_TO_XRECT (clip_rect, nr);
2684 image_rect.x = x; 2658 image_rect.x = x;
2685 image_rect.y = y; 2659 image_rect.y = y;
2686 image_rect.width = s->img->width; 2660 image_rect.width = s->slice.width;
2687 image_rect.height = s->img->height; 2661 image_rect.height = s->slice.height;
2688 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2662 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2689 mac_copy_area (s->display, s->img->pixmap, s->window, s->gc, 2663 mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,
2690 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 2664 s->slice.x + r.x - x, s->slice.y + r.y - y,
2665 r.width, r.height, r.x, r.y);
2691 2666
2692 /* When the image has a mask, we can expect that at 2667 /* When the image has a mask, we can expect that at
2693 least part of a mouse highlight or a block cursor will 2668 least part of a mouse highlight or a block cursor will
@@ -2699,15 +2674,17 @@ x_draw_image_foreground (s)
2699 { 2674 {
2700 int r = s->img->relief; 2675 int r = s->img->relief;
2701 if (r < 0) r = -r; 2676 if (r < 0) r = -r;
2702 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r, 2677 mac_draw_rectangle (s->display, s->window, s->gc,
2703 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2678 x - r, y - r,
2679 s->slice.width + r*2 - 1,
2680 s->slice.height + r*2 - 1);
2704 } 2681 }
2705 } 2682 }
2706 } 2683 }
2707 else 2684 else
2708 /* Draw a rectangle if image could not be loaded. */ 2685 /* Draw a rectangle if image could not be loaded. */
2709 mac_draw_rectangle (s->display, s->window, s->gc, x, y, 2686 mac_draw_rectangle (s->display, s->window, s->gc, x, y,
2710 s->img->width - 1, s->img->height - 1); 2687 s->slice.width - 1, s->slice.height - 1);
2711} 2688}
2712 2689
2713 2690
@@ -2719,21 +2696,22 @@ x_draw_image_relief (s)
2719{ 2696{
2720 int x0, y0, x1, y1, thick, raised_p; 2697 int x0, y0, x1, y1, thick, raised_p;
2721 Rect r; 2698 Rect r;
2722 int x; 2699 int x = s->x;
2723 int y = s->ybase - image_ascent (s->img, s->face); 2700 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2724 2701
2725 /* If first glyph of S has a left box line, start drawing it to the 2702 /* If first glyph of S has a left box line, start drawing it to the
2726 right of that line. */ 2703 right of that line. */
2727 if (s->face->box != FACE_NO_BOX 2704 if (s->face->box != FACE_NO_BOX
2728 && s->first_glyph->left_box_line_p) 2705 && s->first_glyph->left_box_line_p
2729 x = s->x + abs (s->face->box_line_width); 2706 && s->slice.x == 0)
2730 else 2707 x += abs (s->face->box_line_width);
2731 x = s->x;
2732 2708
2733 /* If there is a margin around the image, adjust x- and y-position 2709 /* If there is a margin around the image, adjust x- and y-position
2734 by that margin. */ 2710 by that margin. */
2735 x += s->img->hmargin; 2711 if (s->slice.x == 0)
2736 y += s->img->vmargin; 2712 x += s->img->hmargin;
2713 if (s->slice.y == 0)
2714 y += s->img->vmargin;
2737 2715
2738 if (s->hl == DRAW_IMAGE_SUNKEN 2716 if (s->hl == DRAW_IMAGE_SUNKEN
2739 || s->hl == DRAW_IMAGE_RAISED) 2717 || s->hl == DRAW_IMAGE_RAISED)
@@ -2749,12 +2727,17 @@ x_draw_image_relief (s)
2749 2727
2750 x0 = x - thick; 2728 x0 = x - thick;
2751 y0 = y - thick; 2729 y0 = y - thick;
2752 x1 = x + s->img->width + thick - 1; 2730 x1 = x + s->slice.width + thick - 1;
2753 y1 = y + s->img->height + thick - 1; 2731 y1 = y + s->slice.height + thick - 1;
2754 2732
2755 x_setup_relief_colors (s); 2733 x_setup_relief_colors (s);
2756 get_glyph_string_clip_rect (s, &r); 2734 get_glyph_string_clip_rect (s, &r);
2757 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r); 2735 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
2736 s->slice.y == 0,
2737 s->slice.y + s->slice.height == s->img->height,
2738 s->slice.x == 0,
2739 s->slice.x + s->slice.width == s->img->width,
2740 &r);
2758} 2741}
2759 2742
2760 2743
@@ -2765,33 +2748,37 @@ x_draw_image_foreground_1 (s, pixmap)
2765 struct glyph_string *s; 2748 struct glyph_string *s;
2766 Pixmap pixmap; 2749 Pixmap pixmap;
2767{ 2750{
2768 int x; 2751 int x = 0;
2769 int y = s->ybase - s->y - image_ascent (s->img, s->face); 2752 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
2770 2753
2771 /* If first glyph of S has a left box line, start drawing it to the 2754 /* If first glyph of S has a left box line, start drawing it to the
2772 right of that line. */ 2755 right of that line. */
2773 if (s->face->box != FACE_NO_BOX 2756 if (s->face->box != FACE_NO_BOX
2774 && s->first_glyph->left_box_line_p) 2757 && s->first_glyph->left_box_line_p
2775 x = abs (s->face->box_line_width); 2758 && s->slice.x == 0)
2776 else 2759 x += abs (s->face->box_line_width);
2777 x = 0;
2778 2760
2779 /* If there is a margin around the image, adjust x- and y-position 2761 /* If there is a margin around the image, adjust x- and y-position
2780 by that margin. */ 2762 by that margin. */
2781 x += s->img->hmargin; 2763 if (s->slice.x == 0)
2782 y += s->img->vmargin; 2764 x += s->img->hmargin;
2765 if (s->slice.y == 0)
2766 y += s->img->vmargin;
2783 2767
2784 if (s->img->pixmap) 2768 if (s->img->pixmap)
2785 { 2769 {
2786 if (s->img->mask) 2770 if (s->img->mask)
2787 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap, 2771 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
2788 s->img->mask, pixmap, s->gc, 2772 s->img->mask, pixmap, s->gc,
2789 0, 0, s->img->width, s->img->height, 2773 s->slice.x, s->slice.y,
2774 s->slice.width, s->slice.height,
2790 x, y); 2775 x, y);
2791 else 2776 else
2792 { 2777 {
2793 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc, 2778 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
2794 0, 0, s->img->width, s->img->height, x, y); 2779 s->slice.x, s->slice.y,
2780 s->slice.width, s->slice.height,
2781 x, y);
2795 2782
2796 /* When the image has a mask, we can expect that at 2783 /* When the image has a mask, we can expect that at
2797 least part of a mouse highlight or a block cursor will 2784 least part of a mouse highlight or a block cursor will
@@ -2804,15 +2791,15 @@ x_draw_image_foreground_1 (s, pixmap)
2804 int r = s->img->relief; 2791 int r = s->img->relief;
2805 if (r < 0) r = -r; 2792 if (r < 0) r = -r;
2806 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r, 2793 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
2807 s->img->width + r*2 - 1, 2794 s->slice.width + r*2 - 1,
2808 s->img->height + r*2 - 1); 2795 s->slice.height + r*2 - 1);
2809 } 2796 }
2810 } 2797 }
2811 } 2798 }
2812 else 2799 else
2813 /* Draw a rectangle if image could not be loaded. */ 2800 /* Draw a rectangle if image could not be loaded. */
2814 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y, 2801 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
2815 s->img->width - 1, s->img->height - 1); 2802 s->slice.width - 1, s->slice.height - 1);
2816} 2803}
2817 2804
2818 2805
@@ -2869,19 +2856,21 @@ x_draw_image_glyph_string (s)
2869 taller than image or if image has a clip mask to reduce 2856 taller than image or if image has a clip mask to reduce
2870 flickering. */ 2857 flickering. */
2871 s->stippled_p = s->face->stipple != 0; 2858 s->stippled_p = s->face->stipple != 0;
2872 if (height > s->img->height 2859 if (height > s->slice.height
2873 || s->img->hmargin 2860 || s->img->hmargin
2874 || s->img->vmargin 2861 || s->img->vmargin
2875 || s->img->mask 2862 || s->img->mask
2876 || s->img->pixmap == 0 2863 || s->img->pixmap == 0
2877 || s->width != s->background_width) 2864 || s->width != s->background_width)
2878 { 2865 {
2879 if (box_line_hwidth && s->first_glyph->left_box_line_p) 2866 x = s->x;
2880 x = s->x + box_line_hwidth; 2867 if (s->first_glyph->left_box_line_p
2881 else 2868 && s->slice.x == 0)
2882 x = s->x; 2869 x += box_line_hwidth;
2883 2870
2884 y = s->y + box_line_vwidth; 2871 y = s->y;
2872 if (s->slice.y == 0)
2873 y += box_line_vwidth;
2885 2874
2886 if (s->img->mask) 2875 if (s->img->mask)
2887 { 2876 {
@@ -3695,11 +3684,7 @@ construct_mouse_click (result, event, f)
3695 3684
3696 mouseLoc = event->where; 3685 mouseLoc = event->where;
3697 3686
3698#if TARGET_API_MAC_CARBON 3687 SetPortWindowPort (FRAME_MAC_WINDOW (f));
3699 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
3700#else
3701 SetPort (FRAME_MAC_WINDOW (f));
3702#endif
3703 3688
3704 GlobalToLocal (&mouseLoc); 3689 GlobalToLocal (&mouseLoc);
3705 XSETINT (result->x, mouseLoc.h); 3690 XSETINT (result->x, mouseLoc.h);
@@ -3728,6 +3713,7 @@ note_mouse_movement (frame, pos)
3728 FRAME_PTR frame; 3713 FRAME_PTR frame;
3729 Point *pos; 3714 Point *pos;
3730{ 3715{
3716 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame);
3731#if TARGET_API_MAC_CARBON 3717#if TARGET_API_MAC_CARBON
3732 Rect r; 3718 Rect r;
3733#endif 3719#endif
@@ -3742,9 +3728,17 @@ note_mouse_movement (frame, pos)
3742 if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect)) 3728 if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect))
3743#endif 3729#endif
3744 { 3730 {
3745 frame->mouse_moved = 1; 3731 if (frame == dpyinfo->mouse_face_mouse_frame)
3746 last_mouse_scroll_bar = Qnil; 3732 /* This case corresponds to LeaveNotify in X11. */
3747 note_mouse_highlight (frame, -1, -1); 3733 {
3734 /* If we move outside the frame, then we're certainly no
3735 longer on any text in the frame. */
3736 clear_mouse_face (dpyinfo);
3737 dpyinfo->mouse_face_mouse_frame = 0;
3738 if (!dpyinfo->grabbed)
3739 rif->define_frame_cursor (frame,
3740 frame->output_data.mac->nontext_cursor);
3741 }
3748 } 3742 }
3749 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3743 /* Has the mouse moved off the glyph it was on at the last sighting? */
3750 else if (pos->h < last_mouse_glyph.left 3744 else if (pos->h < last_mouse_glyph.left
@@ -3842,7 +3836,7 @@ glyph_rect (f, x, y, rect)
3842 3836
3843 /* x is to the right of the last glyph in the row. */ 3837 /* x is to the right of the last glyph in the row. */
3844 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); 3838 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3845 /* Shouldn't this be a pixel value? 3839 /* Shouldn't this be a pixel value?
3846 WINDOW_RIGHT_EDGE_X (w) seems to be the right value. 3840 WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
3847 ++KFS */ 3841 ++KFS */
3848 rect->right = WINDOW_RIGHT_EDGE_COL (w); 3842 rect->right = WINDOW_RIGHT_EDGE_COL (w);
@@ -3892,6 +3886,23 @@ remember_mouse_glyph (f1, gx, gy)
3892} 3886}
3893 3887
3894 3888
3889static WindowPtr
3890mac_front_window ()
3891{
3892#if TARGET_API_MAC_CARBON
3893 return GetFrontWindowOfClass (kDocumentWindowClass, true);
3894#else
3895 WindowPtr front_window = FrontWindow ();
3896
3897 if (tip_window && front_window == tip_window)
3898 return GetNextWindow (front_window);
3899 else
3900 return front_window;
3901#endif
3902}
3903
3904#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
3905
3895/* Return the current position of the mouse. 3906/* Return the current position of the mouse.
3896 *fp should be a frame which indicates which display to ask about. 3907 *fp should be a frame which indicates which display to ask about.
3897 3908
@@ -3923,12 +3934,12 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3923{ 3934{
3924 Point mouse_pos; 3935 Point mouse_pos;
3925 int ignore1, ignore2; 3936 int ignore1, ignore2;
3926 WindowPtr wp = FrontWindow (); 3937 WindowPtr wp = mac_front_window ();
3927 struct frame *f; 3938 struct frame *f;
3928 Lisp_Object frame, tail; 3939 Lisp_Object frame, tail;
3929 3940
3930 if (is_emacs_window(wp)) 3941 if (is_emacs_window(wp))
3931 f = ((mac_output *) GetWRefCon (wp))->mFP; 3942 f = mac_window_to_frame (wp);
3932 3943
3933 BLOCK_INPUT; 3944 BLOCK_INPUT;
3934 3945
@@ -3942,11 +3953,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3942 3953
3943 last_mouse_scroll_bar = Qnil; 3954 last_mouse_scroll_bar = Qnil;
3944 3955
3945#if TARGET_API_MAC_CARBON 3956 SetPortWindowPort (wp);
3946 SetPort (GetWindowPort (wp));
3947#else
3948 SetPort (wp);
3949#endif
3950 3957
3951 GetMouse (&mouse_pos); 3958 GetMouse (&mouse_pos);
3952 3959
@@ -3984,7 +3991,7 @@ mac_handle_tool_bar_click (f, button_event)
3984 if (button_event->what == mouseDown) 3991 if (button_event->what == mouseDown)
3985 handle_tool_bar_click (f, x, y, 1, 0); 3992 handle_tool_bar_click (f, x, y, 1, 0);
3986 else 3993 else
3987 handle_tool_bar_click (f, x, y, 0, 3994 handle_tool_bar_click (f, x, y, 0,
3988 x_mac_to_emacs_modifiers (FRAME_MAC_DISPLAY_INFO (f), 3995 x_mac_to_emacs_modifiers (FRAME_MAC_DISPLAY_INFO (f),
3989 button_event->modifiers)); 3996 button_event->modifiers));
3990} 3997}
@@ -4441,6 +4448,8 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp)
4441 EventRecord *er; 4448 EventRecord *er;
4442 struct input_event *bufp; 4449 struct input_event *bufp;
4443{ 4450{
4451 int win_y, top_range;
4452
4444 if (! GC_WINDOWP (bar->window)) 4453 if (! GC_WINDOWP (bar->window))
4445 abort (); 4454 abort ();
4446 4455
@@ -4475,6 +4484,24 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp)
4475 bufp->part = scroll_bar_handle; 4484 bufp->part = scroll_bar_handle;
4476 break; 4485 break;
4477 } 4486 }
4487
4488 win_y = XINT (bufp->y) - XINT (bar->top);
4489 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height));
4490
4491 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
4492
4493 win_y -= 24;
4494
4495 if (! NILP (bar->dragging))
4496 win_y -= XINT (bar->dragging);
4497
4498 if (win_y < 0)
4499 win_y = 0;
4500 if (win_y > top_range)
4501 win_y = top_range;
4502
4503 XSETINT (bufp->x, win_y);
4504 XSETINT (bufp->y, top_range);
4478} 4505}
4479 4506
4480 4507
@@ -4524,16 +4551,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4524 unsigned long *time; 4551 unsigned long *time;
4525{ 4552{
4526 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 4553 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4527 WindowPtr wp = FrontWindow (); 4554 WindowPtr wp = mac_front_window ();
4528 Point mouse_pos; 4555 Point mouse_pos;
4529 struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; 4556 struct frame *f = mac_window_to_frame (wp);
4530 int win_y, top_range; 4557 int win_y, top_range;
4531 4558
4532#if TARGET_API_MAC_CARBON 4559 SetPortWindowPort (wp);
4533 SetPort (GetWindowPort (wp));
4534#else
4535 SetPort (wp);
4536#endif
4537 4560
4538 GetMouse (&mouse_pos); 4561 GetMouse (&mouse_pos);
4539 4562
@@ -4645,7 +4668,8 @@ x_draw_hollow_cursor (w, row)
4645 /* Compute the proper height and ascent of the rectangle, based 4668 /* Compute the proper height and ascent of the rectangle, based
4646 on the actual glyph. Using the full height of the row looks 4669 on the actual glyph. Using the full height of the row looks
4647 bad when there are tall images on that row. */ 4670 bad when there are tall images on that row. */
4648 h = max (FRAME_LINE_HEIGHT (f), cursor_glyph->ascent + cursor_glyph->descent); 4671 h = max (min (FRAME_LINE_HEIGHT (f), row->height),
4672 cursor_glyph->ascent + cursor_glyph->descent);
4649 if (h < row->height) 4673 if (h < row->height)
4650 y += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h; 4674 y += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h;
4651 h--; 4675 h--;
@@ -4759,7 +4783,11 @@ mac_define_frame_cursor (f, cursor)
4759 struct frame *f; 4783 struct frame *f;
4760 Cursor cursor; 4784 Cursor cursor;
4761{ 4785{
4762 /* MAC TODO */ 4786#if TARGET_API_MAC_CARBON
4787 SetThemeCursor (cursor);
4788#else
4789 SetCursor (*cursor);
4790#endif
4763} 4791}
4764 4792
4765 4793
@@ -4933,7 +4961,7 @@ x_new_font (f, fontname)
4933 if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0) 4961 if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
4934 { 4962 {
4935 int wid = FRAME_COLUMN_WIDTH (f); 4963 int wid = FRAME_COLUMN_WIDTH (f);
4936 FRAME_CONFIG_SCROLL_BAR_COLS (f) 4964 FRAME_CONFIG_SCROLL_BAR_COLS (f)
4937 = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid; 4965 = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
4938 } 4966 }
4939 else 4967 else
@@ -5027,11 +5055,7 @@ x_calc_absolute_position (f)
5027 GrafPtr savePort; 5055 GrafPtr savePort;
5028 GetPort (&savePort); 5056 GetPort (&savePort);
5029 5057
5030#if TARGET_API_MAC_CARBON 5058 SetPortWindowPort (FRAME_MAC_WINDOW (f));
5031 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
5032#else
5033 SetPort (FRAME_MAC_WINDOW (f));
5034#endif
5035 5059
5036#if TARGET_API_MAC_CARBON 5060#if TARGET_API_MAC_CARBON
5037 { 5061 {
@@ -5406,10 +5430,15 @@ x_free_frame_resources (f)
5406 struct frame *f; 5430 struct frame *f;
5407{ 5431{
5408 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 5432 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
5433 WindowPtr wp = FRAME_MAC_WINDOW (f);
5409 5434
5410 BLOCK_INPUT; 5435 BLOCK_INPUT;
5411 5436
5412 DisposeWindow (FRAME_MAC_WINDOW (f)); 5437 DisposeWindow (wp);
5438 if (wp == tip_window)
5439 /* Neither WaitNextEvent nor ReceiveNextEvent receives `window
5440 closed' event. So we reset tip_window here. */
5441 tip_window = NULL;
5413 5442
5414 free_frame_menubar (f); 5443 free_frame_menubar (f);
5415 5444
@@ -5826,7 +5855,7 @@ decode_mac_font_name (char *name, int size, short scriptcode)
5826 break; 5855 break;
5827 case smKorean: 5856 case smKorean:
5828 coding_system = Qeuc_kr; 5857 coding_system = Qeuc_kr;
5829 break; 5858 break;
5830 default: 5859 default:
5831 return; 5860 return;
5832 } 5861 }
@@ -6277,7 +6306,7 @@ mac_do_list_fonts (pattern, maxnames)
6277 if (fast_string_match (pattern_regex, fontname) >= 0) 6306 if (fast_string_match (pattern_regex, fontname) >= 0)
6278 { 6307 {
6279 font_list = Fcons (fontname, font_list); 6308 font_list = Fcons (fontname, font_list);
6280 6309
6281 n_fonts++; 6310 n_fonts++;
6282 if (maxnames > 0 && n_fonts >= maxnames) 6311 if (maxnames > 0 && n_fonts >= maxnames)
6283 break; 6312 break;
@@ -6933,6 +6962,11 @@ Lisp_Object drag_and_drop_file_list;
6933 6962
6934Point saved_menu_event_location; 6963Point saved_menu_event_location;
6935 6964
6965#if !TARGET_API_MAC_CARBON
6966/* Place holder for the default arrow cursor. */
6967CursPtr arrow_cursor;
6968#endif
6969
6936/* Apple Events */ 6970/* Apple Events */
6937static void init_required_apple_events (void); 6971static void init_required_apple_events (void);
6938static pascal OSErr 6972static pascal OSErr
@@ -6982,12 +7016,12 @@ static int
6982mac_get_emulated_btn ( UInt32 modifiers ) 7016mac_get_emulated_btn ( UInt32 modifiers )
6983{ 7017{
6984 int result = 0; 7018 int result = 0;
6985 if (Vmac_emulate_three_button_mouse != Qnil) { 7019 if (!NILP (Vmac_emulate_three_button_mouse)) {
6986 int cmdIs3 = (Vmac_emulate_three_button_mouse != Qreverse); 7020 int cmdIs3 = !EQ (Vmac_emulate_three_button_mouse, Qreverse);
6987 if (modifiers & controlKey) 7021 if (modifiers & controlKey)
6988 result = cmdIs3 ? 2 : 1; 7022 result = cmdIs3 ? 2 : 1;
6989 else if (modifiers & optionKey) 7023 else if (modifiers & optionKey)
6990 result = cmdIs3 ? 1 : 2; 7024 result = cmdIs3 ? 1 : 2;
6991 } 7025 }
6992 return result; 7026 return result;
6993} 7027}
@@ -7001,7 +7035,7 @@ mac_event_to_emacs_modifiers (EventRef eventRef)
7001 UInt32 mods = 0; 7035 UInt32 mods = 0;
7002 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, 7036 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
7003 sizeof (UInt32), NULL, &mods); 7037 sizeof (UInt32), NULL, &mods);
7004 if (Vmac_emulate_three_button_mouse != Qnil && 7038 if (!NILP (Vmac_emulate_three_button_mouse) &&
7005 GetEventClass(eventRef) == kEventClassMouse) 7039 GetEventClass(eventRef) == kEventClassMouse)
7006 { 7040 {
7007 mods &= ~(optionKey & cmdKey); 7041 mods &= ~(optionKey & cmdKey);
@@ -7020,7 +7054,7 @@ mac_get_mouse_btn (EventRef ref)
7020 switch (result) 7054 switch (result)
7021 { 7055 {
7022 case kEventMouseButtonPrimary: 7056 case kEventMouseButtonPrimary:
7023 if (Vmac_emulate_three_button_mouse == Qnil) 7057 if (NILP (Vmac_emulate_three_button_mouse))
7024 return 0; 7058 return 0;
7025 else { 7059 else {
7026 UInt32 mods = 0; 7060 UInt32 mods = 0;
@@ -7119,6 +7153,8 @@ do_init_managers (void)
7119 InitCursor (); 7153 InitCursor ();
7120 7154
7121#if !TARGET_API_MAC_CARBON 7155#if !TARGET_API_MAC_CARBON
7156 arrow_cursor = &qd.arrow;
7157
7122 /* set up some extra stack space for use by emacs */ 7158 /* set up some extra stack space for use by emacs */
7123 SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); 7159 SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
7124 7160
@@ -7147,8 +7183,12 @@ do_check_ram_size (void)
7147static void 7183static void
7148do_window_update (WindowPtr win) 7184do_window_update (WindowPtr win)
7149{ 7185{
7150 struct mac_output *mwp = (mac_output *) GetWRefCon (win); 7186 struct frame *f = mac_window_to_frame (win);
7151 struct frame *f = mwp->mFP; 7187
7188 if (win == tip_window)
7189 /* The tooltip has been drawn already. Avoid the
7190 SET_FRAME_GARBAGED below. */
7191 return;
7152 7192
7153 if (f) 7193 if (f)
7154 { 7194 {
@@ -7199,13 +7239,11 @@ is_emacs_window (WindowPtr win)
7199static void 7239static void
7200do_window_activate (WindowPtr win) 7240do_window_activate (WindowPtr win)
7201{ 7241{
7202 mac_output *mwp;
7203 struct frame *f; 7242 struct frame *f;
7204 7243
7205 if (is_emacs_window (win)) 7244 if (is_emacs_window (win))
7206 { 7245 {
7207 mwp = (mac_output *) GetWRefCon (win); 7246 f = mac_window_to_frame (win);
7208 f = mwp->mFP;
7209 7247
7210 if (f) 7248 if (f)
7211 { 7249 {
@@ -7218,13 +7256,11 @@ do_window_activate (WindowPtr win)
7218static void 7256static void
7219do_window_deactivate (WindowPtr win) 7257do_window_deactivate (WindowPtr win)
7220{ 7258{
7221 mac_output *mwp;
7222 struct frame *f; 7259 struct frame *f;
7223 7260
7224 if (is_emacs_window (win)) 7261 if (is_emacs_window (win))
7225 { 7262 {
7226 mwp = (mac_output *) GetWRefCon (win); 7263 f = mac_window_to_frame (win);
7227 f = mwp->mFP;
7228 7264
7229 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) 7265 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7230 { 7266 {
@@ -7238,14 +7274,12 @@ static void
7238do_app_resume () 7274do_app_resume ()
7239{ 7275{
7240 WindowPtr wp; 7276 WindowPtr wp;
7241 mac_output *mwp;
7242 struct frame *f; 7277 struct frame *f;
7243 7278
7244 wp = FrontWindow(); 7279 wp = mac_front_window ();
7245 if (is_emacs_window (wp)) 7280 if (is_emacs_window (wp))
7246 { 7281 {
7247 mwp = (mac_output *) GetWRefCon (wp); 7282 f = mac_window_to_frame (wp);
7248 f = mwp->mFP;
7249 7283
7250 if (f) 7284 if (f)
7251 { 7285 {
@@ -7262,14 +7296,12 @@ static void
7262do_app_suspend () 7296do_app_suspend ()
7263{ 7297{
7264 WindowPtr wp; 7298 WindowPtr wp;
7265 mac_output *mwp;
7266 struct frame *f; 7299 struct frame *f;
7267 7300
7268 wp = FrontWindow(); 7301 wp = mac_front_window ();
7269 if (is_emacs_window (wp)) 7302 if (is_emacs_window (wp))
7270 { 7303 {
7271 mwp = (mac_output *) GetWRefCon (wp); 7304 f = mac_window_to_frame (wp);
7272 f = mwp->mFP;
7273 7305
7274 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) 7306 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7275 { 7307 {
@@ -7284,67 +7316,38 @@ do_app_suspend ()
7284 7316
7285 7317
7286static void 7318static void
7287do_mouse_moved (Point mouse_pos) 7319do_mouse_moved (mouse_pos, f)
7320 Point mouse_pos;
7321 FRAME_PTR *f;
7288{ 7322{
7289 WindowPtr wp = FrontWindow (); 7323 WindowPtr wp = mac_front_window ();
7290 struct frame *f; 7324 struct x_display_info *dpyinfo;
7291 7325
7292 if (is_emacs_window (wp)) 7326 if (is_emacs_window (wp))
7293 { 7327 {
7294 f = ((mac_output *) GetWRefCon (wp))->mFP; 7328 *f = mac_window_to_frame (wp);
7329 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
7295 7330
7296#if TARGET_API_MAC_CARBON 7331 if (dpyinfo->mouse_face_hidden)
7297 SetPort (GetWindowPort (wp)); 7332 {
7298#else 7333 dpyinfo->mouse_face_hidden = 0;
7299 SetPort (wp); 7334 clear_mouse_face (dpyinfo);
7300#endif 7335 }
7301 7336
7302 GlobalToLocal (&mouse_pos); 7337 SetPortWindowPort (wp);
7303
7304 note_mouse_movement (f, &mouse_pos);
7305 }
7306}
7307 7338
7339 GlobalToLocal (&mouse_pos);
7308 7340
7309static void 7341 if (dpyinfo->grabbed && tracked_scroll_bar)
7310do_os_event (EventRecord *erp) 7342 x_scroll_bar_note_movement (tracked_scroll_bar,
7311{ 7343 mouse_pos.v
7312 switch((erp->message >> 24) & 0x000000FF) 7344 - XINT (tracked_scroll_bar->top),
7313 { 7345 TickCount() * (1000 / 60));
7314 case suspendResumeMessage:
7315 if((erp->message & resumeFlag) == 1)
7316 do_app_resume ();
7317 else 7346 else
7318 do_app_suspend (); 7347 note_mouse_movement (*f, &mouse_pos);
7319 break;
7320
7321 case mouseMovedMessage:
7322 do_mouse_moved (erp->where);
7323 break;
7324 } 7348 }
7325} 7349}
7326 7350
7327static void
7328do_events (EventRecord *erp)
7329{
7330 switch (erp->what)
7331 {
7332 case updateEvt:
7333 do_window_update ((WindowPtr) erp->message);
7334 break;
7335
7336 case osEvt:
7337 do_os_event (erp);
7338 break;
7339
7340 case activateEvt:
7341 if ((erp->modifiers & activeFlag) != 0)
7342 do_window_activate ((WindowPtr) erp->message);
7343 else
7344 do_window_deactivate ((WindowPtr) erp->message);
7345 break;
7346 }
7347}
7348 7351
7349static void 7352static void
7350do_apple_menu (SInt16 menu_item) 7353do_apple_menu (SInt16 menu_item)
@@ -7382,8 +7385,7 @@ do_menu_choice (SInt32 menu_choice)
7382 7385
7383 default: 7386 default:
7384 { 7387 {
7385 WindowPtr wp = FrontWindow (); 7388 struct frame *f = mac_window_to_frame (mac_front_window ());
7386 struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
7387 MenuHandle menu = GetMenuHandle (menu_id); 7389 MenuHandle menu = GetMenuHandle (menu_id);
7388 if (menu) 7390 if (menu)
7389 { 7391 {
@@ -7408,8 +7410,7 @@ do_grow_window (WindowPtr w, EventRecord *e)
7408 long grow_size; 7410 long grow_size;
7409 Rect limit_rect; 7411 Rect limit_rect;
7410 int rows, columns; 7412 int rows, columns;
7411 mac_output *mwp = (mac_output *) GetWRefCon (w); 7413 struct frame *f = mac_window_to_frame (w);
7412 struct frame *f = mwp->mFP;
7413 7414
7414 SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); 7415 SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);
7415 7416
@@ -7438,16 +7439,11 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7438 Rect zoom_rect, port_rect; 7439 Rect zoom_rect, port_rect;
7439 Point top_left; 7440 Point top_left;
7440 int w_title_height, columns, rows, width, height, dummy, x, y; 7441 int w_title_height, columns, rows, width, height, dummy, x, y;
7441 mac_output *mwp = (mac_output *) GetWRefCon (w); 7442 struct frame *f = mac_window_to_frame (w);
7442 struct frame *f = mwp->mFP;
7443 7443
7444 GetPort (&save_port); 7444 GetPort (&save_port);
7445 7445
7446#if TARGET_API_MAC_CARBON 7446 SetPortWindowPort (w);
7447 SetPort (GetWindowPort (w));
7448#else
7449 SetPort (w);
7450#endif
7451 7447
7452 /* Clear window to avoid flicker. */ 7448 /* Clear window to avoid flicker. */
7453#if TARGET_API_MAC_CARBON 7449#if TARGET_API_MAC_CARBON
@@ -7500,7 +7496,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7500 } 7496 }
7501#endif /* not TARGET_API_MAC_CARBON */ 7497#endif /* not TARGET_API_MAC_CARBON */
7502 7498
7503 ZoomWindow (w, zoom_in_or_out, w == FrontWindow ()); 7499 ZoomWindow (w, zoom_in_or_out, w == mac_front_window ());
7504 7500
7505 /* retrieve window size and update application values */ 7501 /* retrieve window size and update application values */
7506#if TARGET_API_MAC_CARBON 7502#if TARGET_API_MAC_CARBON
@@ -7510,7 +7506,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7510#endif 7506#endif
7511 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); 7507 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top);
7512 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); 7508 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left);
7513 x_set_window_size (mwp->mFP, 0, columns, rows); 7509 x_set_window_size (f, 0, columns, rows);
7514 7510
7515 SetPort (save_port); 7511 SetPort (save_port);
7516} 7512}
@@ -7841,8 +7837,8 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
7841 { 7837 {
7842 struct input_event event; 7838 struct input_event event;
7843 Lisp_Object frame; 7839 Lisp_Object frame;
7844 struct frame *f = ((mac_output *) GetWRefCon(window))->mFP; 7840 struct frame *f = mac_window_to_frame (window);
7845 SetPort (GetWindowPort (window)); 7841 SetPortWindowPort (window);
7846 GlobalToLocal (&mouse); 7842 GlobalToLocal (&mouse);
7847 7843
7848 event.kind = DRAG_N_DROP_EVENT; 7844 event.kind = DRAG_N_DROP_EVENT;
@@ -8016,26 +8012,26 @@ keycode_to_xkeysym (int keyCode, int *xKeySym)
8016/* Emacs calls this whenever it wants to read an input event from the 8012/* Emacs calls this whenever it wants to read an input event from the
8017 user. */ 8013 user. */
8018int 8014int
8019XTread_socket (int sd, int expected, struct input_event *hold_quit) 8015XTread_socket (sd, expected, hold_quit)
8016 int sd, expected;
8017 struct input_event *hold_quit;
8020{ 8018{
8021 struct input_event inev; 8019 struct input_event inev;
8022 int count = 0; 8020 int count = 0;
8023#if USE_CARBON_EVENTS 8021#if USE_CARBON_EVENTS
8024 OSStatus rneResult;
8025 EventRef eventRef; 8022 EventRef eventRef;
8026 EventMouseButton mouseBtn; 8023 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
8024#else
8025 EventMask event_mask;
8027#endif 8026#endif
8028 EventRecord er; 8027 EventRecord er;
8029 int the_modifiers; 8028 struct mac_display_info *dpyinfo = &one_mac_display_info;
8030 EventMask event_mask;
8031 8029
8032#if 0
8033 if (interrupt_input_blocked) 8030 if (interrupt_input_blocked)
8034 { 8031 {
8035 interrupt_input_pending = 1; 8032 interrupt_input_pending = 1;
8036 return -1; 8033 return -1;
8037 } 8034 }
8038#endif
8039 8035
8040 interrupt_input_pending = 0; 8036 interrupt_input_pending = 0;
8041 BLOCK_INPUT; 8037 BLOCK_INPUT;
@@ -8057,26 +8053,33 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit)
8057 if (terminate_flag) 8053 if (terminate_flag)
8058 Fkill_emacs (make_number (1)); 8054 Fkill_emacs (make_number (1));
8059 8055
8060 /* It is necessary to set this (additional) argument slot of an 8056#if !USE_CARBON_EVENTS
8061 event to nil because keyboard.c protects incompletely processed
8062 event from being garbage collected by placing them in the
8063 kbd_buffer_gcpro vector. */
8064 EVENT_INIT (inev);
8065 inev.kind = NO_EVENT;
8066 inev.arg = Qnil;
8067
8068 event_mask = everyEvent; 8057 event_mask = everyEvent;
8069 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) 8058 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
8070 event_mask -= highLevelEventMask; 8059 event_mask -= highLevelEventMask;
8071 8060
8072#if USE_CARBON_EVENTS 8061 while (WaitNextEvent (event_mask, &er,
8073 rneResult = ReceiveNextEvent (0, NULL, 8062 (expected ? app_sleep_time : 0L), NULL))
8074 expected 8063#else
8075 ? TicksToEventTime (app_sleep_time) 8064 while (!ReceiveNextEvent (0, NULL,
8076 : 0, 8065 (expected ? TicksToEventTime (app_sleep_time) : 0),
8077 kEventRemoveFromQueue, &eventRef); 8066 kEventRemoveFromQueue, &eventRef))
8078 if (!rneResult) 8067#endif /* !USE_CARBON_EVENTS */
8079 { 8068 {
8069 int do_help = 0;
8070 struct frame *f;
8071
8072 expected = 0;
8073
8074 /* It is necessary to set this (additional) argument slot of an
8075 event to nil because keyboard.c protects incompletely
8076 processed event from being garbage collected by placing them
8077 in the kbd_buffer_gcpro vector. */
8078 EVENT_INIT (inev);
8079 inev.kind = NO_EVENT;
8080 inev.arg = Qnil;
8081
8082#if USE_CARBON_EVENTS
8080 /* Handle new events */ 8083 /* Handle new events */
8081 if (!mac_convert_event_ref (eventRef, &er)) 8084 if (!mac_convert_event_ref (eventRef, &er))
8082 switch (GetEventClass (eventRef)) 8085 switch (GetEventClass (eventRef))
@@ -8086,13 +8089,12 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit)
8086 { 8089 {
8087 SInt32 delta; 8090 SInt32 delta;
8088 Point point; 8091 Point point;
8089 WindowPtr window_ptr = FrontNonFloatingWindow (); 8092 WindowPtr window_ptr = mac_front_window ();
8090 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); 8093
8091 if (!IsValidWindowPtr (window_ptr)) 8094 if (!IsValidWindowPtr (window_ptr))
8092 { 8095 {
8093 SysBeep(1); 8096 SysBeep(1);
8094 UNBLOCK_INPUT; 8097 break;
8095 return 0;
8096 } 8098 }
8097 8099
8098 GetEventParameter(eventRef, kEventParamMouseWheelDelta, 8100 GetEventParameter(eventRef, kEventParamMouseWheelDelta,
@@ -8103,457 +8105,557 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit)
8103 NULL, &point); 8105 NULL, &point);
8104 inev.kind = WHEEL_EVENT; 8106 inev.kind = WHEEL_EVENT;
8105 inev.code = 0; 8107 inev.code = 0;
8106 inev.modifiers = (mac_event_to_emacs_modifiers(eventRef) 8108 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8107 | ((delta < 0) ? down_modifier 8109 | ((delta < 0) ? down_modifier
8108 : up_modifier)); 8110 : up_modifier));
8109 SetPort (GetWindowPort (window_ptr)); 8111 SetPortWindowPort (window_ptr);
8110 GlobalToLocal (&point); 8112 GlobalToLocal (&point);
8111 XSETINT (inev.x, point.h); 8113 XSETINT (inev.x, point.h);
8112 XSETINT (inev.y, point.v); 8114 XSETINT (inev.y, point.v);
8113 XSETFRAME (inev.frame_or_window, mwp->mFP); 8115 XSETFRAME (inev.frame_or_window,
8116 mac_window_to_frame (window_ptr));
8114 inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); 8117 inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
8115 } 8118 }
8116 else 8119 else
8117 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); 8120 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8118 8121
8119 break; 8122 break;
8120 default: 8123 default:
8121 /* Send the event to the appropriate receiver. */ 8124 /* Send the event to the appropriate receiver. */
8122 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); 8125 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8123 } 8126 }
8124 else 8127 else
8125#else
8126 if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL))
8127#endif /* USE_CARBON_EVENTS */ 8128#endif /* USE_CARBON_EVENTS */
8128 switch (er.what) 8129 switch (er.what)
8129 {
8130 case mouseDown:
8131 case mouseUp:
8132 { 8130 {
8133 WindowPtr window_ptr = FrontWindow (); 8131 case mouseDown:
8134 SInt16 part_code; 8132 case mouseUp:
8133 {
8134 WindowPtr window_ptr;
8135 SInt16 part_code;
8136 int tool_bar_p = 0;
8137
8138 if (dpyinfo->grabbed && last_mouse_frame
8139 && FRAME_LIVE_P (last_mouse_frame))
8140 {
8141 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
8142 part_code = inContent;
8143 }
8144 else
8145 {
8146 window_ptr = FrontWindow ();
8147 if (tip_window && window_ptr == tip_window)
8148 {
8149 HideWindow (tip_window);
8150 window_ptr = FrontWindow ();
8151 }
8135 8152
8136#if USE_CARBON_EVENTS 8153#if USE_CARBON_EVENTS
8137 /* This is needed to send mouse events like aqua window buttons 8154 /* This is needed to send mouse events like aqua
8138 to the correct handler. */ 8155 window buttons to the correct handler. */
8139 if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) { 8156 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8140 break; 8157 != eventNotHandledErr)
8141 } 8158 break;
8142 8159
8143 if (!is_emacs_window(window_ptr)) 8160 if (!is_emacs_window (window_ptr))
8144 break; 8161 break;
8145#endif 8162#endif
8163 part_code = FindWindow (er.where, &window_ptr);
8164 }
8165
8166 switch (part_code)
8167 {
8168 case inMenuBar:
8169 if (er.what == mouseDown)
8170 {
8171 f = mac_window_to_frame (mac_front_window ());
8172 saved_menu_event_location = er.where;
8173 inev.kind = MENU_BAR_ACTIVATE_EVENT;
8174 XSETFRAME (inev.frame_or_window, f);
8175 }
8176 break;
8146 8177
8147 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar 8178 case inContent:
8148 && er.what == mouseUp) 8179 if (window_ptr != mac_front_window ())
8149 { 8180 SelectWindow (window_ptr);
8150 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); 8181 else
8151 Point mouse_loc = er.where; 8182 {
8183 SInt16 control_part_code;
8184 ControlHandle ch;
8185 Point mouse_loc = er.where;
8152 8186
8153 /* Convert to local coordinates of new window. */ 8187 f = mac_window_to_frame (window_ptr);
8188 /* convert to local coordinates of new window */
8189 SetPortWindowPort (window_ptr);
8190
8191 GlobalToLocal (&mouse_loc);
8154#if TARGET_API_MAC_CARBON 8192#if TARGET_API_MAC_CARBON
8155 SetPort (GetWindowPort (window_ptr)); 8193 ch = FindControlUnderMouse (mouse_loc, window_ptr,
8194 &control_part_code);
8156#else 8195#else
8157 SetPort (window_ptr); 8196 control_part_code = FindControl (mouse_loc, window_ptr,
8197 &ch);
8158#endif 8198#endif
8159 8199
8160 GlobalToLocal (&mouse_loc);
8161
8162#if USE_CARBON_EVENTS 8200#if USE_CARBON_EVENTS
8163 inev.code = mac_get_mouse_btn (eventRef); 8201 inev.code = mac_get_mouse_btn (eventRef);
8202 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8164#else 8203#else
8165 inev.code = mac_get_emulate_btn (er.modifiers); 8204 inev.code = mac_get_emulated_btn (er.modifiers);
8205 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8166#endif 8206#endif
8167 inev.kind = SCROLL_BAR_CLICK_EVENT; 8207 XSETINT (inev.x, mouse_loc.h);
8168 inev.frame_or_window = tracked_scroll_bar->window; 8208 XSETINT (inev.y, mouse_loc.v);
8169 inev.part = scroll_bar_handle; 8209 inev.timestamp = er.when * (1000 / 60);
8170#if USE_CARBON_EVENTS 8210 /* ticks to milliseconds */
8171 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 8211
8212 if (dpyinfo->grabbed && tracked_scroll_bar
8213#if TARGET_API_MAC_CARBON
8214 || ch != 0
8172#else 8215#else
8173 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 8216 || control_part_code != 0
8174#endif 8217#endif
8175 inev.modifiers |= up_modifier; 8218 )
8176 inev.timestamp = er.when * (1000 / 60); 8219 {
8177 /* ticks to milliseconds */ 8220 struct scroll_bar *bar;
8221
8222 if (dpyinfo->grabbed && tracked_scroll_bar)
8223 {
8224 bar = tracked_scroll_bar;
8225 control_part_code = kControlIndicatorPart;
8226 }
8227 else
8228 bar = (struct scroll_bar *) GetControlReference (ch);
8229 x_scroll_bar_handle_click (bar, control_part_code,
8230 &er, &inev);
8231 if (er.what == mouseDown
8232 && control_part_code == kControlIndicatorPart)
8233 tracked_scroll_bar = bar;
8234 else
8235 tracked_scroll_bar = NULL;
8236 }
8237 else
8238 {
8239 Lisp_Object window;
8240 int x = mouse_loc.h;
8241 int y = mouse_loc.v;
8242
8243 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
8244 if (EQ (window, f->tool_bar_window))
8245 {
8246 if (er.what == mouseDown)
8247 handle_tool_bar_click (f, x, y, 1, 0);
8248 else
8249 handle_tool_bar_click (f, x, y, 0,
8250 inev.modifiers);
8251 tool_bar_p = 1;
8252 }
8253 else
8254 {
8255 XSETFRAME (inev.frame_or_window, f);
8256 inev.kind = MOUSE_CLICK_EVENT;
8257 }
8258 }
8259
8260 if (er.what == mouseDown)
8261 {
8262 dpyinfo->grabbed |= (1 << inev.code);
8263 last_mouse_frame = f;
8264 /* Ignore any mouse motion that happened
8265 before this event; any subsequent
8266 mouse-movement Emacs events should reflect
8267 only motion after the ButtonPress. */
8268 if (f != 0)
8269 f->mouse_moved = 0;
8270
8271 if (!tool_bar_p)
8272 last_tool_bar_item = -1;
8273 }
8274 else
8275 {
8276 if (dpyinfo->grabbed & (1 << inev.code) == 0)
8277 /* If a button is released though it was not
8278 previously pressed, that would be because
8279 of multi-button emulation. */
8280 dpyinfo->grabbed = 0;
8281 else
8282 dpyinfo->grabbed &= ~(1 << inev.code);
8283 }
8284
8285 switch (er.what)
8286 {
8287 case mouseDown:
8288 inev.modifiers |= down_modifier;
8289 break;
8290 case mouseUp:
8291 inev.modifiers |= up_modifier;
8292 break;
8293 }
8294 }
8295 break;
8178 8296
8179 XSETINT (inev.x, tracked_scroll_bar->left + 2); 8297 case inDrag:
8180 XSETINT (inev.y, mouse_loc.v - 24); 8298#if TARGET_API_MAC_CARBON
8181 tracked_scroll_bar->dragging = Qnil; 8299 if (er.what == mouseDown)
8182 mouse_tracking_in_progress = mouse_tracking_none; 8300 {
8183 tracked_scroll_bar = NULL; 8301 BitMap bm;
8184 break;
8185 }
8186 8302
8187 part_code = FindWindow (er.where, &window_ptr); 8303 GetQDGlobalsScreenBits (&bm);
8304 DragWindow (window_ptr, er.where, &bm.bounds);
8305 }
8306#else /* not TARGET_API_MAC_CARBON */
8307 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
8308#endif /* not TARGET_API_MAC_CARBON */
8309 break;
8188 8310
8189 switch (part_code) 8311 case inGoAway:
8190 { 8312 if (TrackGoAway (window_ptr, er.where))
8191 case inMenuBar: 8313 {
8192 if (er.what == mouseDown) 8314 inev.kind = DELETE_WINDOW_EVENT;
8193 { 8315 XSETFRAME (inev.frame_or_window,
8194 struct frame *f = ((mac_output *) 8316 mac_window_to_frame (window_ptr));
8195 GetWRefCon (FrontWindow ()))->mFP; 8317 }
8196 saved_menu_event_location = er.where; 8318 break;
8197 inev.kind = MENU_BAR_ACTIVATE_EVENT;
8198 XSETFRAME (inev.frame_or_window, f);
8199 }
8200 break;
8201 8319
8202 case inContent: 8320 /* window resize handling added --ben */
8203 if (window_ptr != FrontWindow ()) 8321 case inGrow:
8204 SelectWindow (window_ptr); 8322 if (er.what == mouseDown)
8205 else 8323 {
8206 { 8324 do_grow_window(window_ptr, &er);
8207 SInt16 control_part_code; 8325 break;
8208 ControlHandle ch; 8326 }
8209 struct mac_output *mwp = (mac_output *)
8210 GetWRefCon (window_ptr);
8211 Point mouse_loc = er.where;
8212
8213 /* convert to local coordinates of new window */
8214#if TARGET_API_MAC_CARBON
8215 SetPort (GetWindowPort (window_ptr));
8216#else
8217 SetPort (window_ptr);
8218#endif
8219 8327
8220 GlobalToLocal (&mouse_loc); 8328 /* window zoom handling added --ben */
8221#if TARGET_API_MAC_CARBON 8329 case inZoomIn:
8222 ch = FindControlUnderMouse (mouse_loc, window_ptr, 8330 case inZoomOut:
8223 &control_part_code); 8331 if (TrackBox (window_ptr, er.where, part_code))
8224#else 8332 do_zoom_window (window_ptr, part_code);
8225 control_part_code = FindControl (mouse_loc, window_ptr, &ch); 8333 break;
8226#endif
8227 8334
8228#if USE_CARBON_EVENTS 8335 default:
8229 inev.code = mac_get_mouse_btn (eventRef); 8336 break;
8230#else 8337 }
8231 inev.code = mac_get_emulate_btn (er.modifiers); 8338 }
8232#endif 8339 break;
8233 XSETINT (inev.x, mouse_loc.h);
8234 XSETINT (inev.y, mouse_loc.v);
8235 inev.timestamp = er.when * (1000 / 60);
8236 /* ticks to milliseconds */
8237 8340
8238#if TARGET_API_MAC_CARBON 8341 case updateEvt:
8239 if (ch != 0)
8240#else
8241 if (control_part_code != 0)
8242#endif
8243 {
8244 struct scroll_bar *bar = (struct scroll_bar *)
8245 GetControlReference (ch);
8246 x_scroll_bar_handle_click (bar, control_part_code, &er,
8247 &inev);
8248 if (er.what == mouseDown
8249 && control_part_code == kControlIndicatorPart)
8250 {
8251 mouse_tracking_in_progress
8252 = mouse_tracking_scroll_bar;
8253 tracked_scroll_bar = bar;
8254 }
8255 else
8256 {
8257 mouse_tracking_in_progress = mouse_tracking_none;
8258 tracked_scroll_bar = NULL;
8259 }
8260 }
8261 else
8262 {
8263 Lisp_Object window;
8264
8265 XSETFRAME (inev.frame_or_window, mwp->mFP);
8266 if (er.what == mouseDown)
8267 mouse_tracking_in_progress
8268 = mouse_tracking_mouse_movement;
8269 else
8270 mouse_tracking_in_progress = mouse_tracking_none;
8271 window = window_from_coordinates (mwp->mFP, inev.x, inev.y, 0, 0, 0, 1);
8272
8273 if (EQ (window, mwp->mFP->tool_bar_window))
8274 {
8275 if (er.what == mouseDown)
8276 handle_tool_bar_click (mwp->mFP, inev.x, inev.y, 1, 0);
8277 else
8278 handle_tool_bar_click (mwp->mFP, inev.x, inev.y, 0,
8279#if USE_CARBON_EVENTS 8342#if USE_CARBON_EVENTS
8280 mac_event_to_emacs_modifiers (eventRef) 8343 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8281#else 8344 != eventNotHandledErr)
8282 er.modifiers 8345 break;
8283#endif 8346#endif
8284 ); 8347 do_window_update ((WindowPtr) er.message);
8285 break; 8348 break;
8286 }
8287 else
8288 inev.kind = MOUSE_CLICK_EVENT;
8289 }
8290 8349
8350 case osEvt:
8291#if USE_CARBON_EVENTS 8351#if USE_CARBON_EVENTS
8292 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 8352 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8293#else 8353 != eventNotHandledErr)
8294 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 8354 break;
8295#endif 8355#endif
8296 8356 switch ((er.message >> 24) & 0x000000FF)
8297 switch (er.what) 8357 {
8298 { 8358 case suspendResumeMessage:
8299 case mouseDown: 8359 if ((er.message & resumeFlag) == 1)
8300 inev.modifiers |= down_modifier; 8360 do_app_resume ();
8301 break; 8361 else
8302 case mouseUp: 8362 do_app_suspend ();
8303 inev.modifiers |= up_modifier;
8304 break;
8305 }
8306 }
8307 break;
8308
8309 case inDrag:
8310#if TARGET_API_MAC_CARBON
8311 if (er.what == mouseDown)
8312 {
8313 BitMap bm;
8314
8315 GetQDGlobalsScreenBits (&bm);
8316 DragWindow (window_ptr, er.where, &bm.bounds);
8317 }
8318#else /* not TARGET_API_MAC_CARBON */
8319 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
8320#endif /* not TARGET_API_MAC_CARBON */
8321 break; 8363 break;
8322 8364
8323 case inGoAway: 8365 case mouseMovedMessage:
8324 if (TrackGoAway (window_ptr, er.where)) 8366 previous_help_echo_string = help_echo_string;
8325 { 8367 help_echo_string = help_echo_object = help_echo_window = Qnil;
8326 inev.kind = DELETE_WINDOW_EVENT; 8368 help_echo_pos = -1;
8327 XSETFRAME (inev.frame_or_window,
8328 ((mac_output *) GetWRefCon (window_ptr))->mFP);
8329 }
8330 break;
8331 8369
8332 /* window resize handling added --ben */ 8370 do_mouse_moved (er.where, &f);
8333 case inGrow:
8334 if (er.what == mouseDown)
8335 {
8336 do_grow_window(window_ptr, &er);
8337 break;
8338 }
8339
8340 /* window zoom handling added --ben */
8341 case inZoomIn:
8342 case inZoomOut:
8343 if (TrackBox (window_ptr, er.where, part_code))
8344 do_zoom_window (window_ptr, part_code);
8345 break;
8346 8371
8347 default: 8372 /* If the contents of the global variable
8373 help_echo_string has changed, generate a
8374 HELP_EVENT. */
8375 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
8376 do_help = 1;
8348 break; 8377 break;
8349 } 8378 }
8350 } 8379 break;
8351 break; 8380
8381 case activateEvt:
8382 {
8383 WindowPtr window_ptr = (WindowPtr) er.message;
8352 8384
8353 case updateEvt:
8354 case osEvt:
8355 case activateEvt:
8356#if USE_CARBON_EVENTS 8385#if USE_CARBON_EVENTS
8357 if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) 8386 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8387 != eventNotHandledErr)
8388 break;
8358#endif 8389#endif
8359 do_events (&er); 8390 if (window_ptr == tip_window)
8360 break; 8391 {
8392 HideWindow (tip_window);
8393 break;
8394 }
8361 8395
8362 case keyDown: 8396 if ((er.modifiers & activeFlag) != 0)
8363 case autoKey: 8397 {
8364 { 8398 Point mouse_loc = er.where;
8365 int keycode = (er.message & keyCodeMask) >> 8;
8366 int xkeysym;
8367 8399
8368#if USE_CARBON_EVENTS 8400 do_window_activate (window_ptr);
8369 /* When using Carbon Events, we need to pass raw keyboard events
8370 to the TSM ourselves. If TSM handles it, it will pass back
8371 noErr, otherwise it will pass back "eventNotHandledErr" and
8372 we can process it normally. */
8373 if ((!NILP (Vmac_pass_command_to_system)
8374 || !(er.modifiers & cmdKey))
8375 && (!NILP (Vmac_pass_control_to_system)
8376 || !(er.modifiers & controlKey)))
8377 {
8378 OSStatus err;
8379 err = SendEventToEventTarget (eventRef,
8380 GetEventDispatcherTarget ());
8381 if (err != eventNotHandledErr)
8382 break;
8383 }
8384#endif
8385 8401
8386 if (!IsValidWindowPtr (FrontNonFloatingWindow ())) 8402 SetPortWindowPort (window_ptr);
8387 { 8403 GlobalToLocal (&mouse_loc);
8388 SysBeep (1); 8404 /* activateEvt counts as mouse movement,
8389 UNBLOCK_INPUT; 8405 so update things that depend on mouse position. */
8390 return 0; 8406 note_mouse_movement (mac_window_to_frame (window_ptr),
8391 } 8407 &mouse_loc);
8408 }
8409 else
8410 {
8411 do_window_deactivate (window_ptr);
8392 8412
8393 ObscureCursor (); 8413 f = mac_window_to_frame (window_ptr);
8414 if (f == dpyinfo->mouse_face_mouse_frame)
8415 {
8416 /* If we move outside the frame, then we're
8417 certainly no longer on any text in the
8418 frame. */
8419 clear_mouse_face (dpyinfo);
8420 dpyinfo->mouse_face_mouse_frame = 0;
8421 }
8394 8422
8395 if (keycode_to_xkeysym (keycode, &xkeysym)) 8423 /* Generate a nil HELP_EVENT to cancel a help-echo.
8396 { 8424 Do it only if there's something to cancel.
8397 inev.code = 0xff00 | xkeysym; 8425 Otherwise, the startup message is cleared when the
8398 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 8426 mouse leaves the frame. */
8399 } 8427 if (any_help_event_p)
8400 else 8428 do_help = -1;
8401 { 8429 }
8402 if (er.modifiers & (controlKey | 8430 }
8403 (NILP (Vmac_command_key_is_meta) ? optionKey 8431 break;
8404 : cmdKey)))
8405 {
8406 /* This code comes from Keyboard Resource, Appendix
8407 C of IM - Text. This is necessary since shift is
8408 ignored in KCHR table translation when option or
8409 command is pressed. It also does not translate
8410 correctly control-shift chars like C-% so mask off
8411 shift here also */
8412 int new_modifiers = er.modifiers & 0xe600;
8413 /* mask off option and command */
8414 int new_keycode = keycode | new_modifiers;
8415 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8416 unsigned long some_state = 0;
8417 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8418 &some_state) & 0xff;
8419 }
8420 else
8421 inev.code = er.message & charCodeMask;
8422 inev.kind = ASCII_KEYSTROKE_EVENT;
8423 }
8424 }
8425 8432
8426 /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil, 8433 case keyDown:
8427 convert non-ASCII characters typed at the Mac keyboard 8434 case autoKey:
8428 (presumed to be in the Mac Roman encoding) to iso-latin-1
8429 encoding before they are passed to Emacs. This enables the
8430 Mac keyboard to be used to enter non-ASCII iso-latin-1
8431 characters directly. */
8432 if (mac_keyboard_text_encoding != kTextEncodingMacRoman
8433 && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
8434 { 8435 {
8435 static TECObjectRef converter = NULL; 8436 int keycode = (er.message & keyCodeMask) >> 8;
8436 OSStatus the_err = noErr; 8437 int xkeysym;
8437 OSStatus convert_status = noErr;
8438 8438
8439 if (converter == NULL) 8439#if USE_CARBON_EVENTS
8440 /* When using Carbon Events, we need to pass raw keyboard
8441 events to the TSM ourselves. If TSM handles it, it
8442 will pass back noErr, otherwise it will pass back
8443 "eventNotHandledErr" and we can process it
8444 normally. */
8445 if ((!NILP (Vmac_pass_command_to_system)
8446 || !(er.modifiers & cmdKey))
8447 && (!NILP (Vmac_pass_control_to_system)
8448 || !(er.modifiers & controlKey)))
8449 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8450 != eventNotHandledErr)
8451 break;
8452#endif
8453
8454#if TARGET_API_MAC_CARBON
8455 if (!IsValidWindowPtr (mac_front_window ()))
8440 { 8456 {
8441 the_err = TECCreateConverter (&converter, 8457 SysBeep (1);
8442 kTextEncodingMacRoman, 8458 break;
8443 mac_keyboard_text_encoding);
8444 current_mac_keyboard_text_encoding
8445 = mac_keyboard_text_encoding;
8446 } 8459 }
8447 else if (mac_keyboard_text_encoding 8460#endif
8448 != current_mac_keyboard_text_encoding) 8461
8462 ObscureCursor ();
8463
8464 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
8449 { 8465 {
8450 /* Free the converter for the current encoding before 8466 clear_mouse_face (dpyinfo);
8451 creating a new one. */ 8467 dpyinfo->mouse_face_hidden = 1;
8452 TECDisposeConverter (converter);
8453 the_err = TECCreateConverter (&converter,
8454 kTextEncodingMacRoman,
8455 mac_keyboard_text_encoding);
8456 current_mac_keyboard_text_encoding
8457 = mac_keyboard_text_encoding;
8458 } 8468 }
8459 8469
8460 if (the_err == noErr) 8470 if (keycode_to_xkeysym (keycode, &xkeysym))
8461 { 8471 {
8462 unsigned char ch = inev.code; 8472 inev.code = 0xff00 | xkeysym;
8463 ByteCount actual_input_length, actual_output_length; 8473 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
8464 unsigned char outch; 8474 }
8465 8475 else
8466 convert_status = TECConvertText (converter, &ch, 1, 8476 {
8467 &actual_input_length, 8477 if (er.modifiers & (controlKey |
8468 &outch, 1, 8478 (NILP (Vmac_command_key_is_meta) ? optionKey
8469 &actual_output_length); 8479 : cmdKey)))
8470 if (convert_status == noErr 8480 {
8471 && actual_input_length == 1 8481 /* This code comes from Keyboard Resource,
8472 && actual_output_length == 1) 8482 Appendix C of IM - Text. This is necessary
8473 inev.code = outch; 8483 since shift is ignored in KCHR table
8484 translation when option or command is pressed.
8485 It also does not translate correctly
8486 control-shift chars like C-% so mask off shift
8487 here also */
8488 int new_modifiers = er.modifiers & 0xe600;
8489 /* mask off option and command */
8490 int new_keycode = keycode | new_modifiers;
8491 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8492 unsigned long some_state = 0;
8493 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8494 &some_state) & 0xff;
8495 }
8496 else
8497 inev.code = er.message & charCodeMask;
8498 inev.kind = ASCII_KEYSTROKE_EVENT;
8474 } 8499 }
8475 } 8500 }
8476 8501
8502 /* If variable mac-convert-keyboard-input-to-latin-1 is
8503 non-nil, convert non-ASCII characters typed at the Mac
8504 keyboard (presumed to be in the Mac Roman encoding) to
8505 iso-latin-1 encoding before they are passed to Emacs.
8506 This enables the Mac keyboard to be used to enter
8507 non-ASCII iso-latin-1 characters directly. */
8508 if (mac_keyboard_text_encoding != kTextEncodingMacRoman
8509 && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
8510 {
8511 static TECObjectRef converter = NULL;
8512 OSStatus the_err = noErr;
8513 OSStatus convert_status = noErr;
8514
8515 if (converter == NULL)
8516 {
8517 the_err = TECCreateConverter (&converter,
8518 kTextEncodingMacRoman,
8519 mac_keyboard_text_encoding);
8520 current_mac_keyboard_text_encoding
8521 = mac_keyboard_text_encoding;
8522 }
8523 else if (mac_keyboard_text_encoding
8524 != current_mac_keyboard_text_encoding)
8525 {
8526 /* Free the converter for the current encoding
8527 before creating a new one. */
8528 TECDisposeConverter (converter);
8529 the_err = TECCreateConverter (&converter,
8530 kTextEncodingMacRoman,
8531 mac_keyboard_text_encoding);
8532 current_mac_keyboard_text_encoding
8533 = mac_keyboard_text_encoding;
8534 }
8535
8536 if (the_err == noErr)
8537 {
8538 unsigned char ch = inev.code;
8539 ByteCount actual_input_length, actual_output_length;
8540 unsigned char outch;
8541
8542 convert_status = TECConvertText (converter, &ch, 1,
8543 &actual_input_length,
8544 &outch, 1,
8545 &actual_output_length);
8546 if (convert_status == noErr
8547 && actual_input_length == 1
8548 && actual_output_length == 1)
8549 inev.code = outch;
8550 }
8551 }
8552
8477#if USE_CARBON_EVENTS 8553#if USE_CARBON_EVENTS
8478 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 8554 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8479#else 8555#else
8480 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 8556 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8481#endif 8557#endif
8558 XSETFRAME (inev.frame_or_window,
8559 mac_window_to_frame (mac_front_window ()));
8560 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8561 break;
8482 8562
8483 { 8563 case kHighLevelEvent:
8484 mac_output *mwp 8564 drag_and_drop_file_list = Qnil;
8485 = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
8486 XSETFRAME (inev.frame_or_window, mwp->mFP);
8487 }
8488
8489 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8490 break;
8491
8492 case kHighLevelEvent:
8493 drag_and_drop_file_list = Qnil;
8494 8565
8495 AEProcessAppleEvent(&er); 8566 AEProcessAppleEvent(&er);
8496 8567
8497 /* Build a DRAG_N_DROP_EVENT type event as is done in 8568 /* Build a DRAG_N_DROP_EVENT type event as is done in
8498 constuct_drag_n_drop in w32term.c. */ 8569 constuct_drag_n_drop in w32term.c. */
8499 if (!NILP (drag_and_drop_file_list)) 8570 if (!NILP (drag_and_drop_file_list))
8500 { 8571 {
8501 struct frame *f = NULL; 8572 struct frame *f = NULL;
8502 WindowPtr wp; 8573 WindowPtr wp;
8503 Lisp_Object frame; 8574 Lisp_Object frame;
8504 8575
8505 wp = FrontNonFloatingWindow (); 8576 wp = mac_front_window ();
8506 8577
8507 if (!wp) 8578 if (!wp)
8508 { 8579 {
8509 struct frame *f = XFRAME (XCAR (Vframe_list)); 8580 struct frame *f = XFRAME (XCAR (Vframe_list));
8510 CollapseWindow (FRAME_MAC_WINDOW (f), false); 8581 CollapseWindow (FRAME_MAC_WINDOW (f), false);
8511 wp = FrontNonFloatingWindow (); 8582 wp = mac_front_window ();
8512 } 8583 }
8513 8584
8514 if (wp && is_emacs_window(wp)) 8585 if (wp && is_emacs_window (wp))
8515 f = ((mac_output *) GetWRefCon (wp))->mFP; 8586 f = mac_window_to_frame (wp);
8516 8587
8517 inev.kind = DRAG_N_DROP_EVENT; 8588 inev.kind = DRAG_N_DROP_EVENT;
8518 inev.code = 0; 8589 inev.code = 0;
8519 inev.timestamp = er.when * (1000 / 60); 8590 inev.timestamp = er.when * (1000 / 60);
8520 /* ticks to milliseconds */ 8591 /* ticks to milliseconds */
8521#if USE_CARBON_EVENTS 8592#if USE_CARBON_EVENTS
8522 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 8593 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8523#else 8594#else
8524 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 8595 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8525#endif 8596#endif
8526 8597
8527 XSETINT (inev.x, 0); 8598 XSETINT (inev.x, 0);
8528 XSETINT (inev.y, 0); 8599 XSETINT (inev.y, 0);
8529 8600
8530 XSETFRAME (frame, f); 8601 XSETFRAME (frame, f);
8531 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); 8602 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
8532 8603
8533 /* Regardless of whether Emacs was suspended or in the 8604 /* Regardless of whether Emacs was suspended or in the
8534 foreground, ask it to redraw its entire screen. 8605 foreground, ask it to redraw its entire screen.
8535 Otherwise parts of the screen can be left in an 8606 Otherwise parts of the screen can be left in an
8536 inconsistent state. */ 8607 inconsistent state. */
8537 if (wp) 8608 if (wp)
8538#if TARGET_API_MAC_CARBON 8609#if TARGET_API_MAC_CARBON
8539 { 8610 {
8540 Rect r; 8611 Rect r;
8541 8612
8542 GetWindowPortBounds (wp, &r); 8613 GetWindowPortBounds (wp, &r);
8543 InvalWindowRect (wp, &r); 8614 InvalWindowRect (wp, &r);
8544 } 8615 }
8545#else /* not TARGET_API_MAC_CARBON */ 8616#else /* not TARGET_API_MAC_CARBON */
8546 InvalRect (&(wp->portRect)); 8617 InvalRect (&(wp->portRect));
8547#endif /* not TARGET_API_MAC_CARBON */ 8618#endif /* not TARGET_API_MAC_CARBON */
8548 } 8619 }
8549 default: 8620 default:
8550 break; 8621 break;
8551 } 8622 }
8552#if USE_CARBON_EVENTS 8623#if USE_CARBON_EVENTS
8553 ReleaseEvent (eventRef); 8624 ReleaseEvent (eventRef);
8554 }
8555#endif 8625#endif
8556 8626
8627 if (inev.kind != NO_EVENT)
8628 {
8629 kbd_buffer_store_event_hold (&inev, hold_quit);
8630 count++;
8631 }
8632
8633 if (do_help
8634 && !(hold_quit && hold_quit->kind != NO_EVENT))
8635 {
8636 Lisp_Object frame;
8637
8638 if (f)
8639 XSETFRAME (frame, f);
8640 else
8641 frame = Qnil;
8642
8643 if (do_help > 0)
8644 {
8645 any_help_event_p = 1;
8646 gen_help_event (help_echo_string, frame, help_echo_window,
8647 help_echo_object, help_echo_pos);
8648 }
8649 else
8650 {
8651 help_echo_string = Qnil;
8652 gen_help_event (Qnil, frame, Qnil, Qnil, 0);
8653 }
8654 count++;
8655 }
8656
8657 }
8658
8557 /* If the focus was just given to an autoraising frame, 8659 /* If the focus was just given to an autoraising frame,
8558 raise it now. */ 8660 raise it now. */
8559 /* ??? This ought to be able to handle more than one such frame. */ 8661 /* ??? This ought to be able to handle more than one such frame. */
@@ -8567,58 +8669,6 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit)
8567 check_alarm (); /* simulate the handling of a SIGALRM */ 8669 check_alarm (); /* simulate the handling of a SIGALRM */
8568#endif 8670#endif
8569 8671
8570 {
8571 static Point old_mouse_pos = { -1, -1 };
8572
8573 if (app_is_suspended)
8574 {
8575 old_mouse_pos.h = -1;
8576 old_mouse_pos.v = -1;
8577 }
8578 else
8579 {
8580 Point mouse_pos;
8581 WindowPtr wp;
8582 struct frame *f;
8583 Lisp_Object bar;
8584 struct scroll_bar *sb;
8585
8586 wp = FrontWindow ();
8587 if (is_emacs_window (wp))
8588 {
8589 f = ((mac_output *) GetWRefCon (wp))->mFP;
8590
8591#if TARGET_API_MAC_CARBON
8592 SetPort (GetWindowPort (wp));
8593#else
8594 SetPort (wp);
8595#endif
8596
8597 GetMouse (&mouse_pos);
8598
8599 if (!EqualPt (mouse_pos, old_mouse_pos))
8600 {
8601 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
8602 && tracked_scroll_bar)
8603 x_scroll_bar_note_movement (tracked_scroll_bar,
8604 mouse_pos.v
8605 - XINT (tracked_scroll_bar->top),
8606 TickCount() * (1000 / 60));
8607 else
8608 note_mouse_movement (f, &mouse_pos);
8609
8610 old_mouse_pos = mouse_pos;
8611 }
8612 }
8613 }
8614 }
8615
8616 if (inev.kind != NO_EVENT)
8617 {
8618 kbd_buffer_store_event_hold (&inev, hold_quit);
8619 count++;
8620 }
8621
8622 UNBLOCK_INPUT; 8672 UNBLOCK_INPUT;
8623 return count; 8673 return count;
8624} 8674}
@@ -8647,7 +8697,7 @@ __convert_from_newlines (unsigned char * p, size_t * n)
8647 ROWS Macintosh window, using font with name FONTNAME and size 8697 ROWS Macintosh window, using font with name FONTNAME and size
8648 FONTSIZE. */ 8698 FONTSIZE. */
8649void 8699void
8650NewMacWindow (FRAME_PTR fp) 8700make_mac_frame (FRAME_PTR fp)
8651{ 8701{
8652 mac_output *mwp; 8702 mac_output *mwp;
8653#if TARGET_API_MAC_CARBON 8703#if TARGET_API_MAC_CARBON
@@ -8666,33 +8716,52 @@ NewMacWindow (FRAME_PTR fp)
8666 making_terminal_window = 0; 8716 making_terminal_window = 0;
8667 } 8717 }
8668 else 8718 else
8669 if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) 8719 {
8670 abort (); 8720#if TARGET_API_MAC_CARBON
8721 Rect r;
8722
8723 SetRect (&r, 0, 0, 1, 1);
8724 if (CreateNewWindow (kDocumentWindowClass,
8725 kWindowStandardDocumentAttributes
8726 /* | kWindowToolbarButtonAttribute */,
8727 &r, &mwp->mWP) != noErr)
8728#else
8729 if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
8730#endif
8731 abort ();
8732 }
8671 8733
8672 SetWRefCon (mwp->mWP, (long) mwp); 8734 SetWRefCon (mwp->mWP, (long) mwp);
8673 /* so that update events can find this mac_output struct */ 8735 /* so that update events can find this mac_output struct */
8674 mwp->mFP = fp; /* point back to emacs frame */ 8736 mwp->mFP = fp; /* point back to emacs frame */
8675 8737
8676#if TARGET_API_MAC_CARBON 8738 SetPortWindowPort (mwp->mWP);
8677 SetPort (GetWindowPort (mwp->mWP));
8678#else
8679 SetPort (mwp->mWP);
8680#endif
8681
8682 mwp->fontset = -1;
8683 8739
8684 SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false); 8740 SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);
8685 ShowWindow (mwp->mWP);
8686
8687} 8741}
8688 8742
8689 8743
8690void 8744void
8691make_mac_frame (struct frame *f) 8745make_mac_terminal_frame (struct frame *f)
8692{ 8746{
8693 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; 8747 Lisp_Object frame;
8694 8748
8695 NewMacWindow(f); 8749 XSETFRAME (frame, f);
8750
8751 f->output_method = output_mac;
8752 f->output_data.mac = (struct mac_output *)
8753 xmalloc (sizeof (struct mac_output));
8754 bzero (f->output_data.mac, sizeof (struct mac_output));
8755
8756 XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
8757
8758 FRAME_COLS (f) = 96;
8759 FRAME_LINES (f) = 4;
8760
8761 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8762 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8763
8764 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
8696 8765
8697 f->output_data.mac->cursor_pixel = 0; 8766 f->output_data.mac->cursor_pixel = 0;
8698 f->output_data.mac->border_pixel = 0x00ff00; 8767 f->output_data.mac->border_pixel = 0x00ff00;
@@ -8700,8 +8769,6 @@ make_mac_frame (struct frame *f)
8700 f->output_data.mac->cursor_foreground_pixel = 0x0000ff; 8769 f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
8701 8770
8702 FRAME_FONTSET (f) = -1; 8771 FRAME_FONTSET (f) = -1;
8703 f->output_data.mac->scroll_bar_foreground_pixel = -1;
8704 f->output_data.mac->scroll_bar_background_pixel = -1;
8705 f->output_data.mac->explicit_parent = 0; 8772 f->output_data.mac->explicit_parent = 0;
8706 f->left_pos = 4; 8773 f->left_pos = 4;
8707 f->top_pos = 4; 8774 f->top_pos = 4;
@@ -8709,37 +8776,11 @@ make_mac_frame (struct frame *f)
8709 8776
8710 f->internal_border_width = 0; 8777 f->internal_border_width = 0;
8711 8778
8712 f->output_method = output_mac;
8713
8714 f->auto_raise = 1; 8779 f->auto_raise = 1;
8715 f->auto_lower = 1; 8780 f->auto_lower = 1;
8716 8781
8717 f->new_text_cols = 0; 8782 f->new_text_cols = 0;
8718 f->new_text_lines = 0; 8783 f->new_text_lines = 0;
8719}
8720
8721void
8722make_mac_terminal_frame (struct frame *f)
8723{
8724 Lisp_Object frame;
8725
8726 XSETFRAME (frame, f);
8727
8728 f->output_method = output_mac;
8729 f->output_data.mac = (struct mac_output *)
8730 xmalloc (sizeof (struct mac_output));
8731 bzero (f->output_data.mac, sizeof (struct mac_output));
8732 FRAME_FONTSET (f) = -1;
8733 f->output_data.mac->scroll_bar_foreground_pixel = -1;
8734 f->output_data.mac->scroll_bar_background_pixel = -1;
8735
8736 XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
8737
8738 FRAME_COLS (f) = 96;
8739 FRAME_LINES (f) = 4;
8740
8741 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8742 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8743 8784
8744 make_mac_frame (f); 8785 make_mac_frame (f);
8745 8786
@@ -8757,6 +8798,8 @@ make_mac_terminal_frame (struct frame *f)
8757 Fmodify_frame_parameters (frame, 8798 Fmodify_frame_parameters (frame,
8758 Fcons (Fcons (Qbackground_color, 8799 Fcons (Fcons (Qbackground_color,
8759 build_string ("white")), Qnil)); 8800 build_string ("white")), Qnil));
8801
8802 ShowWindow (f->output_data.mac->mWP);
8760} 8803}
8761 8804
8762 8805
@@ -8797,10 +8840,16 @@ mac_initialize_display_info ()
8797 dpyinfo->resx = 75.0; 8840 dpyinfo->resx = 75.0;
8798 dpyinfo->resy = 75.0; 8841 dpyinfo->resy = 75.0;
8799 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); 8842 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType);
8843#ifdef MAC_OSX
8844 /* HasDepth returns true if it is possible to have a 32 bit display,
8845 but this may not be what is actually used. Mac OSX can do better. */
8846 dpyinfo->n_planes = CGDisplayBitsPerPixel (CGMainDisplayID ());
8847#else
8800 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) 8848 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1)
8801 if (HasDepth (main_device_handle, dpyinfo->n_planes, 8849 if (HasDepth (main_device_handle, dpyinfo->n_planes,
8802 gdDevType, dpyinfo->color_p)) 8850 gdDevType, dpyinfo->color_p))
8803 break; 8851 break;
8852#endif
8804 dpyinfo->height = (**main_device_handle).gdRect.bottom; 8853 dpyinfo->height = (**main_device_handle).gdRect.bottom;
8805 dpyinfo->width = (**main_device_handle).gdRect.right; 8854 dpyinfo->width = (**main_device_handle).gdRect.right;
8806 dpyinfo->grabbed = 0; 8855 dpyinfo->grabbed = 0;
@@ -8811,6 +8860,8 @@ mac_initialize_display_info ()
8811 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 8860 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
8812 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; 8861 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
8813 dpyinfo->mouse_face_window = Qnil; 8862 dpyinfo->mouse_face_window = Qnil;
8863 dpyinfo->mouse_face_overlay = Qnil;
8864 dpyinfo->mouse_face_hidden = 0;
8814} 8865}
8815 8866
8816struct mac_display_info * 8867struct mac_display_info *
@@ -8959,22 +9010,23 @@ mac_check_for_quit_char ()
8959 mac_determine_quit_char_modifiers (); 9010 mac_determine_quit_char_modifiers ();
8960 9011
8961 /* Fill the queue with events */ 9012 /* Fill the queue with events */
9013 BLOCK_INPUT;
8962 ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event); 9014 ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event);
8963 event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp, 9015 event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp,
8964 NULL); 9016 NULL);
9017 UNBLOCK_INPUT;
8965 if (event) 9018 if (event)
8966 { 9019 {
8967 struct input_event e; 9020 struct input_event e;
8968 struct mac_output *mwp = 9021
8969 (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
8970 /* Use an input_event to emulate what the interrupt handler does. */ 9022 /* Use an input_event to emulate what the interrupt handler does. */
8971 EVENT_INIT (e); 9023 EVENT_INIT (e);
8972 e.kind = ASCII_KEYSTROKE_EVENT; 9024 e.kind = ASCII_KEYSTROKE_EVENT;
8973 e.code = quit_char; 9025 e.code = quit_char;
8974 e.arg = NULL; 9026 e.arg = Qnil;
8975 e.modifiers = NULL; 9027 e.modifiers = NULL;
8976 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); 9028 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
8977 XSETFRAME (e.frame_or_window, mwp->mFP); 9029 XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ()));
8978 /* Remove event from queue to prevent looping. */ 9030 /* Remove event from queue to prevent looping. */
8979 RemoveEventFromQueue (GetMainEventQueue (), event); 9031 RemoveEventFromQueue (GetMainEventQueue (), event);
8980 ReleaseEvent (event); 9032 ReleaseEvent (event);
@@ -9185,10 +9237,10 @@ Otherwise the option key is used. */);
9185 useful for non-standard keyboard layouts. */); 9237 useful for non-standard keyboard layouts. */);
9186 Vmac_reverse_ctrl_meta = Qnil; 9238 Vmac_reverse_ctrl_meta = Qnil;
9187 9239
9188 DEFVAR_LISP ("mac-emulate-three-button-mouse", 9240 DEFVAR_LISP ("mac-emulate-three-button-mouse",
9189 &Vmac_emulate_three_button_mouse, 9241 &Vmac_emulate_three_button_mouse,
9190 doc: /* t means that when the option-key is held down while pressing the 9242 doc: /* t means that when the option-key is held down while pressing the
9191 mouse button, the click will register as mouse-2 and while the 9243 mouse button, the click will register as mouse-2 and while the
9192 command-key is held down, the click will register as mouse-3. 9244 command-key is held down, the click will register as mouse-3.
9193 'reverse means that the the option-key will register for mouse-3 9245 'reverse means that the the option-key will register for mouse-3
9194 and the command-key will register for mouse-2. nil means that 9246 and the command-key will register for mouse-2. nil means that
diff --git a/src/macterm.h b/src/macterm.h
index 868ce88318c..f9bde772fcd 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -565,8 +565,18 @@ struct scroll_bar {
565 text from glomming up against the scroll bar */ 565 text from glomming up against the scroll bar */
566#define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0) 566#define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
567 567
568 568struct frame;
569struct frame * check_x_frame (Lisp_Object); 569struct face;
570struct image;
571
572Lisp_Object display_x_get_resource P_ ((struct x_display_info *,
573 Lisp_Object, Lisp_Object,
574 Lisp_Object, Lisp_Object));
575struct frame *check_x_frame P_ ((Lisp_Object));
576EXFUN (Fx_display_color_p, 1);
577EXFUN (Fx_display_grayscale_p, 1);
578EXFUN (Fx_display_planes, 1);
579extern void x_free_gcs P_ ((struct frame *));
570 580
571void activate_scroll_bars (FRAME_PTR); 581void activate_scroll_bars (FRAME_PTR);
572void deactivate_scroll_bars (FRAME_PTR); 582void deactivate_scroll_bars (FRAME_PTR);
diff --git a/src/makefile.nt b/src/makefile.nt
deleted file mode 100644
index 0cf08f37105..00000000000
--- a/src/makefile.nt
+++ /dev/null
@@ -1,1232 +0,0 @@
1# Makefile for GNU Emacs on the Microsoft W32 API.
2# Copyright (c) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3# Tim Fleehart (apollo@online.com) 17-Apr-92
4# Geoff Voelker (voelker@cs.washington.edu) 11-20-93
5#
6# This file is part of GNU Emacs.
7#
8# GNU Emacs is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2, or (at your option)
11# any later version.
12#
13# GNU Emacs is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with GNU Emacs; see the file COPYING. If not, write to the
20# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21# Boston, MA 02111-1307, USA.
22#
23
24#
25# Sets up the system dependent macros.
26#
27!include ..\nt\makefile.def
28
29SUBSYSTEM=console
30
31#
32# HAVE_CONFIG_H is required by some generic gnu sources stuck into
33# the emacs source tree.
34#
35LOCAL_FLAGS = -Demacs=1 -DWINDOWSNT -DDOS_NT -DHAVE_CONFIG_H -I..\nt\inc
36!ifdef NTGUI
37LOCAL_FLAGS = $(LOCAL_FLAGS) -DHAVE_NTGUI=1
38!endif
39!ifdef USE_CRT_DLL
40LOCAL_FLAGS = $(LOCAL_FLAGS) -DUSE_CRT_DLL=1 -MD
41libc = msvcrt.lib
42LINK_FLAGS = -nodefaultlib
43!endif
44
45# From MSVC 5.0 onwards, it seem base relocation information is not included,
46# at least in release builds. We need to ensure the reloc info is included
47# in order to use the MSVC profiler.
48!IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
49EXTRA_LINK =
50!ELSE
51EXTRA_LINK = -profile
52!ENDIF
53
54EMACS = $(BLD)\emacs.exe
55TEMACS = $(BLD)\temacs.exe
56TEMACS_TMP = $(BLD)\temacs.bin
57TLIB0 = $(BLD)\temacs0.lib
58TLIB1 = $(BLD)\temacs1.lib
59TLIB2 = $(BLD)\temacs2.lib
60!IFDEF NTGUI
61TLIBW32 = $(BLD)\temacw32.lib
62!ELSE
63TLIBW32 =
64!ENDIF
65TOBJ = $(BLD)\firstfile.obj
66!if $(MSVCNT11)
67TRES = $(BLD)\emacs.res
68!else
69TRES = $(BLD)\emacs.rbj
70!endif
71TLASTLIB = $(BLD)\lastfile.lib
72
73# see comments in allocate_heap in w32heap.c before changing any of the
74# -stack, -heap, or -base settings.
75!if "$(BUILD_TYPE)" == "spd"
76LINK_FLAGS = $(LINK_FLAGS) $(ARCH_LDFLAGS) -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -debug:full -debugtype:both -pdb:$(BLD)\temacs.pdb -machine:$(ARCH) -subsystem:$(SUBSYSTEM) -entry:_start -map:$(BLD)\temacs.map -swaprun:net -swaprun:cd
77!else
78LINK_FLAGS = $(LINK_FLAGS) $(ARCH_LDFLAGS) -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -debug:full -debugtype:both -pdb:none -machine:$(ARCH) -subsystem:$(SUBSYSTEM) -entry:_start -map:$(BLD)\temacs.map -swaprun:net -swaprun:cd $(EXTRA_LINK)
79!endif
80
81#
82# Split up the objects into two sets so that we don't run out of
83# command line space when we link them into a library.
84#
85# Put emacs.obj in a separate lib, since we need to have firstfile.obj
86# as the "main" object file when linking.
87#
88OBJ0 = $(BLD)\emacs.obj
89
90OBJ1 = $(BLD)\abbrev.obj \
91 $(BLD)\alloc.obj \
92 $(BLD)\alloca.obj \
93 $(BLD)\atimer.obj \
94 $(BLD)\buffer.obj \
95 $(BLD)\bytecode.obj \
96 $(BLD)\callint.obj \
97 $(BLD)\callproc.obj \
98 $(BLD)\casefiddle.obj \
99 $(BLD)\cm.obj \
100 $(BLD)\cmds.obj \
101 $(BLD)\data.obj \
102 $(BLD)\dired.obj \
103 $(BLD)\dispnew.obj \
104 $(BLD)\doc.obj \
105 $(BLD)\doprnt.obj \
106 $(BLD)\editfns.obj \
107 $(BLD)\eval.obj \
108 $(BLD)\fileio.obj \
109 $(BLD)\filelock.obj \
110 $(BLD)\filemode.obj \
111 $(BLD)\fns.obj \
112 $(BLD)\indent.obj \
113 $(BLD)\insdel.obj \
114 $(BLD)\keyboard.obj \
115 $(BLD)\keymap.obj \
116 $(BLD)\lread.obj \
117 $(BLD)\macros.obj \
118 $(BLD)\marker.obj \
119 $(BLD)\md5.obj \
120 $(BLD)\minibuf.obj
121
122OBJ2 = $(BLD)\w32.obj \
123 $(BLD)\w32heap.obj \
124 $(BLD)\w32inevt.obj \
125 $(BLD)\w32proc.obj \
126 $(BLD)\w32console.obj \
127 $(BLD)\print.obj \
128 $(BLD)\process.obj \
129 $(BLD)\regex.obj \
130 $(BLD)\scroll.obj \
131 $(BLD)\search.obj \
132 $(BLD)\syntax.obj \
133 $(BLD)\sysdep.obj \
134 $(BLD)\term.obj \
135 $(BLD)\termcap.obj \
136 $(BLD)\tparam.obj \
137 $(BLD)\undo.obj \
138 $(BLD)\unexw32.obj \
139 $(BLD)\window.obj \
140 $(BLD)\xdisp.obj \
141 $(BLD)\casetab.obj \
142 $(BLD)\floatfns.obj \
143 $(BLD)\frame.obj \
144 $(BLD)\gmalloc.obj \
145 $(BLD)\intervals.obj \
146 $(BLD)\composite.obj \
147 $(BLD)\ralloc.obj \
148 $(BLD)\textprop.obj \
149 $(BLD)\vm-limit.obj \
150 $(BLD)\region-cache.obj \
151 $(BLD)\strftime.obj \
152 $(BLD)\charset.obj \
153 $(BLD)\coding.obj \
154 $(BLD)\category.obj \
155 $(BLD)\ccl.obj \
156 $(BLD)\fontset.obj
157
158WIN32OBJ = $(BLD)\w32term.obj \
159 $(BLD)\w32xfns.obj \
160 $(BLD)\w32fns.obj \
161 $(BLD)\xfaces.obj \
162 $(BLD)\w32select.obj \
163 $(BLD)\w32menu.obj \
164 $(BLD)\w32reg.obj \
165 $(BLD)\w32bdf.obj
166
167LIBS = $(TLIB0) \
168 $(TLIB1) \
169 $(TLIB2) \
170!IFDEF NTGUI
171 $(TLIBW32) \
172!ENDIF
173 $(TLASTLIB) \
174!IFDEF NTGUI
175 gdi32.lib \
176 comdlg32.lib \
177!ENDIF
178# libcmt.lib \
179 $(BASE_LIBS) \
180 $(ADVAPI32) \
181 user32.lib \
182 mpr.lib \
183 shell32.lib \
184 setargv.obj
185
186#
187# Build the executable and dump it.
188#
189all: $(BLD) $(EMACS)
190
191#
192# Headers we would preprocess if we could.
193#
194PREPARED_HEADERS = config.h epaths.h
195config.h: ..\nt\$(CONFIG_H)
196 $(CP) $** $@
197epaths.h: ..\nt\paths.h
198 $(CP) $** $@
199
200#
201# Make sure we have the DOC file in the right place.
202#
203DOC = $(OBJDIR)\etc\DOC-X
204$(DOC):; cd ..\lib-src
205 - $(DEL) DOC-X
206 $(MAKE) $(MFLAGS) -f makefile.nt all
207 cd ..\src
208
209#
210# The dumped executable
211#
212emacs: $(EMACS)
213$(EMACS): $(DOC) $(TEMACS)
214 $(MAKEDIR)\$(BLD)\temacs.exe -batch -l loadup dump
215
216#
217# The undumped executable
218# Note the extra post-link step to insert a static preload heap section.
219# If preload runs out of memory, increase the last argument to addsection
220# (it is the preload heap size in MB).
221#
222temacs: $(BLD) $(TEMACS)
223$(TEMACS): $(PREPARED_HEADERS) $(TLIB0) $(TLIB1) $(TLIB2) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES)
224 $(LINK) -out:$(TEMACS_TMP) $(LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
225 ..\nt\$(BLD)\addsection $(TEMACS_TMP) $(TEMACS) EMHEAP 16
226
227bootstrap: bootstrap-emacs
228
229#
230# Build a temacs with a sufficiently large PURESIZE to load the
231# Lisp files from loadup.el in source form.
232#
233bootstrap-temacs: bootstrap-clean
234 $(MAKE) $(MFLAGS) -f makefile.nt temacs CFLAGS="$(CFLAGS) -DPURESIZE=5000000"
235
236#
237# Dump an Emacs executable named bootstrap-emacs containing the
238# files from loadup.el in source form.
239#
240bootstrap-emacs: bootstrap-temacs
241 $(MAKEDIR)\$(BLD)\temacs.exe -batch -l loadup bootstrap
242 - mkdir ..\bin
243 $(CP) $(EMACS) ..\bin
244
245#
246# Force recompile of files that depend on PURESIZE
247#
248bootstrap-clean:
249 - $(DEL) $(BLD)\alloc.obj
250 - $(DEL) $(BLD)\data.obj
251 - $(DEL) $(BLD)\intervals.obj
252 - $(DEL) $(BLD)\keyboard.obj
253 - $(DEL) $(BLD)\keymap.obj
254
255#
256# The resource file. NT 3.10 requires the use of cvtres; even though
257# it is not necessary on later versions, it is still ok to use it.
258#
259$(TRES): ..\nt\emacs.rc
260 $(RC) -i..\nt -Fo$(BLD)\emacs.res $**
261!if !$(MSVCNT11)
262 $(CVTRES) -r -$(ARCH) -o $@ $(BLD)\emacs.res
263!endif
264
265#
266# Build the library. Split up the build into two phases...otherwise we
267# run out of command line space.
268#
269$(TLIB0): $(OBJ0)
270 @- $(AR) -out:$@ $**
271$(TLIB1): $(OBJ1)
272 @- $(AR) -out:$@ $**
273$(TLIB2): $(OBJ2)
274 @- $(AR) -out:$@ $**
275!IFDEF NTGUI
276$(TLIBW32): $(WIN32OBJ)
277 @- $(AR) -out:$@ $**
278!ENDIF
279
280#
281# Place lastfile.obj in its own library so that it can be loaded after
282# the source libraries but before any system libraries. Doing so defines
283# the end of Emacs' data section portably across compilers and systems.
284#
285$(TLASTLIB): $(BLD)\lastfile.obj
286 @- $(AR) -out:$@ $**
287
288#
289# Assuming INSTALL_DIR is defined, build and install emacs in it.
290#
291install: all
292 - mkdir $(INSTALL_DIR)\bin
293 $(CP) $(EMACS) $(INSTALL_DIR)\bin
294
295#
296# Maintenance
297#
298clean:; - $(DEL) *~ s\*~
299 - $(DEL) *.pdb config.h epaths.h
300 - $(DEL) *.orig *.rej *.crlf
301 - $(DEL) s\*.orig s\*.rej s\*.crlf
302 - $(DEL_TREE) deleted
303 - $(DEL_TREE) obj
304 - $(DEL_TREE) obj-spd
305
306#
307# These files are the ones that compile conditionally on CANNOT_DUMP...
308# this target is mostly used for debugging.
309#
310cleandump:; cd $(BLD)
311 - $(DEL) callproc.obj data.obj dispnew.obj doc.obj editfns.obj emacs.obj lread.obj process.obj sysdep.obj term.obj w32heap.obj unexw32.obj
312 cd ..\..
313
314
315### DEPENDENCIES ###
316
317EMACS_ROOT = ..
318SRC = .
319
320$(BLD)\abbrev.obj : \
321 $(SRC)\abbrev.c \
322 $(EMACS_ROOT)\src\s\ms-w32.h \
323 $(EMACS_ROOT)\src\m\intel386.h \
324 $(EMACS_ROOT)\src\config.h \
325 $(SRC)\commands.h \
326 $(SRC)\buffer.h \
327 $(SRC)\window.h
328
329$(BLD)\alloc.obj : \
330 $(SRC)\alloc.c \
331 $(EMACS_ROOT)\src\s\ms-w32.h \
332 $(EMACS_ROOT)\src\m\intel386.h \
333 $(EMACS_ROOT)\src\config.h \
334 $(SRC)\dispextern.h \
335 $(SRC)\w32gui.h \
336 $(SRC)\intervals.h \
337 $(SRC)\composite.h \
338 $(SRC)\puresize.h \
339 $(SRC)\buffer.h \
340 $(SRC)\window.h \
341 $(SRC)\frame.h \
342 $(SRC)\blockinput.h \
343 $(SRC)\syssignal.h
344
345$(BLD)\alloca.obj : \
346 $(SRC)\alloca.c \
347 $(EMACS_ROOT)\src\s\ms-w32.h \
348 $(EMACS_ROOT)\src\m\intel386.h \
349 $(EMACS_ROOT)\src\config.h \
350 $(SRC)\s\ms-w32.h \
351 $(SRC)\m\intel386.h \
352 $(SRC)\config.h \
353 $(SRC)\blockinput.h
354
355$(BLD)\atimer.obj : \
356 $(SRC)\atimer.c \
357 $(EMACS_ROOT)\src\s\ms-w32.h \
358 $(EMACS_ROOT)\src\m\intel386.h \
359 $(EMACS_ROOT)\src\config.h \
360 $(SRC)\s\ms-w32.h \
361 $(SRC)\m\intel386.h \
362 $(SRC)\config.h \
363 $(SRC)\atimer.h \
364 $(SRC)\syssignal.h \
365 $(SRC)\systime.h \
366 $(SRC)\blockinput.h
367
368$(BLD)\buffer.obj : \
369 $(SRC)\buffer.c \
370 $(EMACS_ROOT)\nt\inc\sys\param.h \
371 $(EMACS_ROOT)\src\s\ms-w32.h \
372 $(EMACS_ROOT)\src\m\intel386.h \
373 $(EMACS_ROOT)\src\config.h \
374 $(SRC)\dispextern.h \
375 $(SRC)\w32gui.h \
376 $(SRC)\intervals.h \
377 $(SRC)\composite.h \
378 $(SRC)\frame.h \
379 $(SRC)\window.h \
380 $(SRC)\commands.h \
381 $(SRC)\buffer.h \
382 $(SRC)\indent.h \
383 $(SRC)\blockinput.h \
384 $(SRC)\region-cache.h
385
386$(BLD)\bytecode.obj : \
387 $(SRC)\bytecode.c \
388 $(EMACS_ROOT)\src\s\ms-w32.h \
389 $(EMACS_ROOT)\src\m\intel386.h \
390 $(EMACS_ROOT)\src\config.h \
391 $(SRC)\buffer.h \
392 $(SRC)\syntax.h
393
394$(BLD)\callint.obj : \
395 $(SRC)\callint.c \
396 $(EMACS_ROOT)\src\s\ms-w32.h \
397 $(EMACS_ROOT)\src\m\intel386.h \
398 $(EMACS_ROOT)\src\config.h \
399 $(SRC)\buffer.h \
400 $(SRC)\commands.h \
401 $(SRC)\keyboard.h \
402 $(SRC)\window.h
403
404$(BLD)\callproc.obj : \
405 $(SRC)\callproc.c \
406 $(EMACS_ROOT)\src\s\ms-w32.h \
407 $(EMACS_ROOT)\src\m\intel386.h \
408 $(EMACS_ROOT)\src\config.h \
409 $(SRC)\msdos.h \
410 $(EMACS_ROOT)\nt\inc\sys\param.h \
411 $(SRC)\commands.h \
412 $(SRC)\buffer.h \
413 $(SRC)\process.h \
414 $(SRC)\syssignal.h \
415 $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
416 $(EMACS_ROOT)\nt\inc\sys\file.h \
417 $(SRC)\systty.h
418
419$(BLD)\casefiddle.obj : \
420 $(SRC)\casefiddle.c \
421 $(EMACS_ROOT)\src\s\ms-w32.h \
422 $(EMACS_ROOT)\src\m\intel386.h \
423 $(EMACS_ROOT)\src\config.h \
424 $(SRC)\buffer.h \
425 $(SRC)\commands.h \
426 $(SRC)\syntax.h
427 $(CC) $(CFLAGS) -Fo$@ casefiddle.c
428
429$(BLD)\casetab.obj : \
430 $(SRC)\casetab.c \
431 $(EMACS_ROOT)\src\s\ms-w32.h \
432 $(EMACS_ROOT)\src\m\intel386.h \
433 $(EMACS_ROOT)\src\config.h \
434 $(SRC)\buffer.h
435
436$(BLD)\cm.obj : \
437 $(SRC)\cm.c \
438 $(EMACS_ROOT)\src\s\ms-w32.h \
439 $(EMACS_ROOT)\src\m\intel386.h \
440 $(EMACS_ROOT)\src\config.h \
441 $(SRC)\cm.h \
442 $(SRC)\termhooks.h
443
444$(BLD)\cmds.obj : \
445 $(SRC)\cmds.c \
446 $(EMACS_ROOT)\src\s\ms-w32.h \
447 $(EMACS_ROOT)\src\m\intel386.h \
448 $(EMACS_ROOT)\src\config.h \
449 $(SRC)\commands.h \
450 $(SRC)\buffer.h \
451 $(SRC)\syntax.h
452
453$(BLD)\composite.obj : \
454 $(SRC)\composite.c \
455 $(SRC)\buffer.h \
456 $(SRC)\charset.h \
457 $(SRC)\intervals.h \
458 $(SRC)\composite.h \
459 $(EMACS_ROOT)\src\s\ms-w32.h \
460 $(EMACS_ROOT)\src\m\intel386.h \
461 $(EMACS_ROOT)\src\config.h
462
463$(BLD)\data.obj : \
464 $(SRC)\data.c \
465 $(EMACS_ROOT)\src\s\ms-w32.h \
466 $(EMACS_ROOT)\src\m\intel386.h \
467 $(EMACS_ROOT)\src\config.h \
468 $(SRC)\puresize.h \
469 $(SRC)\buffer.h \
470 $(SRC)\syssignal.h
471
472$(BLD)\dired.obj : \
473 $(SRC)\dired.c \
474 $(EMACS_ROOT)\src\s\ms-w32.h \
475 $(EMACS_ROOT)\src\m\intel386.h \
476 $(EMACS_ROOT)\src\config.h \
477 $(SRC)\ndir.h \
478 $(SRC)\buffer.h \
479 $(SRC)\commands.h \
480 $(SRC)\regex.h
481
482$(BLD)\dispnew.obj : \
483 $(SRC)\dispnew.c \
484 $(EMACS_ROOT)\src\s\ms-w32.h \
485 $(EMACS_ROOT)\src\m\intel386.h \
486 $(EMACS_ROOT)\src\config.h \
487 $(SRC)\termchar.h \
488 $(SRC)\termopts.h \
489 $(SRC)\termhooks.h \
490 $(SRC)\cm.h \
491 $(SRC)\buffer.h \
492 $(SRC)\frame.h \
493 $(SRC)\window.h \
494 $(SRC)\commands.h \
495 $(SRC)\disptab.h \
496 $(SRC)\indent.h \
497 $(SRC)\dispextern.h \
498 $(SRC)\intervals.h \
499 $(SRC)\composite.h \
500 $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
501 $(EMACS_ROOT)\nt\inc\sys\file.h \
502 $(SRC)\systty.h \
503 $(SRC)\w32term.h \
504 $(SRC)\w32gui.h \
505 $(SRC)\xterm.h \
506 $(SRC)\systime.h
507
508$(BLD)\doc.obj : \
509 $(SRC)\doc.c \
510 $(EMACS_ROOT)\src\s\ms-w32.h \
511 $(EMACS_ROOT)\src\m\intel386.h \
512 $(EMACS_ROOT)\src\config.h \
513 $(EMACS_ROOT)\nt\inc\sys\file.h \
514 $(SRC)\buffer.h \
515 $(SRC)\keyboard.h
516
517$(BLD)\doprnt.obj : \
518 $(SRC)\doprnt.c \
519 $(EMACS_ROOT)\src\s\ms-w32.h \
520 $(EMACS_ROOT)\src\m\intel386.h \
521 $(EMACS_ROOT)\src\config.h
522
523$(BLD)\dosfns.obj : \
524 $(SRC)\dosfns.c \
525 $(EMACS_ROOT)\src\s\ms-w32.h \
526 $(EMACS_ROOT)\src\m\intel386.h \
527 $(EMACS_ROOT)\src\config.h \
528 $(SRC)\buffer.h \
529 $(SRC)\termchar.h \
530 $(SRC)\termhooks.h \
531 $(SRC)\frame.h \
532 $(SRC)\dosfns.h \
533 $(SRC)\msdos.h
534
535$(BLD)\editfns.obj : \
536 $(SRC)\editfns.c \
537 $(EMACS_ROOT)\src\s\ms-w32.h \
538 $(EMACS_ROOT)\src\m\intel386.h \
539 $(EMACS_ROOT)\src\config.h \
540 $(SRC)\uaf.h \
541 $(EMACS_ROOT)\nt\inc\pwd.h \
542 $(SRC)\dispextern.h \
543 $(SRC)\w32gui.h \
544 $(SRC)\intervals.h \
545 $(SRC)\composite.h \
546 $(SRC)\buffer.h \
547 $(SRC)\window.h \
548 $(SRC)\systime.h
549
550$(BLD)\emacs.obj : \
551 $(SRC)\emacs.c \
552 $(EMACS_ROOT)\src\s\ms-w32.h \
553 $(EMACS_ROOT)\src\m\intel386.h \
554 $(EMACS_ROOT)\src\config.h \
555 $(SRC)\commands.h \
556 $(SRC)\dispextern.h \
557 $(SRC)\w32gui.h \
558 $(SRC)\intervals.h \
559 $(SRC)\composite.h \
560 $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
561 $(EMACS_ROOT)\nt\inc\sys\file.h \
562 $(SRC)\systty.h \
563 $(SRC)\syssignal.h \
564 $(SRC)\process.h
565
566$(BLD)\eval.obj : \
567 $(SRC)\eval.c \
568 $(EMACS_ROOT)\src\s\ms-w32.h \
569 $(EMACS_ROOT)\src\m\intel386.h \
570 $(EMACS_ROOT)\src\config.h \
571 $(SRC)\blockinput.h \
572 $(SRC)\commands.h \
573 $(SRC)\keyboard.h
574
575$(BLD)\fileio.obj : \
576 $(SRC)\fileio.c \
577 $(EMACS_ROOT)\src\s\ms-w32.h \
578 $(EMACS_ROOT)\src\m\intel386.h \
579 $(EMACS_ROOT)\src\config.h \
580 $(SRC)\uaf.h \
581 $(EMACS_ROOT)\nt\inc\pwd.h \
582 $(SRC)\msdos.h \
583 $(EMACS_ROOT)\nt\inc\sys\param.h \
584 $(SRC)\dispextern.h \
585 $(SRC)\w32gui.h \
586 $(SRC)\intervals.h \
587 $(SRC)\composite.h \
588 $(SRC)\buffer.h \
589 $(SRC)\window.h \
590 $(EMACS_ROOT)\nt\inc\sys\file.h \
591 $(SRC)\systime.h
592
593$(BLD)\filelock.obj : \
594 $(SRC)\filelock.c \
595 $(EMACS_ROOT)\src\s\ms-w32.h \
596 $(EMACS_ROOT)\src\m\intel386.h \
597 $(EMACS_ROOT)\src\config.h \
598 $(SRC)\uaf.h \
599 $(EMACS_ROOT)\nt\inc\pwd.h \
600 $(EMACS_ROOT)\nt\inc\sys\file.h \
601 $(EMACS_ROOT)\src\epaths.h \
602 $(SRC)\buffer.h \
603 $(SRC)\ndir.h
604
605$(BLD)\filemode.obj : \
606 $(SRC)\filemode.c \
607 $(EMACS_ROOT)\src\s\ms-w32.h \
608 $(EMACS_ROOT)\src\m\intel386.h \
609 $(EMACS_ROOT)\src\config.h \
610 $(SRC)\s\ms-w32.h \
611 $(SRC)\m\intel386.h \
612 $(SRC)\config.h
613
614$(BLD)\firstfile.obj : \
615 $(SRC)\firstfile.c \
616 $(EMACS_ROOT)\src\s\ms-w32.h \
617 $(EMACS_ROOT)\src\m\intel386.h \
618 $(EMACS_ROOT)\src\config.h
619
620$(BLD)\floatfns.obj : \
621 $(SRC)\floatfns.c \
622 $(EMACS_ROOT)\src\s\ms-w32.h \
623 $(EMACS_ROOT)\src\m\intel386.h \
624 $(EMACS_ROOT)\src\config.h \
625 $(SRC)\syssignal.h
626
627$(BLD)\fns.obj : \
628 $(SRC)\fns.c \
629 $(EMACS_ROOT)\src\s\ms-w32.h \
630 $(EMACS_ROOT)\src\m\intel386.h \
631 $(EMACS_ROOT)\src\config.h \
632 $(SRC)\commands.h \
633 $(SRC)\buffer.h \
634 $(SRC)\keyboard.h \
635 $(SRC)\dispextern.h \
636 $(SRC)\w32gui.h \
637 $(SRC)\intervals.h \
638 $(SRC)\composite.h \
639 $(SRC)\md5.h
640
641$(BLD)\frame.obj : \
642 $(SRC)\frame.c \
643 $(EMACS_ROOT)\src\s\ms-w32.h \
644 $(EMACS_ROOT)\src\m\intel386.h \
645 $(EMACS_ROOT)\src\config.h \
646 $(SRC)\frame.h \
647 $(SRC)\termhooks.h \
648 $(SRC)\window.h \
649 $(SRC)\buffer.h \
650 $(SRC)\commands.h \
651 $(SRC)\keyboard.h
652
653$(BLD)\getloadavg.obj : \
654 $(SRC)\getloadavg.c \
655 $(EMACS_ROOT)\nt\inc\sys\param.h \
656 $(EMACS_ROOT)\src\s\ms-w32.h \
657 $(EMACS_ROOT)\src\m\intel386.h \
658 $(EMACS_ROOT)\src\config.h \
659 $(SRC)\s\ms-w32.h \
660 $(SRC)\m\intel386.h \
661 $(SRC)\config.h \
662 $(EMACS_ROOT)\nt\inc\sys\file.h
663
664$(BLD)\gmalloc.obj : \
665 $(SRC)\gmalloc.c \
666 $(EMACS_ROOT)\src\s\ms-w32.h \
667 $(EMACS_ROOT)\src\m\intel386.h \
668 $(EMACS_ROOT)\src\config.h \
669 $(EMACS_ROOT)\nt\inc\sys\param.h \
670 $(SRC)\getpagesize.h
671 $(CC) $(CFLAGS) -D__STDC__ -Fo$@ gmalloc.c
672
673$(BLD)\hftctl.obj : \
674 $(SRC)\hftctl.c \
675 $(EMACS_ROOT)\src\s\ms-w32.h \
676 $(EMACS_ROOT)\src\m\intel386.h \
677 $(EMACS_ROOT)\src\config.h \
678 $(EMACS_ROOT)\nt\inc\sys\ioctl.h
679
680$(BLD)\indent.obj : \
681 $(SRC)\indent.c \
682 $(EMACS_ROOT)\src\s\ms-w32.h \
683 $(EMACS_ROOT)\src\m\intel386.h \
684 $(EMACS_ROOT)\src\config.h \
685 $(SRC)\buffer.h \
686 $(SRC)\indent.h \
687 $(SRC)\frame.h \
688 $(SRC)\window.h \
689 $(SRC)\termchar.h \
690 $(SRC)\termopts.h \
691 $(SRC)\disptab.h \
692 $(SRC)\dispextern.h \
693 $(SRC)\w32gui.h \
694 $(SRC)\intervals.h \
695 $(SRC)\region-cache.h \
696 $(SRC)\composite.h
697
698$(BLD)\insdel.obj : \
699 $(SRC)\insdel.c \
700 $(EMACS_ROOT)\src\s\ms-w32.h \
701 $(EMACS_ROOT)\src\m\intel386.h \
702 $(EMACS_ROOT)\src\config.h \
703 $(SRC)\dispextern.h \
704 $(SRC)\w32gui.h \
705 $(SRC)\intervals.h \
706 $(SRC)\composite.h \
707 $(SRC)\buffer.h \
708 $(SRC)\window.h \
709 $(SRC)\blockinput.h
710
711$(BLD)\intervals.obj : \
712 $(SRC)\intervals.c \
713 $(EMACS_ROOT)\src\s\ms-w32.h \
714 $(EMACS_ROOT)\src\m\intel386.h \
715 $(EMACS_ROOT)\src\config.h \
716 $(SRC)\dispextern.h \
717 $(SRC)\w32gui.h \
718 $(SRC)\intervals.h \
719 $(SRC)\composite.h \
720 $(SRC)\keyboard.h \
721 $(SRC)\buffer.h \
722 $(SRC)\puresize.h
723
724$(BLD)\keyboard.obj : \
725 $(SRC)\keyboard.c \
726 $(EMACS_ROOT)\src\s\ms-w32.h \
727 $(EMACS_ROOT)\src\m\intel386.h \
728 $(EMACS_ROOT)\src\config.h \
729 $(SRC)\termchar.h \
730 $(SRC)\termopts.h \
731 $(SRC)\termhooks.h \
732 $(SRC)\macros.h \
733 $(SRC)\frame.h \
734 $(SRC)\window.h \
735 $(SRC)\commands.h \
736 $(SRC)\buffer.h \
737 $(SRC)\disptab.h \
738 $(SRC)\keyboard.h \
739 $(SRC)\dispextern.h \
740 $(SRC)\intervals.h \
741 $(SRC)\composite.h \
742 $(SRC)\blockinput.h \
743 $(SRC)\msdos.h \
744 $(SRC)\syssignal.h \
745 $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
746 $(EMACS_ROOT)\nt\inc\sys\file.h \
747 $(SRC)\systty.h \
748 $(SRC)\w32term.h \
749 $(SRC)\w32gui.h \
750 $(SRC)\xterm.h \
751 $(SRC)\systime.h \
752 $(SRC)\atimer.h
753
754$(BLD)\keymap.obj : \
755 $(SRC)\keymap.c \
756 $(EMACS_ROOT)\src\s\ms-w32.h \
757 $(EMACS_ROOT)\src\m\intel386.h \
758 $(EMACS_ROOT)\src\config.h \
759 $(SRC)\commands.h \
760 $(SRC)\buffer.h \
761 $(SRC)\keyboard.h \
762 $(SRC)\termhooks.h \
763 $(SRC)\blockinput.h
764
765$(BLD)\lastfile.obj : \
766 $(SRC)\lastfile.c \
767 $(EMACS_ROOT)\src\s\ms-w32.h \
768 $(EMACS_ROOT)\src\m\intel386.h \
769 $(EMACS_ROOT)\src\config.h
770
771$(BLD)\lread.obj : \
772 $(SRC)\lread.c \
773 $(EMACS_ROOT)\src\s\ms-w32.h \
774 $(EMACS_ROOT)\src\m\intel386.h \
775 $(EMACS_ROOT)\src\config.h \
776 $(EMACS_ROOT)\nt\inc\sys\file.h \
777 $(SRC)\buffer.h \
778 $(EMACS_ROOT)\src\epaths.h \
779 $(SRC)\commands.h \
780 $(SRC)\keyboard.h \
781 $(SRC)\termhooks.h \
782 $(SRC)\msdos.h
783
784$(BLD)\macros.obj : \
785 $(SRC)\macros.c \
786 $(EMACS_ROOT)\src\s\ms-w32.h \
787 $(EMACS_ROOT)\src\m\intel386.h \
788 $(EMACS_ROOT)\src\config.h \
789 $(SRC)\macros.h \
790 $(SRC)\commands.h \
791 $(SRC)\buffer.h \
792 $(SRC)\window.h
793
794$(BLD)\marker.obj : \
795 $(SRC)\marker.c \
796 $(EMACS_ROOT)\src\s\ms-w32.h \
797 $(EMACS_ROOT)\src\m\intel386.h \
798 $(EMACS_ROOT)\src\config.h \
799 $(SRC)\buffer.h
800
801$(BLD)\md5.obj : \
802 $(SRC)\md5.c \
803 $(SRC)\md5.h
804
805$(BLD)\minibuf.obj : \
806 $(SRC)\minibuf.c \
807 $(EMACS_ROOT)\src\s\ms-w32.h \
808 $(EMACS_ROOT)\src\m\intel386.h \
809 $(EMACS_ROOT)\src\config.h \
810 $(SRC)\commands.h \
811 $(SRC)\buffer.h \
812 $(SRC)\dispextern.h \
813 $(SRC)\w32gui.h \
814 $(SRC)\frame.h \
815 $(SRC)\window.h \
816 $(SRC)\syntax.h
817
818$(BLD)\w32.obj : \
819 $(SRC)\w32.c \
820 $(SRC)\w32.h \
821 $(SRC)\s\ms-w32.h \
822 $(SRC)\m\intel386.h \
823 $(SRC)\config.h \
824 $(EMACS_ROOT)\nt\inc\pwd.h \
825 $(SRC)\w32heap.h
826
827$(BLD)\w32heap.obj : \
828 $(SRC)\w32heap.c \
829 $(SRC)\w32heap.h \
830 $(SRC)\s\ms-w32.h \
831 $(SRC)\m\intel386.h \
832 $(SRC)\config.h
833
834$(BLD)\w32inevt.obj : \
835 $(SRC)\w32inevt.c \
836 $(SRC)\s\ms-w32.h \
837 $(SRC)\m\intel386.h \
838 $(SRC)\config.h \
839 $(SRC)\frame.h \
840 $(SRC)\blockinput.h \
841 $(SRC)\termhooks.h \
842 $(SRC)\w32heap.h \
843 $(SRC)\w32term.h \
844 $(SRC)\w32gui.h
845
846$(BLD)\w32proc.obj : \
847 $(SRC)\w32proc.c \
848 $(SRC)\s\ms-w32.h \
849 $(SRC)\m\intel386.h \
850 $(SRC)\config.h \
851 $(SRC)\w32.h \
852 $(SRC)\w32heap.h \
853 $(SRC)\systime.h
854
855$(BLD)\w32console.obj : \
856 $(SRC)\w32console.c \
857 $(SRC)\s\ms-w32.h \
858 $(SRC)\m\intel386.h \
859 $(SRC)\config.h \
860 $(SRC)\frame.h \
861 $(SRC)\disptab.h \
862 $(SRC)\termhooks.h \
863 $(SRC)\w32inevt.h
864
865$(BLD)\prefix-args.obj : \
866 $(SRC)\prefix-args.c
867
868$(BLD)\print.obj : \
869 $(SRC)\print.c \
870 $(EMACS_ROOT)\src\s\ms-w32.h \
871 $(EMACS_ROOT)\src\m\intel386.h \
872 $(EMACS_ROOT)\src\config.h \
873 $(SRC)\buffer.h \
874 $(SRC)\frame.h \
875 $(SRC)\window.h \
876 $(SRC)\process.h \
877 $(SRC)\termchar.h \
878 $(SRC)\dispextern.h \
879 $(SRC)\w32gui.h \
880 $(SRC)\intervals.h \
881 $(SRC)\composite.h
882
883$(BLD)\process.obj : \
884 $(SRC)\process.c \
885 $(EMACS_ROOT)\src\s\ms-w32.h \
886 $(EMACS_ROOT)\src\m\intel386.h \
887 $(EMACS_ROOT)\src\config.h \
888 $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
889 $(EMACS_ROOT)\nt\inc\sys\file.h \
890 $(SRC)\systty.h \
891 $(SRC)\window.h \
892 $(SRC)\buffer.h \
893 $(SRC)\process.h \
894 $(SRC)\termhooks.h \
895 $(SRC)\commands.h \
896 $(SRC)\frame.h \
897 $(SRC)\syssignal.h \
898 $(SRC)\syswait.h \
899 $(SRC)\systime.h \
900 $(SRC)\termopts.h \
901 $(SRC)\composite.h \
902 $(SRC)\atimer.h
903
904$(BLD)\ralloc.obj : \
905 $(SRC)\ralloc.c \
906 $(EMACS_ROOT)\src\s\ms-w32.h \
907 $(EMACS_ROOT)\src\m\intel386.h \
908 $(EMACS_ROOT)\src\config.h \
909 $(SRC)\s\ms-w32.h \
910 $(SRC)\m\intel386.h \
911 $(SRC)\config.h \
912 $(EMACS_ROOT)\nt\inc\sys\param.h \
913 $(SRC)\getpagesize.h
914
915$(BLD)\regex.obj : \
916 $(SRC)\regex.c \
917 $(EMACS_ROOT)\src\s\ms-w32.h \
918 $(EMACS_ROOT)\src\m\intel386.h \
919 $(EMACS_ROOT)\src\config.h \
920 $(SRC)\s\ms-w32.h \
921 $(SRC)\m\intel386.h \
922 $(SRC)\config.h \
923 $(SRC)\buffer.h \
924 $(SRC)\syntax.h \
925 $(SRC)\regex.h
926
927$(BLD)\region-cache.obj : \
928 $(SRC)\region-cache.c \
929 $(EMACS_ROOT)\src\s\ms-w32.h \
930 $(EMACS_ROOT)\src\m\intel386.h \
931 $(EMACS_ROOT)\src\config.h \
932 $(SRC)\buffer.h \
933 $(SRC)\region-cache.h
934
935$(BLD)\scroll.obj : \
936 $(SRC)\scroll.c \
937 $(EMACS_ROOT)\src\s\ms-w32.h \
938 $(EMACS_ROOT)\src\m\intel386.h \
939 $(EMACS_ROOT)\src\config.h \
940 $(SRC)\termchar.h \
941 $(SRC)\dispextern.h \
942 $(SRC)\w32gui.h \
943 $(SRC)\frame.h
944
945$(BLD)\search.obj : \
946 $(SRC)\search.c \
947 $(EMACS_ROOT)\src\s\ms-w32.h \
948 $(EMACS_ROOT)\src\m\intel386.h \
949 $(EMACS_ROOT)\src\config.h \
950 $(SRC)\syntax.h \
951 $(SRC)\buffer.h \
952 $(SRC)\commands.h \
953 $(SRC)\blockinput.h \
954 $(SRC)\regex.h \
955 $(SRC)\region-cache.h \
956 $(SRC)\composite.h
957
958$(BLD)\strftime.obj : \
959 $(SRC)\strftime.c \
960 $(EMACS_ROOT)\src\s\ms-w32.h \
961 $(EMACS_ROOT)\src\m\intel386.h \
962 $(EMACS_ROOT)\src\config.h
963
964$(BLD)\syntax.obj : \
965 $(SRC)\syntax.c \
966 $(EMACS_ROOT)\src\s\ms-w32.h \
967 $(EMACS_ROOT)\src\m\intel386.h \
968 $(EMACS_ROOT)\src\config.h \
969 $(SRC)\commands.h \
970 $(SRC)\buffer.h \
971 $(SRC)\syntax.h \
972 $(SRC)\composite.h
973
974$(BLD)\sysdep.obj : \
975 $(SRC)\sysdep.c \
976 $(EMACS_ROOT)\src\s\ms-w32.h \
977 $(EMACS_ROOT)\src\m\intel386.h \
978 $(EMACS_ROOT)\src\config.h \
979 $(SRC)\blockinput.h \
980 $(SRC)\dosfns.h \
981 $(SRC)\msdos.h \
982 $(EMACS_ROOT)\nt\inc\sys\param.h \
983 $(EMACS_ROOT)\nt\inc\sys\file.h \
984 $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
985 $(EMACS_ROOT)\nt\inc\sys\file.h \
986 $(SRC)\systty.h \
987 $(SRC)\syswait.h \
988 $(SRC)\frame.h \
989 $(SRC)\window.h \
990 $(SRC)\termhooks.h \
991 $(SRC)\termchar.h \
992 $(SRC)\termopts.h \
993 $(SRC)\dispextern.h \
994 $(SRC)\w32gui.h \
995 $(SRC)\process.h \
996 $(SRC)\ndir.h \
997 $(SRC)\syssignal.h \
998 $(SRC)\systime.h \
999 $(SRC)\uaf.h \
1000 $(EMACS_ROOT)\src\acldef.h \
1001 $(EMACS_ROOT)\src\chpdef.h
1002
1003$(BLD)\term.obj : \
1004 $(SRC)\term.c \
1005 $(EMACS_ROOT)\src\s\ms-w32.h \
1006 $(EMACS_ROOT)\src\m\intel386.h \
1007 $(EMACS_ROOT)\src\config.h \
1008 $(SRC)\termchar.h \
1009 $(SRC)\termopts.h \
1010 $(SRC)\cm.h \
1011 $(SRC)\frame.h \
1012 $(SRC)\disptab.h \
1013 $(SRC)/dispextern.h \
1014 $(SRC)\termhooks.h \
1015 $(SRC)\keyboard.h
1016
1017$(BLD)\termcap.obj : \
1018 $(SRC)\termcap.c \
1019 $(EMACS_ROOT)\src\s\ms-w32.h \
1020 $(EMACS_ROOT)\src\m\intel386.h \
1021 $(EMACS_ROOT)\src\config.h \
1022 $(EMACS_ROOT)\nt\inc\sys\file.h
1023
1024$(BLD)\terminfo.obj : \
1025 $(SRC)\terminfo.c
1026
1027$(BLD)\textprop.obj : \
1028 $(SRC)\textprop.c \
1029 $(EMACS_ROOT)\src\s\ms-w32.h \
1030 $(EMACS_ROOT)\src\m\intel386.h \
1031 $(EMACS_ROOT)\src\config.h \
1032 $(SRC)\dispextern.h \
1033 $(SRC)\w32gui.h \
1034 $(SRC)\intervals.h \
1035 $(SRC)\composite.h \
1036 $(SRC)\buffer.h \
1037 $(SRC)\window.h
1038
1039$(BLD)\tparam.obj : \
1040 $(SRC)\tparam.c \
1041 $(EMACS_ROOT)\src\s\ms-w32.h \
1042 $(EMACS_ROOT)\src\m\intel386.h \
1043 $(EMACS_ROOT)\src\config.h
1044
1045$(BLD)\undo.obj : \
1046 $(SRC)\undo.c \
1047 $(EMACS_ROOT)\src\s\ms-w32.h \
1048 $(EMACS_ROOT)\src\m\intel386.h \
1049 $(EMACS_ROOT)\src\config.h \
1050 $(SRC)\buffer.h \
1051 $(SRC)\commands.h
1052
1053$(BLD)\unexw32.obj : \
1054 $(SRC)\unexw32.c \
1055 $(EMACS_ROOT)\src\s\ms-w32.h \
1056 $(EMACS_ROOT)\src\m\intel386.h \
1057 $(EMACS_ROOT)\src\config.h \
1058 $(SRC)\w32heap.h
1059
1060$(BLD)\vm-limit.obj : \
1061 $(SRC)\vm-limit.c \
1062 $(EMACS_ROOT)\src\s\ms-w32.h \
1063 $(EMACS_ROOT)\src\m\intel386.h \
1064 $(EMACS_ROOT)\src\config.h \
1065 $(SRC)\mem-limits.h
1066
1067$(BLD)\widget.obj : \
1068 $(SRC)\widget.c \
1069 $(EMACS_ROOT)\src\s\ms-w32.h \
1070 $(EMACS_ROOT)\src\m\intel386.h \
1071 $(EMACS_ROOT)\src\config.h \
1072 $(SRC)\xterm.h \
1073 $(SRC)\frame.h \
1074 $(SRC)\dispextern.h \
1075 $(SRC)\w32gui.h \
1076 $(SRC)\widget.h \
1077 $(SRC)\widgetprv.h
1078
1079$(BLD)\window.obj : \
1080 $(SRC)\window.c \
1081 $(EMACS_ROOT)\src\s\ms-w32.h \
1082 $(EMACS_ROOT)\src\m\intel386.h \
1083 $(EMACS_ROOT)\src\config.h \
1084 $(SRC)\buffer.h \
1085 $(SRC)\frame.h \
1086 $(SRC)\window.h \
1087 $(SRC)\commands.h \
1088 $(SRC)\indent.h \
1089 $(SRC)\termchar.h \
1090 $(SRC)\disptab.h \
1091 $(SRC)\keyboard.h \
1092 $(SRC)\composite.h
1093
1094$(BLD)\xdisp.obj : \
1095 $(SRC)\xdisp.c \
1096 $(EMACS_ROOT)\src\s\ms-w32.h \
1097 $(EMACS_ROOT)\src\m\intel386.h \
1098 $(EMACS_ROOT)\src\config.h \
1099 $(SRC)\frame.h \
1100 $(SRC)\window.h \
1101 $(SRC)\termchar.h \
1102 $(SRC)\buffer.h \
1103 $(SRC)\indent.h \
1104 $(SRC)\commands.h \
1105 $(SRC)\macros.h \
1106 $(SRC)\disptab.h \
1107 $(SRC)\termhooks.h \
1108 $(SRC)\dispextern.h \
1109 $(SRC)\w32gui.h \
1110 $(SRC)\intervals.h \
1111 $(SRC)\composite.h
1112
1113$(BLD)\xfaces.obj: \
1114 $(EMACS_ROOT)\src\s\ms-w32.h \
1115 $(EMACS_ROOT)\src\m\intel386.h \
1116 $(EMACS_ROOT)\src\config.h \
1117 $(SRC)\xfaces.c \
1118 $(SRC)\charset.h \
1119 $(SRC)\fontset.h \
1120 $(SRC)\w32term.h \
1121 $(SRC)\w32gui.h \
1122 $(SRC)\buffer.h \
1123 $(SRC)\dispextern.h \
1124 $(SRC)\frame.h \
1125 $(SRC)\blockinput.h \
1126 $(SRC)\window.h \
1127 $(SRC)\intervals.h \
1128 $(SRC)\composite.h
1129
1130$(BLD)\w32fns.obj: \
1131 $(EMACS_ROOT)\src\s\ms-w32.h \
1132 $(EMACS_ROOT)\src\m\intel386.h \
1133 $(EMACS_ROOT)\src\config.h \
1134 $(SRC)\w32fns.c \
1135 $(SRC)\w32term.h \
1136 $(SRC)\w32gui.h \
1137 $(SRC)\frame.h \
1138 $(SRC)\window.h \
1139 $(SRC)\buffer.h \
1140 $(SRC)\charset.h \
1141 $(SRC)\coding.h \
1142 $(SRC)\dispextern.h \
1143 $(SRC)\keyboard.h \
1144 $(SRC)\blockinput.h \
1145 $(SRC)\epaths.h \
1146 $(SRC)\w32heap.h \
1147 $(SRC)\termhooks.h
1148
1149$(BLD)\w32menu.obj: \
1150 $(EMACS_ROOT)\src\s\ms-w32.h \
1151 $(EMACS_ROOT)\src\m\intel386.h \
1152 $(EMACS_ROOT)\src\config.h \
1153 $(SRC)\w32menu.c \
1154 $(SRC)\termhooks.h \
1155 $(SRC)\frame.h \
1156 $(SRC)\window.h \
1157 $(SRC)\keyboard.h \
1158 $(SRC)\blockinput.h \
1159 $(SRC)\buffer.h \
1160 $(SRC)\charset.h \
1161 $(SRC)\coding.h
1162
1163$(BLD)\w32term.obj: \
1164 $(EMACS_ROOT)\src\s\ms-w32.h \
1165 $(EMACS_ROOT)\src\m\intel386.h \
1166 $(EMACS_ROOT)\src\config.h \
1167 $(SRC)\w32term.c \
1168 $(SRC)\blockinput.h \
1169 $(SRC)\w32heap.h \
1170 $(SRC)\w32term.h \
1171 $(SRC)\w32gui.h \
1172 $(SRC)\systty.h \
1173 $(SRC)\systime.h \
1174 $(SRC)\frame.h \
1175 $(SRC)\dispextern.h \
1176 $(SRC)\termhooks.h \
1177 $(SRC)\termopts.h \
1178 $(SRC)\termchar.h \
1179 $(SRC)\gnu.h \
1180 $(SRC)\disptab.h \
1181 $(SRC)\buffer.h \
1182 $(SRC)\window.h \
1183 $(SRC)\keyboard.h \
1184 $(SRC)\intervals.h \
1185 $(SRC)\composite.h \
1186 $(SRC)\atimer.h
1187
1188$(BLD)\w32select.obj: \
1189 $(EMACS_ROOT)\src\s\ms-w32.h \
1190 $(EMACS_ROOT)\src\m\intel386.h \
1191 $(EMACS_ROOT)\src\config.h \
1192 $(SRC)\w32select.c \
1193 $(SRC)\w32term.h \
1194 $(SRC)\w32gui.h \
1195 $(SRC)\dispextern.h \
1196 $(SRC)\frame.h \
1197 $(SRC)\blockinput.h
1198
1199$(BLD)\w32reg.obj: \
1200 $(EMACS_ROOT)\src\s\ms-w32.h \
1201 $(EMACS_ROOT)\src\m\intel386.h \
1202 $(EMACS_ROOT)\src\config.h \
1203 $(SRC)\w32reg.c \
1204 $(SRC)\w32term.h \
1205 $(SRC)\w32gui.h \
1206 $(SRC)\blockinput.h
1207
1208$(BLD)\w32xfns.obj: \
1209 $(EMACS_ROOT)\src\s\ms-w32.h \
1210 $(EMACS_ROOT)\src\m\intel386.h \
1211 $(EMACS_ROOT)\src\config.h \
1212 $(SRC)\w32xfns.c \
1213
1214$(BLD)\w32bdf.obj: \
1215 $(EMACS_ROOT)\src/s\ms-w32.h \
1216 $(EMACS_ROOT)\src/m\intel386.h \
1217 $(EMACS_ROOT)\src/config.h \
1218 $(SRC)\w32bdf.c \
1219 $(SRC)\charset.h \
1220 $(SRC)\frame.h \
1221 $(SRC)\dispextern.h \
1222 $(SRC)\fontset.h \
1223 $(SRC)\blockinput.h \
1224 $(SRC)\w32gui.h \
1225 $(SRC)\w32term.h \
1226 $(SRC)\w32gui.h \
1227 $(SRC)\w32bdf.h \
1228 $(SRC)\w32.h \
1229 $(SRC)\frame.h \
1230 $(SRC)\blockinput.h
1231
1232# arch-tag: ee9a97ba-19b7-4b50-a127-aaf4efe494dc
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 99a04ecc17d..a7efcc4cae5 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1,5 +1,5 @@
1# Makefile for GNU Emacs on the Microsoft W32 API. 1# -*- Makefile -*- for GNU Emacs on the Microsoft W32 API.
2# Copyright (c) 2000-2001 Free Software Foundation, Inc. 2# Copyright (c) 2000-2001, 2004 Free Software Foundation, Inc.
3# 3#
4# This file is part of GNU Emacs. 4# This file is part of GNU Emacs.
5# 5#
@@ -115,8 +115,6 @@ OBJ1 = $(BLD)/abbrev.$(O) \
115 $(BLD)/region-cache.$(O) \ 115 $(BLD)/region-cache.$(O) \
116 $(BLD)/strftime.$(O) \ 116 $(BLD)/strftime.$(O) \
117 $(BLD)/charset.$(O) \ 117 $(BLD)/charset.$(O) \
118 $(BLD)/character.$(O) \
119 $(BLD)/chartab.$(O) \
120 $(BLD)/coding.$(O) \ 118 $(BLD)/coding.$(O) \
121 $(BLD)/category.$(O) \ 119 $(BLD)/category.$(O) \
122 $(BLD)/ccl.$(O) \ 120 $(BLD)/ccl.$(O) \
@@ -124,7 +122,6 @@ OBJ1 = $(BLD)/abbrev.$(O) \
124 $(BLD)/fringe.$(O) \ 122 $(BLD)/fringe.$(O) \
125 $(BLD)/image.$(O) 123 $(BLD)/image.$(O)
126 124
127
128WIN32OBJ = $(BLD)/w32term.$(O) \ 125WIN32OBJ = $(BLD)/w32term.$(O) \
129 $(BLD)/w32xfns.$(O) \ 126 $(BLD)/w32xfns.$(O) \
130 $(BLD)/w32fns.$(O) \ 127 $(BLD)/w32fns.$(O) \
@@ -170,7 +167,7 @@ $(EMACS): $(DOC) $(TEMACS)
170temacs: $(BLD) $(TEMACS) 167temacs: $(BLD) $(TEMACS)
171$(TEMACS): $(TLIB0) $(TLIB1) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES) 168$(TEMACS): $(TLIB0) $(TLIB1) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES)
172 $(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS) 169 $(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
173 "../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 20 170 "../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 16
174 171
175bootstrap: bootstrap-emacs 172bootstrap: bootstrap-emacs
176 173
@@ -265,7 +262,6 @@ $(BLD)/abbrev.$(O) : \
265 $(EMACS_ROOT)/src/m/intel386.h \ 262 $(EMACS_ROOT)/src/m/intel386.h \
266 $(EMACS_ROOT)/src/config.h \ 263 $(EMACS_ROOT)/src/config.h \
267 $(SRC)/buffer.h \ 264 $(SRC)/buffer.h \
268 $(SRC)/character.h \
269 $(SRC)/charset.h \ 265 $(SRC)/charset.h \
270 $(SRC)/commands.h \ 266 $(SRC)/commands.h \
271 $(SRC)/dispextern.h \ 267 $(SRC)/dispextern.h \
@@ -281,7 +277,6 @@ $(BLD)/alloc.$(O) : \
281 $(EMACS_ROOT)/src/config.h \ 277 $(EMACS_ROOT)/src/config.h \
282 $(SRC)/blockinput.h \ 278 $(SRC)/blockinput.h \
283 $(SRC)/buffer.h \ 279 $(SRC)/buffer.h \
284 $(SRC)/character.h \
285 $(SRC)/charset.h \ 280 $(SRC)/charset.h \
286 $(SRC)/composite.h \ 281 $(SRC)/composite.h \
287 $(SRC)/dispextern.h \ 282 $(SRC)/dispextern.h \
@@ -364,7 +359,6 @@ $(BLD)/callproc.$(O) : \
364 $(EMACS_ROOT)/nt/inc/sys/file.h \ 359 $(EMACS_ROOT)/nt/inc/sys/file.h \
365 $(SRC)/buffer.h \ 360 $(SRC)/buffer.h \
366 $(SRC)/ccl.h \ 361 $(SRC)/ccl.h \
367 $(SRC)/character.h \
368 $(SRC)/charset.h \ 362 $(SRC)/charset.h \
369 $(SRC)/coding.h \ 363 $(SRC)/coding.h \
370 $(SRC)/commands.h \ 364 $(SRC)/commands.h \
@@ -381,7 +375,6 @@ $(BLD)/casefiddle.$(O) : \
381 $(EMACS_ROOT)/src/m/intel386.h \ 375 $(EMACS_ROOT)/src/m/intel386.h \
382 $(EMACS_ROOT)/src/config.h \ 376 $(EMACS_ROOT)/src/config.h \
383 $(SRC)/buffer.h \ 377 $(SRC)/buffer.h \
384 $(SRC)/character.h \
385 $(SRC)/charset.h \ 378 $(SRC)/charset.h \
386 $(SRC)/commands.h \ 379 $(SRC)/commands.h \
387 $(SRC)/composite.h \ 380 $(SRC)/composite.h \
@@ -403,7 +396,6 @@ $(BLD)/category.$(O) : \
403 $(EMACS_ROOT)/src/config.h \ 396 $(EMACS_ROOT)/src/config.h \
404 $(SRC)/buffer.h \ 397 $(SRC)/buffer.h \
405 $(SRC)/category.h \ 398 $(SRC)/category.h \
406 $(SRC)/character.h \
407 $(SRC)/charset.h \ 399 $(SRC)/charset.h \
408 $(SRC)/keymap.h 400 $(SRC)/keymap.h
409 401
@@ -413,22 +405,9 @@ $(BLD)/ccl.$(O) : \
413 $(EMACS_ROOT)/src/m/intel386.h \ 405 $(EMACS_ROOT)/src/m/intel386.h \
414 $(EMACS_ROOT)/src/config.h \ 406 $(EMACS_ROOT)/src/config.h \
415 $(SRC)/ccl.h \ 407 $(SRC)/ccl.h \
416 $(SRC)/character.h \
417 $(SRC)/charset.h \ 408 $(SRC)/charset.h \
418 $(SRC)/coding.h 409 $(SRC)/coding.h
419 410
420$(BLD)/character.$(O) : \
421 $(SRC)/character.c \
422 $(EMACS_ROOT)/src/s/ms-w32.h \
423 $(EMACS_ROOT)/src/m/intel386.h \
424 $(EMACS_ROOT)/src/config.h \
425 $(SRC)/buffer.h \
426 $(SRC)/character.h \
427 $(SRC)/charset.h \
428 $(SRC)/coding.h \
429 $(SRC)/composite.h \
430 $(SRC)/disptab.h
431
432$(BLD)/charset.$(O) : \ 411$(BLD)/charset.$(O) : \
433 $(SRC)/charset.c \ 412 $(SRC)/charset.c \
434 $(EMACS_ROOT)/src/s/ms-w32.h \ 413 $(EMACS_ROOT)/src/s/ms-w32.h \
@@ -436,20 +415,11 @@ $(BLD)/charset.$(O) : \
436 $(EMACS_ROOT)/src/config.h \ 415 $(EMACS_ROOT)/src/config.h \
437 $(SRC)/buffer.h \ 416 $(SRC)/buffer.h \
438 $(SRC)/ccl.h \ 417 $(SRC)/ccl.h \
439 $(SRC)/character.h \
440 $(SRC)/charset.h \ 418 $(SRC)/charset.h \
441 $(SRC)/coding.h \ 419 $(SRC)/coding.h \
442 $(SRC)/composite.h \ 420 $(SRC)/composite.h \
443 $(SRC)/disptab.h 421 $(SRC)/disptab.h
444 422
445$(BLD)/chartab.$(O) : \
446 $(SRC)/chartab.c \
447 $(EMACS_ROOT)/src/s/ms-w32.h \
448 $(EMACS_ROOT)/src/m/intel386.h \
449 $(EMACS_ROOT)/src/config.h \
450 $(SRC)/charset.h \
451 $(SRC)/character.h
452
453$(BLD)/cm.$(O) : \ 423$(BLD)/cm.$(O) : \
454 $(SRC)/cm.c \ 424 $(SRC)/cm.c \
455 $(EMACS_ROOT)/src/s/ms-w32.h \ 425 $(EMACS_ROOT)/src/s/ms-w32.h \
@@ -464,7 +434,6 @@ $(BLD)/cmds.$(O) : \
464 $(EMACS_ROOT)/src/m/intel386.h \ 434 $(EMACS_ROOT)/src/m/intel386.h \
465 $(EMACS_ROOT)/src/config.h \ 435 $(EMACS_ROOT)/src/config.h \
466 $(SRC)/buffer.h \ 436 $(SRC)/buffer.h \
467 $(SRC)/character.h \
468 $(SRC)/charset.h \ 437 $(SRC)/charset.h \
469 $(SRC)/commands.h \ 438 $(SRC)/commands.h \
470 $(SRC)/dispextern.h \ 439 $(SRC)/dispextern.h \
@@ -482,7 +451,6 @@ $(BLD)/coding.$(O) : \
482 $(EMACS_ROOT)/src/config.h \ 451 $(EMACS_ROOT)/src/config.h \
483 $(SRC)/buffer.h \ 452 $(SRC)/buffer.h \
484 $(SRC)/ccl.h \ 453 $(SRC)/ccl.h \
485 $(SRC)/character.h \
486 $(SRC)/charset.h \ 454 $(SRC)/charset.h \
487 $(SRC)/coding.h \ 455 $(SRC)/coding.h \
488 $(SRC)/composite.h \ 456 $(SRC)/composite.h \
@@ -498,7 +466,6 @@ $(BLD)/composite.$(O) : \
498 $(EMACS_ROOT)/src/m/intel386.h \ 466 $(EMACS_ROOT)/src/m/intel386.h \
499 $(EMACS_ROOT)/src/config.h \ 467 $(EMACS_ROOT)/src/config.h \
500 $(SRC)/buffer.h \ 468 $(SRC)/buffer.h \
501 $(SRC)/character.h \
502 $(SRC)/charset.h \ 469 $(SRC)/charset.h \
503 $(SRC)/composite.h \ 470 $(SRC)/composite.h \
504 $(SRC)/dispextern.h \ 471 $(SRC)/dispextern.h \
@@ -512,7 +479,6 @@ $(BLD)/data.$(O) : \
512 $(EMACS_ROOT)/src/m/intel386.h \ 479 $(EMACS_ROOT)/src/m/intel386.h \
513 $(EMACS_ROOT)/src/config.h \ 480 $(EMACS_ROOT)/src/config.h \
514 $(SRC)/buffer.h \ 481 $(SRC)/buffer.h \
515 $(SRC)/character.h \
516 $(SRC)/charset.h \ 482 $(SRC)/charset.h \
517 $(SRC)/frame.h \ 483 $(SRC)/frame.h \
518 $(SRC)/keyboard.h \ 484 $(SRC)/keyboard.h \
@@ -526,7 +492,6 @@ $(BLD)/dired.$(O) : \
526 $(EMACS_ROOT)/src/config.h \ 492 $(EMACS_ROOT)/src/config.h \
527 $(SRC)/buffer.h \ 493 $(SRC)/buffer.h \
528 $(SRC)/ccl.h \ 494 $(SRC)/ccl.h \
529 $(SRC)/character.h \
530 $(SRC)/charset.h \ 495 $(SRC)/charset.h \
531 $(SRC)/coding.h \ 496 $(SRC)/coding.h \
532 $(SRC)/commands.h \ 497 $(SRC)/commands.h \
@@ -544,7 +509,6 @@ $(BLD)/dispnew.$(O) : \
544 $(SRC)/atimer.h \ 509 $(SRC)/atimer.h \
545 $(SRC)/blockinput.h \ 510 $(SRC)/blockinput.h \
546 $(SRC)/buffer.h \ 511 $(SRC)/buffer.h \
547 $(SRC)/character.h \
548 $(SRC)/charset.h \ 512 $(SRC)/charset.h \
549 $(SRC)/cm.h \ 513 $(SRC)/cm.h \
550 $(SRC)/commands.h \ 514 $(SRC)/commands.h \
@@ -573,7 +537,6 @@ $(BLD)/doc.$(O) : \
573 $(EMACS_ROOT)/src/config.h \ 537 $(EMACS_ROOT)/src/config.h \
574 $(EMACS_ROOT)/nt/inc/sys/file.h \ 538 $(EMACS_ROOT)/nt/inc/sys/file.h \
575 $(SRC)/buffer.h \ 539 $(SRC)/buffer.h \
576 $(SRC)/character.h \
577 $(SRC)/charset.h \ 540 $(SRC)/charset.h \
578 $(SRC)/keyboard.h \ 541 $(SRC)/keyboard.h \
579 $(SRC)/keymap.h 542 $(SRC)/keymap.h
@@ -583,7 +546,6 @@ $(BLD)/doprnt.$(O) : \
583 $(EMACS_ROOT)/src/s/ms-w32.h \ 546 $(EMACS_ROOT)/src/s/ms-w32.h \
584 $(EMACS_ROOT)/src/m/intel386.h \ 547 $(EMACS_ROOT)/src/m/intel386.h \
585 $(EMACS_ROOT)/src/config.h \ 548 $(EMACS_ROOT)/src/config.h \
586 $(SRC)/character.h \
587 $(SRC)/charset.c 549 $(SRC)/charset.c
588 550
589$(BLD)/editfns.$(O) : \ 551$(BLD)/editfns.$(O) : \
@@ -594,7 +556,6 @@ $(BLD)/editfns.$(O) : \
594 $(EMACS_ROOT)/nt/inc/pwd.h \ 556 $(EMACS_ROOT)/nt/inc/pwd.h \
595 $(SRC)/buffer.h \ 557 $(SRC)/buffer.h \
596 $(SRC)/ccl.h \ 558 $(SRC)/ccl.h \
597 $(SRC)/character.h \
598 $(SRC)/charset.h \ 559 $(SRC)/charset.h \
599 $(SRC)/coding.h \ 560 $(SRC)/coding.h \
600 $(SRC)/composite.h \ 561 $(SRC)/composite.h \
@@ -655,7 +616,6 @@ $(BLD)/fileio.$(O) : \
655 $(EMACS_ROOT)/nt/inc/sys/file.h \ 616 $(EMACS_ROOT)/nt/inc/sys/file.h \
656 $(SRC)/buffer.h \ 617 $(SRC)/buffer.h \
657 $(SRC)/ccl.h \ 618 $(SRC)/ccl.h \
658 $(SRC)/character.h \
659 $(SRC)/charset.h \ 619 $(SRC)/charset.h \
660 $(SRC)/coding.h \ 620 $(SRC)/coding.h \
661 $(SRC)/commands.h \ 621 $(SRC)/commands.h \
@@ -677,7 +637,6 @@ $(BLD)/filelock.$(O) : \
677 $(EMACS_ROOT)/src/epaths.h \ 637 $(EMACS_ROOT)/src/epaths.h \
678 $(SRC)/buffer.h \ 638 $(SRC)/buffer.h \
679 $(SRC)/ccl.h \ 639 $(SRC)/ccl.h \
680 $(SRC)/character.h \
681 $(SRC)/charset.h \ 640 $(SRC)/charset.h \
682 $(SRC)/coding.h \ 641 $(SRC)/coding.h \
683 $(SRC)/systime.h 642 $(SRC)/systime.h
@@ -713,7 +672,6 @@ $(BLD)/fns.$(O) : \
713 $(SRC)/blockinput.h \ 672 $(SRC)/blockinput.h \
714 $(SRC)/buffer.h \ 673 $(SRC)/buffer.h \
715 $(SRC)/ccl.h \ 674 $(SRC)/ccl.h \
716 $(SRC)/character.h \
717 $(SRC)/charset.h \ 675 $(SRC)/charset.h \
718 $(SRC)/coding.h \ 676 $(SRC)/coding.h \
719 $(SRC)/commands.h \ 677 $(SRC)/commands.h \
@@ -736,7 +694,6 @@ $(BLD)/fontset.$(O) : \
736 $(EMACS_ROOT)/src/config.h \ 694 $(EMACS_ROOT)/src/config.h \
737 $(SRC)/buffer.h \ 695 $(SRC)/buffer.h \
738 $(SRC)/ccl.h \ 696 $(SRC)/ccl.h \
739 $(SRC)/character.h \
740 $(SRC)/charset.h \ 697 $(SRC)/charset.h \
741 $(SRC)/dispextern.h \ 698 $(SRC)/dispextern.h \
742 $(SRC)/fontset.h \ 699 $(SRC)/fontset.h \
@@ -754,7 +711,6 @@ $(BLD)/frame.$(O) : \
754 $(SRC)/atimer.h \ 711 $(SRC)/atimer.h \
755 $(SRC)/blockinput.h \ 712 $(SRC)/blockinput.h \
756 $(SRC)/buffer.h \ 713 $(SRC)/buffer.h \
757 $(SRC)/character.h \
758 $(SRC)/charset.h \ 714 $(SRC)/charset.h \
759 $(SRC)/commands.h \ 715 $(SRC)/commands.h \
760 $(SRC)/dispextern.h \ 716 $(SRC)/dispextern.h \
@@ -816,7 +772,6 @@ $(BLD)/indent.$(O) : \
816 $(EMACS_ROOT)/src/config.h \ 772 $(EMACS_ROOT)/src/config.h \
817 $(SRC)/buffer.h \ 773 $(SRC)/buffer.h \
818 $(SRC)/category.h \ 774 $(SRC)/category.h \
819 $(SRC)/character.h \
820 $(SRC)/charset.h \ 775 $(SRC)/charset.h \
821 $(SRC)/composite.h \ 776 $(SRC)/composite.h \
822 $(SRC)/dispextern.h \ 777 $(SRC)/dispextern.h \
@@ -840,7 +795,6 @@ $(BLD)/insdel.$(O) : \
840 $(SRC)/atimer.h \ 795 $(SRC)/atimer.h \
841 $(SRC)/blockinput.h \ 796 $(SRC)/blockinput.h \
842 $(SRC)/buffer.h \ 797 $(SRC)/buffer.h \
843 $(SRC)/character.h \
844 $(SRC)/charset.h \ 798 $(SRC)/charset.h \
845 $(SRC)/composite.h \ 799 $(SRC)/composite.h \
846 $(SRC)/dispextern.h \ 800 $(SRC)/dispextern.h \
@@ -876,7 +830,6 @@ $(BLD)/keyboard.$(O) : \
876 $(SRC)/atimer.h \ 830 $(SRC)/atimer.h \
877 $(SRC)/blockinput.h \ 831 $(SRC)/blockinput.h \
878 $(SRC)/buffer.h \ 832 $(SRC)/buffer.h \
879 $(SRC)/character.h \
880 $(SRC)/charset.h \ 833 $(SRC)/charset.h \
881 $(SRC)/commands.h \ 834 $(SRC)/commands.h \
882 $(SRC)/composite.h \ 835 $(SRC)/composite.h \
@@ -908,7 +861,6 @@ $(BLD)/keymap.$(O) : \
908 $(SRC)/atimer.h \ 861 $(SRC)/atimer.h \
909 $(SRC)/blockinput.h \ 862 $(SRC)/blockinput.h \
910 $(SRC)/buffer.h \ 863 $(SRC)/buffer.h \
911 $(SRC)/character.h \
912 $(SRC)/charset.h \ 864 $(SRC)/charset.h \
913 $(SRC)/commands.h \ 865 $(SRC)/commands.h \
914 $(SRC)/composite.h \ 866 $(SRC)/composite.h \
@@ -937,7 +889,6 @@ $(BLD)/lread.$(O) : \
937 $(EMACS_ROOT)/src/epaths.h \ 889 $(EMACS_ROOT)/src/epaths.h \
938 $(SRC)/buffer.h \ 890 $(SRC)/buffer.h \
939 $(SRC)/ccl.h \ 891 $(SRC)/ccl.h \
940 $(SRC)/character.h \
941 $(SRC)/charset.h \ 892 $(SRC)/charset.h \
942 $(SRC)/coding.h \ 893 $(SRC)/coding.h \
943 $(SRC)/commands.h \ 894 $(SRC)/commands.h \
@@ -969,7 +920,6 @@ $(BLD)/marker.$(O) : \
969 $(EMACS_ROOT)/src/m/intel386.h \ 920 $(EMACS_ROOT)/src/m/intel386.h \
970 $(EMACS_ROOT)/src/config.h \ 921 $(EMACS_ROOT)/src/config.h \
971 $(SRC)/buffer.h \ 922 $(SRC)/buffer.h \
972 $(SRC)/character.h \
973 $(SRC)/charset.h 923 $(SRC)/charset.h
974 924
975$(BLD)/md5.$(O) : \ 925$(BLD)/md5.$(O) : \
@@ -982,7 +932,6 @@ $(BLD)/minibuf.$(O) : \
982 $(EMACS_ROOT)/src/m/intel386.h \ 932 $(EMACS_ROOT)/src/m/intel386.h \
983 $(EMACS_ROOT)/src/config.h \ 933 $(EMACS_ROOT)/src/config.h \
984 $(SRC)/buffer.h \ 934 $(SRC)/buffer.h \
985 $(SRC)/character.h \
986 $(SRC)/charset.h \ 935 $(SRC)/charset.h \
987 $(SRC)/commands.h \ 936 $(SRC)/commands.h \
988 $(SRC)/composite.h \ 937 $(SRC)/composite.h \
@@ -1050,7 +999,6 @@ $(BLD)/w32console.$(O) : \
1050 $(SRC)/s/ms-w32.h \ 999 $(SRC)/s/ms-w32.h \
1051 $(SRC)/m/intel386.h \ 1000 $(SRC)/m/intel386.h \
1052 $(SRC)/ccl.h \ 1001 $(SRC)/ccl.h \
1053 $(SRC)/character.h \
1054 $(SRC)/charset.h \ 1002 $(SRC)/charset.h \
1055 $(SRC)/coding.h \ 1003 $(SRC)/coding.h \
1056 $(SRC)/config.h \ 1004 $(SRC)/config.h \
@@ -1068,7 +1016,6 @@ $(BLD)/print.$(O) : \
1068 $(EMACS_ROOT)/src/m/intel386.h \ 1016 $(EMACS_ROOT)/src/m/intel386.h \
1069 $(EMACS_ROOT)/src/config.h \ 1017 $(EMACS_ROOT)/src/config.h \
1070 $(SRC)/buffer.h \ 1018 $(SRC)/buffer.h \
1071 $(SRC)/character.h \
1072 $(SRC)/charset.h \ 1019 $(SRC)/charset.h \
1073 $(SRC)/composite.h \ 1020 $(SRC)/composite.h \
1074 $(SRC)/dispextern.h \ 1021 $(SRC)/dispextern.h \
@@ -1092,7 +1039,6 @@ $(BLD)/process.$(O) : \
1092 $(SRC)/blockinput.h \ 1039 $(SRC)/blockinput.h \
1093 $(SRC)/buffer.h \ 1040 $(SRC)/buffer.h \
1094 $(SRC)/ccl.h \ 1041 $(SRC)/ccl.h \
1095 $(SRC)/character.h \
1096 $(SRC)/charset.h \ 1042 $(SRC)/charset.h \
1097 $(SRC)/coding.h \ 1043 $(SRC)/coding.h \
1098 $(SRC)/commands.h \ 1044 $(SRC)/commands.h \
@@ -1132,7 +1078,6 @@ $(BLD)/regex.$(O) : \
1132 $(SRC)/m/intel386.h \ 1078 $(SRC)/m/intel386.h \
1133 $(SRC)/buffer.h \ 1079 $(SRC)/buffer.h \
1134 $(SRC)/category.h \ 1080 $(SRC)/category.h \
1135 $(SRC)/character.h \
1136 $(SRC)/charset.h \ 1081 $(SRC)/charset.h \
1137 $(SRC)/config.h \ 1082 $(SRC)/config.h \
1138 $(SRC)/regex.h \ 1083 $(SRC)/regex.h \
@@ -1168,7 +1113,6 @@ $(BLD)/search.$(O) : \
1168 $(SRC)/blockinput.h \ 1113 $(SRC)/blockinput.h \
1169 $(SRC)/buffer.h \ 1114 $(SRC)/buffer.h \
1170 $(SRC)/category.h \ 1115 $(SRC)/category.h \
1171 $(SRC)/character.h \
1172 $(SRC)/charset.h \ 1116 $(SRC)/charset.h \
1173 $(SRC)/commands.h \ 1117 $(SRC)/commands.h \
1174 $(SRC)/composite.h \ 1118 $(SRC)/composite.h \
@@ -1201,7 +1145,6 @@ $(BLD)/syntax.$(O) : \
1201 $(EMACS_ROOT)/src/config.h \ 1145 $(EMACS_ROOT)/src/config.h \
1202 $(SRC)/buffer.h \ 1146 $(SRC)/buffer.h \
1203 $(SRC)/category.h \ 1147 $(SRC)/category.h \
1204 $(SRC)/character.h \
1205 $(SRC)/charset.h \ 1148 $(SRC)/charset.h \
1206 $(SRC)/commands.h \ 1149 $(SRC)/commands.h \
1207 $(SRC)/composite.h \ 1150 $(SRC)/composite.h \
@@ -1246,7 +1189,6 @@ $(BLD)/term.$(O) : \
1246 $(EMACS_ROOT)/src/m/intel386.h \ 1189 $(EMACS_ROOT)/src/m/intel386.h \
1247 $(EMACS_ROOT)/src/config.h \ 1190 $(EMACS_ROOT)/src/config.h \
1248 $(SRC)/ccl.h \ 1191 $(SRC)/ccl.h \
1249 $(SRC)/character.h \
1250 $(SRC)/charset.h \ 1192 $(SRC)/charset.h \
1251 $(SRC)/cm.h \ 1193 $(SRC)/cm.h \
1252 $(SRC)/coding.h \ 1194 $(SRC)/coding.h \
@@ -1343,7 +1285,6 @@ $(BLD)/xdisp.$(O) : \
1343 $(SRC)/blockinput.h \ 1285 $(SRC)/blockinput.h \
1344 $(SRC)/buffer.h \ 1286 $(SRC)/buffer.h \
1345 $(SRC)/ccl.h \ 1287 $(SRC)/ccl.h \
1346 $(SRC)/character.h \
1347 $(SRC)/charset.h \ 1288 $(SRC)/charset.h \
1348 $(SRC)/coding.h \ 1289 $(SRC)/coding.h \
1349 $(SRC)/commands.h \ 1290 $(SRC)/commands.h \
@@ -1375,7 +1316,6 @@ $(BLD)/xfaces.$(O): \
1375 $(SRC)/atimer.h \ 1316 $(SRC)/atimer.h \
1376 $(SRC)/blockinput.h \ 1317 $(SRC)/blockinput.h \
1377 $(SRC)/buffer.h \ 1318 $(SRC)/buffer.h \
1378 $(SRC)/character.h \
1379 $(SRC)/charset.h \ 1319 $(SRC)/charset.h \
1380 $(SRC)/composite.h \ 1320 $(SRC)/composite.h \
1381 $(SRC)/dispextern.h \ 1321 $(SRC)/dispextern.h \
@@ -1398,7 +1338,6 @@ $(BLD)/w32fns.$(O): \
1398 $(SRC)/blockinput.h \ 1338 $(SRC)/blockinput.h \
1399 $(SRC)/buffer.h \ 1339 $(SRC)/buffer.h \
1400 $(SRC)/ccl.h \ 1340 $(SRC)/ccl.h \
1401 $(SRC)/character.h \
1402 $(SRC)/charset.h \ 1341 $(SRC)/charset.h \
1403 $(SRC)/coding.h \ 1342 $(SRC)/coding.h \
1404 $(SRC)/composite.h \ 1343 $(SRC)/composite.h \
@@ -1424,7 +1363,6 @@ $(BLD)/w32menu.$(O): \
1424 $(SRC)/atimer.h \ 1363 $(SRC)/atimer.h \
1425 $(SRC)/blockinput.h \ 1364 $(SRC)/blockinput.h \
1426 $(SRC)/buffer.h \ 1365 $(SRC)/buffer.h \
1427 $(SRC)/character.h \
1428 $(SRC)/charset.h \ 1366 $(SRC)/charset.h \
1429 $(SRC)/coding.h \ 1367 $(SRC)/coding.h \
1430 $(SRC)/dispextern.h \ 1368 $(SRC)/dispextern.h \
@@ -1447,7 +1385,6 @@ $(BLD)/w32term.$(O): \
1447 $(SRC)/blockinput.h \ 1385 $(SRC)/blockinput.h \
1448 $(SRC)/buffer.h \ 1386 $(SRC)/buffer.h \
1449 $(SRC)/ccl.h \ 1387 $(SRC)/ccl.h \
1450 $(SRC)/character.h \
1451 $(SRC)/charset.h \ 1388 $(SRC)/charset.h \
1452 $(SRC)/coding.h \ 1389 $(SRC)/coding.h \
1453 $(SRC)/composite.h \ 1390 $(SRC)/composite.h \
@@ -1479,7 +1416,6 @@ $(BLD)/w32select.$(O): \
1479 $(SRC)/blockinput.h \ 1416 $(SRC)/blockinput.h \
1480 $(SRC)/buffer.h \ 1417 $(SRC)/buffer.h \
1481 $(SRC)/ccl.h \ 1418 $(SRC)/ccl.h \
1482 $(SRC)/character.h \
1483 $(SRC)/charset.h \ 1419 $(SRC)/charset.h \
1484 $(SRC)/coding.h \ 1420 $(SRC)/coding.h \
1485 $(SRC)/composite.h \ 1421 $(SRC)/composite.h \
@@ -1510,7 +1446,6 @@ $(BLD)/w32xfns.$(O): \
1510 $(EMACS_ROOT)/src/config.h \ 1446 $(EMACS_ROOT)/src/config.h \
1511 $(SRC)/atimer.h \ 1447 $(SRC)/atimer.h \
1512 $(SRC)/blockinput.h \ 1448 $(SRC)/blockinput.h \
1513 $(SRC)/character.h \
1514 $(SRC)/charset.h \ 1449 $(SRC)/charset.h \
1515 $(SRC)/fontset.h \ 1450 $(SRC)/fontset.h \
1516 $(SRC)/frame.h \ 1451 $(SRC)/frame.h \
@@ -1527,7 +1462,6 @@ $(BLD)/w32bdf.$(O): \
1527 $(EMACS_ROOT)/src/config.h \ 1462 $(EMACS_ROOT)/src/config.h \
1528 $(SRC)/atimer.h \ 1463 $(SRC)/atimer.h \
1529 $(SRC)/blockinput.h \ 1464 $(SRC)/blockinput.h \
1530 $(SRC)/character.h \
1531 $(SRC)/charset.h \ 1465 $(SRC)/charset.h \
1532 $(SRC)/dispextern.h \ 1466 $(SRC)/dispextern.h \
1533 $(SRC)/fontset.h \ 1467 $(SRC)/fontset.h \
@@ -1537,5 +1471,3 @@ $(BLD)/w32bdf.$(O): \
1537 $(SRC)/w32bdf.h \ 1471 $(SRC)/w32bdf.h \
1538 $(SRC)/w32gui.h \ 1472 $(SRC)/w32gui.h \
1539 $(SRC)/w32term.h 1473 $(SRC)/w32term.h
1540
1541# arch-tag: 9fd7aba8-f826-4111-b3c0-497a8e7db9a0
diff --git a/src/mem-limits.h b/src/mem-limits.h
index 578cf59f12e..57a79863a1b 100644
--- a/src/mem-limits.h
+++ b/src/mem-limits.h
@@ -1,5 +1,5 @@
1/* Includes for memory limit warnings. 1/* Includes for memory limit warnings.
2 Copyright (C) 1990, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. 2 Copyright (C) 1990, 93, 94, 95, 1996, 2004 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -81,7 +81,9 @@ typedef unsigned long SIZE;
81#define NULL ((POINTER) 0) 81#define NULL ((POINTER) 0)
82 82
83extern POINTER start_of_data (); 83extern POINTER start_of_data ();
84#ifdef DATA_SEG_BITS 84#if defined USE_LSB_TAG
85#define EXCEEDS_LISP_PTR(ptr) 0
86#elif defined DATA_SEG_BITS
85#define EXCEEDS_LISP_PTR(ptr) \ 87#define EXCEEDS_LISP_PTR(ptr) \
86 (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS) 88 (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
87#else 89#else
diff --git a/src/minibuf.c b/src/minibuf.c
index 2feac10f2b7..a313016154e 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1,5 +1,5 @@
1/* Minibuffer input and completion. 1/* Minibuffer input and completion.
2 Copyright (C) 1985,86,93,94,95,96,97,98,99,2000,01,03 2 Copyright (C) 1985,86,93,94,95,96,97,98,99,2000,01,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -209,6 +209,7 @@ without invoking the usual minibuffer commands. */)
209/* Actual minibuffer invocation. */ 209/* Actual minibuffer invocation. */
210 210
211static Lisp_Object read_minibuf_unwind P_ ((Lisp_Object)); 211static Lisp_Object read_minibuf_unwind P_ ((Lisp_Object));
212static Lisp_Object run_exit_minibuf_hook P_ ((Lisp_Object));
212static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object, 213static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object,
213 Lisp_Object, Lisp_Object, 214 Lisp_Object, Lisp_Object,
214 int, Lisp_Object, 215 int, Lisp_Object,
@@ -563,6 +564,12 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
563 564
564 record_unwind_protect (read_minibuf_unwind, Qnil); 565 record_unwind_protect (read_minibuf_unwind, Qnil);
565 minibuf_level++; 566 minibuf_level++;
567 /* We are exiting the minibuffer one way or the other, so run the hook.
568 It should be run before unwinding the minibuf settings. Do it
569 separately from read_minibuf_unwind because we need to make sure that
570 read_minibuf_unwind is fully executed even if exit-minibuffer-hook
571 signals an error. --Stef */
572 record_unwind_protect (run_exit_minibuf_hook, Qnil);
566 573
567 /* Now that we can restore all those variables, start changing them. */ 574 /* Now that we can restore all those variables, start changing them. */
568 575
@@ -822,6 +829,17 @@ get_minibuffer (depth)
822 return buf; 829 return buf;
823} 830}
824 831
832static Lisp_Object
833run_exit_minibuf_hook (data)
834 Lisp_Object data;
835{
836 if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound)
837 && !NILP (Vrun_hooks))
838 safe_run_hooks (Qminibuffer_exit_hook);
839
840 return Qnil;
841}
842
825/* This function is called on exiting minibuffer, whether normally or 843/* This function is called on exiting minibuffer, whether normally or
826 not, and it restores the current window, buffer, etc. */ 844 not, and it restores the current window, buffer, etc. */
827 845
@@ -832,12 +850,6 @@ read_minibuf_unwind (data)
832 Lisp_Object old_deactivate_mark; 850 Lisp_Object old_deactivate_mark;
833 Lisp_Object window; 851 Lisp_Object window;
834 852
835 /* We are exiting the minibuffer one way or the other,
836 so run the hook. */
837 if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound)
838 && !NILP (Vrun_hooks))
839 safe_run_hooks (Qminibuffer_exit_hook);
840
841 /* If this was a recursive minibuffer, 853 /* If this was a recursive minibuffer,
842 tie the minibuffer window back to the outer level minibuffer buffer. */ 854 tie the minibuffer window back to the outer level minibuffer buffer. */
843 minibuf_level--; 855 minibuf_level--;
@@ -1195,6 +1207,7 @@ is used to further constrain the set of candidates. */)
1195 || NILP (XCAR (alist)))); 1207 || NILP (XCAR (alist))));
1196 int index = 0, obsize = 0; 1208 int index = 0, obsize = 0;
1197 int matchcount = 0; 1209 int matchcount = 0;
1210 int bindcount = -1;
1198 Lisp_Object bucket, zero, end, tem; 1211 Lisp_Object bucket, zero, end, tem;
1199 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1212 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1200 1213
@@ -1274,16 +1287,18 @@ is used to further constrain the set of candidates. */)
1274 1287
1275 /* Ignore this element if it fails to match all the regexps. */ 1288 /* Ignore this element if it fails to match all the regexps. */
1276 { 1289 {
1277 int count = SPECPDL_INDEX ();
1278 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
1279 for (regexps = Vcompletion_regexp_list; CONSP (regexps); 1290 for (regexps = Vcompletion_regexp_list; CONSP (regexps);
1280 regexps = XCDR (regexps)) 1291 regexps = XCDR (regexps))
1281 { 1292 {
1293 if (bindcount < 0) {
1294 bindcount = SPECPDL_INDEX ();
1295 specbind (Qcase_fold_search,
1296 completion_ignore_case ? Qt : Qnil);
1297 }
1282 tem = Fstring_match (XCAR (regexps), eltstring, zero); 1298 tem = Fstring_match (XCAR (regexps), eltstring, zero);
1283 if (NILP (tem)) 1299 if (NILP (tem))
1284 break; 1300 break;
1285 } 1301 }
1286 unbind_to (count, Qnil);
1287 if (CONSP (regexps)) 1302 if (CONSP (regexps))
1288 continue; 1303 continue;
1289 } 1304 }
@@ -1297,6 +1312,10 @@ is used to further constrain the set of candidates. */)
1297 tem = Fcommandp (elt, Qnil); 1312 tem = Fcommandp (elt, Qnil);
1298 else 1313 else
1299 { 1314 {
1315 if (bindcount >= 0) {
1316 unbind_to (bindcount, Qnil);
1317 bindcount = -1;
1318 }
1300 GCPRO4 (tail, string, eltstring, bestmatch); 1319 GCPRO4 (tail, string, eltstring, bestmatch);
1301 tem = type == 3 1320 tem = type == 3
1302 ? call2 (predicate, elt, 1321 ? call2 (predicate, elt,
@@ -1378,6 +1397,11 @@ is used to further constrain the set of candidates. */)
1378 } 1397 }
1379 } 1398 }
1380 1399
1400 if (bindcount >= 0) {
1401 unbind_to (bindcount, Qnil);
1402 bindcount = -1;
1403 }
1404
1381 if (NILP (bestmatch)) 1405 if (NILP (bestmatch))
1382 return Qnil; /* No completions found */ 1406 return Qnil; /* No completions found */
1383 /* If we are ignoring case, and there is no exact match, 1407 /* If we are ignoring case, and there is no exact match,
@@ -1440,6 +1464,7 @@ are ignored unless STRING itself starts with a space. */)
1440 && (!SYMBOLP (XCAR (alist)) 1464 && (!SYMBOLP (XCAR (alist))
1441 || NILP (XCAR (alist)))); 1465 || NILP (XCAR (alist))));
1442 int index = 0, obsize = 0; 1466 int index = 0, obsize = 0;
1467 int bindcount = -1;
1443 Lisp_Object bucket, tem; 1468 Lisp_Object bucket, tem;
1444 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1469 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1445 1470
@@ -1525,16 +1550,18 @@ are ignored unless STRING itself starts with a space. */)
1525 1550
1526 /* Ignore this element if it fails to match all the regexps. */ 1551 /* Ignore this element if it fails to match all the regexps. */
1527 { 1552 {
1528 int count = SPECPDL_INDEX ();
1529 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
1530 for (regexps = Vcompletion_regexp_list; CONSP (regexps); 1553 for (regexps = Vcompletion_regexp_list; CONSP (regexps);
1531 regexps = XCDR (regexps)) 1554 regexps = XCDR (regexps))
1532 { 1555 {
1556 if (bindcount < 0) {
1557 bindcount = SPECPDL_INDEX ();
1558 specbind (Qcase_fold_search,
1559 completion_ignore_case ? Qt : Qnil);
1560 }
1533 tem = Fstring_match (XCAR (regexps), eltstring, zero); 1561 tem = Fstring_match (XCAR (regexps), eltstring, zero);
1534 if (NILP (tem)) 1562 if (NILP (tem))
1535 break; 1563 break;
1536 } 1564 }
1537 unbind_to (count, Qnil);
1538 if (CONSP (regexps)) 1565 if (CONSP (regexps))
1539 continue; 1566 continue;
1540 } 1567 }
@@ -1548,6 +1575,10 @@ are ignored unless STRING itself starts with a space. */)
1548 tem = Fcommandp (elt, Qnil); 1575 tem = Fcommandp (elt, Qnil);
1549 else 1576 else
1550 { 1577 {
1578 if (bindcount >= 0) {
1579 unbind_to (bindcount, Qnil);
1580 bindcount = -1;
1581 }
1551 GCPRO4 (tail, eltstring, allmatches, string); 1582 GCPRO4 (tail, eltstring, allmatches, string);
1552 tem = type == 3 1583 tem = type == 3
1553 ? call2 (predicate, elt, 1584 ? call2 (predicate, elt,
@@ -1562,6 +1593,11 @@ are ignored unless STRING itself starts with a space. */)
1562 } 1593 }
1563 } 1594 }
1564 1595
1596 if (bindcount >= 0) {
1597 unbind_to (bindcount, Qnil);
1598 bindcount = -1;
1599 }
1600
1565 return Fnreverse (allmatches); 1601 return Fnreverse (allmatches);
1566} 1602}
1567 1603
@@ -1602,7 +1638,7 @@ HIST, if non-nil, specifies a history list and optionally the initial
1602 is the initial position (the position in the list used by the 1638 is the initial position (the position in the list used by the
1603 minibuffer history commands). For consistency, you should also 1639 minibuffer history commands). For consistency, you should also
1604 specify that element of the history as the value of 1640 specify that element of the history as the value of
1605 INITIAL-CONTENTS. (This is the only case in which you should use 1641 INITIAL-INPUT. (This is the only case in which you should use
1606 INITIAL-INPUT instead of DEF.) Positions are counted starting from 1642 INITIAL-INPUT instead of DEF.) Positions are counted starting from
1607 1 at the beginning of the list. The variable `history-length' 1643 1 at the beginning of the list. The variable `history-length'
1608 controls the maximum length of a history list. 1644 controls the maximum length of a history list.
@@ -1772,19 +1808,20 @@ the values STRING, PREDICATE and `lambda'. */)
1772 return call3 (alist, string, predicate, Qlambda); 1808 return call3 (alist, string, predicate, Qlambda);
1773 1809
1774 /* Reject this element if it fails to match all the regexps. */ 1810 /* Reject this element if it fails to match all the regexps. */
1775 { 1811 if (CONSP (Vcompletion_regexp_list))
1776 int count = SPECPDL_INDEX (); 1812 {
1777 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); 1813 int count = SPECPDL_INDEX ();
1778 for (regexps = Vcompletion_regexp_list; CONSP (regexps); 1814 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
1779 regexps = XCDR (regexps)) 1815 for (regexps = Vcompletion_regexp_list; CONSP (regexps);
1780 { 1816 regexps = XCDR (regexps))
1781 if (NILP (Fstring_match (XCAR (regexps), 1817 {
1782 SYMBOLP (tem) ? string : tem, 1818 if (NILP (Fstring_match (XCAR (regexps),
1783 Qnil))) 1819 SYMBOLP (tem) ? string : tem,
1784 return unbind_to (count, Qnil); 1820 Qnil)))
1785 } 1821 return unbind_to (count, Qnil);
1786 unbind_to (count, Qnil); 1822 }
1787 } 1823 unbind_to (count, Qnil);
1824 }
1788 1825
1789 /* Finally, check the predicate. */ 1826 /* Finally, check the predicate. */
1790 if (!NILP (predicate)) 1827 if (!NILP (predicate))
diff --git a/src/msdos.c b/src/msdos.c
index c4e9197ab49..d0de02aba3f 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -40,6 +40,7 @@ Boston, MA 02111-1307, USA. */
40#include <unistd.h> /* for chdir, dup, dup2, etc. */ 40#include <unistd.h> /* for chdir, dup, dup2, etc. */
41#include <dir.h> /* for getdisk */ 41#include <dir.h> /* for getdisk */
42#if __DJGPP__ >= 2 42#if __DJGPP__ >= 2
43#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */
43#include <fcntl.h> 44#include <fcntl.h>
44#include <io.h> /* for setmode */ 45#include <io.h> /* for setmode */
45#include <dpmi.h> /* for __dpmi_xxx stuff */ 46#include <dpmi.h> /* for __dpmi_xxx stuff */
@@ -950,8 +951,8 @@ static void
950IT_write_glyphs (struct glyph *str, int str_len) 951IT_write_glyphs (struct glyph *str, int str_len)
951{ 952{
952 unsigned char *screen_buf, *screen_bp, *screen_buf_end, *bp; 953 unsigned char *screen_buf, *screen_bp, *screen_buf_end, *bp;
953 int unsupported_face = FAST_GLYPH_FACE (Vdos_unsupported_char_glyph); 954 int unsupported_face = 0;
954 unsigned unsupported_char= FAST_GLYPH_CHAR (Vdos_unsupported_char_glyph); 955 unsigned unsupported_char = '\177';
955 int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); 956 int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
956 register int sl = str_len; 957 register int sl = str_len;
957 register int tlen = GLYPH_TABLE_LENGTH; 958 register int tlen = GLYPH_TABLE_LENGTH;
@@ -977,6 +978,13 @@ IT_write_glyphs (struct glyph *str, int str_len)
977 978
978 if (str_len <= 0) return; 979 if (str_len <= 0) return;
979 980
981 /* Set up the unsupported character glyph */
982 if (!NILP (Vdos_unsupported_char_glyph))
983 {
984 unsupported_char = FAST_GLYPH_CHAR (XINT (Vdos_unsupported_char_glyph));
985 unsupported_face = FAST_GLYPH_FACE (XINT (Vdos_unsupported_char_glyph));
986 }
987
980 screen_buf = screen_bp = alloca (str_len * 2); 988 screen_buf = screen_bp = alloca (str_len * 2);
981 screen_buf_end = screen_buf + str_len * 2; 989 screen_buf_end = screen_buf + str_len * 2;
982 sf = SELECTED_FRAME(); 990 sf = SELECTED_FRAME();
@@ -1041,7 +1049,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
1041 if (! CHAR_VALID_P (ch, 0)) 1049 if (! CHAR_VALID_P (ch, 0))
1042 { 1050 {
1043 g = !NILP (Vdos_unsupported_char_glyph) 1051 g = !NILP (Vdos_unsupported_char_glyph)
1044 ? Vdos_unsupported_char_glyph 1052 ? XINT (Vdos_unsupported_char_glyph)
1045 : MAKE_GLYPH (sf, '\177', GLYPH_FACE (sf, g)); 1053 : MAKE_GLYPH (sf, '\177', GLYPH_FACE (sf, g));
1046 ch = FAST_GLYPH_CHAR (g); 1054 ch = FAST_GLYPH_CHAR (g);
1047 } 1055 }
@@ -1571,7 +1579,7 @@ IT_note_mouse_highlight (struct frame *f, int x, int y)
1571 { 1579 {
1572 extern Lisp_Object Qmouse_face; 1580 extern Lisp_Object Qmouse_face;
1573 Lisp_Object mouse_face, overlay, position, *overlay_vec; 1581 Lisp_Object mouse_face, overlay, position, *overlay_vec;
1574 int len, noverlays, obegv, ozv;; 1582 int noverlays, obegv, ozv;;
1575 struct buffer *obuf; 1583 struct buffer *obuf;
1576 1584
1577 /* If we get an out-of-range value, return now; avoid an error. */ 1585 /* If we get an out-of-range value, return now; avoid an error. */
@@ -1590,20 +1598,8 @@ IT_note_mouse_highlight (struct frame *f, int x, int y)
1590 /* Is this char mouse-active or does it have help-echo? */ 1598 /* Is this char mouse-active or does it have help-echo? */
1591 XSETINT (position, pos); 1599 XSETINT (position, pos);
1592 1600
1593 /* Put all the overlays we want in a vector in overlay_vec. 1601 /* Put all the overlays we want in a vector in overlay_vec. */
1594 Store the length in len. If there are more than 10, make 1602 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
1595 enough space for all, and try again. */
1596 len = 10;
1597 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
1598 noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL, 0);
1599 if (noverlays > len)
1600 {
1601 len = noverlays;
1602 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
1603 noverlays = overlays_at (pos,
1604 0, &overlay_vec, &len, NULL, NULL, 0);
1605 }
1606
1607 /* Sort overlays into increasing priority order. */ 1603 /* Sort overlays into increasing priority order. */
1608 noverlays = sort_overlays (overlay_vec, noverlays, w); 1604 noverlays = sort_overlays (overlay_vec, noverlays, w);
1609 1605
@@ -4408,9 +4404,28 @@ init_environment (argc, argv, skip_args)
4408 for (i = 0; i < imax ; i++) 4404 for (i = 0; i < imax ; i++)
4409 { 4405 {
4410 const char *tmp = tempdirs[i]; 4406 const char *tmp = tempdirs[i];
4407 char buf[FILENAME_MAX];
4411 4408
4412 if (*tmp == '$') 4409 if (*tmp == '$')
4413 tmp = getenv (tmp + 1); 4410 {
4411 int tmp_len;
4412
4413 tmp = getenv (tmp + 1);
4414 if (!tmp)
4415 continue;
4416
4417 /* Some lusers set TMPDIR=e:, probably because some losing
4418 programs cannot handle multiple slashes if they use e:/.
4419 e: fails in `access' below, so we interpret e: as e:/. */
4420 tmp_len = strlen(tmp);
4421 if (tmp[tmp_len - 1] != '/' && tmp[tmp_len - 1] != '\\')
4422 {
4423 strcpy(buf, tmp);
4424 buf[tmp_len++] = '/', buf[tmp_len] = 0;
4425 tmp = buf;
4426 }
4427 }
4428
4414 /* Note that `access' can lie to us if the directory resides on a 4429 /* Note that `access' can lie to us if the directory resides on a
4415 read-only filesystem, like CD-ROM or a write-protected floppy. 4430 read-only filesystem, like CD-ROM or a write-protected floppy.
4416 The only way to be really sure is to actually create a file and 4431 The only way to be really sure is to actually create a file and
@@ -5272,7 +5287,7 @@ syms_of_msdos ()
5272 DEFVAR_LISP ("dos-unsupported-char-glyph", &Vdos_unsupported_char_glyph, 5287 DEFVAR_LISP ("dos-unsupported-char-glyph", &Vdos_unsupported_char_glyph,
5273 doc: /* *Glyph to display instead of chars not supported by current codepage. 5288 doc: /* *Glyph to display instead of chars not supported by current codepage.
5274This variable is used only by MSDOS terminals. */); 5289This variable is used only by MSDOS terminals. */);
5275 Vdos_unsupported_char_glyph = '\177'; 5290 Vdos_unsupported_char_glyph = make_number ('\177');
5276 5291
5277#endif 5292#endif
5278#ifndef subprocesses 5293#ifndef subprocesses
diff --git a/src/print.c b/src/print.c
index 8d0a5e2bb3b..4b94d77e876 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1,5 +1,5 @@
1/* Lisp object printing and output streams. 1/* Lisp object printing and output streams.
2 Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 01, 2003 2 Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 01, 03, 2004
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -601,6 +601,8 @@ temp_output_buffer_setup (bufname)
601 eassert (current_buffer->overlays_after == NULL); 601 eassert (current_buffer->overlays_after == NULL);
602 current_buffer->enable_multibyte_characters 602 current_buffer->enable_multibyte_characters
603 = buffer_defaults.enable_multibyte_characters; 603 = buffer_defaults.enable_multibyte_characters;
604 specbind (Qinhibit_read_only, Qt);
605 specbind (Qinhibit_modification_hooks, Qt);
604 Ferase_buffer (); 606 Ferase_buffer ();
605 XSETBUFFER (buf, current_buffer); 607 XSETBUFFER (buf, current_buffer);
606 608
@@ -789,7 +791,7 @@ A printed representation of an object is text which describes that object. */)
789 if (SBYTES (object) == SCHARS (object)) 791 if (SBYTES (object) == SCHARS (object))
790 STRING_SET_UNIBYTE (object); 792 STRING_SET_UNIBYTE (object);
791 793
792 /* Note that this won't make prepare_to_modify_buffer call 794 /* Note that this won't make prepare_to_modify_buffer call
793 ask-user-about-supersession-threat because this buffer 795 ask-user-about-supersession-threat because this buffer
794 does not visit a file. */ 796 does not visit a file. */
795 Ferase_buffer (); 797 Ferase_buffer ();
@@ -927,7 +929,7 @@ DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugg
927 doc: /* Redirect debugging output (stderr stream) to file FILE. 929 doc: /* Redirect debugging output (stderr stream) to file FILE.
928If FILE is nil, reset target to the initial stderr stream. 930If FILE is nil, reset target to the initial stderr stream.
929Optional arg APPEND non-nil (interactively, with prefix arg) means 931Optional arg APPEND non-nil (interactively, with prefix arg) means
930append to existing target file. */) 932append to existing target file. */)
931 (file, append) 933 (file, append)
932 Lisp_Object file, append; 934 Lisp_Object file, append;
933{ 935{
@@ -1218,7 +1220,6 @@ print (obj, printcharfun, escapeflag)
1218 register Lisp_Object printcharfun; 1220 register Lisp_Object printcharfun;
1219 int escapeflag; 1221 int escapeflag;
1220{ 1222{
1221 print_depth = 0;
1222 old_backquote_output = 0; 1223 old_backquote_output = 0;
1223 1224
1224 /* Reset print_number_index and Vprint_number_table only when 1225 /* Reset print_number_index and Vprint_number_table only when
@@ -1238,6 +1239,7 @@ print (obj, printcharfun, escapeflag)
1238 start = index = print_number_index; 1239 start = index = print_number_index;
1239 /* Construct Vprint_number_table. 1240 /* Construct Vprint_number_table.
1240 This increments print_number_index for the objects added. */ 1241 This increments print_number_index for the objects added. */
1242 print_depth = 0;
1241 print_preprocess (obj); 1243 print_preprocess (obj);
1242 1244
1243 /* Remove unnecessary objects, which appear only once in OBJ; 1245 /* Remove unnecessary objects, which appear only once in OBJ;
@@ -1262,6 +1264,7 @@ print (obj, printcharfun, escapeflag)
1262 print_number_index = index; 1264 print_number_index = index;
1263 } 1265 }
1264 1266
1267 print_depth = 0;
1265 print_object (obj, printcharfun, escapeflag); 1268 print_object (obj, printcharfun, escapeflag);
1266} 1269}
1267 1270
@@ -1278,6 +1281,26 @@ print_preprocess (obj)
1278{ 1281{
1279 int i; 1282 int i;
1280 EMACS_INT size; 1283 EMACS_INT size;
1284 int loop_count = 0;
1285 Lisp_Object halftail;
1286
1287 /* Avoid infinite recursion for circular nested structure
1288 in the case where Vprint_circle is nil. */
1289 if (NILP (Vprint_circle))
1290 {
1291 for (i = 0; i < print_depth; i++)
1292 if (EQ (obj, being_printed[i]))
1293 return;
1294 being_printed[print_depth] = obj;
1295 }
1296
1297 /* Give up if we go so deep that print_object will get an error. */
1298 /* See similar code in print_object. */
1299 if (print_depth >= PRINT_CIRCLE)
1300 return;
1301
1302 print_depth++;
1303 halftail = obj;
1281 1304
1282 loop: 1305 loop:
1283 if (STRINGP (obj) || CONSP (obj) || VECTORP (obj) 1306 if (STRINGP (obj) || CONSP (obj) || VECTORP (obj)
@@ -1338,8 +1361,15 @@ print_preprocess (obj)
1338 break; 1361 break;
1339 1362
1340 case Lisp_Cons: 1363 case Lisp_Cons:
1364 /* Use HALFTAIL and LOOP_COUNT to detect circular lists,
1365 just as in print_object. */
1366 if (loop_count && EQ (obj, halftail))
1367 break;
1341 print_preprocess (XCAR (obj)); 1368 print_preprocess (XCAR (obj));
1342 obj = XCDR (obj); 1369 obj = XCDR (obj);
1370 loop_count++;
1371 if (!(loop_count & 1))
1372 halftail = XCDR (halftail);
1343 goto loop; 1373 goto loop;
1344 1374
1345 case Lisp_Vectorlike: 1375 case Lisp_Vectorlike:
@@ -1354,6 +1384,7 @@ print_preprocess (obj)
1354 break; 1384 break;
1355 } 1385 }
1356 } 1386 }
1387 print_depth--;
1357} 1388}
1358 1389
1359static void 1390static void
@@ -1457,7 +1488,7 @@ print_object (obj, printcharfun, escapeflag)
1457 register Lisp_Object printcharfun; 1488 register Lisp_Object printcharfun;
1458 int escapeflag; 1489 int escapeflag;
1459{ 1490{
1460 char buf[30]; 1491 char buf[40];
1461 1492
1462 QUIT; 1493 QUIT;
1463 1494
@@ -1511,6 +1542,7 @@ print_object (obj, printcharfun, escapeflag)
1511 1542
1512 print_depth++; 1543 print_depth++;
1513 1544
1545 /* See similar code in print_preprocess. */
1514 if (print_depth > PRINT_CIRCLE) 1546 if (print_depth > PRINT_CIRCLE)
1515 error ("Apparently circular structure being printed"); 1547 error ("Apparently circular structure being printed");
1516#ifdef MAX_PRINT_CHARS 1548#ifdef MAX_PRINT_CHARS
@@ -1876,18 +1908,14 @@ print_object (obj, printcharfun, escapeflag)
1876 register unsigned char c; 1908 register unsigned char c;
1877 struct gcpro gcpro1; 1909 struct gcpro gcpro1;
1878 int size_in_chars 1910 int size_in_chars
1879 = (XBOOL_VECTOR (obj)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; 1911 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
1912 / BOOL_VECTOR_BITS_PER_CHAR);
1880 1913
1881 GCPRO1 (obj); 1914 GCPRO1 (obj);
1882 1915
1883 PRINTCHAR ('#'); 1916 PRINTCHAR ('#');
1884 PRINTCHAR ('&'); 1917 PRINTCHAR ('&');
1885 if (sizeof (int) == sizeof (EMACS_INT)) 1918 sprintf (buf, "%ld", (long) XBOOL_VECTOR (obj)->size);
1886 sprintf (buf, "%d", XBOOL_VECTOR (obj)->size);
1887 else if (sizeof (long) == sizeof (EMACS_INT))
1888 sprintf (buf, "%ld", XBOOL_VECTOR (obj)->size);
1889 else
1890 abort ();
1891 strout (buf, -1, -1, printcharfun, 0); 1919 strout (buf, -1, -1, printcharfun, 0);
1892 PRINTCHAR ('\"'); 1920 PRINTCHAR ('\"');
1893 1921
@@ -1917,6 +1945,14 @@ print_object (obj, printcharfun, escapeflag)
1917 PRINTCHAR ('\\'); 1945 PRINTCHAR ('\\');
1918 PRINTCHAR ('f'); 1946 PRINTCHAR ('f');
1919 } 1947 }
1948 else if (c > '\177')
1949 {
1950 /* Use octal escapes to avoid encoding issues. */
1951 PRINTCHAR ('\\');
1952 PRINTCHAR ('0' + ((c >> 6) & 3));
1953 PRINTCHAR ('0' + ((c >> 3) & 7));
1954 PRINTCHAR ('0' + (c & 7));
1955 }
1920 else 1956 else
1921 { 1957 {
1922 if (c == '\"' || c == '\\') 1958 if (c == '\"' || c == '\\')
@@ -1937,7 +1973,7 @@ print_object (obj, printcharfun, escapeflag)
1937 else if (WINDOWP (obj)) 1973 else if (WINDOWP (obj))
1938 { 1974 {
1939 strout ("#<window ", -1, -1, printcharfun, 0); 1975 strout ("#<window ", -1, -1, printcharfun, 0);
1940 sprintf (buf, "%d", XFASTINT (XWINDOW (obj)->sequence_number)); 1976 sprintf (buf, "%ld", (long) XFASTINT (XWINDOW (obj)->sequence_number));
1941 strout (buf, -1, -1, printcharfun, 0); 1977 strout (buf, -1, -1, printcharfun, 0);
1942 if (!NILP (XWINDOW (obj)->buffer)) 1978 if (!NILP (XWINDOW (obj)->buffer))
1943 { 1979 {
@@ -1958,8 +1994,8 @@ print_object (obj, printcharfun, escapeflag)
1958 PRINTCHAR (' '); 1994 PRINTCHAR (' ');
1959 strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun, 0); 1995 strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun, 0);
1960 PRINTCHAR (' '); 1996 PRINTCHAR (' ');
1961 sprintf (buf, "%d/%d", XFASTINT (h->count), 1997 sprintf (buf, "%ld/%ld", (long) XFASTINT (h->count),
1962 XVECTOR (h->next)->size); 1998 (long) XVECTOR (h->next)->size);
1963 strout (buf, -1, -1, printcharfun, 0); 1999 strout (buf, -1, -1, printcharfun, 0);
1964 } 2000 }
1965 sprintf (buf, " 0x%lx", (unsigned long) h); 2001 sprintf (buf, " 0x%lx", (unsigned long) h);
@@ -2082,7 +2118,7 @@ print_object (obj, printcharfun, escapeflag)
2082 break; 2118 break;
2083 2119
2084 case Lisp_Misc_Intfwd: 2120 case Lisp_Misc_Intfwd:
2085 sprintf (buf, "#<intfwd to %d>", *XINTFWD (obj)->intvar); 2121 sprintf (buf, "#<intfwd to %ld>", (long) *XINTFWD (obj)->intvar);
2086 strout (buf, -1, -1, printcharfun, 0); 2122 strout (buf, -1, -1, printcharfun, 0);
2087 break; 2123 break;
2088 2124
diff --git a/src/process.c b/src/process.c
index 4999aebf723..b810b027737 100644
--- a/src/process.c
+++ b/src/process.c
@@ -445,10 +445,11 @@ decode_status (l, symbol, code, coredump)
445 445
446/* Return a string describing a process status list. */ 446/* Return a string describing a process status list. */
447 447
448Lisp_Object 448static Lisp_Object
449status_message (status) 449status_message (p)
450 Lisp_Object status; 450 struct Lisp_Process *p;
451{ 451{
452 Lisp_Object status = p->status;
452 Lisp_Object symbol; 453 Lisp_Object symbol;
453 int code, coredump; 454 int code, coredump;
454 Lisp_Object string, string2; 455 Lisp_Object string, string2;
@@ -469,6 +470,8 @@ status_message (status)
469 } 470 }
470 else if (EQ (symbol, Qexit)) 471 else if (EQ (symbol, Qexit))
471 { 472 {
473 if (NETCONN1_P (p))
474 return build_string (code == 0 ? "deleted\n" : "connection broken by remote peer\n");
472 if (code == 0) 475 if (code == 0)
473 return build_string ("finished\n"); 476 return build_string ("finished\n");
474 string = Fnumber_to_string (make_number (code)); 477 string = Fnumber_to_string (make_number (code));
@@ -532,7 +535,7 @@ allocate_pty ()
532 three failures in a row before deciding that we've reached the 535 three failures in a row before deciding that we've reached the
533 end of the ptys. */ 536 end of the ptys. */
534 int failed_count = 0; 537 int failed_count = 0;
535 538
536 if (stat (pty_name, &stb) < 0) 539 if (stat (pty_name, &stb) < 0)
537 { 540 {
538 failed_count++; 541 failed_count++;
@@ -765,6 +768,7 @@ nil, indicating the current buffer's process. */)
765 { 768 {
766 XPROCESS (process)->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); 769 XPROCESS (process)->status = Fcons (Qexit, Fcons (make_number (0), Qnil));
767 XSETINT (XPROCESS (process)->tick, ++process_tick); 770 XSETINT (XPROCESS (process)->tick, ++process_tick);
771 status_notify ();
768 } 772 }
769 else if (XINT (XPROCESS (process)->infd) >= 0) 773 else if (XINT (XPROCESS (process)->infd) >= 0)
770 { 774 {
@@ -843,7 +847,7 @@ If PROCESS has not yet exited or died, return 0. */)
843 847
844DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0, 848DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0,
845 doc: /* Return the process id of PROCESS. 849 doc: /* Return the process id of PROCESS.
846This is the pid of the Unix process which PROCESS uses or talks to. 850This is the pid of the external process which PROCESS uses or talks to.
847For a network connection, this value is nil. */) 851For a network connection, this value is nil. */)
848 (process) 852 (process)
849 register Lisp_Object process; 853 register Lisp_Object process;
@@ -1082,7 +1086,7 @@ DEFUN ("set-process-query-on-exit-flag",
1082 Fset_process_query_on_exit_flag, Sset_process_query_on_exit_flag, 1086 Fset_process_query_on_exit_flag, Sset_process_query_on_exit_flag,
1083 2, 2, 0, 1087 2, 2, 0,
1084 doc: /* Specify if query is needed for PROCESS when Emacs is exited. 1088 doc: /* Specify if query is needed for PROCESS when Emacs is exited.
1085If the second argument FLAG is non-nil, emacs will query the user before 1089If the second argument FLAG is non-nil, Emacs will query the user before
1086exiting if PROCESS is running. */) 1090exiting if PROCESS is running. */)
1087 (process, flag) 1091 (process, flag)
1088 register Lisp_Object process, flag; 1092 register Lisp_Object process, flag;
@@ -1095,7 +1099,7 @@ exiting if PROCESS is running. */)
1095DEFUN ("process-query-on-exit-flag", 1099DEFUN ("process-query-on-exit-flag",
1096 Fprocess_query_on_exit_flag, Sprocess_query_on_exit_flag, 1100 Fprocess_query_on_exit_flag, Sprocess_query_on_exit_flag,
1097 1, 1, 0, 1101 1, 1, 0,
1098 doc: /* Return the current value of query on exit flag for PROCESS. */) 1102 doc: /* Return the current value of query-on-exit flag for PROCESS. */)
1099 (process) 1103 (process)
1100 register Lisp_Object process; 1104 register Lisp_Object process;
1101{ 1105{
@@ -1458,12 +1462,12 @@ static Lisp_Object start_process_unwind ();
1458DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0, 1462DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0,
1459 doc: /* Start a program in a subprocess. Return the process object for it. 1463 doc: /* Start a program in a subprocess. Return the process object for it.
1460NAME is name for process. It is modified if necessary to make it unique. 1464NAME is name for process. It is modified if necessary to make it unique.
1461BUFFER is the buffer or (buffer-name) to associate with the process. 1465BUFFER is the buffer (or buffer name) to associate with the process.
1462 Process output goes at end of that buffer, unless you specify 1466 Process output goes at end of that buffer, unless you specify
1463 an output stream or filter function to handle the output. 1467 an output stream or filter function to handle the output.
1464 BUFFER may be also nil, meaning that this process is not associated 1468 BUFFER may be also nil, meaning that this process is not associated
1465 with any buffer. 1469 with any buffer.
1466Third arg is program file name. It is searched for in PATH. 1470PROGRAM is the program file name. It is searched for in PATH.
1467Remaining arguments are strings to give program as arguments. 1471Remaining arguments are strings to give program as arguments.
1468 1472
1469usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) 1473usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
@@ -2609,7 +2613,7 @@ successful) or "failed" when the connect completes. Default is to use
2609a blocking connect (i.e. wait) for stream type connections. 2613a blocking connect (i.e. wait) for stream type connections.
2610 2614
2611:noquery BOOL -- Query the user unless BOOL is non-nil, and process is 2615:noquery BOOL -- Query the user unless BOOL is non-nil, and process is
2612running when emacs is exited. 2616running when Emacs is exited.
2613 2617
2614:stop BOOL -- Start process in the `stopped' state if BOOL non-nil. 2618:stop BOOL -- Start process in the `stopped' state if BOOL non-nil.
2615In the stopped state, a server process does not accept new 2619In the stopped state, a server process does not accept new
@@ -2955,7 +2959,7 @@ usage: (make-network-process &rest ARGS) */)
2955 struct hostent *host_info_ptr; 2959 struct hostent *host_info_ptr;
2956 2960
2957 /* gethostbyname may fail with TRY_AGAIN, but we don't honour that, 2961 /* gethostbyname may fail with TRY_AGAIN, but we don't honour that,
2958 as it may `hang' emacs for a very long time. */ 2962 as it may `hang' Emacs for a very long time. */
2959 immediate_quit = 1; 2963 immediate_quit = 1;
2960 QUIT; 2964 QUIT;
2961 host_info_ptr = gethostbyname (SDATA (host)); 2965 host_info_ptr = gethostbyname (SDATA (host));
@@ -3616,6 +3620,8 @@ FLAGS is the current flags of the interface. */)
3616#endif 3620#endif
3617#endif /* HAVE_SOCKETS */ 3621#endif /* HAVE_SOCKETS */
3618 3622
3623/* Turn off input and output for process PROC. */
3624
3619void 3625void
3620deactivate_process (proc) 3626deactivate_process (proc)
3621 Lisp_Object proc; 3627 Lisp_Object proc;
@@ -3635,7 +3641,7 @@ deactivate_process (proc)
3635 p->read_output_skip = Qnil; 3641 p->read_output_skip = Qnil;
3636 } 3642 }
3637#endif 3643#endif
3638 3644
3639 if (inchannel >= 0) 3645 if (inchannel >= 0)
3640 { 3646 {
3641 /* Beware SIGCHLD hereabouts. */ 3647 /* Beware SIGCHLD hereabouts. */
@@ -3965,7 +3971,7 @@ server_accept_connection (server, channel)
3965 3971
3966/* This variable is different from waiting_for_input in keyboard.c. 3972/* This variable is different from waiting_for_input in keyboard.c.
3967 It is used to communicate to a lisp process-filter/sentinel (via the 3973 It is used to communicate to a lisp process-filter/sentinel (via the
3968 function Fwaiting_for_user_input_p below) whether emacs was waiting 3974 function Fwaiting_for_user_input_p below) whether Emacs was waiting
3969 for user-input when that process-filter was called. 3975 for user-input when that process-filter was called.
3970 waiting_for_input cannot be used as that is by definition 0 when 3976 waiting_for_input cannot be used as that is by definition 0 when
3971 lisp code is being evalled. 3977 lisp code is being evalled.
@@ -4019,8 +4025,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4019 int do_display; 4025 int do_display;
4020{ 4026{
4021 register int channel, nfds; 4027 register int channel, nfds;
4022 static SELECT_TYPE Available; 4028 SELECT_TYPE Available;
4023 static SELECT_TYPE Connecting; 4029 SELECT_TYPE Connecting;
4024 int check_connect, check_delay, no_avail; 4030 int check_connect, check_delay, no_avail;
4025 int xerrno; 4031 int xerrno;
4026 Lisp_Object proc; 4032 Lisp_Object proc;
@@ -4031,6 +4037,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4031 /* Either nil or a cons cell, the car of which is of interest and 4037 /* Either nil or a cons cell, the car of which is of interest and
4032 may be changed outside of this routine. */ 4038 may be changed outside of this routine. */
4033 Lisp_Object wait_for_cell = Qnil; 4039 Lisp_Object wait_for_cell = Qnil;
4040 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4034 4041
4035 FD_ZERO (&Available); 4042 FD_ZERO (&Available);
4036 FD_ZERO (&Connecting); 4043 FD_ZERO (&Connecting);
@@ -4581,7 +4588,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4581 } 4588 }
4582 } 4589 }
4583#ifdef NON_BLOCKING_CONNECT 4590#ifdef NON_BLOCKING_CONNECT
4584 if (check_connect && FD_ISSET (channel, &Connecting)) 4591 if (check_connect && FD_ISSET (channel, &Connecting)
4592 && FD_ISSET (channel, &connect_wait_mask))
4585 { 4593 {
4586 struct Lisp_Process *p; 4594 struct Lisp_Process *p;
4587 4595
@@ -4644,7 +4652,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4644 } /* end for each file descriptor */ 4652 } /* end for each file descriptor */
4645 } /* end while exit conditions not met */ 4653 } /* end while exit conditions not met */
4646 4654
4647 waiting_for_user_input_p = 0; 4655 waiting_for_user_input_p = saved_waiting_for_user_input_p;
4648 4656
4649 /* If calling from keyboard input, do not quit 4657 /* If calling from keyboard input, do not quit
4650 since we want to return C-g as an input character. 4658 since we want to return C-g as an input character.
@@ -4691,7 +4699,7 @@ read_process_output_error_handler (error)
4691 starting with our buffered-ahead character if we have one. 4699 starting with our buffered-ahead character if we have one.
4692 Yield number of decoded characters read. 4700 Yield number of decoded characters read.
4693 4701
4694 This function reads at most 1024 characters. 4702 This function reads at most 4096 characters.
4695 If you want to read all available subprocess output, 4703 If you want to read all available subprocess output,
4696 you must call it repeatedly until it returns zero. 4704 you must call it repeatedly until it returns zero.
4697 4705
@@ -4711,7 +4719,7 @@ read_process_output (proc, channel)
4711 register int opoint; 4719 register int opoint;
4712 struct coding_system *coding = proc_decode_coding_system[channel]; 4720 struct coding_system *coding = proc_decode_coding_system[channel];
4713 int carryover = XINT (p->decoding_carryover); 4721 int carryover = XINT (p->decoding_carryover);
4714 int readmax = 1024; 4722 int readmax = 4096;
4715 4723
4716#ifdef VMS 4724#ifdef VMS
4717 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); 4725 VMS_PROC_STUFF *vs, *get_vms_process_pointer();
@@ -4744,16 +4752,6 @@ read_process_output (proc, channel)
4744 } 4752 }
4745#else /* not VMS */ 4753#else /* not VMS */
4746 4754
4747#ifdef DATAGRAM_SOCKETS
4748 /* A datagram is one packet; allow at least 1500+ bytes of data
4749 corresponding to the typical Ethernet frame size. */
4750 if (DATAGRAM_CHAN_P (channel))
4751 {
4752 /* carryover = 0; */ /* Does carryover make sense for datagrams? */
4753 readmax += 1024;
4754 }
4755#endif
4756
4757 chars = (char *) alloca (carryover + readmax); 4755 chars = (char *) alloca (carryover + readmax);
4758 if (carryover) 4756 if (carryover)
4759 /* See the comment above. */ 4757 /* See the comment above. */
@@ -5069,7 +5067,7 @@ read_process_output (proc, channel)
5069 5067
5070DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p, 5068DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p,
5071 0, 0, 0, 5069 0, 0, 0,
5072 doc: /* Returns non-nil if emacs is waiting for input from the user. 5070 doc: /* Returns non-nil if Emacs is waiting for input from the user.
5073This is intended for use by asynchronous process output filters and sentinels. */) 5071This is intended for use by asynchronous process output filters and sentinels. */)
5074 () 5072 ()
5075{ 5073{
@@ -5446,7 +5444,7 @@ emacs_get_tty_pgrp (p)
5446{ 5444{
5447 int gid = -1; 5445 int gid = -1;
5448 5446
5449#ifdef TIOCGPGRP 5447#ifdef TIOCGPGRP
5450 if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) 5448 if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name))
5451 { 5449 {
5452 int fd; 5450 int fd;
@@ -5643,7 +5641,7 @@ process_send_signal (process, signo, current_group, nomsg)
5643 we should just assume that p->pid is also the process group id. */ 5641 we should just assume that p->pid is also the process group id. */
5644 5642
5645 gid = emacs_get_tty_pgrp (p); 5643 gid = emacs_get_tty_pgrp (p);
5646 5644
5647 if (gid == -1) 5645 if (gid == -1)
5648 /* If we can't get the information, assume 5646 /* If we can't get the information, assume
5649 the shell owns the tty. */ 5647 the shell owns the tty. */
@@ -5726,7 +5724,7 @@ process_send_signal (process, signo, current_group, nomsg)
5726DEFUN ("interrupt-process", Finterrupt_process, Sinterrupt_process, 0, 2, 0, 5724DEFUN ("interrupt-process", Finterrupt_process, Sinterrupt_process, 0, 2, 0,
5727 doc: /* Interrupt process PROCESS. 5725 doc: /* Interrupt process PROCESS.
5728PROCESS may be a process, a buffer, or the name of a process or buffer. 5726PROCESS may be a process, a buffer, or the name of a process or buffer.
5729nil or no arg means current buffer's process. 5727No arg or nil means current buffer's process.
5730Second arg CURRENT-GROUP non-nil means send signal to 5728Second arg CURRENT-GROUP non-nil means send signal to
5731the current process-group of the process's controlling terminal 5729the current process-group of the process's controlling terminal
5732rather than to the process's own process group. 5730rather than to the process's own process group.
@@ -6385,7 +6383,7 @@ status_notify ()
6385 /* Get the text to use for the message. */ 6383 /* Get the text to use for the message. */
6386 if (!NILP (p->raw_status_low)) 6384 if (!NILP (p->raw_status_low))
6387 update_status (p); 6385 update_status (p);
6388 msg = status_message (p->status); 6386 msg = status_message (p);
6389 6387
6390 /* If process is terminated, deactivate it or delete it. */ 6388 /* If process is terminated, deactivate it or delete it. */
6391 symbol = p->status; 6389 symbol = p->status;
@@ -6471,13 +6469,13 @@ DEFUN ("set-process-coding-system", Fset_process_coding_system,
6471 doc: /* Set coding systems of PROCESS to DECODING and ENCODING. 6469 doc: /* Set coding systems of PROCESS to DECODING and ENCODING.
6472DECODING will be used to decode subprocess output and ENCODING to 6470DECODING will be used to decode subprocess output and ENCODING to
6473encode subprocess input. */) 6471encode subprocess input. */)
6474 (proc, decoding, encoding) 6472 (process, decoding, encoding)
6475 register Lisp_Object proc, decoding, encoding; 6473 register Lisp_Object process, decoding, encoding;
6476{ 6474{
6477 register struct Lisp_Process *p; 6475 register struct Lisp_Process *p;
6478 6476
6479 CHECK_PROCESS (proc); 6477 CHECK_PROCESS (process);
6480 p = XPROCESS (proc); 6478 p = XPROCESS (process);
6481 if (XINT (p->infd) < 0) 6479 if (XINT (p->infd) < 0)
6482 error ("Input file descriptor of %s closed", SDATA (p->name)); 6480 error ("Input file descriptor of %s closed", SDATA (p->name));
6483 if (XINT (p->outfd) < 0) 6481 if (XINT (p->outfd) < 0)
@@ -6487,7 +6485,7 @@ encode subprocess input. */)
6487 6485
6488 p->decode_coding_system = decoding; 6486 p->decode_coding_system = decoding;
6489 p->encode_coding_system = encoding; 6487 p->encode_coding_system = encoding;
6490 setup_process_coding_systems (proc); 6488 setup_process_coding_systems (process);
6491 6489
6492 return Qnil; 6490 return Qnil;
6493} 6491}
@@ -6495,12 +6493,12 @@ encode subprocess input. */)
6495DEFUN ("process-coding-system", 6493DEFUN ("process-coding-system",
6496 Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0, 6494 Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0,
6497 doc: /* Return a cons of coding systems for decoding and encoding of PROCESS. */) 6495 doc: /* Return a cons of coding systems for decoding and encoding of PROCESS. */)
6498 (proc) 6496 (process)
6499 register Lisp_Object proc; 6497 register Lisp_Object process;
6500{ 6498{
6501 CHECK_PROCESS (proc); 6499 CHECK_PROCESS (process);
6502 return Fcons (XPROCESS (proc)->decode_coding_system, 6500 return Fcons (XPROCESS (process)->decode_coding_system,
6503 XPROCESS (proc)->encode_coding_system); 6501 XPROCESS (process)->encode_coding_system);
6504} 6502}
6505 6503
6506DEFUN ("set-process-filter-multibyte", Fset_process_filter_multibyte, 6504DEFUN ("set-process-filter-multibyte", Fset_process_filter_multibyte,
@@ -6510,15 +6508,15 @@ If FLAG is non-nil, the filter is given multibyte strings.
6510If FLAG is nil, the filter is given unibyte strings. In this case, 6508If FLAG is nil, the filter is given unibyte strings. In this case,
6511all character code conversion except for end-of-line conversion is 6509all character code conversion except for end-of-line conversion is
6512suppressed. */) 6510suppressed. */)
6513 (proc, flag) 6511 (process, flag)
6514 Lisp_Object proc, flag; 6512 Lisp_Object process, flag;
6515{ 6513{
6516 register struct Lisp_Process *p; 6514 register struct Lisp_Process *p;
6517 6515
6518 CHECK_PROCESS (proc); 6516 CHECK_PROCESS (process);
6519 p = XPROCESS (proc); 6517 p = XPROCESS (process);
6520 p->filter_multibyte = flag; 6518 p->filter_multibyte = flag;
6521 setup_process_coding_systems (proc); 6519 setup_process_coding_systems (process);
6522 6520
6523 return Qnil; 6521 return Qnil;
6524} 6522}
@@ -6526,13 +6524,13 @@ suppressed. */)
6526DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, 6524DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6527 Sprocess_filter_multibyte_p, 1, 1, 0, 6525 Sprocess_filter_multibyte_p, 1, 1, 0,
6528 doc: /* Return t if a multibyte string is given to PROCESS's filter.*/) 6526 doc: /* Return t if a multibyte string is given to PROCESS's filter.*/)
6529 (proc) 6527 (process)
6530 Lisp_Object proc; 6528 Lisp_Object process;
6531{ 6529{
6532 register struct Lisp_Process *p; 6530 register struct Lisp_Process *p;
6533 6531
6534 CHECK_PROCESS (proc); 6532 CHECK_PROCESS (process);
6535 p = XPROCESS (proc); 6533 p = XPROCESS (process);
6536 6534
6537 return (NILP (p->filter_multibyte) ? Qnil : Qt); 6535 return (NILP (p->filter_multibyte) ? Qnil : Qt);
6538} 6536}
@@ -6753,11 +6751,11 @@ The value takes effect when `start-process' is called. */);
6753#ifdef ADAPTIVE_READ_BUFFERING 6751#ifdef ADAPTIVE_READ_BUFFERING
6754 DEFVAR_LISP ("process-adaptive-read-buffering", &Vprocess_adaptive_read_buffering, 6752 DEFVAR_LISP ("process-adaptive-read-buffering", &Vprocess_adaptive_read_buffering,
6755 doc: /* If non-nil, improve receive buffering by delaying after short reads. 6753 doc: /* If non-nil, improve receive buffering by delaying after short reads.
6756On some systems, when emacs reads the output from a subprocess, the output data 6754On some systems, when Emacs reads the output from a subprocess, the output data
6757is read in very small blocks, potentially resulting in very poor performance. 6755is read in very small blocks, potentially resulting in very poor performance.
6758This behaviour can be remedied to some extent by setting this variable to a 6756This behaviour can be remedied to some extent by setting this variable to a
6759non-nil value, as it will automatically delay reading from such processes, to 6757non-nil value, as it will automatically delay reading from such processes, to
6760allowing them to produce more output before emacs tries to read it. 6758allowing them to produce more output before Emacs tries to read it.
6761If the value is t, the delay is reset after each write to the process; any other 6759If the value is t, the delay is reset after each write to the process; any other
6762non-nil value means that the delay is not reset on write. 6760non-nil value means that the delay is not reset on write.
6763The variable takes effect when `start-process' is called. */); 6761The variable takes effect when `start-process' is called. */);
diff --git a/src/regex.c b/src/regex.c
index e1479e64c9f..006b79acba8 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -2,7 +2,7 @@
2 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the 2 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the
3 internationalization features.) 3 internationalization features.)
4 4
5 Copyright (C) 1993,94,95,96,97,98,99,2000 Free Software Foundation, Inc. 5 Copyright (C) 1993,94,95,96,97,98,99,2000,04 Free Software Foundation, Inc.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -233,7 +233,7 @@ char *realloc ();
233/* Define the syntax stuff for \<, \>, etc. */ 233/* Define the syntax stuff for \<, \>, etc. */
234 234
235/* Sword must be nonzero for the wordchar pattern commands in re_match_2. */ 235/* Sword must be nonzero for the wordchar pattern commands in re_match_2. */
236enum syntaxcode { Swhitespace = 0, Sword = 1 }; 236enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
237 237
238# ifdef SWITCH_ENUM_BUG 238# ifdef SWITCH_ENUM_BUG
239# define SWITCH_ENUM_CAST(x) ((int)(x)) 239# define SWITCH_ENUM_CAST(x) ((int)(x))
@@ -423,7 +423,7 @@ init_syntax_once ()
423 if (ISALNUM (c)) 423 if (ISALNUM (c))
424 re_syntax_table[c] = Sword; 424 re_syntax_table[c] = Sword;
425 425
426 re_syntax_table['_'] = Sword; 426 re_syntax_table['_'] = Ssymbol;
427 427
428 done = 1; 428 done = 1;
429} 429}
@@ -680,6 +680,9 @@ typedef enum
680 wordbound, /* Succeeds if at a word boundary. */ 680 wordbound, /* Succeeds if at a word boundary. */
681 notwordbound, /* Succeeds if not at a word boundary. */ 681 notwordbound, /* Succeeds if not at a word boundary. */
682 682
683 symbeg, /* Succeeds if at symbol beginning. */
684 symend, /* Succeeds if at symbol end. */
685
683 /* Matches any character whose syntax is specified. Followed by 686 /* Matches any character whose syntax is specified. Followed by
684 a byte which contains a syntax code, e.g., Sword. */ 687 a byte which contains a syntax code, e.g., Sword. */
685 syntaxspec, 688 syntaxspec,
@@ -1118,6 +1121,15 @@ print_partial_compiled_pattern (start, end)
1118 1121
1119 case wordend: 1122 case wordend:
1120 fprintf (stderr, "/wordend"); 1123 fprintf (stderr, "/wordend");
1124 break;
1125
1126 case symbeg:
1127 fprintf (stderr, "/symbeg");
1128 break;
1129
1130 case symend:
1131 fprintf (stderr, "/symend");
1132 break;
1121 1133
1122 case syntaxspec: 1134 case syntaxspec:
1123 fprintf (stderr, "/syntaxspec"); 1135 fprintf (stderr, "/syntaxspec");
@@ -2003,41 +2015,10 @@ struct range_table_work_area
2003 } \ 2015 } \
2004 } while (0) 2016 } while (0)
2005 2017
2006#if WIDE_CHAR_SUPPORT 2018#if ! WIDE_CHAR_SUPPORT
2007/* The GNU C library provides support for user-defined character classes
2008 and the functions from ISO C amendement 1. */
2009# ifdef CHARCLASS_NAME_MAX
2010# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
2011# else
2012/* This shouldn't happen but some implementation might still have this
2013 problem. Use a reasonable default value. */
2014# define CHAR_CLASS_MAX_LENGTH 256
2015# endif
2016typedef wctype_t re_wctype_t;
2017typedef wchar_t re_wchar_t;
2018# define re_wctype wctype
2019# define re_iswctype iswctype
2020# define re_wctype_to_bit(cc) 0
2021#else
2022# define CHAR_CLASS_MAX_LENGTH 9 /* Namely, `multibyte'. */
2023# define btowc(c) c
2024
2025/* Character classes. */
2026typedef enum { RECC_ERROR = 0,
2027 RECC_ALNUM, RECC_ALPHA, RECC_WORD,
2028 RECC_GRAPH, RECC_PRINT,
2029 RECC_LOWER, RECC_UPPER,
2030 RECC_PUNCT, RECC_CNTRL,
2031 RECC_DIGIT, RECC_XDIGIT,
2032 RECC_BLANK, RECC_SPACE,
2033 RECC_MULTIBYTE, RECC_NONASCII,
2034 RECC_ASCII, RECC_UNIBYTE
2035} re_wctype_t;
2036
2037typedef int re_wchar_t;
2038 2019
2039/* Map a string to the char class it names (if any). */ 2020/* Map a string to the char class it names (if any). */
2040static re_wctype_t 2021re_wctype_t
2041re_wctype (str) 2022re_wctype (str)
2042 re_char *str; 2023 re_char *str;
2043{ 2024{
@@ -2063,7 +2044,7 @@ re_wctype (str)
2063} 2044}
2064 2045
2065/* True iff CH is in the char class CC. */ 2046/* True iff CH is in the char class CC. */
2066static boolean 2047boolean
2067re_iswctype (ch, cc) 2048re_iswctype (ch, cc)
2068 int ch; 2049 int ch;
2069 re_wctype_t cc; 2050 re_wctype_t cc;
@@ -3464,6 +3445,19 @@ regex_compile (pattern, size, syntax, bufp)
3464 BUF_PUSH (wordend); 3445 BUF_PUSH (wordend);
3465 break; 3446 break;
3466 3447
3448 case '_':
3449 if (syntax & RE_NO_GNU_OPS)
3450 goto normal_char;
3451 laststart = b;
3452 PATFETCH (c);
3453 if (c == '<')
3454 BUF_PUSH (symbeg);
3455 else if (c == '>')
3456 BUF_PUSH (symend);
3457 else
3458 FREE_STACK_RETURN (REG_BADPAT);
3459 break;
3460
3467 case 'b': 3461 case 'b':
3468 if (syntax & RE_NO_GNU_OPS) 3462 if (syntax & RE_NO_GNU_OPS)
3469 goto normal_char; 3463 goto normal_char;
@@ -3980,6 +3974,8 @@ analyse_first (p, pend, fastmap, multibyte)
3980 case notwordbound: 3974 case notwordbound:
3981 case wordbeg: 3975 case wordbeg:
3982 case wordend: 3976 case wordend:
3977 case symbeg:
3978 case symend:
3983 continue; 3979 continue;
3984 3980
3985 3981
@@ -4768,14 +4764,20 @@ mutually_exclusive_p (bufp, p1, p2)
4768 break; 4764 break;
4769 4765
4770 case wordend: 4766 case wordend:
4771 case notsyntaxspec: 4767 return ((re_opcode_t) *p1 == syntaxspec && p1[1] == Sword);
4768 case symend:
4772 return ((re_opcode_t) *p1 == syntaxspec 4769 return ((re_opcode_t) *p1 == syntaxspec
4773 && p1[1] == (op2 == wordend ? Sword : p2[1])); 4770 && (p1[1] == Ssymbol || p1[1] == Sword));
4771 case notsyntaxspec:
4772 return ((re_opcode_t) *p1 == syntaxspec && p1[1] == p2[1]);
4774 4773
4775 case wordbeg: 4774 case wordbeg:
4776 case syntaxspec: 4775 return ((re_opcode_t) *p1 == notsyntaxspec && p1[1] == Sword);
4776 case symbeg:
4777 return ((re_opcode_t) *p1 == notsyntaxspec 4777 return ((re_opcode_t) *p1 == notsyntaxspec
4778 && p1[1] == (op2 == wordend ? Sword : p2[1])); 4778 && (p1[1] == Ssymbol || p1[1] == Sword));
4779 case syntaxspec:
4780 return ((re_opcode_t) *p1 == notsyntaxspec && p1[1] == p2[1]);
4779 4781
4780 case wordbound: 4782 case wordbound:
4781 return (((re_opcode_t) *p1 == notsyntaxspec 4783 return (((re_opcode_t) *p1 == notsyntaxspec
@@ -5952,6 +5954,92 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
5952 } 5954 }
5953 break; 5955 break;
5954 5956
5957 case symbeg:
5958 DEBUG_PRINT1 ("EXECUTING symbeg.\n");
5959
5960 /* We FAIL in one of the following cases: */
5961
5962 /* Case 1: D is at the end of string. */
5963 if (AT_STRINGS_END (d))
5964 goto fail;
5965 else
5966 {
5967 /* C1 is the character before D, S1 is the syntax of C1, C2
5968 is the character at D, and S2 is the syntax of C2. */
5969 re_wchar_t c1, c2;
5970 int s1, s2;
5971#ifdef emacs
5972 int offset = PTR_TO_OFFSET (d);
5973 int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
5974 UPDATE_SYNTAX_TABLE (charpos);
5975#endif
5976 PREFETCH ();
5977 c2 = RE_STRING_CHAR (d, dend - d);
5978 s2 = SYNTAX (c2);
5979
5980 /* Case 2: S2 is neither Sword nor Ssymbol. */
5981 if (s2 != Sword && s2 != Ssymbol)
5982 goto fail;
5983
5984 /* Case 3: D is not at the beginning of string ... */
5985 if (!AT_STRINGS_BEG (d))
5986 {
5987 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
5988#ifdef emacs
5989 UPDATE_SYNTAX_TABLE_BACKWARD (charpos - 1);
5990#endif
5991 s1 = SYNTAX (c1);
5992
5993 /* ... and S1 is Sword or Ssymbol. */
5994 if (s1 == Sword || s1 == Ssymbol)
5995 goto fail;
5996 }
5997 }
5998 break;
5999
6000 case symend:
6001 DEBUG_PRINT1 ("EXECUTING symend.\n");
6002
6003 /* We FAIL in one of the following cases: */
6004
6005 /* Case 1: D is at the beginning of string. */
6006 if (AT_STRINGS_BEG (d))
6007 goto fail;
6008 else
6009 {
6010 /* C1 is the character before D, S1 is the syntax of C1, C2
6011 is the character at D, and S2 is the syntax of C2. */
6012 re_wchar_t c1, c2;
6013 int s1, s2;
6014#ifdef emacs
6015 int offset = PTR_TO_OFFSET (d) - 1;
6016 int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
6017 UPDATE_SYNTAX_TABLE (charpos);
6018#endif
6019 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
6020 s1 = SYNTAX (c1);
6021
6022 /* Case 2: S1 is neither Ssymbol nor Sword. */
6023 if (s1 != Sword && s1 != Ssymbol)
6024 goto fail;
6025
6026 /* Case 3: D is not at the end of string ... */
6027 if (!AT_STRINGS_END (d))
6028 {
6029 PREFETCH_NOLIMIT ();
6030 c2 = RE_STRING_CHAR (d, dend - d);
6031#ifdef emacs
6032 UPDATE_SYNTAX_TABLE_FORWARD (charpos);
6033#endif
6034 s2 = SYNTAX (c2);
6035
6036 /* ... and S2 is Sword or Ssymbol. */
6037 if (s2 == Sword || s2 == Ssymbol)
6038 goto fail;
6039 }
6040 }
6041 break;
6042
5955 case syntaxspec: 6043 case syntaxspec:
5956 case notsyntaxspec: 6044 case notsyntaxspec:
5957 not = (re_opcode_t) *(p - 1) == notsyntaxspec; 6045 not = (re_opcode_t) *(p - 1) == notsyntaxspec;
diff --git a/src/regex.h b/src/regex.h
index be7634bb8de..26c589bde92 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -568,6 +568,49 @@ extern void regfree _RE_ARGS ((regex_t *__preg));
568} 568}
569#endif /* C++ */ 569#endif /* C++ */
570 570
571/* For platform which support the ISO C amendement 1 functionality we
572 support user defined character classes. */
573#if WIDE_CHAR_SUPPORT
574/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
575# include <wchar.h>
576# include <wctype.h>
577#endif
578
579#if WIDE_CHAR_SUPPORT
580/* The GNU C library provides support for user-defined character classes
581 and the functions from ISO C amendement 1. */
582# ifdef CHARCLASS_NAME_MAX
583# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
584# else
585/* This shouldn't happen but some implementation might still have this
586 problem. Use a reasonable default value. */
587# define CHAR_CLASS_MAX_LENGTH 256
588# endif
589typedef wctype_t re_wctype_t;
590typedef wchar_t re_wchar_t;
591# define re_wctype wctype
592# define re_iswctype iswctype
593# define re_wctype_to_bit(cc) 0
594#else
595# define CHAR_CLASS_MAX_LENGTH 9 /* Namely, `multibyte'. */
596# define btowc(c) c
597
598/* Character classes. */
599typedef enum { RECC_ERROR = 0,
600 RECC_ALNUM, RECC_ALPHA, RECC_WORD,
601 RECC_GRAPH, RECC_PRINT,
602 RECC_LOWER, RECC_UPPER,
603 RECC_PUNCT, RECC_CNTRL,
604 RECC_DIGIT, RECC_XDIGIT,
605 RECC_BLANK, RECC_SPACE,
606 RECC_MULTIBYTE, RECC_NONASCII,
607 RECC_ASCII, RECC_UNIBYTE
608} re_wctype_t;
609
610typedef int re_wchar_t;
611
612#endif /* not WIDE_CHAR_SUPPORT */
613
571#endif /* regex.h */ 614#endif /* regex.h */
572 615
573/* 616/*
diff --git a/src/search.c b/src/search.c
index f9b45c8eca6..eba74f418ce 100644
--- a/src/search.c
+++ b/src/search.c
@@ -924,7 +924,7 @@ trivial_regexp_p (regexp)
924 { 924 {
925 case '|': case '(': case ')': case '`': case '\'': case 'b': 925 case '|': case '(': case ')': case '`': case '\'': case 'b':
926 case 'B': case '<': case '>': case 'w': case 'W': case 's': 926 case 'B': case '<': case '>': case 'w': case 'W': case 's':
927 case 'S': case '=': case '{': case '}': 927 case 'S': case '=': case '{': case '}': case '_':
928 case 'c': case 'C': /* for categoryspec and notcategoryspec */ 928 case 'c': case 'C': /* for categoryspec and notcategoryspec */
929 case '1': case '2': case '3': case '4': case '5': 929 case '1': case '2': case '3': case '4': case '5':
930 case '6': case '7': case '8': case '9': 930 case '6': case '7': case '8': case '9':
@@ -2576,9 +2576,11 @@ match_limit (num, beginningp)
2576 2576
2577 CHECK_NUMBER (num); 2577 CHECK_NUMBER (num);
2578 n = XINT (num); 2578 n = XINT (num);
2579 if (n < 0 || n >= search_regs.num_regs) 2579 if (n < 0)
2580 args_out_of_range (num, make_number (search_regs.num_regs)); 2580 args_out_of_range (num, 0);
2581 if (search_regs.num_regs <= 0 2581 if (search_regs.num_regs <= 0)
2582 error ("No match data, because no search succeeded");
2583 if (n >= search_regs.num_regs
2582 || search_regs.start[n] < 0) 2584 || search_regs.start[n] < 0)
2583 return Qnil; 2585 return Qnil;
2584 return (make_number ((beginningp) ? search_regs.start[n] 2586 return (make_number ((beginningp) ? search_regs.start[n]
diff --git a/src/syntax.c b/src/syntax.c
index 22a34c40fb3..57606f314d6 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -26,6 +26,7 @@ Boston, MA 02111-1307, USA. */
26#include "buffer.h" 26#include "buffer.h"
27#include "character.h" 27#include "character.h"
28#include "keymap.h" 28#include "keymap.h"
29#include "regex.h"
29 30
30/* Make syntax table lookup grant data in gl_state. */ 31/* Make syntax table lookup grant data in gl_state. */
31#define SYNTAX_ENTRY_VIA_PROPERTY 32#define SYNTAX_ENTRY_VIA_PROPERTY
@@ -97,12 +98,13 @@ static int find_start_modiff;
97static int find_defun_start P_ ((int, int)); 98static int find_defun_start P_ ((int, int));
98static int back_comment P_ ((int, int, int, int, int, int *, int *)); 99static int back_comment P_ ((int, int, int, int, int, int *, int *));
99static int char_quoted P_ ((int, int)); 100static int char_quoted P_ ((int, int));
100static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object)); 101static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object, int));
101static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object)); 102static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object));
102static Lisp_Object scan_lists P_ ((int, int, int, int)); 103static Lisp_Object scan_lists P_ ((int, int, int, int));
103static void scan_sexps_forward P_ ((struct lisp_parse_state *, 104static void scan_sexps_forward P_ ((struct lisp_parse_state *,
104 int, int, int, int, 105 int, int, int, int,
105 int, Lisp_Object, int)); 106 int, Lisp_Object, int));
107static int in_classes P_ ((int, Lisp_Object));
106 108
107 109
108struct gl_state_s gl_state; /* Global state of syntax parser. */ 110struct gl_state_s gl_state; /* Global state of syntax parser. */
@@ -293,8 +295,11 @@ char_quoted (charpos, bytepos)
293 295
294 while (bytepos >= beg) 296 while (bytepos >= beg)
295 { 297 {
298 int c;
299
296 UPDATE_SYNTAX_TABLE_BACKWARD (charpos); 300 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
297 code = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (bytepos)); 301 c = FETCH_CHAR_AS_MULTIBYTE (bytepos);
302 code = SYNTAX (c);
298 if (! (code == Scharquote || code == Sescape)) 303 if (! (code == Scharquote || code == Sescape))
299 break; 304 break;
300 305
@@ -381,12 +386,16 @@ find_defun_start (pos, pos_byte)
381 gl_state.use_global = 0; 386 gl_state.use_global = 0;
382 while (PT > BEGV) 387 while (PT > BEGV)
383 { 388 {
389 int c;
390
384 /* Open-paren at start of line means we may have found our 391 /* Open-paren at start of line means we may have found our
385 defun-start. */ 392 defun-start. */
386 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen) 393 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
394 if (SYNTAX (c) == Sopen)
387 { 395 {
388 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ 396 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */
389 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen) 397 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
398 if (SYNTAX (c) == Sopen)
390 break; 399 break;
391 /* Now fallback to the default value. */ 400 /* Now fallback to the default value. */
392 gl_state.current_syntax_table = current_buffer->syntax_table; 401 gl_state.current_syntax_table = current_buffer->syntax_table;
@@ -955,7 +964,7 @@ text property. */)
955DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, 964DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
956 "cSet syntax for character: \nsSet syntax for %s to: ", 965 "cSet syntax for character: \nsSet syntax for %s to: ",
957 doc: /* Set syntax for character CHAR according to string NEWENTRY. 966 doc: /* Set syntax for character CHAR according to string NEWENTRY.
958The syntax is changed only for table SYNTAX_TABLE, which defaults to 967The syntax is changed only for table SYNTAX-TABLE, which defaults to
959 the current buffer's syntax table. 968 the current buffer's syntax table.
960CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters 969CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters
961in the range MIN and MAX are changed. 970in the range MIN and MAX are changed.
@@ -1339,13 +1348,13 @@ except that `]' is never special and `\\' quotes `^', `-' or `\\'
1339 (but not as the end of a range; quoting is never needed there). 1348 (but not as the end of a range; quoting is never needed there).
1340Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter. 1349Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
1341With arg "^a-zA-Z", skips nonletters stopping before first letter. 1350With arg "^a-zA-Z", skips nonletters stopping before first letter.
1342Returns the distance traveled, either zero or positive. 1351Char classes, e.g. `[:alpha:]', are supported.
1343Note that char classes, e.g. `[:alpha:]', are not currently supported; 1352
1344they will be treated as literals. */) 1353Returns the distance traveled, either zero or positive. */)
1345 (string, lim) 1354 (string, lim)
1346 Lisp_Object string, lim; 1355 Lisp_Object string, lim;
1347{ 1356{
1348 return skip_chars (1, string, lim); 1357 return skip_chars (1, string, lim, 1);
1349} 1358}
1350 1359
1351DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, 1360DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0,
@@ -1355,7 +1364,7 @@ Returns the distance traveled, either zero or negative. */)
1355 (string, lim) 1364 (string, lim)
1356 Lisp_Object string, lim; 1365 Lisp_Object string, lim;
1357{ 1366{
1358 return skip_chars (0, string, lim); 1367 return skip_chars (0, string, lim, 1);
1359} 1368}
1360 1369
1361DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0, 1370DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0,
@@ -1383,9 +1392,10 @@ This function returns the distance traveled, either zero or negative. */)
1383} 1392}
1384 1393
1385static Lisp_Object 1394static Lisp_Object
1386skip_chars (forwardp, string, lim) 1395skip_chars (forwardp, string, lim, handle_iso_classes)
1387 int forwardp; 1396 int forwardp;
1388 Lisp_Object string, lim; 1397 Lisp_Object string, lim;
1398 int handle_iso_classes;
1389{ 1399{
1390 register unsigned int c; 1400 register unsigned int c;
1391 unsigned char fastmap[0400]; 1401 unsigned char fastmap[0400];
@@ -1403,8 +1413,10 @@ skip_chars (forwardp, string, lim)
1403 int size_byte; 1413 int size_byte;
1404 const unsigned char *str; 1414 const unsigned char *str;
1405 int len; 1415 int len;
1416 Lisp_Object iso_classes;
1406 1417
1407 CHECK_STRING (string); 1418 CHECK_STRING (string);
1419 iso_classes = Qnil;
1408 1420
1409 if (NILP (lim)) 1421 if (NILP (lim))
1410 XSETINT (lim, forwardp ? ZV : BEGV); 1422 XSETINT (lim, forwardp ? ZV : BEGV);
@@ -1448,6 +1460,42 @@ skip_chars (forwardp, string, lim)
1448 { 1460 {
1449 c = str[i_byte++]; 1461 c = str[i_byte++];
1450 1462
1463 if (handle_iso_classes && c == '['
1464 && i_byte < size_byte
1465 && str[i_byte] == ':')
1466 {
1467 const unsigned char *class_beg = str + i_byte + 1;
1468 const unsigned char *class_end = class_beg;
1469 const unsigned char *class_limit = str + size_byte - 2;
1470 /* Leave room for the null. */
1471 unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1];
1472 re_wctype_t cc;
1473
1474 if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH)
1475 class_limit = class_beg + CHAR_CLASS_MAX_LENGTH;
1476
1477 while (class_end < class_limit
1478 && *class_end >= 'a' && *class_end <= 'z')
1479 class_end++;
1480
1481 if (class_end == class_beg
1482 || *class_end != ':' || class_end[1] != ']')
1483 goto not_a_class_name;
1484
1485 bcopy (class_beg, class_name, class_end - class_beg);
1486 class_name[class_end - class_beg] = 0;
1487
1488 cc = re_wctype (class_name);
1489 if (cc == 0)
1490 error ("Invalid ISO C character class");
1491
1492 iso_classes = Fcons (make_number (cc), iso_classes);
1493
1494 i_byte = class_end + 2 - str;
1495 continue;
1496 }
1497
1498 not_a_class_name:
1451 if (c == '\\') 1499 if (c == '\\')
1452 { 1500 {
1453 if (i_byte == size_byte) 1501 if (i_byte == size_byte)
@@ -1534,6 +1582,42 @@ skip_chars (forwardp, string, lim)
1534 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1582 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1535 i_byte += len; 1583 i_byte += len;
1536 1584
1585 if (handle_iso_classes && c == '['
1586 && i_byte < size_byte
1587 && STRING_CHAR (str + i_byte, size_byte - i_byte) == ':')
1588 {
1589 const unsigned char *class_beg = str + i_byte + 1;
1590 const unsigned char *class_end = class_beg;
1591 const unsigned char *class_limit = str + size_byte - 2;
1592 /* Leave room for the null. */
1593 unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1];
1594 re_wctype_t cc;
1595
1596 if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH)
1597 class_limit = class_beg + CHAR_CLASS_MAX_LENGTH;
1598
1599 while (class_end < class_limit
1600 && *class_end >= 'a' && *class_end <= 'z')
1601 class_end++;
1602
1603 if (class_end == class_beg
1604 || *class_end != ':' || class_end[1] != ']')
1605 goto not_a_class_name_multibyte;
1606
1607 bcopy (class_beg, class_name, class_end - class_beg);
1608 class_name[class_end - class_beg] = 0;
1609
1610 cc = re_wctype (class_name);
1611 if (cc == 0)
1612 error ("Invalid ISO C character class");
1613
1614 iso_classes = Fcons (make_number (cc), iso_classes);
1615
1616 i_byte = class_end + 2 - str;
1617 continue;
1618 }
1619
1620 not_a_class_name_multibyte:
1537 if (c == '\\') 1621 if (c == '\\')
1538 { 1622 {
1539 if (i_byte == size_byte) 1623 if (i_byte == size_byte)
@@ -1643,13 +1727,13 @@ skip_chars (forwardp, string, lim)
1643 1727
1644 if (forwardp) 1728 if (forwardp)
1645 { 1729 {
1646 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); 1730 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim));
1647 stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp; 1731 stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp;
1648 } 1732 }
1649 else 1733 else
1650 { 1734 {
1651 endp = CHAR_POS_ADDR (XINT (lim)); 1735 endp = CHAR_POS_ADDR (XINT (lim));
1652 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 1736 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
1653 } 1737 }
1654 1738
1655 immediate_quit = 1; 1739 immediate_quit = 1;
@@ -1667,9 +1751,17 @@ skip_chars (forwardp, string, lim)
1667 p = GAP_END_ADDR; 1751 p = GAP_END_ADDR;
1668 stop = endp; 1752 stop = endp;
1669 } 1753 }
1754 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes);
1755 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1756 {
1757 if (negate)
1758 break;
1759 else
1760 goto fwd_ok;
1761 }
1762
1670 if (! fastmap[*p]) 1763 if (! fastmap[*p])
1671 break; 1764 break;
1672 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes);
1673 if (! ASCII_CHAR_P (c)) 1765 if (! ASCII_CHAR_P (c))
1674 { 1766 {
1675 /* As we are looking at a multibyte character, we 1767 /* As we are looking at a multibyte character, we
@@ -1686,6 +1778,7 @@ skip_chars (forwardp, string, lim)
1686 if (!(negate ^ (i < n_char_ranges))) 1778 if (!(negate ^ (i < n_char_ranges)))
1687 break; 1779 break;
1688 } 1780 }
1781 fwd_ok:
1689 p += nbytes, pos++, pos_byte += nbytes; 1782 p += nbytes, pos++, pos_byte += nbytes;
1690 } 1783 }
1691 else 1784 else
@@ -1698,8 +1791,18 @@ skip_chars (forwardp, string, lim)
1698 p = GAP_END_ADDR; 1791 p = GAP_END_ADDR;
1699 stop = endp; 1792 stop = endp;
1700 } 1793 }
1794
1795 if (!NILP (iso_classes) && in_classes (*p, iso_classes))
1796 {
1797 if (negate)
1798 break;
1799 else
1800 goto fwd_unibyte_ok;
1801 }
1802
1701 if (!fastmap[*p]) 1803 if (!fastmap[*p])
1702 break; 1804 break;
1805 fwd_unibyte_ok:
1703 p++, pos++, pos_byte++; 1806 p++, pos++, pos_byte++;
1704 } 1807 }
1705 } 1808 }
@@ -1719,9 +1822,18 @@ skip_chars (forwardp, string, lim)
1719 } 1822 }
1720 prev_p = p; 1823 prev_p = p;
1721 while (--p >= stop && ! CHAR_HEAD_P (*p)); 1824 while (--p >= stop && ! CHAR_HEAD_P (*p));
1825 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH);
1826
1827 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1828 {
1829 if (negate)
1830 break;
1831 else
1832 goto back_ok;
1833 }
1834
1722 if (! fastmap[*p]) 1835 if (! fastmap[*p])
1723 break; 1836 break;
1724 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH);
1725 if (! ASCII_CHAR_P (c)) 1837 if (! ASCII_CHAR_P (c))
1726 { 1838 {
1727 /* See the comment in the previous similar code. */ 1839 /* See the comment in the previous similar code. */
@@ -1731,6 +1843,7 @@ skip_chars (forwardp, string, lim)
1731 if (!(negate ^ (i < n_char_ranges))) 1843 if (!(negate ^ (i < n_char_ranges)))
1732 break; 1844 break;
1733 } 1845 }
1846 back_ok:
1734 pos--, pos_byte -= prev_p - p; 1847 pos--, pos_byte -= prev_p - p;
1735 } 1848 }
1736 else 1849 else
@@ -1743,8 +1856,18 @@ skip_chars (forwardp, string, lim)
1743 p = GPT_ADDR; 1856 p = GPT_ADDR;
1744 stop = endp; 1857 stop = endp;
1745 } 1858 }
1859
1860 if (! NILP (iso_classes) && in_classes (p[-1], iso_classes))
1861 {
1862 if (negate)
1863 break;
1864 else
1865 goto back_unibyte_ok;
1866 }
1867
1746 if (!fastmap[p[-1]]) 1868 if (!fastmap[p[-1]])
1747 break; 1869 break;
1870 back_unibyte_ok:
1748 p--, pos--, pos_byte--; 1871 p--, pos--, pos_byte--;
1749 } 1872 }
1750 } 1873 }
@@ -1927,6 +2050,30 @@ skip_syntaxes (forwardp, string, lim)
1927 return make_number (PT - start_point); 2050 return make_number (PT - start_point);
1928 } 2051 }
1929} 2052}
2053
2054/* Return 1 if character C belongs to one of the ISO classes
2055 in the list ISO_CLASSES. Each class is represented by an
2056 integer which is its type according to re_wctype. */
2057
2058static int
2059in_classes (c, iso_classes)
2060 int c;
2061 Lisp_Object iso_classes;
2062{
2063 int fits_class = 0;
2064
2065 while (! NILP (iso_classes))
2066 {
2067 Lisp_Object elt;
2068 elt = XCAR (iso_classes);
2069 iso_classes = XCDR (iso_classes);
2070
2071 if (re_iswctype (c, XFASTINT (elt)))
2072 fits_class = 1;
2073 }
2074
2075 return fits_class;
2076}
1930 2077
1931/* Jump over a comment, assuming we are at the beginning of one. 2078/* Jump over a comment, assuming we are at the beginning of one.
1932 FROM is the current position. 2079 FROM is the current position.
@@ -2310,7 +2457,8 @@ scan_lists (from, count, depth, sexpflag)
2310 INC_BOTH (from, from_byte); 2457 INC_BOTH (from, from_byte);
2311 UPDATE_SYNTAX_TABLE_FORWARD (from); 2458 UPDATE_SYNTAX_TABLE_FORWARD (from);
2312 if (from < stop && comstart_first 2459 if (from < stop && comstart_first
2313 && SYNTAX_COMSTART_SECOND (FETCH_CHAR_AS_MULTIBYTE (from_byte)) 2460 && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte),
2461 SYNTAX_COMSTART_SECOND (c))
2314 && parse_sexp_ignore_comments) 2462 && parse_sexp_ignore_comments)
2315 { 2463 {
2316 /* we have encountered a comment start sequence and we 2464 /* we have encountered a comment start sequence and we
@@ -2636,7 +2784,7 @@ scan_lists (from, count, depth, sexpflag)
2636 Fcons (build_string ("Unbalanced parentheses"), 2784 Fcons (build_string ("Unbalanced parentheses"),
2637 Fcons (make_number (last_good), 2785 Fcons (make_number (last_good),
2638 Fcons (make_number (from), Qnil)))); 2786 Fcons (make_number (from), Qnil))));
2639 2787 abort ();
2640 /* NOTREACHED */ 2788 /* NOTREACHED */
2641} 2789}
2642 2790
@@ -2776,8 +2924,8 @@ scan_sexps_forward (stateptr, from, from_byte, end, targetdepth,
2776#define INC_FROM \ 2924#define INC_FROM \
2777do { prev_from = from; \ 2925do { prev_from = from; \
2778 prev_from_byte = from_byte; \ 2926 prev_from_byte = from_byte; \
2779 prev_from_syntax \ 2927 temp = FETCH_CHAR_AS_MULTIBYTE (prev_from_byte); \
2780 = SYNTAX_WITH_FLAGS (FETCH_CHAR_AS_MULTIBYTE (prev_from_byte)); \ 2928 prev_from_syntax = SYNTAX_WITH_FLAGS (temp); \
2781 INC_BOTH (from, from_byte); \ 2929 INC_BOTH (from, from_byte); \
2782 if (from < end) \ 2930 if (from < end) \
2783 UPDATE_SYNTAX_TABLE_FORWARD (from); \ 2931 UPDATE_SYNTAX_TABLE_FORWARD (from); \
@@ -2852,7 +3000,8 @@ do { prev_from = from; \
2852 curlevel->last = -1; 3000 curlevel->last = -1;
2853 3001
2854 SETUP_SYNTAX_TABLE (prev_from, 1); 3002 SETUP_SYNTAX_TABLE (prev_from, 1);
2855 prev_from_syntax = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); 3003 temp = FETCH_CHAR (prev_from_byte);
3004 prev_from_syntax = SYNTAX_WITH_FLAGS (temp);
2856 UPDATE_SYNTAX_TABLE_FORWARD (from); 3005 UPDATE_SYNTAX_TABLE_FORWARD (from);
2857 3006
2858 /* Enter the loop at a place appropriate for initial state. */ 3007 /* Enter the loop at a place appropriate for initial state. */
@@ -2931,7 +3080,8 @@ do { prev_from = from; \
2931 while (from < end) 3080 while (from < end)
2932 { 3081 {
2933 /* Some compilers can't handle this inside the switch. */ 3082 /* Some compilers can't handle this inside the switch. */
2934 temp = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (from_byte)); 3083 temp = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3084 temp = SYNTAX (temp);
2935 switch (temp) 3085 switch (temp)
2936 { 3086 {
2937 case Scharquote: 3087 case Scharquote:
diff --git a/src/syntax.h b/src/syntax.h
index 21f24dbd100..ba862655cfe 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -89,24 +89,24 @@ enum syntaxcode
89 89
90#ifdef __GNUC__ 90#ifdef __GNUC__
91#define SYNTAX(c) \ 91#define SYNTAX(c) \
92 ({ Lisp_Object temp; \ 92 ({ Lisp_Object _syntax_temp; \
93 temp = SYNTAX_ENTRY (c); \ 93 _syntax_temp = SYNTAX_ENTRY (c); \
94 (CONSP (temp) \ 94 (CONSP (_syntax_temp) \
95 ? (enum syntaxcode) (XINT (XCAR (temp)) & 0xff) \ 95 ? (enum syntaxcode) (XINT (XCAR (_syntax_temp)) & 0xff) \
96 : Swhitespace); }) 96 : Swhitespace); })
97 97
98#define SYNTAX_WITH_FLAGS(c) \ 98#define SYNTAX_WITH_FLAGS(c) \
99 ({ Lisp_Object temp; \ 99 ({ Lisp_Object _syntax_temp; \
100 temp = SYNTAX_ENTRY (c); \ 100 _syntax_temp = SYNTAX_ENTRY (c); \
101 (CONSP (temp) \ 101 (CONSP (_syntax_temp) \
102 ? XINT (XCAR (temp)) \ 102 ? XINT (XCAR (_syntax_temp)) \
103 : (int) Swhitespace); }) 103 : (int) Swhitespace); })
104 104
105#define SYNTAX_MATCH(c) \ 105#define SYNTAX_MATCH(c) \
106 ({ Lisp_Object temp; \ 106 ({ Lisp_Object _syntax_temp; \
107 temp = SYNTAX_ENTRY (c); \ 107 _syntax_temp = SYNTAX_ENTRY (c); \
108 (CONSP (temp) \ 108 (CONSP (_syntax_temp) \
109 ? XCDR (temp) \ 109 ? XCDR (_syntax_temp) \
110 : Qnil); }) 110 : Qnil); })
111#else 111#else
112extern Lisp_Object syntax_temp; 112extern Lisp_Object syntax_temp;
diff --git a/src/syssignal.h b/src/syssignal.h
index 2b536758e27..cef71f7459a 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -18,6 +18,8 @@ along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */ 19Boston, MA 02111-1307, USA. */
20 20
21extern void init_signals P_ ((void));
22
21#ifdef POSIX_SIGNALS 23#ifdef POSIX_SIGNALS
22 24
23/* Don't #include <signal.h>. That header should always be #included 25/* Don't #include <signal.h>. That header should always be #included
@@ -31,7 +33,6 @@ Boston, MA 02111-1307, USA. */
31#define SIGEMPTYMASK (empty_mask) 33#define SIGEMPTYMASK (empty_mask)
32#define SIGFULLMASK (full_mask) 34#define SIGFULLMASK (full_mask)
33extern sigset_t empty_mask, full_mask; 35extern sigset_t empty_mask, full_mask;
34extern void init_signals P_ ((void));
35 36
36/* POSIX pretty much destroys any possibility of writing sigmask as a 37/* POSIX pretty much destroys any possibility of writing sigmask as a
37 macro in standard C. We always define our own version because the 38 macro in standard C. We always define our own version because the
diff --git a/src/textprop.c b/src/textprop.c
index 4f13aefb1be..c8ec008dcbd 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -637,30 +637,13 @@ get_char_property_and_overlay (position, prop, object, overlay)
637 } 637 }
638 if (BUFFERP (object)) 638 if (BUFFERP (object))
639 { 639 {
640 int posn = XINT (position);
641 int noverlays; 640 int noverlays;
642 Lisp_Object *overlay_vec, tem; 641 Lisp_Object *overlay_vec;
643 int len;
644 struct buffer *obuf = current_buffer; 642 struct buffer *obuf = current_buffer;
645 643
646 set_buffer_temp (XBUFFER (object)); 644 set_buffer_temp (XBUFFER (object));
647 645
648 /* First try with room for 40 overlays. */ 646 GET_OVERLAYS_AT (XINT (position), overlay_vec, noverlays, NULL, 0);
649 len = 40;
650 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
651
652 noverlays = overlays_at (posn, 0, &overlay_vec, &len,
653 NULL, NULL, 0);
654
655 /* If there are more than 40,
656 make enough space for all, and try again. */
657 if (noverlays > len)
658 {
659 len = noverlays;
660 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
661 noverlays = overlays_at (posn, 0, &overlay_vec, &len,
662 NULL, NULL, 0);
663 }
664 noverlays = sort_overlays (overlay_vec, noverlays, w); 647 noverlays = sort_overlays (overlay_vec, noverlays, w);
665 648
666 set_buffer_temp (obuf); 649 set_buffer_temp (obuf);
@@ -668,7 +651,7 @@ get_char_property_and_overlay (position, prop, object, overlay)
668 /* Now check the overlays in order of decreasing priority. */ 651 /* Now check the overlays in order of decreasing priority. */
669 while (--noverlays >= 0) 652 while (--noverlays >= 0)
670 { 653 {
671 tem = Foverlay_get (overlay_vec[noverlays], prop); 654 Lisp_Object tem = Foverlay_get (overlay_vec[noverlays], prop);
672 if (!NILP (tem)) 655 if (!NILP (tem))
673 { 656 {
674 if (overlay) 657 if (overlay)
diff --git a/src/undo.c b/src/undo.c
index dd086db6c40..9fdc46a3b13 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -292,14 +292,15 @@ but another undo command will undo to the previous boundary. */)
292 292
293/* At garbage collection time, make an undo list shorter at the end, 293/* At garbage collection time, make an undo list shorter at the end,
294 returning the truncated list. 294 returning the truncated list.
295 MINSIZE and MAXSIZE are the limits on size allowed, as described below. 295 MINSIZE, MAXSIZE and LIMITSIZE are the limits on size allowed,
296 In practice, these are the values of undo-limit and 296 as described below.
297 undo-strong-limit. */ 297 In practice, these are the values of undo-limit,
298 undo-strong-limit, and undo-outer-limit. */
298 299
299Lisp_Object 300Lisp_Object
300truncate_undo_list (list, minsize, maxsize) 301truncate_undo_list (list, minsize, maxsize, limitsize)
301 Lisp_Object list; 302 Lisp_Object list;
302 int minsize, maxsize; 303 int minsize, maxsize, limitsize;
303{ 304{
304 Lisp_Object prev, next, last_boundary; 305 Lisp_Object prev, next, last_boundary;
305 int size_so_far = 0; 306 int size_so_far = 0;
@@ -308,7 +309,8 @@ truncate_undo_list (list, minsize, maxsize)
308 next = list; 309 next = list;
309 last_boundary = Qnil; 310 last_boundary = Qnil;
310 311
311 /* Always preserve at least the most recent undo record. 312 /* Always preserve at least the most recent undo record
313 unless it is really horribly big.
312 If the first element is an undo boundary, skip past it. 314 If the first element is an undo boundary, skip past it.
313 315
314 Skip, skip, skip the undo, skip, skip, skip the undo, 316 Skip, skip, skip the undo, skip, skip, skip the undo,
@@ -323,6 +325,7 @@ truncate_undo_list (list, minsize, maxsize)
323 prev = next; 325 prev = next;
324 next = XCDR (next); 326 next = XCDR (next);
325 } 327 }
328
326 while (CONSP (next) && ! NILP (XCAR (next))) 329 while (CONSP (next) && ! NILP (XCAR (next)))
327 { 330 {
328 Lisp_Object elt; 331 Lisp_Object elt;
@@ -338,13 +341,20 @@ truncate_undo_list (list, minsize, maxsize)
338 + SCHARS (XCAR (elt))); 341 + SCHARS (XCAR (elt)));
339 } 342 }
340 343
344 /* If we reach LIMITSIZE before the first boundary,
345 we're heading for memory full, so truncate the list to nothing. */
346 if (size_so_far > limitsize)
347 return Qnil;
348
341 /* Advance to next element. */ 349 /* Advance to next element. */
342 prev = next; 350 prev = next;
343 next = XCDR (next); 351 next = XCDR (next);
344 } 352 }
353
345 if (CONSP (next)) 354 if (CONSP (next))
346 last_boundary = prev; 355 last_boundary = prev;
347 356
357 /* Keep more if it fits. */
348 while (CONSP (next)) 358 while (CONSP (next))
349 { 359 {
350 Lisp_Object elt; 360 Lisp_Object elt;
diff --git a/src/w32.c b/src/w32.c
index 98d630529e6..12d1f21b091 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -105,7 +105,7 @@ void globals_of_w32 ();
105extern Lisp_Object Vw32_downcase_file_names; 105extern Lisp_Object Vw32_downcase_file_names;
106extern Lisp_Object Vw32_generate_fake_inodes; 106extern Lisp_Object Vw32_generate_fake_inodes;
107extern Lisp_Object Vw32_get_true_file_attributes; 107extern Lisp_Object Vw32_get_true_file_attributes;
108extern Lisp_Object Vw32_num_mouse_buttons; 108extern int w32_num_mouse_buttons;
109 109
110 110
111/* 111/*
@@ -1094,7 +1094,7 @@ init_environment (char ** argv)
1094 /* Determine if there is a middle mouse button, to allow parse_button 1094 /* Determine if there is a middle mouse button, to allow parse_button
1095 to decide whether right mouse events should be mouse-2 or 1095 to decide whether right mouse events should be mouse-2 or
1096 mouse-3. */ 1096 mouse-3. */
1097 XSETINT (Vw32_num_mouse_buttons, GetSystemMetrics (SM_CMOUSEBUTTONS)); 1097 w32_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
1098 1098
1099 init_user_info (); 1099 init_user_info ();
1100} 1100}
@@ -1627,7 +1627,7 @@ static WIN32_FIND_DATA dir_find_data;
1627/* Support shares on a network resource as subdirectories of a read-only 1627/* Support shares on a network resource as subdirectories of a read-only
1628 root directory. */ 1628 root directory. */
1629static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE; 1629static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE;
1630HANDLE open_unc_volume (char *); 1630HANDLE open_unc_volume (const char *);
1631char *read_unc_volume (HANDLE, char *, int); 1631char *read_unc_volume (HANDLE, char *, int);
1632void close_unc_volume (HANDLE); 1632void close_unc_volume (HANDLE);
1633 1633
@@ -1740,7 +1740,7 @@ readdir (DIR *dirp)
1740} 1740}
1741 1741
1742HANDLE 1742HANDLE
1743open_unc_volume (char *path) 1743open_unc_volume (const char *path)
1744{ 1744{
1745 NETRESOURCE nr; 1745 NETRESOURCE nr;
1746 HANDLE henum; 1746 HANDLE henum;
@@ -1797,7 +1797,7 @@ close_unc_volume (HANDLE henum)
1797} 1797}
1798 1798
1799DWORD 1799DWORD
1800unc_volume_file_attributes (char *path) 1800unc_volume_file_attributes (const char *path)
1801{ 1801{
1802 HANDLE henum; 1802 HANDLE henum;
1803 DWORD attrs; 1803 DWORD attrs;
@@ -3486,7 +3486,7 @@ sys_pipe (int * phandles)
3486} 3486}
3487 3487
3488/* From ntproc.c */ 3488/* From ntproc.c */
3489extern Lisp_Object Vw32_pipe_read_delay; 3489extern int w32_pipe_read_delay;
3490 3490
3491/* Function to do blocking read of one byte, needed to implement 3491/* Function to do blocking read of one byte, needed to implement
3492 select. It is only allowed on sockets and pipes. */ 3492 select. It is only allowed on sockets and pipes. */
@@ -3526,7 +3526,7 @@ _sys_read_ahead (int fd)
3526 shell on NT is very slow if we don't do this. */ 3526 shell on NT is very slow if we don't do this. */
3527 if (rc > 0) 3527 if (rc > 0)
3528 { 3528 {
3529 int wait = XINT (Vw32_pipe_read_delay); 3529 int wait = w32_pipe_read_delay;
3530 3530
3531 if (wait > 0) 3531 if (wait > 0)
3532 Sleep (wait); 3532 Sleep (wait);
diff --git a/src/w32console.c b/src/w32console.c
index 50cbfb281d3..cd71f0ba6ad 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -53,20 +53,20 @@ extern int read_input_pending ();
53extern struct frame * updating_frame; 53extern struct frame * updating_frame;
54extern int meta_key; 54extern int meta_key;
55 55
56static void move_cursor (int row, int col); 56static void w32con_move_cursor (int row, int col);
57static void clear_to_end (void); 57static void w32con_clear_to_end (void);
58static void clear_frame (void); 58static void w32con_clear_frame (void);
59static void clear_end_of_line (int); 59static void w32con_clear_end_of_line (int);
60static void ins_del_lines (int vpos, int n); 60static void w32con_ins_del_lines (int vpos, int n);
61static void insert_glyphs (struct glyph *start, int len); 61static void w32con_insert_glyphs (struct glyph *start, int len);
62static void write_glyphs (struct glyph *string, int len); 62static void w32con_write_glyphs (struct glyph *string, int len);
63static void delete_glyphs (int n); 63static void w32con_delete_glyphs (int n);
64void w32_sys_ring_bell (void); 64void w32_sys_ring_bell (void);
65static void reset_terminal_modes (void); 65static void w32con_reset_terminal_modes (void);
66static void set_terminal_modes (void); 66static void w32con_set_terminal_modes (void);
67static void set_terminal_window (int size); 67static void w32con_set_terminal_window (int size);
68static void update_begin (struct frame * f); 68static void w32con_update_begin (struct frame * f);
69static void update_end (struct frame * f); 69static void w32con_update_end (struct frame * f);
70static WORD w32_face_attributes (struct frame *f, int face_id); 70static WORD w32_face_attributes (struct frame *f, int face_id);
71 71
72static COORD cursor_coords; 72static COORD cursor_coords;
@@ -103,8 +103,8 @@ ctrl_c_handler (unsigned long type)
103#define PICK_FRAME() (updating_frame ? updating_frame : SELECTED_FRAME ()) 103#define PICK_FRAME() (updating_frame ? updating_frame : SELECTED_FRAME ())
104 104
105/* Move the cursor to (row, col). */ 105/* Move the cursor to (row, col). */
106void 106static void
107move_cursor (int row, int col) 107w32con_move_cursor (int row, int col)
108{ 108{
109 cursor_coords.X = col; 109 cursor_coords.X = col;
110 cursor_coords.Y = row; 110 cursor_coords.Y = row;
@@ -116,18 +116,18 @@ move_cursor (int row, int col)
116} 116}
117 117
118/* Clear from cursor to end of screen. */ 118/* Clear from cursor to end of screen. */
119void 119static void
120clear_to_end (void) 120w32con_clear_to_end (void)
121{ 121{
122 struct frame * f = PICK_FRAME (); 122 struct frame * f = PICK_FRAME ();
123 123
124 clear_end_of_line (FRAME_COLS (f) - 1); 124 w32con_clear_end_of_line (FRAME_COLS (f) - 1);
125 ins_del_lines (cursor_coords.Y, FRAME_LINES (f) - cursor_coords.Y - 1); 125 w32con_ins_del_lines (cursor_coords.Y, FRAME_LINES (f) - cursor_coords.Y - 1);
126} 126}
127 127
128/* Clear the frame. */ 128/* Clear the frame. */
129void 129static void
130clear_frame (void) 130w32con_clear_frame (void)
131{ 131{
132 struct frame * f = PICK_FRAME (); 132 struct frame * f = PICK_FRAME ();
133 COORD dest; 133 COORD dest;
@@ -144,7 +144,7 @@ clear_frame (void)
144 FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r); 144 FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r);
145 FillConsoleOutputCharacter (cur_screen, ' ', n, dest, &r); 145 FillConsoleOutputCharacter (cur_screen, ' ', n, dest, &r);
146 146
147 move_cursor (0, 0); 147 w32con_move_cursor (0, 0);
148} 148}
149 149
150 150
@@ -152,8 +152,8 @@ static struct glyph glyph_base[256];
152static BOOL ceol_initialized = FALSE; 152static BOOL ceol_initialized = FALSE;
153 153
154/* Clear from Cursor to end (what's "standout marker"?). */ 154/* Clear from Cursor to end (what's "standout marker"?). */
155void 155static void
156clear_end_of_line (int end) 156w32con_clear_end_of_line (int end)
157{ 157{
158 if (!ceol_initialized) 158 if (!ceol_initialized)
159 { 159 {
@@ -164,12 +164,12 @@ clear_end_of_line (int end)
164 } 164 }
165 ceol_initialized = TRUE; 165 ceol_initialized = TRUE;
166 } 166 }
167 write_glyphs (glyph_base, end - cursor_coords.X); /* fencepost ? */ 167 w32con_write_glyphs (glyph_base, end - cursor_coords.X); /* fencepost ? */
168} 168}
169 169
170/* Insert n lines at vpos. if n is negative delete -n lines. */ 170/* Insert n lines at vpos. if n is negative delete -n lines. */
171void 171static void
172ins_del_lines (int vpos, int n) 172w32con_ins_del_lines (int vpos, int n)
173{ 173{
174 int i, nb; 174 int i, nb;
175 SMALL_RECT scroll; 175 SMALL_RECT scroll;
@@ -212,8 +212,8 @@ ins_del_lines (int vpos, int n)
212 { 212 {
213 for (i = scroll.Bottom; i < dest.Y; i++) 213 for (i = scroll.Bottom; i < dest.Y; i++)
214 { 214 {
215 move_cursor (i, 0); 215 w32con_move_cursor (i, 0);
216 clear_end_of_line (FRAME_COLS (f)); 216 w32con_clear_end_of_line (FRAME_COLS (f));
217 } 217 }
218 } 218 }
219 } 219 }
@@ -225,8 +225,8 @@ ins_del_lines (int vpos, int n)
225 { 225 {
226 for (i = nb; i < scroll.Top; i++) 226 for (i = nb; i < scroll.Top; i++)
227 { 227 {
228 move_cursor (i, 0); 228 w32con_move_cursor (i, 0);
229 clear_end_of_line (FRAME_COLS (f)); 229 w32con_clear_end_of_line (FRAME_COLS (f));
230 } 230 }
231 } 231 }
232 } 232 }
@@ -240,7 +240,7 @@ ins_del_lines (int vpos, int n)
240#define LEFT 1 240#define LEFT 1
241#define RIGHT 0 241#define RIGHT 0
242 242
243void 243static void
244scroll_line (int dist, int direction) 244scroll_line (int dist, int direction)
245{ 245{
246 /* The idea here is to implement a horizontal scroll in one line to 246 /* The idea here is to implement a horizontal scroll in one line to
@@ -275,8 +275,8 @@ scroll_line (int dist, int direction)
275 275
276 276
277/* If start is zero insert blanks instead of a string at start ?. */ 277/* If start is zero insert blanks instead of a string at start ?. */
278void 278static void
279insert_glyphs (register struct glyph *start, register int len) 279w32con_insert_glyphs (register struct glyph *start, register int len)
280{ 280{
281 scroll_line (len, RIGHT); 281 scroll_line (len, RIGHT);
282 282
@@ -286,18 +286,18 @@ insert_glyphs (register struct glyph *start, register int len)
286 /* Print the first len characters of start, cursor_coords.X adjusted 286 /* Print the first len characters of start, cursor_coords.X adjusted
287 by write_glyphs. */ 287 by write_glyphs. */
288 288
289 write_glyphs (start, len); 289 w32con_write_glyphs (start, len);
290 } 290 }
291 else 291 else
292 { 292 {
293 clear_end_of_line (cursor_coords.X + len); 293 w32con_clear_end_of_line (cursor_coords.X + len);
294 } 294 }
295} 295}
296 296
297extern unsigned char *terminal_encode_buffer; 297extern unsigned char *terminal_encode_buffer;
298 298
299void 299static void
300write_glyphs (register struct glyph *string, register int len) 300w32con_write_glyphs (register struct glyph *string, register int len)
301{ 301{
302 int produced, consumed; 302 int produced, consumed;
303 DWORD r; 303 DWORD r;
@@ -350,7 +350,7 @@ write_glyphs (register struct glyph *string, register int len)
350 } 350 }
351 351
352 cursor_coords.X += produced; 352 cursor_coords.X += produced;
353 move_cursor (cursor_coords.Y, cursor_coords.X); 353 w32con_move_cursor (cursor_coords.Y, cursor_coords.X);
354 } 354 }
355 len -= consumed; 355 len -= consumed;
356 n -= consumed; 356 n -= consumed;
@@ -393,8 +393,8 @@ write_glyphs (register struct glyph *string, register int len)
393} 393}
394 394
395 395
396void 396static void
397delete_glyphs (int n) 397w32con_delete_glyphs (int n)
398{ 398{
399 /* delete chars means scroll chars from cursor_coords.X + n to 399 /* delete chars means scroll chars from cursor_coords.X + n to
400 cursor_coords.X, anything beyond the edge of the screen should 400 cursor_coords.X, anything beyond the edge of the screen should
@@ -452,8 +452,8 @@ SOUND is nil to use the normal beep. */)
452 return sound; 452 return sound;
453} 453}
454 454
455void 455static void
456reset_terminal_modes (void) 456w32con_reset_terminal_modes (void)
457{ 457{
458#ifdef USE_SEPARATE_SCREEN 458#ifdef USE_SEPARATE_SCREEN
459 SetConsoleActiveScreenBuffer (prev_screen); 459 SetConsoleActiveScreenBuffer (prev_screen);
@@ -463,8 +463,8 @@ reset_terminal_modes (void)
463 SetConsoleMode (keyboard_handle, prev_console_mode); 463 SetConsoleMode (keyboard_handle, prev_console_mode);
464} 464}
465 465
466void 466static void
467set_terminal_modes (void) 467w32con_set_terminal_modes (void)
468{ 468{
469 CONSOLE_CURSOR_INFO cci; 469 CONSOLE_CURSOR_INFO cci;
470 470
@@ -486,19 +486,19 @@ set_terminal_modes (void)
486 clumps rather than one-character-at-a-time... 486 clumps rather than one-character-at-a-time...
487 487
488 we'll start with not moving the cursor while an update is in progress. */ 488 we'll start with not moving the cursor while an update is in progress. */
489void 489static void
490update_begin (struct frame * f) 490w32con_update_begin (struct frame * f)
491{ 491{
492} 492}
493 493
494void 494static void
495update_end (struct frame * f) 495w32con_update_end (struct frame * f)
496{ 496{
497 SetConsoleCursorPosition (cur_screen, cursor_coords); 497 SetConsoleCursorPosition (cur_screen, cursor_coords);
498} 498}
499 499
500void 500static void
501set_terminal_window (int size) 501w32con_set_terminal_window (int size)
502{ 502{
503} 503}
504 504
@@ -576,21 +576,21 @@ initialize_w32_display (void)
576{ 576{
577 CONSOLE_SCREEN_BUFFER_INFO info; 577 CONSOLE_SCREEN_BUFFER_INFO info;
578 578
579 cursor_to_hook = move_cursor; 579 cursor_to_hook = w32con_move_cursor;
580 raw_cursor_to_hook = move_cursor; 580 raw_cursor_to_hook = w32con_move_cursor;
581 clear_to_end_hook = clear_to_end; 581 clear_to_end_hook = w32con_clear_to_end;
582 clear_frame_hook = clear_frame; 582 clear_frame_hook = w32con_clear_frame;
583 clear_end_of_line_hook = clear_end_of_line; 583 clear_end_of_line_hook = w32con_clear_end_of_line;
584 ins_del_lines_hook = ins_del_lines; 584 ins_del_lines_hook = w32con_ins_del_lines;
585 insert_glyphs_hook = insert_glyphs; 585 insert_glyphs_hook = w32con_insert_glyphs;
586 write_glyphs_hook = write_glyphs; 586 write_glyphs_hook = w32con_write_glyphs;
587 delete_glyphs_hook = delete_glyphs; 587 delete_glyphs_hook = w32con_delete_glyphs;
588 ring_bell_hook = w32_sys_ring_bell; 588 ring_bell_hook = w32_sys_ring_bell;
589 reset_terminal_modes_hook = reset_terminal_modes; 589 reset_terminal_modes_hook = w32con_reset_terminal_modes;
590 set_terminal_modes_hook = set_terminal_modes; 590 set_terminal_modes_hook = w32con_set_terminal_modes;
591 set_terminal_window_hook = set_terminal_window; 591 set_terminal_window_hook = w32con_set_terminal_window;
592 update_begin_hook = update_begin; 592 update_begin_hook = w32con_update_begin;
593 update_end_hook = update_end; 593 update_end_hook = w32con_update_end;
594 594
595 read_socket_hook = w32_console_read_socket; 595 read_socket_hook = w32_console_read_socket;
596 mouse_position_hook = w32_console_mouse_position; 596 mouse_position_hook = w32_console_mouse_position;
diff --git a/src/w32fns.c b/src/w32fns.c
index ebdf5c3ccca..a5f8c4b61f3 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1,5 +1,5 @@
1/* Graphical user interface functions for the Microsoft W32 API. 1/* Graphical user interface functions for the Microsoft W32 API.
2 Copyright (C) 1989, 92, 93, 94, 95, 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright (C) 1989, 1992, 93, 94, 95, 96, 97, 98, 99, 2000, 01, 04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -89,7 +89,7 @@ Lisp_Object Vw32_pass_alt_to_system;
89Lisp_Object Vw32_alt_is_meta; 89Lisp_Object Vw32_alt_is_meta;
90 90
91/* If non-zero, the windows virtual key code for an alternative quit key. */ 91/* If non-zero, the windows virtual key code for an alternative quit key. */
92Lisp_Object Vw32_quit_key; 92int w32_quit_key;
93 93
94/* Non nil if left window key events are passed on to Windows (this only 94/* Non nil if left window key events are passed on to Windows (this only
95 affects whether "tapping" the key opens the Start menu). */ 95 affects whether "tapping" the key opens the Start menu). */
@@ -133,11 +133,11 @@ Lisp_Object Vw32_enable_palette;
133 133
134/* Control how close left/right button down events must be to 134/* Control how close left/right button down events must be to
135 be converted to a middle button down event. */ 135 be converted to a middle button down event. */
136Lisp_Object Vw32_mouse_button_tolerance; 136int w32_mouse_button_tolerance;
137 137
138/* Minimum interval between mouse movement (and scroll bar drag) 138/* Minimum interval between mouse movement (and scroll bar drag)
139 events that are passed on to the event loop. */ 139 events that are passed on to the event loop. */
140Lisp_Object Vw32_mouse_move_interval; 140int w32_mouse_move_interval;
141 141
142/* Flag to indicate if XBUTTON events should be passed on to Windows. */ 142/* Flag to indicate if XBUTTON events should be passed on to Windows. */
143int w32_pass_extra_mouse_buttons_to_system; 143int w32_pass_extra_mouse_buttons_to_system;
@@ -235,6 +235,9 @@ Lisp_Object Qw32_charset_mac;
235Lisp_Object Qw32_charset_unicode; 235Lisp_Object Qw32_charset_unicode;
236#endif 236#endif
237 237
238/* The ANSI codepage. */
239int w32_ansi_code_page;
240
238/* Prefix for system colors. */ 241/* Prefix for system colors. */
239#define SYSTEM_COLOR_PREFIX "System" 242#define SYSTEM_COLOR_PREFIX "System"
240#define SYSTEM_COLOR_PREFIX_LEN (sizeof (SYSTEM_COLOR_PREFIX) - 1) 243#define SYSTEM_COLOR_PREFIX_LEN (sizeof (SYSTEM_COLOR_PREFIX) - 1)
@@ -281,7 +284,7 @@ int image_cache_refcount, dpyinfo_refcount;
281 284
282 285
283/* From w32term.c. */ 286/* From w32term.c. */
284extern Lisp_Object Vw32_num_mouse_buttons; 287extern int w32_num_mouse_buttons;
285extern Lisp_Object Vw32_recognize_altgr; 288extern Lisp_Object Vw32_recognize_altgr;
286 289
287extern HWND w32_system_caret_hwnd; 290extern HWND w32_system_caret_hwnd;
@@ -463,7 +466,7 @@ if the entry is new. */)
463 CHECK_NUMBER (blue); 466 CHECK_NUMBER (blue);
464 CHECK_STRING (name); 467 CHECK_STRING (name);
465 468
466 XSET (rgb, Lisp_Int, RGB(XUINT (red), XUINT (green), XUINT (blue))); 469 XSETINT (rgb, RGB(XUINT (red), XUINT (green), XUINT (blue)));
467 470
468 BLOCK_INPUT; 471 BLOCK_INPUT;
469 472
@@ -826,7 +829,7 @@ w32_to_x_color (rgb)
826 return Qnil; 829 return Qnil;
827} 830}
828 831
829COLORREF 832static Lisp_Object
830w32_color_map_lookup (colorname) 833w32_color_map_lookup (colorname)
831 char *colorname; 834 char *colorname;
832{ 835{
@@ -845,7 +848,7 @@ w32_color_map_lookup (colorname)
845 848
846 if (lstrcmpi (SDATA (tem), colorname) == 0) 849 if (lstrcmpi (SDATA (tem), colorname) == 0)
847 { 850 {
848 ret = XUINT (Fcdr (elt)); 851 ret = Fcdr (elt);
849 break; 852 break;
850 } 853 }
851 854
@@ -908,7 +911,7 @@ add_system_logical_colors_to_map (system_colors)
908} 911}
909 912
910 913
911COLORREF 914static Lisp_Object
912x_to_w32_color (colorname) 915x_to_w32_color (colorname)
913 char * colorname; 916 char * colorname;
914{ 917{
@@ -968,7 +971,8 @@ x_to_w32_color (colorname)
968 if (i == 2) 971 if (i == 2)
969 { 972 {
970 UNBLOCK_INPUT; 973 UNBLOCK_INPUT;
971 return (colorval); 974 XSETINT (ret, colorval);
975 return ret;
972 } 976 }
973 color = end; 977 color = end;
974 } 978 }
@@ -1021,7 +1025,8 @@ x_to_w32_color (colorname)
1021 if (*end != '\0') 1025 if (*end != '\0')
1022 break; 1026 break;
1023 UNBLOCK_INPUT; 1027 UNBLOCK_INPUT;
1024 return (colorval); 1028 XSETINT (ret, colorval);
1029 return ret;
1025 } 1030 }
1026 if (*end != '/') 1031 if (*end != '/')
1027 break; 1032 break;
@@ -1062,7 +1067,8 @@ x_to_w32_color (colorname)
1062 if (*end != '\0') 1067 if (*end != '\0')
1063 break; 1068 break;
1064 UNBLOCK_INPUT; 1069 UNBLOCK_INPUT;
1065 return (colorval); 1070 XSETINT (ret, colorval);
1071 return ret;
1066 } 1072 }
1067 if (*end != '/') 1073 if (*end != '/')
1068 break; 1074 break;
@@ -2416,6 +2422,10 @@ Lisp_Object w32_grabbed_keys;
2416#define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255) 2422#define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255)
2417#define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8) 2423#define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8)
2418 2424
2425#define RAW_HOTKEY_ID(k) ((k) & 0xbfff)
2426#define RAW_HOTKEY_VK_CODE(k) ((k) & 255)
2427#define RAW_HOTKEY_MODIFIERS(k) ((k) >> 8)
2428
2419/* Register hot-keys for reserved key combinations when Emacs has 2429/* Register hot-keys for reserved key combinations when Emacs has
2420 keyboard focus, since this is the only way Emacs can receive key 2430 keyboard focus, since this is the only way Emacs can receive key
2421 combinations like Alt-Tab which are used by the system. */ 2431 combinations like Alt-Tab which are used by the system. */
@@ -2497,20 +2507,20 @@ w32_msg_pump (deferred_msg * msg_buf)
2497 focus_window = GetFocus (); 2507 focus_window = GetFocus ();
2498 if (focus_window != NULL) 2508 if (focus_window != NULL)
2499 RegisterHotKey (focus_window, 2509 RegisterHotKey (focus_window,
2500 HOTKEY_ID (msg.wParam), 2510 RAW_HOTKEY_ID (msg.wParam),
2501 HOTKEY_MODIFIERS (msg.wParam), 2511 RAW_HOTKEY_MODIFIERS (msg.wParam),
2502 HOTKEY_VK_CODE (msg.wParam)); 2512 RAW_HOTKEY_VK_CODE (msg.wParam));
2503 /* Reply is not expected. */ 2513 /* Reply is not expected. */
2504 break; 2514 break;
2505 case WM_EMACS_UNREGISTER_HOT_KEY: 2515 case WM_EMACS_UNREGISTER_HOT_KEY:
2506 focus_window = GetFocus (); 2516 focus_window = GetFocus ();
2507 if (focus_window != NULL) 2517 if (focus_window != NULL)
2508 UnregisterHotKey (focus_window, HOTKEY_ID (msg.wParam)); 2518 UnregisterHotKey (focus_window, RAW_HOTKEY_ID (msg.wParam));
2509 /* Mark item as erased. NB: this code must be 2519 /* Mark item as erased. NB: this code must be
2510 thread-safe. The next line is okay because the cons 2520 thread-safe. The next line is okay because the cons
2511 cell is never made into garbage and is not relocated by 2521 cell is never made into garbage and is not relocated by
2512 GC. */ 2522 GC. */
2513 XSETCAR ((Lisp_Object) msg.lParam, Qnil); 2523 XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil);
2514 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2524 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2515 abort (); 2525 abort ();
2516 break; 2526 break;
@@ -2518,7 +2528,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2518 { 2528 {
2519 int vk_code = (int) msg.wParam; 2529 int vk_code = (int) msg.wParam;
2520 int cur_state = (GetKeyState (vk_code) & 1); 2530 int cur_state = (GetKeyState (vk_code) & 1);
2521 Lisp_Object new_state = (Lisp_Object) msg.lParam; 2531 Lisp_Object new_state = (Lisp_Object) ((EMACS_INT) msg.lParam);
2522 2532
2523 /* NB: This code must be thread-safe. It is safe to 2533 /* NB: This code must be thread-safe. It is safe to
2524 call NILP because symbols are not relocated by GC, 2534 call NILP because symbols are not relocated by GC,
@@ -2708,7 +2718,7 @@ post_character_message (hwnd, msg, wParam, lParam, modifiers)
2708 c = make_ctrl_char (c) & 0377; 2718 c = make_ctrl_char (c) & 0377;
2709 if (c == quit_char 2719 if (c == quit_char
2710 || (wmsg.dwModifiers == 0 && 2720 || (wmsg.dwModifiers == 0 &&
2711 XFASTINT (Vw32_quit_key) && wParam == XFASTINT (Vw32_quit_key))) 2721 w32_quit_key && wParam == w32_quit_key))
2712 { 2722 {
2713 Vquit_flag = Qt; 2723 Vquit_flag = Qt;
2714 2724
@@ -3118,7 +3128,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3118 are used together, but only if user has two button mouse. */ 3128 are used together, but only if user has two button mouse. */
3119 case WM_LBUTTONDOWN: 3129 case WM_LBUTTONDOWN:
3120 case WM_RBUTTONDOWN: 3130 case WM_RBUTTONDOWN:
3121 if (XINT (Vw32_num_mouse_buttons) > 2) 3131 if (w32_num_mouse_buttons > 2)
3122 goto handle_plain_button; 3132 goto handle_plain_button;
3123 3133
3124 { 3134 {
@@ -3168,7 +3178,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3168 /* Hold onto message for now. */ 3178 /* Hold onto message for now. */
3169 mouse_button_timer = 3179 mouse_button_timer =
3170 SetTimer (hwnd, MOUSE_BUTTON_ID, 3180 SetTimer (hwnd, MOUSE_BUTTON_ID,
3171 XINT (Vw32_mouse_button_tolerance), NULL); 3181 w32_mouse_button_tolerance, NULL);
3172 saved_mouse_button_msg.msg.hwnd = hwnd; 3182 saved_mouse_button_msg.msg.hwnd = hwnd;
3173 saved_mouse_button_msg.msg.message = msg; 3183 saved_mouse_button_msg.msg.message = msg;
3174 saved_mouse_button_msg.msg.wParam = wParam; 3184 saved_mouse_button_msg.msg.wParam = wParam;
@@ -3181,7 +3191,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3181 3191
3182 case WM_LBUTTONUP: 3192 case WM_LBUTTONUP:
3183 case WM_RBUTTONUP: 3193 case WM_RBUTTONUP:
3184 if (XINT (Vw32_num_mouse_buttons) > 2) 3194 if (w32_num_mouse_buttons > 2)
3185 goto handle_plain_button; 3195 goto handle_plain_button;
3186 3196
3187 { 3197 {
@@ -3277,7 +3287,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3277 track_mouse_window = hwnd; 3287 track_mouse_window = hwnd;
3278 } 3288 }
3279 case WM_VSCROLL: 3289 case WM_VSCROLL:
3280 if (XINT (Vw32_mouse_move_interval) <= 0 3290 if (w32_mouse_move_interval <= 0
3281 || (msg == WM_MOUSEMOVE && button_state == 0)) 3291 || (msg == WM_MOUSEMOVE && button_state == 0))
3282 { 3292 {
3283 wmsg.dwModifiers = w32_get_modifiers (); 3293 wmsg.dwModifiers = w32_get_modifiers ();
@@ -3293,7 +3303,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3293 if (saved_mouse_move_msg.msg.hwnd == 0) 3303 if (saved_mouse_move_msg.msg.hwnd == 0)
3294 mouse_move_timer = 3304 mouse_move_timer =
3295 SetTimer (hwnd, MOUSE_MOVE_ID, 3305 SetTimer (hwnd, MOUSE_MOVE_ID,
3296 XINT (Vw32_mouse_move_interval), NULL); 3306 w32_mouse_move_interval, NULL);
3297 3307
3298 /* Hold onto message for now. */ 3308 /* Hold onto message for now. */
3299 saved_mouse_move_msg.msg.hwnd = hwnd; 3309 saved_mouse_move_msg.msg.hwnd = hwnd;
@@ -4036,15 +4046,15 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
4036 1, 1, 0, 4046 1, 1, 0,
4037 doc: /* Make a new window, which is called a \"frame\" in Emacs terms. 4047 doc: /* Make a new window, which is called a \"frame\" in Emacs terms.
4038Returns an Emacs frame object. 4048Returns an Emacs frame object.
4039ALIST is an alist of frame parameters. 4049PARAMETERS is an alist of frame parameters.
4040If the parameters specify that the frame should not have a minibuffer, 4050If the parameters specify that the frame should not have a minibuffer,
4041and do not specify a specific minibuffer window to use, 4051and do not specify a specific minibuffer window to use,
4042then `default-minibuffer-frame' must be a frame whose minibuffer can 4052then `default-minibuffer-frame' must be a frame whose minibuffer can
4043be shared by the new frame. 4053be shared by the new frame.
4044 4054
4045This function is an internal primitive--use `make-frame' instead. */) 4055This function is an internal primitive--use `make-frame' instead. */)
4046 (parms) 4056 (parameters)
4047 Lisp_Object parms; 4057 Lisp_Object parameters;
4048{ 4058{
4049 struct frame *f; 4059 struct frame *f;
4050 Lisp_Object frame, tem; 4060 Lisp_Object frame, tem;
@@ -4065,7 +4075,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4065 until we know if this frame has a specified name. */ 4075 until we know if this frame has a specified name. */
4066 Vx_resource_name = Vinvocation_name; 4076 Vx_resource_name = Vinvocation_name;
4067 4077
4068 display = w32_get_arg (parms, Qdisplay, 0, 0, RES_TYPE_STRING); 4078 display = w32_get_arg (parameters, Qdisplay, 0, 0, RES_TYPE_STRING);
4069 if (EQ (display, Qunbound)) 4079 if (EQ (display, Qunbound))
4070 display = Qnil; 4080 display = Qnil;
4071 dpyinfo = check_x_display_info (display); 4081 dpyinfo = check_x_display_info (display);
@@ -4075,7 +4085,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4075 kb = &the_only_kboard; 4085 kb = &the_only_kboard;
4076#endif 4086#endif
4077 4087
4078 name = w32_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); 4088 name = w32_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING);
4079 if (!STRINGP (name) 4089 if (!STRINGP (name)
4080 && ! EQ (name, Qunbound) 4090 && ! EQ (name, Qunbound)
4081 && ! NILP (name)) 4091 && ! NILP (name))
@@ -4085,7 +4095,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4085 Vx_resource_name = name; 4095 Vx_resource_name = name;
4086 4096
4087 /* See if parent window is specified. */ 4097 /* See if parent window is specified. */
4088 parent = w32_get_arg (parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER); 4098 parent = w32_get_arg (parameters, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
4089 if (EQ (parent, Qunbound)) 4099 if (EQ (parent, Qunbound))
4090 parent = Qnil; 4100 parent = Qnil;
4091 if (! NILP (parent)) 4101 if (! NILP (parent))
@@ -4095,8 +4105,8 @@ This function is an internal primitive--use `make-frame' instead. */)
4095 /* No need to protect DISPLAY because that's not used after passing 4105 /* No need to protect DISPLAY because that's not used after passing
4096 it to make_frame_without_minibuffer. */ 4106 it to make_frame_without_minibuffer. */
4097 frame = Qnil; 4107 frame = Qnil;
4098 GCPRO4 (parms, parent, name, frame); 4108 GCPRO4 (parameters, parent, name, frame);
4099 tem = w32_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer", 4109 tem = w32_get_arg (parameters, Qminibuffer, "minibuffer", "Minibuffer",
4100 RES_TYPE_SYMBOL); 4110 RES_TYPE_SYMBOL);
4101 if (EQ (tem, Qnone) || NILP (tem)) 4111 if (EQ (tem, Qnone) || NILP (tem))
4102 f = make_frame_without_minibuffer (Qnil, kb, display); 4112 f = make_frame_without_minibuffer (Qnil, kb, display);
@@ -4126,7 +4136,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4126 record_unwind_protect (unwind_create_frame, frame); 4136 record_unwind_protect (unwind_create_frame, frame);
4127 4137
4128 f->icon_name 4138 f->icon_name
4129 = w32_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING); 4139 = w32_get_arg (parameters, Qicon_name, "iconName", "Title", RES_TYPE_STRING);
4130 if (! STRINGP (f->icon_name)) 4140 if (! STRINGP (f->icon_name))
4131 f->icon_name = Qnil; 4141 f->icon_name = Qnil;
4132 4142
@@ -4168,7 +4178,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4168 { 4178 {
4169 Lisp_Object font; 4179 Lisp_Object font;
4170 4180
4171 font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING); 4181 font = w32_get_arg (parameters, Qfont, "font", "Font", RES_TYPE_STRING);
4172 4182
4173 BLOCK_INPUT; 4183 BLOCK_INPUT;
4174 /* First, try whatever font the caller has specified. */ 4184 /* First, try whatever font the caller has specified. */
@@ -4192,49 +4202,49 @@ This function is an internal primitive--use `make-frame' instead. */)
4192 if (! STRINGP (font)) 4202 if (! STRINGP (font))
4193 font = build_string ("Fixedsys"); 4203 font = build_string ("Fixedsys");
4194 4204
4195 x_default_parameter (f, parms, Qfont, font, 4205 x_default_parameter (f, parameters, Qfont, font,
4196 "font", "Font", RES_TYPE_STRING); 4206 "font", "Font", RES_TYPE_STRING);
4197 } 4207 }
4198 4208
4199 x_default_parameter (f, parms, Qborder_width, make_number (2), 4209 x_default_parameter (f, parameters, Qborder_width, make_number (2),
4200 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); 4210 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
4201 /* This defaults to 2 in order to match xterm. We recognize either 4211 /* This defaults to 2 in order to match xterm. We recognize either
4202 internalBorderWidth or internalBorder (which is what xterm calls 4212 internalBorderWidth or internalBorder (which is what xterm calls
4203 it). */ 4213 it). */
4204 if (NILP (Fassq (Qinternal_border_width, parms))) 4214 if (NILP (Fassq (Qinternal_border_width, parameters)))
4205 { 4215 {
4206 Lisp_Object value; 4216 Lisp_Object value;
4207 4217
4208 value = w32_get_arg (parms, Qinternal_border_width, 4218 value = w32_get_arg (parameters, Qinternal_border_width,
4209 "internalBorder", "InternalBorder", RES_TYPE_NUMBER); 4219 "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
4210 if (! EQ (value, Qunbound)) 4220 if (! EQ (value, Qunbound))
4211 parms = Fcons (Fcons (Qinternal_border_width, value), 4221 parameters = Fcons (Fcons (Qinternal_border_width, value),
4212 parms); 4222 parameters);
4213 } 4223 }
4214 /* Default internalBorderWidth to 0 on Windows to match other programs. */ 4224 /* Default internalBorderWidth to 0 on Windows to match other programs. */
4215 x_default_parameter (f, parms, Qinternal_border_width, make_number (0), 4225 x_default_parameter (f, parameters, Qinternal_border_width, make_number (0),
4216 "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER); 4226 "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
4217 x_default_parameter (f, parms, Qvertical_scroll_bars, Qright, 4227 x_default_parameter (f, parameters, Qvertical_scroll_bars, Qright,
4218 "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL); 4228 "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
4219 4229
4220 /* Also do the stuff which must be set before the window exists. */ 4230 /* Also do the stuff which must be set before the window exists. */
4221 x_default_parameter (f, parms, Qforeground_color, build_string ("black"), 4231 x_default_parameter (f, parameters, Qforeground_color, build_string ("black"),
4222 "foreground", "Foreground", RES_TYPE_STRING); 4232 "foreground", "Foreground", RES_TYPE_STRING);
4223 x_default_parameter (f, parms, Qbackground_color, build_string ("white"), 4233 x_default_parameter (f, parameters, Qbackground_color, build_string ("white"),
4224 "background", "Background", RES_TYPE_STRING); 4234 "background", "Background", RES_TYPE_STRING);
4225 x_default_parameter (f, parms, Qmouse_color, build_string ("black"), 4235 x_default_parameter (f, parameters, Qmouse_color, build_string ("black"),
4226 "pointerColor", "Foreground", RES_TYPE_STRING); 4236 "pointerColor", "Foreground", RES_TYPE_STRING);
4227 x_default_parameter (f, parms, Qcursor_color, build_string ("black"), 4237 x_default_parameter (f, parameters, Qcursor_color, build_string ("black"),
4228 "cursorColor", "Foreground", RES_TYPE_STRING); 4238 "cursorColor", "Foreground", RES_TYPE_STRING);
4229 x_default_parameter (f, parms, Qborder_color, build_string ("black"), 4239 x_default_parameter (f, parameters, Qborder_color, build_string ("black"),
4230 "borderColor", "BorderColor", RES_TYPE_STRING); 4240 "borderColor", "BorderColor", RES_TYPE_STRING);
4231 x_default_parameter (f, parms, Qscreen_gamma, Qnil, 4241 x_default_parameter (f, parameters, Qscreen_gamma, Qnil,
4232 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT); 4242 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
4233 x_default_parameter (f, parms, Qline_spacing, Qnil, 4243 x_default_parameter (f, parameters, Qline_spacing, Qnil,
4234 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER); 4244 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
4235 x_default_parameter (f, parms, Qleft_fringe, Qnil, 4245 x_default_parameter (f, parameters, Qleft_fringe, Qnil,
4236 "leftFringe", "LeftFringe", RES_TYPE_NUMBER); 4246 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
4237 x_default_parameter (f, parms, Qright_fringe, Qnil, 4247 x_default_parameter (f, parameters, Qright_fringe, Qnil,
4238 "rightFringe", "RightFringe", RES_TYPE_NUMBER); 4248 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
4239 4249
4240 4250
@@ -4246,16 +4256,16 @@ This function is an internal primitive--use `make-frame' instead. */)
4246 happen. */ 4256 happen. */
4247 init_frame_faces (f); 4257 init_frame_faces (f);
4248 4258
4249 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), 4259 x_default_parameter (f, parameters, Qmenu_bar_lines, make_number (1),
4250 "menuBar", "MenuBar", RES_TYPE_NUMBER); 4260 "menuBar", "MenuBar", RES_TYPE_NUMBER);
4251 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1), 4261 x_default_parameter (f, parameters, Qtool_bar_lines, make_number (1),
4252 "toolBar", "ToolBar", RES_TYPE_NUMBER); 4262 "toolBar", "ToolBar", RES_TYPE_NUMBER);
4253 4263
4254 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, 4264 x_default_parameter (f, parameters, Qbuffer_predicate, Qnil,
4255 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); 4265 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
4256 x_default_parameter (f, parms, Qtitle, Qnil, 4266 x_default_parameter (f, parameters, Qtitle, Qnil,
4257 "title", "Title", RES_TYPE_STRING); 4267 "title", "Title", RES_TYPE_STRING);
4258 x_default_parameter (f, parms, Qfullscreen, Qnil, 4268 x_default_parameter (f, parameters, Qfullscreen, Qnil,
4259 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); 4269 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
4260 4270
4261 f->output_data.w32->dwStyle = WS_OVERLAPPEDWINDOW; 4271 f->output_data.w32->dwStyle = WS_OVERLAPPEDWINDOW;
@@ -4268,13 +4278,13 @@ This function is an internal primitive--use `make-frame' instead. */)
4268 f->output_data.w32->hourglass_cursor = w32_load_cursor (IDC_WAIT); 4278 f->output_data.w32->hourglass_cursor = w32_load_cursor (IDC_WAIT);
4269 f->output_data.w32->horizontal_drag_cursor = w32_load_cursor (IDC_SIZEWE); 4279 f->output_data.w32->horizontal_drag_cursor = w32_load_cursor (IDC_SIZEWE);
4270 4280
4271 window_prompting = x_figure_window_size (f, parms, 1); 4281 window_prompting = x_figure_window_size (f, parameters, 1);
4272 4282
4273 tem = w32_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 4283 tem = w32_get_arg (parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
4274 f->no_split = minibuffer_only || EQ (tem, Qt); 4284 f->no_split = minibuffer_only || EQ (tem, Qt);
4275 4285
4276 w32_window (f, window_prompting, minibuffer_only); 4286 w32_window (f, window_prompting, minibuffer_only);
4277 x_icon (f, parms); 4287 x_icon (f, parameters);
4278 4288
4279 x_make_gc (f); 4289 x_make_gc (f);
4280 4290
@@ -4284,16 +4294,16 @@ This function is an internal primitive--use `make-frame' instead. */)
4284 4294
4285 /* We need to do this after creating the window, so that the 4295 /* We need to do this after creating the window, so that the
4286 icon-creation functions can say whose icon they're describing. */ 4296 icon-creation functions can say whose icon they're describing. */
4287 x_default_parameter (f, parms, Qicon_type, Qnil, 4297 x_default_parameter (f, parameters, Qicon_type, Qnil,
4288 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL); 4298 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
4289 4299
4290 x_default_parameter (f, parms, Qauto_raise, Qnil, 4300 x_default_parameter (f, parameters, Qauto_raise, Qnil,
4291 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN); 4301 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
4292 x_default_parameter (f, parms, Qauto_lower, Qnil, 4302 x_default_parameter (f, parameters, Qauto_lower, Qnil,
4293 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN); 4303 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
4294 x_default_parameter (f, parms, Qcursor_type, Qbox, 4304 x_default_parameter (f, parameters, Qcursor_type, Qbox,
4295 "cursorType", "CursorType", RES_TYPE_SYMBOL); 4305 "cursorType", "CursorType", RES_TYPE_SYMBOL);
4296 x_default_parameter (f, parms, Qscroll_bar_width, Qnil, 4306 x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
4297 "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); 4307 "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
4298 4308
4299 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. 4309 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
@@ -4331,7 +4341,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4331 { 4341 {
4332 Lisp_Object visibility; 4342 Lisp_Object visibility;
4333 4343
4334 visibility = w32_get_arg (parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL); 4344 visibility = w32_get_arg (parameters, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
4335 if (EQ (visibility, Qunbound)) 4345 if (EQ (visibility, Qunbound))
4336 visibility = Qt; 4346 visibility = Qt;
4337 4347
@@ -4775,46 +4785,46 @@ x_to_w32_charset (lpcs)
4775 w32_charset = Fcar (Fcdr (this_entry)); 4785 w32_charset = Fcar (Fcdr (this_entry));
4776 4786
4777 /* Translate Lisp symbol to number. */ 4787 /* Translate Lisp symbol to number. */
4778 if (w32_charset == Qw32_charset_ansi) 4788 if (EQ (w32_charset, Qw32_charset_ansi))
4779 return ANSI_CHARSET; 4789 return ANSI_CHARSET;
4780 if (w32_charset == Qw32_charset_symbol) 4790 if (EQ (w32_charset, Qw32_charset_symbol))
4781 return SYMBOL_CHARSET; 4791 return SYMBOL_CHARSET;
4782 if (w32_charset == Qw32_charset_shiftjis) 4792 if (EQ (w32_charset, Qw32_charset_shiftjis))
4783 return SHIFTJIS_CHARSET; 4793 return SHIFTJIS_CHARSET;
4784 if (w32_charset == Qw32_charset_hangeul) 4794 if (EQ (w32_charset, Qw32_charset_hangeul))
4785 return HANGEUL_CHARSET; 4795 return HANGEUL_CHARSET;
4786 if (w32_charset == Qw32_charset_chinesebig5) 4796 if (EQ (w32_charset, Qw32_charset_chinesebig5))
4787 return CHINESEBIG5_CHARSET; 4797 return CHINESEBIG5_CHARSET;
4788 if (w32_charset == Qw32_charset_gb2312) 4798 if (EQ (w32_charset, Qw32_charset_gb2312))
4789 return GB2312_CHARSET; 4799 return GB2312_CHARSET;
4790 if (w32_charset == Qw32_charset_oem) 4800 if (EQ (w32_charset, Qw32_charset_oem))
4791 return OEM_CHARSET; 4801 return OEM_CHARSET;
4792#ifdef JOHAB_CHARSET 4802#ifdef JOHAB_CHARSET
4793 if (w32_charset == Qw32_charset_johab) 4803 if (EQ (w32_charset, Qw32_charset_johab))
4794 return JOHAB_CHARSET; 4804 return JOHAB_CHARSET;
4795 if (w32_charset == Qw32_charset_easteurope) 4805 if (EQ (w32_charset, Qw32_charset_easteurope))
4796 return EASTEUROPE_CHARSET; 4806 return EASTEUROPE_CHARSET;
4797 if (w32_charset == Qw32_charset_turkish) 4807 if (EQ (w32_charset, Qw32_charset_turkish))
4798 return TURKISH_CHARSET; 4808 return TURKISH_CHARSET;
4799 if (w32_charset == Qw32_charset_baltic) 4809 if (EQ (w32_charset, Qw32_charset_baltic))
4800 return BALTIC_CHARSET; 4810 return BALTIC_CHARSET;
4801 if (w32_charset == Qw32_charset_russian) 4811 if (EQ (w32_charset, Qw32_charset_russian))
4802 return RUSSIAN_CHARSET; 4812 return RUSSIAN_CHARSET;
4803 if (w32_charset == Qw32_charset_arabic) 4813 if (EQ (w32_charset, Qw32_charset_arabic))
4804 return ARABIC_CHARSET; 4814 return ARABIC_CHARSET;
4805 if (w32_charset == Qw32_charset_greek) 4815 if (EQ (w32_charset, Qw32_charset_greek))
4806 return GREEK_CHARSET; 4816 return GREEK_CHARSET;
4807 if (w32_charset == Qw32_charset_hebrew) 4817 if (EQ (w32_charset, Qw32_charset_hebrew))
4808 return HEBREW_CHARSET; 4818 return HEBREW_CHARSET;
4809 if (w32_charset == Qw32_charset_vietnamese) 4819 if (EQ (w32_charset, Qw32_charset_vietnamese))
4810 return VIETNAMESE_CHARSET; 4820 return VIETNAMESE_CHARSET;
4811 if (w32_charset == Qw32_charset_thai) 4821 if (EQ (w32_charset, Qw32_charset_thai))
4812 return THAI_CHARSET; 4822 return THAI_CHARSET;
4813 if (w32_charset == Qw32_charset_mac) 4823 if (EQ (w32_charset, Qw32_charset_mac))
4814 return MAC_CHARSET; 4824 return MAC_CHARSET;
4815#endif /* JOHAB_CHARSET */ 4825#endif /* JOHAB_CHARSET */
4816#ifdef UNICODE_CHARSET 4826#ifdef UNICODE_CHARSET
4817 if (w32_charset == Qw32_charset_unicode) 4827 if (EQ (w32_charset, Qw32_charset_unicode))
4818 return UNICODE_CHARSET; 4828 return UNICODE_CHARSET;
4819#endif 4829#endif
4820 4830
@@ -4956,8 +4966,8 @@ w32_to_x_charset (fncharset, matching)
4956 4966
4957 /* Look for Same charset and a valid codepage (or non-int 4967 /* Look for Same charset and a valid codepage (or non-int
4958 which means ignore). */ 4968 which means ignore). */
4959 if (w32_charset == charset_type 4969 if (EQ (w32_charset, charset_type)
4960 && (!INTEGERP (codepage) || codepage == CP_DEFAULT 4970 && (!INTEGERP (codepage) || XINT (codepage) == CP_DEFAULT
4961 || IsValidCodePage (XINT (codepage)))) 4971 || IsValidCodePage (XINT (codepage))))
4962 { 4972 {
4963 /* If we don't have a match already, then this is the 4973 /* If we don't have a match already, then this is the
@@ -5151,8 +5161,8 @@ w32_to_all_x_charsets (fncharset)
5151 5161
5152 /* Look for Same charset and a valid codepage (or non-int 5162 /* Look for Same charset and a valid codepage (or non-int
5153 which means ignore). */ 5163 which means ignore). */
5154 if (w32_charset == charset_type 5164 if (EQ (w32_charset, charset_type)
5155 && (!INTEGERP (codepage) || codepage == CP_DEFAULT 5165 && (!INTEGERP (codepage) || XINT (codepage) == CP_DEFAULT
5156 || IsValidCodePage (XINT (codepage)))) 5166 || IsValidCodePage (XINT (codepage))))
5157 { 5167 {
5158 retval = Fcons (x_charset, retval); 5168 retval = Fcons (x_charset, retval);
@@ -6205,6 +6215,9 @@ w32_find_ccl_program (fontp)
6205 } 6215 }
6206} 6216}
6207 6217
6218/* directory-files from dired.c. */
6219Lisp_Object Fdirectory_files P_((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object));
6220
6208 6221
6209/* Find BDF files in a specified directory. (use GCPRO when calling, 6222/* Find BDF files in a specified directory. (use GCPRO when calling,
6210 as this calls lisp to get a directory listing). */ 6223 as this calls lisp to get a directory listing). */
@@ -6218,7 +6231,7 @@ w32_find_bdf_fonts_in_dir (Lisp_Object directory)
6218 return Qnil; 6231 return Qnil;
6219 6232
6220 filelist = Fdirectory_files (directory, Qt, 6233 filelist = Fdirectory_files (directory, Qt,
6221 build_string (".*\\.[bB][dD][fF]"), Qt); 6234 build_string (".*\\.[bB][dD][fF]"), Qt);
6222 6235
6223 for ( ; CONSP(filelist); filelist = XCDR (filelist)) 6236 for ( ; CONSP(filelist); filelist = XCDR (filelist))
6224 { 6237 {
@@ -6231,10 +6244,10 @@ w32_find_bdf_fonts_in_dir (Lisp_Object directory)
6231 6244
6232DEFUN ("w32-find-bdf-fonts", Fw32_find_bdf_fonts, Sw32_find_bdf_fonts, 6245DEFUN ("w32-find-bdf-fonts", Fw32_find_bdf_fonts, Sw32_find_bdf_fonts,
6233 1, 1, 0, 6246 1, 1, 0,
6234 doc: /* Return a list of BDF fonts in DIR. 6247 doc: /* Return a list of BDF fonts in DIRECTORY.
6235The list is suitable for appending to w32-bdf-filename-alist. Fonts 6248The list is suitable for appending to `w32-bdf-filename-alist'.
6236which do not contain an xlfd description will not be included in the 6249Fonts which do not contain an xlfd description will not be included
6237list. DIR may be a list of directories. */) 6250in the list. DIRECTORY may be a list of directories. */)
6238 (directory) 6251 (directory)
6239 Lisp_Object directory; 6252 Lisp_Object directory;
6240{ 6253{
@@ -6315,7 +6328,7 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
6315 6328
6316DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, 6329DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p,
6317 Sx_display_grayscale_p, 0, 1, 0, 6330 Sx_display_grayscale_p, 0, 1, 0,
6318 doc: /* Return t if the X display supports shades of gray. 6331 doc: /* Return t if DISPLAY supports shades of gray.
6319Note that color displays do support shades of gray. 6332Note that color displays do support shades of gray.
6320The optional argument DISPLAY specifies which display to ask about. 6333The optional argument DISPLAY specifies which display to ask about.
6321DISPLAY should be either a frame or a display name (a string). 6334DISPLAY should be either a frame or a display name (a string).
@@ -6388,9 +6401,9 @@ If omitted or nil, that stands for the selected frame's display. */)
6388 6401
6389 hdc = GetDC (dpyinfo->root_window); 6402 hdc = GetDC (dpyinfo->root_window);
6390 if (dpyinfo->has_palette) 6403 if (dpyinfo->has_palette)
6391 cap = GetDeviceCaps (hdc,SIZEPALETTE); 6404 cap = GetDeviceCaps (hdc, SIZEPALETTE);
6392 else 6405 else
6393 cap = GetDeviceCaps (hdc,NUMCOLORS); 6406 cap = GetDeviceCaps (hdc, NUMCOLORS);
6394 6407
6395 /* We force 24+ bit depths to 24-bit, both to prevent an overflow 6408 /* We force 24+ bit depths to 24-bit, both to prevent an overflow
6396 and because probably is more meaningful on Windows anyway */ 6409 and because probably is more meaningful on Windows anyway */
@@ -7175,6 +7188,8 @@ x_create_tip_frame (dpyinfo, parms, text)
7175 old_buffer = current_buffer; 7188 old_buffer = current_buffer;
7176 set_buffer_internal_1 (XBUFFER (buffer)); 7189 set_buffer_internal_1 (XBUFFER (buffer));
7177 current_buffer->truncate_lines = Qnil; 7190 current_buffer->truncate_lines = Qnil;
7191 specbind (Qinhibit_read_only, Qt);
7192 specbind (Qinhibit_modification_hooks, Qt);
7178 Ferase_buffer (); 7193 Ferase_buffer ();
7179 Finsert (1, &text); 7194 Finsert (1, &text);
7180 set_buffer_internal_1 (old_buffer); 7195 set_buffer_internal_1 (old_buffer);
@@ -7442,7 +7457,7 @@ used to change the tooltip's appearance.
7442Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil 7457Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
7443means use the default timeout of 5 seconds. 7458means use the default timeout of 5 seconds.
7444 7459
7445If the list of frame parameters PARAMS contains a `left' parameter, 7460If the list of frame parameters PARMS contains a `left' parameter,
7446the tooltip is displayed at that x-position. Otherwise it is 7461the tooltip is displayed at that x-position. Otherwise it is
7447displayed at the mouse position, with offset DX added (default is 5 if 7462displayed at the mouse position, with offset DX added (default is 5 if
7448DX isn't specified). Likewise for the y-position; if a `top' frame 7463DX isn't specified). Likewise for the y-position; if a `top' frame
@@ -7923,7 +7938,7 @@ Returns an X font string corresponding to the selection. */)
7923DEFUN ("w32-send-sys-command", Fw32_send_sys_command, 7938DEFUN ("w32-send-sys-command", Fw32_send_sys_command,
7924 Sw32_send_sys_command, 1, 2, 0, 7939 Sw32_send_sys_command, 1, 2, 0,
7925 doc: /* Send frame a Windows WM_SYSCOMMAND message of type COMMAND. 7940 doc: /* Send frame a Windows WM_SYSCOMMAND message of type COMMAND.
7926Some useful values for command are #xf030 to maximise frame (#xf020 7941Some useful values for COMMAND are #xf030 to maximize frame (#xf020
7927to minimize), #xf120 to restore frame to original size, and #xf100 7942to minimize), #xf120 to restore frame to original size, and #xf100
7928to activate the menubar for keyboard access. #xf140 activates the 7943to activate the menubar for keyboard access. #xf140 activates the
7929screen saver if defined. 7944screen saver if defined.
@@ -8003,7 +8018,7 @@ lookup_vk_code (char *key)
8003 8018
8004/* Convert a one-element vector style key sequence to a hot key 8019/* Convert a one-element vector style key sequence to a hot key
8005 definition. */ 8020 definition. */
8006static int 8021static Lisp_Object
8007w32_parse_hot_key (key) 8022w32_parse_hot_key (key)
8008 Lisp_Object key; 8023 Lisp_Object key;
8009{ 8024{
@@ -8035,7 +8050,7 @@ w32_parse_hot_key (key)
8035 if (SYMBOLP (c)) 8050 if (SYMBOLP (c))
8036 { 8051 {
8037 c = parse_modifiers (c); 8052 c = parse_modifiers (c);
8038 lisp_modifiers = Fcar (Fcdr (c)); 8053 lisp_modifiers = XINT (Fcar (Fcdr (c)));
8039 c = Fcar (c); 8054 c = Fcar (c);
8040 if (!SYMBOLP (c)) 8055 if (!SYMBOLP (c))
8041 abort (); 8056 abort ();
@@ -8104,8 +8119,13 @@ The return value is the hotkey-id if registered, otherwise nil. */)
8104 8119
8105 /* Notify input thread about new hot-key definition, so that it 8120 /* Notify input thread about new hot-key definition, so that it
8106 takes effect without needing to switch focus. */ 8121 takes effect without needing to switch focus. */
8122#ifdef USE_LISP_UNION_TYPE
8123 PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY,
8124 (WPARAM) key.i, 0);
8125#else
8107 PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY, 8126 PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY,
8108 (WPARAM) key, 0); 8127 (WPARAM) key, 0);
8128#endif
8109 } 8129 }
8110 8130
8111 return key; 8131 return key;
@@ -8113,7 +8133,7 @@ The return value is the hotkey-id if registered, otherwise nil. */)
8113 8133
8114DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key, 8134DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
8115 Sw32_unregister_hot_key, 1, 1, 0, 8135 Sw32_unregister_hot_key, 1, 1, 0,
8116 doc: /* Unregister HOTKEY as a hot-key combination. */) 8136 doc: /* Unregister KEY as a hot-key combination. */)
8117 (key) 8137 (key)
8118 Lisp_Object key; 8138 Lisp_Object key;
8119{ 8139{
@@ -8128,8 +8148,14 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
8128 { 8148 {
8129 /* Notify input thread about hot-key definition being removed, so 8149 /* Notify input thread about hot-key definition being removed, so
8130 that it takes effect without needing focus switch. */ 8150 that it takes effect without needing focus switch. */
8151#ifdef USE_LISP_UNION_TYPE
8152 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY,
8153 (WPARAM) XINT (XCAR (item)), (LPARAM) item.i))
8154#else
8131 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, 8155 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY,
8132 (WPARAM) XINT (XCAR (item)), (LPARAM) item)) 8156 (WPARAM) XINT (XCAR (item)), (LPARAM) item))
8157
8158#endif
8133 { 8159 {
8134 MSG msg; 8160 MSG msg;
8135 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 8161 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
@@ -8149,7 +8175,8 @@ DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys,
8149 8175
8150DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key, 8176DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key,
8151 Sw32_reconstruct_hot_key, 1, 1, 0, 8177 Sw32_reconstruct_hot_key, 1, 1, 0,
8152 doc: /* Convert hot-key ID to a lisp key combination. */) 8178 doc: /* Convert hot-key ID to a lisp key combination.
8179usage: (w32-reconstruct-hot-key ID) */)
8153 (hotkeyid) 8180 (hotkeyid)
8154 Lisp_Object hotkeyid; 8181 Lisp_Object hotkeyid;
8155{ 8182{
@@ -8202,8 +8229,13 @@ is set to off if the low bit of NEW-STATE is zero, otherwise on. */)
8202 if (!dwWindowsThreadId) 8229 if (!dwWindowsThreadId)
8203 return make_number (w32_console_toggle_lock_key (vk_code, new_state)); 8230 return make_number (w32_console_toggle_lock_key (vk_code, new_state));
8204 8231
8232#ifdef USE_LISP_UNION_TYPE
8233 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY,
8234 (WPARAM) vk_code, (LPARAM) new_state.i))
8235#else
8205 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY, 8236 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY,
8206 (WPARAM) vk_code, (LPARAM) new_state)) 8237 (WPARAM) vk_code, (LPARAM) new_state))
8238#endif
8207 { 8239 {
8208 MSG msg; 8240 MSG msg;
8209 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 8241 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
@@ -8383,7 +8415,7 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
8383 Initialization 8415 Initialization
8384 ***********************************************************************/ 8416 ***********************************************************************/
8385 8417
8386/* Keep this list in the same order as frame_parms in frame.c. 8418/* Keep this list in the same order as frame_parms in frame.c.
8387 Use 0 for unsupported frame parameters. */ 8419 Use 0 for unsupported frame parameters. */
8388 8420
8389frame_parm_handler w32_frame_parm_handlers[] = 8421frame_parm_handler w32_frame_parm_handlers[] =
@@ -8468,7 +8500,7 @@ syms_of_w32fns ()
8468 w32_grabbed_keys = Qnil; 8500 w32_grabbed_keys = Qnil;
8469 8501
8470 DEFVAR_LISP ("w32-color-map", &Vw32_color_map, 8502 DEFVAR_LISP ("w32-color-map", &Vw32_color_map,
8471 doc: /* An array of color name mappings for windows. */); 8503 doc: /* An array of color name mappings for Windows. */);
8472 Vw32_color_map = Qnil; 8504 Vw32_color_map = Qnil;
8473 8505
8474 DEFVAR_LISP ("w32-pass-alt-to-system", &Vw32_pass_alt_to_system, 8506 DEFVAR_LISP ("w32-pass-alt-to-system", &Vw32_pass_alt_to_system,
@@ -8482,9 +8514,9 @@ open the System menu. When nil, Emacs silently swallows alt key events. */);
8482When nil, Emacs will translate the alt key to the Alt modifier, and not Meta. */); 8514When nil, Emacs will translate the alt key to the Alt modifier, and not Meta. */);
8483 Vw32_alt_is_meta = Qt; 8515 Vw32_alt_is_meta = Qt;
8484 8516
8485 DEFVAR_INT ("w32-quit-key", &Vw32_quit_key, 8517 DEFVAR_INT ("w32-quit-key", &w32_quit_key,
8486 doc: /* If non-zero, the virtual key code for an alternative quit key. */); 8518 doc: /* If non-zero, the virtual key code for an alternative quit key. */);
8487 XSETINT (Vw32_quit_key, 0); 8519 w32_quit_key = 0;
8488 8520
8489 DEFVAR_LISP ("w32-pass-lwindow-to-system", 8521 DEFVAR_LISP ("w32-pass-lwindow-to-system",
8490 &Vw32_pass_lwindow_to_system, 8522 &Vw32_pass_lwindow_to_system,
@@ -8498,9 +8530,9 @@ When non-nil, the Start menu is opened by tapping the key. */);
8498When non-nil, the Start menu is opened by tapping the key. */); 8530When non-nil, the Start menu is opened by tapping the key. */);
8499 Vw32_pass_rwindow_to_system = Qt; 8531 Vw32_pass_rwindow_to_system = Qt;
8500 8532
8501 DEFVAR_INT ("w32-phantom-key-code", 8533 DEFVAR_LISP ("w32-phantom-key-code",
8502 &Vw32_phantom_key_code, 8534 &Vw32_phantom_key_code,
8503 doc: /* Virtual key code used to generate \"phantom\" key presses. 8535 doc: /* Virtual key code used to generate \"phantom\" key presses.
8504Value is a number between 0 and 255. 8536Value is a number between 0 and 255.
8505 8537
8506Phantom key presses are generated in order to stop the system from 8538Phantom key presses are generated in order to stop the system from
@@ -8508,7 +8540,7 @@ acting on \"Windows\" key events when `w32-pass-lwindow-to-system' or
8508`w32-pass-rwindow-to-system' is nil. */); 8540`w32-pass-rwindow-to-system' is nil. */);
8509 /* Although 255 is technically not a valid key code, it works and 8541 /* Although 255 is technically not a valid key code, it works and
8510 means that this hack won't interfere with any real key code. */ 8542 means that this hack won't interfere with any real key code. */
8511 Vw32_phantom_key_code = 255; 8543 XSETINT (Vw32_phantom_key_code, 255);
8512 8544
8513 DEFVAR_LISP ("w32-enable-num-lock", 8545 DEFVAR_LISP ("w32-enable-num-lock",
8514 &Vw32_enable_num_lock, 8546 &Vw32_enable_num_lock,
@@ -8563,21 +8595,21 @@ Any other value will cause the key to be ignored. */);
8563 Vw32_enable_palette = Qt; 8595 Vw32_enable_palette = Qt;
8564 8596
8565 DEFVAR_INT ("w32-mouse-button-tolerance", 8597 DEFVAR_INT ("w32-mouse-button-tolerance",
8566 &Vw32_mouse_button_tolerance, 8598 &w32_mouse_button_tolerance,
8567 doc: /* Analogue of double click interval for faking middle mouse events. 8599 doc: /* Analogue of double click interval for faking middle mouse events.
8568The value is the minimum time in milliseconds that must elapse between 8600The value is the minimum time in milliseconds that must elapse between
8569left/right button down events before they are considered distinct events. 8601left/right button down events before they are considered distinct events.
8570If both mouse buttons are depressed within this interval, a middle mouse 8602If both mouse buttons are depressed within this interval, a middle mouse
8571button down event is generated instead. */); 8603button down event is generated instead. */);
8572 XSETINT (Vw32_mouse_button_tolerance, GetDoubleClickTime () / 2); 8604 w32_mouse_button_tolerance = GetDoubleClickTime () / 2;
8573 8605
8574 DEFVAR_INT ("w32-mouse-move-interval", 8606 DEFVAR_INT ("w32-mouse-move-interval",
8575 &Vw32_mouse_move_interval, 8607 &w32_mouse_move_interval,
8576 doc: /* Minimum interval between mouse move events. 8608 doc: /* Minimum interval between mouse move events.
8577The value is the minimum time in milliseconds that must elapse between 8609The value is the minimum time in milliseconds that must elapse between
8578successive mouse move (or scroll bar drag) events before they are 8610successive mouse move (or scroll bar drag) events before they are
8579reported as lisp events. */); 8611reported as lisp events. */);
8580 XSETINT (Vw32_mouse_move_interval, 0); 8612 w32_mouse_move_interval = 0;
8581 8613
8582 DEFVAR_BOOL ("w32-pass-extra-mouse-buttons-to-system", 8614 DEFVAR_BOOL ("w32-pass-extra-mouse-buttons-to-system",
8583 &w32_pass_extra_mouse_buttons_to_system, 8615 &w32_pass_extra_mouse_buttons_to_system,
@@ -8857,6 +8889,11 @@ void globals_of_w32fns ()
8857 /* ditto for GetClipboardSequenceNumber. */ 8889 /* ditto for GetClipboardSequenceNumber. */
8858 clipboard_sequence_fn = (ClipboardSequence_Proc) 8890 clipboard_sequence_fn = (ClipboardSequence_Proc)
8859 GetProcAddress (user32_lib, "GetClipboardSequenceNumber"); 8891 GetProcAddress (user32_lib, "GetClipboardSequenceNumber");
8892
8893 DEFVAR_INT ("w32-ansi-code-page",
8894 &w32_ansi_code_page,
8895 doc: /* The ANSI code page used by the system. */);
8896 w32_ansi_code_page = GetACP ();
8860} 8897}
8861 8898
8862#undef abort 8899#undef abort
diff --git a/src/w32heap.c b/src/w32heap.c
index b40db430ea9..d947842474f 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -245,6 +245,7 @@ init_heap ()
245 exit (1); 245 exit (1);
246 } 246 }
247 247
248#if defined (NO_UNION_TYPE) && !defined (USE_LSB_TAG)
248 /* Ensure that the addresses don't use the upper tag bits since 249 /* Ensure that the addresses don't use the upper tag bits since
249 the Lisp type goes there. */ 250 the Lisp type goes there. */
250 if (((unsigned long) data_region_base & ~VALMASK) != 0) 251 if (((unsigned long) data_region_base & ~VALMASK) != 0)
@@ -252,7 +253,7 @@ init_heap ()
252 printf ("Error: The heap was allocated in upper memory.\n"); 253 printf ("Error: The heap was allocated in upper memory.\n");
253 exit (1); 254 exit (1);
254 } 255 }
255 256#endif
256 data_region_end = data_region_base; 257 data_region_end = data_region_base;
257 real_data_region_end = data_region_end; 258 real_data_region_end = data_region_end;
258 } 259 }
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 168a0fb87b3..8dd4f406881 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -464,12 +464,12 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
464 } 464 }
465 if (event->uChar.AsciiChar == 0) 465 if (event->uChar.AsciiChar == 0)
466 return 0; 466 return 0;
467 XSETINT (emacs_ev->code, event->uChar.AsciiChar); 467 emacs_ev->code = event->uChar.AsciiChar;
468 } 468 }
469 else 469 else
470 { 470 {
471 emacs_ev->kind = NON_ASCII_KEYSTROKE_EVENT; 471 emacs_ev->kind = NON_ASCII_KEYSTROKE_EVENT;
472 XSETINT (emacs_ev->code, event->wVirtualKeyCode); 472 emacs_ev->code = event->wVirtualKeyCode;
473 } 473 }
474 474
475 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); 475 XSETFRAME (emacs_ev->frame_or_window, get_frame ());
@@ -524,8 +524,8 @@ w32_console_mouse_position (FRAME_PTR *f,
524 *part = 0; 524 *part = 0;
525 SELECTED_FRAME ()->mouse_moved = 0; 525 SELECTED_FRAME ()->mouse_moved = 0;
526 526
527 *x = movement_pos.X; 527 XSETINT(*x, movement_pos.X);
528 *y = movement_pos.Y; 528 XSETINT(*y, movement_pos.Y);
529 *time = movement_time; 529 *time = movement_time;
530 530
531 UNBLOCK_INPUT; 531 UNBLOCK_INPUT;
@@ -593,9 +593,9 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
593 if (but_change & mask) 593 if (but_change & mask)
594 { 594 {
595 if (i < NUM_TRANSLATED_MOUSE_BUTTONS) 595 if (i < NUM_TRANSLATED_MOUSE_BUTTONS)
596 XSETINT (emacs_ev->code, emacs_button_translation[i]); 596 emacs_ev->code = emacs_button_translation[i];
597 else 597 else
598 XSETINT (emacs_ev->code, i); 598 emacs_ev->code = i;
599 break; 599 break;
600 } 600 }
601 601
diff --git a/src/w32menu.c b/src/w32menu.c
index 5f8f8a4e5e0..cc0932d7bf5 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -2225,9 +2225,12 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
2225 /* Set help string for menu item. Leave it as a Lisp_Object 2225 /* Set help string for menu item. Leave it as a Lisp_Object
2226 until it is ready to be displayed, since GC can happen while 2226 until it is ready to be displayed, since GC can happen while
2227 menus are active. */ 2227 menus are active. */
2228 if (wv->help) 2228 if (!NILP (wv->help))
2229 info.dwItemData = (DWORD) wv->help; 2229#ifdef USE_LISP_UNION_TYPE
2230 2230 info.dwItemData = (DWORD) (wv->help).i;
2231#else
2232 info.dwItemData = (DWORD) (wv->help);
2233#endif
2231 if (wv->button_type == BUTTON_TYPE_RADIO) 2234 if (wv->button_type == BUTTON_TYPE_RADIO)
2232 { 2235 {
2233 /* CheckMenuRadioItem allows us to differentiate TOGGLE and 2236 /* CheckMenuRadioItem allows us to differentiate TOGGLE and
@@ -2307,7 +2310,12 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
2307 info.fMask = MIIM_DATA; 2310 info.fMask = MIIM_DATA;
2308 get_menu_item_info (menu, item, FALSE, &info); 2311 get_menu_item_info (menu, item, FALSE, &info);
2309 2312
2313#ifdef USE_LISP_UNION_TYPE
2314 help = info.dwItemData ? (Lisp_Object) ((EMACS_INT) info.dwItemData)
2315 : Qnil;
2316#else
2310 help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil; 2317 help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil;
2318#endif
2311 } 2319 }
2312 2320
2313 /* Store the help echo in the keyboard buffer as the X toolkit 2321 /* Store the help echo in the keyboard buffer as the X toolkit
diff --git a/src/w32proc.c b/src/w32proc.c
index edd286e50d0..8452337f7e2 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1,5 +1,5 @@
1/* Process support for GNU Emacs on the Microsoft W32 API. 1/* Process support for GNU Emacs on the Microsoft W32 API.
2 Copyright (C) 1992, 1995, 1999, 2000, 2001 Free Software Foundation, Inc. 2 Copyright (C) 1992, 95, 99, 2000, 01, 04 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -82,7 +82,7 @@ Lisp_Object Vw32_start_process_inherit_error_mode;
82 avoids the inefficiency of frequently reading small amounts of data. 82 avoids the inefficiency of frequently reading small amounts of data.
83 This is primarily necessary for handling DOS processes on Windows 95, 83 This is primarily necessary for handling DOS processes on Windows 95,
84 but is useful for W32 processes on both Windows 95 and NT as well. */ 84 but is useful for W32 processes on both Windows 95 and NT as well. */
85Lisp_Object Vw32_pipe_read_delay; 85int w32_pipe_read_delay;
86 86
87/* Control conversion of upper case file names to lower case. 87/* Control conversion of upper case file names to lower case.
88 nil means no, t means yes. */ 88 nil means no, t means yes. */
@@ -367,7 +367,7 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app,
367 cp->pid = -cp->pid; 367 cp->pid = -cp->pid;
368 368
369 /* pid must fit in a Lisp_Int */ 369 /* pid must fit in a Lisp_Int */
370 cp->pid = (cp->pid & VALMASK); 370 cp->pid = cp->pid & INTMASK;
371 371
372 *pPid = cp->pid; 372 *pPid = cp->pid;
373 373
@@ -2202,7 +2202,7 @@ When non-nil, they inherit their error mode setting from Emacs, which stops
2202them blocking when trying to access unmounted drives etc. */); 2202them blocking when trying to access unmounted drives etc. */);
2203 Vw32_start_process_inherit_error_mode = Qt; 2203 Vw32_start_process_inherit_error_mode = Qt;
2204 2204
2205 DEFVAR_INT ("w32-pipe-read-delay", &Vw32_pipe_read_delay, 2205 DEFVAR_INT ("w32-pipe-read-delay", &w32_pipe_read_delay,
2206 doc: /* Forced delay before reading subprocess output. 2206 doc: /* Forced delay before reading subprocess output.
2207This is done to improve the buffering of subprocess output, by 2207This is done to improve the buffering of subprocess output, by
2208avoiding the inefficiency of frequently reading small amounts of data. 2208avoiding the inefficiency of frequently reading small amounts of data.
@@ -2211,7 +2211,7 @@ If positive, the value is the number of milliseconds to sleep before
2211reading the subprocess output. If negative, the magnitude is the number 2211reading the subprocess output. If negative, the magnitude is the number
2212of time slices to wait (effectively boosting the priority of the child 2212of time slices to wait (effectively boosting the priority of the child
2213process temporarily). A value of zero disables waiting entirely. */); 2213process temporarily). A value of zero disables waiting entirely. */);
2214 Vw32_pipe_read_delay = 50; 2214 w32_pipe_read_delay = 50;
2215 2215
2216 DEFVAR_LISP ("w32-downcase-file-names", &Vw32_downcase_file_names, 2216 DEFVAR_LISP ("w32-downcase-file-names", &Vw32_downcase_file_names,
2217 doc: /* Non-nil means convert all-upper case file names to lower case. 2217 doc: /* Non-nil means convert all-upper case file names to lower case.
diff --git a/src/w32select.c b/src/w32select.c
index 21f828d1f0c..cc0ca64fab8 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -249,11 +249,18 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
249 249
250 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); 250 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext);
251 251
252 CloseClipboard ();
253
254 /* Common sense says to read the sequence number inside the
255 OpenClipboard/ CloseClipboard block to avoid race conditions
256 where another app puts something on the clipboard straight after
257 us. But experience suggests that the sequence number from the
258 SetClipboardData is not allocated until we close the clipboard!
259 Since clipboard operations are normally user-driven, the race
260 condition is probably not going to really happen. */
252 if (clipboard_sequence_fn) 261 if (clipboard_sequence_fn)
253 last_clipboard_sequence_number = clipboard_sequence_fn (); 262 last_clipboard_sequence_number = clipboard_sequence_fn ();
254 263
255 CloseClipboard ();
256
257 if (ok) goto done; 264 if (ok) goto done;
258 265
259 error: 266 error:
diff --git a/src/w32term.c b/src/w32term.c
index a9afc99b959..95ccafe415b 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -204,7 +204,7 @@ int last_scroll_bar_drag_pos;
204static RECT last_mouse_glyph; 204static RECT last_mouse_glyph;
205static Lisp_Object last_mouse_press_frame; 205static Lisp_Object last_mouse_press_frame;
206 206
207Lisp_Object Vw32_num_mouse_buttons; 207int w32_num_mouse_buttons;
208 208
209Lisp_Object Vw32_swap_mouse_buttons; 209Lisp_Object Vw32_swap_mouse_buttons;
210 210
@@ -1371,7 +1371,8 @@ static void w32_draw_image_foreground_1 P_ ((struct glyph_string *, HBITMAP));
1371static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 1371static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
1372 int, int, int)); 1372 int, int, int));
1373static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int, 1373static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int,
1374 int, int, int, int, RECT *)); 1374 int, int, int, int, int, int,
1375 RECT *));
1375static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 1376static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
1376 int, int, int, RECT *)); 1377 int, int, int, RECT *));
1377 1378
@@ -1952,9 +1953,10 @@ x_setup_relief_colors (s)
1952 1953
1953static void 1954static void
1954w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, 1955w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
1955 raised_p, left_p, right_p, clip_rect) 1956 raised_p, top_p, bot_p, left_p, right_p, clip_rect)
1956 struct frame *f; 1957 struct frame *f;
1957 int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p; 1958 int left_x, top_y, right_x, bottom_y, width;
1959 int top_p, bot_p, left_p, right_p, raised_p;
1958 RECT *clip_rect; 1960 RECT *clip_rect;
1959{ 1961{
1960 int i; 1962 int i;
@@ -1969,10 +1971,11 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
1969 w32_set_clip_rectangle (hdc, clip_rect); 1971 w32_set_clip_rectangle (hdc, clip_rect);
1970 1972
1971 /* Top. */ 1973 /* Top. */
1972 for (i = 0; i < width; ++i) 1974 if (top_p)
1973 w32_fill_area (f, hdc, gc.foreground, 1975 for (i = 0; i < width; ++i)
1974 left_x + i * left_p, top_y + i, 1976 w32_fill_area (f, hdc, gc.foreground,
1975 right_x - left_x - i * (left_p + right_p ) + 1, 1); 1977 left_x + i * left_p, top_y + i,
1978 right_x - left_x - i * (left_p + right_p ) + 1, 1);
1976 1979
1977 /* Left. */ 1980 /* Left. */
1978 if (left_p) 1981 if (left_p)
@@ -1987,10 +1990,11 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
1987 gc.foreground = f->output_data.w32->white_relief.gc->foreground; 1990 gc.foreground = f->output_data.w32->white_relief.gc->foreground;
1988 1991
1989 /* Bottom. */ 1992 /* Bottom. */
1990 for (i = 0; i < width; ++i) 1993 if (bot_p)
1991 w32_fill_area (f, hdc, gc.foreground, 1994 for (i = 0; i < width; ++i)
1992 left_x + i * left_p, bottom_y - i, 1995 w32_fill_area (f, hdc, gc.foreground,
1993 right_x - left_x - i * (left_p + right_p) + 1, 1); 1996 left_x + i * left_p, bottom_y - i,
1997 right_x - left_x - i * (left_p + right_p) + 1, 1);
1994 1998
1995 /* Right. */ 1999 /* Right. */
1996 if (right_p) 2000 if (right_p)
@@ -2100,7 +2104,7 @@ x_draw_glyph_string_box (s)
2100 { 2104 {
2101 x_setup_relief_colors (s); 2105 x_setup_relief_colors (s);
2102 w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, 2106 w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
2103 width, raised_p, left_p, right_p, &clip_rect); 2107 width, raised_p, 1, 1, left_p, right_p, &clip_rect);
2104 } 2108 }
2105} 2109}
2106 2110
@@ -2111,21 +2115,22 @@ static void
2111x_draw_image_foreground (s) 2115x_draw_image_foreground (s)
2112 struct glyph_string *s; 2116 struct glyph_string *s;
2113{ 2117{
2114 int x; 2118 int x = s->x;
2115 int y = s->ybase - image_ascent (s->img, s->face); 2119 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2116 2120
2117 /* If first glyph of S has a left box line, start drawing it to the 2121 /* If first glyph of S has a left box line, start drawing it to the
2118 right of that line. */ 2122 right of that line. */
2119 if (s->face->box != FACE_NO_BOX 2123 if (s->face->box != FACE_NO_BOX
2120 && s->first_glyph->left_box_line_p) 2124 && s->first_glyph->left_box_line_p
2121 x = s->x + abs (s->face->box_line_width); 2125 && s->slice.x == 0)
2122 else 2126 x += abs (s->face->box_line_width);
2123 x = s->x;
2124 2127
2125 /* If there is a margin around the image, adjust x- and y-position 2128 /* If there is a margin around the image, adjust x- and y-position
2126 by that margin. */ 2129 by that margin. */
2127 x += s->img->hmargin; 2130 if (s->slice.x == 0)
2128 y += s->img->vmargin; 2131 x += s->img->hmargin;
2132 if (s->slice.y == 0)
2133 y += s->img->vmargin;
2129 2134
2130 SaveDC (s->hdc); 2135 SaveDC (s->hdc);
2131 2136
@@ -2147,12 +2152,12 @@ x_draw_image_foreground (s)
2147 SetTextColor (s->hdc, RGB (255, 255, 255)); 2152 SetTextColor (s->hdc, RGB (255, 255, 255));
2148 SetBkColor (s->hdc, RGB (0, 0, 0)); 2153 SetBkColor (s->hdc, RGB (0, 0, 0));
2149 2154
2150 BitBlt (s->hdc, x, y, s->img->width, s->img->height, 2155 BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
2151 compat_hdc, 0, 0, SRCINVERT); 2156 compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
2152 BitBlt (s->hdc, x, y, s->img->width, s->img->height, 2157 BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
2153 mask_dc, 0, 0, SRCAND); 2158 mask_dc, s->slice.x, s->slice.y, SRCAND);
2154 BitBlt (s->hdc, x, y, s->img->width, s->img->height, 2159 BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
2155 compat_hdc, 0, 0, SRCINVERT); 2160 compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
2156 2161
2157 SelectObject (mask_dc, mask_orig_obj); 2162 SelectObject (mask_dc, mask_orig_obj);
2158 DeleteDC (mask_dc); 2163 DeleteDC (mask_dc);
@@ -2162,8 +2167,8 @@ x_draw_image_foreground (s)
2162 SetTextColor (s->hdc, s->gc->foreground); 2167 SetTextColor (s->hdc, s->gc->foreground);
2163 SetBkColor (s->hdc, s->gc->background); 2168 SetBkColor (s->hdc, s->gc->background);
2164 2169
2165 BitBlt (s->hdc, x, y, s->img->width, s->img->height, 2170 BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
2166 compat_hdc, 0, 0, SRCCOPY); 2171 compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
2167 2172
2168 /* When the image has a mask, we can expect that at 2173 /* When the image has a mask, we can expect that at
2169 least part of a mouse highlight or a block cursor will 2174 least part of a mouse highlight or a block cursor will
@@ -2176,7 +2181,8 @@ x_draw_image_foreground (s)
2176 int r = s->img->relief; 2181 int r = s->img->relief;
2177 if (r < 0) r = -r; 2182 if (r < 0) r = -r;
2178 w32_draw_rectangle (s->hdc, s->gc, x - r, y - r , 2183 w32_draw_rectangle (s->hdc, s->gc, x - r, y - r ,
2179 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2184 s->slice.width + r*2 - 1,
2185 s->slice.height + r*2 - 1);
2180 } 2186 }
2181 } 2187 }
2182 2188
@@ -2187,8 +2193,8 @@ x_draw_image_foreground (s)
2187 DeleteDC (compat_hdc); 2193 DeleteDC (compat_hdc);
2188 } 2194 }
2189 else 2195 else
2190 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width -1, 2196 w32_draw_rectangle (s->hdc, s->gc, x, y,
2191 s->img->height - 1); 2197 s->slice.width - 1, s->slice.height - 1);
2192 2198
2193 RestoreDC (s->hdc ,-1); 2199 RestoreDC (s->hdc ,-1);
2194} 2200}
@@ -2203,21 +2209,22 @@ x_draw_image_relief (s)
2203{ 2209{
2204 int x0, y0, x1, y1, thick, raised_p; 2210 int x0, y0, x1, y1, thick, raised_p;
2205 RECT r; 2211 RECT r;
2206 int x; 2212 int x = s->x;
2207 int y = s->ybase - image_ascent (s->img, s->face); 2213 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2208 2214
2209 /* If first glyph of S has a left box line, start drawing it to the 2215 /* If first glyph of S has a left box line, start drawing it to the
2210 right of that line. */ 2216 right of that line. */
2211 if (s->face->box != FACE_NO_BOX 2217 if (s->face->box != FACE_NO_BOX
2212 && s->first_glyph->left_box_line_p) 2218 && s->first_glyph->left_box_line_p
2213 x = s->x + abs (s->face->box_line_width); 2219 && s->slice.x == 0)
2214 else 2220 x += abs (s->face->box_line_width);
2215 x = s->x;
2216 2221
2217 /* If there is a margin around the image, adjust x- and y-position 2222 /* If there is a margin around the image, adjust x- and y-position
2218 by that margin. */ 2223 by that margin. */
2219 x += s->img->hmargin; 2224 if (s->slice.x == 0)
2220 y += s->img->vmargin; 2225 x += s->img->hmargin;
2226 if (s->slice.y == 0)
2227 y += s->img->vmargin;
2221 2228
2222 if (s->hl == DRAW_IMAGE_SUNKEN 2229 if (s->hl == DRAW_IMAGE_SUNKEN
2223 || s->hl == DRAW_IMAGE_RAISED) 2230 || s->hl == DRAW_IMAGE_RAISED)
@@ -2233,12 +2240,17 @@ x_draw_image_relief (s)
2233 2240
2234 x0 = x - thick; 2241 x0 = x - thick;
2235 y0 = y - thick; 2242 y0 = y - thick;
2236 x1 = x + s->img->width + thick - 1; 2243 x1 = x + s->slice.width + thick - 1;
2237 y1 = y + s->img->height + thick - 1; 2244 y1 = y + s->slice.height + thick - 1;
2238 2245
2239 x_setup_relief_colors (s); 2246 x_setup_relief_colors (s);
2240 get_glyph_string_clip_rect (s, &r); 2247 get_glyph_string_clip_rect (s, &r);
2241 w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r); 2248 w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
2249 s->slice.y == 0,
2250 s->slice.y + s->slice.height == s->img->height,
2251 s->slice.x == 0,
2252 s->slice.x + s->slice.width == s->img->width,
2253 &r);
2242} 2254}
2243 2255
2244 2256
@@ -2251,21 +2263,22 @@ w32_draw_image_foreground_1 (s, pixmap)
2251{ 2263{
2252 HDC hdc = CreateCompatibleDC (s->hdc); 2264 HDC hdc = CreateCompatibleDC (s->hdc);
2253 HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap); 2265 HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap);
2254 int x; 2266 int x = 0;
2255 int y = s->ybase - s->y - image_ascent (s->img, s->face); 2267 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
2256 2268
2257 /* If first glyph of S has a left box line, start drawing it to the 2269 /* If first glyph of S has a left box line, start drawing it to the
2258 right of that line. */ 2270 right of that line. */
2259 if (s->face->box != FACE_NO_BOX 2271 if (s->face->box != FACE_NO_BOX
2260 && s->first_glyph->left_box_line_p) 2272 && s->first_glyph->left_box_line_p
2261 x = abs (s->face->box_line_width); 2273 && s->slice.x == 0)
2262 else 2274 x += abs (s->face->box_line_width);
2263 x = 0;
2264 2275
2265 /* If there is a margin around the image, adjust x- and y-position 2276 /* If there is a margin around the image, adjust x- and y-position
2266 by that margin. */ 2277 by that margin. */
2267 x += s->img->hmargin; 2278 if (s->slice.x == 0)
2268 y += s->img->vmargin; 2279 x += s->img->hmargin;
2280 if (s->slice.y == 0)
2281 y += s->img->vmargin;
2269 2282
2270 if (s->img->pixmap) 2283 if (s->img->pixmap)
2271 { 2284 {
@@ -2281,12 +2294,12 @@ w32_draw_image_foreground_1 (s, pixmap)
2281 2294
2282 SetTextColor (hdc, RGB (0, 0, 0)); 2295 SetTextColor (hdc, RGB (0, 0, 0));
2283 SetBkColor (hdc, RGB (255, 255, 255)); 2296 SetBkColor (hdc, RGB (255, 255, 255));
2284 BitBlt (hdc, x, y, s->img->width, s->img->height, 2297 BitBlt (hdc, x, y, s->slice.width, s->slice.height,
2285 compat_hdc, 0, 0, SRCINVERT); 2298 compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
2286 BitBlt (hdc, x, y, s->img->width, s->img->height, 2299 BitBlt (hdc, x, y, s->slice.width, s->slice.height,
2287 mask_dc, 0, 0, SRCAND); 2300 mask_dc, s->slice.x, s->slice.y, SRCAND);
2288 BitBlt (hdc, x, y, s->img->width, s->img->height, 2301 BitBlt (hdc, x, y, s->slice.width, s->slice.height,
2289 compat_hdc, 0, 0, SRCINVERT); 2302 compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
2290 2303
2291 SelectObject (mask_dc, mask_orig_obj); 2304 SelectObject (mask_dc, mask_orig_obj);
2292 DeleteDC (mask_dc); 2305 DeleteDC (mask_dc);
@@ -2296,8 +2309,8 @@ w32_draw_image_foreground_1 (s, pixmap)
2296 SetTextColor (hdc, s->gc->foreground); 2309 SetTextColor (hdc, s->gc->foreground);
2297 SetBkColor (hdc, s->gc->background); 2310 SetBkColor (hdc, s->gc->background);
2298 2311
2299 BitBlt (hdc, x, y, s->img->width, s->img->height, 2312 BitBlt (hdc, x, y, s->slice.width, s->slice.height,
2300 compat_hdc, 0, 0, SRCCOPY); 2313 compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
2301 2314
2302 /* When the image has a mask, we can expect that at 2315 /* When the image has a mask, we can expect that at
2303 least part of a mouse highlight or a block cursor will 2316 least part of a mouse highlight or a block cursor will
@@ -2309,8 +2322,9 @@ w32_draw_image_foreground_1 (s, pixmap)
2309 { 2322 {
2310 int r = s->img->relief; 2323 int r = s->img->relief;
2311 if (r < 0) r = -r; 2324 if (r < 0) r = -r;
2312 w32_draw_rectangle (hdc, s->gc, x - r, y - r , 2325 w32_draw_rectangle (hdc, s->gc, x - r, y - r,
2313 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2326 s->slice.width + r*2 - 1,
2327 s->slice.height + r*2 - 1);
2314 } 2328 }
2315 } 2329 }
2316 2330
@@ -2320,8 +2334,8 @@ w32_draw_image_foreground_1 (s, pixmap)
2320 DeleteDC (compat_hdc); 2334 DeleteDC (compat_hdc);
2321 } 2335 }
2322 else 2336 else
2323 w32_draw_rectangle (hdc, s->gc, x, y, s->img->width - 1, 2337 w32_draw_rectangle (hdc, s->gc, x, y,
2324 s->img->height - 1); 2338 s->slice.width - 1, s->slice.height - 1);
2325 2339
2326 SelectObject (hdc, orig_hdc_obj); 2340 SelectObject (hdc, orig_hdc_obj);
2327 DeleteDC (hdc); 2341 DeleteDC (hdc);
@@ -2380,19 +2394,22 @@ x_draw_image_glyph_string (s)
2380 taller than image or if image has a clip mask to reduce 2394 taller than image or if image has a clip mask to reduce
2381 flickering. */ 2395 flickering. */
2382 s->stippled_p = s->face->stipple != 0; 2396 s->stippled_p = s->face->stipple != 0;
2383 if (height > s->img->height 2397 if (height > s->slice.height
2384 || s->img->hmargin 2398 || s->img->hmargin
2385 || s->img->vmargin 2399 || s->img->vmargin
2386 || s->img->mask 2400 || s->img->mask
2387 || s->img->pixmap == 0 2401 || s->img->pixmap == 0
2388 || s->width != s->background_width) 2402 || s->width != s->background_width)
2389 { 2403 {
2390 if (box_line_hwidth && s->first_glyph->left_box_line_p) 2404 x = s->x;
2391 x = s->x + box_line_hwidth; 2405 if (s->first_glyph->left_box_line_p
2392 else 2406 && s->slice.x == 0)
2393 x = s->x; 2407 x += box_line_hwidth;
2408
2409 y = s->y;
2410 if (s->slice.y == 0)
2411 y += box_line_vwidth;
2394 2412
2395 y = s->y + box_line_vwidth;
2396#if 0 /* TODO: figure out if we need to do this on Windows. */ 2413#if 0 /* TODO: figure out if we need to do this on Windows. */
2397 if (s->img->mask) 2414 if (s->img->mask)
2398 { 2415 {
@@ -4311,8 +4328,7 @@ w32_read_socket (sd, expected, hold_quit)
4311 /* So people can tell when we have read the available input. */ 4328 /* So people can tell when we have read the available input. */
4312 input_signal_count++; 4329 input_signal_count++;
4313 4330
4314 /* TODO: tool-bars, ghostscript integration, mouse 4331 /* TODO: ghostscript integration. */
4315 cursors. */
4316 while (get_next_msg (&msg, FALSE)) 4332 while (get_next_msg (&msg, FALSE))
4317 { 4333 {
4318 struct input_event inev; 4334 struct input_event inev;
@@ -4495,10 +4511,16 @@ w32_read_socket (sd, expected, hold_quit)
4495 4511
4496 /* If the contents of the global variable help_echo_string 4512 /* If the contents of the global variable help_echo_string
4497 has changed, generate a HELP_EVENT. */ 4513 has changed, generate a HELP_EVENT. */
4514#if 0 /* The below is an invalid comparison when USE_LISP_UNION_TYPE.
4515 But it was originally changed to this to fix a bug, so I have
4516 not removed it completely in case the bug is still there. */
4498 if (help_echo_string != previous_help_echo_string || 4517 if (help_echo_string != previous_help_echo_string ||
4499 (!NILP (help_echo_string) && !STRINGP (help_echo_string) && f->mouse_moved)) 4518 (!NILP (help_echo_string) && !STRINGP (help_echo_string) && f->mouse_moved))
4519#else /* This is what xterm.c does. */
4520 if (!NILP (help_echo_string)
4521 || !NILP (previous_help_echo_string))
4500 do_help = 1; 4522 do_help = 1;
4501 4523#endif
4502 break; 4524 break;
4503 4525
4504 case WM_LBUTTONDOWN: 4526 case WM_LBUTTONDOWN:
@@ -4919,7 +4941,7 @@ w32_read_socket (sd, expected, hold_quit)
4919 4941
4920 if (do_help > 0) 4942 if (do_help > 0)
4921 { 4943 {
4922 if (help_echo_string == Qnil) 4944 if (NILP (help_echo_string))
4923 { 4945 {
4924 help_echo_object = help_echo_window = Qnil; 4946 help_echo_object = help_echo_window = Qnil;
4925 help_echo_pos = -1; 4947 help_echo_pos = -1;
@@ -5068,28 +5090,38 @@ x_draw_hollow_cursor (w, row)
5068 struct frame *f = XFRAME (WINDOW_FRAME (w)); 5090 struct frame *f = XFRAME (WINDOW_FRAME (w));
5069 HDC hdc; 5091 HDC hdc;
5070 RECT rect; 5092 RECT rect;
5071 int wd; 5093 int wd, h;
5072 struct glyph *cursor_glyph; 5094 struct glyph *cursor_glyph;
5073 HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel); 5095 HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel);
5074 5096
5097 /* Get the glyph the cursor is on. If we can't tell because
5098 the current matrix is invalid or such, give up. */
5099 cursor_glyph = get_phys_cursor_glyph (w);
5100 if (cursor_glyph == NULL)
5101 return;
5102
5075 /* Compute frame-relative coordinates from window-relative 5103 /* Compute frame-relative coordinates from window-relative
5076 coordinates. */ 5104 coordinates. */
5077 rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 5105 rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
5078 rect.top = (WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y) 5106 rect.top = (WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y)
5079 + row->ascent - w->phys_cursor_ascent); 5107 + row->ascent - w->phys_cursor_ascent);
5080 rect.bottom = rect.top + row->height;
5081 5108
5082 /* Get the glyph the cursor is on. If we can't tell because 5109 /* Compute the proper height and ascent of the rectangle, based
5083 the current matrix is invalid or such, give up. */ 5110 on the actual glyph. Using the full height of the row looks
5084 cursor_glyph = get_phys_cursor_glyph (w); 5111 bad when there are tall images on that row. */
5085 if (cursor_glyph == NULL) 5112 h = max (min (FRAME_LINE_HEIGHT (f), row->height),
5086 return; 5113 cursor_glyph->ascent + cursor_glyph->descent);
5114 if (h < row->height)
5115 rect.top += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h;
5116 h--;
5117
5118 rect.bottom = rect.top + h;
5087 5119
5088 /* Compute the width of the rectangle to draw. If on a stretch 5120 /* Compute the width of the rectangle to draw. If on a stretch
5089 glyph, and `x-stretch-block-cursor' is nil, don't draw a 5121 glyph, and `x-stretch-block-cursor' is nil, don't draw a
5090 rectangle as wide as the glyph, but use a canonical character 5122 rectangle as wide as the glyph, but use a canonical character
5091 width instead. */ 5123 width instead. */
5092 wd = cursor_glyph->pixel_width; 5124 wd = cursor_glyph->pixel_width; /* TODO: Why off by one compared with X? */
5093 if (cursor_glyph->type == STRETCH_GLYPH 5125 if (cursor_glyph->type == STRETCH_GLYPH
5094 && !x_stretch_cursor_p) 5126 && !x_stretch_cursor_p)
5095 wd = min (FRAME_COLUMN_WIDTH (f), wd); 5127 wd = min (FRAME_COLUMN_WIDTH (f), wd);
@@ -6604,9 +6636,9 @@ syms_of_w32term ()
6604 Qvendor_specific_keysyms = intern ("vendor-specific-keysyms"); 6636 Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
6605 6637
6606 DEFVAR_INT ("w32-num-mouse-buttons", 6638 DEFVAR_INT ("w32-num-mouse-buttons",
6607 &Vw32_num_mouse_buttons, 6639 &w32_num_mouse_buttons,
6608 doc: /* Number of physical mouse buttons. */); 6640 doc: /* Number of physical mouse buttons. */);
6609 Vw32_num_mouse_buttons = Qnil; 6641 w32_num_mouse_buttons = 2;
6610 6642
6611 DEFVAR_LISP ("w32-swap-mouse-buttons", 6643 DEFVAR_LISP ("w32-swap-mouse-buttons",
6612 &Vw32_swap_mouse_buttons, 6644 &Vw32_swap_mouse_buttons,
diff --git a/src/w32term.h b/src/w32term.h
index cf6956c1efa..524b1097c42 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -252,6 +252,10 @@ extern int unibyte_display_via_language_environment;
252 252
253struct w32_display_info *x_display_info_for_name (); 253struct w32_display_info *x_display_info_for_name ();
254 254
255Lisp_Object display_x_get_resource P_ ((struct w32_display_info *,
256 Lisp_Object, Lisp_Object,
257 Lisp_Object, Lisp_Object));
258
255extern struct w32_display_info *w32_term_init (); 259extern struct w32_display_info *w32_term_init ();
256 260
257extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int)); 261extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
@@ -721,9 +725,10 @@ struct face;
721 725
722XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *); 726XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
723struct frame * check_x_frame (Lisp_Object); 727struct frame * check_x_frame (Lisp_Object);
728Lisp_Object vga_stdcolor_name (int);
729
724EXFUN (Fx_display_color_p, 1); 730EXFUN (Fx_display_color_p, 1);
725EXFUN (Fx_display_grayscale_p, 1); 731EXFUN (Fx_display_grayscale_p, 1);
726int image_ascent P_ ((struct image *, struct face *));
727 732
728#define FONT_TYPE_FOR_UNIBYTE(font, ch) \ 733#define FONT_TYPE_FOR_UNIBYTE(font, ch) \
729 ((font)->bdf ? BDF_1D_FONT : ANSI_FONT) 734 ((font)->bdf ? BDF_1D_FONT : ANSI_FONT)
diff --git a/src/window.c b/src/window.c
index 47bbf0806ee..d3203c99e90 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,6 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985,86,87,93,94,95,96,97,1998,2000, 2001, 2002, 2003 3 Copyright (C) 1985,86,87, 1993,94,95,96,97,98, 2000,01,02,03,04
4 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
@@ -322,7 +322,11 @@ DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p,
322Return nil if that position is scrolled vertically out of view. 322Return nil if that position is scrolled vertically out of view.
323If a character is only partially visible, nil is returned, unless the 323If a character is only partially visible, nil is returned, unless the
324optional argument PARTIALLY is non-nil. 324optional argument PARTIALLY is non-nil.
325POS defaults to point in WINDOW; WINDOW defaults to the selected window. */) 325POS defaults to point in WINDOW; WINDOW defaults to the selected window.
326
327If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
328return value is a list (X Y PARTIAL) where X and Y are the pixel relative
329coordinate */)
326 (pos, window, partially) 330 (pos, window, partially)
327 Lisp_Object pos, window, partially; 331 Lisp_Object pos, window, partially;
328{ 332{
@@ -330,8 +334,9 @@ POS defaults to point in WINDOW; WINDOW defaults to the selected window. */)
330 register int posint; 334 register int posint;
331 register struct buffer *buf; 335 register struct buffer *buf;
332 struct text_pos top; 336 struct text_pos top;
333 Lisp_Object in_window; 337 Lisp_Object in_window = Qnil;
334 int fully_p; 338 int fully_p = 1;
339 int x, y;
335 340
336 w = decode_window (window); 341 w = decode_window (window);
337 buf = XBUFFER (w->buffer); 342 buf = XBUFFER (w->buffer);
@@ -347,38 +352,20 @@ POS defaults to point in WINDOW; WINDOW defaults to the selected window. */)
347 else 352 else
348 posint = XMARKER (w->pointm)->charpos; 353 posint = XMARKER (w->pointm)->charpos;
349 354
350 /* If position is above window start, it's not visible. */ 355 /* If position is above window start or outside buffer boundaries,
351 if (posint < CHARPOS (top)) 356 or if window start is out of range, position is not visible. */
352 in_window = Qnil; 357 if (posint >= CHARPOS (top)
353 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) 358 && posint <= BUF_ZV (buf)
354 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf) 359 && CHARPOS (top) >= BUF_BEGV (buf)
355 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) 360 && CHARPOS (top) <= BUF_ZV (buf)
356 { 361 && pos_visible_p (w, posint, &fully_p, &x, &y, NILP (partially))
357 /* If frame is up-to-date, and POSINT is < window end pos, use 362 && (!NILP (partially) || fully_p))
358 that info. This doesn't work for POSINT == end pos, because 363 in_window = Qt;
359 the window end pos is actually the position _after_ the last 364
360 char in the window. */ 365 if (!NILP (in_window) && !NILP (partially))
361 if (NILP (partially)) 366 in_window = Fcons (make_number (x),
362 { 367 Fcons (make_number (y),
363 pos_visible_p (w, posint, &fully_p, NILP (partially)); 368 Fcons (fully_p ? Qt : Qnil, Qnil)));
364 in_window = fully_p ? Qt : Qnil;
365 }
366 else
367 in_window = Qt;
368 }
369 else if (posint > BUF_ZV (buf))
370 in_window = Qnil;
371 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))
372 /* If window start is out of range, do something reasonable. */
373 in_window = Qnil;
374 else
375 {
376 if (pos_visible_p (w, posint, &fully_p, NILP (partially)))
377 in_window = !NILP (partially) || fully_p ? Qt : Qnil;
378 else
379 in_window = Qnil;
380 }
381
382 return in_window; 369 return in_window;
383} 370}
384 371
@@ -3036,7 +3023,7 @@ set_window_buffer (window, buffer, run_hooks_p, keep_margins_p)
3036DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, 3023DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
3037 doc: /* Make WINDOW display BUFFER as its contents. 3024 doc: /* Make WINDOW display BUFFER as its contents.
3038BUFFER can be a buffer or buffer name. 3025BUFFER can be a buffer or buffer name.
3039Optional third arg KEEP_MARGINS non-nil means that WINDOW's current 3026Optional third arg KEEP-MARGINS non-nil means that WINDOW's current
3040display margins, fringe widths, and scroll bar settings are maintained; 3027display margins, fringe widths, and scroll bar settings are maintained;
3041the default is to reset these from BUFFER's local settings or the frame 3028the default is to reset these from BUFFER's local settings or the frame
3042defaults. */) 3029defaults. */)
@@ -3075,8 +3062,8 @@ defaults. */)
3075 3062
3076DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, 3063DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
3077 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. 3064 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
3078If WINDOW is not already selected, also make WINDOW's buffer current. 3065If WINDOW is not already selected, make WINDOW's buffer current
3079Also make WINDOW the frame's selected window. 3066and make WINDOW the frame's selected window.
3080Optional second arg NORECORD non-nil means 3067Optional second arg NORECORD non-nil means
3081do not put this buffer at the front of the list of recently selected ones. 3068do not put this buffer at the front of the list of recently selected ones.
3082 3069
@@ -3283,6 +3270,10 @@ If FRAME is nil, search only the selected frame
3283 unless `pop-up-frames' or `display-buffer-reuse-frames' is non-nil, 3270 unless `pop-up-frames' or `display-buffer-reuse-frames' is non-nil,
3284 which means search visible and iconified frames. 3271 which means search visible and iconified frames.
3285 3272
3273If a full-width window on a splittable frame is available to display
3274the buffer, it may be split, subject to the value of the variable
3275`split-height-threshold'.
3276
3286If `even-window-heights' is non-nil, window heights will be evened out 3277If `even-window-heights' is non-nil, window heights will be evened out
3287if displaying the buffer causes two vertically adjacent windows to be 3278if displaying the buffer causes two vertically adjacent windows to be
3288displayed. */) 3279displayed. */)
@@ -3460,7 +3451,7 @@ DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update,
3460 0, 1, 0, 3451 0, 1, 0,
3461 doc: /* Force redisplay of all windows. 3452 doc: /* Force redisplay of all windows.
3462If optional arg OBJECT is a window, force redisplay of that window only. 3453If optional arg OBJECT is a window, force redisplay of that window only.
3463If OBJECT is a buffer or buffer name, force redisplay of all windows 3454If OBJECT is a buffer or buffer name, force redisplay of all windows
3464displaying that buffer. */) 3455displaying that buffer. */)
3465 (object) 3456 (object)
3466 Lisp_Object object; 3457 Lisp_Object object;
@@ -3482,7 +3473,7 @@ displaying that buffer. */)
3482 ++update_mode_lines; 3473 ++update_mode_lines;
3483 return Qt; 3474 return Qt;
3484 } 3475 }
3485 3476
3486 if (STRINGP (object)) 3477 if (STRINGP (object))
3487 object = Fget_buffer (object); 3478 object = Fget_buffer (object);
3488 if (BUFFERP (object) && !NILP (XBUFFER (object)->name)) 3479 if (BUFFERP (object) && !NILP (XBUFFER (object)->name))
@@ -3547,7 +3538,7 @@ temp_output_buffer_show (buf)
3547 Lisp_Object prev_window, prev_buffer; 3538 Lisp_Object prev_window, prev_buffer;
3548 prev_window = selected_window; 3539 prev_window = selected_window;
3549 XSETBUFFER (prev_buffer, old); 3540 XSETBUFFER (prev_buffer, old);
3550 3541
3551 /* Select the window that was chosen, for running the hook. 3542 /* Select the window that was chosen, for running the hook.
3552 Note: Both Fselect_window and select_window_norecord may 3543 Note: Both Fselect_window and select_window_norecord may
3553 set-buffer to the buffer displayed in the window, 3544 set-buffer to the buffer displayed in the window,
@@ -3598,7 +3589,8 @@ DEFUN ("split-window", Fsplit_window, Ssplit_window, 0, 3, "",
3598WINDOW defaults to selected one and SIZE to half its size. 3589WINDOW defaults to selected one and SIZE to half its size.
3599If optional third arg HORFLAG is non-nil, split side by side 3590If optional third arg HORFLAG is non-nil, split side by side
3600and put SIZE columns in the first of the pair. In that case, 3591and put SIZE columns in the first of the pair. In that case,
3601SIZE includes that window's scroll bar, or the divider column to its right. */) 3592SIZE includes that window's scroll bar, or the divider column to its right.
3593Returns the newly-created window. */)
3602 (window, size, horflag) 3594 (window, size, horflag)
3603 Lisp_Object window, size, horflag; 3595 Lisp_Object window, size, horflag;
3604{ 3596{
@@ -6067,7 +6059,7 @@ If TYPE is t, use the frame's scroll-bar type. */)
6067 vertical_type = Qnil; 6059 vertical_type = Qnil;
6068 6060
6069 if (!(EQ (vertical_type, Qnil) 6061 if (!(EQ (vertical_type, Qnil)
6070 || EQ (vertical_type, Qleft) 6062 || EQ (vertical_type, Qleft)
6071 || EQ (vertical_type, Qright) 6063 || EQ (vertical_type, Qright)
6072 || EQ (vertical_type, Qt))) 6064 || EQ (vertical_type, Qt)))
6073 error ("Invalid type of vertical scroll bar"); 6065 error ("Invalid type of vertical scroll bar");
@@ -6116,12 +6108,13 @@ value. */)
6116 Smooth scrolling 6108 Smooth scrolling
6117 ***********************************************************************/ 6109 ***********************************************************************/
6118 6110
6119DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 1, 0, 6111DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0,
6120 doc: /* Return the amount by which WINDOW is scrolled vertically. 6112 doc: /* Return the amount by which WINDOW is scrolled vertically.
6121Use the selected window if WINDOW is nil or omitted. 6113Use the selected window if WINDOW is nil or omitted.
6122Value is a multiple of the canonical character height of WINDOW. */) 6114Normally, value is a multiple of the canonical character height of WINDOW;
6123 (window) 6115optional second arg PIXELS_P means value is measured in pixels. */)
6124 Lisp_Object window; 6116 (window, pixels_p)
6117 Lisp_Object window, pixels_p;
6125{ 6118{
6126 Lisp_Object result; 6119 Lisp_Object result;
6127 struct frame *f; 6120 struct frame *f;
@@ -6135,7 +6128,9 @@ Value is a multiple of the canonical character height of WINDOW. */)
6135 f = XFRAME (w->frame); 6128 f = XFRAME (w->frame);
6136 6129
6137 if (FRAME_WINDOW_P (f)) 6130 if (FRAME_WINDOW_P (f))
6138 result = FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll); 6131 result = (NILP (pixels_p)
6132 ? FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll)
6133 : make_number (-w->vscroll));
6139 else 6134 else
6140 result = make_number (0); 6135 result = make_number (0);
6141 return result; 6136 return result;
@@ -6143,12 +6138,13 @@ Value is a multiple of the canonical character height of WINDOW. */)
6143 6138
6144 6139
6145DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll, 6140DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll,
6146 2, 2, 0, 6141 2, 3, 0,
6147 doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL. 6142 doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.
6148WINDOW nil means use the selected window. VSCROLL is a non-negative 6143WINDOW nil means use the selected window. Normally, VSCROLL is a
6149multiple of the canonical character height of WINDOW. */) 6144non-negative multiple of the canonical character height of WINDOW;
6150 (window, vscroll) 6145optional third arg PIXELS_P non-nil means that VSCROLL is in pixels. */)
6151 Lisp_Object window, vscroll; 6146 (window, vscroll, pixels_p)
6147 Lisp_Object window, vscroll, pixels_p;
6152{ 6148{
6153 struct window *w; 6149 struct window *w;
6154 struct frame *f; 6150 struct frame *f;
@@ -6166,7 +6162,9 @@ multiple of the canonical character height of WINDOW. */)
6166 { 6162 {
6167 int old_dy = w->vscroll; 6163 int old_dy = w->vscroll;
6168 6164
6169 w->vscroll = - FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll); 6165 w->vscroll = - (NILP (pixels_p)
6166 ? FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll)
6167 : XFLOATINT (vscroll));
6170 w->vscroll = min (w->vscroll, 0); 6168 w->vscroll = min (w->vscroll, 0);
6171 6169
6172 /* Adjust glyph matrix of the frame if the virtual display 6170 /* Adjust glyph matrix of the frame if the virtual display
@@ -6178,7 +6176,7 @@ multiple of the canonical character height of WINDOW. */)
6178 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 6176 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
6179 } 6177 }
6180 6178
6181 return Fwindow_vscroll (window); 6179 return Fwindow_vscroll (window, pixels_p);
6182} 6180}
6183 6181
6184 6182
@@ -6506,9 +6504,10 @@ using `special-display-function'. See also `special-display-regexps'.
6506An element of the list can be a list instead of just a string. 6504An element of the list can be a list instead of just a string.
6507There are two ways to use a list as an element: 6505There are two ways to use a list as an element:
6508 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...) 6506 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...)
6509In the first case, FRAME-PARAMETERS are used to create the frame. 6507In the first case, the FRAME-PARAMETERS are pairs of the form
6510In the latter case, FUNCTION is called with BUFFER as the first argument, 6508\(PARAMETER . VALUE); these parameter values are used to create the frame.
6511followed by OTHER-ARGS--it can display BUFFER in any way it likes. 6509In the second case, FUNCTION is called with BUFFER as the first argument,
6510followed by the OTHER-ARGS--it can display BUFFER in any way it likes.
6512All this is done by the function found in `special-display-function'. 6511All this is done by the function found in `special-display-function'.
6513 6512
6514If the specified frame parameters include (same-buffer . t), the 6513If the specified frame parameters include (same-buffer . t), the
@@ -6531,9 +6530,10 @@ using `special-display-function'.
6531An element of the list can be a list instead of just a string. 6530An element of the list can be a list instead of just a string.
6532There are two ways to use a list as an element: 6531There are two ways to use a list as an element:
6533 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...) 6532 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...)
6534In the first case, FRAME-PARAMETERS are used to create the frame. 6533In the first case, the FRAME-PARAMETERS are pairs of the form
6535In the latter case, FUNCTION is called with the buffer as first argument, 6534\(PARAMETER . VALUE); these parameter values are used to create the frame.
6536followed by OTHER-ARGS--it can display the buffer in any way it likes. 6535In the second case, FUNCTION is called with BUFFER as the first argument,
6536followed by the OTHER-ARGS--it can display the buffer in any way it likes.
6537All this is done by the function found in `special-display-function'. 6537All this is done by the function found in `special-display-function'.
6538 6538
6539If the specified frame parameters include (same-buffer . t), the 6539If the specified frame parameters include (same-buffer . t), the
@@ -6599,7 +6599,7 @@ See also `same-window-buffer-names'. */);
6599 next_screen_context_lines = 2; 6599 next_screen_context_lines = 2;
6600 6600
6601 DEFVAR_INT ("split-height-threshold", &split_height_threshold, 6601 DEFVAR_INT ("split-height-threshold", &split_height_threshold,
6602 doc: /* *display-buffer would prefer to split the largest window if this large. 6602 doc: /* *A window must be at least this tall to be eligible for splitting by `display-buffer'.
6603If there is only one window, it is split regardless of this value. */); 6603If there is only one window, it is split regardless of this value. */);
6604 split_height_threshold = 500; 6604 split_height_threshold = 500;
6605 6605
diff --git a/src/window.h b/src/window.h
index c665e9921c6..1e53ae659cb 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,5 +1,5 @@
1/* Window definitions for GNU Emacs. 1/* Window definitions for GNU Emacs.
2 Copyright (C) 1985, 1986, 1993, 1995, 1997, 1998, 1999, 2000, 2001, 2003 2 Copyright (C) 1985,86,93,95,97,98,99, 2000,01,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -320,7 +320,7 @@ struct window
320 | | +--------------------------- LEFT_MARGIN_COLS 320 | | +--------------------------- LEFT_MARGIN_COLS
321 | +------------------------------- LEFT_FRINGE_WIDTH 321 | +------------------------------- LEFT_FRINGE_WIDTH
322 +---------------------------------- LEFT_SCROLL_BAR_COLS 322 +---------------------------------- LEFT_SCROLL_BAR_COLS
323 323
324*/ 324*/
325 325
326 326
@@ -767,8 +767,8 @@ EXFUN (Fdisplay_buffer, 3);
767EXFUN (Fset_window_buffer, 3); 767EXFUN (Fset_window_buffer, 3);
768EXFUN (Fset_window_hscroll, 2); 768EXFUN (Fset_window_hscroll, 2);
769EXFUN (Fwindow_hscroll, 1); 769EXFUN (Fwindow_hscroll, 1);
770EXFUN (Fset_window_vscroll, 2); 770EXFUN (Fset_window_vscroll, 3);
771EXFUN (Fwindow_vscroll, 1); 771EXFUN (Fwindow_vscroll, 2);
772EXFUN (Fset_window_margins, 3); 772EXFUN (Fset_window_margins, 3);
773EXFUN (Fwindow_live_p, 1); 773EXFUN (Fwindow_live_p, 1);
774EXFUN (Fset_window_point, 2); 774EXFUN (Fset_window_point, 2);
diff --git a/src/xdisp.c b/src/xdisp.c
index 13fdd0d8c72..41e00893c30 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -199,8 +199,6 @@ Boston, MA 02111-1307, USA. */
199#endif 199#endif
200#ifdef MAC_OS 200#ifdef MAC_OS
201#include "macterm.h" 201#include "macterm.h"
202
203Cursor No_Cursor;
204#endif 202#endif
205 203
206#ifndef FRAME_X_OUTPUT 204#ifndef FRAME_X_OUTPUT
@@ -302,8 +300,10 @@ extern Lisp_Object Qface, Qinvisible, Qwidth;
302Lisp_Object Vdisplay_pixels_per_inch; 300Lisp_Object Vdisplay_pixels_per_inch;
303Lisp_Object Qspace, QCalign_to, QCrelative_width, QCrelative_height; 301Lisp_Object Qspace, QCalign_to, QCrelative_width, QCrelative_height;
304Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise; 302Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise;
303Lisp_Object Qslice;
305Lisp_Object Qcenter; 304Lisp_Object Qcenter;
306Lisp_Object Qmargin, Qpointer; 305Lisp_Object Qmargin, Qpointer;
306Lisp_Object Qline_height, Qtotal;
307extern Lisp_Object Qheight; 307extern Lisp_Object Qheight;
308extern Lisp_Object QCwidth, QCheight, QCascent; 308extern Lisp_Object QCwidth, QCheight, QCascent;
309extern Lisp_Object Qscroll_bar; 309extern Lisp_Object Qscroll_bar;
@@ -671,10 +671,6 @@ EMACS_INT hscroll_margin;
671/* How much to scroll horizontally when point is inside the above margin. */ 671/* How much to scroll horizontally when point is inside the above margin. */
672Lisp_Object Vhscroll_step; 672Lisp_Object Vhscroll_step;
673 673
674/* A list of symbols, one for each supported image type. */
675
676Lisp_Object Vimage_types;
677
678/* The variable `resize-mini-windows'. If nil, don't resize 674/* The variable `resize-mini-windows'. If nil, don't resize
679 mini-windows. If t, always resize them to fit the text they 675 mini-windows. If t, always resize them to fit the text they
680 display. If `grow-only', let mini-windows grow only until they 676 display. If `grow-only', let mini-windows grow only until they
@@ -800,6 +796,9 @@ int help_echo_pos;
800 796
801Lisp_Object previous_help_echo_string; 797Lisp_Object previous_help_echo_string;
802 798
799/* Null glyph slice */
800
801static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
803 802
804 803
805/* Function prototypes. */ 804/* Function prototypes. */
@@ -852,7 +851,7 @@ static void insert_left_trunc_glyphs P_ ((struct it *));
852static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *, 851static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *,
853 Lisp_Object)); 852 Lisp_Object));
854static void extend_face_to_end_of_line P_ ((struct it *)); 853static void extend_face_to_end_of_line P_ ((struct it *));
855static int append_space P_ ((struct it *, int)); 854static int append_space_for_newline P_ ((struct it *, int));
856static int make_cursor_line_fully_visible P_ ((struct window *, int)); 855static int make_cursor_line_fully_visible P_ ((struct window *, int));
857static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); 856static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int));
858static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); 857static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *));
@@ -1238,9 +1237,9 @@ line_bottom_y (it)
1238 and header-lines heights. */ 1237 and header-lines heights. */
1239 1238
1240int 1239int
1241pos_visible_p (w, charpos, fully, exact_mode_line_heights_p) 1240pos_visible_p (w, charpos, fully, x, y, exact_mode_line_heights_p)
1242 struct window *w; 1241 struct window *w;
1243 int charpos, *fully, exact_mode_line_heights_p; 1242 int charpos, *fully, *x, *y, exact_mode_line_heights_p;
1244{ 1243{
1245 struct it it; 1244 struct it it;
1246 struct text_pos top; 1245 struct text_pos top;
@@ -1288,14 +1287,27 @@ pos_visible_p (w, charpos, fully, exact_mode_line_heights_p)
1288 visible_p = 1; 1287 visible_p = 1;
1289 *fully = bottom_y <= it.last_visible_y; 1288 *fully = bottom_y <= it.last_visible_y;
1290 } 1289 }
1290 if (visible_p && x)
1291 {
1292 *x = it.current_x;
1293 *y = max (top_y + it.max_ascent - it.ascent, window_top_y);
1294 }
1291 } 1295 }
1292 else if (it.current_y + it.max_ascent + it.max_descent > it.last_visible_y) 1296 else if (it.current_y + it.max_ascent + it.max_descent > it.last_visible_y)
1293 { 1297 {
1298 struct it it2;
1299
1300 it2 = it;
1294 move_it_by_lines (&it, 1, 0); 1301 move_it_by_lines (&it, 1, 0);
1295 if (charpos < IT_CHARPOS (it)) 1302 if (charpos < IT_CHARPOS (it))
1296 { 1303 {
1297 visible_p = 1; 1304 visible_p = 1;
1298 *fully = 0; 1305 if (x)
1306 {
1307 move_it_to (&it2, charpos, -1, -1, -1, MOVE_TO_POS);
1308 *x = it2.current_x;
1309 *y = it2.current_y + it2.max_ascent - it2.ascent;
1310 }
1299 } 1311 }
1300 } 1312 }
1301 1313
@@ -1303,6 +1315,7 @@ pos_visible_p (w, charpos, fully, exact_mode_line_heights_p)
1303 set_buffer_internal_1 (old_buffer); 1315 set_buffer_internal_1 (old_buffer);
1304 1316
1305 current_header_line_height = current_mode_line_height = -1; 1317 current_header_line_height = current_mode_line_height = -1;
1318
1306 return visible_p; 1319 return visible_p;
1307} 1320}
1308 1321
@@ -2057,6 +2070,9 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id)
2057 { 2070 {
2058 if (NATNUMP (current_buffer->extra_line_spacing)) 2071 if (NATNUMP (current_buffer->extra_line_spacing))
2059 it->extra_line_spacing = XFASTINT (current_buffer->extra_line_spacing); 2072 it->extra_line_spacing = XFASTINT (current_buffer->extra_line_spacing);
2073 else if (FLOATP (current_buffer->extra_line_spacing))
2074 it->extra_line_spacing = (XFLOAT_DATA (current_buffer->extra_line_spacing)
2075 * FRAME_LINE_HEIGHT (it->f));
2060 else if (it->f->extra_line_spacing > 0) 2076 else if (it->f->extra_line_spacing > 0)
2061 it->extra_line_spacing = it->f->extra_line_spacing; 2077 it->extra_line_spacing = it->f->extra_line_spacing;
2062 } 2078 }
@@ -2070,9 +2086,11 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id)
2070 if (FRAME_FACE_CACHE (it->f)->used == 0) 2086 if (FRAME_FACE_CACHE (it->f)->used == 0)
2071 recompute_basic_faces (it->f); 2087 recompute_basic_faces (it->f);
2072 2088
2073 /* Current value of the `space-width', and 'height' properties. */ 2089 /* Current value of the `slice', `space-width', and 'height' properties. */
2090 it->slice.x = it->slice.y = it->slice.width = it->slice.height = Qnil;
2074 it->space_width = Qnil; 2091 it->space_width = Qnil;
2075 it->font_height = Qnil; 2092 it->font_height = Qnil;
2093 it->override_ascent = -1;
2076 2094
2077 /* Are control characters displayed as `^C'? */ 2095 /* Are control characters displayed as `^C'? */
2078 it->ctl_arrow_p = !NILP (current_buffer->ctl_arrow); 2096 it->ctl_arrow_p = !NILP (current_buffer->ctl_arrow);
@@ -2713,19 +2731,10 @@ next_overlay_change (pos)
2713 int noverlays; 2731 int noverlays;
2714 int endpos; 2732 int endpos;
2715 Lisp_Object *overlays; 2733 Lisp_Object *overlays;
2716 int len;
2717 int i; 2734 int i;
2718 2735
2719 /* Get all overlays at the given position. */ 2736 /* Get all overlays at the given position. */
2720 len = 10; 2737 GET_OVERLAYS_AT (pos, overlays, noverlays, &endpos, 1);
2721 overlays = (Lisp_Object *) alloca (len * sizeof *overlays);
2722 noverlays = overlays_at (pos, 0, &overlays, &len, &endpos, NULL, 1);
2723 if (noverlays > len)
2724 {
2725 len = noverlays;
2726 overlays = (Lisp_Object *) alloca (len * sizeof *overlays);
2727 noverlays = overlays_at (pos, 0, &overlays, &len, &endpos, NULL, 1);
2728 }
2729 2738
2730 /* If any of these overlays ends before endpos, 2739 /* If any of these overlays ends before endpos,
2731 use its ending point instead. */ 2740 use its ending point instead. */
@@ -3278,8 +3287,9 @@ handle_display_prop (it)
3278 } 3287 }
3279 3288
3280 /* Reset those iterator values set from display property values. */ 3289 /* Reset those iterator values set from display property values. */
3281 it->font_height = Qnil; 3290 it->slice.x = it->slice.y = it->slice.width = it->slice.height = Qnil;
3282 it->space_width = Qnil; 3291 it->space_width = Qnil;
3292 it->font_height = Qnil;
3283 it->voffset = 0; 3293 it->voffset = 0;
3284 3294
3285 /* We don't support recursive `display' properties, i.e. string 3295 /* We don't support recursive `display' properties, i.e. string
@@ -3298,6 +3308,7 @@ handle_display_prop (it)
3298 && !EQ (XCAR (prop), Qimage) 3308 && !EQ (XCAR (prop), Qimage)
3299 && !EQ (XCAR (prop), Qspace) 3309 && !EQ (XCAR (prop), Qspace)
3300 && !EQ (XCAR (prop), Qwhen) 3310 && !EQ (XCAR (prop), Qwhen)
3311 && !EQ (XCAR (prop), Qslice)
3301 && !EQ (XCAR (prop), Qspace_width) 3312 && !EQ (XCAR (prop), Qspace_width)
3302 && !EQ (XCAR (prop), Qheight) 3313 && !EQ (XCAR (prop), Qheight)
3303 && !EQ (XCAR (prop), Qraise) 3314 && !EQ (XCAR (prop), Qraise)
@@ -3494,6 +3505,30 @@ handle_single_display_prop (it, prop, object, position,
3494 it->space_width = value; 3505 it->space_width = value;
3495 } 3506 }
3496 else if (CONSP (prop) 3507 else if (CONSP (prop)
3508 && EQ (XCAR (prop), Qslice))
3509 {
3510 /* `(slice X Y WIDTH HEIGHT)'. */
3511 Lisp_Object tem;
3512
3513 if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
3514 return 0;
3515
3516 if (tem = XCDR (prop), CONSP (tem))
3517 {
3518 it->slice.x = XCAR (tem);
3519 if (tem = XCDR (tem), CONSP (tem))
3520 {
3521 it->slice.y = XCAR (tem);
3522 if (tem = XCDR (tem), CONSP (tem))
3523 {
3524 it->slice.width = XCAR (tem);
3525 if (tem = XCDR (tem), CONSP (tem))
3526 it->slice.height = XCAR (tem);
3527 }
3528 }
3529 }
3530 }
3531 else if (CONSP (prop)
3497 && EQ (XCAR (prop), Qraise) 3532 && EQ (XCAR (prop), Qraise)
3498 && CONSP (XCDR (prop))) 3533 && CONSP (XCDR (prop)))
3499 { 3534 {
@@ -4427,6 +4462,7 @@ push_it (it)
4427 p->string_nchars = it->string_nchars; 4462 p->string_nchars = it->string_nchars;
4428 p->area = it->area; 4463 p->area = it->area;
4429 p->multibyte_p = it->multibyte_p; 4464 p->multibyte_p = it->multibyte_p;
4465 p->slice = it->slice;
4430 p->space_width = it->space_width; 4466 p->space_width = it->space_width;
4431 p->font_height = it->font_height; 4467 p->font_height = it->font_height;
4432 p->voffset = it->voffset; 4468 p->voffset = it->voffset;
@@ -4459,6 +4495,7 @@ pop_it (it)
4459 it->string_nchars = p->string_nchars; 4495 it->string_nchars = p->string_nchars;
4460 it->area = p->area; 4496 it->area = p->area;
4461 it->multibyte_p = p->multibyte_p; 4497 it->multibyte_p = p->multibyte_p;
4498 it->slice = p->slice;
4462 it->space_width = p->space_width; 4499 it->space_width = p->space_width;
4463 it->font_height = p->font_height; 4500 it->font_height = p->font_height;
4464 it->voffset = p->voffset; 4501 it->voffset = p->voffset;
@@ -4616,6 +4653,14 @@ back_to_previous_visible_line_start (it)
4616 visible_p = 0; 4653 visible_p = 0;
4617 } 4654 }
4618 4655
4656 if (visible_p)
4657 {
4658 struct it it2 = *it;
4659
4660 if (handle_display_prop (&it2) == HANDLED_RETURN)
4661 visible_p = 0;
4662 }
4663
4619 /* Back one more newline if the current one is invisible. */ 4664 /* Back one more newline if the current one is invisible. */
4620 if (!visible_p) 4665 if (!visible_p)
4621 back_to_previous_line_start (it); 4666 back_to_previous_line_start (it);
@@ -9539,7 +9584,7 @@ update_overlay_arrows (up_to_date)
9539 if (!SYMBOLP (var)) 9584 if (!SYMBOLP (var))
9540 continue; 9585 continue;
9541 9586
9542 if (up_to_date) 9587 if (up_to_date > 0)
9543 { 9588 {
9544 Lisp_Object val = find_symbol_value (var); 9589 Lisp_Object val = find_symbol_value (var);
9545 Fput (var, Qlast_arrow_position, 9590 Fput (var, Qlast_arrow_position,
@@ -10862,15 +10907,14 @@ make_cursor_line_fully_visible (w, force_p)
10862 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 10907 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row))
10863 return 1; 10908 return 1;
10864 10909
10865 if (force_p)
10866 return 0;
10867
10868 /* If the row the cursor is in is taller than the window's height, 10910 /* If the row the cursor is in is taller than the window's height,
10869 it's not clear what to do, so do nothing. */ 10911 it's not clear what to do, so do nothing. */
10870 window_height = window_box_height (w); 10912 window_height = window_box_height (w);
10871 if (row->height >= window_height) 10913 if (row->height >= window_height)
10872 return 1; 10914 {
10873 10915 if (!force_p || w->vscroll)
10916 return 1;
10917 }
10874 return 0; 10918 return 0;
10875 10919
10876#if 0 10920#if 0
@@ -10979,6 +11023,12 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
10979 else 11023 else
10980 this_scroll_margin = 0; 11024 this_scroll_margin = 0;
10981 11025
11026 /* Force scroll_conservatively to have a reasonable value so it doesn't
11027 cause an overflow while computing how much to scroll. */
11028 if (scroll_conservatively)
11029 scroll_conservatively = min (scroll_conservatively,
11030 MOST_POSITIVE_FIXNUM / FRAME_LINE_HEIGHT (f));
11031
10982 /* Compute how much we should try to scroll maximally to bring point 11032 /* Compute how much we should try to scroll maximally to bring point
10983 into view. */ 11033 into view. */
10984 if (scroll_step || scroll_conservatively || temp_scroll_step) 11034 if (scroll_step || scroll_conservatively || temp_scroll_step)
@@ -11054,7 +11104,12 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11054 aggressive = current_buffer->scroll_up_aggressively; 11104 aggressive = current_buffer->scroll_up_aggressively;
11055 height = WINDOW_BOX_TEXT_HEIGHT (w); 11105 height = WINDOW_BOX_TEXT_HEIGHT (w);
11056 if (NUMBERP (aggressive)) 11106 if (NUMBERP (aggressive))
11057 amount_to_scroll = XFLOATINT (aggressive) * height; 11107 {
11108 double float_amount = XFLOATINT (aggressive) * height;
11109 amount_to_scroll = float_amount;
11110 if (amount_to_scroll == 0 && float_amount > 0)
11111 amount_to_scroll = 1;
11112 }
11058 } 11113 }
11059 11114
11060 if (amount_to_scroll <= 0) 11115 if (amount_to_scroll <= 0)
@@ -11112,7 +11167,12 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11112 aggressive = current_buffer->scroll_down_aggressively; 11167 aggressive = current_buffer->scroll_down_aggressively;
11113 height = WINDOW_BOX_TEXT_HEIGHT (w); 11168 height = WINDOW_BOX_TEXT_HEIGHT (w);
11114 if (NUMBERP (aggressive)) 11169 if (NUMBERP (aggressive))
11115 amount_to_scroll = XFLOATINT (aggressive) * height; 11170 {
11171 double float_amount = XFLOATINT (aggressive) * height;
11172 amount_to_scroll = float_amount;
11173 if (amount_to_scroll == 0 && float_amount > 0)
11174 amount_to_scroll = 1;
11175 }
11116 } 11176 }
11117 11177
11118 if (amount_to_scroll <= 0) 11178 if (amount_to_scroll <= 0)
@@ -11307,7 +11367,7 @@ try_cursor_movement (window, startp, scroll_step)
11307 && (FRAME_WINDOW_P (f) 11367 && (FRAME_WINDOW_P (f)
11308 || !overlay_arrow_in_current_buffer_p ())) 11368 || !overlay_arrow_in_current_buffer_p ()))
11309 { 11369 {
11310 int this_scroll_margin; 11370 int this_scroll_margin, top_scroll_margin;
11311 struct glyph_row *row = NULL; 11371 struct glyph_row *row = NULL;
11312 11372
11313#if GLYPH_DEBUG 11373#if GLYPH_DEBUG
@@ -11320,6 +11380,10 @@ try_cursor_movement (window, startp, scroll_step)
11320 this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 11380 this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
11321 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 11381 this_scroll_margin *= FRAME_LINE_HEIGHT (f);
11322 11382
11383 top_scroll_margin = this_scroll_margin;
11384 if (WINDOW_WANTS_HEADER_LINE_P (w))
11385 top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w);
11386
11323 /* Start with the row the cursor was displayed during the last 11387 /* Start with the row the cursor was displayed during the last
11324 not paused redisplay. Give up if that row is not valid. */ 11388 not paused redisplay. Give up if that row is not valid. */
11325 if (w->last_cursor.vpos < 0 11389 if (w->last_cursor.vpos < 0
@@ -11380,7 +11444,7 @@ try_cursor_movement (window, startp, scroll_step)
11380 && (MATRIX_ROW_START_CHARPOS (row) > PT 11444 && (MATRIX_ROW_START_CHARPOS (row) > PT
11381 || (MATRIX_ROW_START_CHARPOS (row) == PT 11445 || (MATRIX_ROW_START_CHARPOS (row) == PT
11382 && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row))) 11446 && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row)))
11383 && (row->y > this_scroll_margin 11447 && (row->y > top_scroll_margin
11384 || CHARPOS (startp) == BEGV)) 11448 || CHARPOS (startp) == BEGV))
11385 { 11449 {
11386 xassert (row->enabled_p); 11450 xassert (row->enabled_p);
@@ -11408,7 +11472,7 @@ try_cursor_movement (window, startp, scroll_step)
11408 ++row; 11472 ++row;
11409 11473
11410 /* If within the scroll margin, scroll. */ 11474 /* If within the scroll margin, scroll. */
11411 if (row->y < this_scroll_margin 11475 if (row->y < top_scroll_margin
11412 && CHARPOS (startp) != BEGV) 11476 && CHARPOS (startp) != BEGV)
11413 scroll_p = 1; 11477 scroll_p = 1;
11414 } 11478 }
@@ -12578,9 +12642,8 @@ try_window_reusing_current_matrix (w)
12578 position. */ 12642 position. */
12579 if (pt_row) 12643 if (pt_row)
12580 { 12644 {
12581 w->cursor.vpos -= MATRIX_ROW_VPOS (first_reusable_row, 12645 w->cursor.vpos -= nrows_scrolled;
12582 w->current_matrix); 12646 w->cursor.y -= first_reusable_row->y - start_row->y;
12583 w->cursor.y -= first_reusable_row->y;
12584 } 12647 }
12585 12648
12586 /* Scroll the display. */ 12649 /* Scroll the display. */
@@ -12625,6 +12688,29 @@ try_window_reusing_current_matrix (w)
12625 for (row -= nrows_scrolled; row < bottom_row; ++row) 12688 for (row -= nrows_scrolled; row < bottom_row; ++row)
12626 row->enabled_p = 0; 12689 row->enabled_p = 0;
12627 12690
12691 /* Point may have moved to a different line, so we cannot assume that
12692 the previous cursor position is valid; locate the correct row. */
12693 if (pt_row)
12694 {
12695 for (row = MATRIX_ROW (w->current_matrix, w->cursor.vpos);
12696 row < bottom_row && PT >= MATRIX_ROW_END_CHARPOS (row);
12697 row++)
12698 {
12699 w->cursor.vpos++;
12700 w->cursor.y = row->y;
12701 }
12702 if (row < bottom_row)
12703 {
12704 struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos;
12705 while (glyph->charpos < PT)
12706 {
12707 w->cursor.hpos++;
12708 w->cursor.x += glyph->pixel_width;
12709 glyph++;
12710 }
12711 }
12712 }
12713
12628 /* Adjust window end. A null value of last_text_row means that 12714 /* Adjust window end. A null value of last_text_row means that
12629 the window end is in reused rows which in turn means that 12715 the window end is in reused rows which in turn means that
12630 only its vpos can have changed. */ 12716 only its vpos can have changed. */
@@ -13408,9 +13494,9 @@ try_window_id (w)
13408 13494
13409 if ((w->cursor.y < this_scroll_margin 13495 if ((w->cursor.y < this_scroll_margin
13410 && CHARPOS (start) > BEGV) 13496 && CHARPOS (start) > BEGV)
13411 /* Don't take scroll margin into account at the bottom because 13497 /* Old redisplay didn't take scroll margin into account at the bottom,
13412 old redisplay didn't do it either. */ 13498 but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */
13413 || w->cursor.y + cursor_height > it.last_visible_y) 13499 || w->cursor.y + cursor_height + this_scroll_margin > it.last_visible_y)
13414 { 13500 {
13415 w->cursor.vpos = -1; 13501 w->cursor.vpos = -1;
13416 clear_glyph_matrix (w->desired_matrix); 13502 clear_glyph_matrix (w->desired_matrix);
@@ -14196,8 +14282,7 @@ compute_line_metrics (it)
14196 14282
14197 14283
14198/* Append one space to the glyph row of iterator IT if doing a 14284/* Append one space to the glyph row of iterator IT if doing a
14199 window-based redisplay. DEFAULT_FACE_P non-zero means let the 14285 window-based redisplay. The space has the same face as
14200 space have the default face, otherwise let it have the same face as
14201 IT->face_id. Value is non-zero if a space was added. 14286 IT->face_id. Value is non-zero if a space was added.
14202 14287
14203 This function is called to make sure that there is always one glyph 14288 This function is called to make sure that there is always one glyph
@@ -14209,7 +14294,7 @@ compute_line_metrics (it)
14209 end of the line if the row ends in italic text. */ 14294 end of the line if the row ends in italic text. */
14210 14295
14211static int 14296static int
14212append_space (it, default_face_p) 14297append_space_for_newline (it, default_face_p)
14213 struct it *it; 14298 struct it *it;
14214 int default_face_p; 14299 int default_face_p;
14215{ 14300{
@@ -14223,7 +14308,7 @@ append_space (it, default_face_p)
14223 /* Save some values that must not be changed. 14308 /* Save some values that must not be changed.
14224 Must save IT->c and IT->len because otherwise 14309 Must save IT->c and IT->len because otherwise
14225 ITERATOR_AT_END_P wouldn't work anymore after 14310 ITERATOR_AT_END_P wouldn't work anymore after
14226 append_space has been called. */ 14311 append_space_for_newline has been called. */
14227 enum display_element_type saved_what = it->what; 14312 enum display_element_type saved_what = it->what;
14228 int saved_c = it->c, saved_len = it->len; 14313 int saved_c = it->c, saved_len = it->len;
14229 int saved_x = it->current_x; 14314 int saved_x = it->current_x;
@@ -14250,6 +14335,8 @@ append_space (it, default_face_p)
14250 14335
14251 PRODUCE_GLYPHS (it); 14336 PRODUCE_GLYPHS (it);
14252 14337
14338 it->override_ascent = -1;
14339 it->constrain_row_ascent_descent_p = 0;
14253 it->current_x = saved_x; 14340 it->current_x = saved_x;
14254 it->object = saved_object; 14341 it->object = saved_object;
14255 it->position = saved_pos; 14342 it->position = saved_pos;
@@ -14531,7 +14618,7 @@ display_line (it)
14531 row->exact_window_width_line_p = 1; 14618 row->exact_window_width_line_p = 1;
14532 else 14619 else
14533#endif /* HAVE_WINDOW_SYSTEM */ 14620#endif /* HAVE_WINDOW_SYSTEM */
14534 if ((append_space (it, 1) && row->used[TEXT_AREA] == 1) 14621 if ((append_space_for_newline (it, 1) && row->used[TEXT_AREA] == 1)
14535 || row->used[TEXT_AREA] == 0) 14622 || row->used[TEXT_AREA] == 0)
14536 { 14623 {
14537 row->glyphs[TEXT_AREA]->charpos = -1; 14624 row->glyphs[TEXT_AREA]->charpos = -1;
@@ -14773,7 +14860,7 @@ display_line (it)
14773 /* Add a space at the end of the line that is used to 14860 /* Add a space at the end of the line that is used to
14774 display the cursor there. */ 14861 display the cursor there. */
14775 if (!IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 14862 if (!IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
14776 append_space (it, 0); 14863 append_space_for_newline (it, 0);
14777#endif /* HAVE_WINDOW_SYSTEM */ 14864#endif /* HAVE_WINDOW_SYSTEM */
14778 14865
14779 /* Extend the face to the end of the line. */ 14866 /* Extend the face to the end of the line. */
@@ -17400,6 +17487,7 @@ fill_image_glyph_string (s)
17400 xassert (s->first_glyph->type == IMAGE_GLYPH); 17487 xassert (s->first_glyph->type == IMAGE_GLYPH);
17401 s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id); 17488 s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id);
17402 xassert (s->img); 17489 xassert (s->img);
17490 s->slice = s->first_glyph->slice;
17403 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 17491 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
17404 s->font = s->face->font; 17492 s->font = s->face->font;
17405 s->width = s->first_glyph->pixel_width; 17493 s->width = s->first_glyph->pixel_width;
@@ -18146,6 +18234,7 @@ append_glyph (it)
18146 glyph->glyph_not_available_p = it->glyph_not_available_p; 18234 glyph->glyph_not_available_p = it->glyph_not_available_p;
18147 glyph->face_id = it->face_id; 18235 glyph->face_id = it->face_id;
18148 glyph->u.ch = it->char_to_display; 18236 glyph->u.ch = it->char_to_display;
18237 glyph->slice = null_glyph_slice;
18149 glyph->font_type = FONT_TYPE_UNKNOWN; 18238 glyph->font_type = FONT_TYPE_UNKNOWN;
18150 ++it->glyph_row->used[area]; 18239 ++it->glyph_row->used[area];
18151 } 18240 }
@@ -18182,6 +18271,7 @@ append_composite_glyph (it)
18182 glyph->glyph_not_available_p = 0; 18271 glyph->glyph_not_available_p = 0;
18183 glyph->face_id = it->face_id; 18272 glyph->face_id = it->face_id;
18184 glyph->u.cmp_id = it->cmp_id; 18273 glyph->u.cmp_id = it->cmp_id;
18274 glyph->slice = null_glyph_slice;
18185 glyph->font_type = FONT_TYPE_UNKNOWN; 18275 glyph->font_type = FONT_TYPE_UNKNOWN;
18186 ++it->glyph_row->used[area]; 18276 ++it->glyph_row->used[area];
18187 } 18277 }
@@ -18200,7 +18290,7 @@ take_vertical_position_into_account (it)
18200 if (it->voffset < 0) 18290 if (it->voffset < 0)
18201 /* Increase the ascent so that we can display the text higher 18291 /* Increase the ascent so that we can display the text higher
18202 in the line. */ 18292 in the line. */
18203 it->ascent += abs (it->voffset); 18293 it->ascent -= it->voffset;
18204 else 18294 else
18205 /* Increase the descent so that we can display the text lower 18295 /* Increase the descent so that we can display the text lower
18206 in the line. */ 18296 in the line. */
@@ -18220,6 +18310,7 @@ produce_image_glyph (it)
18220 struct image *img; 18310 struct image *img;
18221 struct face *face; 18311 struct face *face;
18222 int face_ascent, glyph_ascent; 18312 int face_ascent, glyph_ascent;
18313 struct glyph_slice slice;
18223 18314
18224 xassert (it->what == IT_IMAGE); 18315 xassert (it->what == IT_IMAGE);
18225 18316
@@ -18243,19 +18334,68 @@ produce_image_glyph (it)
18243 /* Make sure X resources of the image is loaded. */ 18334 /* Make sure X resources of the image is loaded. */
18244 prepare_image_for_display (it->f, img); 18335 prepare_image_for_display (it->f, img);
18245 18336
18246 it->ascent = it->phys_ascent = glyph_ascent = image_ascent (img, face); 18337 slice.x = slice.y = 0;
18247 it->descent = it->phys_descent = img->height + 2 * img->vmargin - it->ascent; 18338 slice.width = img->width;
18248 it->pixel_width = img->width + 2 * img->hmargin; 18339 slice.height = img->height;
18340
18341 if (INTEGERP (it->slice.x))
18342 slice.x = XINT (it->slice.x);
18343 else if (FLOATP (it->slice.x))
18344 slice.x = XFLOAT_DATA (it->slice.x) * img->width;
18345
18346 if (INTEGERP (it->slice.y))
18347 slice.y = XINT (it->slice.y);
18348 else if (FLOATP (it->slice.y))
18349 slice.y = XFLOAT_DATA (it->slice.y) * img->height;
18350
18351 if (INTEGERP (it->slice.width))
18352 slice.width = XINT (it->slice.width);
18353 else if (FLOATP (it->slice.width))
18354 slice.width = XFLOAT_DATA (it->slice.width) * img->width;
18355
18356 if (INTEGERP (it->slice.height))
18357 slice.height = XINT (it->slice.height);
18358 else if (FLOATP (it->slice.height))
18359 slice.height = XFLOAT_DATA (it->slice.height) * img->height;
18360
18361 if (slice.x >= img->width)
18362 slice.x = img->width;
18363 if (slice.y >= img->height)
18364 slice.y = img->height;
18365 if (slice.x + slice.width >= img->width)
18366 slice.width = img->width - slice.x;
18367 if (slice.y + slice.height > img->height)
18368 slice.height = img->height - slice.y;
18369
18370 if (slice.width == 0 || slice.height == 0)
18371 return;
18372
18373 it->ascent = it->phys_ascent = glyph_ascent = image_ascent (img, face, &slice);
18374
18375 it->descent = slice.height - glyph_ascent;
18376 if (slice.y == 0)
18377 it->descent += img->vmargin;
18378 if (slice.y + slice.height == img->height)
18379 it->descent += img->vmargin;
18380 it->phys_descent = it->descent;
18381
18382 it->pixel_width = slice.width;
18383 if (slice.x == 0)
18384 it->pixel_width += img->hmargin;
18385 if (slice.x + slice.width == img->width)
18386 it->pixel_width += img->hmargin;
18249 18387
18250 /* It's quite possible for images to have an ascent greater than 18388 /* It's quite possible for images to have an ascent greater than
18251 their height, so don't get confused in that case. */ 18389 their height, so don't get confused in that case. */
18252 if (it->descent < 0) 18390 if (it->descent < 0)
18253 it->descent = 0; 18391 it->descent = 0;
18254 18392
18393#if 0 /* this breaks image tiling */
18255 /* If this glyph is alone on the last line, adjust it.ascent to minimum row ascent. */ 18394 /* If this glyph is alone on the last line, adjust it.ascent to minimum row ascent. */
18256 face_ascent = face->font ? FONT_BASE (face->font) : FRAME_BASELINE_OFFSET (it->f); 18395 face_ascent = face->font ? FONT_BASE (face->font) : FRAME_BASELINE_OFFSET (it->f);
18257 if (face_ascent > it->ascent) 18396 if (face_ascent > it->ascent)
18258 it->ascent = it->phys_ascent = face_ascent; 18397 it->ascent = it->phys_ascent = face_ascent;
18398#endif
18259 18399
18260 it->nglyphs = 1; 18400 it->nglyphs = 1;
18261 18401
@@ -18263,13 +18403,15 @@ produce_image_glyph (it)
18263 { 18403 {
18264 if (face->box_line_width > 0) 18404 if (face->box_line_width > 0)
18265 { 18405 {
18266 it->ascent += face->box_line_width; 18406 if (slice.y == 0)
18267 it->descent += face->box_line_width; 18407 it->ascent += face->box_line_width;
18408 if (slice.y + slice.height == img->height)
18409 it->descent += face->box_line_width;
18268 } 18410 }
18269 18411
18270 if (it->start_of_box_run_p) 18412 if (it->start_of_box_run_p && slice.x == 0)
18271 it->pixel_width += abs (face->box_line_width); 18413 it->pixel_width += abs (face->box_line_width);
18272 if (it->end_of_box_run_p) 18414 if (it->end_of_box_run_p && slice.x + slice.width == img->width)
18273 it->pixel_width += abs (face->box_line_width); 18415 it->pixel_width += abs (face->box_line_width);
18274 } 18416 }
18275 18417
@@ -18298,6 +18440,7 @@ produce_image_glyph (it)
18298 glyph->glyph_not_available_p = 0; 18440 glyph->glyph_not_available_p = 0;
18299 glyph->face_id = it->face_id; 18441 glyph->face_id = it->face_id;
18300 glyph->u.img_id = img->id; 18442 glyph->u.img_id = img->id;
18443 glyph->slice = slice;
18301 glyph->font_type = FONT_TYPE_UNKNOWN; 18444 glyph->font_type = FONT_TYPE_UNKNOWN;
18302 ++it->glyph_row->used[area]; 18445 ++it->glyph_row->used[area];
18303 } 18446 }
@@ -18340,6 +18483,7 @@ append_stretch_glyph (it, object, width, height, ascent)
18340 glyph->face_id = it->face_id; 18483 glyph->face_id = it->face_id;
18341 glyph->u.stretch.ascent = ascent; 18484 glyph->u.stretch.ascent = ascent;
18342 glyph->u.stretch.height = height; 18485 glyph->u.stretch.height = height;
18486 glyph->slice = null_glyph_slice;
18343 glyph->font_type = FONT_TYPE_UNKNOWN; 18487 glyph->font_type = FONT_TYPE_UNKNOWN;
18344 ++it->glyph_row->used[area]; 18488 ++it->glyph_row->used[area];
18345 } 18489 }
@@ -18505,6 +18649,107 @@ produce_stretch_glyph (it)
18505 take_vertical_position_into_account (it); 18649 take_vertical_position_into_account (it);
18506} 18650}
18507 18651
18652/* Calculate line-height and line-spacing properties.
18653 An integer value specifies explicit pixel value.
18654 A float value specifies relative value to current face height.
18655 A cons (float . face-name) specifies relative value to
18656 height of specified face font.
18657
18658 Returns height in pixels, or nil. */
18659
18660static Lisp_Object
18661calc_line_height_property (it, prop, font, boff, total)
18662 struct it *it;
18663 Lisp_Object prop;
18664 XFontStruct *font;
18665 int boff, *total;
18666{
18667 Lisp_Object position, val;
18668 Lisp_Object face_name = Qnil;
18669 int ascent, descent, height, override;
18670
18671 if (STRINGP (it->object))
18672 position = make_number (IT_STRING_CHARPOS (*it));
18673 else
18674 position = make_number (IT_CHARPOS (*it));
18675
18676 val = Fget_char_property (position, prop, it->object);
18677
18678 if (NILP (val))
18679 return val;
18680
18681 if (total && CONSP (val) && EQ (XCAR (val), Qtotal))
18682 {
18683 *total = 1;
18684 val = XCDR (val);
18685 }
18686
18687 if (INTEGERP (val))
18688 return val;
18689
18690 if (CONSP (val))
18691 {
18692 face_name = XCDR (val);
18693 val = XCAR (val);
18694 }
18695 else if (SYMBOLP (val))
18696 {
18697 face_name = val;
18698 val = Qnil;
18699 }
18700
18701 override = EQ (prop, Qline_height);
18702
18703 if (NILP (face_name))
18704 {
18705 font = FRAME_FONT (it->f);
18706 boff = FRAME_BASELINE_OFFSET (it->f);
18707 }
18708 else if (EQ (face_name, Qt))
18709 {
18710 override = 0;
18711 }
18712 else
18713 {
18714 int face_id;
18715 struct face *face;
18716 struct font_info *font_info;
18717
18718 face_id = lookup_named_face (it->f, face_name);
18719 if (face_id < 0)
18720 return make_number (-1);
18721
18722 face = FACE_FROM_ID (it->f, face_id);
18723 font = face->font;
18724 if (font == NULL)
18725 return make_number (-1);
18726
18727 font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id);
18728 boff = font_info->baseline_offset;
18729 if (font_info->vertical_centering)
18730 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
18731 }
18732
18733 ascent = FONT_BASE (font) + boff;
18734 descent = FONT_DESCENT (font) - boff;
18735
18736 if (override)
18737 {
18738 it->override_ascent = ascent;
18739 it->override_descent = descent;
18740 it->override_boff = boff;
18741 }
18742
18743 height = ascent + descent;
18744 if (FLOATP (val))
18745 height = (int)(XFLOAT_DATA (val) * height);
18746 else if (INTEGERP (val))
18747 height *= XINT (val);
18748
18749 return make_number (height);
18750}
18751
18752
18508/* RIF: 18753/* RIF:
18509 Produce glyphs/get display metrics for the display element IT is 18754 Produce glyphs/get display metrics for the display element IT is
18510 loaded with. See the description of struct display_iterator in 18755 loaded with. See the description of struct display_iterator in
@@ -18514,6 +18759,8 @@ void
18514x_produce_glyphs (it) 18759x_produce_glyphs (it)
18515 struct it *it; 18760 struct it *it;
18516{ 18761{
18762 int extra_line_spacing = it->extra_line_spacing;
18763
18517 it->glyph_not_available_p = 0; 18764 it->glyph_not_available_p = 0;
18518 18765
18519 if (it->what == IT_CHARACTER) 18766 if (it->what == IT_CHARACTER)
@@ -18585,8 +18832,18 @@ x_produce_glyphs (it)
18585 18832
18586 pcm = rif->per_char_metric (font, &char2b, 18833 pcm = rif->per_char_metric (font, &char2b,
18587 FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display)); 18834 FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display));
18588 it->ascent = FONT_BASE (font) + boff; 18835
18589 it->descent = FONT_DESCENT (font) - boff; 18836 if (it->override_ascent >= 0)
18837 {
18838 it->ascent = it->override_ascent;
18839 it->descent = it->override_descent;
18840 boff = it->override_boff;
18841 }
18842 else
18843 {
18844 it->ascent = FONT_BASE (font) + boff;
18845 it->descent = FONT_DESCENT (font) - boff;
18846 }
18590 18847
18591 if (pcm) 18848 if (pcm)
18592 { 18849 {
@@ -18597,11 +18854,28 @@ x_produce_glyphs (it)
18597 else 18854 else
18598 { 18855 {
18599 it->glyph_not_available_p = 1; 18856 it->glyph_not_available_p = 1;
18600 it->phys_ascent = FONT_BASE (font) + boff; 18857 it->phys_ascent = it->ascent;
18601 it->phys_descent = FONT_DESCENT (font) - boff; 18858 it->phys_descent = it->descent;
18602 it->pixel_width = FONT_WIDTH (font); 18859 it->pixel_width = FONT_WIDTH (font);
18603 } 18860 }
18604 18861
18862 if (it->constrain_row_ascent_descent_p)
18863 {
18864 if (it->descent > it->max_descent)
18865 {
18866 it->ascent += it->descent - it->max_descent;
18867 it->descent = it->max_descent;
18868 }
18869 if (it->ascent > it->max_ascent)
18870 {
18871 it->descent = min (it->max_descent, it->descent + it->ascent - it->max_ascent);
18872 it->ascent = it->max_ascent;
18873 }
18874 it->phys_ascent = min (it->phys_ascent, it->ascent);
18875 it->phys_descent = min (it->phys_descent, it->descent);
18876 extra_line_spacing = 0;
18877 }
18878
18605 /* If this is a space inside a region of text with 18879 /* If this is a space inside a region of text with
18606 `space-width' property, change its width. */ 18880 `space-width' property, change its width. */
18607 stretched_p = it->char_to_display == ' ' && !NILP (it->space_width); 18881 stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);
@@ -18634,6 +18908,14 @@ x_produce_glyphs (it)
18634 if (face->overline_p) 18908 if (face->overline_p)
18635 it->ascent += 2; 18909 it->ascent += 2;
18636 18910
18911 if (it->constrain_row_ascent_descent_p)
18912 {
18913 if (it->ascent > it->max_ascent)
18914 it->ascent = it->max_ascent;
18915 if (it->descent > it->max_descent)
18916 it->descent = it->max_descent;
18917 }
18918
18637 take_vertical_position_into_account (it); 18919 take_vertical_position_into_account (it);
18638 18920
18639 /* If we have to actually produce glyphs, do it. */ 18921 /* If we have to actually produce glyphs, do it. */
@@ -18660,17 +18942,73 @@ x_produce_glyphs (it)
18660 } 18942 }
18661 else if (it->char_to_display == '\n') 18943 else if (it->char_to_display == '\n')
18662 { 18944 {
18663 /* A newline has no width but we need the height of the line. */ 18945 /* A newline has no width but we need the height of the line.
18946 But if previous part of the line set a height, don't
18947 increase that height */
18948
18949 Lisp_Object height;
18950
18951 it->override_ascent = -1;
18664 it->pixel_width = 0; 18952 it->pixel_width = 0;
18665 it->nglyphs = 0; 18953 it->nglyphs = 0;
18666 it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
18667 it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
18668 18954
18669 if (face->box != FACE_NO_BOX 18955 height = calc_line_height_property(it, Qline_height, font, boff, 0);
18670 && face->box_line_width > 0) 18956
18957 if (it->override_ascent >= 0)
18671 { 18958 {
18672 it->ascent += face->box_line_width; 18959 it->ascent = it->override_ascent;
18673 it->descent += face->box_line_width; 18960 it->descent = it->override_descent;
18961 boff = it->override_boff;
18962 }
18963 else
18964 {
18965 it->ascent = FONT_BASE (font) + boff;
18966 it->descent = FONT_DESCENT (font) - boff;
18967 }
18968
18969 if (EQ (height, make_number(0)))
18970 {
18971 if (it->descent > it->max_descent)
18972 {
18973 it->ascent += it->descent - it->max_descent;
18974 it->descent = it->max_descent;
18975 }
18976 if (it->ascent > it->max_ascent)
18977 {
18978 it->descent = min (it->max_descent, it->descent + it->ascent - it->max_ascent);
18979 it->ascent = it->max_ascent;
18980 }
18981 it->phys_ascent = min (it->phys_ascent, it->ascent);
18982 it->phys_descent = min (it->phys_descent, it->descent);
18983 it->constrain_row_ascent_descent_p = 1;
18984 extra_line_spacing = 0;
18985 }
18986 else
18987 {
18988 Lisp_Object spacing;
18989 int total = 0;
18990
18991 it->phys_ascent = it->ascent;
18992 it->phys_descent = it->descent;
18993
18994 if ((it->max_ascent > 0 || it->max_descent > 0)
18995 && face->box != FACE_NO_BOX
18996 && face->box_line_width > 0)
18997 {
18998 it->ascent += face->box_line_width;
18999 it->descent += face->box_line_width;
19000 }
19001 if (!NILP (height)
19002 && XINT (height) > it->ascent + it->descent)
19003 it->ascent = XINT (height) - it->descent;
19004
19005 spacing = calc_line_height_property(it, Qline_spacing, font, boff, &total);
19006 if (INTEGERP (spacing))
19007 {
19008 extra_line_spacing = XINT (spacing);
19009 if (total)
19010 extra_line_spacing -= (it->phys_ascent + it->phys_descent);
19011 }
18674 } 19012 }
18675 } 19013 }
18676 else if (it->char_to_display == '\t') 19014 else if (it->char_to_display == '\t')
@@ -19093,7 +19431,8 @@ x_produce_glyphs (it)
19093 if (it->area == TEXT_AREA) 19431 if (it->area == TEXT_AREA)
19094 it->current_x += it->pixel_width; 19432 it->current_x += it->pixel_width;
19095 19433
19096 it->descent += it->extra_line_spacing; 19434 if (extra_line_spacing > 0)
19435 it->descent += extra_line_spacing;
19097 19436
19098 it->max_ascent = max (it->max_ascent, it->ascent); 19437 it->max_ascent = max (it->max_ascent, it->ascent);
19099 it->max_descent = max (it->max_descent, it->descent); 19438 it->max_descent = max (it->max_descent, it->descent);
@@ -20390,8 +20729,8 @@ on_hot_spot_p (hot_spot, x, y)
20390 return inside; 20729 return inside;
20391 } 20730 }
20392 } 20731 }
20393 else 20732 /* If we don't understand the format, pretend we're not in the hot-spot. */
20394 return 0; 20733 return 0;
20395} 20734}
20396 20735
20397Lisp_Object 20736Lisp_Object
@@ -20426,7 +20765,6 @@ Returns the alist element for the first matching AREA in MAP. */)
20426 Lisp_Object map; 20765 Lisp_Object map;
20427 Lisp_Object x, y; 20766 Lisp_Object x, y;
20428{ 20767{
20429 int ix, iy;
20430 if (NILP (map)) 20768 if (NILP (map))
20431 return Qnil; 20769 return Qnil;
20432 20770
@@ -20466,11 +20804,7 @@ define_frame_cursor1 (f, cursor, pointer)
20466 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 20804 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
20467 } 20805 }
20468 20806
20469#ifndef HAVE_CARBON
20470 if (cursor != No_Cursor) 20807 if (cursor != No_Cursor)
20471#else
20472 if (bcmp (&cursor, &No_Cursor, sizeof (Cursor)))
20473#endif
20474 rif->define_frame_cursor (f, cursor); 20808 rif->define_frame_cursor (f, cursor);
20475} 20809}
20476 20810
@@ -20492,7 +20826,7 @@ note_mode_line_or_margin_highlight (w, x, y, area)
20492 Lisp_Object pointer = Qnil; 20826 Lisp_Object pointer = Qnil;
20493 int charpos, dx, dy, width, height; 20827 int charpos, dx, dy, width, height;
20494 Lisp_Object string, object = Qnil; 20828 Lisp_Object string, object = Qnil;
20495 Lisp_Object pos, help, image; 20829 Lisp_Object pos, help;
20496 20830
20497 if (area == ON_MODE_LINE || area == ON_HEADER_LINE) 20831 if (area == ON_MODE_LINE || area == ON_HEADER_LINE)
20498 string = mode_line_string (w, area, &x, &y, &charpos, 20832 string = mode_line_string (w, area, &x, &y, &charpos,
@@ -20671,7 +21005,7 @@ note_mouse_highlight (f, x, y)
20671 Lisp_Object object; 21005 Lisp_Object object;
20672 Lisp_Object mouse_face = Qnil, overlay = Qnil, position; 21006 Lisp_Object mouse_face = Qnil, overlay = Qnil, position;
20673 Lisp_Object *overlay_vec = NULL; 21007 Lisp_Object *overlay_vec = NULL;
20674 int len, noverlays; 21008 int noverlays;
20675 struct buffer *obuf; 21009 struct buffer *obuf;
20676 int obegv, ozv, same_region; 21010 int obegv, ozv, same_region;
20677 21011
@@ -20687,7 +21021,9 @@ note_mouse_highlight (f, x, y)
20687 Lisp_Object image_map, hotspot; 21021 Lisp_Object image_map, hotspot;
20688 if ((image_map = Fplist_get (XCDR (img->spec), QCmap), 21022 if ((image_map = Fplist_get (XCDR (img->spec), QCmap),
20689 !NILP (image_map)) 21023 !NILP (image_map))
20690 && (hotspot = find_hot_spot (image_map, dx, dy), 21024 && (hotspot = find_hot_spot (image_map,
21025 glyph->slice.x + dx,
21026 glyph->slice.y + dy),
20691 CONSP (hotspot)) 21027 CONSP (hotspot))
20692 && (hotspot = XCDR (hotspot), CONSP (hotspot))) 21028 && (hotspot = XCDR (hotspot), CONSP (hotspot)))
20693 { 21029 {
@@ -20756,19 +21092,8 @@ note_mouse_highlight (f, x, y)
20756 21092
20757 if (BUFFERP (object)) 21093 if (BUFFERP (object))
20758 { 21094 {
20759 /* Put all the overlays we want in a vector in overlay_vec. 21095 /* Put all the overlays we want in a vector in overlay_vec. */
20760 Store the length in len. If there are more than 10, make 21096 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
20761 enough space for all, and try again. */
20762 len = 10;
20763 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
20764 noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL, 0);
20765 if (noverlays > len)
20766 {
20767 len = noverlays;
20768 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
20769 noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL,0);
20770 }
20771
20772 /* Sort overlays into increasing priority order. */ 21097 /* Sort overlays into increasing priority order. */
20773 noverlays = sort_overlays (overlay_vec, noverlays, w); 21098 noverlays = sort_overlays (overlay_vec, noverlays, w);
20774 } 21099 }
@@ -21724,6 +22049,8 @@ syms_of_xdisp ()
21724 staticpro (&Qspace_width); 22049 staticpro (&Qspace_width);
21725 Qraise = intern ("raise"); 22050 Qraise = intern ("raise");
21726 staticpro (&Qraise); 22051 staticpro (&Qraise);
22052 Qslice = intern ("slice");
22053 staticpro (&Qslice);
21727 Qspace = intern ("space"); 22054 Qspace = intern ("space");
21728 staticpro (&Qspace); 22055 staticpro (&Qspace);
21729 Qmargin = intern ("margin"); 22056 Qmargin = intern ("margin");
@@ -21736,6 +22063,10 @@ syms_of_xdisp ()
21736 staticpro (&Qright_margin); 22063 staticpro (&Qright_margin);
21737 Qcenter = intern ("center"); 22064 Qcenter = intern ("center");
21738 staticpro (&Qcenter); 22065 staticpro (&Qcenter);
22066 Qline_height = intern ("line-height");
22067 staticpro (&Qline_height);
22068 Qtotal = intern ("total");
22069 staticpro (&Qtotal);
21739 QCalign_to = intern (":align-to"); 22070 QCalign_to = intern (":align-to");
21740 staticpro (&QCalign_to); 22071 staticpro (&QCalign_to);
21741 QCrelative_width = intern (":relative-width"); 22072 QCrelative_width = intern (":relative-width");
@@ -22096,11 +22427,6 @@ Note that the lower bound for automatic hscrolling specified by `scroll-left'
22096and `scroll-right' overrides this variable's effect. */); 22427and `scroll-right' overrides this variable's effect. */);
22097 Vhscroll_step = make_number (0); 22428 Vhscroll_step = make_number (0);
22098 22429
22099 DEFVAR_LISP ("image-types", &Vimage_types,
22100 doc: /* List of supported image types.
22101Each element of the list is a symbol for a supported image type. */);
22102 Vimage_types = Qnil;
22103
22104 DEFVAR_BOOL ("message-truncate-lines", &message_truncate_lines, 22430 DEFVAR_BOOL ("message-truncate-lines", &message_truncate_lines,
22105 doc: /* If non-nil, messages are truncated instead of resizing the echo area. 22431 doc: /* If non-nil, messages are truncated instead of resizing the echo area.
22106Bind this around calls to `message' to let it take effect. */); 22432Bind this around calls to `message' to let it take effect. */);
diff --git a/src/xfaces.c b/src/xfaces.c
index f44b216877f..d2da290ed56 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -464,6 +464,7 @@ int menu_face_changed_default;
464 464
465struct font_name; 465struct font_name;
466struct table_entry; 466struct table_entry;
467struct named_merge_point;
467 468
468static void map_tty_color P_ ((struct frame *, struct face *, 469static void map_tty_color P_ ((struct frame *, struct face *,
469 enum lface_attribute_index, int *)); 470 enum lface_attribute_index, int *));
@@ -519,11 +520,10 @@ static int face_numeric_weight P_ ((Lisp_Object));
519static int face_numeric_slant P_ ((Lisp_Object)); 520static int face_numeric_slant P_ ((Lisp_Object));
520static int face_numeric_swidth P_ ((Lisp_Object)); 521static int face_numeric_swidth P_ ((Lisp_Object));
521static int face_fontset P_ ((Lisp_Object *)); 522static int face_fontset P_ ((Lisp_Object *));
522static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object)); 523static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*,
523static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object, 524 struct named_merge_point *));
524 Lisp_Object *, Lisp_Object)); 525static int merge_face_ref P_ ((struct frame *, Lisp_Object, Lisp_Object *,
525static void merge_face_vector_with_property P_ ((struct frame *, Lisp_Object *, 526 int, struct named_merge_point *));
526 Lisp_Object));
527static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, 527static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object,
528 Lisp_Object, int, int)); 528 Lisp_Object, int, int));
529static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); 529static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int));
@@ -3214,6 +3214,49 @@ check_lface (lface)
3214#endif /* GLYPH_DEBUG == 0 */ 3214#endif /* GLYPH_DEBUG == 0 */
3215 3215
3216 3216
3217
3218/* Face-merge cycle checking. */
3219
3220/* A `named merge point' is simply a point during face-merging where we
3221 look up a face by name. We keep a stack of which named lookups we're
3222 currently processing so that we can easily detect cycles, using a
3223 linked- list of struct named_merge_point structures, typically
3224 allocated on the stack frame of the named lookup functions which are
3225 active (so no consing is required). */
3226struct named_merge_point
3227{
3228 Lisp_Object face_name;
3229 struct named_merge_point *prev;
3230};
3231
3232
3233/* If a face merging cycle is detected for FACE_NAME, return 0,
3234 otherwise add NEW_NAMED_MERGE_POINT, which is initialized using
3235 FACE_NAME, as the head of the linked list pointed to by
3236 NAMED_MERGE_POINTS, and return 1. */
3237
3238static INLINE int
3239push_named_merge_point (struct named_merge_point *new_named_merge_point,
3240 Lisp_Object face_name,
3241 struct named_merge_point **named_merge_points)
3242{
3243 struct named_merge_point *prev;
3244
3245 for (prev = *named_merge_points; prev; prev = prev->prev)
3246 if (EQ (face_name, prev->face_name))
3247 return 0;
3248
3249 new_named_merge_point->face_name = face_name;
3250 new_named_merge_point->prev = *named_merge_points;
3251
3252 *named_merge_points = new_named_merge_point;
3253
3254 return 1;
3255}
3256
3257
3258
3259
3217/* Resolve face name FACE_NAME. If FACE_NAME is a string, intern it 3260/* Resolve face name FACE_NAME. If FACE_NAME is a string, intern it
3218 to make it a symvol. If FACE_NAME is an alias for another face, 3261 to make it a symvol. If FACE_NAME is an alias for another face,
3219 return that face's name. */ 3262 return that face's name. */
@@ -3480,6 +3523,8 @@ merge_face_heights (from, to, invalid, gcpro)
3480 else if (FLOATP (to)) 3523 else if (FLOATP (to))
3481 /* relative X relative => relative */ 3524 /* relative X relative => relative */
3482 result = make_float (XFLOAT_DATA (from) * XFLOAT_DATA (to)); 3525 result = make_float (XFLOAT_DATA (from) * XFLOAT_DATA (to));
3526 else if (UNSPECIFIEDP (to))
3527 result = from;
3483 } 3528 }
3484 else if (FUNCTIONP (from)) 3529 else if (FUNCTIONP (from))
3485 /* FROM is a function, which use to adjust TO. */ 3530 /* FROM is a function, which use to adjust TO. */
@@ -3511,14 +3556,15 @@ merge_face_heights (from, to, invalid, gcpro)
3511 completely specified and contain only absolute attributes. Every 3556 completely specified and contain only absolute attributes. Every
3512 specified attribute of FROM overrides the corresponding attribute of 3557 specified attribute of FROM overrides the corresponding attribute of
3513 TO; relative attributes in FROM are merged with the absolute value in 3558 TO; relative attributes in FROM are merged with the absolute value in
3514 TO and replace it. CYCLE_CHECK is used internally to detect loops in 3559 TO and replace it. NAMED_MERGE_POINTS is used internally to detect
3515 face inheritance; it should be Qnil when called from other places. */ 3560 loops in face inheritance; it should be 0 when called from other
3561 places. */
3516 3562
3517static INLINE void 3563static INLINE void
3518merge_face_vectors (f, from, to, cycle_check) 3564merge_face_vectors (f, from, to, named_merge_points)
3519 struct frame *f; 3565 struct frame *f;
3520 Lisp_Object *from, *to; 3566 Lisp_Object *from, *to;
3521 Lisp_Object cycle_check; 3567 struct named_merge_point *named_merge_points;
3522{ 3568{
3523 int i; 3569 int i;
3524 3570
@@ -3529,7 +3575,7 @@ merge_face_vectors (f, from, to, cycle_check)
3529 other code uses `unspecified' as a generic value for face attributes. */ 3575 other code uses `unspecified' as a generic value for face attributes. */
3530 if (!UNSPECIFIEDP (from[LFACE_INHERIT_INDEX]) 3576 if (!UNSPECIFIEDP (from[LFACE_INHERIT_INDEX])
3531 && !NILP (from[LFACE_INHERIT_INDEX])) 3577 && !NILP (from[LFACE_INHERIT_INDEX]))
3532 merge_face_inheritance (f, from[LFACE_INHERIT_INDEX], to, cycle_check); 3578 merge_face_ref (f, from[LFACE_INHERIT_INDEX], to, 0, named_merge_points);
3533 3579
3534 /* If TO specifies a :font attribute, and FROM specifies some 3580 /* If TO specifies a :font attribute, and FROM specifies some
3535 font-related attribute, we need to clear TO's :font attribute 3581 font-related attribute, we need to clear TO's :font attribute
@@ -3548,7 +3594,8 @@ merge_face_vectors (f, from, to, cycle_check)
3548 if (!UNSPECIFIEDP (from[i])) 3594 if (!UNSPECIFIEDP (from[i]))
3549 { 3595 {
3550 if (i == LFACE_HEIGHT_INDEX && !INTEGERP (from[i])) 3596 if (i == LFACE_HEIGHT_INDEX && !INTEGERP (from[i]))
3551 to[i] = merge_face_heights (from[i], to[i], to[i], cycle_check); 3597 to[i] = merge_face_heights (from[i], to[i], to[i],
3598 named_merge_points);
3552 else 3599 else
3553 to[i] = from[i]; 3600 to[i] = from[i];
3554 } 3601 }
@@ -3558,87 +3605,45 @@ merge_face_vectors (f, from, to, cycle_check)
3558 to[LFACE_INHERIT_INDEX] = Qnil; 3605 to[LFACE_INHERIT_INDEX] = Qnil;
3559} 3606}
3560 3607
3608/* Merge the named face FACE_NAME on frame F, into the vector of face
3609 attributes TO. NAMED_MERGE_POINTS is used to detect loops in face
3610 inheritance. Returns true if FACE_NAME is a valid face name and
3611 merging succeeded. */
3561 3612
3562/* Checks the `cycle check' variable CHECK to see if it indicates that 3613static int
3563 EL is part of a cycle; CHECK must be either Qnil or a value returned 3614merge_named_face (f, face_name, to, named_merge_points)
3564 by an earlier use of CYCLE_CHECK. SUSPICIOUS is the number of
3565 elements after which a cycle might be suspected; after that many
3566 elements, this macro begins consing in order to keep more precise
3567 track of elements.
3568
3569 Returns nil if a cycle was detected, otherwise a new value for CHECK
3570 that includes EL.
3571
3572 CHECK is evaluated multiple times, EL and SUSPICIOUS 0 or 1 times, so
3573 the caller should make sure that's ok. */
3574
3575#define CYCLE_CHECK(check, el, suspicious) \
3576 (NILP (check) \
3577 ? make_number (0) \
3578 : (INTEGERP (check) \
3579 ? (XFASTINT (check) < (suspicious) \
3580 ? make_number (XFASTINT (check) + 1) \
3581 : Fcons (el, Qnil)) \
3582 : (!NILP (Fmemq ((el), (check))) \
3583 ? Qnil \
3584 : Fcons ((el), (check)))))
3585
3586
3587/* Merge face attributes from the face on frame F whose name is
3588 INHERITS, into the vector of face attributes TO; INHERITS may also be
3589 a list of face names, in which case they are applied in order.
3590 CYCLE_CHECK is used to detect loops in face inheritance.
3591 Returns true if any of the inherited attributes are `font-related'. */
3592
3593static void
3594merge_face_inheritance (f, inherit, to, cycle_check)
3595 struct frame *f; 3615 struct frame *f;
3596 Lisp_Object inherit; 3616 Lisp_Object face_name;
3597 Lisp_Object *to; 3617 Lisp_Object *to;
3598 Lisp_Object cycle_check; 3618 struct named_merge_point *named_merge_points;
3599{ 3619{
3600 if (SYMBOLP (inherit) && !EQ (inherit, Qunspecified)) 3620 struct named_merge_point named_merge_point;
3601 /* Inherit from the named face INHERIT. */
3602 {
3603 Lisp_Object lface;
3604
3605 /* Make sure we're not in an inheritance loop. */
3606 cycle_check = CYCLE_CHECK (cycle_check, inherit, 15);
3607 if (NILP (cycle_check))
3608 /* Cycle detected, ignore any further inheritance. */
3609 return;
3610 3621
3611 lface = lface_from_face_name (f, inherit, 0); 3622 if (push_named_merge_point (&named_merge_point,
3612 if (!NILP (lface)) 3623 face_name, &named_merge_points))
3613 merge_face_vectors (f, XVECTOR (lface)->contents, to, cycle_check);
3614 }
3615 else if (CONSP (inherit))
3616 /* Handle a list of inherited faces by calling ourselves recursively
3617 on each element. Note that we only do so for symbol elements, so
3618 it's not possible to infinitely recurse. */
3619 { 3624 {
3620 while (CONSP (inherit)) 3625 Lisp_Object from[LFACE_VECTOR_SIZE];
3621 { 3626 int ok = get_lface_attributes (f, face_name, from, 0);
3622 if (SYMBOLP (XCAR (inherit)))
3623 merge_face_inheritance (f, XCAR (inherit), to, cycle_check);
3624 3627
3625 /* Check for a circular inheritance list. */ 3628 if (ok)
3626 cycle_check = CYCLE_CHECK (cycle_check, inherit, 15); 3629 merge_face_vectors (f, from, to, named_merge_points);
3627 if (NILP (cycle_check))
3628 /* Cycle detected. */
3629 break;
3630 3630
3631 inherit = XCDR (inherit); 3631 return ok;
3632 }
3633 } 3632 }
3633 else
3634 return 0;
3634} 3635}
3635 3636
3636 3637
3637/* Given a Lisp face attribute vector TO and a Lisp object PROP that 3638/* Merge face attributes from the lisp `face reference' FACE_REF on
3638 is a face property, determine the resulting face attributes on 3639 frame F into the face attribute vector TO. If ERR_MSGS is non-zero,
3639 frame F, and store them in TO. PROP may be a single face 3640 problems with FACE_REF cause an error message to be shown. Return
3640 specification or a list of such specifications. Each face 3641 non-zero if no errors occurred (regardless of the value of ERR_MSGS).
3641 specification can be 3642 NAMED_MERGE_POINTS is used to detect loops in face inheritance or
3643 list structure; it may be 0 for most callers.
3644
3645 FACE_REF may be a single face specification or a list of such
3646 specifications. Each face specification can be:
3642 3647
3643 1. A symbol or string naming a Lisp face. 3648 1. A symbol or string naming a Lisp face.
3644 3649
@@ -3653,22 +3658,26 @@ merge_face_inheritance (f, inherit, to, cycle_check)
3653 Face specifications earlier in lists take precedence over later 3658 Face specifications earlier in lists take precedence over later
3654 specifications. */ 3659 specifications. */
3655 3660
3656static void 3661static int
3657merge_face_vector_with_property (f, to, prop) 3662merge_face_ref (f, face_ref, to, err_msgs, named_merge_points)
3658 struct frame *f; 3663 struct frame *f;
3664 Lisp_Object face_ref;
3659 Lisp_Object *to; 3665 Lisp_Object *to;
3660 Lisp_Object prop; 3666 int err_msgs;
3667 struct named_merge_point *named_merge_points;
3661{ 3668{
3662 if (CONSP (prop)) 3669 int ok = 1; /* Succeed without an error? */
3670
3671 if (CONSP (face_ref))
3663 { 3672 {
3664 Lisp_Object first = XCAR (prop); 3673 Lisp_Object first = XCAR (face_ref);
3665 3674
3666 if (EQ (first, Qforeground_color) 3675 if (EQ (first, Qforeground_color)
3667 || EQ (first, Qbackground_color)) 3676 || EQ (first, Qbackground_color))
3668 { 3677 {
3669 /* One of (FOREGROUND-COLOR . COLOR) or (BACKGROUND-COLOR 3678 /* One of (FOREGROUND-COLOR . COLOR) or (BACKGROUND-COLOR
3670 . COLOR). COLOR must be a string. */ 3679 . COLOR). COLOR must be a string. */
3671 Lisp_Object color_name = XCDR (prop); 3680 Lisp_Object color_name = XCDR (face_ref);
3672 Lisp_Object color = first; 3681 Lisp_Object color = first;
3673 3682
3674 if (STRINGP (color_name)) 3683 if (STRINGP (color_name))
@@ -3679,23 +3688,28 @@ merge_face_vector_with_property (f, to, prop)
3679 to[LFACE_BACKGROUND_INDEX] = color_name; 3688 to[LFACE_BACKGROUND_INDEX] = color_name;
3680 } 3689 }
3681 else 3690 else
3682 add_to_log ("Invalid face color", color_name, Qnil); 3691 {
3692 if (err_msgs)
3693 add_to_log ("Invalid face color", color_name, Qnil);
3694 ok = 0;
3695 }
3683 } 3696 }
3684 else if (SYMBOLP (first) 3697 else if (SYMBOLP (first)
3685 && *SDATA (SYMBOL_NAME (first)) == ':') 3698 && *SDATA (SYMBOL_NAME (first)) == ':')
3686 { 3699 {
3687 /* Assume this is the property list form. */ 3700 /* Assume this is the property list form. */
3688 while (CONSP (prop) && CONSP (XCDR (prop))) 3701 while (CONSP (face_ref) && CONSP (XCDR (face_ref)))
3689 { 3702 {
3690 Lisp_Object keyword = XCAR (prop); 3703 Lisp_Object keyword = XCAR (face_ref);
3691 Lisp_Object value = XCAR (XCDR (prop)); 3704 Lisp_Object value = XCAR (XCDR (face_ref));
3705 int err = 0;
3692 3706
3693 if (EQ (keyword, QCfamily)) 3707 if (EQ (keyword, QCfamily))
3694 { 3708 {
3695 if (STRINGP (value)) 3709 if (STRINGP (value))
3696 to[LFACE_FAMILY_INDEX] = value; 3710 to[LFACE_FAMILY_INDEX] = value;
3697 else 3711 else
3698 add_to_log ("Invalid face font family", value, Qnil); 3712 err = 1;
3699 } 3713 }
3700 else if (EQ (keyword, QCheight)) 3714 else if (EQ (keyword, QCheight))
3701 { 3715 {
@@ -3703,10 +3717,10 @@ merge_face_vector_with_property (f, to, prop)
3703 merge_face_heights (value, to[LFACE_HEIGHT_INDEX], 3717 merge_face_heights (value, to[LFACE_HEIGHT_INDEX],
3704 Qnil, Qnil); 3718 Qnil, Qnil);
3705 3719
3706 if (NILP (new_height)) 3720 if (! NILP (new_height))
3707 add_to_log ("Invalid face font height", value, Qnil);
3708 else
3709 to[LFACE_HEIGHT_INDEX] = new_height; 3721 to[LFACE_HEIGHT_INDEX] = new_height;
3722 else
3723 err = 1;
3710 } 3724 }
3711 else if (EQ (keyword, QCweight)) 3725 else if (EQ (keyword, QCweight))
3712 { 3726 {
@@ -3714,7 +3728,7 @@ merge_face_vector_with_property (f, to, prop)
3714 && face_numeric_weight (value) >= 0) 3728 && face_numeric_weight (value) >= 0)
3715 to[LFACE_WEIGHT_INDEX] = value; 3729 to[LFACE_WEIGHT_INDEX] = value;
3716 else 3730 else
3717 add_to_log ("Invalid face weight", value, Qnil); 3731 err = 1;
3718 } 3732 }
3719 else if (EQ (keyword, QCslant)) 3733 else if (EQ (keyword, QCslant))
3720 { 3734 {
@@ -3722,7 +3736,7 @@ merge_face_vector_with_property (f, to, prop)
3722 && face_numeric_slant (value) >= 0) 3736 && face_numeric_slant (value) >= 0)
3723 to[LFACE_SLANT_INDEX] = value; 3737 to[LFACE_SLANT_INDEX] = value;
3724 else 3738 else
3725 add_to_log ("Invalid face slant", value, Qnil); 3739 err = 1;
3726 } 3740 }
3727 else if (EQ (keyword, QCunderline)) 3741 else if (EQ (keyword, QCunderline))
3728 { 3742 {
@@ -3731,7 +3745,7 @@ merge_face_vector_with_property (f, to, prop)
3731 || STRINGP (value)) 3745 || STRINGP (value))
3732 to[LFACE_UNDERLINE_INDEX] = value; 3746 to[LFACE_UNDERLINE_INDEX] = value;
3733 else 3747 else
3734 add_to_log ("Invalid face underline", value, Qnil); 3748 err = 1;
3735 } 3749 }
3736 else if (EQ (keyword, QCoverline)) 3750 else if (EQ (keyword, QCoverline))
3737 { 3751 {
@@ -3740,7 +3754,7 @@ merge_face_vector_with_property (f, to, prop)
3740 || STRINGP (value)) 3754 || STRINGP (value))
3741 to[LFACE_OVERLINE_INDEX] = value; 3755 to[LFACE_OVERLINE_INDEX] = value;
3742 else 3756 else
3743 add_to_log ("Invalid face overline", value, Qnil); 3757 err = 1;
3744 } 3758 }
3745 else if (EQ (keyword, QCstrike_through)) 3759 else if (EQ (keyword, QCstrike_through))
3746 { 3760 {
@@ -3749,7 +3763,7 @@ merge_face_vector_with_property (f, to, prop)
3749 || STRINGP (value)) 3763 || STRINGP (value))
3750 to[LFACE_STRIKE_THROUGH_INDEX] = value; 3764 to[LFACE_STRIKE_THROUGH_INDEX] = value;
3751 else 3765 else
3752 add_to_log ("Invalid face strike-through", value, Qnil); 3766 err = 1;
3753 } 3767 }
3754 else if (EQ (keyword, QCbox)) 3768 else if (EQ (keyword, QCbox))
3755 { 3769 {
@@ -3761,7 +3775,7 @@ merge_face_vector_with_property (f, to, prop)
3761 || NILP (value)) 3775 || NILP (value))
3762 to[LFACE_BOX_INDEX] = value; 3776 to[LFACE_BOX_INDEX] = value;
3763 else 3777 else
3764 add_to_log ("Invalid face box", value, Qnil); 3778 err = 1;
3765 } 3779 }
3766 else if (EQ (keyword, QCinverse_video) 3780 else if (EQ (keyword, QCinverse_video)
3767 || EQ (keyword, QCreverse_video)) 3781 || EQ (keyword, QCreverse_video))
@@ -3769,21 +3783,21 @@ merge_face_vector_with_property (f, to, prop)
3769 if (EQ (value, Qt) || NILP (value)) 3783 if (EQ (value, Qt) || NILP (value))
3770 to[LFACE_INVERSE_INDEX] = value; 3784 to[LFACE_INVERSE_INDEX] = value;
3771 else 3785 else
3772 add_to_log ("Invalid face inverse-video", value, Qnil); 3786 err = 1;
3773 } 3787 }
3774 else if (EQ (keyword, QCforeground)) 3788 else if (EQ (keyword, QCforeground))
3775 { 3789 {
3776 if (STRINGP (value)) 3790 if (STRINGP (value))
3777 to[LFACE_FOREGROUND_INDEX] = value; 3791 to[LFACE_FOREGROUND_INDEX] = value;
3778 else 3792 else
3779 add_to_log ("Invalid face foreground", value, Qnil); 3793 err = 1;
3780 } 3794 }
3781 else if (EQ (keyword, QCbackground)) 3795 else if (EQ (keyword, QCbackground))
3782 { 3796 {
3783 if (STRINGP (value)) 3797 if (STRINGP (value))
3784 to[LFACE_BACKGROUND_INDEX] = value; 3798 to[LFACE_BACKGROUND_INDEX] = value;
3785 else 3799 else
3786 add_to_log ("Invalid face background", value, Qnil); 3800 err = 1;
3787 } 3801 }
3788 else if (EQ (keyword, QCstipple)) 3802 else if (EQ (keyword, QCstipple))
3789 { 3803 {
@@ -3792,7 +3806,7 @@ merge_face_vector_with_property (f, to, prop)
3792 if (!NILP (pixmap_p)) 3806 if (!NILP (pixmap_p))
3793 to[LFACE_STIPPLE_INDEX] = value; 3807 to[LFACE_STIPPLE_INDEX] = value;
3794 else 3808 else
3795 add_to_log ("Invalid face stipple", value, Qnil); 3809 err = 1;
3796#endif 3810#endif
3797 } 3811 }
3798 else if (EQ (keyword, QCwidth)) 3812 else if (EQ (keyword, QCwidth))
@@ -3801,52 +3815,51 @@ merge_face_vector_with_property (f, to, prop)
3801 && face_numeric_swidth (value) >= 0) 3815 && face_numeric_swidth (value) >= 0)
3802 to[LFACE_SWIDTH_INDEX] = value; 3816 to[LFACE_SWIDTH_INDEX] = value;
3803 else 3817 else
3804 add_to_log ("Invalid face width", value, Qnil); 3818 err = 1;
3805 } 3819 }
3806 else if (EQ (keyword, QCinherit)) 3820 else if (EQ (keyword, QCinherit))
3807 { 3821 {
3808 if (SYMBOLP (value)) 3822 /* This is not really very useful; it's just like a
3809 to[LFACE_INHERIT_INDEX] = value; 3823 normal face reference. */
3810 else 3824 if (! merge_face_ref (f, value, to,
3811 { 3825 err_msgs, named_merge_points))
3812 Lisp_Object tail; 3826 err = 1;
3813 for (tail = value; CONSP (tail); tail = XCDR (tail))
3814 if (!SYMBOLP (XCAR (tail)))
3815 break;
3816 if (NILP (tail))
3817 to[LFACE_INHERIT_INDEX] = value;
3818 else
3819 add_to_log ("Invalid face inherit", value, Qnil);
3820 }
3821 } 3827 }
3822 else 3828 else
3823 add_to_log ("Invalid attribute %s in face property", 3829 err = 1;
3824 keyword, Qnil);
3825 3830
3826 prop = XCDR (XCDR (prop)); 3831 if (err)
3832 {
3833 add_to_log ("Invalid face attribute %S %S", keyword, value);
3834 ok = 0;
3835 }
3836
3837 face_ref = XCDR (XCDR (face_ref));
3827 } 3838 }
3828 } 3839 }
3829 else 3840 else
3830 { 3841 {
3831 /* This is a list of face specs. Specifications at the 3842 /* This is a list of face refs. Those at the beginning of the
3832 beginning of the list take precedence over later 3843 list take precedence over what follows, so we have to merge
3833 specifications, so we have to merge starting with the 3844 from the end backwards. */
3834 last specification. */ 3845 Lisp_Object next = XCDR (face_ref);
3835 Lisp_Object next = XCDR (prop); 3846
3836 if (!NILP (next)) 3847 if (! NILP (next))
3837 merge_face_vector_with_property (f, to, next); 3848 ok = merge_face_ref (f, next, to, err_msgs, named_merge_points);
3838 merge_face_vector_with_property (f, to, first); 3849
3850 if (! merge_face_ref (f, first, to, err_msgs, named_merge_points))
3851 ok = 0;
3839 } 3852 }
3840 } 3853 }
3841 else 3854 else
3842 { 3855 {
3843 /* PROP ought to be a face name. */ 3856 /* FACE_REF ought to be a face name. */
3844 Lisp_Object lface = lface_from_face_name (f, prop, 0); 3857 ok = merge_named_face (f, face_ref, to, named_merge_points);
3845 if (NILP (lface)) 3858 if (!ok && err_msgs)
3846 add_to_log ("Invalid face text property value: %s", prop, Qnil); 3859 add_to_log ("Invalid face reference: %s", face_ref, Qnil);
3847 else
3848 merge_face_vectors (f, XVECTOR (lface)->contents, to, Qnil);
3849 } 3860 }
3861
3862 return ok;
3850} 3863}
3851 3864
3852 3865
@@ -3962,12 +3975,13 @@ Otherwise check for the existence of a global face. */)
3962DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, 3975DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face,
3963 Sinternal_copy_lisp_face, 4, 4, 0, 3976 Sinternal_copy_lisp_face, 4, 4, 0,
3964 doc: /* Copy face FROM to TO. 3977 doc: /* Copy face FROM to TO.
3965If FRAME it t, copy the global face definition of FROM to the 3978If FRAME is t, copy the global face definition of FROM.
3966global face definition of TO. Otherwise, copy the frame-local 3979Otherwise, copy the frame-local definition of FROM on FRAME.
3967definition of FROM on FRAME to the frame-local definition of TO 3980If NEW-FRAME is a frame, copy that data into the frame-local
3968on NEW-FRAME, or FRAME if NEW-FRAME is nil. 3981definition of TO on NEW-FRAME. If NEW-FRAME is nil.
3982FRAME controls where the data is copied to.
3969 3983
3970Value is TO. */) 3984The value is TO. */)
3971 (from, to, frame, new_frame) 3985 (from, to, frame, new_frame)
3972 Lisp_Object from, to, frame, new_frame; 3986 Lisp_Object from, to, frame, new_frame;
3973{ 3987{
@@ -3975,8 +3989,6 @@ Value is TO. */)
3975 3989
3976 CHECK_SYMBOL (from); 3990 CHECK_SYMBOL (from);
3977 CHECK_SYMBOL (to); 3991 CHECK_SYMBOL (to);
3978 if (NILP (new_frame))
3979 new_frame = frame;
3980 3992
3981 if (EQ (frame, Qt)) 3993 if (EQ (frame, Qt))
3982 { 3994 {
@@ -3988,6 +4000,8 @@ Value is TO. */)
3988 else 4000 else
3989 { 4001 {
3990 /* Copy frame-local definition of FROM. */ 4002 /* Copy frame-local definition of FROM. */
4003 if (NILP (new_frame))
4004 new_frame = frame;
3991 CHECK_LIVE_FRAME (frame); 4005 CHECK_LIVE_FRAME (frame);
3992 CHECK_LIVE_FRAME (new_frame); 4006 CHECK_LIVE_FRAME (new_frame);
3993 lface = lface_from_face_name (XFRAME (frame), from, 1); 4007 lface = lface_from_face_name (XFRAME (frame), from, 1);
@@ -4797,8 +4811,8 @@ DEFUN ("internal-get-lisp-face-attribute", Finternal_get_lisp_face_attribute,
4797 doc: /* Return face attribute KEYWORD of face SYMBOL. 4811 doc: /* Return face attribute KEYWORD of face SYMBOL.
4798If SYMBOL does not name a valid Lisp face or KEYWORD isn't a valid 4812If SYMBOL does not name a valid Lisp face or KEYWORD isn't a valid
4799face attribute name, signal an error. 4813face attribute name, signal an error.
4800If the optional argument FRAME is given, report on face FACE in that 4814If the optional argument FRAME is given, report on face SYMBOL in that
4801frame. If FRAME is t, report on the defaults for face FACE (for new 4815frame. If FRAME is t, report on the defaults for face SYMBOL (for new
4802frames). If FRAME is omitted or nil, use the selected frame. */) 4816frames). If FRAME is omitted or nil, use the selected frame. */)
4803 (symbol, keyword, frame) 4817 (symbol, keyword, frame)
4804 Lisp_Object symbol, keyword, frame; 4818 Lisp_Object symbol, keyword, frame;
@@ -4995,49 +5009,52 @@ return the font name used for CHARACTER. */)
4995} 5009}
4996 5010
4997 5011
4998/* Compare face vectors V1 and V2 for equality. Value is non-zero if 5012/* Compare face-attribute values v1 and v2 for equality. Value is non-zero if
4999 all attributes are `equal'. Tries to be fast because this function 5013 all attributes are `equal'. Tries to be fast because this function
5000 is called quite often. */ 5014 is called quite often. */
5001 5015
5002static INLINE int 5016static INLINE int
5003lface_equal_p (v1, v2) 5017face_attr_equal_p (v1, v2)
5004 Lisp_Object *v1, *v2; 5018 Lisp_Object v1, v2;
5005{ 5019{
5006 int i, equal_p = 1; 5020 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil,
5021 and the other is specified. */
5022 if (XTYPE (v1) != XTYPE (v2))
5023 return 0;
5007 5024
5008 for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i) 5025 if (EQ (v1, v2))
5009 { 5026 return 1;
5010 Lisp_Object a = v1[i];
5011 Lisp_Object b = v2[i];
5012 5027
5013 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil, 5028 switch (XTYPE (v1))
5014 and the other is specified. */ 5029 {
5015 equal_p = XTYPE (a) == XTYPE (b); 5030 case Lisp_String:
5016 if (!equal_p) 5031 if (SBYTES (v1) != SBYTES (v2))
5017 break; 5032 return 0;
5018 5033
5019 if (!EQ (a, b)) 5034 return bcmp (SDATA (v1), SDATA (v2), SBYTES (v1)) == 0;
5020 {
5021 switch (XTYPE (a))
5022 {
5023 case Lisp_String:
5024 equal_p = ((SBYTES (a)
5025 == SBYTES (b))
5026 && bcmp (SDATA (a), SDATA (b),
5027 SBYTES (a)) == 0);
5028 break;
5029 5035
5030 case Lisp_Int: 5036 case Lisp_Int:
5031 case Lisp_Symbol: 5037 case Lisp_Symbol:
5032 equal_p = 0; 5038 return 0;
5033 break;
5034 5039
5035 default: 5040 default:
5036 equal_p = !NILP (Fequal (a, b)); 5041 return !NILP (Fequal (v1, v2));
5037 break;
5038 }
5039 }
5040 } 5042 }
5043}
5044
5045
5046/* Compare face vectors V1 and V2 for equality. Value is non-zero if
5047 all attributes are `equal'. Tries to be fast because this function
5048 is called quite often. */
5049
5050static INLINE int
5051lface_equal_p (v1, v2)
5052 Lisp_Object *v1, *v2;
5053{
5054 int i, equal_p = 1;
5055
5056 for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i)
5057 equal_p = face_attr_equal_p (v1[i], v2[i]);
5041 5058
5042 return equal_p; 5059 return equal_p;
5043} 5060}
@@ -5333,192 +5350,6 @@ If FRAME is unspecified or nil, the current frame is used. */)
5333 5350
5334 5351
5335/*********************************************************************** 5352/***********************************************************************
5336 Face capability testing for ttys
5337 ***********************************************************************/
5338
5339
5340/* If the distance (as returned by color_distance) between two colors is
5341 less than this, then they are considered the same, for determining
5342 whether a color is supported or not. The range of values is 0-65535. */
5343
5344#define TTY_SAME_COLOR_THRESHOLD 10000
5345
5346
5347DEFUN ("tty-supports-face-attributes-p",
5348 Ftty_supports_face_attributes_p, Stty_supports_face_attributes_p,
5349 1, 2, 0,
5350 doc: /* Return non-nil if all the face attributes in ATTRIBUTES are supported.
5351The optional argument FRAME is the frame on which to test; if it is nil
5352or unspecified, then the current frame is used. If FRAME is not a tty
5353frame, then nil is returned.
5354
5355The definition of `supported' is somewhat heuristic, but basically means
5356that a face containing all the attributes in ATTRIBUTES, when merged
5357with the default face for display, can be represented in a way that's
5358
5359 \(1) different in appearance than the default face, and
5360 \(2) `close in spirit' to what the attributes specify, if not exact.
5361
5362Point (2) implies that a `:weight black' attribute will be satisified
5363by any terminal that can display bold, and a `:foreground "yellow"' as
5364long as the terminal can display a yellowish color, but `:slant italic'
5365will _not_ be satisified by the tty display code's automatic
5366substitution of a `dim' face for italic. */)
5367 (attributes, frame)
5368 Lisp_Object attributes, frame;
5369{
5370 int weight, i;
5371 struct frame *f;
5372 Lisp_Object val, fg, bg;
5373 XColor fg_tty_color, fg_std_color;
5374 XColor bg_tty_color, bg_std_color;
5375 Lisp_Object attrs[LFACE_VECTOR_SIZE];
5376 unsigned test_caps = 0;
5377
5378 if (NILP (frame))
5379 frame = selected_frame;
5380 CHECK_LIVE_FRAME (frame);
5381 f = XFRAME (frame);
5382
5383 for (i = 0; i < LFACE_VECTOR_SIZE; i++)
5384 attrs[i] = Qunspecified;
5385 merge_face_vector_with_property (f, attrs, attributes);
5386
5387 /* This function only works on ttys. */
5388 if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
5389 return Qnil;
5390
5391 /* First check some easy-to-check stuff; ttys support none of the
5392 following attributes, so we can just return nil if any are requested. */
5393
5394 /* stipple */
5395 val = attrs[LFACE_STIPPLE_INDEX];
5396 if (!UNSPECIFIEDP (val) && !NILP (val))
5397 return Qnil;
5398
5399 /* font height */
5400 val = attrs[LFACE_HEIGHT_INDEX];
5401 if (!UNSPECIFIEDP (val) && !NILP (val))
5402 return Qnil;
5403
5404 /* font width */
5405 val = attrs[LFACE_SWIDTH_INDEX];
5406 if (!UNSPECIFIEDP (val) && !NILP (val)
5407 && face_numeric_swidth (val) != XLFD_SWIDTH_MEDIUM)
5408 return Qnil;
5409
5410 /* overline */
5411 val = attrs[LFACE_OVERLINE_INDEX];
5412 if (!UNSPECIFIEDP (val) && !NILP (val))
5413 return Qnil;
5414
5415 /* strike-through */
5416 val = attrs[LFACE_STRIKE_THROUGH_INDEX];
5417 if (!UNSPECIFIEDP (val) && !NILP (val))
5418 return Qnil;
5419
5420 /* boxes */
5421 val = attrs[LFACE_BOX_INDEX];
5422 if (!UNSPECIFIEDP (val) && !NILP (val))
5423 return Qnil;
5424
5425 /* slant (italics/oblique); We consider any non-default value
5426 unsupportable on ttys, even though the face code actually `fakes'
5427 them using a dim attribute if possible. This is because the faked
5428 result is too different from what the face specifies. */
5429 val = attrs[LFACE_SLANT_INDEX];
5430 if (!UNSPECIFIEDP (val) && !NILP (val)
5431 && face_numeric_slant (val) != XLFD_SLANT_ROMAN)
5432 return Qnil;
5433
5434
5435 /* Test for terminal `capabilities' (non-color character attributes). */
5436
5437 /* font weight (bold/dim) */
5438 weight = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]);
5439 if (weight >= 0)
5440 {
5441 if (weight > XLFD_WEIGHT_MEDIUM)
5442 test_caps = TTY_CAP_BOLD;
5443 else if (weight < XLFD_WEIGHT_MEDIUM)
5444 test_caps = TTY_CAP_DIM;
5445 }
5446
5447 /* underlining */
5448 val = attrs[LFACE_UNDERLINE_INDEX];
5449 if (!UNSPECIFIEDP (val) && !NILP (val))
5450 {
5451 if (STRINGP (val))
5452 return Qnil; /* ttys don't support colored underlines */
5453 else
5454 test_caps |= TTY_CAP_UNDERLINE;
5455 }
5456
5457 /* inverse video */
5458 val = attrs[LFACE_INVERSE_INDEX];
5459 if (!UNSPECIFIEDP (val) && !NILP (val))
5460 test_caps |= TTY_CAP_INVERSE;
5461
5462
5463 /* Color testing. */
5464
5465 /* Default the color indices in FG_TTY_COLOR and BG_TTY_COLOR, since
5466 we use them when calling `tty_capable_p' below, even if the face
5467 specifies no colors. */
5468 fg_tty_color.pixel = FACE_TTY_DEFAULT_FG_COLOR;
5469 bg_tty_color.pixel = FACE_TTY_DEFAULT_BG_COLOR;
5470
5471 /* Check if foreground color is close enough. */
5472 fg = attrs[LFACE_FOREGROUND_INDEX];
5473 if (STRINGP (fg))
5474 {
5475 if (! tty_lookup_color (f, fg, &fg_tty_color, &fg_std_color))
5476 return Qnil;
5477 else if (color_distance (&fg_tty_color, &fg_std_color)
5478 > TTY_SAME_COLOR_THRESHOLD)
5479 return Qnil;
5480 }
5481
5482 /* Check if background color is close enough. */
5483 bg = attrs[LFACE_BACKGROUND_INDEX];
5484 if (STRINGP (bg))
5485 {
5486 if (! tty_lookup_color (f, bg, &bg_tty_color, &bg_std_color))
5487 return Qnil;
5488 else if (color_distance (&bg_tty_color, &bg_std_color)
5489 > TTY_SAME_COLOR_THRESHOLD)
5490 return Qnil;
5491 }
5492
5493 /* If both foreground and background are requested, see if the
5494 distance between them is OK. We just check to see if the distance
5495 between the tty's foreground and background is close enough to the
5496 distance between the standard foreground and background. */
5497 if (STRINGP (fg) && STRINGP (bg))
5498 {
5499 int delta_delta
5500 = (color_distance (&fg_std_color, &bg_std_color)
5501 - color_distance (&fg_tty_color, &bg_tty_color));
5502 if (delta_delta > TTY_SAME_COLOR_THRESHOLD
5503 || delta_delta < -TTY_SAME_COLOR_THRESHOLD)
5504 return Qnil;
5505 }
5506
5507
5508 /* See if the capabilities we selected above are supported, with the
5509 given colors. */
5510 if (test_caps != 0 &&
5511 ! tty_capable_p (f, test_caps, fg_tty_color.pixel, bg_tty_color.pixel))
5512 return Qnil;
5513
5514
5515 /* Hmmm, everything checks out, this terminal must support this face. */
5516 return Qt;
5517}
5518
5519
5520
5521/***********************************************************************
5522 Face Cache 5353 Face Cache
5523 ***********************************************************************/ 5354 ***********************************************************************/
5524 5355
@@ -5570,8 +5401,8 @@ clear_face_gcs (c)
5570} 5401}
5571 5402
5572 5403
5573/* Free all realized faces in face cache C, including basic faces. C 5404/* Free all realized faces in face cache C, including basic faces.
5574 may be null. If faces are freed, make sure the frame's current 5405 C may be null. If faces are freed, make sure the frame's current
5575 matrix is marked invalid, so that a display caused by an expose 5406 matrix is marked invalid, so that a display caused by an expose
5576 event doesn't try to use faces we destroyed. */ 5407 event doesn't try to use faces we destroyed. */
5577 5408
@@ -5911,7 +5742,8 @@ lookup_named_face (f, symbol)
5911 5742
5912 get_lface_attributes (f, symbol, symbol_attrs, 1); 5743 get_lface_attributes (f, symbol, symbol_attrs, 1);
5913 bcopy (default_face->lface, attrs, sizeof attrs); 5744 bcopy (default_face->lface, attrs, sizeof attrs);
5914 merge_face_vectors (f, symbol_attrs, attrs, Qnil); 5745 merge_face_vectors (f, symbol_attrs, attrs, 0);
5746
5915 return lookup_face (f, attrs); 5747 return lookup_face (f, attrs);
5916} 5748}
5917 5749
@@ -6049,7 +5881,7 @@ lookup_derived_face (f, symbol, face_id)
6049 5881
6050 get_lface_attributes (f, symbol, symbol_attrs, 1); 5882 get_lface_attributes (f, symbol, symbol_attrs, 1);
6051 bcopy (default_face->lface, attrs, sizeof attrs); 5883 bcopy (default_face->lface, attrs, sizeof attrs);
6052 merge_face_vectors (f, symbol_attrs, attrs, Qnil); 5884 merge_face_vectors (f, symbol_attrs, attrs, 0);
6053 return lookup_face (f, attrs); 5885 return lookup_face (f, attrs);
6054} 5886}
6055 5887
@@ -6062,15 +5894,367 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
6062 Lisp_Object lface; 5894 Lisp_Object lface;
6063 lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), 5895 lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE),
6064 Qunspecified); 5896 Qunspecified);
6065 merge_face_vector_with_property (XFRAME (selected_frame), 5897 merge_face_ref (XFRAME (selected_frame), plist, XVECTOR (lface)->contents,
6066 XVECTOR (lface)->contents, 5898 1, 0);
6067 plist);
6068 return lface; 5899 return lface;
6069} 5900}
6070 5901
6071 5902
6072 5903
6073/*********************************************************************** 5904/***********************************************************************
5905 Face capability testing
5906 ***********************************************************************/
5907
5908
5909/* If the distance (as returned by color_distance) between two colors is
5910 less than this, then they are considered the same, for determining
5911 whether a color is supported or not. The range of values is 0-65535. */
5912
5913#define TTY_SAME_COLOR_THRESHOLD 10000
5914
5915#ifdef HAVE_WINDOW_SYSTEM
5916
5917/* Return non-zero if all the face attributes in ATTRS are supported
5918 on the window-system frame F.
5919
5920 The definition of `supported' is somewhat heuristic, but basically means
5921 that a face containing all the attributes in ATTRS, when merged with the
5922 default face for display, can be represented in a way that's
5923
5924 \(1) different in appearance than the default face, and
5925 \(2) `close in spirit' to what the attributes specify, if not exact. */
5926
5927static int
5928x_supports_face_attributes_p (f, attrs, def_face)
5929 struct frame *f;
5930 Lisp_Object *attrs;
5931 struct face *def_face;
5932{
5933 Lisp_Object *def_attrs = def_face->lface;
5934
5935 /* Check that other specified attributes are different that the default
5936 face. */
5937 if ((!UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX])
5938 && face_attr_equal_p (attrs[LFACE_UNDERLINE_INDEX],
5939 def_attrs[LFACE_UNDERLINE_INDEX]))
5940 || (!UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX])
5941 && face_attr_equal_p (attrs[LFACE_INVERSE_INDEX],
5942 def_attrs[LFACE_INVERSE_INDEX]))
5943 || (!UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
5944 && face_attr_equal_p (attrs[LFACE_FOREGROUND_INDEX],
5945 def_attrs[LFACE_FOREGROUND_INDEX]))
5946 || (!UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
5947 && face_attr_equal_p (attrs[LFACE_BACKGROUND_INDEX],
5948 def_attrs[LFACE_BACKGROUND_INDEX]))
5949 || (!UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
5950 && face_attr_equal_p (attrs[LFACE_STIPPLE_INDEX],
5951 def_attrs[LFACE_STIPPLE_INDEX]))
5952 || (!UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
5953 && face_attr_equal_p (attrs[LFACE_OVERLINE_INDEX],
5954 def_attrs[LFACE_OVERLINE_INDEX]))
5955 || (!UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
5956 && face_attr_equal_p (attrs[LFACE_STRIKE_THROUGH_INDEX],
5957 def_attrs[LFACE_STRIKE_THROUGH_INDEX]))
5958 || (!UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
5959 && face_attr_equal_p (attrs[LFACE_BOX_INDEX],
5960 def_attrs[LFACE_BOX_INDEX])))
5961 return 0;
5962
5963 /* Check font-related attributes, as those are the most commonly
5964 "unsupported" on a window-system (because of missing fonts). */
5965 if (!UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
5966 || !UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
5967 || !UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX])
5968 || !UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX])
5969 || !UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
5970 || !UNSPECIFIEDP (attrs[LFACE_AVGWIDTH_INDEX]))
5971 {
5972 int face_id;
5973 struct face *face;
5974 Lisp_Object merged_attrs[LFACE_VECTOR_SIZE];
5975
5976 bcopy (def_attrs, merged_attrs, sizeof merged_attrs);
5977
5978 merge_face_vectors (f, attrs, merged_attrs, 0);
5979
5980 face_id = lookup_face (f, merged_attrs);
5981 face = FACE_FROM_ID (f, face_id);
5982
5983 if (! face)
5984 signal_error ("cannot make face", 0);
5985
5986 /* If the font is the same, then not supported. */
5987 if (face->font == def_face->font)
5988 return 0;
5989 }
5990
5991 /* Everything checks out, this face is supported. */
5992 return 1;
5993}
5994
5995#endif /* HAVE_WINDOW_SYSTEM */
5996
5997/* Return non-zero if all the face attributes in ATTRS are supported
5998 on the tty frame F.
5999
6000 The definition of `supported' is somewhat heuristic, but basically means
6001 that a face containing all the attributes in ATTRS, when merged
6002 with the default face for display, can be represented in a way that's
6003
6004 \(1) different in appearance than the default face, and
6005 \(2) `close in spirit' to what the attributes specify, if not exact.
6006
6007 Point (2) implies that a `:weight black' attribute will be satisfied
6008 by any terminal that can display bold, and a `:foreground "yellow"' as
6009 long as the terminal can display a yellowish color, but `:slant italic'
6010 will _not_ be satisfied by the tty display code's automatic
6011 substitution of a `dim' face for italic. */
6012
6013static int
6014tty_supports_face_attributes_p (f, attrs, def_face)
6015 struct frame *f;
6016 Lisp_Object *attrs;
6017 struct face *def_face;
6018{
6019 int weight, i;
6020 Lisp_Object val, fg, bg;
6021 XColor fg_tty_color, fg_std_color;
6022 XColor bg_tty_color, bg_std_color;
6023 unsigned test_caps = 0;
6024 Lisp_Object *def_attrs = def_face->lface;
6025
6026
6027 /* First check some easy-to-check stuff; ttys support none of the
6028 following attributes, so we can just return false if any are requested
6029 (even if `nominal' values are specified, we should still return false,
6030 as that will be the same value that the default face uses). We
6031 consider :slant unsupportable on ttys, even though the face code
6032 actually `fakes' them using a dim attribute if possible. This is
6033 because the faked result is too different from what the face
6034 specifies. */
6035 if (!UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
6036 || !UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
6037 || !UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
6038 || !UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
6039 || !UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
6040 || !UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
6041 || !UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
6042 || !UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX]))
6043 return 0;
6044
6045
6046 /* Test for terminal `capabilities' (non-color character attributes). */
6047
6048 /* font weight (bold/dim) */
6049 weight = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]);
6050 if (weight >= 0)
6051 {
6052 int def_weight = face_numeric_weight (def_attrs[LFACE_WEIGHT_INDEX]);
6053
6054 if (weight > XLFD_WEIGHT_MEDIUM)
6055 {
6056 if (def_weight > XLFD_WEIGHT_MEDIUM)
6057 return 0; /* same as default */
6058 test_caps = TTY_CAP_BOLD;
6059 }
6060 else if (weight < XLFD_WEIGHT_MEDIUM)
6061 {
6062 if (def_weight < XLFD_WEIGHT_MEDIUM)
6063 return 0; /* same as default */
6064 test_caps = TTY_CAP_DIM;
6065 }
6066 else if (def_weight == XLFD_WEIGHT_MEDIUM)
6067 return 0; /* same as default */
6068 }
6069
6070 /* underlining */
6071 val = attrs[LFACE_UNDERLINE_INDEX];
6072 if (!UNSPECIFIEDP (val))
6073 {
6074 if (STRINGP (val))
6075 return 0; /* ttys can't use colored underlines */
6076 else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
6077 return 0; /* same as default */
6078 else
6079 test_caps |= TTY_CAP_UNDERLINE;
6080 }
6081
6082 /* inverse video */
6083 val = attrs[LFACE_INVERSE_INDEX];
6084 if (!UNSPECIFIEDP (val))
6085 {
6086 if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
6087 return 0; /* same as default */
6088 else
6089 test_caps |= TTY_CAP_INVERSE;
6090 }
6091
6092
6093 /* Color testing. */
6094
6095 /* Default the color indices in FG_TTY_COLOR and BG_TTY_COLOR, since
6096 we use them when calling `tty_capable_p' below, even if the face
6097 specifies no colors. */
6098 fg_tty_color.pixel = FACE_TTY_DEFAULT_FG_COLOR;
6099 bg_tty_color.pixel = FACE_TTY_DEFAULT_BG_COLOR;
6100
6101 /* Check if foreground color is close enough. */
6102 fg = attrs[LFACE_FOREGROUND_INDEX];
6103 if (STRINGP (fg))
6104 {
6105 Lisp_Object def_fg = def_attrs[LFACE_FOREGROUND_INDEX];
6106
6107 if (face_attr_equal_p (fg, def_fg))
6108 return 0; /* same as default */
6109 else if (! tty_lookup_color (f, fg, &fg_tty_color, &fg_std_color))
6110 return 0; /* not a valid color */
6111 else if (color_distance (&fg_tty_color, &fg_std_color)
6112 > TTY_SAME_COLOR_THRESHOLD)
6113 return 0; /* displayed color is too different */
6114 else
6115 /* Make sure the color is really different than the default. */
6116 {
6117 XColor def_fg_color;
6118 if (tty_lookup_color (f, def_fg, &def_fg_color, 0)
6119 && (color_distance (&fg_tty_color, &def_fg_color)
6120 <= TTY_SAME_COLOR_THRESHOLD))
6121 return 0;
6122 }
6123 }
6124
6125 /* Check if background color is close enough. */
6126 bg = attrs[LFACE_BACKGROUND_INDEX];
6127 if (STRINGP (bg))
6128 {
6129 Lisp_Object def_bg = def_attrs[LFACE_FOREGROUND_INDEX];
6130
6131 if (face_attr_equal_p (bg, def_bg))
6132 return 0; /* same as default */
6133 else if (! tty_lookup_color (f, bg, &bg_tty_color, &bg_std_color))
6134 return 0; /* not a valid color */
6135 else if (color_distance (&bg_tty_color, &bg_std_color)
6136 > TTY_SAME_COLOR_THRESHOLD)
6137 return 0; /* displayed color is too different */
6138 else
6139 /* Make sure the color is really different than the default. */
6140 {
6141 XColor def_bg_color;
6142 if (tty_lookup_color (f, def_bg, &def_bg_color, 0)
6143 && (color_distance (&bg_tty_color, &def_bg_color)
6144 <= TTY_SAME_COLOR_THRESHOLD))
6145 return 0;
6146 }
6147 }
6148
6149 /* If both foreground and background are requested, see if the
6150 distance between them is OK. We just check to see if the distance
6151 between the tty's foreground and background is close enough to the
6152 distance between the standard foreground and background. */
6153 if (STRINGP (fg) && STRINGP (bg))
6154 {
6155 int delta_delta
6156 = (color_distance (&fg_std_color, &bg_std_color)
6157 - color_distance (&fg_tty_color, &bg_tty_color));
6158 if (delta_delta > TTY_SAME_COLOR_THRESHOLD
6159 || delta_delta < -TTY_SAME_COLOR_THRESHOLD)
6160 return 0;
6161 }
6162
6163
6164 /* See if the capabilities we selected above are supported, with the
6165 given colors. */
6166 if (test_caps != 0 &&
6167 ! tty_capable_p (f, test_caps, fg_tty_color.pixel, bg_tty_color.pixel))
6168 return 0;
6169
6170
6171 /* Hmmm, everything checks out, this terminal must support this face. */
6172 return 1;
6173}
6174
6175
6176DEFUN ("display-supports-face-attributes-p",
6177 Fdisplay_supports_face_attributes_p, Sdisplay_supports_face_attributes_p,
6178 1, 2, 0,
6179 doc: /* Return non-nil if all the face attributes in ATTRIBUTES are supported.
6180The optional argument DISPLAY can be a display name, a frame, or
6181nil (meaning the selected frame's display)
6182
6183The definition of `supported' is somewhat heuristic, but basically means
6184that a face containing all the attributes in ATTRIBUTES, when merged
6185with the default face for display, can be represented in a way that's
6186
6187 \(1) different in appearance than the default face, and
6188 \(2) `close in spirit' to what the attributes specify, if not exact.
6189
6190Point (2) implies that a `:weight black' attribute will be satisfied by
6191any display that can display bold, and a `:foreground \"yellow\"' as long
6192as it can display a yellowish color, but `:slant italic' will _not_ be
6193satisfied by the tty display code's automatic substitution of a `dim'
6194face for italic. */)
6195 (attributes, display)
6196 Lisp_Object attributes, display;
6197{
6198 int supports, i;
6199 Lisp_Object frame;
6200 struct frame *f;
6201 struct face *def_face;
6202 Lisp_Object attrs[LFACE_VECTOR_SIZE];
6203
6204 if (noninteractive || !initialized)
6205 /* We may not be able to access low-level face information in batch
6206 mode, or before being dumped, and this function is not going to
6207 be very useful in those cases anyway, so just give up. */
6208 return Qnil;
6209
6210 if (NILP (display))
6211 frame = selected_frame;
6212 else if (FRAMEP (display))
6213 frame = display;
6214 else
6215 {
6216 /* Find any frame on DISPLAY. */
6217 Lisp_Object fl_tail;
6218
6219 frame = Qnil;
6220 for (fl_tail = Vframe_list; CONSP (fl_tail); fl_tail = XCDR (fl_tail))
6221 {
6222 frame = XCAR (fl_tail);
6223 if (!NILP (Fequal (Fcdr (Fassq (Qdisplay,
6224 XFRAME (frame)->param_alist)),
6225 display)))
6226 break;
6227 }
6228 }
6229
6230 CHECK_LIVE_FRAME (frame);
6231 f = XFRAME (frame);
6232
6233 for (i = 0; i < LFACE_VECTOR_SIZE; i++)
6234 attrs[i] = Qunspecified;
6235 merge_face_ref (f, attributes, attrs, 1, 0);
6236
6237 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6238 if (def_face == NULL)
6239 {
6240 if (! realize_basic_faces (f))
6241 signal_error ("Cannot realize default face", 0);
6242 def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6243 }
6244
6245 /* Dispatch to the appropriate handler. */
6246 if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
6247 supports = tty_supports_face_attributes_p (f, attrs, def_face);
6248#ifdef HAVE_WINDOW_SYSTEM
6249 else
6250 supports = x_supports_face_attributes_p (f, attrs, def_face);
6251#endif
6252
6253 return supports ? Qt : Qnil;
6254}
6255
6256
6257/***********************************************************************
6074 Font selection 6258 Font selection
6075 ***********************************************************************/ 6259 ***********************************************************************/
6076 6260
@@ -6968,7 +7152,7 @@ realize_named_face (f, symbol, id)
6968 7152
6969 /* Merge SYMBOL's face with the default face. */ 7153 /* Merge SYMBOL's face with the default face. */
6970 get_lface_attributes (f, symbol, symbol_attrs, 1); 7154 get_lface_attributes (f, symbol, symbol_attrs, 1);
6971 merge_face_vectors (f, symbol_attrs, attrs, Qnil); 7155 merge_face_vectors (f, symbol_attrs, attrs, 0);
6972 7156
6973 /* Realize the face. */ 7157 /* Realize the face. */
6974 new_face = realize_face (c, attrs, id); 7158 new_face = realize_face (c, attrs, id);
@@ -7441,15 +7625,10 @@ compute_char_face (f, ch, prop)
7441 else 7625 else
7442 { 7626 {
7443 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 7627 Lisp_Object attrs[LFACE_VECTOR_SIZE];
7444 struct face *face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 7628 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
7445 bcopy (face->lface, attrs, sizeof attrs); 7629 bcopy (default_face->lface, attrs, sizeof attrs);
7446 merge_face_vector_with_property (f, attrs, prop); 7630 merge_face_ref (f, prop, attrs, 1, 0);
7447 face_id = lookup_face (f, attrs); 7631 face_id = lookup_face (f, attrs);
7448 if (! ASCII_CHAR_P (ch))
7449 {
7450 face = FACE_FROM_ID (f, face_id);
7451 face_id = FACE_FOR_CHAR (f, face, ch, -1, Qnil);
7452 }
7453 } 7632 }
7454 7633
7455 return face_id; 7634 return face_id;
@@ -7513,24 +7692,8 @@ face_at_buffer_position (w, pos, region_beg, region_end,
7513 /* Look at properties from overlays. */ 7692 /* Look at properties from overlays. */
7514 { 7693 {
7515 int next_overlay; 7694 int next_overlay;
7516 int len;
7517
7518 /* First try with room for 40 overlays. */
7519 len = 40;
7520 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
7521 noverlays = overlays_at (pos, 0, &overlay_vec, &len,
7522 &next_overlay, NULL, 0);
7523
7524 /* If there are more than 40, make enough space for all, and try
7525 again. */
7526 if (noverlays > len)
7527 {
7528 len = noverlays;
7529 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
7530 noverlays = overlays_at (pos, 0, &overlay_vec, &len,
7531 &next_overlay, NULL, 0);
7532 }
7533 7695
7696 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, &next_overlay, 0);
7534 if (next_overlay < endpos) 7697 if (next_overlay < endpos)
7535 endpos = next_overlay; 7698 endpos = next_overlay;
7536 } 7699 }
@@ -7550,7 +7713,7 @@ face_at_buffer_position (w, pos, region_beg, region_end,
7550 7713
7551 /* Merge in attributes specified via text properties. */ 7714 /* Merge in attributes specified via text properties. */
7552 if (!NILP (prop)) 7715 if (!NILP (prop))
7553 merge_face_vector_with_property (f, attrs, prop); 7716 merge_face_ref (f, prop, attrs, 1, 0);
7554 7717
7555 /* Now merge the overlay data. */ 7718 /* Now merge the overlay data. */
7556 noverlays = sort_overlays (overlay_vec, noverlays, w); 7719 noverlays = sort_overlays (overlay_vec, noverlays, w);
@@ -7561,7 +7724,7 @@ face_at_buffer_position (w, pos, region_beg, region_end,
7561 7724
7562 prop = Foverlay_get (overlay_vec[i], propname); 7725 prop = Foverlay_get (overlay_vec[i], propname);
7563 if (!NILP (prop)) 7726 if (!NILP (prop))
7564 merge_face_vector_with_property (f, attrs, prop); 7727 merge_face_ref (f, prop, attrs, 1, 0);
7565 7728
7566 oend = OVERLAY_END (overlay_vec[i]); 7729 oend = OVERLAY_END (overlay_vec[i]);
7567 oendpos = OVERLAY_POSITION (oend); 7730 oendpos = OVERLAY_POSITION (oend);
@@ -7572,8 +7735,7 @@ face_at_buffer_position (w, pos, region_beg, region_end,
7572 /* If in the region, merge in the region face. */ 7735 /* If in the region, merge in the region face. */
7573 if (pos >= region_beg && pos < region_end) 7736 if (pos >= region_beg && pos < region_end)
7574 { 7737 {
7575 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); 7738 merge_named_face (f, Qregion, attrs, 0);
7576 merge_face_vectors (f, XVECTOR (region_face)->contents, attrs, Qnil);
7577 7739
7578 if (region_end < endpos) 7740 if (region_end < endpos)
7579 endpos = region_end; 7741 endpos = region_end;
@@ -7669,16 +7831,13 @@ face_at_string_position (w, string, pos, bufpos, region_beg,
7669 7831
7670 /* Merge in attributes specified via text properties. */ 7832 /* Merge in attributes specified via text properties. */
7671 if (!NILP (prop)) 7833 if (!NILP (prop))
7672 merge_face_vector_with_property (f, attrs, prop); 7834 merge_face_ref (f, prop, attrs, 1, 0);
7673 7835
7674 /* If in the region, merge in the region face. */ 7836 /* If in the region, merge in the region face. */
7675 if (bufpos 7837 if (bufpos
7676 && bufpos >= region_beg 7838 && bufpos >= region_beg
7677 && bufpos < region_end) 7839 && bufpos < region_end)
7678 { 7840 merge_named_face (f, Qregion, attrs, 0);
7679 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0);
7680 merge_face_vectors (f, XVECTOR (region_face)->contents, attrs, Qnil);
7681 }
7682 7841
7683 /* Look up a realized face with the given face attributes, 7842 /* Look up a realized face with the given face attributes,
7684 or realize a new one for ASCII characters. */ 7843 or realize a new one for ASCII characters. */
@@ -7946,7 +8105,7 @@ syms_of_xfaces ()
7946 defsubr (&Sinternal_merge_in_global_face); 8105 defsubr (&Sinternal_merge_in_global_face);
7947 defsubr (&Sface_font); 8106 defsubr (&Sface_font);
7948 defsubr (&Sframe_face_alist); 8107 defsubr (&Sframe_face_alist);
7949 defsubr (&Stty_supports_face_attributes_p); 8108 defsubr (&Sdisplay_supports_face_attributes_p);
7950 defsubr (&Scolor_distance); 8109 defsubr (&Scolor_distance);
7951 defsubr (&Sinternal_set_font_selection_order); 8110 defsubr (&Sinternal_set_font_selection_order);
7952 defsubr (&Sinternal_set_alternative_font_family_alist); 8111 defsubr (&Sinternal_set_alternative_font_family_alist);
diff --git a/src/xfns.c b/src/xfns.c
index 12df902ae49..cdbce00fe4c 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4425,6 +4425,8 @@ x_create_tip_frame (dpyinfo, parms, text)
4425 old_buffer = current_buffer; 4425 old_buffer = current_buffer;
4426 set_buffer_internal_1 (XBUFFER (buffer)); 4426 set_buffer_internal_1 (XBUFFER (buffer));
4427 current_buffer->truncate_lines = Qnil; 4427 current_buffer->truncate_lines = Qnil;
4428 specbind (Qinhibit_read_only, Qt);
4429 specbind (Qinhibit_modification_hooks, Qt);
4428 Ferase_buffer (); 4430 Ferase_buffer ();
4429 Finsert (1, &text); 4431 Finsert (1, &text);
4430 set_buffer_internal_1 (old_buffer); 4432 set_buffer_internal_1 (old_buffer);
@@ -5477,6 +5479,11 @@ Chinese, Japanese, and Korean. */);
5477#endif /* USE_X_TOOLKIT */ 5479#endif /* USE_X_TOOLKIT */
5478 5480
5479#ifdef USE_GTK 5481#ifdef USE_GTK
5482 /* Provide x-toolkit also for GTK. Internally GTK does not use Xt so it
5483 is not an X toolkit in that sense (USE_X_TOOLKIT is not defined).
5484 But for a user it is a toolkit for X, and indeed, configure
5485 accepts --with-x-toolkit=gtk. */
5486 Fprovide (intern ("x-toolkit"), Qnil);
5480 Fprovide (intern ("gtk"), Qnil); 5487 Fprovide (intern ("gtk"), Qnil);
5481 5488
5482 DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string, 5489 DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
diff --git a/src/xselect.c b/src/xselect.c
index b4d61f7c9a9..7be238651a0 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1,5 +1,5 @@
1/* X Selection processing for Emacs. 1/* X Selection processing for Emacs.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003 2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2004
3 Free Software Foundation. 3 Free Software Foundation.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -2576,7 +2576,7 @@ are ignored. */)
2576 if (event.xclient.format != 8 && event.xclient.format != 16 2576 if (event.xclient.format != 8 && event.xclient.format != 16
2577 && event.xclient.format != 32) 2577 && event.xclient.format != 32)
2578 error ("FORMAT must be one of 8, 16 or 32"); 2578 error ("FORMAT must be one of 8, 16 or 32");
2579 2579
2580 if (FRAMEP (dest) || NILP (dest)) 2580 if (FRAMEP (dest) || NILP (dest))
2581 { 2581 {
2582 struct frame *fdest = check_x_frame (dest); 2582 struct frame *fdest = check_x_frame (dest);
diff --git a/src/xsmfns.c b/src/xsmfns.c
index e486e5c6e32..9a6a7ccefb8 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -1,6 +1,6 @@
1/* Session management module for systems which understand the X Session 1/* Session management module for systems which understand the X Session
2 management protocol. 2 management protocol.
3 Copyright (C) 2002 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xterm.c b/src/xterm.c
index ae4d4063be9..3e606e2560a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1,5 +1,5 @@
1/* X Communication module for terminals which understand the X protocol. 1/* X Communication module for terminals which understand the X protocol.
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999, 2000, 01, 02, 2003 2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999, 2000,01,02,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -983,7 +983,8 @@ static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap));
983static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 983static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
984 int, int, int)); 984 int, int, int));
985static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, 985static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
986 int, int, int, int, XRectangle *)); 986 int, int, int, int, int, int,
987 XRectangle *));
987static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 988static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
988 int, int, int, XRectangle *)); 989 int, int, int, XRectangle *));
989 990
@@ -2025,9 +2026,10 @@ x_setup_relief_colors (s)
2025 2026
2026static void 2027static void
2027x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, 2028x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2028 raised_p, left_p, right_p, clip_rect) 2029 raised_p, top_p, bot_p, left_p, right_p, clip_rect)
2029 struct frame *f; 2030 struct frame *f;
2030 int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p; 2031 int left_x, top_y, right_x, bottom_y, width;
2032 int top_p, bot_p, left_p, right_p, raised_p;
2031 XRectangle *clip_rect; 2033 XRectangle *clip_rect;
2032{ 2034{
2033 Display *dpy = FRAME_X_DISPLAY (f); 2035 Display *dpy = FRAME_X_DISPLAY (f);
@@ -2042,10 +2044,11 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2042 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); 2044 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted);
2043 2045
2044 /* Top. */ 2046 /* Top. */
2045 for (i = 0; i < width; ++i) 2047 if (top_p)
2046 XDrawLine (dpy, window, gc, 2048 for (i = 0; i < width; ++i)
2047 left_x + i * left_p, top_y + i, 2049 XDrawLine (dpy, window, gc,
2048 right_x + 1 - i * right_p, top_y + i); 2050 left_x + i * left_p, top_y + i,
2051 right_x + 1 - i * right_p, top_y + i);
2049 2052
2050 /* Left. */ 2053 /* Left. */
2051 if (left_p) 2054 if (left_p)
@@ -2061,10 +2064,11 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2061 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); 2064 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted);
2062 2065
2063 /* Bottom. */ 2066 /* Bottom. */
2064 for (i = 0; i < width; ++i) 2067 if (bot_p)
2065 XDrawLine (dpy, window, gc, 2068 for (i = 0; i < width; ++i)
2066 left_x + i * left_p, bottom_y - i, 2069 XDrawLine (dpy, window, gc,
2067 right_x + 1 - i * right_p, bottom_y - i); 2070 left_x + i * left_p, bottom_y - i,
2071 right_x + 1 - i * right_p, bottom_y - i);
2068 2072
2069 /* Right. */ 2073 /* Right. */
2070 if (right_p) 2074 if (right_p)
@@ -2172,7 +2176,7 @@ x_draw_glyph_string_box (s)
2172 { 2176 {
2173 x_setup_relief_colors (s); 2177 x_setup_relief_colors (s);
2174 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, 2178 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
2175 width, raised_p, left_p, right_p, &clip_rect); 2179 width, raised_p, 1, 1, left_p, right_p, &clip_rect);
2176 } 2180 }
2177} 2181}
2178 2182
@@ -2183,21 +2187,22 @@ static void
2183x_draw_image_foreground (s) 2187x_draw_image_foreground (s)
2184 struct glyph_string *s; 2188 struct glyph_string *s;
2185{ 2189{
2186 int x; 2190 int x = s->x;
2187 int y = s->ybase - image_ascent (s->img, s->face); 2191 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2188 2192
2189 /* If first glyph of S has a left box line, start drawing it to the 2193 /* If first glyph of S has a left box line, start drawing it to the
2190 right of that line. */ 2194 right of that line. */
2191 if (s->face->box != FACE_NO_BOX 2195 if (s->face->box != FACE_NO_BOX
2192 && s->first_glyph->left_box_line_p) 2196 && s->first_glyph->left_box_line_p
2193 x = s->x + abs (s->face->box_line_width); 2197 && s->slice.x == 0)
2194 else 2198 x += abs (s->face->box_line_width);
2195 x = s->x;
2196 2199
2197 /* If there is a margin around the image, adjust x- and y-position 2200 /* If there is a margin around the image, adjust x- and y-position
2198 by that margin. */ 2201 by that margin. */
2199 x += s->img->hmargin; 2202 if (s->slice.x == 0)
2200 y += s->img->vmargin; 2203 x += s->img->hmargin;
2204 if (s->slice.y == 0)
2205 y += s->img->vmargin;
2201 2206
2202 if (s->img->pixmap) 2207 if (s->img->pixmap)
2203 { 2208 {
@@ -2222,11 +2227,12 @@ x_draw_image_foreground (s)
2222 get_glyph_string_clip_rect (s, &clip_rect); 2227 get_glyph_string_clip_rect (s, &clip_rect);
2223 image_rect.x = x; 2228 image_rect.x = x;
2224 image_rect.y = y; 2229 image_rect.y = y;
2225 image_rect.width = s->img->width; 2230 image_rect.width = s->slice.width;
2226 image_rect.height = s->img->height; 2231 image_rect.height = s->slice.height;
2227 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2232 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2228 XCopyArea (s->display, s->img->pixmap, s->window, s->gc, 2233 XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
2229 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 2234 s->slice.x + r.x - x, s->slice.y + r.y - y,
2235 r.width, r.height, r.x, r.y);
2230 } 2236 }
2231 else 2237 else
2232 { 2238 {
@@ -2235,11 +2241,12 @@ x_draw_image_foreground (s)
2235 get_glyph_string_clip_rect (s, &clip_rect); 2241 get_glyph_string_clip_rect (s, &clip_rect);
2236 image_rect.x = x; 2242 image_rect.x = x;
2237 image_rect.y = y; 2243 image_rect.y = y;
2238 image_rect.width = s->img->width; 2244 image_rect.width = s->slice.width;
2239 image_rect.height = s->img->height; 2245 image_rect.height = s->slice.height;
2240 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2246 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2241 XCopyArea (s->display, s->img->pixmap, s->window, s->gc, 2247 XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
2242 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 2248 s->slice.x + r.x - x, s->slice.y + r.y - y,
2249 r.width, r.height, r.x, r.y);
2243 2250
2244 /* When the image has a mask, we can expect that at 2251 /* When the image has a mask, we can expect that at
2245 least part of a mouse highlight or a block cursor will 2252 least part of a mouse highlight or a block cursor will
@@ -2251,15 +2258,17 @@ x_draw_image_foreground (s)
2251 { 2258 {
2252 int r = s->img->relief; 2259 int r = s->img->relief;
2253 if (r < 0) r = -r; 2260 if (r < 0) r = -r;
2254 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r, 2261 XDrawRectangle (s->display, s->window, s->gc,
2255 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2262 x - r, y - r,
2263 s->slice.width + r*2 - 1,
2264 s->slice.height + r*2 - 1);
2256 } 2265 }
2257 } 2266 }
2258 } 2267 }
2259 else 2268 else
2260 /* Draw a rectangle if image could not be loaded. */ 2269 /* Draw a rectangle if image could not be loaded. */
2261 XDrawRectangle (s->display, s->window, s->gc, x, y, 2270 XDrawRectangle (s->display, s->window, s->gc, x, y,
2262 s->img->width - 1, s->img->height - 1); 2271 s->slice.width - 1, s->slice.height - 1);
2263} 2272}
2264 2273
2265 2274
@@ -2271,21 +2280,22 @@ x_draw_image_relief (s)
2271{ 2280{
2272 int x0, y0, x1, y1, thick, raised_p; 2281 int x0, y0, x1, y1, thick, raised_p;
2273 XRectangle r; 2282 XRectangle r;
2274 int x; 2283 int x = s->x;
2275 int y = s->ybase - image_ascent (s->img, s->face); 2284 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2276 2285
2277 /* If first glyph of S has a left box line, start drawing it to the 2286 /* If first glyph of S has a left box line, start drawing it to the
2278 right of that line. */ 2287 right of that line. */
2279 if (s->face->box != FACE_NO_BOX 2288 if (s->face->box != FACE_NO_BOX
2280 && s->first_glyph->left_box_line_p) 2289 && s->first_glyph->left_box_line_p
2281 x = s->x + abs (s->face->box_line_width); 2290 && s->slice.x == 0)
2282 else 2291 x += abs (s->face->box_line_width);
2283 x = s->x;
2284 2292
2285 /* If there is a margin around the image, adjust x- and y-position 2293 /* If there is a margin around the image, adjust x- and y-position
2286 by that margin. */ 2294 by that margin. */
2287 x += s->img->hmargin; 2295 if (s->slice.x == 0)
2288 y += s->img->vmargin; 2296 x += s->img->hmargin;
2297 if (s->slice.y == 0)
2298 y += s->img->vmargin;
2289 2299
2290 if (s->hl == DRAW_IMAGE_SUNKEN 2300 if (s->hl == DRAW_IMAGE_SUNKEN
2291 || s->hl == DRAW_IMAGE_RAISED) 2301 || s->hl == DRAW_IMAGE_RAISED)
@@ -2301,12 +2311,17 @@ x_draw_image_relief (s)
2301 2311
2302 x0 = x - thick; 2312 x0 = x - thick;
2303 y0 = y - thick; 2313 y0 = y - thick;
2304 x1 = x + s->img->width + thick - 1; 2314 x1 = x + s->slice.width + thick - 1;
2305 y1 = y + s->img->height + thick - 1; 2315 y1 = y + s->slice.height + thick - 1;
2306 2316
2307 x_setup_relief_colors (s); 2317 x_setup_relief_colors (s);
2308 get_glyph_string_clip_rect (s, &r); 2318 get_glyph_string_clip_rect (s, &r);
2309 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r); 2319 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
2320 s->slice.y == 0,
2321 s->slice.y + s->slice.height == s->img->height,
2322 s->slice.x == 0,
2323 s->slice.x + s->slice.width == s->img->width,
2324 &r);
2310} 2325}
2311 2326
2312 2327
@@ -2317,21 +2332,22 @@ x_draw_image_foreground_1 (s, pixmap)
2317 struct glyph_string *s; 2332 struct glyph_string *s;
2318 Pixmap pixmap; 2333 Pixmap pixmap;
2319{ 2334{
2320 int x; 2335 int x = 0;
2321 int y = s->ybase - s->y - image_ascent (s->img, s->face); 2336 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
2322 2337
2323 /* If first glyph of S has a left box line, start drawing it to the 2338 /* If first glyph of S has a left box line, start drawing it to the
2324 right of that line. */ 2339 right of that line. */
2325 if (s->face->box != FACE_NO_BOX 2340 if (s->face->box != FACE_NO_BOX
2326 && s->first_glyph->left_box_line_p) 2341 && s->first_glyph->left_box_line_p
2327 x = abs (s->face->box_line_width); 2342 && s->slice.x == 0)
2328 else 2343 x += abs (s->face->box_line_width);
2329 x = 0;
2330 2344
2331 /* If there is a margin around the image, adjust x- and y-position 2345 /* If there is a margin around the image, adjust x- and y-position
2332 by that margin. */ 2346 by that margin. */
2333 x += s->img->hmargin; 2347 if (s->slice.x == 0)
2334 y += s->img->vmargin; 2348 x += s->img->hmargin;
2349 if (s->slice.y == 0)
2350 y += s->img->vmargin;
2335 2351
2336 if (s->img->pixmap) 2352 if (s->img->pixmap)
2337 { 2353 {
@@ -2347,19 +2363,21 @@ x_draw_image_foreground_1 (s, pixmap)
2347 XGCValues xgcv; 2363 XGCValues xgcv;
2348 2364
2349 xgcv.clip_mask = s->img->mask; 2365 xgcv.clip_mask = s->img->mask;
2350 xgcv.clip_x_origin = x; 2366 xgcv.clip_x_origin = x - s->slice.x;
2351 xgcv.clip_y_origin = y; 2367 xgcv.clip_y_origin = y - s->slice.y;
2352 xgcv.function = GXcopy; 2368 xgcv.function = GXcopy;
2353 XChangeGC (s->display, s->gc, mask, &xgcv); 2369 XChangeGC (s->display, s->gc, mask, &xgcv);
2354 2370
2355 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, 2371 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
2356 0, 0, s->img->width, s->img->height, x, y); 2372 s->slice.x, s->slice.y,
2373 s->slice.width, s->slice.height, x, y);
2357 XSetClipMask (s->display, s->gc, None); 2374 XSetClipMask (s->display, s->gc, None);
2358 } 2375 }
2359 else 2376 else
2360 { 2377 {
2361 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, 2378 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
2362 0, 0, s->img->width, s->img->height, x, y); 2379 s->slice.x, s->slice.y,
2380 s->slice.width, s->slice.height, x, y);
2363 2381
2364 /* When the image has a mask, we can expect that at 2382 /* When the image has a mask, we can expect that at
2365 least part of a mouse highlight or a block cursor will 2383 least part of a mouse highlight or a block cursor will
@@ -2372,14 +2390,15 @@ x_draw_image_foreground_1 (s, pixmap)
2372 int r = s->img->relief; 2390 int r = s->img->relief;
2373 if (r < 0) r = -r; 2391 if (r < 0) r = -r;
2374 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r, 2392 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r,
2375 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2393 s->slice.width + r*2 - 1,
2394 s->slice.height + r*2 - 1);
2376 } 2395 }
2377 } 2396 }
2378 } 2397 }
2379 else 2398 else
2380 /* Draw a rectangle if image could not be loaded. */ 2399 /* Draw a rectangle if image could not be loaded. */
2381 XDrawRectangle (s->display, pixmap, s->gc, x, y, 2400 XDrawRectangle (s->display, pixmap, s->gc, x, y,
2382 s->img->width - 1, s->img->height - 1); 2401 s->slice.width - 1, s->slice.height - 1);
2383} 2402}
2384 2403
2385 2404
@@ -2421,33 +2440,28 @@ static void
2421x_draw_image_glyph_string (s) 2440x_draw_image_glyph_string (s)
2422 struct glyph_string *s; 2441 struct glyph_string *s;
2423{ 2442{
2424 int x, y;
2425 int box_line_hwidth = abs (s->face->box_line_width); 2443 int box_line_hwidth = abs (s->face->box_line_width);
2426 int box_line_vwidth = max (s->face->box_line_width, 0); 2444 int box_line_vwidth = max (s->face->box_line_width, 0);
2427 int height; 2445 int height;
2428 Pixmap pixmap = None; 2446 Pixmap pixmap = None;
2429 2447
2430 height = s->height - 2 * box_line_vwidth; 2448 height = s->height;
2431 2449 if (s->slice.y == 0)
2450 height -= box_line_vwidth;
2451 if (s->slice.y + s->slice.height >= s->img->height)
2452 height -= box_line_vwidth;
2432 2453
2433 /* Fill background with face under the image. Do it only if row is 2454 /* Fill background with face under the image. Do it only if row is
2434 taller than image or if image has a clip mask to reduce 2455 taller than image or if image has a clip mask to reduce
2435 flickering. */ 2456 flickering. */
2436 s->stippled_p = s->face->stipple != 0; 2457 s->stippled_p = s->face->stipple != 0;
2437 if (height > s->img->height 2458 if (height > s->slice.height
2438 || s->img->hmargin 2459 || s->img->hmargin
2439 || s->img->vmargin 2460 || s->img->vmargin
2440 || s->img->mask 2461 || s->img->mask
2441 || s->img->pixmap == 0 2462 || s->img->pixmap == 0
2442 || s->width != s->background_width) 2463 || s->width != s->background_width)
2443 { 2464 {
2444 if (box_line_hwidth && s->first_glyph->left_box_line_p)
2445 x = s->x + box_line_hwidth;
2446 else
2447 x = s->x;
2448
2449 y = s->y + box_line_vwidth;
2450
2451 if (s->img->mask) 2465 if (s->img->mask)
2452 { 2466 {
2453 /* Create a pixmap as large as the glyph string. Fill it 2467 /* Create a pixmap as large as the glyph string. Fill it
@@ -2486,7 +2500,19 @@ x_draw_image_glyph_string (s)
2486 } 2500 }
2487 } 2501 }
2488 else 2502 else
2489 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height); 2503 {
2504 int x = s->x;
2505 int y = s->y;
2506
2507 if (s->first_glyph->left_box_line_p
2508 && s->slice.x == 0)
2509 x += box_line_hwidth;
2510
2511 if (s->slice.y == 0)
2512 y += box_line_vwidth;
2513
2514 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
2515 }
2490 2516
2491 s->background_filled_p = 1; 2517 s->background_filled_p = 1;
2492 } 2518 }
@@ -7239,7 +7265,8 @@ x_draw_hollow_cursor (w, row)
7239 /* Compute the proper height and ascent of the rectangle, based 7265 /* Compute the proper height and ascent of the rectangle, based
7240 on the actual glyph. Using the full height of the row looks 7266 on the actual glyph. Using the full height of the row looks
7241 bad when there are tall images on that row. */ 7267 bad when there are tall images on that row. */
7242 h = max (FRAME_LINE_HEIGHT (f), cursor_glyph->ascent + cursor_glyph->descent); 7268 h = max (min (FRAME_LINE_HEIGHT (f), row->height),
7269 cursor_glyph->ascent + cursor_glyph->descent);
7243 if (h < row->height) 7270 if (h < row->height)
7244 y += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h; 7271 y += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h;
7245 h--; 7272 h--;
diff --git a/src/xterm.h b/src/xterm.h
index fe0449a3bc5..d87135e8bf6 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1,5 +1,5 @@
1/* Definitions and headers for communication with X protocol. 1/* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989, 1993, 1994, 1998, 1999, 2000, 2001, 2001 2 Copyright (C) 1989, 1993, 1994, 1998, 1999, 2000,01,02,03,04
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -167,7 +167,7 @@ struct x_display_info
167 /* The colormap being used. */ 167 /* The colormap being used. */
168 Colormap cmap; 168 Colormap cmap;
169 169
170 /* Number of panes on this screen. */ 170 /* Number of planes on this screen. */
171 int n_planes; 171 int n_planes;
172 172
173 /* Dimensions of this screen. */ 173 /* Dimensions of this screen. */
@@ -941,7 +941,6 @@ Lisp_Object display_x_get_resource P_ ((struct x_display_info *,
941struct frame *check_x_frame P_ ((Lisp_Object)); 941struct frame *check_x_frame P_ ((Lisp_Object));
942EXFUN (Fx_display_color_p, 1); 942EXFUN (Fx_display_color_p, 1);
943EXFUN (Fx_display_grayscale_p, 1); 943EXFUN (Fx_display_grayscale_p, 1);
944int image_ascent P_ ((struct image *, struct face *));
945extern void x_free_gcs P_ ((struct frame *)); 944extern void x_free_gcs P_ ((struct frame *));
946 945
947/* From xrdb.c. */ 946/* From xrdb.c. */