aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2005-07-22 08:27:27 +0000
committerMiles Bader2005-07-22 08:27:27 +0000
commit3674ae2f87e47a654524af689ea610ee3edeaca7 (patch)
tree58ea33c40c8521a79fb503080b8bb6231ffbf579 /src
parent3e03f554f116e04ba860dcde7c6d862939911e16 (diff)
parent7929f858f8897f0448771a471f8afc5f244e4bca (diff)
downloademacs-3674ae2f87e47a654524af689ea610ee3edeaca7.tar.gz
emacs-3674ae2f87e47a654524af689ea610ee3edeaca7.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-71
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 485-492) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 92-94) - Merge from emacs--cvs-trunk--0 - Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit10
-rw-r--r--src/ChangeLog175
-rw-r--r--src/buffer.c30
-rw-r--r--src/buffer.h5
-rw-r--r--src/ccl.c9
-rw-r--r--src/composite.c12
-rw-r--r--src/eval.c37
-rw-r--r--src/fileio.c31
-rw-r--r--src/frame.h8
-rw-r--r--src/keymap.c2
-rw-r--r--src/lread.c16
-rw-r--r--src/mac.c8
-rw-r--r--src/macfns.c7
-rw-r--r--src/macgui.h25
-rw-r--r--src/macselect.c4
-rw-r--r--src/macterm.c304
-rw-r--r--src/macterm.h7
-rw-r--r--src/minibuf.c6
-rw-r--r--src/search.c1
-rw-r--r--src/syntax.c8
-rw-r--r--src/textprop.c4
-rw-r--r--src/w32.c39
-rw-r--r--src/w32fns.c4
-rw-r--r--src/w32proc.c5
-rw-r--r--src/window.c48
-rw-r--r--src/xdisp.c41
-rw-r--r--src/xfaces.c4
27 files changed, 532 insertions, 318 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index 68042505ed5..95ea18f7136 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -129,20 +129,24 @@ define pitx
129 end 129 end
130 if ($it->what == IT_CHARACTER) 130 if ($it->what == IT_CHARACTER)
131 if ($it->len == 1 && $it->c >= ' ' && it->c < 255) 131 if ($it->len == 1 && $it->c >= ' ' && it->c < 255)
132 printf "ch='%c'", $it->c 132 printf " ch='%c'", $it->c
133 else 133 else
134 printf "ch=[%d,%d]", $it->c, $it->len 134 printf " ch=[%d,%d]", $it->c, $it->len
135 end 135 end
136 else 136 else
137 if ($it->what == IT_IMAGE) 137 if ($it->what == IT_IMAGE)
138 printf "IMAGE=%d", $it->image_id 138 printf " IMAGE=%d", $it->image_id
139 else 139 else
140 printf " "
140 output $it->what 141 output $it->what
141 end 142 end
142 end 143 end
143 if ($it->method != GET_FROM_BUFFER) 144 if ($it->method != GET_FROM_BUFFER)
144 printf " next=" 145 printf " next="
145 output $it->method 146 output $it->method
147 if ($it->method == GET_FROM_STRING)
148 printf "[%d]", $it->current.string_pos.charpos
149 end
146 end 150 end
147 printf "\n" 151 printf "\n"
148 if ($it->region_beg_charpos >= 0) 152 if ($it->region_beg_charpos >= 0)
diff --git a/src/ChangeLog b/src/ChangeLog
index f3f865612f6..5f04eec4768 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,164 @@
12005-07-21 Juanma Barranquero <lekktu@gmail.com>
2
3 * buffer.c (syms_of_buffer) <cursor-type>: Doc fix.
4
5 * ccl.c (Fregister_ccl_program): Fix typos in docstring.
6 (Fccl_execute_on_string): Likewise; add usage info.
7
8 * composite.c (Fcompose_region_internal)
9 (Fcompose_string_internal):
10 Improve argument/docstring consistency.
11
12 * minibuf.c (Fminibuffer_prompt_end, Feval_minibuffer):
13 Fix typos in docstrings.
14
15 * textprop.c (Fnext_char_property_change)
16 (Fprevious_char_property_change): Doc fixes.
17
18 * window.c (Fset_window_margins, Fset_window_fringes):
19 Improve argument/docstring consistency.
20
21 * xfaces.c (Finternal_lisp_face_p): Doc fix.
22
232005-07-21 Andreas Schwab <schwab@suse.de>
24
25 * eval.c (restore_stack_limits): Return a value.
26
272005-07-20 Juanma Barranquero <lekktu@gmail.com>
28
29 * eval.c (Fdefvar): Doc fix.
30
312005-07-20 Kim F. Storm <storm@cua.dk>
32
33 * fileio.c (Fdo_auto_save, do_auto_save_unwind):
34 Use make_save_value to unwind protect stream.
35
36 * lread.c (Fload, load_unwind):
37 Use make_save_value to unwind protect stream.
38
392005-07-19 Juanma Barranquero <lekktu@gmail.com>
40
41 * eval.c (Fprog2, Fcalled_interactively_p),
42 (syms_of_eval) <debug-on-quit>: Doc fixes.
43 (syms_of_eval) <max-specpdl-size>:
44 (Finteractive_p): Fix typos in docstrings.
45
462005-07-19 Kim F. Storm <storm@cua.dk>
47
48 * w32fns.c (Vx_hand_shape): Variable removed.
49 (syms_of_w32fns): Intern and staticpro Qw32_charset_default.
50
512005-07-18 Stefan Monnier <monnier@iro.umontreal.ca>
52
53 * buffer.h (Fgenerate_new_buffer_name): Declare (for use in coding.c).
54
552005-07-18 Kim F. Storm <storm@cua.dk>
56
57 * frame.h (struct frame): New member already_hscrolled_p.
58
59 * xdisp.c (redisplay_internal): Only try to hscroll each frame once
60 to avoid redisplay looping hscrolling back and forth ad infinitum.
61
622005-07-18 Juri Linkov <juri@jurta.org>
63
64 * buffer.c (scroll-up-aggressively, scroll-down-aggressively):
65 * keymap.c (Fminor_mode_key_binding):
66 * macterm.c (mac-emulate-three-button-mouse):
67 Delete duplicate duplicate words.
68
692005-07-18 Ken Raeburn <raeburn@gnu.org>
70
71 * minibuf.c (Ftest_completion): Fix odd syntax in test.
72
732005-07-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
74
75 * macfns.c (x_set_cursor_color): Use XSetBackground and XSetForeground.
76
77 * macgui.h (struct _XGC): New struct.
78 (GC): Use it.
79 (GCForeground, GCBackground, GCFont): Use X11 mask values.
80 (XCreateGC, XParseGeometry): Move externs to macterm.h.
81
82 * macterm.c (x_bitmap_icon, x_make_frame_visible): Remove declarations.
83 (XSetFont): Add declaration.
84 (mac_set_forecolor, mac_set_backcolor, mac_set_colors):
85 Remove functions.
86 (GC_FORE_COLOR, GC_BACK_COLOR, GC_FONT, MAC_WINDOW_NORMAL_GC):
87 New defines.
88 (XDrawLine, mac_draw_line_to_pixmap, XClearWindow)
89 (mac_draw_bitmap, XCreatePixmapFromBitmapData, XFillRectangle)
90 (mac_draw_rectangle, mac_draw_string_common, mac_scroll_area):
91 Use them.
92 (mac_erase_rectangle): New function.
93 (XClearArea, x_draw_fringe_bitmap, x_clear_glyph_string_rect)
94 (x_draw_stretch_glyph_string): Use it.
95 (XChangeGC, XCreateGC, XGetGCValues, XSetForeground)
96 (XSetBackground, XSetFont): Adjust for new GC implementation.
97 (x_draw_fringe_bitmap, x_draw_box_rect): Use GC to set colors.
98 (XTset_vertical_scroll_bar): Clear area under scroll bar.
99
100 * macterm.h (struct mac_display_info): Change types of
101 scratch_cursor_gc black_relief.gc, and white_relief.gc to GC.
102 (XCreateGC, XParseGeometry): Move externs from macgui.h.
103
104 * xfaces.c [MAC_OS] (XCreateGC): Remove extern.
105
1062005-07-16 Richard M. Stallman <rms@gnu.org>
107
108 * buffer.c (Fmake_overlay): Doc fix.
109
1102005-07-16 Eli Zaretskii <eliz@gnu.org>
111
112 * w32proc.c (syms_of_ntproc): staticpro Qhigh, Qlow,
113 Vw32_valid_locale_ids, and Vw32_valid_codepages.
114
1152005-07-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
116
117 * mac.c [TARGET_API_MAC_CARBON] (Fmac_code_convert_string):
118 Use Fstring_as_unibyte instead of string_make_unibyte.
119
1202005-07-15 Richard M. Stallman <rms@gnu.org>
121
122 * xdisp.c (select_frame_for_redisplay): Use find_symbol_value.
123
1242005-07-15 Kim F. Storm <storm@cua.dk>
125
126 * xdisp.c: Fix redisplay loop in last change.
127 (IT_POS_VALID_AFTER_MOVE_P): New macro.
128 (move_it_vertically_backward, move_it_by_lines): Use it.
129
1302005-07-14 Jason Rumney <jasonr@gnu.org>
131
132 * w32.c (init_environment): Default HOME directory to user's
133 appdata directory if possible.
134
1352005-07-14 Kim F. Storm <storm@cua.dk>
136
137 * .gdbinit (pitx): Fix output format. Print string charpos.
138
139 * lread.c (syms_of_lread): Initialize seen_list.
140
141 * search.c (syms_of_search): Staticpro searchbuf.whitespace_regexp.
142
143 * syntax.c (syms_of_syntax): Staticpro lisp objects in gl_state.
144 Staticpro re_match_object.
145
1462005-07-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
147
148 * macselect.c (get_scrap_target_type_list): Avoid NULL pointer
149 dereference.
150
151 * macterm.c (mac_window_to_frame): Remove duplicate define.
152
1532005-07-14 Kenichi Handa <handa@m17n.org>
154
155 * coding.c (code_convert_region_unwind): ARG is changed to a cons.
156 (code_convert_region): Adjust for the above change.
157 (set_conversion_work_buffer): If the work buffer is already in
158 use, generate a new buffer and return it. Otherwise return Qnil.
159 (run_pre_post_conversion_on_str): Adjust for the above change.
160 (run_pre_write_conversin_on_c_str): Likewise.
161
12005-07-13 Kim F. Storm <storm@cua.dk> 1622005-07-13 Kim F. Storm <storm@cua.dk>
2 163
3 * xdisp.c (start_display): Don't reseat to next visible line start 164 * xdisp.c (start_display): Don't reseat to next visible line start
@@ -9,7 +170,7 @@
9 count rows moved over when moving to start of current row in case 170 count rows moved over when moving to start of current row in case
10 row starts in middle of a string or image. Also move further 171 row starts in middle of a string or image. Also move further
11 backward if we end up in a string or image. 172 backward if we end up in a string or image.
12 (try_cursor_movement): if overlay string spans multiple lines, 173 (try_cursor_movement): If overlay string spans multiple lines,
13 move backward to set cursor on start of an overlay string. 174 move backward to set cursor on start of an overlay string.
14 (cursor_row_p): Row is ok if cursor is at newline from string, but 175 (cursor_row_p): Row is ok if cursor is at newline from string, but
15 string starts on this line (so we always position cursor at start 176 string starts on this line (so we always position cursor at start
@@ -38,22 +199,22 @@
38 (disable_mouse_highlight): Remove unused variable. 199 (disable_mouse_highlight): Remove unused variable.
39 [USE_TOOLKIT_SCROLL_BARS] (construct_scroll_bar_click) 200 [USE_TOOLKIT_SCROLL_BARS] (construct_scroll_bar_click)
40 (x_scroll_bar_handle_press, x_scroll_bar_handle_release) 201 (x_scroll_bar_handle_press, x_scroll_bar_handle_release)
41 (x_scroll_bar_handle_drag): Remove argument `timestamp'. All 202 (x_scroll_bar_handle_drag): Remove argument `timestamp'.
42 callers changed. 203 All callers changed.
43 [USE_TOOLKIT_SCROLL_BARS] (construct_scroll_bar_click): Don't set 204 [USE_TOOLKIT_SCROLL_BARS] (construct_scroll_bar_click): Don't set
44 timestamp. 205 timestamp.
45 [USE_CARBON_EVENTS] (mac_handle_mouse_event): Likewise. 206 [USE_CARBON_EVENTS] (mac_handle_mouse_event): Likewise.
46 (x_scroll_bar_create, XTset_vertical_scroll_bar): Show scroll bar 207 (x_scroll_bar_create, XTset_vertical_scroll_bar): Show scroll bar
47 only when its width is less than the height. 208 only when its width is less than the height.
48 (XTredeem_scroll_bar): Sync with xterm.c. 209 (XTredeem_scroll_bar): Sync with xterm.c.
49 (font_name_table, font_name_table_size, font_name_count): Make 210 (font_name_table, font_name_table_size, font_name_count):
50 static. 211 Make static.
51 (drag_and_drop_file_list): Remove variable. Previous use is now 212 (drag_and_drop_file_list): Remove variable. Previous use is now
52 local to function. 213 local to function.
53 (do_ae_open_documents): Move DRAG_N_DROP event construction part 214 (do_ae_open_documents): Move DRAG_N_DROP event construction part
54 from XTread_socket. 215 from XTread_socket.
55 (XTread_socket): Consolidate setting of event timestamp. Move 216 (XTread_socket): Consolidate setting of event timestamp.
56 DRAG_N_DROP event construction part to do_ae_open_documents. 217 Move DRAG_N_DROP event construction part to do_ae_open_documents.
57 Support extra_keyboard_modifiers. 218 Support extra_keyboard_modifiers.
58 219
59 * xfaces.c (try_font_list) [MAC_OS]: Try font family name 220 * xfaces.c (try_font_list) [MAC_OS]: Try font family name
diff --git a/src/buffer.c b/src/buffer.c
index 4001801922f..01be485fcc0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3573,10 +3573,12 @@ DEFUN ("make-overlay", Fmake_overlay, Smake_overlay, 2, 5, 0,
3573 doc: /* Create a new overlay with range BEG to END in BUFFER. 3573 doc: /* Create a new overlay with range BEG to END in BUFFER.
3574If omitted, BUFFER defaults to the current buffer. 3574If omitted, BUFFER defaults to the current buffer.
3575BEG and END may be integers or markers. 3575BEG and END may be integers or markers.
3576The fourth arg FRONT-ADVANCE, if non-nil, makes the 3576The fourth arg FRONT-ADVANCE, if non-nil, makes the marker
3577front delimiter advance when text is inserted there. 3577for the front of the overlay advance when text is inserted there
3578The fifth arg REAR-ADVANCE, if non-nil, makes the 3578(which means the text *is not* included in the overlay).
3579rear delimiter advance when text is inserted there. */) 3579The fifth arg REAR-ADVANCE, if non-nil, makes the marker
3580for the rear of the overlay advance when text is inserted there
3581(which means the text *is* included in the overlay). */)
3580 (beg, end, buffer, front_advance, rear_advance) 3582 (beg, end, buffer, front_advance, rear_advance)
3581 Lisp_Object beg, end, buffer; 3583 Lisp_Object beg, end, buffer;
3582 Lisp_Object front_advance, rear_advance; 3584 Lisp_Object front_advance, rear_advance;
@@ -5743,7 +5745,7 @@ that fraction of the window's height from the bottom of the window.
5743When the value is 0.0, point goes at the bottom line, which in the simple 5745When the value is 0.0, point goes at the bottom line, which in the simple
5744case that you moved off with C-f means scrolling just one line. 1.0 means 5746case that you moved off with C-f means scrolling just one line. 1.0 means
5745point goes at the top, so that in that simple case, the window 5747point goes at the top, so that in that simple case, the window
5746window scrolls by a full window height. Meaningful values are 5748scrolls by a full window height. Meaningful values are
5747between 0.0 and 1.0, inclusive. */); 5749between 0.0 and 1.0, inclusive. */);
5748 5750
5749 DEFVAR_PER_BUFFER ("scroll-down-aggressively", 5751 DEFVAR_PER_BUFFER ("scroll-down-aggressively",
@@ -5756,7 +5758,7 @@ that fraction of the window's height from the top of the window.
5756When the value is 0.0, point goes at the top line, which in the simple 5758When the value is 0.0, point goes at the top line, which in the simple
5757case that you moved off with C-b means scrolling just one line. 1.0 means 5759case that you moved off with C-b means scrolling just one line. 1.0 means
5758point goes at the bottom, so that in that simple case, the window 5760point goes at the bottom, so that in that simple case, the window
5759window scrolls by a full window height. Meaningful values are 5761scrolls by a full window height. Meaningful values are
5760between 0.0 and 1.0, inclusive. */); 5762between 0.0 and 1.0, inclusive. */);
5761 5763
5762/*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol, 5764/*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol,
@@ -5944,15 +5946,15 @@ is a member of the list. */);
5944 doc: /* Cursor to use when this buffer is in the selected window. 5946 doc: /* Cursor to use when this buffer is in the selected window.
5945Values are interpreted as follows: 5947Values are interpreted as follows:
5946 5948
5947 t use the cursor specified for the frame 5949 t use the cursor specified for the frame
5948 nil don't display a cursor 5950 nil don't display a cursor
5949 box display a filled box cursor 5951 box display a filled box cursor
5950 hollow display a hollow box cursor 5952 hollow display a hollow box cursor
5951 bar display a vertical bar cursor with default width 5953 bar display a vertical bar cursor with default width
5952 (bar . WIDTH) display a vertical bar cursor with width WIDTH 5954 (bar . WIDTH) display a vertical bar cursor with width WIDTH
5953 hbar display a horizontal bar cursor with default height 5955 hbar display a horizontal bar cursor with default height
5954 (hbar . HEIGHT) display a horizontal bar cursor with height HEIGHT 5956 (hbar . HEIGHT) display a horizontal bar cursor with height HEIGHT
5955 ANYTHING ELSE display a hollow box cursor. 5957 ANYTHING ELSE display a hollow box cursor
5956 5958
5957When the buffer is displayed in a nonselected window, 5959When the buffer is displayed in a nonselected window,
5958this variable has no effect; the cursor appears as a hollow box. */); 5960this variable has no effect; the cursor appears as a hollow box. */);
diff --git a/src/buffer.h b/src/buffer.h
index d97640d6cea..12475ce26a8 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,6 +1,6 @@
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,98,99,2000,01,03,04 2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
3 Free Software Foundation, Inc. 3 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -860,6 +860,7 @@ EXFUN (Fget_file_buffer, 1);
860EXFUN (Fnext_overlay_change, 1); 860EXFUN (Fnext_overlay_change, 1);
861EXFUN (Fdelete_overlay, 1); 861EXFUN (Fdelete_overlay, 1);
862EXFUN (Fbuffer_local_value, 2); 862EXFUN (Fbuffer_local_value, 2);
863EXFUN (Fgenerate_new_buffer_name, 2);
863 864
864/* Functions to call before and after each text change. */ 865/* Functions to call before and after each text change. */
865extern Lisp_Object Vbefore_change_functions; 866extern Lisp_Object Vbefore_change_functions;
diff --git a/src/ccl.c b/src/ccl.c
index 6359e947d27..e827ed7f28d 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -2030,7 +2030,7 @@ DEFUN ("ccl-execute-on-string", Fccl_execute_on_string, Sccl_execute_on_string,
2030 3, 5, 0, 2030 3, 5, 0,
2031 doc: /* Execute CCL-PROGRAM with initial STATUS on STRING. 2031 doc: /* Execute CCL-PROGRAM with initial STATUS on STRING.
2032 2032
2033CCL-PROGRAM is a symbol registered by register-ccl-program, 2033CCL-PROGRAM is a symbol registered by `register-ccl-program',
2034or a compiled code generated by `ccl-compile' (for backward compatibility, 2034or a compiled code generated by `ccl-compile' (for backward compatibility,
2035in this case, the execution is slower). 2035in this case, the execution is slower).
2036 2036
@@ -2051,7 +2051,8 @@ It returns the contents of write buffer as a string,
2051If the optional 5th arg UNIBYTE-P is non-nil, the returned string 2051If the optional 5th arg UNIBYTE-P is non-nil, the returned string
2052is a unibyte string. By default it is a multibyte string. 2052is a unibyte string. By default it is a multibyte string.
2053 2053
2054See the documentation of `define-ccl-program' for the detail of CCL program. */) 2054See the documentation of `define-ccl-program' for the detail of CCL program.
2055usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBYTE-P) */)
2055 (ccl_prog, status, str, contin, unibyte_p) 2056 (ccl_prog, status, str, contin, unibyte_p)
2056 Lisp_Object ccl_prog, status, str, contin, unibyte_p; 2057 Lisp_Object ccl_prog, status, str, contin, unibyte_p;
2057{ 2058{
@@ -2177,8 +2178,8 @@ See the documentation of `define-ccl-program' for the detail of CCL program. */
2177 2178
2178DEFUN ("register-ccl-program", Fregister_ccl_program, Sregister_ccl_program, 2179DEFUN ("register-ccl-program", Fregister_ccl_program, Sregister_ccl_program,
2179 2, 2, 0, 2180 2, 2, 0,
2180 doc: /* Register CCL program CCL_PROG as NAME in `ccl-program-table'. 2181 doc: /* Register CCL program CCL-PROG as NAME in `ccl-program-table'.
2181CCL_PROG should be a compiled CCL program (vector), or nil. 2182CCL-PROG should be a compiled CCL program (vector), or nil.
2182If it is nil, just reserve NAME as a CCL program name. 2183If it is nil, just reserve NAME as a CCL program name.
2183Return index number of the registered CCL program. */) 2184Return index number of the registered CCL program. */)
2184 (name, ccl_prog) 2185 (name, ccl_prog)
diff --git a/src/composite.c b/src/composite.c
index 63d54b93a34..1eb0b0212fd 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -628,8 +628,8 @@ DEFUN ("compose-region-internal", Fcompose_region_internal,
628Compose text in the region between START and END. 628Compose text in the region between START and END.
629Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC 629Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC
630for the composition. See `compose-region' for more detail. */) 630for the composition. See `compose-region' for more detail. */)
631 (start, end, components, mod_func) 631 (start, end, components, modification_func)
632 Lisp_Object start, end, components, mod_func; 632 Lisp_Object start, end, components, modification_func;
633{ 633{
634 validate_region (&start, &end); 634 validate_region (&start, &end);
635 if (!NILP (components) 635 if (!NILP (components)
@@ -638,7 +638,7 @@ for the composition. See `compose-region' for more detail. */)
638 && !STRINGP (components)) 638 && !STRINGP (components))
639 CHECK_VECTOR (components); 639 CHECK_VECTOR (components);
640 640
641 compose_text (XINT (start), XINT (end), components, mod_func, Qnil); 641 compose_text (XINT (start), XINT (end), components, modification_func, Qnil);
642 return Qnil; 642 return Qnil;
643} 643}
644 644
@@ -649,8 +649,8 @@ DEFUN ("compose-string-internal", Fcompose_string_internal,
649Compose text between indices START and END of STRING. 649Compose text between indices START and END of STRING.
650Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC 650Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC
651for the composition. See `compose-string' for more detail. */) 651for the composition. See `compose-string' for more detail. */)
652 (string, start, end, components, mod_func) 652 (string, start, end, components, modification_func)
653 Lisp_Object string, start, end, components, mod_func; 653 Lisp_Object string, start, end, components, modification_func;
654{ 654{
655 CHECK_STRING (string); 655 CHECK_STRING (string);
656 CHECK_NUMBER (start); 656 CHECK_NUMBER (start);
@@ -661,7 +661,7 @@ for the composition. See `compose-string' for more detail. */)
661 || XINT (end) > SCHARS (string)) 661 || XINT (end) > SCHARS (string))
662 args_out_of_range (start, end); 662 args_out_of_range (start, end);
663 663
664 compose_text (XINT (start), XINT (end), components, mod_func, string); 664 compose_text (XINT (start), XINT (end), components, modification_func, string);
665 return string; 665 return string;
666} 666}
667 667
diff --git a/src/eval.c b/src/eval.c
index 3b4e9fe0324..26d1ce967a7 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -235,6 +235,7 @@ restore_stack_limits (data)
235{ 235{
236 max_specpdl_size = XINT (XCAR (data)); 236 max_specpdl_size = XINT (XCAR (data));
237 max_lisp_eval_depth = XINT (XCDR (data)); 237 max_lisp_eval_depth = XINT (XCDR (data));
238 return Qnil;
238} 239}
239 240
240/* Call the Lisp debugger, giving it argument ARG. */ 241/* Call the Lisp debugger, giving it argument ARG. */
@@ -471,10 +472,10 @@ usage: (prog1 FIRST BODY...) */)
471} 472}
472 473
473DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, 474DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
474 doc: /* Eval X, Y and BODY sequentially; value from Y. 475 doc: /* Eval FORM1, FORM2 and BODY sequentially; value from FORM2.
475The value of Y is saved during the evaluation of the remaining args, 476The value of FORM2 is saved during the evaluation of the
476whose values are discarded. 477remaining args, whose values are discarded.
477usage: (prog2 X Y BODY...) */) 478usage: (prog2 FORM1 FORM2 BODY...) */)
478 (args) 479 (args)
479 Lisp_Object args; 480 Lisp_Object args;
480{ 481{
@@ -564,8 +565,8 @@ usage: (function ARG) */)
564 565
565DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, 566DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
566 doc: /* Return t if the function was run directly by user input. 567 doc: /* Return t if the function was run directly by user input.
567This means that the function was called with call-interactively (which 568This means that the function was called with `call-interactively'
568includes being called as the binding of a key) 569\(which includes being called as the binding of a key)
569and input is currently coming from the keyboard (not in keyboard macro), 570and input is currently coming from the keyboard (not in keyboard macro),
570and Emacs is not running in batch mode (`noninteractive' is nil). 571and Emacs is not running in batch mode (`noninteractive' is nil).
571 572
@@ -586,14 +587,14 @@ unconditionally for that argument. (`p' is a good way to do this.) */)
586 587
587 588
588DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0, 589DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0,
589 doc: /* Return t if the function using this was called with call-interactively. 590 doc: /* Return t if the function using this was called with `call-interactively'.
590This is used for implementing advice and other function-modifying 591This is used for implementing advice and other function-modifying
591features of Emacs. 592features of Emacs.
592 593
593The cleanest way to test whether your function was called with 594The cleanest way to test whether your function was called with
594`call-interactively', the way to do that is by adding an extra 595`call-interactively' is by adding an extra optional argument,
595optional argument, and making the `interactive' spec specify non-nil 596and making the `interactive' spec specify non-nil unconditionally
596unconditionally for that argument. (`p' is a good way to do this.) */) 597for that argument. (`p' is a good way to do this.) */)
597 () 598 ()
598{ 599{
599 return interactive_p (1) ? Qt : Qnil; 600 return interactive_p (1) ? Qt : Qnil;
@@ -779,7 +780,7 @@ The return value is BASE-VARIABLE. */)
779 780
780 781
781DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, 782DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0,
782 doc: /* Define SYMBOL as a variable. 783 doc: /* Define SYMBOL as a variable, and return SYMBOL.
783You are not required to define a variable in order to use it, 784You are not required to define a variable in order to use it,
784but the definition can supply documentation and an initial value 785but the definition can supply documentation and an initial value
785in a way that tags can recognize. 786in a way that tags can recognize.
@@ -2859,8 +2860,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2859 val = (*XSUBR (fun)->function) (internal_args[0]); 2860 val = (*XSUBR (fun)->function) (internal_args[0]);
2860 goto done; 2861 goto done;
2861 case 2: 2862 case 2:
2862 val = (*XSUBR (fun)->function) (internal_args[0], 2863 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1]);
2863 internal_args[1]);
2864 goto done; 2864 goto done;
2865 case 3: 2865 case 3:
2866 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], 2866 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
@@ -2868,8 +2868,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2868 goto done; 2868 goto done;
2869 case 4: 2869 case 4:
2870 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], 2870 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
2871 internal_args[2], 2871 internal_args[2], internal_args[3]);
2872 internal_args[3]);
2873 goto done; 2872 goto done;
2874 case 5: 2873 case 5:
2875 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], 2874 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
@@ -3395,7 +3394,7 @@ void
3395syms_of_eval () 3394syms_of_eval ()
3396{ 3395{
3397 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size, 3396 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
3398 doc: /* *Limit on number of Lisp variable bindings & unwind-protects. 3397 doc: /* *Limit on number of Lisp variable bindings and `unwind-protect's.
3399If Lisp code tries to increase the total number past this amount, 3398If Lisp code tries to increase the total number past this amount,
3400an error is signaled. 3399an error is signaled.
3401You can safely use a value considerably larger than the default value, 3400You can safely use a value considerably larger than the default value,
@@ -3492,10 +3491,8 @@ It does not apply to errors handled by `condition-case'. */);
3492 Vdebug_ignored_errors = Qnil; 3491 Vdebug_ignored_errors = Qnil;
3493 3492
3494 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit, 3493 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit,
3495 doc: /* *Non-nil means enter debugger if quit is signaled (C-g, for example). 3494 doc: /* *Non-nil means enter debugger if quit is signaled (C-g, for example).
3496Does not apply if quit is handled by a `condition-case'. 3495Does not apply if quit is handled by a `condition-case'. */);
3497When you evaluate an expression interactively, this variable
3498is temporarily non-nil if `eval-expression-debug-on-quit' is non-nil. */);
3499 debug_on_quit = 0; 3496 debug_on_quit = 0;
3500 3497
3501 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call, 3498 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call,
diff --git a/src/fileio.c b/src/fileio.c
index be6bf37ad94..7d84e243207 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5734,13 +5734,13 @@ auto_save_1 ()
5734} 5734}
5735 5735
5736static Lisp_Object 5736static Lisp_Object
5737do_auto_save_unwind (stream) /* used as unwind-protect function */ 5737do_auto_save_unwind (arg) /* used as unwind-protect function */
5738 Lisp_Object stream; 5738 Lisp_Object arg;
5739{ 5739{
5740 FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
5740 auto_saving = 0; 5741 auto_saving = 0;
5741 if (!NILP (stream)) 5742 if (stream != NULL)
5742 fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16 5743 fclose (stream);
5743 | XFASTINT (XCDR (stream))));
5744 return Qnil; 5744 return Qnil;
5745} 5745}
5746 5746
@@ -5785,8 +5785,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5785 int auto_saved = 0; 5785 int auto_saved = 0;
5786 int do_handled_files; 5786 int do_handled_files;
5787 Lisp_Object oquit; 5787 Lisp_Object oquit;
5788 FILE *stream; 5788 FILE *stream = NULL;
5789 Lisp_Object lispstream;
5790 int count = SPECPDL_INDEX (); 5789 int count = SPECPDL_INDEX ();
5791 int orig_minibuffer_auto_raise = minibuffer_auto_raise; 5790 int orig_minibuffer_auto_raise = minibuffer_auto_raise;
5792 int old_message_p = 0; 5791 int old_message_p = 0;
@@ -5838,24 +5837,10 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5838 } 5837 }
5839 5838
5840 stream = fopen (SDATA (listfile), "w"); 5839 stream = fopen (SDATA (listfile), "w");
5841 if (stream != NULL)
5842 {
5843 /* Arrange to close that file whether or not we get an error.
5844 Also reset auto_saving to 0. */
5845 lispstream = Fcons (Qnil, Qnil);
5846 XSETCARFASTINT (lispstream, (EMACS_UINT)stream >> 16);
5847 XSETCDRFASTINT (lispstream, (EMACS_UINT)stream & 0xffff);
5848 }
5849 else
5850 lispstream = Qnil;
5851 }
5852 else
5853 {
5854 stream = NULL;
5855 lispstream = Qnil;
5856 } 5840 }
5857 5841
5858 record_unwind_protect (do_auto_save_unwind, lispstream); 5842 record_unwind_protect (do_auto_save_unwind,
5843 make_save_value (stream, 0));
5859 record_unwind_protect (do_auto_save_unwind_1, 5844 record_unwind_protect (do_auto_save_unwind_1,
5860 make_number (minibuffer_auto_raise)); 5845 make_number (minibuffer_auto_raise));
5861 minibuffer_auto_raise = 0; 5846 minibuffer_auto_raise = 0;
diff --git a/src/frame.h b/src/frame.h
index 8e4c77f9af4..290aed3266e 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -463,6 +463,10 @@ struct frame
463 realized. Reset to zero whenever the default face changes. 463 realized. Reset to zero whenever the default face changes.
464 Used to see the difference between a font change and face change. */ 464 Used to see the difference between a font change and face change. */
465 unsigned default_face_done_p : 1; 465 unsigned default_face_done_p : 1;
466
467 /* Set to non-zero if this frame has already been hscrolled during
468 current redisplay. */
469 unsigned already_hscrolled_p : 1;
466}; 470};
467 471
468#ifdef MULTI_KBOARD 472#ifdef MULTI_KBOARD
@@ -821,13 +825,13 @@ extern Lisp_Object selected_frame;
821 Display-related Macros 825 Display-related Macros
822 ***********************************************************************/ 826 ***********************************************************************/
823 827
824/* Canonical y-unit on frame F. 828/* Canonical y-unit on frame F.
825 This value currently equals the line height of the frame (which is 829 This value currently equals the line height of the frame (which is
826 the height of the default font of F). */ 830 the height of the default font of F). */
827 831
828#define FRAME_LINE_HEIGHT(F) ((F)->line_height) 832#define FRAME_LINE_HEIGHT(F) ((F)->line_height)
829 833
830/* Canonical x-unit on frame F. 834/* Canonical x-unit on frame F.
831 This value currently equals the average width of the default font of F. */ 835 This value currently equals the average width of the default font of F. */
832 836
833#define FRAME_COLUMN_WIDTH(F) ((F)->column_width) 837#define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
diff --git a/src/keymap.c b/src/keymap.c
index 090996c7e0d..dd206b8f065 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1694,7 +1694,7 @@ bindings; see the description of `lookup-key' for more details about this. */)
1694 1694
1695DEFUN ("minor-mode-key-binding", Fminor_mode_key_binding, Sminor_mode_key_binding, 1, 2, 0, 1695DEFUN ("minor-mode-key-binding", Fminor_mode_key_binding, Sminor_mode_key_binding, 1, 2, 0,
1696 doc: /* Find the visible minor mode bindings of KEY. 1696 doc: /* Find the visible minor mode bindings of KEY.
1697Return an alist of pairs (MODENAME . BINDING), where MODENAME is the 1697Return an alist of pairs (MODENAME . BINDING), where MODENAME is
1698the symbol which names the minor mode binding KEY, and BINDING is 1698the symbol which names the minor mode binding KEY, and BINDING is
1699KEY's definition in that mode. In particular, if KEY has no 1699KEY's definition in that mode. In particular, if KEY has no
1700minor-mode bindings, return nil. If the first binding is a 1700minor-mode bindings, return nil. If the first binding is a
diff --git a/src/lread.c b/src/lread.c
index 52a68923682..0cac2515b4f 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -853,7 +853,6 @@ Return t if file exists. */)
853{ 853{
854 register FILE *stream; 854 register FILE *stream;
855 register int fd = -1; 855 register int fd = -1;
856 register Lisp_Object lispstream;
857 int count = SPECPDL_INDEX (); 856 int count = SPECPDL_INDEX ();
858 Lisp_Object temp; 857 Lisp_Object temp;
859 struct gcpro gcpro1; 858 struct gcpro gcpro1;
@@ -1088,10 +1087,7 @@ Return t if file exists. */)
1088 } 1087 }
1089 1088
1090 GCPRO1 (file); 1089 GCPRO1 (file);
1091 lispstream = Fcons (Qnil, Qnil); 1090 record_unwind_protect (load_unwind, make_save_value (stream, 0));
1092 XSETCARFASTINT (lispstream, (EMACS_UINT)stream >> 16);
1093 XSETCDRFASTINT (lispstream, (EMACS_UINT)stream & 0xffff);
1094 record_unwind_protect (load_unwind, lispstream);
1095 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 1091 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
1096 specbind (Qload_file_name, found); 1092 specbind (Qload_file_name, found);
1097 specbind (Qinhibit_file_name_operation, Qnil); 1093 specbind (Qinhibit_file_name_operation, Qnil);
@@ -1150,11 +1146,12 @@ Return t if file exists. */)
1150} 1146}
1151 1147
1152static Lisp_Object 1148static Lisp_Object
1153load_unwind (stream) /* used as unwind-protect function in load */ 1149load_unwind (arg) /* used as unwind-protect function in load */
1154 Lisp_Object stream; 1150 Lisp_Object arg;
1155{ 1151{
1156 fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16 1152 FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
1157 | XFASTINT (XCDR (stream)))); 1153 if (stream != NULL)
1154 fclose (stream);
1158 if (--load_in_progress < 0) load_in_progress = 0; 1155 if (--load_in_progress < 0) load_in_progress = 0;
1159 return Qnil; 1156 return Qnil;
1160} 1157}
@@ -4161,6 +4158,7 @@ to load. See also `load-dangerous-libraries'. */);
4161 staticpro (&read_objects); 4158 staticpro (&read_objects);
4162 read_objects = Qnil; 4159 read_objects = Qnil;
4163 staticpro (&seen_list); 4160 staticpro (&seen_list);
4161 seen_list = Qnil;
4164 4162
4165 Vloads_in_progress = Qnil; 4163 Vloads_in_progress = Qnil;
4166 staticpro (&Vloads_in_progress); 4164 staticpro (&Vloads_in_progress);
diff --git a/src/mac.c b/src/mac.c
index 203b47a1975..11dd93aa88d 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -1,5 +1,5 @@
1/* Unix emulation routines for GNU Emacs on the Mac OS. 1/* Unix emulation routines for GNU Emacs on the Mac OS.
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc. 2 Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -4144,7 +4144,11 @@ nil. */)
4144 src_encoding = get_cfstring_encoding_from_lisp (source); 4144 src_encoding = get_cfstring_encoding_from_lisp (source);
4145 tgt_encoding = get_cfstring_encoding_from_lisp (target); 4145 tgt_encoding = get_cfstring_encoding_from_lisp (target);
4146 4146
4147 string = string_make_unibyte (string); 4147 /* We really want string_to_unibyte, but since it doesn't exist yet, we
4148 use string_as_unibyte which works as well, except for the fact that
4149 it's too permissive (it doesn't check that the multibyte string only
4150 contain single-byte chars). */
4151 string = Fstring_as_unibyte (string);
4148 if (src_encoding != kCFStringEncodingInvalidId 4152 if (src_encoding != kCFStringEncodingInvalidId
4149 && tgt_encoding != kCFStringEncodingInvalidId) 4153 && tgt_encoding != kCFStringEncodingInvalidId)
4150 str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string), 4154 str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string),
diff --git a/src/macfns.c b/src/macfns.c
index 603f0ec5313..a37ddde3458 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1570,9 +1570,10 @@ x_set_cursor_color (f, arg, oldval)
1570 { 1570 {
1571 BLOCK_INPUT; 1571 BLOCK_INPUT;
1572 /* Update frame's cursor_gc. */ 1572 /* Update frame's cursor_gc. */
1573 f->output_data.mac->cursor_gc->foreground = fore_pixel; 1573 XSetBackground (FRAME_MAC_DISPLAY (f),
1574 f->output_data.mac->cursor_gc->background = pixel; 1574 f->output_data.mac->cursor_gc, pixel);
1575 1575 XSetForeground (FRAME_MAC_DISPLAY (f),
1576 f->output_data.mac->cursor_gc, fore_pixel);
1576 UNBLOCK_INPUT; 1577 UNBLOCK_INPUT;
1577 1578
1578 if (FRAME_VISIBLE_P (f)) 1579 if (FRAME_VISIBLE_P (f))
diff --git a/src/macgui.h b/src/macgui.h
index d9948278d1b..ca55bad7a8c 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -180,15 +180,24 @@ typedef struct _XGCValues
180 XFontStruct *font; 180 XFontStruct *font;
181} XGCValues; 181} XGCValues;
182 182
183typedef XGCValues *GC; 183typedef struct _XGC
184{
185 /* Original value. */
186 XGCValues xgcv;
187
188 /* Cached data members follow. */
184 189
185extern XGCValues * 190 /* QuickDraw foreground color. */
186XCreateGC (void *, Window, unsigned long, XGCValues *); 191 RGBColor fore_color;
187 192
188#define GCForeground 0x01 193 /* QuickDraw background color. */
189#define GCBackground 0x02 194 RGBColor back_color;
190#define GCFont 0x03 195} *GC;
191#define GCGraphicsExposures 0 196
197#define GCForeground (1L<<2)
198#define GCBackground (1L<<3)
199#define GCFont (1L<<14)
200#define GCGraphicsExposures 0
192 201
193/* Bit Gravity */ 202/* Bit Gravity */
194 203
@@ -248,8 +257,6 @@ typedef struct {
248#define PBaseSize (1L << 8) /* program specified base for incrementing */ 257#define PBaseSize (1L << 8) /* program specified base for incrementing */
249#define PWinGravity (1L << 9) /* program specified window gravity */ 258#define PWinGravity (1L << 9) /* program specified window gravity */
250 259
251extern int XParseGeometry ();
252
253typedef struct { 260typedef struct {
254 int x, y; 261 int x, y;
255 unsigned width, height; 262 unsigned width, height;
diff --git a/src/macselect.c b/src/macselect.c
index b519950eb75..94fe591a206 100644
--- a/src/macselect.c
+++ b/src/macselect.c
@@ -371,7 +371,7 @@ get_scrap_target_type_list (scrap)
371 err = GetScrapFlavorCount (scrap, &count); 371 err = GetScrapFlavorCount (scrap, &count);
372 if (err == noErr) 372 if (err == noErr)
373 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count); 373 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
374 if (err == noErr && flavor_info) 374 if (flavor_info)
375 { 375 {
376 err = GetScrapFlavorInfoList (scrap, &count, flavor_info); 376 err = GetScrapFlavorInfoList (scrap, &count, flavor_info);
377 if (err != noErr) 377 if (err != noErr)
@@ -380,6 +380,8 @@ get_scrap_target_type_list (scrap)
380 flavor_info = NULL; 380 flavor_info = NULL;
381 } 381 }
382 } 382 }
383 if (flavor_info == NULL)
384 count = 0;
383#endif 385#endif
384 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest)) 386 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
385 { 387 {
diff --git a/src/macterm.c b/src/macterm.c
index 9420f236e59..5b7d3ee2262 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -96,8 +96,6 @@ Boston, MA 02110-1301, USA. */
96 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \ 96 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \
97 : controlKey) 97 : controlKey)
98#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) 98#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
99
100#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
101 99
102 100
103/* Non-nil means Emacs uses toolkit scroll bars. */ 101/* Non-nil means Emacs uses toolkit scroll bars. */
@@ -263,14 +261,19 @@ static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
263 Lisp_Object *, Lisp_Object *, 261 Lisp_Object *, Lisp_Object *,
264 unsigned long *)); 262 unsigned long *));
265 263
266static int is_emacs_window (WindowPtr); 264static int is_emacs_window P_ ((WindowPtr));
267 265
268int x_bitmap_icon (struct frame *, Lisp_Object); 266static void XSetFont P_ ((Display *, GC, XFontStruct *));
269void x_make_frame_visible (struct frame *);
270 267
271/* Defined in macmenu.h. */ 268/* Defined in macmenu.h. */
272extern void menubar_selection_callback (FRAME_PTR, int); 269extern void menubar_selection_callback (FRAME_PTR, int);
273 270
271#define GC_FORE_COLOR(gc) (&(gc)->fore_color)
272#define GC_BACK_COLOR(gc) (&(gc)->back_color)
273#define GC_FONT(gc) ((gc)->xgcv.font)
274#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc)
275
276
274/* X display function emulation */ 277/* X display function emulation */
275 278
276void 279void
@@ -282,51 +285,6 @@ XFreePixmap (display, pixmap)
282} 285}
283 286
284 287
285/* Set foreground color for subsequent QuickDraw commands. Assume
286 graphic port has already been set. */
287
288static void
289mac_set_forecolor (unsigned long color)
290{
291 RGBColor fg_color;
292
293 fg_color.red = RED16_FROM_ULONG (color);
294 fg_color.green = GREEN16_FROM_ULONG (color);
295 fg_color.blue = BLUE16_FROM_ULONG (color);
296
297 RGBForeColor (&fg_color);
298}
299
300
301/* Set background color for subsequent QuickDraw commands. Assume
302 graphic port has already been set. */
303
304static void
305mac_set_backcolor (unsigned long color)
306{
307 RGBColor bg_color;
308
309 bg_color.red = RED16_FROM_ULONG (color);
310 bg_color.green = GREEN16_FROM_ULONG (color);
311 bg_color.blue = BLUE16_FROM_ULONG (color);
312
313 RGBBackColor (&bg_color);
314}
315
316/* Set foreground and background color for subsequent QuickDraw
317 commands. Assume that the graphic port has already been set. */
318
319static void
320mac_set_colors (gc, bg_save)
321 GC gc;
322 RGBColor *bg_save;
323{
324 if (bg_save)
325 GetBackColor (bg_save);
326 mac_set_forecolor (gc->foreground);
327 mac_set_backcolor (gc->background);
328}
329
330/* Mac version of XDrawLine. */ 288/* Mac version of XDrawLine. */
331 289
332static void 290static void
@@ -336,16 +294,12 @@ XDrawLine (display, w, gc, x1, y1, x2, y2)
336 GC gc; 294 GC gc;
337 int x1, y1, x2, y2; 295 int x1, y1, x2, y2;
338{ 296{
339 RGBColor old_bg;
340
341 SetPortWindowPort (w); 297 SetPortWindowPort (w);
342 298
343 mac_set_colors (gc, &old_bg); 299 RGBForeColor (GC_FORE_COLOR (gc));
344 300
345 MoveTo (x1, y1); 301 MoveTo (x1, y1);
346 LineTo (x2, y2); 302 LineTo (x2, y2);
347
348 RGBBackColor (&old_bg);
349} 303}
350 304
351void 305void
@@ -361,7 +315,7 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
361 GetGWorld (&old_port, &old_gdh); 315 GetGWorld (&old_port, &old_gdh);
362 SetGWorld (p, NULL); 316 SetGWorld (p, NULL);
363 317
364 mac_set_colors (gc, NULL); 318 RGBForeColor (GC_FORE_COLOR (gc));
365 319
366 LockPixels (GetGWorldPixMap (p)); 320 LockPixels (GetGWorldPixMap (p));
367 MoveTo (x1, y1); 321 MoveTo (x1, y1);
@@ -371,32 +325,38 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
371 SetGWorld (old_port, old_gdh); 325 SetGWorld (old_port, old_gdh);
372} 326}
373 327
374/* Mac version of XClearArea. */
375 328
376void 329static void
377XClearArea (display, w, x, y, width, height, exposures) 330mac_erase_rectangle (w, gc, x, y, width, height)
378 Display *display;
379 WindowPtr w; 331 WindowPtr w;
332 GC gc;
380 int x, y; 333 int x, y;
381 unsigned int width, height; 334 unsigned int width, height;
382 int exposures;
383{ 335{
384 struct mac_output *mwp = (mac_output *) GetWRefCon (w);
385 Rect r; 336 Rect r;
386 XGCValues xgc;
387 RGBColor old_bg;
388
389 xgc.foreground = mwp->x_compatible.foreground_pixel;
390 xgc.background = mwp->x_compatible.background_pixel;
391 337
392 SetPortWindowPort (w); 338 SetPortWindowPort (w);
393 339
394 mac_set_colors (&xgc, &old_bg); 340 RGBBackColor (GC_BACK_COLOR (gc));
395 SetRect (&r, x, y, x + width, y + height); 341 SetRect (&r, x, y, x + width, y + height);
396 342
397 EraseRect (&r); 343 EraseRect (&r);
398 344
399 RGBBackColor (&old_bg); 345 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
346}
347
348
349/* Mac version of XClearArea. */
350
351void
352XClearArea (display, w, x, y, width, height, exposures)
353 Display *display;
354 WindowPtr w;
355 int x, y;
356 unsigned int width, height;
357 int exposures;
358{
359 mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height);
400} 360}
401 361
402/* Mac version of XClearWindow. */ 362/* Mac version of XClearWindow. */
@@ -406,15 +366,9 @@ XClearWindow (display, w)
406 Display *display; 366 Display *display;
407 WindowPtr w; 367 WindowPtr w;
408{ 368{
409 struct mac_output *mwp = (mac_output *) GetWRefCon (w);
410 XGCValues xgc;
411
412 xgc.foreground = mwp->x_compatible.foreground_pixel;
413 xgc.background = mwp->x_compatible.background_pixel;
414
415 SetPortWindowPort (w); 369 SetPortWindowPort (w);
416 370
417 mac_set_colors (&xgc, NULL); 371 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
418 372
419#if TARGET_API_MAC_CARBON 373#if TARGET_API_MAC_CARBON
420 { 374 {
@@ -442,7 +396,6 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
442{ 396{
443 BitMap bitmap; 397 BitMap bitmap;
444 Rect r; 398 Rect r;
445 RGBColor old_bg;
446 399
447 bitmap.rowBytes = sizeof(unsigned short); 400 bitmap.rowBytes = sizeof(unsigned short);
448 bitmap.baseAddr = (char *)bits; 401 bitmap.baseAddr = (char *)bits;
@@ -450,7 +403,8 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
450 403
451 SetPortWindowPort (w); 404 SetPortWindowPort (w);
452 405
453 mac_set_colors (gc, &old_bg); 406 RGBForeColor (GC_FORE_COLOR (gc));
407 RGBBackColor (GC_BACK_COLOR (gc));
454 SetRect (&r, x, y, x + width, y + height); 408 SetRect (&r, x, y, x + width, y + height);
455 409
456#if TARGET_API_MAC_CARBON 410#if TARGET_API_MAC_CARBON
@@ -463,7 +417,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
463 overlay_p ? srcOr : srcCopy, 0); 417 overlay_p ? srcOr : srcCopy, 0);
464#endif /* not TARGET_API_MAC_CARBON */ 418#endif /* not TARGET_API_MAC_CARBON */
465 419
466 RGBBackColor (&old_bg); 420 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
467} 421}
468 422
469 423
@@ -569,12 +523,16 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
569 char *data; 523 char *data;
570 unsigned int width, height; 524 unsigned int width, height;
571 unsigned long fg, bg; 525 unsigned long fg, bg;
572 unsigned int depth; /* not used */ 526 unsigned int depth;
573{ 527{
574 Pixmap pixmap; 528 Pixmap pixmap;
575 BitMap bitmap; 529 BitMap bitmap;
576 CGrafPtr old_port; 530 CGrafPtr old_port;
577 GDHandle old_gdh; 531 GDHandle old_gdh;
532 static GC gc = NULL; /* not reentrant */
533
534 if (gc == NULL)
535 gc = XCreateGC (display, w, 0, NULL);
578 536
579 pixmap = XCreatePixmap (display, w, width, height, depth); 537 pixmap = XCreatePixmap (display, w, width, height, depth);
580 if (pixmap == NULL) 538 if (pixmap == NULL)
@@ -583,8 +541,10 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
583 GetGWorld (&old_port, &old_gdh); 541 GetGWorld (&old_port, &old_gdh);
584 SetGWorld (pixmap, NULL); 542 SetGWorld (pixmap, NULL);
585 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); 543 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
586 mac_set_forecolor (fg); 544 XSetForeground (display, gc, fg);
587 mac_set_backcolor (bg); 545 XSetBackground (display, gc, bg);
546 RGBForeColor (GC_FORE_COLOR (gc));
547 RGBBackColor (GC_BACK_COLOR (gc));
588 LockPixels (GetGWorldPixMap (pixmap)); 548 LockPixels (GetGWorldPixMap (pixmap));
589#if TARGET_API_MAC_CARBON 549#if TARGET_API_MAC_CARBON
590 CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap), 550 CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap),
@@ -612,16 +572,13 @@ XFillRectangle (display, w, gc, x, y, width, height)
612 unsigned int width, height; 572 unsigned int width, height;
613{ 573{
614 Rect r; 574 Rect r;
615 RGBColor old_bg;
616 575
617 SetPortWindowPort (w); 576 SetPortWindowPort (w);
618 577
619 mac_set_colors (gc, &old_bg); 578 RGBForeColor (GC_FORE_COLOR (gc));
620 SetRect (&r, x, y, x + width, y + height); 579 SetRect (&r, x, y, x + width, y + height);
621 580
622 PaintRect (&r); /* using foreground color of gc */ 581 PaintRect (&r); /* using foreground color of gc */
623
624 RGBBackColor (&old_bg);
625} 582}
626 583
627 584
@@ -640,7 +597,7 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
640 597
641 GetGWorld (&old_port, &old_gdh); 598 GetGWorld (&old_port, &old_gdh);
642 SetGWorld (p, NULL); 599 SetGWorld (p, NULL);
643 mac_set_colors (gc, NULL); 600 RGBForeColor (GC_FORE_COLOR (gc));
644 SetRect (&r, x, y, x + width, y + height); 601 SetRect (&r, x, y, x + width, y + height);
645 602
646 LockPixels (GetGWorldPixMap (p)); 603 LockPixels (GetGWorldPixMap (p));
@@ -663,16 +620,13 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
663 unsigned int width, height; 620 unsigned int width, height;
664{ 621{
665 Rect r; 622 Rect r;
666 RGBColor old_bg;
667 623
668 SetPortWindowPort (w); 624 SetPortWindowPort (w);
669 625
670 mac_set_colors (gc, &old_bg); 626 RGBForeColor (GC_FORE_COLOR (gc));
671 SetRect (&r, x, y, x + width + 1, y + height + 1); 627 SetRect (&r, x, y, x + width + 1, y + height + 1);
672 628
673 FrameRect (&r); /* using foreground color of gc */ 629 FrameRect (&r); /* using foreground color of gc */
674
675 RGBBackColor (&old_bg);
676} 630}
677 631
678 632
@@ -693,7 +647,7 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
693 647
694 GetGWorld (&old_port, &old_gdh); 648 GetGWorld (&old_port, &old_gdh);
695 SetGWorld (p, NULL); 649 SetGWorld (p, NULL);
696 mac_set_colors (gc, NULL); 650 RGBForeColor (GC_FORE_COLOR (gc));
697 SetRect (&r, x, y, x + width + 1, y + height + 1); 651 SetRect (&r, x, y, x + width + 1, y + height + 1);
698 652
699 LockPixels (GetGWorldPixMap (p)); 653 LockPixels (GetGWorldPixMap (p));
@@ -715,9 +669,6 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
715 char *buf; 669 char *buf;
716 int nchars, mode, bytes_per_char; 670 int nchars, mode, bytes_per_char;
717{ 671{
718 RGBColor old_bg;
719
720 SetPortWindowPort (w);
721#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 672#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
722 UInt32 textFlags, savedFlags; 673 UInt32 textFlags, savedFlags;
723 if (!NILP(Vmac_use_core_graphics)) { 674 if (!NILP(Vmac_use_core_graphics)) {
@@ -726,17 +677,22 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
726 } 677 }
727#endif 678#endif
728 679
729 mac_set_colors (gc, &old_bg); 680 SetPortWindowPort (w);
681
682 RGBForeColor (GC_FORE_COLOR (gc));
683 if (mode != srcOr)
684 RGBBackColor (GC_BACK_COLOR (gc));
730 685
731 TextFont (gc->font->mac_fontnum); 686 TextFont (GC_FONT (gc)->mac_fontnum);
732 TextSize (gc->font->mac_fontsize); 687 TextSize (GC_FONT (gc)->mac_fontsize);
733 TextFace (gc->font->mac_fontface); 688 TextFace (GC_FONT (gc)->mac_fontface);
734 TextMode (mode); 689 TextMode (mode);
735 690
736 MoveTo (x, y); 691 MoveTo (x, y);
737 DrawText (buf, 0, nchars * bytes_per_char); 692 DrawText (buf, 0, nchars * bytes_per_char);
738 693
739 RGBBackColor (&old_bg); 694 if (mode != srcOr)
695 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
740#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 696#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
741 if (!NILP(Vmac_use_core_graphics)) 697 if (!NILP(Vmac_use_core_graphics))
742 SwapQDTextFlags(savedFlags); 698 SwapQDTextFlags(savedFlags);
@@ -915,7 +871,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
915 BackColor (whiteColor); 871 BackColor (whiteColor);
916 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 872 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
917 873
918 mac_set_colors (gc, NULL); 874 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
919#endif /* not TARGET_API_MAC_CARBON */ 875#endif /* not TARGET_API_MAC_CARBON */
920} 876}
921 877
@@ -1005,28 +961,37 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1005/* Mac replacement for XChangeGC. */ 961/* Mac replacement for XChangeGC. */
1006 962
1007static void 963static void
1008XChangeGC (void * ignore, XGCValues* gc, unsigned long mask, 964XChangeGC (display, gc, mask, xgcv)
1009 XGCValues *xgcv) 965 Display *display;
966 GC gc;
967 unsigned long mask;
968 XGCValues *xgcv;
1010{ 969{
1011 if (mask & GCForeground) 970 if (mask & GCForeground)
1012 gc->foreground = xgcv->foreground; 971 XSetForeground (display, gc, xgcv->foreground);
1013 if (mask & GCBackground) 972 if (mask & GCBackground)
1014 gc->background = xgcv->background; 973 XSetBackground (display, gc, xgcv->background);
1015 if (mask & GCFont) 974 if (mask & GCFont)
1016 gc->font = xgcv->font; 975 XSetFont (display, gc, xgcv->font);
1017} 976}
1018 977
1019 978
1020/* Mac replacement for XCreateGC. */ 979/* Mac replacement for XCreateGC. */
1021 980
1022XGCValues * 981GC
1023XCreateGC (void * ignore, Window window, unsigned long mask, 982XCreateGC (display, window, mask, xgcv)
1024 XGCValues *xgcv) 983 Display *display;
984 Window window;
985 unsigned long mask;
986 XGCValues *xgcv;
1025{ 987{
1026 XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); 988 GC gc = xmalloc (sizeof (*gc));
1027 bzero (gc, sizeof (XGCValues));
1028 989
1029 XChangeGC (ignore, gc, mask, xgcv); 990 if (gc)
991 {
992 bzero (gc, sizeof (*gc));
993 XChangeGC (display, gc, mask, xgcv);
994 }
1030 995
1031 return gc; 996 return gc;
1032} 997}
@@ -1046,10 +1011,18 @@ XFreeGC (display, gc)
1046/* Mac replacement for XGetGCValues. */ 1011/* Mac replacement for XGetGCValues. */
1047 1012
1048static void 1013static void
1049XGetGCValues (void* ignore, XGCValues *gc, 1014XGetGCValues (display, gc, mask, xgcv)
1050 unsigned long mask, XGCValues *xgcv) 1015 Display *display;
1016 GC gc;
1017 unsigned long mask;
1018 XGCValues *xgcv;
1051{ 1019{
1052 XChangeGC (ignore, xgcv, mask, gc); 1020 if (mask & GCForeground)
1021 xgcv->foreground = gc->xgcv.foreground;
1022 if (mask & GCBackground)
1023 xgcv->background = gc->xgcv.background;
1024 if (mask & GCFont)
1025 xgcv->font = gc->xgcv.font;
1053} 1026}
1054 1027
1055 1028
@@ -1061,7 +1034,13 @@ XSetForeground (display, gc, color)
1061 GC gc; 1034 GC gc;
1062 unsigned long color; 1035 unsigned long color;
1063{ 1036{
1064 gc->foreground = color; 1037 if (gc->xgcv.foreground != color)
1038 {
1039 gc->xgcv.foreground = color;
1040 gc->fore_color.red = RED16_FROM_ULONG (color);
1041 gc->fore_color.green = GREEN16_FROM_ULONG (color);
1042 gc->fore_color.blue = BLUE16_FROM_ULONG (color);
1043 }
1065} 1044}
1066 1045
1067 1046
@@ -1073,7 +1052,25 @@ XSetBackground (display, gc, color)
1073 GC gc; 1052 GC gc;
1074 unsigned long color; 1053 unsigned long color;
1075{ 1054{
1076 gc->background = color; 1055 if (gc->xgcv.background != color)
1056 {
1057 gc->xgcv.background = color;
1058 gc->back_color.red = RED16_FROM_ULONG (color);
1059 gc->back_color.green = GREEN16_FROM_ULONG (color);
1060 gc->back_color.blue = BLUE16_FROM_ULONG (color);
1061 }
1062}
1063
1064
1065/* Mac replacement for XSetFont. */
1066
1067static void
1068XSetFont (display, gc, font)
1069 Display *display;
1070 GC gc;
1071 XFontStruct *font;
1072{
1073 gc->xgcv.font = font;
1077} 1074}
1078 1075
1079 1076
@@ -1120,19 +1117,6 @@ XSetWindowBackground (display, w, color)
1120#endif 1117#endif
1121} 1118}
1122 1119
1123
1124/* Mac replacement for XSetFont. */
1125
1126static void
1127XSetFont (display, gc, font)
1128 Display *display;
1129 GC gc;
1130 XFontStruct *font;
1131{
1132 gc->font = font;
1133}
1134
1135
1136/* x_sync is a no-op on Mac. */ 1120/* x_sync is a no-op on Mac. */
1137void 1121void
1138x_sync (f) 1122x_sync (f)
@@ -1443,7 +1427,6 @@ x_draw_fringe_bitmap (w, row, p)
1443 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1427 struct frame *f = XFRAME (WINDOW_FRAME (w));
1444 Display *display = FRAME_MAC_DISPLAY (f); 1428 Display *display = FRAME_MAC_DISPLAY (f);
1445 WindowPtr window = FRAME_MAC_WINDOW (f); 1429 WindowPtr window = FRAME_MAC_WINDOW (f);
1446 XGCValues gcv;
1447 GC gc = f->output_data.mac->normal_gc; 1430 GC gc = f->output_data.mac->normal_gc;
1448 struct face *face = p->face; 1431 struct face *face = p->face;
1449 int rowY; 1432 int rowY;
@@ -1467,9 +1450,6 @@ x_draw_fringe_bitmap (w, row, p)
1467 1450
1468 if (p->bx >= 0 && !p->overlay_p) 1451 if (p->bx >= 0 && !p->overlay_p)
1469 { 1452 {
1470 XGCValues gcv;
1471 gcv.foreground = face->background;
1472
1473#if 0 /* MAC_TODO: stipple */ 1453#if 0 /* MAC_TODO: stipple */
1474 /* In case the same realized face is used for fringes and 1454 /* In case the same realized face is used for fringes and
1475 for something displayed in the text (e.g. face `region' on 1455 for something displayed in the text (e.g. face `region' on
@@ -1481,9 +1461,7 @@ x_draw_fringe_bitmap (w, row, p)
1481 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); 1461 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
1482#endif 1462#endif
1483 1463
1484 XFillRectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1464 mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny);
1485 &gcv,
1486 p->bx, p->by, p->nx, p->ny);
1487 1465
1488#if 0 /* MAC_TODO: stipple */ 1466#if 0 /* MAC_TODO: stipple */
1489 if (!face->stipple) 1467 if (!face->stipple)
@@ -1494,15 +1472,17 @@ x_draw_fringe_bitmap (w, row, p)
1494 if (p->which) 1472 if (p->which)
1495 { 1473 {
1496 unsigned short *bits = p->bits + p->dh; 1474 unsigned short *bits = p->bits + p->dh;
1475 XGCValues gcv;
1497 1476
1498 gcv.foreground = (p->cursor_p 1477 XGetGCValues (display, face->gc, GCForeground, &gcv);
1499 ? (p->overlay_p ? face->background 1478 XSetForeground (display, face->gc,
1500 : f->output_data.mac->cursor_pixel) 1479 (p->cursor_p
1501 : face->foreground); 1480 ? (p->overlay_p ? face->background
1502 gcv.background = face->background; 1481 : f->output_data.mac->cursor_pixel)
1503 1482 : face->foreground));
1504 mac_draw_bitmap (display, window, &gcv, p->x, p->y, 1483 mac_draw_bitmap (display, window, face->gc, p->x, p->y,
1505 p->wd, p->h, bits, p->overlay_p); 1484 p->wd, p->h, bits, p->overlay_p);
1485 XSetForeground (display, face->gc, gcv.foreground);
1506 } 1486 }
1507 1487
1508 mac_reset_clipping (display, window); 1488 mac_reset_clipping (display, window);
@@ -1980,10 +1960,7 @@ x_clear_glyph_string_rect (s, x, y, w, h)
1980 struct glyph_string *s; 1960 struct glyph_string *s;
1981 int x, y, w, h; 1961 int x, y, w, h;
1982{ 1962{
1983 XGCValues xgcv; 1963 mac_erase_rectangle (s->window, s->gc, x, y, w, h);
1984
1985 xgcv.foreground = s->gc->background;
1986 XFillRectangle (s->display, s->window, &xgcv, x, y, w, h);
1987} 1964}
1988 1965
1989 1966
@@ -2571,27 +2548,29 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2571{ 2548{
2572 XGCValues xgcv; 2549 XGCValues xgcv;
2573 2550
2574 xgcv.foreground = s->face->box_color; 2551 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2552 XSetForeground (s->display, s->gc, s->face->box_color);
2575 mac_set_clip_rectangle (s->display, s->window, clip_rect); 2553 mac_set_clip_rectangle (s->display, s->window, clip_rect);
2576 2554
2577 /* Top. */ 2555 /* Top. */
2578 XFillRectangle (s->display, s->window, &xgcv, 2556 XFillRectangle (s->display, s->window, s->gc,
2579 left_x, top_y, right_x - left_x + 1, width); 2557 left_x, top_y, right_x - left_x + 1, width);
2580 2558
2581 /* Left. */ 2559 /* Left. */
2582 if (left_p) 2560 if (left_p)
2583 XFillRectangle (s->display, s->window, &xgcv, 2561 XFillRectangle (s->display, s->window, s->gc,
2584 left_x, top_y, width, bottom_y - top_y + 1); 2562 left_x, top_y, width, bottom_y - top_y + 1);
2585 2563
2586 /* Bottom. */ 2564 /* Bottom. */
2587 XFillRectangle (s->display, s->window, &xgcv, 2565 XFillRectangle (s->display, s->window, s->gc,
2588 left_x, bottom_y - width + 1, right_x - left_x + 1, width); 2566 left_x, bottom_y - width + 1, right_x - left_x + 1, width);
2589 2567
2590 /* Right. */ 2568 /* Right. */
2591 if (right_p) 2569 if (right_p)
2592 XFillRectangle (s->display, s->window, &xgcv, 2570 XFillRectangle (s->display, s->window, s->gc,
2593 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2571 right_x - width + 1, top_y, width, bottom_y - top_y + 1);
2594 2572
2573 XSetForeground (s->display, s->gc, xgcv.foreground);
2595 mac_reset_clipping (s->display, s->window); 2574 mac_reset_clipping (s->display, s->window);
2596} 2575}
2597 2576
@@ -3010,13 +2989,7 @@ x_draw_stretch_glyph_string (s)
3010 } 2989 }
3011 else 2990 else
3012#endif /* MAC_TODO */ 2991#endif /* MAC_TODO */
3013 { 2992 mac_erase_rectangle (s->window, gc, x, y, w, h);
3014 XGCValues xgcv;
3015 XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv);
3016 XSetForeground (s->display, gc, xgcv.background);
3017 XFillRectangle (s->display, s->window, gc, x, y, w, h);
3018 XSetForeground (s->display, gc, xgcv.foreground);
3019 }
3020 2993
3021 mac_reset_clipping (s->display, s->window); 2994 mac_reset_clipping (s->display, s->window);
3022 } 2995 }
@@ -4567,13 +4540,10 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4567 && XINT (bar->width) == sb_width 4540 && XINT (bar->width) == sb_width
4568 && XINT (bar->height) == height)) 4541 && XINT (bar->height) == height))
4569 { 4542 {
4570 /* Clear areas not covered by the scroll bar because it's not as 4543 /* Since toolkit scroll bars are smaller than the space reserved
4571 wide as the area reserved for it . This makes sure a 4544 for them on the frame, we have to clear "under" them. */
4572 previous mode line display is cleared after C-x 2 C-x 1, for
4573 example. */
4574 int area_width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
4575 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4545 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4576 left, top, area_width, height, 0); 4546 left, top, width, height, 0);
4577 4547
4578#if 0 4548#if 0
4579 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f)) 4549 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
@@ -10151,7 +10121,7 @@ useful for non-standard keyboard layouts. */);
10151 doc: /* t means that when the option-key is held down while pressing the 10121 doc: /* t means that when the option-key is held down while pressing the
10152mouse button, the click will register as mouse-2 and while the 10122mouse button, the click will register as mouse-2 and while the
10153command-key is held down, the click will register as mouse-3. 10123command-key is held down, the click will register as mouse-3.
10154'reverse means that the the option-key will register for mouse-3 10124'reverse means that the option-key will register for mouse-3
10155and the command-key will register for mouse-2. nil means that 10125and the command-key will register for mouse-2. nil means that
10156no emulation should be done and the modifiers should be placed 10126no emulation should be done and the modifiers should be placed
10157on the mouse-1 event. */); 10127on the mouse-1 event. */);
diff --git a/src/macterm.h b/src/macterm.h
index f0846b10fa4..71cd4db82c0 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -149,7 +149,7 @@ struct mac_display_info
149 int smallest_font_height; 149 int smallest_font_height;
150 150
151 /* Reusable Graphics Context for drawing a cursor in a non-default face. */ 151 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
152 XGCValues *scratch_cursor_gc; 152 GC scratch_cursor_gc;
153 153
154 /* These variables describe the range of text currently shown in its 154 /* These variables describe the range of text currently shown in its
155 mouse-face, together with the window they apply to. As long as 155 mouse-face, together with the window they apply to. As long as
@@ -388,7 +388,7 @@ struct mac_output {
388 /* Relief GCs, colors etc. */ 388 /* Relief GCs, colors etc. */
389 struct relief 389 struct relief
390 { 390 {
391 XGCValues *gc; 391 GC gc;
392 unsigned long pixel; 392 unsigned long pixel;
393 int allocated_p; 393 int allocated_p;
394 } 394 }
@@ -601,6 +601,8 @@ EXFUN (Fx_display_color_p, 1);
601EXFUN (Fx_display_grayscale_p, 1); 601EXFUN (Fx_display_grayscale_p, 1);
602EXFUN (Fx_display_planes, 1); 602EXFUN (Fx_display_planes, 1);
603extern void x_free_gcs P_ ((struct frame *)); 603extern void x_free_gcs P_ ((struct frame *));
604extern int XParseGeometry P_ ((char *, int *, int *, unsigned int *,
605 unsigned int *));
604 606
605/* Defined in macterm.c. */ 607/* Defined in macterm.c. */
606 608
@@ -614,6 +616,7 @@ extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
614 unsigned long, unsigned long, 616 unsigned long, unsigned long,
615 unsigned int)); 617 unsigned int));
616extern void XFreePixmap P_ ((Display *, Pixmap)); 618extern void XFreePixmap P_ ((Display *, Pixmap));
619extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *));
617extern void XSetForeground P_ ((Display *, GC, unsigned long)); 620extern void XSetForeground P_ ((Display *, GC, unsigned long));
618extern void XSetBackground P_ ((Display *, GC, unsigned long)); 621extern void XSetBackground P_ ((Display *, GC, unsigned long));
619extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); 622extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
diff --git a/src/minibuf.c b/src/minibuf.c
index cb843375e82..2a54fae8b01 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -349,7 +349,7 @@ BUFFER can be a buffer or a buffer name. */)
349DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end, 349DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
350 Sminibuffer_prompt_end, 0, 0, 0, 350 Sminibuffer_prompt_end, 0, 0, 0,
351 doc: /* Return the buffer position of the end of the minibuffer prompt. 351 doc: /* Return the buffer position of the end of the minibuffer prompt.
352Return (point-min) if current buffer is not a mini-buffer. */) 352Return (point-min) if current buffer is not a minibuffer. */)
353 () 353 ()
354{ 354{
355 /* This function is written to be most efficient when there's a prompt. */ 355 /* This function is written to be most efficient when there's a prompt. */
@@ -1014,7 +1014,7 @@ DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0,
1014Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS 1014Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS
1015is a string to insert in the minibuffer before reading. 1015is a string to insert in the minibuffer before reading.
1016\(INITIAL-CONTENTS can also be a cons of a string and an integer. Such 1016\(INITIAL-CONTENTS can also be a cons of a string and an integer. Such
1017arguments are used as in `read-from-minibuffer') */) 1017arguments are used as in `read-from-minibuffer'.) */)
1018 (prompt, initial_contents) 1018 (prompt, initial_contents)
1019 Lisp_Object prompt, initial_contents; 1019 Lisp_Object prompt, initial_contents;
1020{ 1020{
@@ -1758,7 +1758,7 @@ the values STRING, PREDICATE and `lambda'. */)
1758 || NILP (alist)) 1758 || NILP (alist))
1759 { 1759 {
1760 tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil); 1760 tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil);
1761 if NILP (tem) 1761 if (NILP (tem))
1762 return Qnil; 1762 return Qnil;
1763 } 1763 }
1764 else if (VECTORP (alist)) 1764 else if (VECTORP (alist))
diff --git a/src/search.c b/src/search.c
index 387abacc161..3b212e007e8 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3047,6 +3047,7 @@ syms_of_search ()
3047 searchbufs[i].regexp = Qnil; 3047 searchbufs[i].regexp = Qnil;
3048 searchbufs[i].whitespace_regexp = Qnil; 3048 searchbufs[i].whitespace_regexp = Qnil;
3049 staticpro (&searchbufs[i].regexp); 3049 staticpro (&searchbufs[i].regexp);
3050 staticpro (&searchbufs[i].whitespace_regexp);
3050 searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]); 3051 searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]);
3051 } 3052 }
3052 searchbuf_head = &searchbufs[0]; 3053 searchbuf_head = &searchbufs[0];
diff --git a/src/syntax.c b/src/syntax.c
index 0ceab9d6af8..a859250b15a 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3391,6 +3391,14 @@ syms_of_syntax ()
3391 3391
3392 staticpro (&Vsyntax_code_object); 3392 staticpro (&Vsyntax_code_object);
3393 3393
3394 staticpro (&gl_state.object);
3395 staticpro (&gl_state.global_code);
3396 staticpro (&gl_state.current_syntax_table);
3397 staticpro (&gl_state.old_prop);
3398
3399 /* Defined in regex.c */
3400 staticpro (&re_match_object);
3401
3394 Qscan_error = intern ("scan-error"); 3402 Qscan_error = intern ("scan-error");
3395 staticpro (&Qscan_error); 3403 staticpro (&Qscan_error);
3396 Fput (Qscan_error, Qerror_conditions, 3404 Fput (Qscan_error, Qerror_conditions,
diff --git a/src/textprop.c b/src/textprop.c
index 718051e38f2..ec75c6907ae 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -719,7 +719,7 @@ it finds a change in some text property, or the beginning or end of an
719overlay, and returns the position of that. 719overlay, and returns the position of that.
720If none is found, the function returns (point-max). 720If none is found, the function returns (point-max).
721 721
722If the optional third argument LIMIT is non-nil, don't search 722If the optional second argument LIMIT is non-nil, don't search
723past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 723past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
724 (position, limit) 724 (position, limit)
725 Lisp_Object position, limit; 725 Lisp_Object position, limit;
@@ -744,7 +744,7 @@ finds a change in some text property, or the beginning or end of an
744overlay, and returns the position of that. 744overlay, and returns the position of that.
745If none is found, the function returns (point-max). 745If none is found, the function returns (point-max).
746 746
747If the optional third argument LIMIT is non-nil, don't search 747If the optional second argument LIMIT is non-nil, don't search
748past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 748past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
749 (position, limit) 749 (position, limit)
750 Lisp_Object position, limit; 750 Lisp_Object position, limit;
diff --git a/src/w32.c b/src/w32.c
index 77959037913..25283c3b4c6 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA.
20 20
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
22*/ 22*/
23
24
25#include <stddef.h> /* for offsetof */ 23#include <stddef.h> /* for offsetof */
26#include <stdlib.h> 24#include <stdlib.h>
27#include <stdio.h> 25#include <stdio.h>
@@ -73,6 +71,7 @@ Boston, MA 02110-1301, USA.
73#define _ANONYMOUS_STRUCT 71#define _ANONYMOUS_STRUCT
74#endif 72#endif
75#include <windows.h> 73#include <windows.h>
74#include <shlobj.h>
76 75
77#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ 76#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */
78#include <sys/socket.h> 77#include <sys/socket.h>
@@ -100,6 +99,9 @@ Boston, MA 02110-1301, USA.
100#include "w32heap.h" 99#include "w32heap.h"
101#include "systime.h" 100#include "systime.h"
102 101
102typedef HRESULT (WINAPI * ShGetFolderPath_fn)
103 (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
104
103void globals_of_w32 (); 105void globals_of_w32 ();
104 106
105extern Lisp_Object Vw32_downcase_file_names; 107extern Lisp_Object Vw32_downcase_file_names;
@@ -903,7 +905,9 @@ init_environment (char ** argv)
903 static const char * const tempdirs[] = { 905 static const char * const tempdirs[] = {
904 "$TMPDIR", "$TEMP", "$TMP", "c:/" 906 "$TMPDIR", "$TEMP", "$TMP", "c:/"
905 }; 907 };
908
906 int i; 909 int i;
910
907 const int imax = sizeof (tempdirs) / sizeof (tempdirs[0]); 911 const int imax = sizeof (tempdirs) / sizeof (tempdirs[0]);
908 912
909 /* Make sure they have a usable $TMPDIR. Many Emacs functions use 913 /* Make sure they have a usable $TMPDIR. Many Emacs functions use
@@ -942,6 +946,8 @@ init_environment (char ** argv)
942 LPBYTE lpval; 946 LPBYTE lpval;
943 DWORD dwType; 947 DWORD dwType;
944 char locale_name[32]; 948 char locale_name[32];
949 struct stat ignored;
950 char default_home[MAX_PATH];
945 951
946 static struct env_entry 952 static struct env_entry
947 { 953 {
@@ -964,6 +970,35 @@ init_environment (char ** argv)
964 {"LANG", NULL}, 970 {"LANG", NULL},
965 }; 971 };
966 972
973 /* For backwards compatibility, check if a .emacs file exists in C:/
974 If not, then we can try to default to the appdata directory under the
975 user's profile, which is more likely to be writable. */
976 if (stat ("C:/.emacs", &ignored) < 0)
977 {
978 HRESULT profile_result;
979 /* Dynamically load ShGetFolderPath, as it won't exist on versions
980 of Windows 95 and NT4 that have not been updated to include
981 MSIE 5. Also we don't link with shell32.dll by default. */
982 HMODULE shell32_dll;
983 ShGetFolderPath_fn get_folder_path;
984 shell32_dll = GetModuleHandle ("shell32.dll");
985 get_folder_path = (ShGetFolderPath_fn)
986 GetProcAddress (shell32_dll, "SHGetFolderPathA");
987
988 if (get_folder_path != NULL)
989 {
990 profile_result = get_folder_path (NULL, CSIDL_APPDATA, NULL,
991 0, default_home);
992
993 /* If we can't get the appdata dir, revert to old behaviour. */
994 if (profile_result == S_OK)
995 env_vars[0].def_value = default_home;
996 }
997
998 /* Unload shell32.dll, it is not needed anymore. */
999 FreeLibrary (shell32_dll);
1000 }
1001
967 /* Get default locale info and use it for LANG. */ 1002 /* Get default locale info and use it for LANG. */
968 if (GetLocaleInfo (LOCALE_USER_DEFAULT, 1003 if (GetLocaleInfo (LOCALE_USER_DEFAULT,
969 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, 1004 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
diff --git a/src/w32fns.c b/src/w32fns.c
index 236aa81d7a8..6bcb668aa8b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -154,7 +154,7 @@ int display_hourglass_p;
154 over text or in the modeline. */ 154 over text or in the modeline. */
155 155
156Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; 156Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
157Lisp_Object Vx_hourglass_pointer_shape, Vx_window_horizontal_drag_shape, Vx_hand_shape; 157Lisp_Object Vx_hourglass_pointer_shape, Vx_window_horizontal_drag_shape;
158 158
159/* The shape when over mouse-sensitive text. */ 159/* The shape when over mouse-sensitive text. */
160 160
@@ -8822,6 +8822,8 @@ versions of Windows) characters. */);
8822 staticpro (&Qw32_charset_ansi); 8822 staticpro (&Qw32_charset_ansi);
8823 Qw32_charset_ansi = intern ("w32-charset-ansi"); 8823 Qw32_charset_ansi = intern ("w32-charset-ansi");
8824 staticpro (&Qw32_charset_symbol); 8824 staticpro (&Qw32_charset_symbol);
8825 Qw32_charset_default = intern ("w32-charset-default");
8826 staticpro (&Qw32_charset_default);
8825 Qw32_charset_symbol = intern ("w32-charset-symbol"); 8827 Qw32_charset_symbol = intern ("w32-charset-symbol");
8826 staticpro (&Qw32_charset_shiftjis); 8828 staticpro (&Qw32_charset_shiftjis);
8827 Qw32_charset_shiftjis = intern ("w32-charset-shiftjis"); 8829 Qw32_charset_shiftjis = intern ("w32-charset-shiftjis");
diff --git a/src/w32proc.c b/src/w32proc.c
index 0e3f8f2fd47..7e344985f4e 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -2146,6 +2146,8 @@ syms_of_ntproc ()
2146{ 2146{
2147 Qhigh = intern ("high"); 2147 Qhigh = intern ("high");
2148 Qlow = intern ("low"); 2148 Qlow = intern ("low");
2149 staticpro (&Qhigh);
2150 staticpro (&Qlow);
2149 2151
2150#ifdef HAVE_SOCKETS 2152#ifdef HAVE_SOCKETS
2151 defsubr (&Sw32_has_winsock); 2153 defsubr (&Sw32_has_winsock);
@@ -2241,6 +2243,9 @@ the truename of a file can be slow. */);
2241Note that this option is only useful for files on NTFS volumes, where hard links 2243Note that this option is only useful for files on NTFS volumes, where hard links
2242are supported. Moreover, it slows down `file-attributes' noticeably. */); 2244are supported. Moreover, it slows down `file-attributes' noticeably. */);
2243 Vw32_get_true_file_attributes = Qt; 2245 Vw32_get_true_file_attributes = Qt;
2246
2247 staticpro (&Vw32_valid_locale_ids);
2248 staticpro (&Vw32_valid_codepages);
2244} 2249}
2245/* end of ntproc.c */ 2250/* end of ntproc.c */
2246 2251
diff --git a/src/window.c b/src/window.c
index 9ae9bbf55f4..d926cedc96a 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6246,33 +6246,33 @@ Second arg LEFT-WIDTH specifies the number of character cells to
6246reserve for the left marginal area. Optional third arg RIGHT-WIDTH 6246reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6247does the same for the right marginal area. A nil width parameter 6247does the same for the right marginal area. A nil width parameter
6248means no margin. */) 6248means no margin. */)
6249 (window, left, right) 6249 (window, left_width, right_width)
6250 Lisp_Object window, left, right; 6250 Lisp_Object window, left_width, right_width;
6251{ 6251{
6252 struct window *w = decode_window (window); 6252 struct window *w = decode_window (window);
6253 6253
6254 /* Translate negative or zero widths to nil. 6254 /* Translate negative or zero widths to nil.
6255 Margins that are too wide have to be checked elsewhere. */ 6255 Margins that are too wide have to be checked elsewhere. */
6256 6256
6257 if (!NILP (left)) 6257 if (!NILP (left_width))
6258 { 6258 {
6259 CHECK_NUMBER (left); 6259 CHECK_NUMBER (left_width);
6260 if (XINT (left) <= 0) 6260 if (XINT (left_width) <= 0)
6261 left = Qnil; 6261 left_width = Qnil;
6262 } 6262 }
6263 6263
6264 if (!NILP (right)) 6264 if (!NILP (right_width))
6265 { 6265 {
6266 CHECK_NUMBER (right); 6266 CHECK_NUMBER (right_width);
6267 if (XINT (right) <= 0) 6267 if (XINT (right_width) <= 0)
6268 right = Qnil; 6268 right_width = Qnil;
6269 } 6269 }
6270 6270
6271 if (!EQ (w->left_margin_cols, left) 6271 if (!EQ (w->left_margin_cols, left_width)
6272 || !EQ (w->right_margin_cols, right)) 6272 || !EQ (w->right_margin_cols, right_width))
6273 { 6273 {
6274 w->left_margin_cols = left; 6274 w->left_margin_cols = left_width;
6275 w->right_margin_cols = right; 6275 w->right_margin_cols = right_width;
6276 6276
6277 adjust_window_margins (w); 6277 adjust_window_margins (w);
6278 6278
@@ -6317,22 +6317,22 @@ the command `set-fringe-style'.
6317If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes 6317If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
6318outside of the display margins. By default, fringes are drawn between 6318outside of the display margins. By default, fringes are drawn between
6319display marginal areas and the text area. */) 6319display marginal areas and the text area. */)
6320 (window, left, right, outside_margins) 6320 (window, left_width, right_width, outside_margins)
6321 Lisp_Object window, left, right, outside_margins; 6321 Lisp_Object window, left_width, right_width, outside_margins;
6322{ 6322{
6323 struct window *w = decode_window (window); 6323 struct window *w = decode_window (window);
6324 6324
6325 if (!NILP (left)) 6325 if (!NILP (left_width))
6326 CHECK_NATNUM (left); 6326 CHECK_NATNUM (left_width);
6327 if (!NILP (right)) 6327 if (!NILP (right_width))
6328 CHECK_NATNUM (right); 6328 CHECK_NATNUM (right_width);
6329 6329
6330 if (!EQ (w->left_fringe_width, left) 6330 if (!EQ (w->left_fringe_width, left_width)
6331 || !EQ (w->right_fringe_width, right) 6331 || !EQ (w->right_fringe_width, right_width)
6332 || !EQ (w->fringes_outside_margins, outside_margins)) 6332 || !EQ (w->fringes_outside_margins, outside_margins))
6333 { 6333 {
6334 w->left_fringe_width = left; 6334 w->left_fringe_width = left_width;
6335 w->right_fringe_width = right; 6335 w->right_fringe_width = right_width;
6336 w->fringes_outside_margins = outside_margins; 6336 w->fringes_outside_margins = outside_margins;
6337 6337
6338 adjust_window_margins (w); 6338 adjust_window_margins (w);
diff --git a/src/xdisp.c b/src/xdisp.c
index d1229b3cb9f..f1316969577 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5967,6 +5967,15 @@ next_element_from_composition (it)
5967 Moving an iterator without producing glyphs 5967 Moving an iterator without producing glyphs
5968 ***********************************************************************/ 5968 ***********************************************************************/
5969 5969
5970/* Check if iterator is at a position corresponding to a valid buffer
5971 position after some move_it_ call. */
5972
5973#define IT_POS_VALID_AFTER_MOVE_P(it) \
5974 ((it)->method == GET_FROM_STRING \
5975 ? IT_STRING_CHARPOS (*it) == 0 \
5976 : 1)
5977
5978
5970/* Move iterator IT to a specified buffer or X position within one 5979/* Move iterator IT to a specified buffer or X position within one
5971 line on the display without producing glyphs. 5980 line on the display without producing glyphs.
5972 5981
@@ -6490,7 +6499,7 @@ move_it_vertically_backward (it, dy)
6490 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1, 6499 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1,
6491 MOVE_TO_POS | MOVE_TO_VPOS); 6500 MOVE_TO_POS | MOVE_TO_VPOS);
6492 } 6501 }
6493 while (it2.method != GET_FROM_BUFFER); 6502 while (!IT_POS_VALID_AFTER_MOVE_P (&it2));
6494 xassert (IT_CHARPOS (*it) >= BEGV); 6503 xassert (IT_CHARPOS (*it) >= BEGV);
6495 it3 = it2; 6504 it3 = it2;
6496 6505
@@ -6690,7 +6699,7 @@ move_it_by_lines (it, dvpos, need_y_p)
6690 else if (dvpos > 0) 6699 else if (dvpos > 0)
6691 { 6700 {
6692 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS); 6701 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS);
6693 if (it->method != GET_FROM_BUFFER) 6702 if (!IT_POS_VALID_AFTER_MOVE_P (it))
6694 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS); 6703 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS);
6695 } 6704 }
6696 else 6705 else
@@ -6712,13 +6721,13 @@ move_it_by_lines (it, dvpos, need_y_p)
6712 reseat (it, it->current.pos, 1); 6721 reseat (it, it->current.pos, 1);
6713 6722
6714 /* Move further back if we end up in a string or an image. */ 6723 /* Move further back if we end up in a string or an image. */
6715 while (it->method != GET_FROM_BUFFER) 6724 while (!IT_POS_VALID_AFTER_MOVE_P (it))
6716 { 6725 {
6717 /* First try to move to start of display line. */ 6726 /* First try to move to start of display line. */
6718 dvpos += it->vpos; 6727 dvpos += it->vpos;
6719 move_it_vertically_backward (it, 0); 6728 move_it_vertically_backward (it, 0);
6720 dvpos -= it->vpos; 6729 dvpos -= it->vpos;
6721 if (it->method == GET_FROM_BUFFER) 6730 if (IT_POS_VALID_AFTER_MOVE_P (it))
6722 break; 6731 break;
6723 /* If start of line is still in string or image, 6732 /* If start of line is still in string or image,
6724 move further back. */ 6733 move further back. */
@@ -10182,7 +10191,9 @@ select_frame_for_redisplay (frame)
10182 (BUFFER_LOCAL_VALUEP (val) 10191 (BUFFER_LOCAL_VALUEP (val)
10183 || SOME_BUFFER_LOCAL_VALUEP (val))) 10192 || SOME_BUFFER_LOCAL_VALUEP (val)))
10184 && XBUFFER_LOCAL_VALUE (val)->check_frame) 10193 && XBUFFER_LOCAL_VALUE (val)->check_frame)
10185 Fsymbol_value (sym); 10194 /* Use find_symbol_value rather than Fsymbol_value
10195 to avoid an error if it is void. */
10196 find_symbol_value (sym);
10186 10197
10187 for (tail = XFRAME (old)->param_alist; CONSP (tail); tail = XCDR (tail)) 10198 for (tail = XFRAME (old)->param_alist; CONSP (tail); tail = XCDR (tail))
10188 if (CONSP (XCAR (tail)) 10199 if (CONSP (XCAR (tail))
@@ -10193,7 +10204,7 @@ select_frame_for_redisplay (frame)
10193 (BUFFER_LOCAL_VALUEP (val) 10204 (BUFFER_LOCAL_VALUEP (val)
10194 || SOME_BUFFER_LOCAL_VALUEP (val))) 10205 || SOME_BUFFER_LOCAL_VALUEP (val)))
10195 && XBUFFER_LOCAL_VALUE (val)->check_frame) 10206 && XBUFFER_LOCAL_VALUE (val)->check_frame)
10196 Fsymbol_value (sym); 10207 find_symbol_value (sym);
10197} 10208}
10198 10209
10199 10210
@@ -10267,6 +10278,16 @@ redisplay_internal (preserve_echo_area)
10267 ++redisplaying_p; 10278 ++redisplaying_p;
10268 specbind (Qinhibit_free_realized_faces, Qnil); 10279 specbind (Qinhibit_free_realized_faces, Qnil);
10269 10280
10281 {
10282 Lisp_Object tail, frame;
10283
10284 FOR_EACH_FRAME (tail, frame)
10285 {
10286 struct frame *f = XFRAME (frame);
10287 f->already_hscrolled_p = 0;
10288 }
10289 }
10290
10270 retry: 10291 retry:
10271 pause = 0; 10292 pause = 0;
10272 reconsider_clip_changes (w, current_buffer); 10293 reconsider_clip_changes (w, current_buffer);
@@ -10701,8 +10722,12 @@ redisplay_internal (preserve_echo_area)
10701 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f)) 10722 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
10702 { 10723 {
10703 /* See if we have to hscroll. */ 10724 /* See if we have to hscroll. */
10704 if (hscroll_windows (f->root_window)) 10725 if (!f->already_hscrolled_p)
10705 goto retry; 10726 {
10727 f->already_hscrolled_p = 1;
10728 if (hscroll_windows (f->root_window))
10729 goto retry;
10730 }
10706 10731
10707 /* Prevent various kinds of signals during display 10732 /* Prevent various kinds of signals during display
10708 update. stdio is not robust about handling 10733 update. stdio is not robust about handling
diff --git a/src/xfaces.c b/src/xfaces.c
index 1e56955a03a..45379c7dd8c 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -783,8 +783,6 @@ x_free_gc (f, gc)
783#ifdef MAC_OS 783#ifdef MAC_OS
784/* Mac OS emulation of GCs */ 784/* Mac OS emulation of GCs */
785 785
786extern XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
787
788static INLINE GC 786static INLINE GC
789x_create_gc (f, mask, xgcv) 787x_create_gc (f, mask, xgcv)
790 struct frame *f; 788 struct frame *f;
@@ -3988,7 +3986,7 @@ Value is a vector of face attributes. */)
3988DEFUN ("internal-lisp-face-p", Finternal_lisp_face_p, 3986DEFUN ("internal-lisp-face-p", Finternal_lisp_face_p,
3989 Sinternal_lisp_face_p, 1, 2, 0, 3987 Sinternal_lisp_face_p, 1, 2, 0,
3990 doc: /* Return non-nil if FACE names a face. 3988 doc: /* Return non-nil if FACE names a face.
3991If optional second parameter FRAME is non-nil, check for the 3989If optional second argument FRAME is non-nil, check for the
3992existence of a frame-local face with name FACE on that frame. 3990existence of a frame-local face with name FACE on that frame.
3993Otherwise check for the existence of a global face. */) 3991Otherwise check for the existence of a global face. */)
3994 (face, frame) 3992 (face, frame)