aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-11-22 11:06:39 +0000
committerKaroly Lorentey2004-11-22 11:06:39 +0000
commit71925ac335f7c3b1fd97fba98cb5b9b4f03a6e23 (patch)
tree63f61c3bebc83c114c16f31dd4ac2b9c0fe17c7d /src
parente417405015c93c81641f5c4a33ec898b5c353772 (diff)
parent83aebfe62204109f19ef7dcca5429c1ddad21c57 (diff)
downloademacs-71925ac335f7c3b1fd97fba98cb5b9b4f03a6e23.tar.gz
emacs-71925ac335f7c3b1fd97fba98cb5b9b4f03a6e23.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-694 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-695 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-696 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-697 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-698 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-699 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-700 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-701 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-702 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-703 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-704 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-705 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-706 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-707 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-708 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-711 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-712 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-713 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-72 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-73 Merge from emacs--cvs-trunk--0 git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-268
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog276
-rw-r--r--src/callint.c2
-rw-r--r--src/dispextern.h1
-rw-r--r--src/eval.c2
-rw-r--r--src/fns.c34
-rw-r--r--src/frame.c3
-rw-r--r--src/fringe.c16
-rw-r--r--src/gtkutil.c227
-rw-r--r--src/indent.c50
-rw-r--r--src/keyboard.c2
-rw-r--r--src/keymap.c12
-rw-r--r--src/lisp.h5
-rw-r--r--src/macterm.c19
-rw-r--r--src/minibuf.c56
-rw-r--r--src/regex.c73
-rw-r--r--src/search.c30
-rw-r--r--src/w32term.c19
-rw-r--r--src/window.c43
-rw-r--r--src/xdisp.c149
-rw-r--r--src/xfns.c46
-rw-r--r--src/xmenu.c187
-rw-r--r--src/xterm.c19
-rw-r--r--src/xterm.h2
23 files changed, 906 insertions, 367 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cc9e71290d5..0d74afca197 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,226 @@
12004-11-21 Kim F. Storm <storm@cua.dk>
2
3 * xdisp.c (erase_phys_cursor): Clear hollow cursor inside TEXT_AREA.
4
5 * xterm.c (x_clip_to_row): Add area arg. Callers changed.
6 (x_draw_hollow_cursor, x_draw_bar_cursor): Clip to TEXT_AREA.
7
8 * w32term.c (w32_clip_to_row): Add area arg. Callers changed.
9 (x_draw_hollow_cursor, x_draw_bar_cursor): Clip to TEXT_AREA.
10
11 * macterm.c (x_clip_to_row): Add area arg. Callers changed.
12 (x_draw_hollow_cursor, x_draw_bar_cursor): Clip to TEXT_AREA.
13
14 * xdisp.c (move_it_in_display_line_to, display_line): Restore
15 saved_face_id if overflow-newline-into-fringe is enabled and line
16 is continued before or in middle of element from display vector.
17
18 * indent.c (Fvertical_motion): Fix last change. Use another
19 method to detect if iterator moved too far ahead after reseat.
20
21 * xdisp.c (IT_EXPAND_MATRIX_WIDTH): New macro. Do not
22 expand matrix width for overflow in zero-width area.
23 (append_glyph, append_composite_glyph, produce_image_glyph)
24 (append_stretch_glyph): Use it to avoid loop in redisplay.
25 (note_mode_line_or_margin_highlight): Don't let help-echo from
26 string override help-echo from image map.
27
282004-11-20 Luc Teirlinck <teirllm@auburn.edu>
29
30 * fns.c (Fyes_or_no_p): Call Fread_from_minibuffer with extra
31 argument.
32 * callint.c (Fcall_interactively): Ditto.
33
342004-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
35
36 * minibuf.c (Fminibuffer_complete_and_exit):
37 Fixup the case of the completed value, for case-indep completion.
38
392004-11-20 Richard M. Stallman <rms@gnu.org>
40
41 * lisp.h (Fread_from_minibuffer): Add arg in decl.
42
43 * minibuf.c (read_minibuf): New arg KEEP_ALL. Callers changed.
44 (Fread_from_minibuffer): New arg KEEP_ALL. Callers changed.
45
46 * search.c (Vsearch_spaces_regexp):
47 Renamed from Vsearch_whitespace_regexp. All uses changed.
48
492004-11-20 Thien-Thi Nguyen <ttn@gnu.org>
50
51 * eval.c (init_eval_once): Increase `max_specpdl_size' to 650.
52
532004-11-19 Richard M. Stallman <rms@gnu.org>
54
55 * search.c (Vsearch_whitespace_regexp): New variable.
56 (syms_of_search): Defvar it.
57 (compile_pattern_1): Call re_set_whitespace_regexp with it.
58 (search_buffer): No regexp is trivial if Vsearch_whitespace_regexp
59 is non-nil.
60 (struct regexp_cache): New element whitespace_regexp.
61 (syms_of_search): Initialize whitespace_regexp elements.
62 (compile_pattern): Compare whitespace_regexp elements.
63 (compile_pattern_1): Set whitespace_regexp elements.
64
65 * regex.c (regex_compile): Substitute whitespace_regexp
66 for spaces, if it is nonzero.
67 (whitespace_regexp): New variable.
68 (re_set_whitespace_regexp): New function.
69
702004-11-19 Kim F. Storm <storm@cua.dk>
71
72 * indent.c (Fvertical_motion): Fix last change.
73
742004-11-18 Kim F. Storm <storm@cua.dk>
75
76 * indent.c (Fvertical_motion): Undo 2004-11-16 change.
77 Instead, move back again if reseating moves too far ahead.
78
792004-11-17 Luc Teirlinck <teirllm@auburn.edu>
80
81 * xdisp.c (message3): Call clear_message.
82
832004-11-17 Kim F. Storm <storm@cua.dk>
84
85 * xdisp.c (erase_phys_cursor): Adjust cursor row visible height.
86
872004-11-16 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
88
89 * gtkutil.c (xg_get_file_name): Fix typo in
90 HAVE_GTK_FILE_SELECTION_NEW.
91
92 * xmenu.c (x_menu_in_use): Remove.
93 (x_menu_set_in_use): Also set popup_activated_flag.
94
95 * xfns.c (Fx_file_dialog): Call popup_activated instead of
96 x_menu_in_use. Call x_menu_set_in_use in Motif version also.
97
98 * xterm.h: (x_menu_in_use): Remove.
99
1002004-11-16 Richard M. Stallman <rms@gnu.org>
101
102 * keymap.c (Fmap_keymap): New arg SORT-FIRST.
103 Use map-keymap-internal to implement that.
104
105 * indent.c (Fvertical_motion): In batch mode, use vmotion directly.
106
1072004-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
108
109 * xdisp.c (get_glyph_string_clip_rect, init_glyph_string): Check it's
110 a window before using XWINDOW.
111
112 * window.c (make_window, Fselect_window, make_dummy_parent)
113 (save_window_save):
114 * frame.c (make_frame):
115 * fns.c (concat): Avoid side-effects inside XSETFASTINT's arguments.
116
117 * lisp.h (NILP): Use EQ rather than XFASTINT.
118
1192004-11-16 Kim F. Storm <storm@cua.dk>
120
121 * fringe.c (Fdefine_fringe_bitmap): Always set 'h'. Simplify.
122
123 * indent.c (Fvertical_motion): Fix last change. Only reseat when
124 moving backwards.
125
1262004-11-16 Luc Teirlinck <teirllm@auburn.edu>
127
128 * dispextern.h: Extern reseat_at_previous_visible_line_start.
129
1302004-11-16 Kenichi Handa <handa@m17n.org>
131
132 * xdisp.c (display_mode_element): Fix previous change (calculate
133 end position of substring to display correctly).
134
1352004-11-16 Kim F. Storm <storm@cua.dk>
136
137 * keyboard.c (Fposn_at_point): Remove extra */ after doc string.
138 Reported by Andrew M. Scott.
139
1402004-11-15 Kim F. Storm <storm@cua.dk>
141
142 * fns.c (Fsafe_plist_get): New defun.
143 (syms_of_fns): Defsubr it.
144
145 * lisp.h (Fsafe_plist_get): Add EXFUN.
146
147 * xdisp.c (store_mode_line_string, produce_stretch_glyph):
148 Use Fsafe_plist_get.
149 (note_mode_line_or_margin_highlight, note_mouse_highlight):
150 Fix image map element parsing. Use Fsafe_plist_get.
151
1522004-11-15 Richard M. Stallman <rms@gnu.org>
153
154 * xdisp.c (get_next_display_element): Fix previous change.
155
1562004-11-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
157
158 * window.c (shrink_windows): Handle special case of one window left
159 when trying to shrink the final reminder. Grow windows if
160 total_removed is less than total_shrink.
161
162 * xmenu.c (pop_down_menu): Remove global variable current_menu,
163 extract pointer from arg with XSAVE_VALUE.
164 (create_and_show_popup_menu, create_and_show_dialog, xmenu_show):
165 Construct arg to record_unwind_protect with make_save_value.
166
1672004-11-13 Richard M. Stallman <rms@gnu.org>
168
169 * xdisp.c (reseat_at_previous_visible_line_start): No longer static.
170 (get_next_display_element): Fix previous change to apply only to \n.
171
172 * indent.c (Fvertical_motion): Scan to PT from start of line to
173 make iterator consistent.
174
175 * minibuf.c (syms_of_minibuf) <completion-ignore-case>: Doc fix.
176
1772004-11-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
178
179 * gtkutil.c (pop_down_file_dialog): Add BLOCK_INPUT.
180
181 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
182 Record unwind with clean_up_file_dialog.
183
184 * xterm.h (x_menu_in_use, x_menu_set_in_use, x_menu_wait_for_event):
185 Declare.
186
187 * xmenu.c (x_menu_in_use, x_menu_set_in_use): New functions.
188
1892004-11-13 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
190
191 * gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
192 (xg_file_sel_destroy): Remove.
193 (xg_file_response_cb, pop_down_file_dialog)
194 (xg_get_file_name_from_chooser, xg_get_file_name_from_selector):
195 New functions.
196 (xg_get_file_with_chooser, xg_get_file_with_selection):
197 Take new arg func, set it to xg_get_file_name_from_chooser/selector.
198 Move common code to xg_get_file_name. Return widget created.
199 (xg_get_file_name): Set name, transient for, modal and destroy
200 with parent here. Connect response signal to xg_file_response_cb,
201 connect delete-event to gtk_true. Record pop_down_file_dialog
202 for unwind. Do event loop and call x_menu_wait_for_event in loop.
203 (xg_create_widget): Make dialogs modal.
204
205 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
206 Lisp_Object.
207 (popup_get_selection): Move unwind protect ...
208 (create_and_show_popup_menu, create_and_show_dialog): ... to here.
209 Move destroy of widget to pop_down_menu.
210 (popup_widget_loop): Move unwind protect ...
211 (create_and_show_popup_menu, create_and_show_dialog): ... to here.
212 Move destroy of widget to pop_down_menu.
213 (pop_down_menu): BLOCK_INPUT and destroy widget/window.
214 (xmenu_show): Record unwind pop_down_menu. Move XMenuDestroy,
215 x_mouse_leave and grabbed = 0 to pop_down_menu.
216
2172004-11-13 Kim F. Storm <storm@cua.dk>
218
219 * xdisp.c (make_cursor_line_fully_visible_p): New variable.
220 (syms_of_xdisp): DEFVAR_BOOL it.
221 (make_cursor_line_fully_visible, try_cursor_movement)
222 (try_window_id): Use it.
223
12004-11-12 Kim F. Storm <storm@cua.dk> 2242004-11-12 Kim F. Storm <storm@cua.dk>
2 225
3 * dispextern.h (struct glyph_row): New member extra_line_spacing. 226 * dispextern.h (struct glyph_row): New member extra_line_spacing.
@@ -11,8 +234,8 @@
11 (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P) 234 (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P)
12 (MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P): Use helper macros. 235 (MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P): Use helper macros.
13 236
14 * window.c (window_scroll_pixel_based, Frecenter): Use 237 * window.c (window_scroll_pixel_based, Frecenter):
15 move_it_vertically_backward directly. 238 Use move_it_vertically_backward directly.
16 (Frecenter): Fix calculation of new start pos for negative arg. 239 (Frecenter): Fix calculation of new start pos for negative arg.
17 Before, the new start pos was sometimes chosen too far back, so 240 Before, the new start pos was sometimes chosen too far back, so
18 the last line became only partially visible, and thus would be 241 the last line became only partially visible, and thus would be
@@ -23,7 +246,7 @@
23 (move_it_vertically_backward): Don't recure to move further back. 246 (move_it_vertically_backward): Don't recure to move further back.
24 (move_it_vertically): Remove superfluous condition. 247 (move_it_vertically): Remove superfluous condition.
25 (move_it_by_lines): Clear last_height when moved 0 lines. 248 (move_it_by_lines): Clear last_height when moved 0 lines.
26 (resize_mini_window): use it.max_extra_line_spacing. 249 (resize_mini_window): Use it.max_extra_line_spacing.
27 (display_tool_bar_line): Clear row->extra_line_spacing. 250 (display_tool_bar_line): Clear row->extra_line_spacing.
28 (try_scrolling): Use move_it_vertically_backward directly. 251 (try_scrolling): Use move_it_vertically_backward directly.
29 (redisplay_window): Likewise. 252 (redisplay_window): Likewise.
@@ -115,7 +338,7 @@
115 * Makefile.in (SOME_MACHINE_OBJECTS): Add fringe.o, image.o 338 * Makefile.in (SOME_MACHINE_OBJECTS): Add fringe.o, image.o
116 and w32*.o. 339 and w32*.o.
117 (temacs${EXEEXT}): Generate buildobj.lst when temacs is linked. 340 (temacs${EXEEXT}): Generate buildobj.lst when temacs is linked.
118 (mostlyclean): rm buildobj.lst 341 (mostlyclean): Rm buildobj.lst
119 342
120 * makefile.w32-in ($(TEMACS)): Generate buildobj.lst when temacs 343 * makefile.w32-in ($(TEMACS)): Generate buildobj.lst when temacs
121 is linked. 344 is linked.
@@ -152,8 +375,8 @@
152 375
1532004-11-07 Andreas Schwab <schwab@suse.de> 3762004-11-07 Andreas Schwab <schwab@suse.de>
154 377
155 * lisp.h: Declare Fmsdos_downcase_filename. 378 * lisp.h (Fmsdos_downcase_filename): Declare.
156 * dired.c: Don't declare Fmsdos_downcase_filename. 379 * dired.c (Fmsdos_downcase_filename): Don't declare here.
157 * fileio.c: Likewise. 380 * fileio.c: Likewise.
158 381
1592004-11-07 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 3822004-11-07 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
@@ -164,7 +387,7 @@
164 387
165 * msdos.c (IT_set_frame_parameters): Use EQ, not ==, for Lisp_Object:s. 388 * msdos.c (IT_set_frame_parameters): Use EQ, not ==, for Lisp_Object:s.
166 389
167 * dired.c: extern declare Fmsdos_downcase_filename on MSDOS to avoid 390 * dired.c (Fmsdos_downcase_filename): Declare extern on MSDOS to avoid
168 int/Lisp_Object mixup. 391 int/Lisp_Object mixup.
169 392
170 * fileio.c: Ditto. 393 * fileio.c: Ditto.
@@ -273,7 +496,7 @@
273 496
274 * fileio.c (Fnext_read_file_uses_dialog_p): New function. 497 * fileio.c (Fnext_read_file_uses_dialog_p): New function.
275 498
276 * gtkutil.h: Declare use_old_gtk_file_dialog. 499 * gtkutil.h (use_old_gtk_file_dialog): Declare.
277 500
278 * gtkutil.c: Make use_old_gtk_file_dialog non-static. 501 * gtkutil.c: Make use_old_gtk_file_dialog non-static.
279 (xg_initialize): Move DEFVAR_BOOL for use_old_gtk_file_dialog ... 502 (xg_initialize): Move DEFVAR_BOOL for use_old_gtk_file_dialog ...
@@ -750,7 +973,6 @@
750 precedence. 973 precedence.
751 (XTread_socket) [TARGET_API_MAC_CARBON]: Don't specify drag area. 974 (XTread_socket) [TARGET_API_MAC_CARBON]: Don't specify drag area.
752 975
753
7542004-10-05 Jan Dj,Ad(Brv. <jan.h.d@swipnet.se> 9762004-10-05 Jan Dj,Ad(Brv. <jan.h.d@swipnet.se>
755 977
756 * config.in: Regenerate. 978 * config.in: Regenerate.
@@ -1327,7 +1549,7 @@
1327 1549
13282004-07-24 Richard M. Stallman <rms@gnu.org> 15502004-07-24 Richard M. Stallman <rms@gnu.org>
1329 1551
1330 * keyboard.h (not_single_kboard_state): Declared. 1552 * keyboard.h (not_single_kboard_state): Declare.
1331 1553
1332 * fileio.c (Fwrite_region): Doc fix. 1554 * fileio.c (Fwrite_region): Doc fix.
1333 1555
@@ -1535,7 +1757,7 @@
1535 (lookup_image_type): Pass Qnil as second argument to 1757 (lookup_image_type): Pass Qnil as second argument to
1536 Finit_image_library. 1758 Finit_image_library.
1537 1759
1538 * lisp.h: Declare Finit_image_library. 1760 * lisp.h (Finit_image_library): Declare.
1539 1761
15402004-06-29 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 17622004-06-29 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
1541 1763
@@ -2380,7 +2602,7 @@
2380 2602
23812004-05-10 Andreas Schwab <schwab@suse.de> 26032004-05-10 Andreas Schwab <schwab@suse.de>
2382 2604
2383 * lisp.h: Declare Fmake_symbolic_link. 2605 * lisp.h (Fmake_symbolic_link): Declare.
2384 2606
2385 * fileio.c (Frename_file): Remove extra argument in call to 2607 * fileio.c (Frename_file): Remove extra argument in call to
2386 Fmake_symbolic_link. 2608 Fmake_symbolic_link.
@@ -4871,9 +5093,9 @@
4871 (update_frame_tool_bar): Call xg_get_gdk_pixmap_and_mask. 5093 (update_frame_tool_bar): Call xg_get_gdk_pixmap_and_mask.
4872 (xg_initialize): Remove xg_left_ptr_cursor. 5094 (xg_initialize): Remove xg_left_ptr_cursor.
4873 5095
4874 * gtkutil.h: xg_get_scroll_id_for_window, xg_win_to_widget takes 5096 * gtkutil.h (xg_get_scroll_id_for_window, xg_win_to_widget): Add
4875 Display* argument also. Declare xg_display_open, 5097 Display* argument.
4876 xg_display_close, xg_create_default_cursor. 5098 (xg_display_open, xg_display_close, xg_create_default_cursor): Declare.
4877 5099
48782003-11-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 51002003-11-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
4879 5101
@@ -4939,8 +5161,8 @@
4939 5161
49402003-11-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 51622003-11-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
4941 5163
4942 * gtkutil.h: Declare xg_have_tear_offs, remove xg_keep_popup 5164 * gtkutil.h (xg_have_tear_offs): Declare.
4943 and xg_did_tearoff. 5165 (xg_keep_popup, xg_did_tearoff): Remove.
4944 5166
4945 * gtkutil.c: Remove variable xg_did_tearoff. 5167 * gtkutil.c: Remove variable xg_did_tearoff.
4946 (xg_have_tear_offs): New function. 5168 (xg_have_tear_offs): New function.
@@ -5438,7 +5660,7 @@
5438 5660
5439 * alloc.c (lisp_align_malloc): Change type of `aligned'. 5661 * alloc.c (lisp_align_malloc): Change type of `aligned'.
5440 5662
5441 * alloca.s: Removed. 5663 * alloca.s: Remove.
5442 5664
54432003-08-19 Gerd Moellmann <gerd@gnu.org> 56652003-08-19 Gerd Moellmann <gerd@gnu.org>
5444 5666
@@ -8060,7 +8282,7 @@
8060 (handle_one_xevent): ButtonPress/Release: If event is for a toolkit 8282 (handle_one_xevent): ButtonPress/Release: If event is for a toolkit
8061 scrollbar and control is pressed, call x_scroll_bar_handle_click. 8283 scrollbar and control is pressed, call x_scroll_bar_handle_click.
8062 8284
8063 * gtkutil.h: Declare xg_get_scroll_id_for_window. 8285 * gtkutil.h (xg_get_scroll_id_for_window): Declare.
8064 8286
8065 * gtkutil.c (xg_get_scroll_id_for_window): New function. 8287 * gtkutil.c (xg_get_scroll_id_for_window): New function.
8066 (xg_tool_bar_item_expose_callback): New function. 8288 (xg_tool_bar_item_expose_callback): New function.
@@ -8762,7 +8984,7 @@
8762 (FRAME_OUTER_TO_INNER_DIFF_Y): Add FRAME_TOOLBAR_HEIGHT to calculation. 8984 (FRAME_OUTER_TO_INNER_DIFF_Y): Add FRAME_TOOLBAR_HEIGHT to calculation.
8763 8985
8764 * xterm.c: Include gtkutil.h for USE_GTK. 8986 * xterm.c: Include gtkutil.h for USE_GTK.
8765 Declare extern void free_frame_menubar for USE_GTK. 8987 (free_frame_menubar): Declare extern void for USE_GTK.
8766 (note_mouse_highlight): Check popup_activated for USE_GTK. 8988 (note_mouse_highlight): Check popup_activated for USE_GTK.
8767 (xt_action_hook): Don't compile if USE_GTK. 8989 (xt_action_hook): Don't compile if USE_GTK.
8768 (x_scroll_bar_to_input_event): Use CurrentTime for USE_GTK. 8990 (x_scroll_bar_to_input_event): Use CurrentTime for USE_GTK.
@@ -8832,7 +9054,7 @@
8832 (redisplay_window): Add check for USE_GTK and FRAME_EXTERNAL_TOOL_BAR. 9054 (redisplay_window): Add check for USE_GTK and FRAME_EXTERNAL_TOOL_BAR.
8833 (display_menu_bar): Add check for USE_GTK 9055 (display_menu_bar): Add check for USE_GTK
8834 9056
8835 * lisp.h: Declare Vx_resource_name extern. 9057 * lisp.h (Vx_resource_name): Declare extern.
8836 9058
8837 * keyboard.c (kbd_buffer_get_event): Check MENU_BAR_ACTIVATE_EVENT 9059 * keyboard.c (kbd_buffer_get_event): Check MENU_BAR_ACTIVATE_EVENT
8838 for USE_GTK. 9060 for USE_GTK.
@@ -9049,7 +9271,7 @@
9049 (XSAVE_VALUE): New macro. 9271 (XSAVE_VALUE): New macro.
9050 (struct Lisp_Save_Value): New data type. 9272 (struct Lisp_Save_Value): New data type.
9051 (union Lisp_Misc): Add u_save_value alternative. 9273 (union Lisp_Misc): Add u_save_value alternative.
9052 (make_save_value): Declared. 9274 (make_save_value): Declare.
9053 9275
9054 * alloc.c (make_save_value): New function. 9276 * alloc.c (make_save_value): New function.
9055 9277
@@ -12119,7 +12341,7 @@
12119 * fontset.c [MAC_OS]: Set Vdefault_fontset to ETL Fixed instead of 12341 * fontset.c [MAC_OS]: Set Vdefault_fontset to ETL Fixed instead of
12120 Apple Monaco. 12342 Apple Monaco.
12121 12343
12122 * process.c: Declare QCfamily and QCfilter as extern. 12344 * process.c (QCfamily, QCfilte): Declare extern.
12123 (wait_reading_process_input) [MAC_OSX]: Clear bit for stdin before 12345 (wait_reading_process_input) [MAC_OSX]: Clear bit for stdin before
12124 calling select. 12346 calling select.
12125 12347
@@ -12947,7 +13169,7 @@
12947 13169
129482002-03-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 131702002-03-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
12949 13171
12950 * xterm.h (x_session_check_input, x_session_initialize): Declared. 13172 * xterm.h (x_session_check_input, x_session_initialize): Declare.
12951 13173
12952 * xterm.c: (XTread_socket): Add call to x_session_check_input and 13174 * xterm.c: (XTread_socket): Add call to x_session_check_input and
12953 x_session_have_connection. 13175 x_session_have_connection.
@@ -12959,7 +13181,7 @@
12959 13181
12960 * emacs.c (main): Add call to syms_of_xsmfns. 13182 * emacs.c (main): Add call to syms_of_xsmfns.
12961 13183
12962 * lisp.h: Declare syms_of_xsmfns as extern. 13184 * lisp.h (syms_of_xsmfns): Declare extern.
12963 13185
12964 * config.in: Add HAVE_X_SM. 13186 * config.in: Add HAVE_X_SM.
12965 13187
@@ -14304,7 +14526,7 @@
143042001-12-09 Jason Rumney <jasonr@gnu.org> 145262001-12-09 Jason Rumney <jasonr@gnu.org>
14305 14527
14306 * w32menu.c (_widget_value): Make `help' field a Lisp_Object. 14528 * w32menu.c (_widget_value): Make `help' field a Lisp_Object.
14307 Add comment to explain where the struct came from. 14529 Add comment to explain where the struct came from.
14308 (single_submenu, w32_menu_show): Set `help' field as Lisp_Object. 14530 (single_submenu, w32_menu_show): Set `help' field as Lisp_Object.
14309 (add_menu_item): Process pop-up menus first to avoid memory leak. 14531 (add_menu_item): Process pop-up menus first to avoid memory leak.
14310 (add_menu_item, w32_menu_display_help): Use `help' field as 14532 (add_menu_item, w32_menu_display_help): Use `help' field as
@@ -15090,7 +15312,7 @@
15090 * insdel.c (replace_range): Use adjust_markers_for_replace 15312 * insdel.c (replace_range): Use adjust_markers_for_replace
15091 instead of adjust_markers_for_delete and adjust_markers_for_insert. 15313 instead of adjust_markers_for_delete and adjust_markers_for_insert.
15092 15314
15093 * intervals.h: Declare set_text_properties and set_text_properties_1. 15315 * intervals.h (set_text_properties, set_text_properties_1): Declare.
15094 15316
15095 * textprop.c (set_text_properties_1): New subroutine 15317 * textprop.c (set_text_properties_1): New subroutine
15096 broken out of set_text_properties. 15318 broken out of set_text_properties.
diff --git a/src/callint.c b/src/callint.c
index bb71ad50f44..933601f67d0 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -723,7 +723,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
723 723
724 tem = Fread_from_minibuffer (build_string (callint_message), 724 tem = Fread_from_minibuffer (build_string (callint_message),
725 Qnil, Qnil, Qnil, Qnil, Qnil, 725 Qnil, Qnil, Qnil, Qnil, Qnil,
726 Qnil); 726 Qnil, Qnil);
727 if (! STRINGP (tem) || SCHARS (tem) == 0) 727 if (! STRINGP (tem) || SCHARS (tem) == 0)
728 args[i] = Qnil; 728 args[i] = Qnil;
729 else 729 else
diff --git a/src/dispextern.h b/src/dispextern.h
index a179c8488dd..d2ca9564ef8 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2594,6 +2594,7 @@ extern int help_echo_pos;
2594extern struct frame *last_mouse_frame; 2594extern struct frame *last_mouse_frame;
2595extern int last_tool_bar_item; 2595extern int last_tool_bar_item;
2596extern int mouse_autoselect_window; 2596extern int mouse_autoselect_window;
2597extern void reseat_at_previous_visible_line_start P_ ((struct it *));
2597 2598
2598extern int calc_pixel_width_or_height P_ ((double *, struct it *, Lisp_Object, 2599extern int calc_pixel_width_or_height P_ ((double *, struct it *, Lisp_Object,
2599 /* XFontStruct */ void *, int, int *)); 2600 /* XFontStruct */ void *, int, int *));
diff --git a/src/eval.c b/src/eval.c
index d1d5d195762..adff3e8670c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -204,7 +204,7 @@ init_eval_once ()
204 specpdl_size = 50; 204 specpdl_size = 50;
205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); 205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding));
206 specpdl_ptr = specpdl; 206 specpdl_ptr = specpdl;
207 max_specpdl_size = 600; 207 max_specpdl_size = 650;
208 max_lisp_eval_depth = 300; 208 max_lisp_eval_depth = 300;
209 209
210 Vrun_hooks = Qnil; 210 Vrun_hooks = Qnil;
diff --git a/src/fns.c b/src/fns.c
index e0167ebf990..c436649f73d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -741,7 +741,7 @@ concat (nargs, args, target_type, last_special)
741 } 741 }
742 else 742 else
743 { 743 {
744 XSETFASTINT (elt, SREF (this, thisindex++)); 744 XSETFASTINT (elt, SREF (this, thisindex)); thisindex++;
745 if (some_multibyte 745 if (some_multibyte
746 && (XINT (elt) >= 0240 746 && (XINT (elt) >= 0240
747 || (XINT (elt) >= 0200 747 || (XINT (elt) >= 0200
@@ -1997,6 +1997,35 @@ one of the properties on the list. */)
1997 return Qnil; 1997 return Qnil;
1998} 1998}
1999 1999
2000DEFUN ("safe-plist-get", Fsafe_plist_get, Ssafe_plist_get, 2, 2, 0,
2001 doc: /* Extract a value from a property list.
2002PLIST is a property list, which is a list of the form
2003\(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value
2004corresponding to the given PROP, or nil if PROP is not
2005one of the properties on the list.
2006This function never signals an error. */)
2007 (plist, prop)
2008 Lisp_Object plist;
2009 Lisp_Object prop;
2010{
2011 Lisp_Object tail, halftail;
2012
2013 /* halftail is used to detect circular lists. */
2014 tail = halftail = plist;
2015 while (CONSP (tail) && CONSP (XCDR (tail)))
2016 {
2017 if (EQ (prop, XCAR (tail)))
2018 return XCAR (XCDR (tail));
2019
2020 tail = XCDR (XCDR (tail));
2021 halftail = XCDR (halftail);
2022 if (EQ (tail, halftail))
2023 break;
2024 }
2025
2026 return Qnil;
2027}
2028
2000DEFUN ("get", Fget, Sget, 2, 2, 0, 2029DEFUN ("get", Fget, Sget, 2, 2, 0,
2001 doc: /* Return the value of SYMBOL's PROPNAME property. 2030 doc: /* Return the value of SYMBOL's PROPNAME property.
2002This is the last value stored with `(put SYMBOL PROPNAME VALUE)'. */) 2031This is the last value stored with `(put SYMBOL PROPNAME VALUE)'. */)
@@ -3275,7 +3304,7 @@ is nil, and `use-dialog-box' is non-nil. */)
3275 { 3304 {
3276 ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil, 3305 ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil,
3277 Qyes_or_no_p_history, Qnil, 3306 Qyes_or_no_p_history, Qnil,
3278 Qnil)); 3307 Qnil, Qnil));
3279 if (SCHARS (ans) == 3 && !strcmp (SDATA (ans), "yes")) 3308 if (SCHARS (ans) == 3 && !strcmp (SDATA (ans), "yes"))
3280 { 3309 {
3281 UNGCPRO; 3310 UNGCPRO;
@@ -5734,6 +5763,7 @@ used if both `use-dialog-box' and this variable are non-nil. */);
5734 defsubr (&Sreverse); 5763 defsubr (&Sreverse);
5735 defsubr (&Ssort); 5764 defsubr (&Ssort);
5736 defsubr (&Splist_get); 5765 defsubr (&Splist_get);
5766 defsubr (&Ssafe_plist_get);
5737 defsubr (&Sget); 5767 defsubr (&Sget);
5738 defsubr (&Splist_put); 5768 defsubr (&Splist_put);
5739 defsubr (&Sput); 5769 defsubr (&Sput);
diff --git a/src/frame.c b/src/frame.c
index 80d1876ef11..660b9db4316 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -398,7 +398,8 @@ make_frame (mini_p)
398 f->selected_window = root_window; 398 f->selected_window = root_window;
399 /* Make sure this window seems more recently used than 399 /* Make sure this window seems more recently used than
400 a newly-created, never-selected window. */ 400 a newly-created, never-selected window. */
401 XSETFASTINT (XWINDOW (f->selected_window)->use_time, ++window_select_count); 401 ++window_select_count;
402 XSETFASTINT (XWINDOW (f->selected_window)->use_time, window_select_count);
402 403
403 f->default_face_done_p = 0; 404 f->default_face_done_p = 0;
404 405
diff --git a/src/fringe.c b/src/fringe.c
index 03abffab5c8..661af1fb0eb 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1210,7 +1210,6 @@ If BITMAP already exists, the existing definition is replaced. */)
1210 (bitmap, bits, height, width, align) 1210 (bitmap, bits, height, width, align)
1211 Lisp_Object bitmap, bits, height, width, align; 1211 Lisp_Object bitmap, bits, height, width, align;
1212{ 1212{
1213 Lisp_Object len;
1214 int n, h, i, j; 1213 int n, h, i, j;
1215 unsigned short *b; 1214 unsigned short *b;
1216 struct fringe_bitmap fb, *xfb; 1215 struct fringe_bitmap fb, *xfb;
@@ -1218,20 +1217,21 @@ If BITMAP already exists, the existing definition is replaced. */)
1218 1217
1219 CHECK_SYMBOL (bitmap); 1218 CHECK_SYMBOL (bitmap);
1220 1219
1221 if (!STRINGP (bits) && !VECTORP (bits)) 1220 if (STRINGP (bits))
1222 bits = wrong_type_argument (Qstringp, bits); 1221 h = SCHARS (bits);
1223 1222 else if (VECTORP (bits))
1224 len = Flength (bits); 1223 h = XVECTOR (bits)->size;
1224 else
1225 bits = wrong_type_argument (Qsequencep, bits);
1225 1226
1226 if (NILP (height)) 1227 if (NILP (height))
1227 h = fb.height = XINT (len); 1228 fb.height = h;
1228 else 1229 else
1229 { 1230 {
1230 CHECK_NUMBER (height); 1231 CHECK_NUMBER (height);
1231 fb.height = min (XINT (height), 255); 1232 fb.height = min (XINT (height), 255);
1232 if (fb.height > XINT (len)) 1233 if (fb.height > h)
1233 { 1234 {
1234 h = XINT (len);
1235 fill1 = (fb.height - h) / 2; 1235 fill1 = (fb.height - h) / 2;
1236 fill2 = fb.height - h - fill1; 1236 fill2 = fb.height - h - fill1;
1237 } 1237 }
diff --git a/src/gtkutil.c b/src/gtkutil.c
index f5f05709e48..25dd88d544e 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1122,41 +1122,75 @@ create_dialog (wv, select_cb, deactivate_cb)
1122/*********************************************************************** 1122/***********************************************************************
1123 File dialog functions 1123 File dialog functions
1124 ***********************************************************************/ 1124 ***********************************************************************/
1125enum
1126{
1127 XG_FILE_NOT_DONE,
1128 XG_FILE_OK,
1129 XG_FILE_CANCEL,
1130 XG_FILE_DESTROYED,
1131};
1132
1133#ifdef HAVE_GTK_FILE_BOTH 1125#ifdef HAVE_GTK_FILE_BOTH
1134int use_old_gtk_file_dialog; 1126int use_old_gtk_file_dialog;
1135#endif 1127#endif
1136 1128
1129/* Function that is called when the file dialog pops down.
1130 W is the dialog widget, RESPONSE is the response code.
1131 USER_DATA is what we passed in to g_signal_connect (pointer to int). */
1132
1133static void
1134xg_file_response_cb (w,
1135 response,
1136 user_data)
1137 GtkDialog *w;
1138 gint response;
1139 gpointer user_data;
1140{
1141 int *ptr = (int *) user_data;
1142 *ptr = response;
1143}
1144
1145
1146/* Destroy the dialog. This makes it pop down. */
1147
1148static Lisp_Object
1149pop_down_file_dialog (arg)
1150 Lisp_Object arg;
1151{
1152 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
1153 BLOCK_INPUT;
1154 gtk_widget_destroy (GTK_WIDGET (p->pointer));
1155 UNBLOCK_INPUT;
1156 return Qnil;
1157}
1158
1159typedef char * (*xg_get_file_func) P_ ((GtkWidget *));
1137 1160
1138#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW 1161#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW
1162
1163/* Return the selected file for file chooser dialog W.
1164 The returned string must be free:d. */
1165
1166static char *
1167xg_get_file_name_from_chooser (w)
1168 GtkWidget *w;
1169{
1170 return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w));
1171}
1172
1139/* Read a file name from the user using a file chooser dialog. 1173/* Read a file name from the user using a file chooser dialog.
1140 F is the current frame. 1174 F is the current frame.
1141 PROMPT is a prompt to show to the user. May not be NULL. 1175 PROMPT is a prompt to show to the user. May not be NULL.
1142 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. 1176 DEFAULT_FILENAME is a default selection to be displayed. May be NULL.
1143 If MUSTMATCH_P is non-zero, the returned file name must be an existing 1177 If MUSTMATCH_P is non-zero, the returned file name must be an existing
1144 file. 1178 file. *FUNC is set to a function that can be used to retrieve the
1179 selected file name from the returned widget.
1145 1180
1146 Returns a file name or NULL if no file was selected. 1181 Returns the created widget. */
1147 The returned string must be freed by the caller. */
1148 1182
1149static char * 1183static GtkWidget *
1150xg_get_file_with_chooser (f, prompt, default_filename, mustmatch_p, only_dir_p) 1184xg_get_file_with_chooser (f, prompt, default_filename,
1185 mustmatch_p, only_dir_p, func)
1151 FRAME_PTR f; 1186 FRAME_PTR f;
1152 char *prompt; 1187 char *prompt;
1153 char *default_filename; 1188 char *default_filename;
1154 int mustmatch_p, only_dir_p; 1189 int mustmatch_p, only_dir_p;
1190 xg_get_file_func *func;
1155{ 1191{
1156 GtkWidget *filewin; 1192 GtkWidget *filewin;
1157 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); 1193 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
1158
1159 char *fn = 0;
1160 GtkFileChooserAction action = (mustmatch_p ? 1194 GtkFileChooserAction action = (mustmatch_p ?
1161 GTK_FILE_CHOOSER_ACTION_OPEN : 1195 GTK_FILE_CHOOSER_ACTION_OPEN :
1162 GTK_FILE_CHOOSER_ACTION_SAVE); 1196 GTK_FILE_CHOOSER_ACTION_SAVE);
@@ -1171,12 +1205,6 @@ xg_get_file_with_chooser (f, prompt, default_filename, mustmatch_p, only_dir_p)
1171 GTK_RESPONSE_OK, 1205 GTK_RESPONSE_OK,
1172 NULL); 1206 NULL);
1173 1207
1174 xg_set_screen (filewin, f);
1175 gtk_widget_set_name (filewin, "emacs-filedialog");
1176 gtk_window_set_transient_for (GTK_WINDOW (filewin), gwin);
1177 gtk_window_set_destroy_with_parent (GTK_WINDOW (filewin), TRUE);
1178
1179
1180 if (default_filename) 1208 if (default_filename)
1181 { 1209 {
1182 Lisp_Object file; 1210 Lisp_Object file;
@@ -1197,104 +1225,49 @@ xg_get_file_with_chooser (f, prompt, default_filename, mustmatch_p, only_dir_p)
1197 UNGCPRO; 1225 UNGCPRO;
1198 } 1226 }
1199 1227
1200 gtk_widget_show (filewin); 1228 *func = xg_get_file_name_from_chooser;
1201 1229 return filewin;
1202 if (gtk_dialog_run (GTK_DIALOG (filewin)) == GTK_RESPONSE_OK)
1203 fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filewin));
1204
1205 gtk_widget_destroy (filewin);
1206
1207 return fn;
1208} 1230}
1209#endif /* HAVE_GTK_FILE_CHOOSER_DIALOG_NEW */ 1231#endif /* HAVE_GTK_FILE_CHOOSER_DIALOG_NEW */
1210 1232
1211#ifdef HAVE_GTK_FILE_SELECTION_NEW 1233#ifdef HAVE_GTK_FILE_SELECTION_NEW
1212/* Callback function invoked when the Ok button is pressed in
1213 a file dialog.
1214 W is the file dialog widget,
1215 ARG points to an integer where we record what has happend. */
1216 1234
1217static void 1235/* Return the selected file for file selector dialog W.
1218xg_file_sel_ok (w, arg) 1236 The returned string must be free:d. */
1219 GtkWidget *w;
1220 gpointer arg;
1221{
1222 *(int*)arg = XG_FILE_OK;
1223}
1224 1237
1225/* Callback function invoked when the Cancel button is pressed in 1238static char *
1226 a file dialog. 1239xg_get_file_name_from_selector (w)
1227 W is the file dialog widget,
1228 ARG points to an integer where we record what has happend. */
1229
1230static void
1231xg_file_sel_cancel (w, arg)
1232 GtkWidget *w;
1233 gpointer arg;
1234{
1235 *(int*)arg = XG_FILE_CANCEL;
1236}
1237
1238/* Callback function invoked when the file dialog is destroyed (i.e.
1239 popped down). We must keep track of this, because if this
1240 happens, GTK destroys the widget. But if for example, Ok is pressed,
1241 the dialog is popped down, but the dialog widget is not destroyed.
1242 W is the file dialog widget,
1243 ARG points to an integer where we record what has happend. */
1244
1245static void
1246xg_file_sel_destroy (w, arg)
1247 GtkWidget *w; 1240 GtkWidget *w;
1248 gpointer arg;
1249{ 1241{
1250 *(int*)arg = XG_FILE_DESTROYED; 1242 GtkFileSelection *filesel = GTK_FILE_SELECTION (w);
1243 return xstrdup ((char*) gtk_file_selection_get_filename (filesel));
1251} 1244}
1252 1245
1253/* Read a file name from the user using a file selection dialog. 1246/* Create a file selection dialog.
1254 F is the current frame. 1247 F is the current frame.
1255 PROMPT is a prompt to show to the user. May not be NULL. 1248 PROMPT is a prompt to show to the user. May not be NULL.
1256 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. 1249 DEFAULT_FILENAME is a default selection to be displayed. May be NULL.
1257 If MUSTMATCH_P is non-zero, the returned file name must be an existing 1250 If MUSTMATCH_P is non-zero, the returned file name must be an existing
1258 file. 1251 file. *FUNC is set to a function that can be used to retrieve the
1252 selected file name from the returned widget.
1259 1253
1260 Returns a file name or NULL if no file was selected. 1254 Returns the created widget. */
1261 The returned string must be freed by the caller. */
1262 1255
1263static char * 1256static GtkWidget *
1264xg_get_file_with_selection (f, prompt, default_filename, 1257xg_get_file_with_selection (f, prompt, default_filename,
1265 mustmatch_p, only_dir_p) 1258 mustmatch_p, only_dir_p, func)
1266 FRAME_PTR f; 1259 FRAME_PTR f;
1267 char *prompt; 1260 char *prompt;
1268 char *default_filename; 1261 char *default_filename;
1269 int mustmatch_p, only_dir_p; 1262 int mustmatch_p, only_dir_p;
1263 xg_get_file_func *func;
1270{ 1264{
1271 GtkWidget *filewin; 1265 GtkWidget *filewin;
1272 GtkFileSelection *filesel; 1266 GtkFileSelection *filesel;
1273 int filesel_done = XG_FILE_NOT_DONE;
1274 char *fn = 0;
1275 1267
1276 filewin = gtk_file_selection_new (prompt); 1268 filewin = gtk_file_selection_new (prompt);
1277 filesel = GTK_FILE_SELECTION (filewin); 1269 filesel = GTK_FILE_SELECTION (filewin);
1278 1270
1279 xg_set_screen (filewin, f);
1280 gtk_widget_set_name (filewin, "emacs-filedialog");
1281 gtk_window_set_transient_for (GTK_WINDOW (filewin),
1282 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
1283 gtk_window_set_destroy_with_parent (GTK_WINDOW (filewin), TRUE);
1284
1285 g_signal_connect (G_OBJECT (filesel->ok_button),
1286 "clicked",
1287 G_CALLBACK (xg_file_sel_ok),
1288 &filesel_done);
1289 g_signal_connect (G_OBJECT (filesel->cancel_button),
1290 "clicked",
1291 G_CALLBACK (xg_file_sel_cancel),
1292 &filesel_done);
1293 g_signal_connect (G_OBJECT (filesel),
1294 "destroy",
1295 G_CALLBACK (xg_file_sel_destroy),
1296 &filesel_done);
1297
1298 if (default_filename) 1271 if (default_filename)
1299 gtk_file_selection_set_filename (filesel, default_filename); 1272 gtk_file_selection_set_filename (filesel, default_filename);
1300 1273
@@ -1305,19 +1278,9 @@ xg_get_file_with_selection (f, prompt, default_filename,
1305 gtk_file_selection_hide_fileop_buttons (filesel); 1278 gtk_file_selection_hide_fileop_buttons (filesel);
1306 } 1279 }
1307 1280
1281 *func = xg_get_file_name_from_selector;
1308 1282
1309 gtk_widget_show_all (filewin); 1283 return filewin;
1310
1311 while (filesel_done == XG_FILE_NOT_DONE)
1312 gtk_main_iteration ();
1313
1314 if (filesel_done == XG_FILE_OK)
1315 fn = xstrdup ((char*) gtk_file_selection_get_filename (filesel));
1316
1317 if (filesel_done != XG_FILE_DESTROYED)
1318 gtk_widget_destroy (filewin);
1319
1320 return fn;
1321} 1284}
1322#endif /* HAVE_GTK_FILE_SELECTION_NEW */ 1285#endif /* HAVE_GTK_FILE_SELECTION_NEW */
1323 1286
@@ -1341,26 +1304,63 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p)
1341 char *default_filename; 1304 char *default_filename;
1342 int mustmatch_p, only_dir_p; 1305 int mustmatch_p, only_dir_p;
1343{ 1306{
1307 GtkWidget *w = 0;
1308 int count = SPECPDL_INDEX ();
1309 char *fn = 0;
1310 int filesel_done = 0;
1311 xg_get_file_func func;
1312
1344#ifdef HAVE_GTK_FILE_BOTH 1313#ifdef HAVE_GTK_FILE_BOTH
1345 if (use_old_gtk_file_dialog) 1314 if (use_old_gtk_file_dialog)
1346 return xg_get_file_with_selection (f, prompt, default_filename, 1315 w = xg_get_file_with_selection (f, prompt, default_filename,
1347 mustmatch_p, only_dir_p); 1316 mustmatch_p, only_dir_p, &func);
1348 return xg_get_file_with_chooser (f, prompt, default_filename, 1317 else
1349 mustmatch_p, only_dir_p); 1318 w = xg_get_file_with_chooser (f, prompt, default_filename,
1319 mustmatch_p, only_dir_p, &func);
1350 1320
1351#else /* not HAVE_GTK_FILE_BOTH */ 1321#else /* not HAVE_GTK_FILE_BOTH */
1352 1322
1353#ifdef HAVE_GTK_FILE_SELECTION_DIALOG_NEW 1323#ifdef HAVE_GTK_FILE_SELECTION_NEW
1354 return xg_get_file_with_selection (f, prompt, default_filename, 1324 w = xg_get_file_with_selection (f, prompt, default_filename,
1355 mustmatch_p, only_dir_p); 1325 mustmatch_p, only_dir_p, &func);
1356#endif 1326#endif
1357#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW 1327#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW
1358 return xg_get_file_with_chooser (f, prompt, default_filename, 1328 w = xg_get_file_with_chooser (f, prompt, default_filename,
1359 mustmatch_p, only_dir_p); 1329 mustmatch_p, only_dir_p, &func);
1360#endif 1330#endif
1361 1331
1362#endif /* HAVE_GTK_FILE_BOTH */ 1332#endif /* HAVE_GTK_FILE_BOTH */
1363 return 0; 1333
1334 xg_set_screen (w, f);
1335 gtk_widget_set_name (w, "emacs-filedialog");
1336 gtk_window_set_transient_for (GTK_WINDOW (w),
1337 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
1338 gtk_window_set_destroy_with_parent (GTK_WINDOW (w), TRUE);
1339 gtk_window_set_modal (GTK_WINDOW (w), TRUE);
1340
1341 g_signal_connect (G_OBJECT (w),
1342 "response",
1343 G_CALLBACK (xg_file_response_cb),
1344 &filesel_done);
1345
1346 /* Don't destroy the widget if closed by the window manager close button. */
1347 g_signal_connect (G_OBJECT (w), "delete-event", G_CALLBACK (gtk_true), NULL);
1348
1349 gtk_widget_show (w);
1350
1351 record_unwind_protect (pop_down_file_dialog, make_save_value (w, 0));
1352 while (! filesel_done)
1353 {
1354 x_menu_wait_for_event (0);
1355 gtk_main_iteration ();
1356 }
1357
1358 if (filesel_done == GTK_RESPONSE_OK)
1359 fn = (*func) (w);
1360
1361 unbind_to (count, Qnil);
1362
1363 return fn;
1364} 1364}
1365 1365
1366 1366
@@ -1999,6 +1999,7 @@ xg_create_widget (type, name, f, val,
1999 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); 1999 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
2000 gtk_window_set_destroy_with_parent (GTK_WINDOW (w), TRUE); 2000 gtk_window_set_destroy_with_parent (GTK_WINDOW (w), TRUE);
2001 gtk_widget_set_name (w, "emacs-dialog"); 2001 gtk_widget_set_name (w, "emacs-dialog");
2002 gtk_window_set_modal (GTK_WINDOW (w), TRUE);
2002 } 2003 }
2003 else if (menu_bar_p || pop_up_p) 2004 else if (menu_bar_p || pop_up_p)
2004 { 2005 {
diff --git a/src/indent.c b/src/indent.c
index 99fca1c2ff7..d2e8a83c11c 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2063,21 +2063,41 @@ whether or not it is currently displayed in some window. */)
2063 XSETBUFFER (w->buffer, current_buffer); 2063 XSETBUFFER (w->buffer, current_buffer);
2064 } 2064 }
2065 2065
2066 SET_TEXT_POS (pt, PT, PT_BYTE); 2066 if (noninteractive)
2067 start_display (&it, w, pt); 2067 {
2068 2068 struct position pos;
2069 /* Move to the start of the display line containing PT. If we don't 2069 pos = *vmotion (PT, XINT (lines), w);
2070 do this, we start moving with IT->current_x == 0, while PT is 2070 SET_PT_BOTH (pos.bufpos, pos.bytepos);
2071 really at some x > 0. The effect is, in continuation lines, that 2071 }
2072 we end up with the iterator placed at where it thinks X is 0, 2072 else
2073 while the end position is really at some X > 0, the same X that 2073 {
2074 PT had. */ 2074 int it_start;
2075 move_it_by_lines (&it, 0, 0); 2075
2076 2076 SET_TEXT_POS (pt, PT, PT_BYTE);
2077 if (XINT (lines) != 0) 2077 start_display (&it, w, pt);
2078 move_it_by_lines (&it, XINT (lines), 0); 2078
2079 2079 /* Scan from the start of the line containing PT. If we don't
2080 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 2080 do this, we start moving with IT->current_x == 0, while PT is
2081 really at some x > 0. The effect is, in continuation lines, that
2082 we end up with the iterator placed at where it thinks X is 0,
2083 while the end position is really at some X > 0, the same X that
2084 PT had. */
2085 it_start = IT_CHARPOS (it);
2086 reseat_at_previous_visible_line_start (&it);
2087 it.current_x = it.hpos = 0;
2088 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
2089
2090 /* Move back if we got too far. This may happen if
2091 truncate-lines is on and PT is beyond right margin. */
2092 if (IT_CHARPOS (it) > it_start && XINT (lines) > 0)
2093 move_it_by_lines (&it, -1, 0);
2094
2095 it.vpos = 0;
2096 if (XINT (lines) != 0)
2097 move_it_by_lines (&it, XINT (lines), 0);
2098
2099 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
2100 }
2081 2101
2082 if (BUFFERP (old_buffer)) 2102 if (BUFFERP (old_buffer))
2083 w->buffer = old_buffer; 2103 w->buffer = old_buffer;
diff --git a/src/keyboard.c b/src/keyboard.c
index b520d655fb9..8501fc3f11a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10655,7 +10655,7 @@ a mouse click at the upper left corner of the glyph corresponding
10655to the given buffer position: 10655to the given buffer position:
10656 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) 10656 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW)
10657 IMAGE (DX . DY) (WIDTH . HEIGHT)) 10657 IMAGE (DX . DY) (WIDTH . HEIGHT))
10658The `posn-' functions access elements of such lists. */*/) 10658The `posn-' functions access elements of such lists. */)
10659 (pos, window) 10659 (pos, window)
10660 Lisp_Object pos, window; 10660 Lisp_Object pos, window;
10661{ 10661{
diff --git a/src/keymap.c b/src/keymap.c
index 891e41f0b58..a5e5fbd3f93 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -729,19 +729,23 @@ map_keymap_call (key, val, fun, dummy)
729 call2 (fun, key, val); 729 call2 (fun, key, val);
730} 730}
731 731
732DEFUN ("map-keymap", Fmap_keymap, Smap_keymap, 2, 2, 0, 732DEFUN ("map-keymap", Fmap_keymap, Smap_keymap, 2, 3, 0,
733 doc: /* Call FUNCTION for every binding in KEYMAP. 733 doc: /* Call FUNCTION for every binding in KEYMAP.
734FUNCTION is called with two arguments: the event and its binding. 734FUNCTION is called with two arguments: the event and its binding.
735If KEYMAP has a parent, the parent's bindings are included as well. 735If KEYMAP has a parent, the parent's bindings are included as well.
736This works recursively: if the parent has itself a parent, then the 736This works recursively: if the parent has itself a parent, then the
737grandparent's bindings are also included and so on. */) 737grandparent's bindings are also included and so on.
738 (function, keymap) 738usage: (map-keymap FUNCTION KEYMAP) */)
739 Lisp_Object function, keymap; 739 (function, keymap, sort_first)
740 Lisp_Object function, keymap, sort_first;
740{ 741{
741 if (INTEGERP (function)) 742 if (INTEGERP (function))
742 /* We have to stop integers early since map_keymap gives them special 743 /* We have to stop integers early since map_keymap gives them special
743 significance. */ 744 significance. */
744 Fsignal (Qinvalid_function, Fcons (function, Qnil)); 745 Fsignal (Qinvalid_function, Fcons (function, Qnil));
746 if (! NILP (sort_first))
747 return call3 (intern ("map-keymap-internal"), function, keymap, Qt);
748
745 map_keymap (keymap, map_keymap_call, function, NULL, 1); 749 map_keymap (keymap, map_keymap_call, function, NULL, 1);
746 return Qnil; 750 return Qnil;
747} 751}
diff --git a/src/lisp.h b/src/lisp.h
index 2c3141733bc..e54c8571fd5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1374,7 +1374,7 @@ typedef unsigned char UCHAR;
1374 1374
1375/* Data type checking */ 1375/* Data type checking */
1376 1376
1377#define NILP(x) (XFASTINT (x) == XFASTINT (Qnil)) 1377#define NILP(x) EQ (x, Qnil)
1378#define GC_NILP(x) GC_EQ (x, Qnil) 1378#define GC_NILP(x) GC_EQ (x, Qnil)
1379 1379
1380#define NUMBERP(x) (INTEGERP (x) || FLOATP (x)) 1380#define NUMBERP(x) (INTEGERP (x) || FLOATP (x))
@@ -2304,6 +2304,7 @@ extern Lisp_Object string_make_multibyte P_ ((Lisp_Object));
2304extern Lisp_Object string_make_unibyte P_ ((Lisp_Object)); 2304extern Lisp_Object string_make_unibyte P_ ((Lisp_Object));
2305EXFUN (Fcopy_alist, 1); 2305EXFUN (Fcopy_alist, 1);
2306EXFUN (Fplist_get, 2); 2306EXFUN (Fplist_get, 2);
2307EXFUN (Fsafe_plist_get, 2);
2307EXFUN (Fplist_put, 3); 2308EXFUN (Fplist_put, 3);
2308EXFUN (Fplist_member, 2); 2309EXFUN (Fplist_member, 2);
2309EXFUN (Fset_char_table_parent, 2); 2310EXFUN (Fset_char_table_parent, 2);
@@ -2807,7 +2808,7 @@ extern void syms_of_search P_ ((void));
2807extern Lisp_Object last_minibuf_string; 2808extern Lisp_Object last_minibuf_string;
2808extern void choose_minibuf_frame P_ ((void)); 2809extern void choose_minibuf_frame P_ ((void));
2809EXFUN (Fcompleting_read, 8); 2810EXFUN (Fcompleting_read, 8);
2810EXFUN (Fread_from_minibuffer, 7); 2811EXFUN (Fread_from_minibuffer, 8);
2811EXFUN (Fread_variable, 2); 2812EXFUN (Fread_variable, 2);
2812EXFUN (Fread_buffer, 3); 2813EXFUN (Fread_buffer, 3);
2813EXFUN (Fread_minibuffer, 2); 2814EXFUN (Fread_minibuffer, 2);
diff --git a/src/macterm.c b/src/macterm.c
index cdc1ccf41e3..8e3f67116f5 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -279,7 +279,7 @@ static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
279static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 279static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
280 enum text_cursor_kinds)); 280 enum text_cursor_kinds));
281 281
282static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC)); 282static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC));
283static void x_flush P_ ((struct frame *f)); 283static void x_flush P_ ((struct frame *f));
284static void x_update_begin P_ ((struct frame *)); 284static void x_update_begin P_ ((struct frame *));
285static void x_update_window_begin P_ ((struct window *)); 285static void x_update_window_begin P_ ((struct window *));
@@ -1454,12 +1454,12 @@ x_draw_fringe_bitmap (w, row, p)
1454 int oldVH = row->visible_height; 1454 int oldVH = row->visible_height;
1455 row->visible_height = p->h; 1455 row->visible_height = p->h;
1456 row->y -= rowY - p->y; 1456 row->y -= rowY - p->y;
1457 x_clip_to_row (w, row, gc); 1457 x_clip_to_row (w, row, -1, gc);
1458 row->y = oldY; 1458 row->y = oldY;
1459 row->visible_height = oldVH; 1459 row->visible_height = oldVH;
1460 } 1460 }
1461 else 1461 else
1462 x_clip_to_row (w, row, gc); 1462 x_clip_to_row (w, row, -1, gc);
1463 1463
1464 if (p->bx >= 0 && !p->overlay_p) 1464 if (p->bx >= 0 && !p->overlay_p)
1465 { 1465 {
@@ -4615,18 +4615,19 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4615 mode lines must be clipped to the whole window. */ 4615 mode lines must be clipped to the whole window. */
4616 4616
4617static void 4617static void
4618x_clip_to_row (w, row, gc) 4618x_clip_to_row (w, row, area, gc)
4619 struct window *w; 4619 struct window *w;
4620 struct glyph_row *row; 4620 struct glyph_row *row;
4621 int area;
4621 GC gc; 4622 GC gc;
4622{ 4623{
4623 struct frame *f = XFRAME (WINDOW_FRAME (w)); 4624 struct frame *f = XFRAME (WINDOW_FRAME (w));
4624 Rect clip_rect; 4625 Rect clip_rect;
4625 int window_y, window_width; 4626 int window_x, window_y, window_width;
4626 4627
4627 window_box (w, -1, 0, &window_y, &window_width, 0); 4628 window_box (w, area, &window_x, &window_y, &window_width, 0);
4628 4629
4629 clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0); 4630 clip_rect.left = window_x;
4630 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 4631 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
4631 clip_rect.top = max (clip_rect.top, window_y); 4632 clip_rect.top = max (clip_rect.top, window_y);
4632 clip_rect.right = clip_rect.left + window_width; 4633 clip_rect.right = clip_rect.left + window_width;
@@ -4692,7 +4693,7 @@ x_draw_hollow_cursor (w, row)
4692 gc = dpyinfo->scratch_cursor_gc; 4693 gc = dpyinfo->scratch_cursor_gc;
4693 4694
4694 /* Set clipping, draw the rectangle, and reset clipping again. */ 4695 /* Set clipping, draw the rectangle, and reset clipping again. */
4695 x_clip_to_row (w, row, gc); 4696 x_clip_to_row (w, row, TEXT_AREA, gc);
4696 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); 4697 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
4697 mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f)); 4698 mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f));
4698} 4699}
@@ -4763,7 +4764,7 @@ x_draw_bar_cursor (w, row, width, kind)
4763 width = min (cursor_glyph->pixel_width, width); 4764 width = min (cursor_glyph->pixel_width, width);
4764 4765
4765 w->phys_cursor_width = width; 4766 w->phys_cursor_width = width;
4766 x_clip_to_row (w, row, gc); 4767 x_clip_to_row (w, row, TEXT_AREA, gc);
4767 4768
4768 if (kind == BAR_CURSOR) 4769 if (kind == BAR_CURSOR)
4769 XFillRectangle (dpy, window, gc, 4770 XFillRectangle (dpy, window, gc,
diff --git a/src/minibuf.c b/src/minibuf.c
index a569daaefee..2ebb736ca00 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -219,7 +219,7 @@ static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object,
219 Lisp_Object, Lisp_Object, 219 Lisp_Object, Lisp_Object,
220 int, Lisp_Object, 220 int, Lisp_Object,
221 Lisp_Object, Lisp_Object, 221 Lisp_Object, Lisp_Object,
222 int, int)); 222 int, int, int));
223static Lisp_Object read_minibuf_noninteractive P_ ((Lisp_Object, Lisp_Object, 223static Lisp_Object read_minibuf_noninteractive P_ ((Lisp_Object, Lisp_Object,
224 Lisp_Object, Lisp_Object, 224 Lisp_Object, Lisp_Object,
225 int, Lisp_Object, 225 int, Lisp_Object,
@@ -438,7 +438,8 @@ minibuffer_completion_contents ()
438 438
439static Lisp_Object 439static Lisp_Object
440read_minibuf (map, initial, prompt, backup_n, expflag, 440read_minibuf (map, initial, prompt, backup_n, expflag,
441 histvar, histpos, defalt, allow_props, inherit_input_method) 441 histvar, histpos, defalt, allow_props, inherit_input_method,
442 keep_all)
442 Lisp_Object map; 443 Lisp_Object map;
443 Lisp_Object initial; 444 Lisp_Object initial;
444 Lisp_Object prompt; 445 Lisp_Object prompt;
@@ -449,6 +450,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
449 Lisp_Object defalt; 450 Lisp_Object defalt;
450 int allow_props; 451 int allow_props;
451 int inherit_input_method; 452 int inherit_input_method;
453 int keep_all;
452{ 454{
453 Lisp_Object val; 455 Lisp_Object val;
454 int count = SPECPDL_INDEX (); 456 int count = SPECPDL_INDEX ();
@@ -727,7 +729,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
727 last_minibuf_string = val; 729 last_minibuf_string = val;
728 730
729 /* Choose the string to add to the history. */ 731 /* Choose the string to add to the history. */
730 if (SCHARS (val) != 0) 732 if (SCHARS (val) != 0 || keep_all)
731 histstring = val; 733 histstring = val;
732 else if (STRINGP (defalt)) 734 else if (STRINGP (defalt))
733 histstring = defalt; 735 histstring = defalt;
@@ -754,7 +756,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
754 if (NILP (histval) 756 if (NILP (histval)
755 || (CONSP (histval) 757 || (CONSP (histval)
756 /* Don't duplicate the most recent entry in the history. */ 758 /* Don't duplicate the most recent entry in the history. */
757 && NILP (Fequal (histstring, Fcar (histval))))) 759 && (keep_all
760 || NILP (Fequal (histstring, Fcar (histval))))))
758 { 761 {
759 Lisp_Object length; 762 Lisp_Object length;
760 763
@@ -916,7 +919,7 @@ read_minibuf_unwind (data)
916} 919}
917 920
918 921
919DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 7, 0, 922DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 8, 0,
920 doc: /* Read a string from the minibuffer, prompting with string PROMPT. 923 doc: /* Read a string from the minibuffer, prompting with string PROMPT.
921The optional second arg INITIAL-CONTENTS is an obsolete alternative to 924The optional second arg INITIAL-CONTENTS is an obsolete alternative to
922 DEFAULT-VALUE. It normally should be nil in new code, except when 925 DEFAULT-VALUE. It normally should be nil in new code, except when
@@ -940,6 +943,8 @@ Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is available
940 the empty string. 943 the empty string.
941Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits 944Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
942 the current input method and the setting of `enable-multibyte-characters'. 945 the current input method and the setting of `enable-multibyte-characters'.
946Eight arg KEEP-ALL, if non-nil, says to put all inputs in the history list,
947 even empty or duplicate inputs.
943If the variable `minibuffer-allow-text-properties' is non-nil, 948If the variable `minibuffer-allow-text-properties' is non-nil,
944 then the string which is returned includes whatever text properties 949 then the string which is returned includes whatever text properties
945 were present in the minibuffer. Otherwise the value has no text properties. 950 were present in the minibuffer. Otherwise the value has no text properties.
@@ -955,9 +960,9 @@ POSITION in the minibuffer. Any integer value less than or equal to
955one puts point at the beginning of the string. *Note* that this 960one puts point at the beginning of the string. *Note* that this
956behavior differs from the way such arguments are used in `completing-read' 961behavior differs from the way such arguments are used in `completing-read'
957and some related functions, which use zero-indexing for POSITION. */) 962and some related functions, which use zero-indexing for POSITION. */)
958 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method) 963 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method, keep_all)
959 Lisp_Object prompt, initial_contents, keymap, read, hist, default_value; 964 Lisp_Object prompt, initial_contents, keymap, read, hist, default_value;
960 Lisp_Object inherit_input_method; 965 Lisp_Object inherit_input_method, keep_all;
961{ 966{
962 Lisp_Object histvar, histpos, val; 967 Lisp_Object histvar, histpos, val;
963 struct gcpro gcpro1; 968 struct gcpro gcpro1;
@@ -988,7 +993,8 @@ and some related functions, which use zero-indexing for POSITION. */)
988 Qnil, !NILP (read), 993 Qnil, !NILP (read),
989 histvar, histpos, default_value, 994 histvar, histpos, default_value,
990 minibuffer_allow_text_properties, 995 minibuffer_allow_text_properties,
991 !NILP (inherit_input_method)); 996 !NILP (inherit_input_method),
997 !NILP (keep_all));
992 UNGCPRO; 998 UNGCPRO;
993 return val; 999 return val;
994} 1000}
@@ -1005,7 +1011,7 @@ arguments are used as in `read-from-minibuffer') */)
1005 CHECK_STRING (prompt); 1011 CHECK_STRING (prompt);
1006 return read_minibuf (Vminibuffer_local_map, initial_contents, 1012 return read_minibuf (Vminibuffer_local_map, initial_contents,
1007 prompt, Qnil, 1, Qminibuffer_history, 1013 prompt, Qnil, 1, Qminibuffer_history,
1008 make_number (0), Qnil, 0, 0); 1014 make_number (0), Qnil, 0, 0, 0);
1009} 1015}
1010 1016
1011DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0, 1017DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0,
@@ -1043,7 +1049,7 @@ Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
1043 Lisp_Object val; 1049 Lisp_Object val;
1044 val = Fread_from_minibuffer (prompt, initial_input, Qnil, 1050 val = Fread_from_minibuffer (prompt, initial_input, Qnil,
1045 Qnil, history, default_value, 1051 Qnil, history, default_value,
1046 inherit_input_method); 1052 inherit_input_method, Qnil);
1047 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value)) 1053 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value))
1048 val = default_value; 1054 val = default_value;
1049 return val; 1055 return val;
@@ -1065,7 +1071,7 @@ the current input method and the setting of`enable-multibyte-characters'. */)
1065 CHECK_STRING (prompt); 1071 CHECK_STRING (prompt);
1066 return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, Qnil, 1072 return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, Qnil,
1067 0, Qminibuffer_history, make_number (0), Qnil, 0, 1073 0, Qminibuffer_history, make_number (0), Qnil, 0,
1068 !NILP (inherit_input_method)); 1074 !NILP (inherit_input_method), 0);
1069} 1075}
1070 1076
1071DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, 1077DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0,
@@ -1716,7 +1722,7 @@ Completion ignores case if the ambient value of
1716 : Vminibuffer_local_must_match_map, 1722 : Vminibuffer_local_must_match_map,
1717 init, prompt, make_number (pos), 0, 1723 init, prompt, make_number (pos), 0,
1718 histvar, histpos, def, 0, 1724 histvar, histpos, def, 0,
1719 !NILP (inherit_input_method)); 1725 !NILP (inherit_input_method), 0);
1720 1726
1721 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def)) 1727 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def))
1722 val = def; 1728 val = def;
@@ -2081,9 +2087,29 @@ a repetition of this command will exit. */)
2081 if (XINT (Fminibuffer_prompt_end ()) == ZV) 2087 if (XINT (Fminibuffer_prompt_end ()) == ZV)
2082 goto exit; 2088 goto exit;
2083 2089
2084 if (!NILP (Ftest_completion (Fminibuffer_contents (), 2090 val = Fminibuffer_contents ();
2091 if (!NILP (Ftest_completion (val,
2085 Vminibuffer_completion_table, 2092 Vminibuffer_completion_table,
2086 Vminibuffer_completion_predicate))) 2093 Vminibuffer_completion_predicate)))
2094 {
2095 if (completion_ignore_case)
2096 { /* Fixup case of the field, if necessary. */
2097 Lisp_Object compl
2098 = Ftry_completion (val,
2099 Vminibuffer_completion_table,
2100 Vminibuffer_completion_predicate);
2101 if (STRINGP (compl)
2102 /* If it weren't for this piece of paranoia, I'd replace
2103 the whole thing with a call to do_completion. */
2104 && EQ (Flength (val), Flength (compl)))
2105 {
2106 del_range (XINT (Fminibuffer_prompt_end ()), ZV);
2107 Finsert (1, &compl);
2108 }
2109 }
2110 goto exit;
2111 }
2112
2087 goto exit; 2113 goto exit;
2088 2114
2089 /* Call do_completion, but ignore errors. */ 2115 /* Call do_completion, but ignore errors. */
@@ -2691,8 +2717,8 @@ elements are deleted. */);
2691 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case, 2717 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case,
2692 doc: /* Non-nil means don't consider case significant in completion. 2718 doc: /* Non-nil means don't consider case significant in completion.
2693 2719
2694See also `read-file-name-completion-ignore-case' concerning case significance 2720For file-name completion, the variable `read-file-name-completion-ignore-case'
2695in completion when reading a file name. */); 2721controls the behavior, rather than this variable. */);
2696 completion_ignore_case = 0; 2722 completion_ignore_case = 0;
2697 2723
2698 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers, 2724 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers,
diff --git a/src/regex.c b/src/regex.c
index 36787238a32..a53eac29216 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1250,7 +1250,7 @@ reg_syntax_t re_syntax_options;
1250 1250
1251reg_syntax_t 1251reg_syntax_t
1252re_set_syntax (syntax) 1252re_set_syntax (syntax)
1253 reg_syntax_t syntax; 1253 reg_syntax_t syntax;
1254{ 1254{
1255 reg_syntax_t ret = re_syntax_options; 1255 reg_syntax_t ret = re_syntax_options;
1256 1256
@@ -1258,6 +1258,17 @@ re_set_syntax (syntax)
1258 return ret; 1258 return ret;
1259} 1259}
1260WEAK_ALIAS (__re_set_syntax, re_set_syntax) 1260WEAK_ALIAS (__re_set_syntax, re_set_syntax)
1261
1262/* Regexp to use to replace spaces, or NULL meaning don't. */
1263static re_char *whitespace_regexp;
1264
1265void
1266re_set_whitespace_regexp (regexp)
1267 re_char *regexp;
1268{
1269 whitespace_regexp = regexp;
1270}
1271WEAK_ALIAS (__re_set_syntax, re_set_syntax)
1261 1272
1262/* This table gives an error message for each of the error codes listed 1273/* This table gives an error message for each of the error codes listed
1263 in regex.h. Obviously the order here has to be same as there. 1274 in regex.h. Obviously the order here has to be same as there.
@@ -2436,6 +2447,15 @@ regex_compile (pattern, size, syntax, bufp)
2436 /* If the object matched can contain multibyte characters. */ 2447 /* If the object matched can contain multibyte characters. */
2437 const boolean multibyte = RE_MULTIBYTE_P (bufp); 2448 const boolean multibyte = RE_MULTIBYTE_P (bufp);
2438 2449
2450 /* Nonzero if we have pushed down into a subpattern. */
2451 int in_subpattern = 0;
2452
2453 /* These hold the values of p, pattern, and pend from the main
2454 pattern when we have pushed into a subpattern. */
2455 re_char *main_p;
2456 re_char *main_pattern;
2457 re_char *main_pend;
2458
2439#ifdef DEBUG 2459#ifdef DEBUG
2440 debug++; 2460 debug++;
2441 DEBUG_PRINT1 ("\nCompiling pattern: "); 2461 DEBUG_PRINT1 ("\nCompiling pattern: ");
@@ -2498,12 +2518,61 @@ regex_compile (pattern, size, syntax, bufp)
2498 begalt = b = bufp->buffer; 2518 begalt = b = bufp->buffer;
2499 2519
2500 /* Loop through the uncompiled pattern until we're at the end. */ 2520 /* Loop through the uncompiled pattern until we're at the end. */
2501 while (p != pend) 2521 while (1)
2502 { 2522 {
2523 if (p == pend)
2524 {
2525 /* If this is the end of an included regexp,
2526 pop back to the main regexp and try again. */
2527 if (in_subpattern)
2528 {
2529 in_subpattern = 0;
2530 pattern = main_pattern;
2531 p = main_p;
2532 pend = main_pend;
2533 continue;
2534 }
2535 /* If this is the end of the main regexp, we are done. */
2536 break;
2537 }
2538
2503 PATFETCH (c); 2539 PATFETCH (c);
2504 2540
2505 switch (c) 2541 switch (c)
2506 { 2542 {
2543 case ' ':
2544 {
2545 re_char *p1 = p;
2546
2547 /* If there's no special whitespace regexp, treat
2548 spaces normally. And don't try to do this recursively. */
2549 if (!whitespace_regexp || in_subpattern)
2550 goto normal_char;
2551
2552 /* Peek past following spaces. */
2553 while (p1 != pend)
2554 {
2555 if (*p1 != ' ')
2556 break;
2557 p1++;
2558 }
2559 /* If the spaces are followed by a repetition op,
2560 treat them normally. */
2561 if (p1 == pend
2562 || (*p1 == '*' || *p1 == '+' || *p1 == '?'
2563 || (*p1 == '\\' && p1 + 1 != pend && p1[1] == '{')))
2564 goto normal_char;
2565
2566 /* Replace the spaces with the whitespace regexp. */
2567 in_subpattern = 1;
2568 main_p = p1;
2569 main_pend = pend;
2570 main_pattern = pattern;
2571 p = pattern = whitespace_regexp;
2572 pend = p + strlen (p);
2573 break;
2574 }
2575
2507 case '^': 2576 case '^':
2508 { 2577 {
2509 if ( /* If at start of pattern, it's an operator. */ 2578 if ( /* If at start of pattern, it's an operator. */
diff --git a/src/search.c b/src/search.c
index 1742cfb08c2..56611ca7af8 100644
--- a/src/search.c
+++ b/src/search.c
@@ -41,7 +41,7 @@ Boston, MA 02111-1307, USA. */
41struct regexp_cache 41struct regexp_cache
42{ 42{
43 struct regexp_cache *next; 43 struct regexp_cache *next;
44 Lisp_Object regexp; 44 Lisp_Object regexp, whitespace_regexp;
45 struct re_pattern_buffer buf; 45 struct re_pattern_buffer buf;
46 char fastmap[0400]; 46 char fastmap[0400];
47 /* Nonzero means regexp was compiled to do full POSIX backtracking. */ 47 /* Nonzero means regexp was compiled to do full POSIX backtracking. */
@@ -83,6 +83,8 @@ static Lisp_Object last_thing_searched;
83 83
84Lisp_Object Qinvalid_regexp; 84Lisp_Object Qinvalid_regexp;
85 85
86Lisp_Object Vsearch_spaces_regexp;
87
86static void set_search_regs (); 88static void set_search_regs ();
87static void save_search_regs (); 89static void save_search_regs ();
88static int simple_search (); 90static int simple_search ();
@@ -107,7 +109,9 @@ matcher_overflow ()
107 for this pattern. 0 means backtrack only enough to get a valid match. 109 for this pattern. 0 means backtrack only enough to get a valid match.
108 MULTIBYTE is nonzero if we want to handle multibyte characters in 110 MULTIBYTE is nonzero if we want to handle multibyte characters in
109 PATTERN. 0 means all multibyte characters are recognized just as 111 PATTERN. 0 means all multibyte characters are recognized just as
110 sequences of binary data. */ 112 sequences of binary data.
113
114 The behavior also depends on Vsearch_spaces_regexp. */
111 115
112static void 116static void
113compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte) 117compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
@@ -158,11 +162,19 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
158 cp->buf.translate = (! NILP (translate) ? translate : make_number (0)); 162 cp->buf.translate = (! NILP (translate) ? translate : make_number (0));
159 cp->posix = posix; 163 cp->posix = posix;
160 cp->buf.multibyte = multibyte; 164 cp->buf.multibyte = multibyte;
165 cp->whitespace_regexp = Vsearch_spaces_regexp;
161 BLOCK_INPUT; 166 BLOCK_INPUT;
162 old = re_set_syntax (RE_SYNTAX_EMACS 167 old = re_set_syntax (RE_SYNTAX_EMACS
163 | (posix ? 0 : RE_NO_POSIX_BACKTRACKING)); 168 | (posix ? 0 : RE_NO_POSIX_BACKTRACKING));
169
170 re_set_whitespace_regexp (NILP (Vsearch_spaces_regexp) ? NULL
171 : SDATA (Vsearch_spaces_regexp));
172
164 val = (char *) re_compile_pattern ((char *)raw_pattern, 173 val = (char *) re_compile_pattern ((char *)raw_pattern,
165 raw_pattern_size, &cp->buf); 174 raw_pattern_size, &cp->buf);
175
176 re_set_whitespace_regexp (NULL);
177
166 re_set_syntax (old); 178 re_set_syntax (old);
167 UNBLOCK_INPUT; 179 UNBLOCK_INPUT;
168 if (val) 180 if (val)
@@ -223,7 +235,8 @@ compile_pattern (pattern, regp, translate, posix, multibyte)
223 && !NILP (Fstring_equal (cp->regexp, pattern)) 235 && !NILP (Fstring_equal (cp->regexp, pattern))
224 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) 236 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0)))
225 && cp->posix == posix 237 && cp->posix == posix
226 && cp->buf.multibyte == multibyte) 238 && cp->buf.multibyte == multibyte
239 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp)))
227 break; 240 break;
228 241
229 /* If we're at the end of the cache, compile into the nil cell 242 /* If we're at the end of the cache, compile into the nil cell
@@ -1051,7 +1064,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1051 return pos; 1064 return pos;
1052 } 1065 }
1053 1066
1054 if (RE && !trivial_regexp_p (string)) 1067 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
1055 { 1068 {
1056 unsigned char *p1, *p2; 1069 unsigned char *p1, *p2;
1057 int s1, s2; 1070 int s1, s2;
@@ -2972,6 +2985,7 @@ syms_of_search ()
2972 searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100); 2985 searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100);
2973 searchbufs[i].buf.fastmap = searchbufs[i].fastmap; 2986 searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
2974 searchbufs[i].regexp = Qnil; 2987 searchbufs[i].regexp = Qnil;
2988 searchbufs[i].whitespace_regexp = Qnil;
2975 staticpro (&searchbufs[i].regexp); 2989 staticpro (&searchbufs[i].regexp);
2976 searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]); 2990 searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]);
2977 } 2991 }
@@ -2998,6 +3012,14 @@ syms_of_search ()
2998 saved_last_thing_searched = Qnil; 3012 saved_last_thing_searched = Qnil;
2999 staticpro (&saved_last_thing_searched); 3013 staticpro (&saved_last_thing_searched);
3000 3014
3015 DEFVAR_LISP ("search-spaces-regexp", &Vsearch_spaces_regexp,
3016 /* doc: Regexp to substitute for bunches of spaces in regexp search.
3017Some commands use this for user-specified regexps.
3018Spaces that occur inside character classes or repetition operators
3019or other such regexp constructs are not replaced with this.
3020A value of nil (which is the normal value) means treat spaces literally. */);
3021 Vsearch_spaces_regexp = Qnil;
3022
3001 defsubr (&Slooking_at); 3023 defsubr (&Slooking_at);
3002 defsubr (&Sposix_looking_at); 3024 defsubr (&Sposix_looking_at);
3003 defsubr (&Sstring_match); 3025 defsubr (&Sstring_match);
diff --git a/src/w32term.c b/src/w32term.c
index aa9c0b96e92..0f6e9f67a66 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -260,7 +260,7 @@ static void x_frame_rehighlight P_ ((struct w32_display_info *));
260static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 260static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
261static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 261static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
262 enum text_cursor_kinds)); 262 enum text_cursor_kinds));
263static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, HDC)); 263static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, int, HDC));
264 264
265static Lisp_Object Qvendor_specific_keysyms; 265static Lisp_Object Qvendor_specific_keysyms;
266 266
@@ -691,12 +691,12 @@ w32_draw_fringe_bitmap (w, row, p)
691 int oldVH = row->visible_height; 691 int oldVH = row->visible_height;
692 row->visible_height = p->h; 692 row->visible_height = p->h;
693 row->y -= rowY - p->y; 693 row->y -= rowY - p->y;
694 w32_clip_to_row (w, row, hdc); 694 w32_clip_to_row (w, row, -1, hdc);
695 row->y = oldY; 695 row->y = oldY;
696 row->visible_height = oldVH; 696 row->visible_height = oldVH;
697 } 697 }
698 else 698 else
699 w32_clip_to_row (w, row, hdc); 699 w32_clip_to_row (w, row, -1, hdc);
700 700
701 if (p->bx >= 0 && !p->overlay_p) 701 if (p->bx >= 0 && !p->overlay_p)
702 { 702 {
@@ -4912,18 +4912,19 @@ w32_read_socket (sd, expected, hold_quit)
4912 mode lines must be clipped to the whole window. */ 4912 mode lines must be clipped to the whole window. */
4913 4913
4914static void 4914static void
4915w32_clip_to_row (w, row, hdc) 4915w32_clip_to_row (w, row, area, hdc)
4916 struct window *w; 4916 struct window *w;
4917 struct glyph_row *row; 4917 struct glyph_row *row;
4918 int area;
4918 HDC hdc; 4919 HDC hdc;
4919{ 4920{
4920 struct frame *f = XFRAME (WINDOW_FRAME (w)); 4921 struct frame *f = XFRAME (WINDOW_FRAME (w));
4921 RECT clip_rect; 4922 RECT clip_rect;
4922 int window_y, window_width; 4923 int window_x, window_y, window_width;
4923 4924
4924 window_box (w, -1, 0, &window_y, &window_width, 0); 4925 window_box (w, area, &window_x, &window_y, &window_width, 0);
4925 4926
4926 clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0); 4927 clip_rect.left = window_x;
4927 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 4928 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
4928 clip_rect.top = max (clip_rect.top, window_y); 4929 clip_rect.top = max (clip_rect.top, window_y);
4929 clip_rect.right = clip_rect.left + window_width; 4930 clip_rect.right = clip_rect.left + window_width;
@@ -4983,7 +4984,7 @@ x_draw_hollow_cursor (w, row)
4983 rect.right = rect.left + wd; 4984 rect.right = rect.left + wd;
4984 hdc = get_frame_dc (f); 4985 hdc = get_frame_dc (f);
4985 /* Set clipping, draw the rectangle, and reset clipping again. */ 4986 /* Set clipping, draw the rectangle, and reset clipping again. */
4986 w32_clip_to_row (w, row, hdc); 4987 w32_clip_to_row (w, row, TEXT_AREA, hdc);
4987 FrameRect (hdc, &rect, hb); 4988 FrameRect (hdc, &rect, hb);
4988 DeleteObject (hb); 4989 DeleteObject (hb);
4989 w32_set_clip_rectangle (hdc, NULL); 4990 w32_set_clip_rectangle (hdc, NULL);
@@ -5049,7 +5050,7 @@ x_draw_bar_cursor (w, row, width, kind)
5049 5050
5050 5051
5051 hdc = get_frame_dc (f); 5052 hdc = get_frame_dc (f);
5052 w32_clip_to_row (w, row, hdc); 5053 w32_clip_to_row (w, row, TEXT_AREA, hdc);
5053 5054
5054 if (kind == BAR_CURSOR) 5055 if (kind == BAR_CURSOR)
5055 { 5056 {
diff --git a/src/window.c b/src/window.c
index be5e9167d67..b202031878b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -243,7 +243,8 @@ make_window ()
243 register struct window *p; 243 register struct window *p;
244 244
245 p = allocate_window (); 245 p = allocate_window ();
246 XSETFASTINT (p->sequence_number, ++sequence_number); 246 ++sequence_number;
247 XSETFASTINT (p->sequence_number, sequence_number);
247 XSETFASTINT (p->left_col, 0); 248 XSETFASTINT (p->left_col, 0);
248 XSETFASTINT (p->top_line, 0); 249 XSETFASTINT (p->top_line, 0);
249 XSETFASTINT (p->total_lines, 0); 250 XSETFASTINT (p->total_lines, 0);
@@ -2659,6 +2660,9 @@ shrink_windows (total, size, nchildren, shrinkable,
2659 --shrinkable; 2660 --shrinkable;
2660 total_removed += smallest; 2661 total_removed += smallest;
2661 2662
2663 /* We don't know what the smallest is now. */
2664 smallest = total;
2665
2662 /* Out of for, just remove one window at the time and 2666 /* Out of for, just remove one window at the time and
2663 check again if we have enough space. */ 2667 check again if we have enough space. */
2664 break; 2668 break;
@@ -2683,6 +2687,16 @@ shrink_windows (total, size, nchildren, shrinkable,
2683 that are left and still can be shrunk. */ 2687 that are left and still can be shrunk. */
2684 while (total_shrink > total_removed) 2688 while (total_shrink > total_removed)
2685 { 2689 {
2690 int nonzero_sizes = 0;
2691 int nonzero_idx = -1;
2692
2693 for (i = 0; i < nchildren; ++i)
2694 if (new_sizes[i] > 0)
2695 {
2696 ++nonzero_sizes;
2697 nonzero_idx = i;
2698 }
2699
2686 for (i = 0; i < nchildren; ++i) 2700 for (i = 0; i < nchildren; ++i)
2687 if (new_sizes[i] > min_size) 2701 if (new_sizes[i] > min_size)
2688 { 2702 {
@@ -2693,6 +2707,25 @@ shrink_windows (total, size, nchildren, shrinkable,
2693 check again if we have enough space. */ 2707 check again if we have enough space. */
2694 break; 2708 break;
2695 } 2709 }
2710
2711
2712 /* Special case, only one window left. */
2713 if (nonzero_sizes == 1)
2714 break;
2715 }
2716
2717 /* Any surplus due to rounding, we add to windows that are left. */
2718 while (total_shrink < total_removed)
2719 {
2720 for (i = 0; i < nchildren; ++i)
2721 {
2722 if (new_sizes[i] != 0 && total_shrink < total_removed)
2723 {
2724 ++new_sizes[i];
2725 --total_removed;
2726 break;
2727 }
2728 }
2696 } 2729 }
2697 2730
2698 return new_sizes; 2731 return new_sizes;
@@ -3119,7 +3152,8 @@ selects the buffer of the selected window before each command. */)
3119 w = XWINDOW (window); 3152 w = XWINDOW (window);
3120 w->frozen_window_start_p = 0; 3153 w->frozen_window_start_p = 0;
3121 3154
3122 XSETFASTINT (w->use_time, ++window_select_count); 3155 ++window_select_count;
3156 XSETFASTINT (w->use_time, window_select_count);
3123 if (EQ (window, selected_window)) 3157 if (EQ (window, selected_window))
3124 return window; 3158 return window;
3125 3159
@@ -3610,7 +3644,8 @@ make_dummy_parent (window)
3610 = ((struct Lisp_Vector *)o)->contents[i]; 3644 = ((struct Lisp_Vector *)o)->contents[i];
3611 XSETWINDOW (new, p); 3645 XSETWINDOW (new, p);
3612 3646
3613 XSETFASTINT (p->sequence_number, ++sequence_number); 3647 ++sequence_number;
3648 XSETFASTINT (p->sequence_number, sequence_number);
3614 3649
3615 /* Put new into window structure in place of window */ 3650 /* Put new into window structure in place of window */
3616 replace_window (window, new); 3651 replace_window (window, new);
@@ -5852,7 +5887,7 @@ save_window_save (window, vector, i)
5852 p = SAVED_WINDOW_N (vector, i); 5887 p = SAVED_WINDOW_N (vector, i);
5853 w = XWINDOW (window); 5888 w = XWINDOW (window);
5854 5889
5855 XSETFASTINT (w->temslot, i++); 5890 XSETFASTINT (w->temslot, i); i++;
5856 p->window = window; 5891 p->window = window;
5857 p->buffer = w->buffer; 5892 p->buffer = w->buffer;
5858 p->left_col = w->left_col; 5893 p->left_col = w->left_col;
diff --git a/src/xdisp.c b/src/xdisp.c
index c3f659a85e6..a872366f31b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -264,6 +264,10 @@ int mouse_autoselect_window;
264 264
265int auto_raise_tool_bar_buttons_p; 265int auto_raise_tool_bar_buttons_p;
266 266
267/* Non-zero means to reposition window if cursor line is only partially visible. */
268
269int make_cursor_line_fully_visible_p;
270
267/* Margin around tool bar buttons in pixels. */ 271/* Margin around tool bar buttons in pixels. */
268 272
269Lisp_Object Vtool_bar_button_margin; 273Lisp_Object Vtool_bar_button_margin;
@@ -884,7 +888,7 @@ static void next_overlay_string P_ ((struct it *));
884static void reseat P_ ((struct it *, struct text_pos, int)); 888static void reseat P_ ((struct it *, struct text_pos, int));
885static void reseat_1 P_ ((struct it *, struct text_pos, int)); 889static void reseat_1 P_ ((struct it *, struct text_pos, int));
886static void back_to_previous_visible_line_start P_ ((struct it *)); 890static void back_to_previous_visible_line_start P_ ((struct it *));
887static void reseat_at_previous_visible_line_start P_ ((struct it *)); 891void reseat_at_previous_visible_line_start P_ ((struct it *));
888static void reseat_at_next_visible_line_start P_ ((struct it *, int)); 892static void reseat_at_next_visible_line_start P_ ((struct it *, int));
889static int next_element_from_display_vector P_ ((struct it *)); 893static int next_element_from_display_vector P_ ((struct it *));
890static int next_element_from_string P_ ((struct it *)); 894static int next_element_from_string P_ ((struct it *));
@@ -1781,7 +1785,8 @@ get_glyph_string_clip_rect (s, nr)
1781 1785
1782 /* If drawing a tool-bar window, draw it over the internal border 1786 /* If drawing a tool-bar window, draw it over the internal border
1783 at the top of the window. */ 1787 at the top of the window. */
1784 if (s->w == XWINDOW (s->f->tool_bar_window)) 1788 if (WINDOWP (s->f->tool_bar_window)
1789 && s->w == XWINDOW (s->f->tool_bar_window))
1785 r.y -= FRAME_INTERNAL_BORDER_WIDTH (s->f); 1790 r.y -= FRAME_INTERNAL_BORDER_WIDTH (s->f);
1786 } 1791 }
1787 1792
@@ -4587,7 +4592,7 @@ back_to_previous_visible_line_start (it)
4587 selective display. At the end, update IT's overlay information, 4592 selective display. At the end, update IT's overlay information,
4588 face information etc. */ 4593 face information etc. */
4589 4594
4590static void 4595void
4591reseat_at_previous_visible_line_start (it) 4596reseat_at_previous_visible_line_start (it)
4592 struct it *it; 4597 struct it *it;
4593{ 4598{
@@ -4892,8 +4897,9 @@ get_next_display_element (it)
4892 translated to octal form. */ 4897 translated to octal form. */
4893 else if ((it->c < ' ' 4898 else if ((it->c < ' '
4894 && (it->area != TEXT_AREA 4899 && (it->area != TEXT_AREA
4895 /* In mode line, treat \n, \t like other crl chars. */ 4900 /* In mode line, treat \n like other crl chars. */
4896 || (it->glyph_row && it->glyph_row->mode_line_p) 4901 || (it->c != '\n'
4902 && it->glyph_row && it->glyph_row->mode_line_p)
4897 || (it->c != '\n' && it->c != '\t'))) 4903 || (it->c != '\n' && it->c != '\t')))
4898 || (it->multibyte_p 4904 || (it->multibyte_p
4899 ? ((it->c >= 127 4905 ? ((it->c >= 127
@@ -5770,6 +5776,8 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
5770 result = MOVE_NEWLINE_OR_CR; 5776 result = MOVE_NEWLINE_OR_CR;
5771 break; 5777 break;
5772 } 5778 }
5779 if (it->method == next_element_from_display_vector)
5780 it->face_id = it->saved_face_id;
5773 } 5781 }
5774#endif /* HAVE_WINDOW_SYSTEM */ 5782#endif /* HAVE_WINDOW_SYSTEM */
5775 } 5783 }
@@ -6696,6 +6704,7 @@ message3 (m, nbytes, multibyte)
6696 struct gcpro gcpro1; 6704 struct gcpro gcpro1;
6697 6705
6698 GCPRO1 (m); 6706 GCPRO1 (m);
6707 clear_message (1,1);
6699 6708
6700 /* First flush out any partial line written with print. */ 6709 /* First flush out any partial line written with print. */
6701 message_log_maybe_newline (); 6710 message_log_maybe_newline ();
@@ -10886,6 +10895,9 @@ make_cursor_line_fully_visible (w, force_p)
10886 struct glyph_row *row; 10895 struct glyph_row *row;
10887 int window_height; 10896 int window_height;
10888 10897
10898 if (!make_cursor_line_fully_visible_p)
10899 return 1;
10900
10889 /* It's not always possible to find the cursor, e.g, when a window 10901 /* It's not always possible to find the cursor, e.g, when a window
10890 is full of overlay strings. Don't do anything in that case. */ 10902 is full of overlay strings. Don't do anything in that case. */
10891 if (w->cursor.vpos < 0) 10903 if (w->cursor.vpos < 0)
@@ -11473,7 +11485,8 @@ try_cursor_movement (window, startp, scroll_step)
11473 /* if PT is not in the glyph row, give up. */ 11485 /* if PT is not in the glyph row, give up. */
11474 rc = CURSOR_MOVEMENT_MUST_SCROLL; 11486 rc = CURSOR_MOVEMENT_MUST_SCROLL;
11475 } 11487 }
11476 else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)) 11488 else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)
11489 && make_cursor_line_fully_visible_p)
11477 { 11490 {
11478 if (PT == MATRIX_ROW_END_CHARPOS (row) 11491 if (PT == MATRIX_ROW_END_CHARPOS (row)
11479 && !row->ends_at_zv_p 11492 && !row->ends_at_zv_p
@@ -13519,7 +13532,9 @@ try_window_id (w)
13519 && CHARPOS (start) > BEGV) 13532 && CHARPOS (start) > BEGV)
13520 /* Old redisplay didn't take scroll margin into account at the bottom, 13533 /* Old redisplay didn't take scroll margin into account at the bottom,
13521 but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */ 13534 but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */
13522 || w->cursor.y + cursor_height + this_scroll_margin > it.last_visible_y) 13535 || (w->cursor.y + (make_cursor_line_fully_visible_p
13536 ? cursor_height + this_scroll_margin
13537 : 1)) > it.last_visible_y)
13523 { 13538 {
13524 w->cursor.vpos = -1; 13539 w->cursor.vpos = -1;
13525 clear_glyph_matrix (w->desired_matrix); 13540 clear_glyph_matrix (w->desired_matrix);
@@ -14776,6 +14791,8 @@ display_line (it)
14776 row->continued_p = 0; 14791 row->continued_p = 0;
14777 row->exact_window_width_line_p = 1; 14792 row->exact_window_width_line_p = 1;
14778 } 14793 }
14794 else if (it->method == next_element_from_display_vector)
14795 it->face_id = it->saved_face_id;
14779 } 14796 }
14780#endif /* HAVE_WINDOW_SYSTEM */ 14797#endif /* HAVE_WINDOW_SYSTEM */
14781 } 14798 }
@@ -15501,7 +15518,9 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
15501 { 15518 {
15502 int bytepos = last - lisp_string; 15519 int bytepos = last - lisp_string;
15503 int charpos = string_byte_to_char (elt, bytepos); 15520 int charpos = string_byte_to_char (elt, bytepos);
15504 int endpos = (precision <= 0 ? SCHARS (elt) 15521 int endpos = (precision <= 0
15522 ? string_byte_to_char (elt,
15523 this - lisp_string)
15505 : charpos + nchars); 15524 : charpos + nchars);
15506 15525
15507 n += store_mode_line_string (NULL, 15526 n += store_mode_line_string (NULL,
@@ -15809,7 +15828,7 @@ store_mode_line_string (string, lisp_string, copy_string, field_width, precision
15809 props = mode_line_string_face_prop; 15828 props = mode_line_string_face_prop;
15810 else if (!NILP (mode_line_string_face)) 15829 else if (!NILP (mode_line_string_face))
15811 { 15830 {
15812 Lisp_Object face = Fplist_get (props, Qface); 15831 Lisp_Object face = Fsafe_plist_get (props, Qface);
15813 props = Fcopy_sequence (props); 15832 props = Fcopy_sequence (props);
15814 if (NILP (face)) 15833 if (NILP (face))
15815 face = mode_line_string_face; 15834 face = mode_line_string_face;
@@ -15834,7 +15853,7 @@ store_mode_line_string (string, lisp_string, copy_string, field_width, precision
15834 Lisp_Object face; 15853 Lisp_Object face;
15835 if (NILP (props)) 15854 if (NILP (props))
15836 props = Ftext_properties_at (make_number (0), lisp_string); 15855 props = Ftext_properties_at (make_number (0), lisp_string);
15837 face = Fplist_get (props, Qface); 15856 face = Fsafe_plist_get (props, Qface);
15838 if (NILP (face)) 15857 if (NILP (face))
15839 face = mode_line_string_face; 15858 face = mode_line_string_face;
15840 else 15859 else
@@ -17283,7 +17302,8 @@ init_glyph_string (s, OPTIONAL_HDC (hdc) char2b, w, row, area, start, hl)
17283 s->y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 17302 s->y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
17284 17303
17285 /* Display the internal border below the tool-bar window. */ 17304 /* Display the internal border below the tool-bar window. */
17286 if (s->w == XWINDOW (s->f->tool_bar_window)) 17305 if (WINDOWP (s->f->tool_bar_window)
17306 && s->w == XWINDOW (s->f->tool_bar_window))
17287 s->y -= FRAME_INTERNAL_BORDER_WIDTH (s->f); 17307 s->y -= FRAME_INTERNAL_BORDER_WIDTH (s->f);
17288 17308
17289 s->ybase = s->y + row->ascent; 17309 s->ybase = s->y + row->ascent;
@@ -18255,6 +18275,19 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
18255 return x_reached; 18275 return x_reached;
18256} 18276}
18257 18277
18278/* Expand row matrix if too narrow. Don't expand if area
18279 is not present. */
18280
18281#define IT_EXPAND_MATRIX_WIDTH(it, area) \
18282 { \
18283 if (!fonts_changed_p \
18284 && (it->glyph_row->glyphs[area] \
18285 < it->glyph_row->glyphs[area + 1])) \
18286 { \
18287 it->w->ncols_scale_factor++; \
18288 fonts_changed_p = 1; \
18289 } \
18290 }
18258 18291
18259/* Store one glyph for IT->char_to_display in IT->glyph_row. 18292/* Store one glyph for IT->char_to_display in IT->glyph_row.
18260 Called from x_produce_glyphs when IT->glyph_row is non-null. */ 18293 Called from x_produce_glyphs when IT->glyph_row is non-null. */
@@ -18292,11 +18325,8 @@ append_glyph (it)
18292 glyph->font_type = FONT_TYPE_UNKNOWN; 18325 glyph->font_type = FONT_TYPE_UNKNOWN;
18293 ++it->glyph_row->used[area]; 18326 ++it->glyph_row->used[area];
18294 } 18327 }
18295 else if (!fonts_changed_p) 18328 else
18296 { 18329 IT_EXPAND_MATRIX_WIDTH (it, area);
18297 it->w->ncols_scale_factor++;
18298 fonts_changed_p = 1;
18299 }
18300} 18330}
18301 18331
18302/* Store one glyph for the composition IT->cmp_id in IT->glyph_row. 18332/* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
@@ -18334,11 +18364,8 @@ append_composite_glyph (it)
18334 glyph->font_type = FONT_TYPE_UNKNOWN; 18364 glyph->font_type = FONT_TYPE_UNKNOWN;
18335 ++it->glyph_row->used[area]; 18365 ++it->glyph_row->used[area];
18336 } 18366 }
18337 else if (!fonts_changed_p) 18367 else
18338 { 18368 IT_EXPAND_MATRIX_WIDTH (it, area);
18339 it->w->ncols_scale_factor++;
18340 fonts_changed_p = 1;
18341 }
18342} 18369}
18343 18370
18344 18371
@@ -18508,11 +18535,8 @@ produce_image_glyph (it)
18508 glyph->font_type = FONT_TYPE_UNKNOWN; 18535 glyph->font_type = FONT_TYPE_UNKNOWN;
18509 ++it->glyph_row->used[area]; 18536 ++it->glyph_row->used[area];
18510 } 18537 }
18511 else if (!fonts_changed_p) 18538 else
18512 { 18539 IT_EXPAND_MATRIX_WIDTH (it, area);
18513 it->w->ncols_scale_factor++;
18514 fonts_changed_p = 1;
18515 }
18516 } 18540 }
18517} 18541}
18518 18542
@@ -18556,11 +18580,8 @@ append_stretch_glyph (it, object, width, height, ascent)
18556 glyph->font_type = FONT_TYPE_UNKNOWN; 18580 glyph->font_type = FONT_TYPE_UNKNOWN;
18557 ++it->glyph_row->used[area]; 18581 ++it->glyph_row->used[area];
18558 } 18582 }
18559 else if (!fonts_changed_p) 18583 else
18560 { 18584 IT_EXPAND_MATRIX_WIDTH (it, area);
18561 it->w->ncols_scale_factor++;
18562 fonts_changed_p = 1;
18563 }
18564} 18585}
18565 18586
18566 18587
@@ -18615,14 +18636,14 @@ produce_stretch_glyph (it)
18615 plist = XCDR (it->object); 18636 plist = XCDR (it->object);
18616 18637
18617 /* Compute the width of the stretch. */ 18638 /* Compute the width of the stretch. */
18618 if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) 18639 if ((prop = Fsafe_plist_get (plist, QCwidth), !NILP (prop))
18619 && calc_pixel_width_or_height (&tem, it, prop, font, 1, 0)) 18640 && calc_pixel_width_or_height (&tem, it, prop, font, 1, 0))
18620 { 18641 {
18621 /* Absolute width `:width WIDTH' specified and valid. */ 18642 /* Absolute width `:width WIDTH' specified and valid. */
18622 zero_width_ok_p = 1; 18643 zero_width_ok_p = 1;
18623 width = (int)tem; 18644 width = (int)tem;
18624 } 18645 }
18625 else if (prop = Fplist_get (plist, QCrelative_width), 18646 else if (prop = Fsafe_plist_get (plist, QCrelative_width),
18626 NUMVAL (prop) > 0) 18647 NUMVAL (prop) > 0)
18627 { 18648 {
18628 /* Relative width `:relative-width FACTOR' specified and valid. 18649 /* Relative width `:relative-width FACTOR' specified and valid.
@@ -18646,7 +18667,7 @@ produce_stretch_glyph (it)
18646 x_produce_glyphs (&it2); 18667 x_produce_glyphs (&it2);
18647 width = NUMVAL (prop) * it2.pixel_width; 18668 width = NUMVAL (prop) * it2.pixel_width;
18648 } 18669 }
18649 else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) 18670 else if ((prop = Fsafe_plist_get (plist, QCalign_to), !NILP (prop))
18650 && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to)) 18671 && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to))
18651 { 18672 {
18652 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) 18673 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
@@ -18666,13 +18687,13 @@ produce_stretch_glyph (it)
18666 width = 1; 18687 width = 1;
18667 18688
18668 /* Compute height. */ 18689 /* Compute height. */
18669 if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) 18690 if ((prop = Fsafe_plist_get (plist, QCheight), !NILP (prop))
18670 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) 18691 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
18671 { 18692 {
18672 height = (int)tem; 18693 height = (int)tem;
18673 zero_height_ok_p = 1; 18694 zero_height_ok_p = 1;
18674 } 18695 }
18675 else if (prop = Fplist_get (plist, QCrelative_height), 18696 else if (prop = Fsafe_plist_get (plist, QCrelative_height),
18676 NUMVAL (prop) > 0) 18697 NUMVAL (prop) > 0)
18677 height = FONT_HEIGHT (font) * NUMVAL (prop); 18698 height = FONT_HEIGHT (font) * NUMVAL (prop);
18678 else 18699 else
@@ -18684,7 +18705,7 @@ produce_stretch_glyph (it)
18684 /* Compute percentage of height used for ascent. If 18705 /* Compute percentage of height used for ascent. If
18685 `:ascent ASCENT' is present and valid, use that. Otherwise, 18706 `:ascent ASCENT' is present and valid, use that. Otherwise,
18686 derive the ascent from the font in use. */ 18707 derive the ascent from the font in use. */
18687 if (prop = Fplist_get (plist, QCascent), 18708 if (prop = Fsafe_plist_get (plist, QCascent),
18688 NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) 18709 NUMVAL (prop) > 0 && NUMVAL (prop) <= 100)
18689 ascent = height * NUMVAL (prop) / 100.0; 18710 ascent = height * NUMVAL (prop) / 100.0;
18690 else if (!NILP (prop) 18711 else if (!NILP (prop)
@@ -20055,6 +20076,11 @@ erase_phys_cursor (w)
20055 if (!cursor_row->enabled_p) 20076 if (!cursor_row->enabled_p)
20056 goto mark_cursor_off; 20077 goto mark_cursor_off;
20057 20078
20079 /* If line spacing is > 0, old cursor may only be partially visible in
20080 window after split-window. So adjust visible height. */
20081 cursor_row->visible_height = min (cursor_row->visible_height,
20082 window_text_bottom_y (w) - cursor_row->y);
20083
20058 /* If row is completely invisible, don't attempt to delete a cursor which 20084 /* If row is completely invisible, don't attempt to delete a cursor which
20059 isn't there. This can happen if cursor is at top of a window, and 20085 isn't there. This can happen if cursor is at top of a window, and
20060 we switch to a buffer with a header line in that window. */ 20086 we switch to a buffer with a header line in that window. */
@@ -20098,6 +20124,7 @@ erase_phys_cursor (w)
20098 { 20124 {
20099 int x, y; 20125 int x, y;
20100 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w); 20126 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
20127 int width;
20101 20128
20102 cursor_glyph = get_phys_cursor_glyph (w); 20129 cursor_glyph = get_phys_cursor_glyph (w);
20103 if (cursor_glyph == NULL) 20130 if (cursor_glyph == NULL)
@@ -20105,9 +20132,10 @@ erase_phys_cursor (w)
20105 20132
20106 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 20133 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
20107 y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y)); 20134 y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y));
20135 width = min (cursor_glyph->pixel_width,
20136 window_box_width (w, TEXT_AREA) - w->phys_cursor.x);
20108 20137
20109 FRAME_RIF (f)->clear_frame_area (f, x, y, 20138 FRAME_RIF (f)->clear_frame_area (f, x, y, width, cursor_row->visible_height);
20110 cursor_glyph->pixel_width, cursor_row->visible_height);
20111 } 20139 }
20112 20140
20113 /* Erase the cursor by redrawing the character underneath it. */ 20141 /* Erase the cursor by redrawing the character underneath it. */
@@ -20887,7 +20915,7 @@ note_mode_line_or_margin_highlight (w, x, y, area)
20887 if (IMAGEP (object)) 20915 if (IMAGEP (object))
20888 { 20916 {
20889 Lisp_Object image_map, hotspot; 20917 Lisp_Object image_map, hotspot;
20890 if ((image_map = Fplist_get (XCDR (object), QCmap), 20918 if ((image_map = Fsafe_plist_get (XCDR (object), QCmap),
20891 !NILP (image_map)) 20919 !NILP (image_map))
20892 && (hotspot = find_hot_spot (image_map, dx, dy), 20920 && (hotspot = find_hot_spot (image_map, dx, dy),
20893 CONSP (hotspot)) 20921 CONSP (hotspot))
@@ -20899,12 +20927,14 @@ note_mode_line_or_margin_highlight (w, x, y, area)
20899 /* Could check AREA_ID to see if we enter/leave this hot-spot. 20927 /* Could check AREA_ID to see if we enter/leave this hot-spot.
20900 If so, we could look for mouse-enter, mouse-leave 20928 If so, we could look for mouse-enter, mouse-leave
20901 properties in PLIST (and do something...). */ 20929 properties in PLIST (and do something...). */
20902 if ((plist = XCDR (hotspot), CONSP (plist))) 20930 hotspot = XCDR (hotspot);
20931 if (CONSP (hotspot)
20932 && (plist = XCAR (hotspot), CONSP (plist)))
20903 { 20933 {
20904 pointer = Fplist_get (plist, Qpointer); 20934 pointer = Fsafe_plist_get (plist, Qpointer);
20905 if (NILP (pointer)) 20935 if (NILP (pointer))
20906 pointer = Qhand; 20936 pointer = Qhand;
20907 help = Fplist_get (plist, Qhelp_echo); 20937 help = Fsafe_plist_get (plist, Qhelp_echo);
20908 if (!NILP (help)) 20938 if (!NILP (help))
20909 { 20939 {
20910 help_echo_string = help; 20940 help_echo_string = help;
@@ -20915,7 +20945,7 @@ note_mode_line_or_margin_highlight (w, x, y, area)
20915 } 20945 }
20916 } 20946 }
20917 if (NILP (pointer)) 20947 if (NILP (pointer))
20918 pointer = Fplist_get (XCDR (object), QCpointer); 20948 pointer = Fsafe_plist_get (XCDR (object), QCpointer);
20919 } 20949 }
20920 } 20950 }
20921 20951
@@ -20925,13 +20955,16 @@ note_mode_line_or_margin_highlight (w, x, y, area)
20925 /* If we're on a string with `help-echo' text property, arrange 20955 /* If we're on a string with `help-echo' text property, arrange
20926 for the help to be displayed. This is done by setting the 20956 for the help to be displayed. This is done by setting the
20927 global variable help_echo_string to the help string. */ 20957 global variable help_echo_string to the help string. */
20928 help = Fget_text_property (pos, Qhelp_echo, string); 20958 if (NILP (help))
20929 if (!NILP (help))
20930 { 20959 {
20931 help_echo_string = help; 20960 help = Fget_text_property (pos, Qhelp_echo, string);
20932 XSETWINDOW (help_echo_window, w); 20961 if (!NILP (help))
20933 help_echo_object = string; 20962 {
20934 help_echo_pos = charpos; 20963 help_echo_string = help;
20964 XSETWINDOW (help_echo_window, w);
20965 help_echo_object = string;
20966 help_echo_pos = charpos;
20967 }
20935 } 20968 }
20936 20969
20937 if (NILP (pointer)) 20970 if (NILP (pointer))
@@ -21066,7 +21099,7 @@ note_mouse_highlight (f, x, y)
21066 if (img != NULL && IMAGEP (img->spec)) 21099 if (img != NULL && IMAGEP (img->spec))
21067 { 21100 {
21068 Lisp_Object image_map, hotspot; 21101 Lisp_Object image_map, hotspot;
21069 if ((image_map = Fplist_get (XCDR (img->spec), QCmap), 21102 if ((image_map = Fsafe_plist_get (XCDR (img->spec), QCmap),
21070 !NILP (image_map)) 21103 !NILP (image_map))
21071 && (hotspot = find_hot_spot (image_map, 21104 && (hotspot = find_hot_spot (image_map,
21072 glyph->slice.x + dx, 21105 glyph->slice.x + dx,
@@ -21080,12 +21113,14 @@ note_mouse_highlight (f, x, y)
21080 /* Could check AREA_ID to see if we enter/leave this hot-spot. 21113 /* Could check AREA_ID to see if we enter/leave this hot-spot.
21081 If so, we could look for mouse-enter, mouse-leave 21114 If so, we could look for mouse-enter, mouse-leave
21082 properties in PLIST (and do something...). */ 21115 properties in PLIST (and do something...). */
21083 if ((plist = XCDR (hotspot), CONSP (plist))) 21116 hotspot = XCDR (hotspot);
21117 if (CONSP (hotspot)
21118 && (plist = XCAR (hotspot), CONSP (plist)))
21084 { 21119 {
21085 pointer = Fplist_get (plist, Qpointer); 21120 pointer = Fsafe_plist_get (plist, Qpointer);
21086 if (NILP (pointer)) 21121 if (NILP (pointer))
21087 pointer = Qhand; 21122 pointer = Qhand;
21088 help_echo_string = Fplist_get (plist, Qhelp_echo); 21123 help_echo_string = Fsafe_plist_get (plist, Qhelp_echo);
21089 if (!NILP (help_echo_string)) 21124 if (!NILP (help_echo_string))
21090 { 21125 {
21091 help_echo_window = window; 21126 help_echo_window = window;
@@ -21095,7 +21130,7 @@ note_mouse_highlight (f, x, y)
21095 } 21130 }
21096 } 21131 }
21097 if (NILP (pointer)) 21132 if (NILP (pointer))
21098 pointer = Fplist_get (XCDR (img->spec), QCpointer); 21133 pointer = Fsafe_plist_get (XCDR (img->spec), QCpointer);
21099 } 21134 }
21100 } 21135 }
21101 21136
@@ -22394,6 +22429,10 @@ otherwise. */);
22394 doc: /* *Non-nil means raise tool-bar buttons when the mouse moves over them. */); 22429 doc: /* *Non-nil means raise tool-bar buttons when the mouse moves over them. */);
22395 auto_raise_tool_bar_buttons_p = 1; 22430 auto_raise_tool_bar_buttons_p = 1;
22396 22431
22432 DEFVAR_BOOL ("make-cursor-line-fully-visible", &make_cursor_line_fully_visible_p,
22433 doc: /* *Non-nil means to scroll (recenter) cursor line if it is not fully visible. */);
22434 make_cursor_line_fully_visible_p = 1;
22435
22397 DEFVAR_LISP ("tool-bar-button-margin", &Vtool_bar_button_margin, 22436 DEFVAR_LISP ("tool-bar-button-margin", &Vtool_bar_button_margin,
22398 doc: /* *Margin around tool-bar buttons in pixels. 22437 doc: /* *Margin around tool-bar buttons in pixels.
22399If an integer, use that for both horizontal and vertical margins. 22438If an integer, use that for both horizontal and vertical margins.
diff --git a/src/xfns.c b/src/xfns.c
index cdce77f158f..a99f3ddd1b8 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5129,6 +5129,23 @@ file_dialog_unmap_cb (widget, client_data, call_data)
5129 *result = XmCR_CANCEL; 5129 *result = XmCR_CANCEL;
5130} 5130}
5131 5131
5132static Lisp_Object
5133clean_up_file_dialog (arg)
5134 Lisp_Object arg;
5135{
5136 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
5137 Widget dialog = (Widget) p->pointer;
5138
5139 /* Clean up. */
5140 BLOCK_INPUT;
5141 XtUnmanageChild (dialog);
5142 XtDestroyWidget (dialog);
5143 x_menu_set_in_use (0);
5144 UNBLOCK_INPUT;
5145
5146 return Qnil;
5147}
5148
5132 5149
5133DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, 5150DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
5134 doc: /* Read file name, prompting with PROMPT in directory DIR. 5151 doc: /* Read file name, prompting with PROMPT in directory DIR.
@@ -5150,6 +5167,10 @@ or directory must exist. ONLY-DIR-P is ignored." */)
5150 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5167 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5151 5168
5152 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); 5169 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5170
5171 if (popup_activated ())
5172 error ("Trying to use a menu from within a menu-entry");
5173
5153 CHECK_STRING (prompt); 5174 CHECK_STRING (prompt);
5154 CHECK_STRING (dir); 5175 CHECK_STRING (dir);
5155 5176
@@ -5232,13 +5253,17 @@ or directory must exist. ONLY-DIR-P is ignored." */)
5232 XmStringFree (default_xmstring); 5253 XmStringFree (default_xmstring);
5233 } 5254 }
5234 5255
5256 record_unwind_protect (clean_up_file_dialog, make_save_value (dialog, 0));
5257
5235 /* Process events until the user presses Cancel or OK. */ 5258 /* Process events until the user presses Cancel or OK. */
5259 x_menu_set_in_use (1);
5236 result = 0; 5260 result = 0;
5237 while (result == 0) 5261 while (result == 0)
5238 { 5262 {
5239 XEvent event; 5263 XEvent event;
5264 x_menu_wait_for_event (0);
5240 XtAppNextEvent (Xt_app_con, &event); 5265 XtAppNextEvent (Xt_app_con, &event);
5241 (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f) ); 5266 (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f));
5242 } 5267 }
5243 5268
5244 /* Get the result. */ 5269 /* Get the result. */
@@ -5256,9 +5281,6 @@ or directory must exist. ONLY-DIR-P is ignored." */)
5256 else 5281 else
5257 file = Qnil; 5282 file = Qnil;
5258 5283
5259 /* Clean up. */
5260 XtUnmanageChild (dialog);
5261 XtDestroyWidget (dialog);
5262 UNBLOCK_INPUT; 5284 UNBLOCK_INPUT;
5263 UNGCPRO; 5285 UNGCPRO;
5264 5286
@@ -5273,6 +5295,15 @@ or directory must exist. ONLY-DIR-P is ignored." */)
5273 5295
5274#ifdef USE_GTK 5296#ifdef USE_GTK
5275 5297
5298static Lisp_Object
5299clean_up_dialog (arg)
5300 Lisp_Object arg;
5301{
5302 x_menu_set_in_use (0);
5303
5304 return Qnil;
5305}
5306
5276DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, 5307DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
5277 doc: /* Read file name, prompting with PROMPT in directory DIR. 5308 doc: /* Read file name, prompting with PROMPT in directory DIR.
5278Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file 5309Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
@@ -5285,16 +5316,21 @@ directories. */)
5285 FRAME_PTR f = SELECTED_FRAME (); 5316 FRAME_PTR f = SELECTED_FRAME ();
5286 char *fn; 5317 char *fn;
5287 Lisp_Object file = Qnil; 5318 Lisp_Object file = Qnil;
5288 int count = specpdl_ptr - specpdl; 5319 int count = SPECPDL_INDEX ();
5289 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5320 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5290 char *cdef_file; 5321 char *cdef_file;
5291 5322
5292 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); 5323 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5324
5325 if (popup_activated ())
5326 error ("Trying to use a menu from within a menu-entry");
5327
5293 CHECK_STRING (prompt); 5328 CHECK_STRING (prompt);
5294 CHECK_STRING (dir); 5329 CHECK_STRING (dir);
5295 5330
5296 /* Prevent redisplay. */ 5331 /* Prevent redisplay. */
5297 specbind (Qinhibit_redisplay, Qt); 5332 specbind (Qinhibit_redisplay, Qt);
5333 record_unwind_protect (clean_up_dialog, Qnil);
5298 5334
5299 BLOCK_INPUT; 5335 BLOCK_INPUT;
5300 5336
diff --git a/src/xmenu.c b/src/xmenu.c
index 0a83266a482..f50237ea8c8 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -288,7 +288,7 @@ finish_menu_items ()
288 288
289static Lisp_Object 289static Lisp_Object
290unuse_menu_items (dummy) 290unuse_menu_items (dummy)
291 int dummy; 291 Lisp_Object dummy;
292{ 292{
293 return menu_items_inuse = Qnil; 293 return menu_items_inuse = Qnil;
294} 294}
@@ -1118,9 +1118,19 @@ on the left of the dialog box and all following items on the right.
1118 1118
1119#ifndef MSDOS 1119#ifndef MSDOS
1120 1120
1121/* Set menu_items_inuse so no other popup menu or dialog is created. */
1122
1123void
1124x_menu_set_in_use (in_use)
1125 int in_use;
1126{
1127 menu_items_inuse = in_use ? Qt : Qnil;
1128 popup_activated_flag = in_use;
1129}
1130
1121/* Wait for an X event to arrive or for a timer to expire. */ 1131/* Wait for an X event to arrive or for a timer to expire. */
1122 1132
1123static void 1133void
1124x_menu_wait_for_event (void *data) 1134x_menu_wait_for_event (void *data)
1125{ 1135{
1126 extern EMACS_TIME timer_check P_ ((int)); 1136 extern EMACS_TIME timer_check P_ ((int));
@@ -1173,14 +1183,6 @@ x_menu_wait_for_event (void *data)
1173 1183
1174#ifdef USE_X_TOOLKIT 1184#ifdef USE_X_TOOLKIT
1175 1185
1176static Lisp_Object
1177pop_down_menu (dummy)
1178 int dummy;
1179{
1180 popup_activated_flag = 0;
1181 return Qnil;
1182}
1183
1184/* Loop in Xt until the menu pulldown or dialog popup has been 1186/* Loop in Xt until the menu pulldown or dialog popup has been
1185 popped down (deactivated). This is used for x-popup-menu 1187 popped down (deactivated). This is used for x-popup-menu
1186 and x-popup-dialog; it is not used for the menu bar. 1188 and x-popup-dialog; it is not used for the menu bar.
@@ -1200,9 +1202,6 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1200{ 1202{
1201 XEvent event; 1203 XEvent event;
1202 1204
1203 int specpdl_count = SPECPDL_INDEX ();
1204 record_unwind_protect (pop_down_menu, Qnil);
1205
1206 while (popup_activated_flag) 1205 while (popup_activated_flag)
1207 { 1206 {
1208 if (initial_event) 1207 if (initial_event)
@@ -1252,8 +1251,6 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1252 1251
1253 x_dispatch_event (&event, event.xany.display); 1252 x_dispatch_event (&event, event.xany.display);
1254 } 1253 }
1255
1256 unbind_to (specpdl_count, Qnil);
1257} 1254}
1258 1255
1259#endif /* USE_X_TOOLKIT */ 1256#endif /* USE_X_TOOLKIT */
@@ -1261,30 +1258,12 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1261#ifdef USE_GTK 1258#ifdef USE_GTK
1262/* Loop util popup_activated_flag is set to zero in a callback. 1259/* Loop util popup_activated_flag is set to zero in a callback.
1263 Used for popup menus and dialogs. */ 1260 Used for popup menus and dialogs. */
1264static GtkWidget *current_menu;
1265
1266static Lisp_Object
1267pop_down_menu (dummy)
1268 int dummy;
1269{
1270 if (current_menu)
1271 {
1272 gtk_widget_unmap (current_menu);
1273 current_menu = 0;
1274 popup_activated_flag = 0;
1275 }
1276 return Qnil;
1277}
1278 1261
1279static void 1262static void
1280popup_widget_loop (do_timers, widget) 1263popup_widget_loop (do_timers, widget)
1281 int do_timers; 1264 int do_timers;
1282 GtkWidget *widget; 1265 GtkWidget *widget;
1283{ 1266{
1284 int specpdl_count = SPECPDL_INDEX ();
1285 current_menu = widget;
1286 record_unwind_protect (pop_down_menu, Qnil);
1287
1288 ++popup_activated_flag; 1267 ++popup_activated_flag;
1289 1268
1290 /* Process events in the Gtk event loop until done. */ 1269 /* Process events in the Gtk event loop until done. */
@@ -1293,8 +1272,6 @@ popup_widget_loop (do_timers, widget)
1293 if (do_timers) x_menu_wait_for_event (0); 1272 if (do_timers) x_menu_wait_for_event (0);
1294 gtk_main_iteration (); 1273 gtk_main_iteration ();
1295 } 1274 }
1296
1297 unbind_to (specpdl_count, Qnil);
1298} 1275}
1299#endif 1276#endif
1300 1277
@@ -2443,6 +2420,19 @@ popup_selection_callback (widget, client_data)
2443 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data; 2420 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data;
2444} 2421}
2445 2422
2423static Lisp_Object
2424pop_down_menu (arg)
2425 Lisp_Object arg;
2426{
2427 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
2428
2429 popup_activated_flag = 0;
2430 BLOCK_INPUT;
2431 gtk_widget_destroy (GTK_WIDGET (p->pointer));
2432 UNBLOCK_INPUT;
2433 return Qnil;
2434}
2435
2446/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the 2436/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2447 menu pops down. 2437 menu pops down.
2448 menu_item_selection will be set to the selection. */ 2438 menu_item_selection will be set to the selection. */
@@ -2458,6 +2448,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2458 GtkWidget *menu; 2448 GtkWidget *menu;
2459 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */ 2449 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */
2460 struct next_popup_x_y popup_x_y; 2450 struct next_popup_x_y popup_x_y;
2451 int specpdl_count = SPECPDL_INDEX ();
2461 2452
2462 xg_crazy_callback_abort = 1; 2453 xg_crazy_callback_abort = 1;
2463 menu = xg_create_widget ("popup", first_wv->name, f, first_wv, 2454 menu = xg_create_widget ("popup", first_wv->name, f, first_wv,
@@ -2488,13 +2479,15 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2488 gtk_widget_show_all (menu); 2479 gtk_widget_show_all (menu);
2489 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0); 2480 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
2490 2481
2482 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
2483
2491 /* Set this to one. popup_widget_loop increases it by one, so it becomes 2484 /* Set this to one. popup_widget_loop increases it by one, so it becomes
2492 two. show_help_echo uses this to detect popup menus. */ 2485 two. show_help_echo uses this to detect popup menus. */
2493 popup_activated_flag = 1; 2486 popup_activated_flag = 1;
2494 /* Process events that apply to the menu. */ 2487 /* Process events that apply to the menu. */
2495 popup_widget_loop (1, 0); 2488 popup_widget_loop (1, menu);
2496 2489
2497 gtk_widget_destroy (menu); 2490 unbind_to (specpdl_count, Qnil);
2498 2491
2499 /* Must reset this manually because the button release event is not passed 2492 /* Must reset this manually because the button release event is not passed
2500 to Emacs event loop. */ 2493 to Emacs event loop. */
@@ -2522,6 +2515,24 @@ popup_selection_callback (widget, id, client_data)
2522 menu_item_selection = (Lisp_Object *) client_data; 2515 menu_item_selection = (Lisp_Object *) client_data;
2523} 2516}
2524 2517
2518/* ARG is the LWLIB ID of the dialog box, represented
2519 as a Lisp object as (HIGHPART . LOWPART). */
2520
2521static Lisp_Object
2522pop_down_menu (arg)
2523 Lisp_Object arg;
2524{
2525 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
2526 | XINT (XCDR (arg)));
2527
2528 BLOCK_INPUT;
2529 lw_destroy_all_widgets (id);
2530 UNBLOCK_INPUT;
2531 popup_activated_flag = 0;
2532
2533 return Qnil;
2534}
2535
2525/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the 2536/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2526 menu pops down. 2537 menu pops down.
2527 menu_item_selection will be set to the selection. */ 2538 menu_item_selection will be set to the selection. */
@@ -2578,15 +2589,19 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2578 /* Display the menu. */ 2589 /* Display the menu. */
2579 lw_popup_menu (menu, (XEvent *) &dummy); 2590 lw_popup_menu (menu, (XEvent *) &dummy);
2580 popup_activated_flag = 1; 2591 popup_activated_flag = 1;
2592
2593 {
2594 int fact = 4 * sizeof (LWLIB_ID);
2595 int specpdl_count = SPECPDL_INDEX ();
2596 record_unwind_protect (pop_down_menu,
2597 Fcons (make_number (menu_id >> (fact)),
2598 make_number (menu_id & ~(-1 << (fact)))));
2581 2599
2582 /* Process events that apply to the menu. */ 2600 /* Process events that apply to the menu. */
2583 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1, 0); 2601 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1, 0);
2584 2602
2585 /* fp turned off the following statement and wrote a comment 2603 unbind_to (specpdl_count, Qnil);
2586 that it is unnecessary--that the menu has already disappeared. 2604 }
2587 Nowadays the menu disappears ok, all right, but
2588 we need to delete the widgets or multiple ones will pile up. */
2589 lw_destroy_all_widgets (menu_id);
2590} 2605}
2591 2606
2592#endif /* not USE_GTK */ 2607#endif /* not USE_GTK */
@@ -2897,13 +2912,16 @@ create_and_show_dialog (f, first_wv)
2897 2912
2898 if (menu) 2913 if (menu)
2899 { 2914 {
2915 int specpdl_count = SPECPDL_INDEX ();
2916 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
2917
2900 /* Display the menu. */ 2918 /* Display the menu. */
2901 gtk_widget_show_all (menu); 2919 gtk_widget_show_all (menu);
2902 2920
2903 /* Process events that apply to the menu. */ 2921 /* Process events that apply to the menu. */
2904 popup_widget_loop (1, menu); 2922 popup_widget_loop (1, menu);
2905 2923
2906 gtk_widget_destroy (menu); 2924 unbind_to (specpdl_count, Qnil);
2907 } 2925 }
2908} 2926}
2909 2927
@@ -2926,23 +2944,6 @@ dialog_selection_callback (widget, id, client_data)
2926} 2944}
2927 2945
2928 2946
2929/* ARG is the LWLIB ID of the dialog box, represented
2930 as a Lisp object as (HIGHPART . LOWPART). */
2931
2932Lisp_Object
2933xdialog_show_unwind (arg)
2934 Lisp_Object arg;
2935{
2936 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
2937 | XINT (XCDR (arg)));
2938 BLOCK_INPUT;
2939 lw_destroy_all_widgets (id);
2940 UNBLOCK_INPUT;
2941 popup_activated_flag = 0;
2942 return Qnil;
2943}
2944
2945
2946/* Pop up the dialog for frame F defined by FIRST_WV and loop until the 2947/* Pop up the dialog for frame F defined by FIRST_WV and loop until the
2947 dialog pops down. 2948 dialog pops down.
2948 menu_item_selection will be set to the selection. */ 2949 menu_item_selection will be set to the selection. */
@@ -2970,7 +2971,7 @@ create_and_show_dialog (f, first_wv)
2970 int fact = 4 * sizeof (LWLIB_ID); 2971 int fact = 4 * sizeof (LWLIB_ID);
2971 2972
2972 /* xdialog_show_unwind is responsible for popping the dialog box down. */ 2973 /* xdialog_show_unwind is responsible for popping the dialog box down. */
2973 record_unwind_protect (xdialog_show_unwind, 2974 record_unwind_protect (pop_down_menu,
2974 Fcons (make_number (dialog_id >> (fact)), 2975 Fcons (make_number (dialog_id >> (fact)),
2975 make_number (dialog_id & ~(-1 << (fact))))); 2976 make_number (dialog_id & ~(-1 << (fact)))));
2976 2977
@@ -3203,6 +3204,41 @@ menu_help_callback (help_string, pane, item)
3203 Qnil, menu_object, make_number (item), 1); 3204 Qnil, menu_object, make_number (item), 1);
3204} 3205}
3205 3206
3207static Lisp_Object
3208pop_down_menu (arg)
3209 Lisp_Object arg;
3210{
3211 struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg));
3212 struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg));
3213
3214 FRAME_PTR f = p1->pointer;
3215 XMenu *menu = p2->pointer;
3216
3217 BLOCK_INPUT;
3218#ifndef MSDOS
3219 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime);
3220 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime);
3221#endif
3222 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
3223
3224#ifdef HAVE_X_WINDOWS
3225 /* Assume the mouse has moved out of the X window.
3226 If it has actually moved in, we will get an EnterNotify. */
3227 x_mouse_leave (FRAME_X_DISPLAY_INFO (f));
3228
3229 /* State that no mouse buttons are now held.
3230 (The oldXMenu code doesn't track this info for us.)
3231 That is not necessarily true, but the fiction leads to reasonable
3232 results, and it is a pain to ask which are actually held now. */
3233 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
3234
3235#endif /* HAVE_X_WINDOWS */
3236
3237 UNBLOCK_INPUT;
3238
3239 return Qnil;
3240}
3241
3206 3242
3207static Lisp_Object 3243static Lisp_Object
3208xmenu_show (f, x, y, for_click, keymaps, title, error) 3244xmenu_show (f, x, y, for_click, keymaps, title, error)
@@ -3224,6 +3260,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3224 int maxwidth; 3260 int maxwidth;
3225 int dummy_int; 3261 int dummy_int;
3226 unsigned int dummy_uint; 3262 unsigned int dummy_uint;
3263 int specpdl_count = SPECPDL_INDEX ();
3227 3264
3228 *error = 0; 3265 *error = 0;
3229 if (menu_items_n_panes == 0) 3266 if (menu_items_n_panes == 0)
@@ -3416,20 +3453,17 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3416#ifndef MSDOS 3453#ifndef MSDOS
3417 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); 3454 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
3418#endif 3455#endif
3456
3457 record_unwind_protect (pop_down_menu,
3458 Fcons (make_save_value (f, 0),
3459 make_save_value (menu, 0)));
3419 3460
3420 /* Help display under X won't work because XMenuActivate contains 3461 /* Help display under X won't work because XMenuActivate contains
3421 a loop that doesn't give Emacs a chance to process it. */ 3462 a loop that doesn't give Emacs a chance to process it. */
3422 menu_help_frame = f; 3463 menu_help_frame = f;
3423 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, 3464 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
3424 x, y, ButtonReleaseMask, &datap, 3465 x, y, ButtonReleaseMask, &datap,
3425 menu_help_callback); 3466 menu_help_callback);
3426
3427
3428#ifdef HAVE_X_WINDOWS
3429 /* Assume the mouse has moved out of the X window.
3430 If it has actually moved in, we will get an EnterNotify. */
3431 x_mouse_leave (FRAME_X_DISPLAY_INFO (f));
3432#endif
3433 3467
3434 switch (status) 3468 switch (status)
3435 { 3469 {
@@ -3480,15 +3514,8 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3480 entry = Qnil; 3514 entry = Qnil;
3481 break; 3515 break;
3482 } 3516 }
3483 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
3484 3517
3485#ifdef HAVE_X_WINDOWS 3518 unbind_to (specpdl_count, Qnil);
3486 /* State that no mouse buttons are now held.
3487 (The oldXMenu code doesn't track this info for us.)
3488 That is not necessarily true, but the fiction leads to reasonable
3489 results, and it is a pain to ask which are actually held now. */
3490 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
3491#endif
3492 3519
3493 return entry; 3520 return entry;
3494} 3521}
diff --git a/src/xterm.c b/src/xterm.c
index a1fd1d5dcc2..5c7775d6777 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -358,7 +358,7 @@ static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
358static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 358static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
359 enum text_cursor_kinds)); 359 enum text_cursor_kinds));
360 360
361static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC)); 361static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC));
362static void x_flush P_ ((struct frame *f)); 362static void x_flush P_ ((struct frame *f));
363static void x_update_begin P_ ((struct frame *)); 363static void x_update_begin P_ ((struct frame *));
364static void x_update_window_begin P_ ((struct window *)); 364static void x_update_window_begin P_ ((struct window *));
@@ -710,12 +710,12 @@ x_draw_fringe_bitmap (w, row, p)
710 int oldVH = row->visible_height; 710 int oldVH = row->visible_height;
711 row->visible_height = p->h; 711 row->visible_height = p->h;
712 row->y -= rowY - p->y; 712 row->y -= rowY - p->y;
713 x_clip_to_row (w, row, gc); 713 x_clip_to_row (w, row, -1, gc);
714 row->y = oldY; 714 row->y = oldY;
715 row->visible_height = oldVH; 715 row->visible_height = oldVH;
716 } 716 }
717 else 717 else
718 x_clip_to_row (w, row, gc); 718 x_clip_to_row (w, row, -1, gc);
719 719
720 if (p->bx >= 0 && !p->overlay_p) 720 if (p->bx >= 0 && !p->overlay_p)
721 { 721 {
@@ -7139,18 +7139,19 @@ XTread_socket (display, expected, hold_quit)
7139 mode lines must be clipped to the whole window. */ 7139 mode lines must be clipped to the whole window. */
7140 7140
7141static void 7141static void
7142x_clip_to_row (w, row, gc) 7142x_clip_to_row (w, row, area, gc)
7143 struct window *w; 7143 struct window *w;
7144 struct glyph_row *row; 7144 struct glyph_row *row;
7145 int area;
7145 GC gc; 7146 GC gc;
7146{ 7147{
7147 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7148 struct frame *f = XFRAME (WINDOW_FRAME (w));
7148 XRectangle clip_rect; 7149 XRectangle clip_rect;
7149 int window_y, window_width; 7150 int window_x, window_y, window_width;
7150 7151
7151 window_box (w, -1, 0, &window_y, &window_width, 0); 7152 window_box (w, area, &window_x, &window_y, &window_width, 0);
7152 7153
7153 clip_rect.x = WINDOW_TO_FRAME_PIXEL_X (w, 0); 7154 clip_rect.x = window_x;
7154 clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 7155 clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
7155 clip_rect.y = max (clip_rect.y, window_y); 7156 clip_rect.y = max (clip_rect.y, window_y);
7156 clip_rect.width = window_width; 7157 clip_rect.width = window_width;
@@ -7216,7 +7217,7 @@ x_draw_hollow_cursor (w, row)
7216 gc = dpyinfo->scratch_cursor_gc; 7217 gc = dpyinfo->scratch_cursor_gc;
7217 7218
7218 /* Set clipping, draw the rectangle, and reset clipping again. */ 7219 /* Set clipping, draw the rectangle, and reset clipping again. */
7219 x_clip_to_row (w, row, gc); 7220 x_clip_to_row (w, row, TEXT_AREA, gc);
7220 XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h); 7221 XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h);
7221 XSetClipMask (dpy, gc, None); 7222 XSetClipMask (dpy, gc, None);
7222} 7223}
@@ -7288,7 +7289,7 @@ x_draw_bar_cursor (w, row, width, kind)
7288 width = min (cursor_glyph->pixel_width, width); 7289 width = min (cursor_glyph->pixel_width, width);
7289 7290
7290 w->phys_cursor_width = width; 7291 w->phys_cursor_width = width;
7291 x_clip_to_row (w, row, gc); 7292 x_clip_to_row (w, row, TEXT_AREA, gc);
7292 7293
7293 if (kind == BAR_CURSOR) 7294 if (kind == BAR_CURSOR)
7294 XFillRectangle (dpy, window, gc, 7295 XFillRectangle (dpy, window, gc,
diff --git a/src/xterm.h b/src/xterm.h
index 23f0e43d149..f9bb6adb6e1 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1072,6 +1072,8 @@ extern void x_free_dpy_colors P_ ((Display *, Screen *, Colormap,
1072 1072
1073/* Defined in xmenu.c */ 1073/* Defined in xmenu.c */
1074 1074
1075extern void x_menu_set_in_use P_ ((int));
1076extern void x_menu_wait_for_event P_ ((void *data));
1075extern void x_activate_menubar P_ ((struct frame *)); 1077extern void x_activate_menubar P_ ((struct frame *));
1076extern int popup_activated P_ ((void)); 1078extern int popup_activated P_ ((void));
1077extern void initialize_frame_menubar P_ ((struct frame *)); 1079extern void initialize_frame_menubar P_ ((struct frame *));