aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-10-31 02:05:24 +0000
committerKaroly Lorentey2004-10-31 02:05:24 +0000
commite0bc17abe6979d607e8de4684dddb96e53c60065 (patch)
treeb7cb7bc5df9f12138937fd958cdf4b9c2d19ee3a /src
parentf158167a84475d5fc41931531406821e6413afd7 (diff)
parent707994d2626cf0f01c3ece4028d73835068d64dc (diff)
downloademacs-e0bc17abe6979d607e8de4684dddb96e53c60065.tar.gz
emacs-e0bc17abe6979d607e8de4684dddb96e53c60065.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-639 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-640 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-641 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-642 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-643 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-644 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-645 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-646 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-647 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-648 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-649 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-651 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-652 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-59 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-60 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-61 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-62 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-63 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-263
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog101
-rw-r--r--src/ChangeLog.812
-rw-r--r--src/buffer.c12
-rw-r--r--src/callint.c23
-rw-r--r--src/casefiddle.c2
-rw-r--r--src/charset.c2
-rw-r--r--src/data.c4
-rw-r--r--src/editfns.c29
-rw-r--r--src/fns.c24
-rw-r--r--src/gtkutil.c105
-rw-r--r--src/indent.c53
-rw-r--r--src/lisp.h17
-rw-r--r--src/macterm.c40
-rw-r--r--src/search.c2
-rw-r--r--src/syntax.c44
-rw-r--r--src/w32fns.c4
-rw-r--r--src/xdisp.c4
-rw-r--r--src/xfns.c7
-rw-r--r--src/xselect.c20
-rw-r--r--src/xsmfns.c82
20 files changed, 401 insertions, 186 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1490b34b4a9..8479a0f94ce 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,74 @@
12004-10-28 Will <will@glozer.net>
2
3 * macterm.c: allow user to assign key modifiers to the Mac Option
4 key via a 'mac-option-modifier' variable.
5
62004-10-28 Stefan <monnier@iro.umontreal.ca>
7
8 * xselect.c (Vx_lost_selection_functions, Vx_sent_selection_functions):
9 Rename from Vx_lost_selection_hooks and Vx_sent_selection_hooks.
10 (x_handle_selection_request, x_handle_selection_clear)
11 (x_clear_frame_selections, syms_of_xselect): Adjust accordingly.
12
132004-10-28 Richard M. Stallman <rms@gnu.org>
14
15 * w32fns.c (Fx_server_vendor, Fx_server_version): Doc fixes.
16
17 * xfns.c (Fx_server_vendor, Fx_server_version): Doc fixes.
18
192004-10-27 Stefan Monnier <monnier@iro.umontreal.ca>
20
21 * syntax.c (scan_sexps_forward): Give precedence to a 2-char
22 comment-starter over a 1-char one.
23
242004-10-27 Richard M. Stallman <rms@gnu.org>
25
26 * xdisp.c (get_next_display_element): In mode lines,
27 treat newline and tab like other control characters.
28
29 * editfns.c (Fmessage): Doc fix.
30
31 * indent.c (vmotion): When moving up, check the newline before.
32 Make prevline an int, not a Lisp_Object.
33
342004-10-27 Kim F. Storm <storm@cua.dk>
35
36 * editfns.c (Fformat): Allocate discarded table with SAFE_ALLOCA.
37 Only allocate info and discarded tables once.
38
39 * lisp.h (USE_SAFE_ALLOCA): Add and init sa_must_free integer.
40 (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Increment it when malloc is used.
41 (SAFE_FREE): Test it to determine if we need to unwind to free.
42 Remove size arg. All users changed.
43 (SAFE_FREE_LISP) Remove. All users changed to use SAFE_FREE.
44
452004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
46
47 * gtkutil.c: Put empty line between comment and function body.
48 (xg_destroy_widgets): Rename from remove_from_container.
49 Just destroy all widgets in list. Argument wcont removed.
50 (xg_update_menubar, xg_update_submenu): Call xg_destroy_widgets
51 instead of remove_from_container.
52 (xg_display_close, xg_create_tool_bar, update_frame_tool_bar)
53 (free_frame_tool_bar): Add comment.
54
55 * xfns.c (xic_create_xfontset): Check that FRAME_XIC_BASE_FONTNAME
56 is not NULL before strcmp.
57
582004-10-26 Kim F. Storm <storm@cua.dk>
59
60 * callint.c (Fcall_interactively): Add 'U' code to get the
61 up-event discarded by a previous 'k' or 'K' argument.
62
632004-10-26 David Kastrup <dak@gnu.org>
64
65 * buffer.c (syms_of_buffer): Fix a few typos.
66
672004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
68
69 * xsmfns.c: Put empty line between comment and function body.
70 Use two spaces before comment end.
71
12004-10-25 Kenichi Handa <handa@m17n.org> 722004-10-25 Kenichi Handa <handa@m17n.org>
2 73
3 * fontset.c (fontset_pattern_regexp): Optimize for the case that 74 * fontset.c (fontset_pattern_regexp): Optimize for the case that
@@ -21,17 +92,17 @@
21 92
222004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu> 932004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu>
23 94
24 * xterm.h (x_output): New member `xic_base_fontname'. 95 * xterm.h (x_output): New member `xic_base_fontname'.
25 (FRAME_XIC_BASE_FONTNAME): New macro. 96 (FRAME_XIC_BASE_FONTNAME): New macro.
26 (xic_free_xfontset): Declare. 97 (xic_free_xfontset): Declare.
27 98
28 * xfns.c (xic_create_xfontset): Share fontsets between frames 99 * xfns.c (xic_create_xfontset): Share fontsets between frames
29 based on base_fontname. 100 based on base_fontname.
30 (xic_free_xfontset): New function. 101 (xic_free_xfontset): New function.
31 (free_frame_xic): Use it. 102 (free_frame_xic): Use it.
32 (xic_set_xfontset): Ditto. 103 (xic_set_xfontset): Ditto.
33 104
34 * xterm.c (xim_destroy_callback): Ditto. 105 * xterm.c (xim_destroy_callback): Ditto.
35 106
36 107
372004-10-20 B. Anyos <banyos@freemail.hu> (tiny change) 1082004-10-20 B. Anyos <banyos@freemail.hu> (tiny change)
@@ -75,10 +146,10 @@
75 146
76 * gtkutil.h (xg_update_scrollbar_pos): Remove arguments real_left 147 * gtkutil.h (xg_update_scrollbar_pos): Remove arguments real_left
77 and canon_width. 148 and canon_width.
78 (xg_frame_cleared): Removed. 149 (xg_frame_cleared): Remove.
79 150
80 * gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose, 151 * gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose)
81 xg_find_top_left_in_fixed): Removed. 152 (xg_find_top_left_in_fixed): Remove.
82 (xg_create_scroll_bar): Put an event box widget between 153 (xg_create_scroll_bar): Put an event box widget between
83 the scroll bar widget and the edit widget. 154 the scroll bar widget and the edit widget.
84 (xg_show_scroll_bar): Show the parent widget (the event box). 155 (xg_show_scroll_bar): Show the parent widget (the event box).
@@ -87,11 +158,11 @@
87 Move the parent (the event box) widget inside the fixed widget. 158 Move the parent (the event box) widget inside the fixed widget.
88 Move window clear to xterm.c. 159 Move window clear to xterm.c.
89 160
90 * gtkutil.h (xg_frame_cleared): Removed. 161 * gtkutil.h (xg_frame_cleared): Remove.
91 162
92 * xterm.c (x_clear_frame): Remove call to xg_frame_cleared 163 * xterm.c (x_clear_frame): Remove call to xg_frame_cleared
93 (x_scroll_bar_create, XTset_vertical_scroll_bar): Remove 164 (x_scroll_bar_create, XTset_vertical_scroll_bar):
94 arguments left and width to xg_update_scrollbar_pos. 165 Remove arguments left and width to xg_update_scrollbar_pos.
95 (XTset_vertical_scroll_bar): Do x_clear_area for USE_GTK also. 166 (XTset_vertical_scroll_bar): Do x_clear_area for USE_GTK also.
96 167
972004-10-19 Kenichi Handa <handa@m17n.org> 1682004-10-19 Kenichi Handa <handa@m17n.org>
diff --git a/src/ChangeLog.8 b/src/ChangeLog.8
index 91fcdd1c899..a9465058194 100644
--- a/src/ChangeLog.8
+++ b/src/ChangeLog.8
@@ -6,25 +6,25 @@
6 6
71999-12-31 William M. Perry <wmperry@aventail.com> 71999-12-31 William M. Perry <wmperry@aventail.com>
8 8
9 * xfns.c (jpeg_format): Added the :data keyword 9 * xfns.c (jpeg_format): Add the :data keyword
10 (jpeg_image_p): JPEG is valid with :file _or_ :data 10 (jpeg_image_p): JPEG is valid with :file _or_ :data
11 (jpeg_memory_src): Defined new JPEG image source to read from a 11 (jpeg_memory_src): Define new JPEG image source to read from a
12 memory buffer. 12 memory buffer.
13 (jpeg_load): Pay attention to the :data keyword if specified. 13 (jpeg_load): Pay attention to the :data keyword if specified.
14 Instantiates a jpeg_memory_src instead of jpeg_stdio_src if found. 14 Instantiates a jpeg_memory_src instead of jpeg_stdio_src if found.
15 (png_format): Added the :data keyword 15 (png_format): Add the :data keyword
16 (png_image_p): PNG is valid with :file _or_ :data 16 (png_image_p): PNG is valid with :file _or_ :data
17 (png_read_from_memory): New PNG read function to read from a 17 (png_read_from_memory): New PNG read function to read from a
18 memory buffer. 18 memory buffer.
19 (png_load): Pay attention to the :data keyword if specified. 19 (png_load): Pay attention to the :data keyword if specified.
20 Use png_set_read_fn() instead of png_init_io() if specified. 20 Use png_set_read_fn() instead of png_init_io() if specified.
21 (tiff_format): Added the :data keyword for TIFF images. 21 (tiff_format): Add the :data keyword for TIFF images.
22 (tiff_image_p): TIFF is valid with :file _or_ :data 22 (tiff_image_p): TIFF is valid with :file _or_ :data
23 (tiff_read_from_memory): Defined new TIFF I/O functions to read 23 (tiff_read_from_memory): Define new TIFF I/O functions to read
24 from a memory buffer. 24 from a memory buffer.
25 (tiff_load): Pay attention to the :data keyword if specified. 25 (tiff_load): Pay attention to the :data keyword if specified.
26 Uses TIFFClientOpen() instead of TIFFOpen() if specified. 26 Uses TIFFClientOpen() instead of TIFFOpen() if specified.
27 (gif_format): Added the :data keyword 27 (gif_format): Add the :data keyword
28 (gif_image_p): GIF is valid with :file _or_ :data 28 (gif_image_p): GIF is valid with :file _or_ :data
29 (gif_read_from_memory): New GIF input function to read from a 29 (gif_read_from_memory): New GIF input function to read from a
30 memory buffer. 30 memory buffer.
diff --git a/src/buffer.c b/src/buffer.c
index b0368a842ca..b0c8c370931 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5812,21 +5812,21 @@ If the value of the variable is t, undo information is not recorded. */);
5812 doc: /* Non-nil means that Emacs should use caches to handle long lines more quickly. 5812 doc: /* Non-nil means that Emacs should use caches to handle long lines more quickly.
5813 5813
5814Normally, the line-motion functions work by scanning the buffer for 5814Normally, the line-motion functions work by scanning the buffer for
5815newlines. Columnar operations (like move-to-column and 5815newlines. Columnar operations (like `move-to-column' and
5816compute-motion) also work by scanning the buffer, summing character 5816`compute-motion') also work by scanning the buffer, summing character
5817widths as they go. This works well for ordinary text, but if the 5817widths as they go. This works well for ordinary text, but if the
5818buffer's lines are very long (say, more than 500 characters), these 5818buffer's lines are very long (say, more than 500 characters), these
5819motion functions will take longer to execute. Emacs may also take 5819motion functions will take longer to execute. Emacs may also take
5820longer to update the display. 5820longer to update the display.
5821 5821
5822If cache-long-line-scans is non-nil, these motion functions cache the 5822If `cache-long-line-scans' is non-nil, these motion functions cache the
5823results of their scans, and consult the cache to avoid rescanning 5823results of their scans, and consult the cache to avoid rescanning
5824regions of the buffer until the text is modified. The caches are most 5824regions of the buffer until the text is modified. The caches are most
5825beneficial when they prevent the most searching---that is, when the 5825beneficial when they prevent the most searching---that is, when the
5826buffer contains long lines and large regions of characters with the 5826buffer contains long lines and large regions of characters with the
5827same, fixed screen width. 5827same, fixed screen width.
5828 5828
5829When cache-long-line-scans is non-nil, processing short lines will 5829When `cache-long-line-scans' is non-nil, processing short lines will
5830become slightly slower (because of the overhead of consulting the 5830become slightly slower (because of the overhead of consulting the
5831cache), and the caches will use memory roughly proportional to the 5831cache), and the caches will use memory roughly proportional to the
5832number of newlines and characters whose screen width varies. 5832number of newlines and characters whose screen width varies.
@@ -5906,8 +5906,8 @@ Values are interpreted as follows:
5906 hollow display a hollow box cursor 5906 hollow display a hollow box cursor
5907 bar display a vertical bar cursor with default width 5907 bar display a vertical bar cursor with default width
5908 (bar . WIDTH) display a vertical bar cursor with width WIDTH 5908 (bar . WIDTH) display a vertical bar cursor with width WIDTH
5909 hbar display a horisontal bar cursor with default width 5909 hbar display a horizontal bar cursor with default width
5910 (hbar . WIDTH) display a horisontal bar cursor with width WIDTH 5910 (hbar . WIDTH) display a horizontal bar cursor with width WIDTH
5911 ANYTHING ELSE display a hollow box cursor. 5911 ANYTHING ELSE display a hollow box cursor.
5912 5912
5913When the buffer is displayed in a nonselected window, 5913When the buffer is displayed in a nonselected window,
diff --git a/src/callint.c b/src/callint.c
index 8b8cb032095..da88693cd78 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -110,6 +110,7 @@ P -- Prefix arg in raw form. Does not do I/O.
110r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O. 110r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O.
111s -- Any string. Does not inherit the current input method. 111s -- Any string. Does not inherit the current input method.
112S -- Any symbol. 112S -- Any symbol.
113U -- Mouse up event discarded by a previous k or K argument.
113v -- Variable name: symbol that is user-variable-p. 114v -- Variable name: symbol that is user-variable-p.
114x -- Lisp expression read but not evaluated. 115x -- Lisp expression read but not evaluated.
115X -- Lisp expression read and evaluated. 116X -- Lisp expression read and evaluated.
@@ -268,6 +269,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
268 Lisp_Object specs; 269 Lisp_Object specs;
269 Lisp_Object filter_specs; 270 Lisp_Object filter_specs;
270 Lisp_Object teml; 271 Lisp_Object teml;
272 Lisp_Object up_event;
271 Lisp_Object enable; 273 Lisp_Object enable;
272 int speccount = SPECPDL_INDEX (); 274 int speccount = SPECPDL_INDEX ();
273 275
@@ -289,7 +291,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
289 char prompt1[100]; 291 char prompt1[100];
290 char *tem1; 292 char *tem1;
291 int arg_from_tty = 0; 293 int arg_from_tty = 0;
292 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 294 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
293 int key_count; 295 int key_count;
294 int record_then_fail = 0; 296 int record_then_fail = 0;
295 297
@@ -328,6 +330,9 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
328 The feature is not fully implemented. */ 330 The feature is not fully implemented. */
329 filter_specs = Qnil; 331 filter_specs = Qnil;
330 332
333 /* If k or K discard an up-event, save it here so it can be retrieved with U */
334 up_event = Qnil;
335
331 /* Decode the kind of function. Either handle it and return, 336 /* Decode the kind of function. Either handle it and return,
332 or go to `lose' if not interactive, or go to `retry' 337 or go to `lose' if not interactive, or go to `retry'
333 to specify a different function, or set either STRING or SPECS. */ 338 to specify a different function, or set either STRING or SPECS. */
@@ -499,7 +504,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
499 varies[i] = 0; 504 varies[i] = 0;
500 } 505 }
501 506
502 GCPRO4 (prefix_arg, function, *args, *visargs); 507 GCPRO5 (prefix_arg, function, *args, *visargs, up_event);
503 gcpro3.nvars = (count + 1); 508 gcpro3.nvars = (count + 1);
504 gcpro4.nvars = (count + 1); 509 gcpro4.nvars = (count + 1);
505 510
@@ -628,7 +633,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
628 /* Ignore first element, which is the base key. */ 633 /* Ignore first element, which is the base key. */
629 tem2 = Fmemq (intern ("down"), Fcdr (teml)); 634 tem2 = Fmemq (intern ("down"), Fcdr (teml));
630 if (! NILP (tem2)) 635 if (! NILP (tem2))
631 Fread_event (Qnil, Qnil); 636 up_event = Fread_event (Qnil, Qnil);
632 } 637 }
633 } 638 }
634 break; 639 break;
@@ -656,11 +661,21 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
656 /* Ignore first element, which is the base key. */ 661 /* Ignore first element, which is the base key. */
657 tem2 = Fmemq (intern ("down"), Fcdr (teml)); 662 tem2 = Fmemq (intern ("down"), Fcdr (teml));
658 if (! NILP (tem2)) 663 if (! NILP (tem2))
659 Fread_event (Qnil, Qnil); 664 up_event = Fread_event (Qnil, Qnil);
660 } 665 }
661 } 666 }
662 break; 667 break;
663 668
669 case 'U': /* Up event from last k or K */
670 if (!NILP (up_event))
671 {
672 args[i] = Fmake_vector (make_number (1), up_event);
673 up_event = Qnil;
674 teml = args[i];
675 visargs[i] = Fkey_description (teml, Qnil);
676 }
677 break;
678
664 case 'e': /* The invoking event. */ 679 case 'e': /* The invoking event. */
665 if (next_event >= key_count) 680 if (next_event >= key_count)
666 error ("%s must be bound to an event with parameters", 681 error ("%s must be bound to an event with parameters",
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 25a5a3d12b8..51fc6444f49 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -137,7 +137,7 @@ casify_object (flag, obj)
137 } 137 }
138 obj = make_multibyte_string (buf, SCHARS (obj), 138 obj = make_multibyte_string (buf, SCHARS (obj),
139 j_byte); 139 j_byte);
140 SAFE_FREE (bufsize); 140 SAFE_FREE ();
141 } 141 }
142 return obj; 142 return obj;
143 } 143 }
diff --git a/src/charset.c b/src/charset.c
index 8eeddd51c92..c03107a9c46 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1673,7 +1673,7 @@ usage: (string &rest CHARACTERS) */)
1673 } 1673 }
1674 1674
1675 ret = make_string_from_bytes (buf, n, p - buf); 1675 ret = make_string_from_bytes (buf, n, p - buf);
1676 SAFE_FREE (bufsize); 1676 SAFE_FREE ();
1677 1677
1678 return ret; 1678 return ret;
1679} 1679}
diff --git a/src/data.c b/src/data.c
index 33b37376a49..92487f82ddb 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2165,7 +2165,7 @@ bool-vector. IDX starts at 0. */)
2165 p1 = SDATA (array) + idxval_byte; 2165 p1 = SDATA (array) + idxval_byte;
2166 bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, 2166 bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes,
2167 nbytes - (idxval_byte + prev_bytes)); 2167 nbytes - (idxval_byte + prev_bytes));
2168 SAFE_FREE (nbytes); 2168 SAFE_FREE ();
2169 clear_string_char_byte_cache (); 2169 clear_string_char_byte_cache ();
2170 } 2170 }
2171 while (new_bytes--) 2171 while (new_bytes--)
@@ -2206,7 +2206,7 @@ bool-vector. IDX starts at 0. */)
2206 *p1++ = *p0++; 2206 *p1++ = *p0++;
2207 bcopy (str + idxval_byte + prev_bytes, p1, 2207 bcopy (str + idxval_byte + prev_bytes, p1,
2208 nbytes - (idxval_byte + prev_bytes)); 2208 nbytes - (idxval_byte + prev_bytes));
2209 SAFE_FREE (nbytes); 2209 SAFE_FREE ();
2210 clear_string_char_byte_cache (); 2210 clear_string_char_byte_cache ();
2211 } 2211 }
2212 } 2212 }
diff --git a/src/editfns.c b/src/editfns.c
index 5b129a18a62..e83e53e9d24 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2775,7 +2775,7 @@ It returns the number of characters changed. */)
2775 2775
2776 pos = XINT (start); 2776 pos = XINT (start);
2777 pos_byte = CHAR_TO_BYTE (pos); 2777 pos_byte = CHAR_TO_BYTE (pos);
2778 end_pos = XINT (end); 2778 end_pos = XINT (end);
2779 modify_region (current_buffer, pos, XINT (end)); 2779 modify_region (current_buffer, pos, XINT (end));
2780 2780
2781 cnt = 0; 2781 cnt = 0;
@@ -3049,11 +3049,14 @@ static int message_length;
3049 3049
3050DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, 3050DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
3051 doc: /* Print a one-line message at the bottom of the screen. 3051 doc: /* Print a one-line message at the bottom of the screen.
3052The message also goes into the `*Messages*' buffer.
3053\(In keyboard macros, that's all it does.)
3054
3052The first argument is a format control string, and the rest are data 3055The first argument is a format control string, and the rest are data
3053to be formatted under control of the string. See `format' for details. 3056to be formatted under control of the string. See `format' for details.
3054 3057
3055If the first argument is nil, clear any existing message; let the 3058If the first argument is nil, the function clears any existing message;
3056minibuffer contents show. 3059this lets the minibuffer contents show. See also `current-message'.
3057 3060
3058usage: (message STRING &rest ARGS) */) 3061usage: (message STRING &rest ARGS) */)
3059 (nargs, args) 3062 (nargs, args)
@@ -3268,7 +3271,7 @@ usage: (format STRING &rest OBJECTS) */)
3268 /* discarded[I] is 1 if byte I of the format 3271 /* discarded[I] is 1 if byte I of the format
3269 string was not copied into the output. 3272 string was not copied into the output.
3270 It is 2 if byte I was not the first byte of its character. */ 3273 It is 2 if byte I was not the first byte of its character. */
3271 char *discarded; 3274 char *discarded = 0;
3272 3275
3273 /* Each element records, for one argument, 3276 /* Each element records, for one argument,
3274 the start and end bytepos in the output string, 3277 the start and end bytepos in the output string,
@@ -3319,11 +3322,13 @@ usage: (format STRING &rest OBJECTS) */)
3319 { 3322 {
3320 int nbytes = (nargs+1) * sizeof *info; 3323 int nbytes = (nargs+1) * sizeof *info;
3321 int i; 3324 int i;
3322 info = (struct info *) alloca (nbytes); 3325 if (!info)
3326 info = (struct info *) alloca (nbytes);
3323 bzero (info, nbytes); 3327 bzero (info, nbytes);
3324 for (i = 0; i <= nargs; i++) 3328 for (i = 0; i <= nargs; i++)
3325 info[i].start = -1; 3329 info[i].start = -1;
3326 discarded = (char *) alloca (SBYTES (args[0])); 3330 if (!discarded)
3331 SAFE_ALLOCA (discarded, char *, SBYTES (args[0]));
3327 bzero (discarded, SBYTES (args[0])); 3332 bzero (discarded, SBYTES (args[0]));
3328 } 3333 }
3329 3334
@@ -3684,7 +3689,7 @@ usage: (format STRING &rest OBJECTS) */)
3684 val = make_specified_string (buf, nchars, p - buf, multibyte); 3689 val = make_specified_string (buf, nchars, p - buf, multibyte);
3685 3690
3686 /* If we allocated BUF with malloc, free it too. */ 3691 /* If we allocated BUF with malloc, free it too. */
3687 SAFE_FREE (total); 3692 SAFE_FREE ();
3688 3693
3689 /* If the format string has text properties, or any of the string 3694 /* If the format string has text properties, or any of the string
3690 arguments has text properties, set up text properties of the 3695 arguments has text properties, set up text properties of the
@@ -4056,7 +4061,7 @@ Transposing beyond buffer boundaries is an error. */)
4056 bcopy (start2_addr, temp, len2_byte); 4061 bcopy (start2_addr, temp, len2_byte);
4057 bcopy (start1_addr, start1_addr + len2_byte, len1_byte); 4062 bcopy (start1_addr, start1_addr + len2_byte, len1_byte);
4058 bcopy (temp, start1_addr, len2_byte); 4063 bcopy (temp, start1_addr, len2_byte);
4059 SAFE_FREE (len2_byte); 4064 SAFE_FREE ();
4060 } 4065 }
4061 else 4066 else
4062 /* First region not smaller than second. */ 4067 /* First region not smaller than second. */
@@ -4069,7 +4074,7 @@ Transposing beyond buffer boundaries is an error. */)
4069 bcopy (start1_addr, temp, len1_byte); 4074 bcopy (start1_addr, temp, len1_byte);
4070 bcopy (start2_addr, start1_addr, len2_byte); 4075 bcopy (start2_addr, start1_addr, len2_byte);
4071 bcopy (temp, start1_addr + len2_byte, len1_byte); 4076 bcopy (temp, start1_addr + len2_byte, len1_byte);
4072 SAFE_FREE (len1_byte); 4077 SAFE_FREE ();
4073 } 4078 }
4074 graft_intervals_into_buffer (tmp_interval1, start1 + len2, 4079 graft_intervals_into_buffer (tmp_interval1, start1 + len2,
4075 len1, current_buffer, 0); 4080 len1, current_buffer, 0);
@@ -4105,7 +4110,7 @@ Transposing beyond buffer boundaries is an error. */)
4105 bcopy (start1_addr, temp, len1_byte); 4110 bcopy (start1_addr, temp, len1_byte);
4106 bcopy (start2_addr, start1_addr, len2_byte); 4111 bcopy (start2_addr, start1_addr, len2_byte);
4107 bcopy (temp, start2_addr, len1_byte); 4112 bcopy (temp, start2_addr, len1_byte);
4108 SAFE_FREE (len1_byte); 4113 SAFE_FREE ();
4109 4114
4110 graft_intervals_into_buffer (tmp_interval1, start2, 4115 graft_intervals_into_buffer (tmp_interval1, start2,
4111 len1, current_buffer, 0); 4116 len1, current_buffer, 0);
@@ -4134,7 +4139,7 @@ Transposing beyond buffer boundaries is an error. */)
4134 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); 4139 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte);
4135 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); 4140 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid);
4136 bcopy (temp, start1_addr, len2_byte); 4141 bcopy (temp, start1_addr, len2_byte);
4137 SAFE_FREE (len2_byte); 4142 SAFE_FREE ();
4138 4143
4139 graft_intervals_into_buffer (tmp_interval1, end2 - len1, 4144 graft_intervals_into_buffer (tmp_interval1, end2 - len1,
4140 len1, current_buffer, 0); 4145 len1, current_buffer, 0);
@@ -4165,7 +4170,7 @@ Transposing beyond buffer boundaries is an error. */)
4165 bcopy (start2_addr, start1_addr, len2_byte); 4170 bcopy (start2_addr, start1_addr, len2_byte);
4166 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); 4171 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid);
4167 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); 4172 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte);
4168 SAFE_FREE (len1_byte); 4173 SAFE_FREE ();
4169 4174
4170 graft_intervals_into_buffer (tmp_interval1, end2 - len1, 4175 graft_intervals_into_buffer (tmp_interval1, end2 - len1,
4171 len1, current_buffer, 0); 4176 len1, current_buffer, 0);
diff --git a/src/fns.c b/src/fns.c
index 814babae7d8..b366cab196a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1012,7 +1012,7 @@ string_make_multibyte (string)
1012 0, 1); 1012 0, 1);
1013 1013
1014 ret = make_multibyte_string (buf, SCHARS (string), nbytes); 1014 ret = make_multibyte_string (buf, SCHARS (string), nbytes);
1015 SAFE_FREE (nbytes); 1015 SAFE_FREE ();
1016 1016
1017 return ret; 1017 return ret;
1018} 1018}
@@ -1046,7 +1046,7 @@ string_to_multibyte (string)
1046 str_to_multibyte (buf, nbytes, SBYTES (string)); 1046 str_to_multibyte (buf, nbytes, SBYTES (string));
1047 1047
1048 ret = make_multibyte_string (buf, SCHARS (string), nbytes); 1048 ret = make_multibyte_string (buf, SCHARS (string), nbytes);
1049 SAFE_FREE (nbytes); 1049 SAFE_FREE ();
1050 1050
1051 return ret; 1051 return ret;
1052} 1052}
@@ -1073,7 +1073,7 @@ string_make_unibyte (string)
1073 1, 0); 1073 1, 0);
1074 1074
1075 ret = make_unibyte_string (buf, nchars); 1075 ret = make_unibyte_string (buf, nchars);
1076 SAFE_FREE (nchars); 1076 SAFE_FREE ();
1077 1077
1078 return ret; 1078 return ret;
1079} 1079}
@@ -3030,7 +3030,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
3030 args[i] = separator; 3030 args[i] = separator;
3031 3031
3032 ret = Fconcat (nargs, args); 3032 ret = Fconcat (nargs, args);
3033 SAFE_FREE_LISP (nargs); 3033 SAFE_FREE ();
3034 3034
3035 return ret; 3035 return ret;
3036} 3036}
@@ -3056,7 +3056,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
3056 mapcar1 (leni, args, function, sequence); 3056 mapcar1 (leni, args, function, sequence);
3057 3057
3058 ret = Flist (leni, args); 3058 ret = Flist (leni, args);
3059 SAFE_FREE_LISP (leni); 3059 SAFE_FREE ();
3060 3060
3061 return ret; 3061 return ret;
3062} 3062}
@@ -3763,7 +3763,7 @@ into shorter lines. */)
3763 if (encoded_length < 0) 3763 if (encoded_length < 0)
3764 { 3764 {
3765 /* The encoding wasn't possible. */ 3765 /* The encoding wasn't possible. */
3766 SAFE_FREE (allength); 3766 SAFE_FREE ();
3767 error ("Multibyte character in data for base64 encoding"); 3767 error ("Multibyte character in data for base64 encoding");
3768 } 3768 }
3769 3769
@@ -3771,7 +3771,7 @@ into shorter lines. */)
3771 and delete the old. (Insert first in order to preserve markers.) */ 3771 and delete the old. (Insert first in order to preserve markers.) */
3772 SET_PT_BOTH (XFASTINT (beg), ibeg); 3772 SET_PT_BOTH (XFASTINT (beg), ibeg);
3773 insert (encoded, encoded_length); 3773 insert (encoded, encoded_length);
3774 SAFE_FREE (allength); 3774 SAFE_FREE ();
3775 del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); 3775 del_range_byte (ibeg + encoded_length, iend + encoded_length, 1);
3776 3776
3777 /* If point was outside of the region, restore it exactly; else just 3777 /* If point was outside of the region, restore it exactly; else just
@@ -3820,12 +3820,12 @@ into shorter lines. */)
3820 if (encoded_length < 0) 3820 if (encoded_length < 0)
3821 { 3821 {
3822 /* The encoding wasn't possible. */ 3822 /* The encoding wasn't possible. */
3823 SAFE_FREE (allength); 3823 SAFE_FREE ();
3824 error ("Multibyte character in data for base64 encoding"); 3824 error ("Multibyte character in data for base64 encoding");
3825 } 3825 }
3826 3826
3827 encoded_string = make_unibyte_string (encoded, encoded_length); 3827 encoded_string = make_unibyte_string (encoded, encoded_length);
3828 SAFE_FREE (allength); 3828 SAFE_FREE ();
3829 3829
3830 return encoded_string; 3830 return encoded_string;
3831} 3831}
@@ -3962,7 +3962,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3962 if (decoded_length < 0) 3962 if (decoded_length < 0)
3963 { 3963 {
3964 /* The decoding wasn't possible. */ 3964 /* The decoding wasn't possible. */
3965 SAFE_FREE (allength); 3965 SAFE_FREE ();
3966 error ("Invalid base64 data"); 3966 error ("Invalid base64 data");
3967 } 3967 }
3968 3968
@@ -3970,7 +3970,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3970 and delete the old. (Insert first in order to preserve markers.) */ 3970 and delete the old. (Insert first in order to preserve markers.) */
3971 TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg); 3971 TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg);
3972 insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0); 3972 insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0);
3973 SAFE_FREE (allength); 3973 SAFE_FREE ();
3974 3974
3975 /* Delete the original text. */ 3975 /* Delete the original text. */
3976 del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars, 3976 del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars,
@@ -4014,7 +4014,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
4014 else 4014 else
4015 decoded_string = Qnil; 4015 decoded_string = Qnil;
4016 4016
4017 SAFE_FREE (length); 4017 SAFE_FREE ();
4018 if (!STRINGP (decoded_string)) 4018 if (!STRINGP (decoded_string))
4019 error ("Invalid base64 data"); 4019 error ("Invalid base64 data");
4020 4020
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 8182ff45766..dc091c1a09b 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -48,6 +48,7 @@ Boston, MA 02111-1307, USA. */
48#ifdef HAVE_GTK_MULTIDISPLAY 48#ifdef HAVE_GTK_MULTIDISPLAY
49 49
50/* Return the GdkDisplay that corresponds to the X display DPY. */ 50/* Return the GdkDisplay that corresponds to the X display DPY. */
51
51static GdkDisplay * 52static GdkDisplay *
52xg_get_gdk_display (dpy) 53xg_get_gdk_display (dpy)
53 Display *dpy; 54 Display *dpy;
@@ -58,6 +59,7 @@ xg_get_gdk_display (dpy)
58/* When the GTK widget W is to be created on a display for F that 59/* When the GTK widget W is to be created on a display for F that
59 is not the default display, set the display for W. 60 is not the default display, set the display for W.
60 W can be a GtkMenu or a GtkWindow widget. */ 61 W can be a GtkMenu or a GtkWindow widget. */
62
61static void 63static void
62xg_set_screen (w, f) 64xg_set_screen (w, f)
63 GtkWidget *w; 65 GtkWidget *w;
@@ -80,6 +82,7 @@ xg_set_screen (w, f)
80 82
81/* Make some defines so we can use the GTK 2.2 functions when 83/* Make some defines so we can use the GTK 2.2 functions when
82 compiling with GTK 2.0. */ 84 compiling with GTK 2.0. */
85
83#define xg_set_screen(w, f) 86#define xg_set_screen(w, f)
84#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w) 87#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w)
85#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p) 88#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p)
@@ -95,6 +98,7 @@ xg_set_screen (w, f)
95 Returns non-zero if display could be opened, zero if display could not 98 Returns non-zero if display could be opened, zero if display could not
96 be opened, and less than zero if the GTK version doesn't support 99 be opened, and less than zero if the GTK version doesn't support
97 multipe displays. */ 100 multipe displays. */
101
98int 102int
99xg_display_open (display_name, dpy) 103xg_display_open (display_name, dpy)
100 char *display_name; 104 char *display_name;
@@ -115,6 +119,8 @@ xg_display_open (display_name, dpy)
115} 119}
116 120
117 121
122/* Close display DPY. */
123
118void 124void
119xg_display_close (Display *dpy) 125xg_display_close (Display *dpy)
120{ 126{
@@ -176,6 +182,7 @@ static int malloc_cpt;
176 widget_value_free_list or by malloc:ing a new one. 182 widget_value_free_list or by malloc:ing a new one.
177 183
178 Return a pointer to the allocated structure. */ 184 Return a pointer to the allocated structure. */
185
179widget_value * 186widget_value *
180malloc_widget_value () 187malloc_widget_value ()
181{ 188{
@@ -197,6 +204,7 @@ malloc_widget_value ()
197 204
198/* This is analogous to free. It frees only what was allocated 205/* This is analogous to free. It frees only what was allocated
199 by malloc_widget_value, and no substructures. */ 206 by malloc_widget_value, and no substructures. */
207
200void 208void
201free_widget_value (wv) 209free_widget_value (wv)
202 widget_value *wv; 210 widget_value *wv;
@@ -221,6 +229,7 @@ free_widget_value (wv)
221 229
222/* Create and return the cursor to be used for popup menus and 230/* Create and return the cursor to be used for popup menus and
223 scroll bars on display DPY. */ 231 scroll bars on display DPY. */
232
224GdkCursor * 233GdkCursor *
225xg_create_default_cursor (dpy) 234xg_create_default_cursor (dpy)
226 Display *dpy; 235 Display *dpy;
@@ -239,6 +248,7 @@ xg_create_default_cursor (dpy)
239 WIDGET is used to find the GdkColormap to use for the GdkPixbuf. 248 WIDGET is used to find the GdkColormap to use for the GdkPixbuf.
240 If OLD_WIDGET is NULL, a new widget is constructed and returned. 249 If OLD_WIDGET is NULL, a new widget is constructed and returned.
241 If OLD_WIDGET is not NULL, that widget is modified. */ 250 If OLD_WIDGET is not NULL, that widget is modified. */
251
242static GtkWidget * 252static GtkWidget *
243xg_get_image_for_pixmap (f, img, widget, old_widget) 253xg_get_image_for_pixmap (f, img, widget, old_widget)
244 FRAME_PTR f; 254 FRAME_PTR f;
@@ -373,6 +383,7 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
373/* Set CURSOR on W and all widgets W contain. We must do like this 383/* Set CURSOR on W and all widgets W contain. We must do like this
374 for scroll bars and menu because they create widgets internally, 384 for scroll bars and menu because they create widgets internally,
375 and it is those widgets that are visible. */ 385 and it is those widgets that are visible. */
386
376static void 387static void
377xg_set_cursor (w, cursor) 388xg_set_cursor (w, cursor)
378 GtkWidget *w; 389 GtkWidget *w;
@@ -400,6 +411,7 @@ xg_set_cursor (w, cursor)
400 has expired by calling the GTK event loop. 411 has expired by calling the GTK event loop.
401 Also, when a menu is active, it has a small timeout before it 412 Also, when a menu is active, it has a small timeout before it
402 pops down the sub menu under it. */ 413 pops down the sub menu under it. */
414
403static void 415static void
404xg_process_timeouts (timer) 416xg_process_timeouts (timer)
405 struct atimer *timer; 417 struct atimer *timer;
@@ -415,6 +427,7 @@ xg_process_timeouts (timer)
415/* Start the xg_timer with an interval of 0.1 seconds, if not already started. 427/* Start the xg_timer with an interval of 0.1 seconds, if not already started.
416 xg_process_timeouts is called when the timer expires. The timer 428 xg_process_timeouts is called when the timer expires. The timer
417 started is continuous, i.e. runs until xg_stop_timer is called. */ 429 started is continuous, i.e. runs until xg_stop_timer is called. */
430
418static void 431static void
419xg_start_timer () 432xg_start_timer ()
420{ 433{
@@ -430,6 +443,7 @@ xg_start_timer ()
430} 443}
431 444
432/* Stop the xg_timer if started. */ 445/* Stop the xg_timer if started. */
446
433static void 447static void
434xg_stop_timer () 448xg_stop_timer ()
435{ 449{
@@ -441,6 +455,7 @@ xg_stop_timer ()
441} 455}
442 456
443/* Insert NODE into linked LIST. */ 457/* Insert NODE into linked LIST. */
458
444static void 459static void
445xg_list_insert (xg_list_node *list, xg_list_node *node) 460xg_list_insert (xg_list_node *list, xg_list_node *node)
446{ 461{
@@ -453,6 +468,7 @@ xg_list_insert (xg_list_node *list, xg_list_node *node)
453} 468}
454 469
455/* Remove NODE from linked LIST. */ 470/* Remove NODE from linked LIST. */
471
456static void 472static void
457xg_list_remove (xg_list_node *list, xg_list_node *node) 473xg_list_remove (xg_list_node *list, xg_list_node *node)
458{ 474{
@@ -473,6 +489,7 @@ xg_list_remove (xg_list_node *list, xg_list_node *node)
473 utf8 or NULL, just return STR. 489 utf8 or NULL, just return STR.
474 If not, a new string is allocated and the caller must free the result 490 If not, a new string is allocated and the caller must free the result
475 with g_free. */ 491 with g_free. */
492
476static char * 493static char *
477get_utf8_string (str) 494get_utf8_string (str)
478 char *str; 495 char *str;
@@ -496,6 +513,7 @@ get_utf8_string (str)
496 only way to get geometry position right if the user explicitly 513 only way to get geometry position right if the user explicitly
497 asked for a position when starting Emacs. 514 asked for a position when starting Emacs.
498 F is the frame we shall set geometry for. */ 515 F is the frame we shall set geometry for. */
516
499static void 517static void
500xg_set_geometry (f) 518xg_set_geometry (f)
501 FRAME_PTR f; 519 FRAME_PTR f;
@@ -529,6 +547,7 @@ xg_set_geometry (f)
529/* Resize the outer window of frame F after chainging the height. 547/* Resize the outer window of frame F after chainging the height.
530 This happend when the menu bar or the tool bar is added or removed. 548 This happend when the menu bar or the tool bar is added or removed.
531 COLUMNS/ROWS is the size the edit area shall have after the resize. */ 549 COLUMNS/ROWS is the size the edit area shall have after the resize. */
550
532static void 551static void
533xg_resize_outer_widget (f, columns, rows) 552xg_resize_outer_widget (f, columns, rows)
534 FRAME_PTR f; 553 FRAME_PTR f;
@@ -555,6 +574,7 @@ xg_resize_outer_widget (f, columns, rows)
555 manually. 574 manually.
556 F is the frame to resize. 575 F is the frame to resize.
557 PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */ 576 PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */
577
558void 578void
559xg_resize_widgets (f, pixelwidth, pixelheight) 579xg_resize_widgets (f, pixelwidth, pixelheight)
560 FRAME_PTR f; 580 FRAME_PTR f;
@@ -591,6 +611,7 @@ xg_resize_widgets (f, pixelwidth, pixelheight)
591 611
592 612
593/* Update our widget size to be COLS/ROWS characters for frame F. */ 613/* Update our widget size to be COLS/ROWS characters for frame F. */
614
594void 615void
595xg_frame_set_char_size (f, cols, rows) 616xg_frame_set_char_size (f, cols, rows)
596 FRAME_PTR f; 617 FRAME_PTR f;
@@ -630,6 +651,7 @@ xg_frame_set_char_size (f, cols, rows)
630 X Window that aren't accessible. 651 X Window that aren't accessible.
631 652
632 Return 0 if no widget match WDESC. */ 653 Return 0 if no widget match WDESC. */
654
633GtkWidget * 655GtkWidget *
634xg_win_to_widget (dpy, wdesc) 656xg_win_to_widget (dpy, wdesc)
635 Display *dpy; 657 Display *dpy;
@@ -655,6 +677,7 @@ xg_win_to_widget (dpy, wdesc)
655 677
656/* Fill in the GdkColor C so that it represents PIXEL. 678/* Fill in the GdkColor C so that it represents PIXEL.
657 W is the widget that color will be used for. Used to find colormap. */ 679 W is the widget that color will be used for. Used to find colormap. */
680
658static void 681static void
659xg_pix_to_gcolor (w, pixel, c) 682xg_pix_to_gcolor (w, pixel, c)
660 GtkWidget *w; 683 GtkWidget *w;
@@ -667,6 +690,7 @@ xg_pix_to_gcolor (w, pixel, c)
667 690
668/* Create and set up the GTK widgets for frame F. 691/* Create and set up the GTK widgets for frame F.
669 Return 0 if creation failed, non-zero otherwise. */ 692 Return 0 if creation failed, non-zero otherwise. */
693
670int 694int
671xg_create_frame_widgets (f) 695xg_create_frame_widgets (f)
672 FRAME_PTR f; 696 FRAME_PTR f;
@@ -802,6 +826,7 @@ xg_create_frame_widgets (f)
802 that the window now has. 826 that the window now has.
803 If USER_POSITION is nonzero, we set the User Position 827 If USER_POSITION is nonzero, we set the User Position
804 flag (this is useful when FLAGS is 0). */ 828 flag (this is useful when FLAGS is 0). */
829
805void 830void
806x_wm_set_size_hint (f, flags, user_position) 831x_wm_set_size_hint (f, flags, user_position)
807 FRAME_PTR f; 832 FRAME_PTR f;
@@ -900,6 +925,7 @@ x_wm_set_size_hint (f, flags, user_position)
900 keep the GTK and X colors in sync. 925 keep the GTK and X colors in sync.
901 F is the frame to change, 926 F is the frame to change,
902 BG is the pixel value to change to. */ 927 BG is the pixel value to change to. */
928
903void 929void
904xg_set_background_color (f, bg) 930xg_set_background_color (f, bg)
905 FRAME_PTR f; 931 FRAME_PTR f;
@@ -923,6 +949,7 @@ xg_set_background_color (f, bg)
923 ***********************************************************************/ 949 ***********************************************************************/
924/* Return the dialog title to use for a dialog of type KEY. 950/* Return the dialog title to use for a dialog of type KEY.
925 This is the encoding used by lwlib. We use the same for GTK. */ 951 This is the encoding used by lwlib. We use the same for GTK. */
952
926static char * 953static char *
927get_dialog_title (char key) 954get_dialog_title (char key)
928{ 955{
@@ -963,6 +990,7 @@ get_dialog_title (char key)
963 user_data is NULL (not used). 990 user_data is NULL (not used).
964 991
965 Returns TRUE to end propagation of event. */ 992 Returns TRUE to end propagation of event. */
993
966static gboolean 994static gboolean
967dialog_delete_callback (w, event, user_data) 995dialog_delete_callback (w, event, user_data)
968 GtkWidget *w; 996 GtkWidget *w;
@@ -979,6 +1007,7 @@ dialog_delete_callback (w, event, user_data)
979 DEACTIVATE_CB is the callback to use when the dialog pops down. 1007 DEACTIVATE_CB is the callback to use when the dialog pops down.
980 1008
981 Returns the GTK dialog widget. */ 1009 Returns the GTK dialog widget. */
1010
982static GtkWidget * 1011static GtkWidget *
983create_dialog (wv, select_cb, deactivate_cb) 1012create_dialog (wv, select_cb, deactivate_cb)
984 widget_value *wv; 1013 widget_value *wv;
@@ -1101,6 +1130,7 @@ enum
1101 a file dialog. 1130 a file dialog.
1102 W is the file dialog widget, 1131 W is the file dialog widget,
1103 ARG points to an integer where we record what has happend. */ 1132 ARG points to an integer where we record what has happend. */
1133
1104static void 1134static void
1105xg_file_sel_ok (w, arg) 1135xg_file_sel_ok (w, arg)
1106 GtkWidget *w; 1136 GtkWidget *w;
@@ -1113,6 +1143,7 @@ xg_file_sel_ok (w, arg)
1113 a file dialog. 1143 a file dialog.
1114 W is the file dialog widget, 1144 W is the file dialog widget,
1115 ARG points to an integer where we record what has happend. */ 1145 ARG points to an integer where we record what has happend. */
1146
1116static void 1147static void
1117xg_file_sel_cancel (w, arg) 1148xg_file_sel_cancel (w, arg)
1118 GtkWidget *w; 1149 GtkWidget *w;
@@ -1127,6 +1158,7 @@ xg_file_sel_cancel (w, arg)
1127 the dialog is popped down, but the dialog widget is not destroyed. 1158 the dialog is popped down, but the dialog widget is not destroyed.
1128 W is the file dialog widget, 1159 W is the file dialog widget,
1129 ARG points to an integer where we record what has happend. */ 1160 ARG points to an integer where we record what has happend. */
1161
1130static void 1162static void
1131xg_file_sel_destroy (w, arg) 1163xg_file_sel_destroy (w, arg)
1132 GtkWidget *w; 1164 GtkWidget *w;
@@ -1144,6 +1176,7 @@ xg_file_sel_destroy (w, arg)
1144 1176
1145 Returns a file name or NULL if no file was selected. 1177 Returns a file name or NULL if no file was selected.
1146 The returned string must be freed by the caller. */ 1178 The returned string must be freed by the caller. */
1179
1147char * 1180char *
1148xg_get_file_name (f, prompt, default_filename, mustmatch_p) 1181xg_get_file_name (f, prompt, default_filename, mustmatch_p)
1149 FRAME_PTR f; 1182 FRAME_PTR f;
@@ -1234,6 +1267,7 @@ static xg_list_node xg_menu_item_cb_list;
1234 1267
1235 Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly 1268 Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly
1236 allocated xg_menu_cb_data if CL_DATA is NULL. */ 1269 allocated xg_menu_cb_data if CL_DATA is NULL. */
1270
1237static xg_menu_cb_data * 1271static xg_menu_cb_data *
1238make_cl_data (cl_data, f, highlight_cb) 1272make_cl_data (cl_data, f, highlight_cb)
1239 xg_menu_cb_data *cl_data; 1273 xg_menu_cb_data *cl_data;
@@ -1267,6 +1301,7 @@ make_cl_data (cl_data, f, highlight_cb)
1267 HIGHLIGHT_CB could change, there is no check that the same 1301 HIGHLIGHT_CB could change, there is no check that the same
1268 function is given when modifying a menu bar as was given when 1302 function is given when modifying a menu bar as was given when
1269 creating the menu bar. */ 1303 creating the menu bar. */
1304
1270static void 1305static void
1271update_cl_data (cl_data, f, highlight_cb) 1306update_cl_data (cl_data, f, highlight_cb)
1272 xg_menu_cb_data *cl_data; 1307 xg_menu_cb_data *cl_data;
@@ -1284,6 +1319,7 @@ update_cl_data (cl_data, f, highlight_cb)
1284 1319
1285/* Decrease reference count for CL_DATA. 1320/* Decrease reference count for CL_DATA.
1286 If reference count is zero, free CL_DATA. */ 1321 If reference count is zero, free CL_DATA. */
1322
1287static void 1323static void
1288unref_cl_data (cl_data) 1324unref_cl_data (cl_data)
1289 xg_menu_cb_data *cl_data; 1325 xg_menu_cb_data *cl_data;
@@ -1300,6 +1336,7 @@ unref_cl_data (cl_data)
1300} 1336}
1301 1337
1302/* Function that marks all lisp data during GC. */ 1338/* Function that marks all lisp data during GC. */
1339
1303void 1340void
1304xg_mark_data () 1341xg_mark_data ()
1305{ 1342{
@@ -1321,6 +1358,7 @@ xg_mark_data ()
1321/* Callback called when a menu item is destroyed. Used to free data. 1358/* Callback called when a menu item is destroyed. Used to free data.
1322 W is the widget that is being destroyed (not used). 1359 W is the widget that is being destroyed (not used).
1323 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */ 1360 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */
1361
1324static void 1362static void
1325menuitem_destroy_callback (w, client_data) 1363menuitem_destroy_callback (w, client_data)
1326 GtkWidget *w; 1364 GtkWidget *w;
@@ -1340,6 +1378,7 @@ menuitem_destroy_callback (w, client_data)
1340 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. 1378 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W.
1341 1379
1342 Returns FALSE to tell GTK to keep processing this event. */ 1380 Returns FALSE to tell GTK to keep processing this event. */
1381
1343static gboolean 1382static gboolean
1344menuitem_highlight_callback (w, event, client_data) 1383menuitem_highlight_callback (w, event, client_data)
1345 GtkWidget *w; 1384 GtkWidget *w;
@@ -1364,6 +1403,7 @@ menuitem_highlight_callback (w, event, client_data)
1364/* Callback called when a menu is destroyed. Used to free data. 1403/* Callback called when a menu is destroyed. Used to free data.
1365 W is the widget that is being destroyed (not used). 1404 W is the widget that is being destroyed (not used).
1366 CLIENT_DATA points to the xg_menu_cb_data associated with W. */ 1405 CLIENT_DATA points to the xg_menu_cb_data associated with W. */
1406
1367static void 1407static void
1368menu_destroy_callback (w, client_data) 1408menu_destroy_callback (w, client_data)
1369 GtkWidget *w; 1409 GtkWidget *w;
@@ -1379,6 +1419,7 @@ menu_destroy_callback (w, client_data)
1379 W is the widget that does the grab (not used). 1419 W is the widget that does the grab (not used).
1380 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. 1420 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab.
1381 CLIENT_DATA is NULL (not used). */ 1421 CLIENT_DATA is NULL (not used). */
1422
1382static void 1423static void
1383menu_grab_callback (GtkWidget *widget, 1424menu_grab_callback (GtkWidget *widget,
1384 gboolean ungrab_p, 1425 gboolean ungrab_p,
@@ -1398,6 +1439,7 @@ menu_grab_callback (GtkWidget *widget,
1398 must be non-NULL) and can be inserted into a menu item. 1439 must be non-NULL) and can be inserted into a menu item.
1399 1440
1400 Returns the GtkHBox. */ 1441 Returns the GtkHBox. */
1442
1401static GtkWidget * 1443static GtkWidget *
1402make_widget_for_menu_item (utf8_label, utf8_key) 1444make_widget_for_menu_item (utf8_label, utf8_key)
1403 char *utf8_label; 1445 char *utf8_label;
@@ -1437,6 +1479,7 @@ make_widget_for_menu_item (utf8_label, utf8_key)
1437 1479
1438 Unfortunately, keys don't line up as nicely as in Motif, 1480 Unfortunately, keys don't line up as nicely as in Motif,
1439 but the MacOS X version doesn't either, so I guess that is OK. */ 1481 but the MacOS X version doesn't either, so I guess that is OK. */
1482
1440static GtkWidget * 1483static GtkWidget *
1441make_menu_item (utf8_label, utf8_key, item, group) 1484make_menu_item (utf8_label, utf8_key, item, group)
1442 char *utf8_label; 1485 char *utf8_label;
@@ -1486,6 +1529,7 @@ make_menu_item (utf8_label, utf8_key, item, group)
1486 1529
1487/* Return non-zero if LABEL specifies a separator (GTK only has one 1530/* Return non-zero if LABEL specifies a separator (GTK only has one
1488 separator type) */ 1531 separator type) */
1532
1489static int 1533static int
1490xg_separator_p (char *label) 1534xg_separator_p (char *label)
1491{ 1535{
@@ -1534,6 +1578,7 @@ xg_separator_p (char *label)
1534static int xg_detached_menus; 1578static int xg_detached_menus;
1535 1579
1536/* Returns non-zero if there are detached menus. */ 1580/* Returns non-zero if there are detached menus. */
1581
1537int 1582int
1538xg_have_tear_offs () 1583xg_have_tear_offs ()
1539{ 1584{
@@ -1544,6 +1589,7 @@ xg_have_tear_offs ()
1544 decrease the xg_detached_menus count. 1589 decrease the xg_detached_menus count.
1545 WIDGET is the top level window that is removed (the parent of the menu). 1590 WIDGET is the top level window that is removed (the parent of the menu).
1546 CLIENT_DATA is not used. */ 1591 CLIENT_DATA is not used. */
1592
1547static void 1593static void
1548tearoff_remove (widget, client_data) 1594tearoff_remove (widget, client_data)
1549 GtkWidget *widget; 1595 GtkWidget *widget;
@@ -1556,6 +1602,7 @@ tearoff_remove (widget, client_data)
1556 xg_detached_menus count. 1602 xg_detached_menus count.
1557 WIDGET is the GtkTearoffMenuItem. 1603 WIDGET is the GtkTearoffMenuItem.
1558 CLIENT_DATA is not used. */ 1604 CLIENT_DATA is not used. */
1605
1559static void 1606static void
1560tearoff_activate (widget, client_data) 1607tearoff_activate (widget, client_data)
1561 GtkWidget *widget; 1608 GtkWidget *widget;
@@ -1585,6 +1632,7 @@ tearoff_activate (widget, client_data)
1585 in the group. On exit, *GROUP contains the radio item group. 1632 in the group. On exit, *GROUP contains the radio item group.
1586 1633
1587 Returns the created GtkWidget. */ 1634 Returns the created GtkWidget. */
1635
1588static GtkWidget * 1636static GtkWidget *
1589xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) 1637xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group)
1590 widget_value *item; 1638 widget_value *item;
@@ -1802,6 +1850,7 @@ create_menus (data, f, select_cb, deactivate_cb, highlight_cb,
1802 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. 1850 HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
1803 1851
1804 Returns the widget created. */ 1852 Returns the widget created. */
1853
1805GtkWidget * 1854GtkWidget *
1806xg_create_widget (type, name, f, val, 1855xg_create_widget (type, name, f, val,
1807 select_cb, deactivate_cb, highlight_cb) 1856 select_cb, deactivate_cb, highlight_cb)
@@ -1859,6 +1908,7 @@ xg_create_widget (type, name, f, val,
1859} 1908}
1860 1909
1861/* Return the label for menu item WITEM. */ 1910/* Return the label for menu item WITEM. */
1911
1862static const char * 1912static const char *
1863xg_get_menu_item_label (witem) 1913xg_get_menu_item_label (witem)
1864 GtkMenuItem *witem; 1914 GtkMenuItem *witem;
@@ -1868,6 +1918,7 @@ xg_get_menu_item_label (witem)
1868} 1918}
1869 1919
1870/* Return non-zero if the menu item WITEM has the text LABEL. */ 1920/* Return non-zero if the menu item WITEM has the text LABEL. */
1921
1871static int 1922static int
1872xg_item_label_same_p (witem, label) 1923xg_item_label_same_p (witem, label)
1873 GtkMenuItem *witem; 1924 GtkMenuItem *witem;
@@ -1887,10 +1938,10 @@ xg_item_label_same_p (witem, label)
1887 return is_same; 1938 return is_same;
1888} 1939}
1889 1940
1890/* Remove widgets in LIST from container WCONT. */ 1941/* Destroy widgets in LIST. */
1942
1891static void 1943static void
1892remove_from_container (wcont, list) 1944xg_destroy_widgets (list)
1893 GtkWidget *wcont;
1894 GList *list; 1945 GList *list;
1895{ 1946{
1896 GList *iter; 1947 GList *iter;
@@ -1899,15 +1950,7 @@ remove_from_container (wcont, list)
1899 { 1950 {
1900 GtkWidget *w = GTK_WIDGET (iter->data); 1951 GtkWidget *w = GTK_WIDGET (iter->data);
1901 1952
1902 /* Add a ref to w so we can explicitly destroy it later. */ 1953 /* Destroying the widget will remove it from the container it is in. */
1903 gtk_widget_ref (w);
1904 gtk_container_remove (GTK_CONTAINER (wcont), w);
1905
1906 /* If there is a menu under this widget that has been detached,
1907 there is a reference to it, and just removing w from the
1908 container does not destroy the submenu. By explicitly
1909 destroying w we make sure the submenu is destroyed, thus
1910 removing the detached window also if there was one. */
1911 gtk_widget_destroy (w); 1954 gtk_widget_destroy (w);
1912 } 1955 }
1913} 1956}
@@ -1923,6 +1966,7 @@ remove_from_container (wcont, list)
1923 CL_DATA points to the callback data to be used for this menu bar. 1966 CL_DATA points to the callback data to be used for this menu bar.
1924 1967
1925 This function calls itself to walk through the menu bar names. */ 1968 This function calls itself to walk through the menu bar names. */
1969
1926static void 1970static void
1927xg_update_menubar (menubar, f, list, iter, pos, val, 1971xg_update_menubar (menubar, f, list, iter, pos, val,
1928 select_cb, highlight_cb, cl_data) 1972 select_cb, highlight_cb, cl_data)
@@ -1941,7 +1985,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val,
1941 else if (iter && ! val) 1985 else if (iter && ! val)
1942 { 1986 {
1943 /* Item(s) have been removed. Remove all remaining items. */ 1987 /* Item(s) have been removed. Remove all remaining items. */
1944 remove_from_container (menubar, iter); 1988 xg_destroy_widgets (iter);
1945 1989
1946 /* All updated. */ 1990 /* All updated. */
1947 val = 0; 1991 val = 0;
@@ -2095,6 +2139,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val,
2095 SELECT_CB is the callback to use when a menu item is selected. 2139 SELECT_CB is the callback to use when a menu item is selected.
2096 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. 2140 HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
2097 CL_DATA is the data to set in the widget for menu invokation. */ 2141 CL_DATA is the data to set in the widget for menu invokation. */
2142
2098static void 2143static void
2099xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) 2144xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data)
2100 widget_value *val; 2145 widget_value *val;
@@ -2229,6 +2274,7 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data)
2229} 2274}
2230 2275
2231/* Update the toggle menu item W so it corresponds to VAL. */ 2276/* Update the toggle menu item W so it corresponds to VAL. */
2277
2232static void 2278static void
2233xg_update_toggle_item (val, w) 2279xg_update_toggle_item (val, w)
2234 widget_value *val; 2280 widget_value *val;
@@ -2238,6 +2284,7 @@ xg_update_toggle_item (val, w)
2238} 2284}
2239 2285
2240/* Update the radio menu item W so it corresponds to VAL. */ 2286/* Update the radio menu item W so it corresponds to VAL. */
2287
2241static void 2288static void
2242xg_update_radio_item (val, w) 2289xg_update_radio_item (val, w)
2243 widget_value *val; 2290 widget_value *val;
@@ -2367,8 +2414,8 @@ xg_update_submenu (submenu, f, val,
2367 { 2414 {
2368 /* If we are adding new menu items below, we must remove from 2415 /* If we are adding new menu items below, we must remove from
2369 first radio button so that radio groups become correct. */ 2416 first radio button so that radio groups become correct. */
2370 if (cur && first_radio) remove_from_container (submenu, first_radio); 2417 if (cur && first_radio) xg_destroy_widgets (first_radio);
2371 else remove_from_container (submenu, iter); 2418 else xg_destroy_widgets (iter);
2372 } 2419 }
2373 2420
2374 if (cur) 2421 if (cur)
@@ -2400,6 +2447,7 @@ xg_update_submenu (submenu, f, val,
2400 SELECT_CB is the callback to use when a menu item is selected. 2447 SELECT_CB is the callback to use when a menu item is selected.
2401 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. 2448 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore.
2402 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */ 2449 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */
2450
2403void 2451void
2404xg_modify_menubar_widgets (menubar, f, val, deep_p, 2452xg_modify_menubar_widgets (menubar, f, val, deep_p,
2405 select_cb, deactivate_cb, highlight_cb) 2453 select_cb, deactivate_cb, highlight_cb)
@@ -2544,12 +2592,14 @@ free_frame_menubar (f)
2544 2592
2545/* Setting scroll bar values invokes the callback. Use this variable 2593/* Setting scroll bar values invokes the callback. Use this variable
2546 to indicate that callback should do nothing. */ 2594 to indicate that callback should do nothing. */
2595
2547int xg_ignore_gtk_scrollbar; 2596int xg_ignore_gtk_scrollbar;
2548 2597
2549/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in 2598/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in
2550 32 bits. But we want to store pointers, and they may be larger 2599 32 bits. But we want to store pointers, and they may be larger
2551 than 32 bits. Keep a mapping from integer index to widget pointers 2600 than 32 bits. Keep a mapping from integer index to widget pointers
2552 to get around the 32 bit limitation. */ 2601 to get around the 32 bit limitation. */
2602
2553static struct 2603static struct
2554{ 2604{
2555 GtkWidget **widgets; 2605 GtkWidget **widgets;
@@ -2558,9 +2608,11 @@ static struct
2558} id_to_widget; 2608} id_to_widget;
2559 2609
2560/* Grow this much every time we need to allocate more */ 2610/* Grow this much every time we need to allocate more */
2611
2561#define ID_TO_WIDGET_INCR 32 2612#define ID_TO_WIDGET_INCR 32
2562 2613
2563/* Store the widget pointer W in id_to_widget and return the integer index. */ 2614/* Store the widget pointer W in id_to_widget and return the integer index. */
2615
2564static int 2616static int
2565xg_store_widget_in_map (w) 2617xg_store_widget_in_map (w)
2566 GtkWidget *w; 2618 GtkWidget *w;
@@ -2599,6 +2651,7 @@ xg_store_widget_in_map (w)
2599 2651
2600/* Remove pointer at IDX from id_to_widget. 2652/* Remove pointer at IDX from id_to_widget.
2601 Called when scroll bar is destroyed. */ 2653 Called when scroll bar is destroyed. */
2654
2602static void 2655static void
2603xg_remove_widget_from_map (idx) 2656xg_remove_widget_from_map (idx)
2604 int idx; 2657 int idx;
@@ -2611,6 +2664,7 @@ xg_remove_widget_from_map (idx)
2611} 2664}
2612 2665
2613/* Get the widget pointer at IDX from id_to_widget. */ 2666/* Get the widget pointer at IDX from id_to_widget. */
2667
2614static GtkWidget * 2668static GtkWidget *
2615xg_get_widget_from_map (idx) 2669xg_get_widget_from_map (idx)
2616 int idx; 2670 int idx;
@@ -2623,6 +2677,7 @@ xg_get_widget_from_map (idx)
2623 2677
2624/* Return the scrollbar id for X Window WID on display DPY. 2678/* Return the scrollbar id for X Window WID on display DPY.
2625 Return -1 if WID not in id_to_widget. */ 2679 Return -1 if WID not in id_to_widget. */
2680
2626int 2681int
2627xg_get_scroll_id_for_window (dpy, wid) 2682xg_get_scroll_id_for_window (dpy, wid)
2628 Display *dpy; 2683 Display *dpy;
@@ -2646,6 +2701,7 @@ xg_get_scroll_id_for_window (dpy, wid)
2646/* Callback invoked when scroll bar WIDGET is destroyed. 2701/* Callback invoked when scroll bar WIDGET is destroyed.
2647 DATA is the index into id_to_widget for WIDGET. 2702 DATA is the index into id_to_widget for WIDGET.
2648 We free pointer to last scroll bar values here and remove the index. */ 2703 We free pointer to last scroll bar values here and remove the index. */
2704
2649static void 2705static void
2650xg_gtk_scroll_destroy (widget, data) 2706xg_gtk_scroll_destroy (widget, data)
2651 GtkWidget *widget; 2707 GtkWidget *widget;
@@ -2668,6 +2724,7 @@ xg_gtk_scroll_destroy (widget, data)
2668 2724
2669 Returns FALSE to tell GTK that it shall continue propagate the event 2725 Returns FALSE to tell GTK that it shall continue propagate the event
2670 to widgets. */ 2726 to widgets. */
2727
2671static gboolean 2728static gboolean
2672scroll_bar_button_cb (widget, event, user_data) 2729scroll_bar_button_cb (widget, event, user_data)
2673 GtkWidget *widget; 2730 GtkWidget *widget;
@@ -2692,6 +2749,7 @@ scroll_bar_button_cb (widget, event, user_data)
2692 bar changes. 2749 bar changes.
2693 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used 2750 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used
2694 to set resources for the widget. */ 2751 to set resources for the widget. */
2752
2695void 2753void
2696xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) 2754xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2697 FRAME_PTR f; 2755 FRAME_PTR f;
@@ -2753,6 +2811,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2753} 2811}
2754 2812
2755/* Make the scroll bar represented by SCROLLBAR_ID visible. */ 2813/* Make the scroll bar represented by SCROLLBAR_ID visible. */
2814
2756void 2815void
2757xg_show_scroll_bar (scrollbar_id) 2816xg_show_scroll_bar (scrollbar_id)
2758 int scrollbar_id; 2817 int scrollbar_id;
@@ -2763,6 +2822,7 @@ xg_show_scroll_bar (scrollbar_id)
2763} 2822}
2764 2823
2765/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ 2824/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */
2825
2766void 2826void
2767xg_remove_scroll_bar (f, scrollbar_id) 2827xg_remove_scroll_bar (f, scrollbar_id)
2768 FRAME_PTR f; 2828 FRAME_PTR f;
@@ -2782,6 +2842,7 @@ xg_remove_scroll_bar (f, scrollbar_id)
2782 in frame F. 2842 in frame F.
2783 TOP/LEFT are the new pixel positions where the bar shall appear. 2843 TOP/LEFT are the new pixel positions where the bar shall appear.
2784 WIDTH, HEIGHT is the size in pixels the bar shall have. */ 2844 WIDTH, HEIGHT is the size in pixels the bar shall have. */
2845
2785void 2846void
2786xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) 2847xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height)
2787 FRAME_PTR f; 2848 FRAME_PTR f;
@@ -2810,6 +2871,7 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height)
2810 2871
2811/* Set the thumb size and position of scroll bar BAR. We are currently 2872/* Set the thumb size and position of scroll bar BAR. We are currently
2812 displaying PORTION out of a whole WHOLE, and our position POSITION. */ 2873 displaying PORTION out of a whole WHOLE, and our position POSITION. */
2874
2813void 2875void
2814xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) 2876xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
2815 struct scroll_bar *bar; 2877 struct scroll_bar *bar;
@@ -2902,6 +2964,7 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
2902 W is the button widget in the tool bar that got pressed, 2964 W is the button widget in the tool bar that got pressed,
2903 CLIENT_DATA is an integer that is the index of the button in the 2965 CLIENT_DATA is an integer that is the index of the button in the
2904 tool bar. 0 is the first button. */ 2966 tool bar. 0 is the first button. */
2967
2905static void 2968static void
2906xg_tool_bar_callback (w, client_data) 2969xg_tool_bar_callback (w, client_data)
2907 GtkWidget *w; 2970 GtkWidget *w;
@@ -2938,6 +3001,7 @@ xg_tool_bar_callback (w, client_data)
2938 WBOX is the handle box widget that enables detach/attach of the tool bar. 3001 WBOX is the handle box widget that enables detach/attach of the tool bar.
2939 W is the tool bar widget. 3002 W is the tool bar widget.
2940 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ 3003 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */
3004
2941static void 3005static void
2942xg_tool_bar_detach_callback (wbox, w, client_data) 3006xg_tool_bar_detach_callback (wbox, w, client_data)
2943 GtkHandleBox *wbox; 3007 GtkHandleBox *wbox;
@@ -2966,6 +3030,7 @@ xg_tool_bar_detach_callback (wbox, w, client_data)
2966 WBOX is the handle box widget that enables detach/attach of the tool bar. 3030 WBOX is the handle box widget that enables detach/attach of the tool bar.
2967 W is the tool bar widget. 3031 W is the tool bar widget.
2968 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ 3032 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */
3033
2969static void 3034static void
2970xg_tool_bar_attach_callback (wbox, w, client_data) 3035xg_tool_bar_attach_callback (wbox, w, client_data)
2971 GtkHandleBox *wbox; 3036 GtkHandleBox *wbox;
@@ -2995,6 +3060,7 @@ xg_tool_bar_attach_callback (wbox, w, client_data)
2995 tool bar. 0 is the first button. 3060 tool bar. 0 is the first button.
2996 3061
2997 Returns FALSE to tell GTK to keep processing this event. */ 3062 Returns FALSE to tell GTK to keep processing this event. */
3063
2998static gboolean 3064static gboolean
2999xg_tool_bar_help_callback (w, event, client_data) 3065xg_tool_bar_help_callback (w, event, client_data)
3000 GtkWidget *w; 3066 GtkWidget *w;
@@ -3040,6 +3106,7 @@ xg_tool_bar_help_callback (w, event, client_data)
3040 CLIENT_DATA is unused. 3106 CLIENT_DATA is unused.
3041 3107
3042 Returns FALSE to tell GTK to keep processing this event. */ 3108 Returns FALSE to tell GTK to keep processing this event. */
3109
3043static gboolean 3110static gboolean
3044xg_tool_bar_item_expose_callback (w, event, client_data) 3111xg_tool_bar_item_expose_callback (w, event, client_data)
3045 GtkWidget *w; 3112 GtkWidget *w;
@@ -3070,6 +3137,7 @@ xg_tool_bar_item_expose_callback (w, event, client_data)
3070 CLIENT_DATA is pointing to the frame for this tool bar. 3137 CLIENT_DATA is pointing to the frame for this tool bar.
3071 3138
3072 Returns FALSE to tell GTK to keep processing this event. */ 3139 Returns FALSE to tell GTK to keep processing this event. */
3140
3073static gboolean 3141static gboolean
3074xg_tool_bar_expose_callback (w, event, client_data) 3142xg_tool_bar_expose_callback (w, event, client_data)
3075 GtkWidget *w; 3143 GtkWidget *w;
@@ -3080,6 +3148,8 @@ xg_tool_bar_expose_callback (w, event, client_data)
3080 return FALSE; 3148 return FALSE;
3081} 3149}
3082 3150
3151/* Create a tool bar for frame F. */
3152
3083static void 3153static void
3084xg_create_tool_bar (f) 3154xg_create_tool_bar (f)
3085 FRAME_PTR f; 3155 FRAME_PTR f;
@@ -3133,6 +3203,8 @@ xg_create_tool_bar (f)
3133 SET_FRAME_GARBAGED (f); 3203 SET_FRAME_GARBAGED (f);
3134} 3204}
3135 3205
3206/* Update the tool bar for frame F. Add new buttons and remove old. */
3207
3136void 3208void
3137update_frame_tool_bar (f) 3209update_frame_tool_bar (f)
3138 FRAME_PTR f; 3210 FRAME_PTR f;
@@ -3300,6 +3372,9 @@ update_frame_tool_bar (f)
3300 UNBLOCK_INPUT; 3372 UNBLOCK_INPUT;
3301} 3373}
3302 3374
3375/* Deallocate all resources for the tool bar on frame F.
3376 Remove the tool bar. */
3377
3303void 3378void
3304free_frame_tool_bar (f) 3379free_frame_tool_bar (f)
3305 FRAME_PTR f; 3380 FRAME_PTR f;
diff --git a/src/indent.c b/src/indent.c
index ffde428c12f..99fca1c2ff7 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1885,7 +1885,7 @@ vmotion (from, vtarget, w)
1885 struct position pos; 1885 struct position pos;
1886 /* vpos is cumulative vertical position, changed as from is changed */ 1886 /* vpos is cumulative vertical position, changed as from is changed */
1887 register int vpos = 0; 1887 register int vpos = 0;
1888 Lisp_Object prevline; 1888 int prevline;
1889 register int first; 1889 register int first;
1890 int from_byte; 1890 int from_byte;
1891 int lmargin = hscroll > 0 ? 1 - hscroll : 0; 1891 int lmargin = hscroll > 0 ? 1 - hscroll : 0;
@@ -1919,23 +1919,21 @@ vmotion (from, vtarget, w)
1919 { 1919 {
1920 Lisp_Object propval; 1920 Lisp_Object propval;
1921 1921
1922 XSETFASTINT (prevline, find_next_newline_no_quit (from - 1, -1)); 1922 prevline = find_next_newline_no_quit (from - 1, -1);
1923 while (XFASTINT (prevline) > BEGV 1923 while (prevline > BEGV
1924 && ((selective > 0 1924 && ((selective > 0
1925 && indented_beyond_p (XFASTINT (prevline), 1925 && indented_beyond_p (prevline,
1926 CHAR_TO_BYTE (XFASTINT (prevline)), 1926 CHAR_TO_BYTE (prevline),
1927 (double) selective)) /* iftc */ 1927 (double) selective)) /* iftc */
1928 /* watch out for newlines with `invisible' property */ 1928 /* Watch out for newlines with `invisible' property.
1929 || (propval = Fget_char_property (prevline, 1929 When moving upward, check the newline before. */
1930 || (propval = Fget_char_property (make_number (prevline - 1),
1930 Qinvisible, 1931 Qinvisible,
1931 text_prop_object), 1932 text_prop_object),
1932 TEXT_PROP_MEANS_INVISIBLE (propval)))) 1933 TEXT_PROP_MEANS_INVISIBLE (propval))))
1933 XSETFASTINT (prevline, 1934 prevline = find_next_newline_no_quit (prevline - 1, -1);
1934 find_next_newline_no_quit (XFASTINT (prevline) - 1, 1935 pos = *compute_motion (prevline, 0,
1935 -1)); 1936 lmargin + (prevline == BEG ? start_hpos : 0),
1936 pos = *compute_motion (XFASTINT (prevline), 0,
1937 lmargin + (XFASTINT (prevline) == BEG
1938 ? start_hpos : 0),
1939 0, 1937 0,
1940 from, 1938 from,
1941 /* Don't care for VPOS... */ 1939 /* Don't care for VPOS... */
@@ -1946,12 +1944,11 @@ vmotion (from, vtarget, w)
1946 /* This compensates for start_hpos 1944 /* This compensates for start_hpos
1947 so that a tab as first character 1945 so that a tab as first character
1948 still occupies 8 columns. */ 1946 still occupies 8 columns. */
1949 (XFASTINT (prevline) == BEG 1947 (prevline == BEG ? -start_hpos : 0),
1950 ? -start_hpos : 0),
1951 w); 1948 w);
1952 vpos -= pos.vpos; 1949 vpos -= pos.vpos;
1953 first = 0; 1950 first = 0;
1954 from = XFASTINT (prevline); 1951 from = prevline;
1955 } 1952 }
1956 1953
1957 /* If we made exactly the desired vertical distance, 1954 /* If we made exactly the desired vertical distance,
@@ -1979,21 +1976,21 @@ vmotion (from, vtarget, w)
1979 { 1976 {
1980 Lisp_Object propval; 1977 Lisp_Object propval;
1981 1978
1982 XSETFASTINT (prevline, find_next_newline_no_quit (from, -1)); 1979 prevline = find_next_newline_no_quit (from, -1);
1983 while (XFASTINT (prevline) > BEGV 1980 while (prevline > BEGV
1984 && ((selective > 0 1981 && ((selective > 0
1985 && indented_beyond_p (XFASTINT (prevline), 1982 && indented_beyond_p (prevline,
1986 CHAR_TO_BYTE (XFASTINT (prevline)), 1983 CHAR_TO_BYTE (prevline),
1987 (double) selective)) /* iftc */ 1984 (double) selective)) /* iftc */
1988 /* watch out for newlines with `invisible' property */ 1985 /* Watch out for newlines with `invisible' property.
1989 || (propval = Fget_char_property (prevline, Qinvisible, 1986 When moving downward, check the newline after. */
1987 || (propval = Fget_char_property (make_number (prevline),
1988 Qinvisible,
1990 text_prop_object), 1989 text_prop_object),
1991 TEXT_PROP_MEANS_INVISIBLE (propval)))) 1990 TEXT_PROP_MEANS_INVISIBLE (propval))))
1992 XSETFASTINT (prevline, 1991 prevline = find_next_newline_no_quit (prevline - 1, -1);
1993 find_next_newline_no_quit (XFASTINT (prevline) - 1, 1992 pos = *compute_motion (prevline, 0,
1994 -1)); 1993 lmargin + (prevline == BEG
1995 pos = *compute_motion (XFASTINT (prevline), 0,
1996 lmargin + (XFASTINT (prevline) == BEG
1997 ? start_hpos : 0), 1994 ? start_hpos : 0),
1998 0, 1995 0,
1999 from, 1996 from,
@@ -2002,7 +1999,7 @@ vmotion (from, vtarget, w)
2002 /* ... nor HPOS. */ 1999 /* ... nor HPOS. */
2003 1 << (BITS_PER_SHORT - 1), 2000 1 << (BITS_PER_SHORT - 1),
2004 -1, hscroll, 2001 -1, hscroll,
2005 (XFASTINT (prevline) == BEG ? -start_hpos : 0), 2002 (prevline == BEG ? -start_hpos : 0),
2006 w); 2003 w);
2007 did_motion = 1; 2004 did_motion = 1;
2008 } 2005 }
diff --git a/src/lisp.h b/src/lisp.h
index ce0fdf96e43..55664cb8ca3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3265,7 +3265,7 @@ extern Lisp_Object Vdirectory_sep_char;
3265extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3265extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3266 3266
3267#define USE_SAFE_ALLOCA \ 3267#define USE_SAFE_ALLOCA \
3268 int sa_count = SPECPDL_INDEX () 3268 int sa_count = SPECPDL_INDEX (), sa_must_free = 0
3269 3269
3270/* SAFE_ALLOCA allocates a simple buffer. */ 3270/* SAFE_ALLOCA allocates a simple buffer. */
3271 3271
@@ -3276,6 +3276,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3276 else \ 3276 else \
3277 { \ 3277 { \
3278 buf = (type) xmalloc (size); \ 3278 buf = (type) xmalloc (size); \
3279 sa_must_free++; \
3279 record_unwind_protect (safe_alloca_unwind, \ 3280 record_unwind_protect (safe_alloca_unwind, \
3280 make_save_value (buf, 0)); \ 3281 make_save_value (buf, 0)); \
3281 } \ 3282 } \
@@ -3283,10 +3284,12 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3283 3284
3284/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ 3285/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
3285 3286
3286#define SAFE_FREE(size) \ 3287#define SAFE_FREE() \
3287 do { \ 3288 do { \
3288 if ((size) >= MAX_ALLOCA) \ 3289 if (sa_must_free) { \
3290 sa_must_free = 0; \
3289 unbind_to (sa_count, Qnil); \ 3291 unbind_to (sa_count, Qnil); \
3292 } \
3290 } while (0) 3293 } while (0)
3291 3294
3292 3295
@@ -3303,17 +3306,11 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3303 buf = (Lisp_Object *) xmalloc (size_); \ 3306 buf = (Lisp_Object *) xmalloc (size_); \
3304 arg_ = make_save_value (buf, nelt); \ 3307 arg_ = make_save_value (buf, nelt); \
3305 XSAVE_VALUE (arg_)->dogc = 1; \ 3308 XSAVE_VALUE (arg_)->dogc = 1; \
3309 sa_must_free++; \
3306 record_unwind_protect (safe_alloca_unwind, arg_); \ 3310 record_unwind_protect (safe_alloca_unwind, arg_); \
3307 } \ 3311 } \
3308 } while (0) 3312 } while (0)
3309 3313
3310#define SAFE_FREE_LISP(nelt) \
3311 do { \
3312 if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \
3313 unbind_to (sa_count, Qnil); \
3314 } while (0)
3315
3316
3317 3314
3318#endif /* EMACS_LISP_H */ 3315#endif /* EMACS_LISP_H */
3319 3316
diff --git a/src/macterm.c b/src/macterm.c
index f62bbbc0d84..cdc1ccf41e3 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -228,6 +228,10 @@ extern int errno;
228 228
229extern int extra_keyboard_modifiers; 229extern int extra_keyboard_modifiers;
230 230
231/* The keysyms to use for the various modifiers. */
232
233static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value;
234
231static Lisp_Object Qvendor_specific_keysyms; 235static Lisp_Object Qvendor_specific_keysyms;
232 236
233#if 0 237#if 0
@@ -6988,6 +6992,9 @@ Lisp_Object Qreverse;
6988/* True if using command key as meta key. */ 6992/* True if using command key as meta key. */
6989Lisp_Object Vmac_command_key_is_meta; 6993Lisp_Object Vmac_command_key_is_meta;
6990 6994
6995/* Modifier associated with the option key, or nil for normal behavior. */
6996Lisp_Object Vmac_option_modifier;
6997
6991/* True if the ctrl and meta keys should be reversed. */ 6998/* True if the ctrl and meta keys should be reversed. */
6992Lisp_Object Vmac_reverse_ctrl_meta; 6999Lisp_Object Vmac_reverse_ctrl_meta;
6993 7000
@@ -7069,6 +7076,12 @@ mac_to_emacs_modifiers (EventModifiers mods)
7069 result |= meta_modifier; 7076 result |= meta_modifier;
7070 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) 7077 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey))
7071 result |= alt_modifier; 7078 result |= alt_modifier;
7079 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) {
7080 Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value);
7081 if (!NILP(val))
7082 result |= XUINT(val);
7083 }
7084
7072 return result; 7085 return result;
7073} 7086}
7074 7087
@@ -8549,7 +8562,18 @@ XTread_socket (sd, expected, hold_quit)
8549 unsigned long some_state = 0; 8562 unsigned long some_state = 0;
8550 inev.code = KeyTranslate (kchr_ptr, new_keycode, 8563 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8551 &some_state) & 0xff; 8564 &some_state) & 0xff;
8552 } 8565 } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey))
8566 {
8567 /* When using the option key as an emacs modifier, convert
8568 the pressed key code back to one without the Mac option
8569 modifier applied. */
8570 int new_modifiers = er.modifiers & ~optionKey;
8571 int new_keycode = keycode | new_modifiers;
8572 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8573 unsigned long some_state = 0;
8574 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8575 &some_state) & 0xff;
8576 }
8553 else 8577 else
8554 inev.code = er.message & charCodeMask; 8578 inev.code = er.message & charCodeMask;
8555 inev.kind = ASCII_KEYSTROKE_EVENT; 8579 inev.kind = ASCII_KEYSTROKE_EVENT;
@@ -9249,6 +9273,14 @@ syms_of_macterm ()
9249 x_error_message_string = Qnil; 9273 x_error_message_string = Qnil;
9250#endif 9274#endif
9251 9275
9276 Qmodifier_value = intern ("modifier-value");
9277 Qalt = intern ("alt");
9278 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
9279 Qhyper = intern ("hyper");
9280 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
9281 Qsuper = intern ("super");
9282 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
9283
9252 Fprovide (intern ("mac-carbon"), Qnil); 9284 Fprovide (intern ("mac-carbon"), Qnil);
9253 9285
9254 staticpro (&Qreverse); 9286 staticpro (&Qreverse);
@@ -9305,6 +9337,12 @@ to 4.1, set this to nil. */);
9305Otherwise the option key is used. */); 9337Otherwise the option key is used. */);
9306 Vmac_command_key_is_meta = Qt; 9338 Vmac_command_key_is_meta = Qt;
9307 9339
9340 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
9341 doc: /* Modifier to use for the Mac alt/option key. The value can
9342be alt, hyper, or super for the respective modifier. If the value is
9343nil then the key will act as the normal Mac option modifier. */);
9344 Vmac_option_modifier = Qnil;
9345
9308 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, 9346 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta,
9309 doc: /* Non-nil means that the control and meta keys are reversed. This is 9347 doc: /* Non-nil means that the control and meta keys are reversed. This is
9310 useful for non-standard keyboard layouts. */); 9348 useful for non-standard keyboard layouts. */);
diff --git a/src/search.c b/src/search.c
index f7bee1b8683..1742cfb08c2 100644
--- a/src/search.c
+++ b/src/search.c
@@ -554,7 +554,7 @@ newline_cache_on_off (buf)
554 direction indicated by COUNT. 554 direction indicated by COUNT.
555 555
556 If we find COUNT instances, set *SHORTAGE to zero, and return the 556 If we find COUNT instances, set *SHORTAGE to zero, and return the
557 position after the COUNTth match. Note that for reverse motion 557 position past the COUNTth match. Note that for reverse motion
558 this is not the same as the usual convention for Emacs motion commands. 558 this is not the same as the usual convention for Emacs motion commands.
559 559
560 If we don't find COUNT instances before reaching END, set *SHORTAGE 560 If we don't find COUNT instances before reaching END, set *SHORTAGE
diff --git a/src/syntax.c b/src/syntax.c
index 272e9cf1b12..8bfa62b49fc 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -2799,12 +2799,23 @@ do { prev_from = from; \
2799 INC_FROM; 2799 INC_FROM;
2800 code = prev_from_syntax & 0xff; 2800 code = prev_from_syntax & 0xff;
2801 2801
2802 if (code == Scomment) 2802 if (from < end
2803 && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax)
2804 && (c1 = FETCH_CHAR (from_byte),
2805 SYNTAX_COMSTART_SECOND (c1)))
2806 /* Duplicate code to avoid a complex if-expression
2807 which causes trouble for the SGI compiler. */
2803 { 2808 {
2804 state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax); 2809 /* Record the comment style we have entered so that only
2805 state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? 2810 the comment-end sequence of the same style actually
2806 1 : -1); 2811 terminates the comment section. */
2812 state.comstyle = SYNTAX_COMMENT_STYLE (c1);
2813 comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax);
2814 comnested = comnested || SYNTAX_COMMENT_NESTED (c1);
2815 state.incomment = comnested ? 1 : -1;
2807 state.comstr_start = prev_from; 2816 state.comstr_start = prev_from;
2817 INC_FROM;
2818 code = Scomment;
2808 } 2819 }
2809 else if (code == Scomment_fence) 2820 else if (code == Scomment_fence)
2810 { 2821 {
@@ -2816,24 +2827,13 @@ do { prev_from = from; \
2816 state.comstr_start = prev_from; 2827 state.comstr_start = prev_from;
2817 code = Scomment; 2828 code = Scomment;
2818 } 2829 }
2819 else if (from < end) 2830 else if (code == Scomment)
2820 if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax)) 2831 {
2821 if (c1 = FETCH_CHAR (from_byte), 2832 state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax);
2822 SYNTAX_COMSTART_SECOND (c1)) 2833 state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ?
2823 /* Duplicate code to avoid a complex if-expression 2834 1 : -1);
2824 which causes trouble for the SGI compiler. */ 2835 state.comstr_start = prev_from;
2825 { 2836 }
2826 /* Record the comment style we have entered so that only
2827 the comment-end sequence of the same style actually
2828 terminates the comment section. */
2829 state.comstyle = SYNTAX_COMMENT_STYLE (c1);
2830 comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax);
2831 comnested = comnested || SYNTAX_COMMENT_NESTED (c1);
2832 state.incomment = comnested ? 1 : -1;
2833 state.comstr_start = prev_from;
2834 INC_FROM;
2835 code = Scomment;
2836 }
2837 2837
2838 if (SYNTAX_FLAGS_PREFIX (prev_from_syntax)) 2838 if (SYNTAX_FLAGS_PREFIX (prev_from_syntax))
2839 continue; 2839 continue;
diff --git a/src/w32fns.c b/src/w32fns.c
index 1e52155ab3b..38faa7c3199 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6398,7 +6398,7 @@ If omitted or nil, that stands for the selected frame's display. */)
6398} 6398}
6399 6399
6400DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 6400DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
6401 doc: /* Returns the vendor ID string of the W32 system (Microsoft). 6401 doc: /* Returns the "vendor ID" string of the W32 system (Microsoft).
6402The optional argument DISPLAY specifies which display to ask about. 6402The optional argument DISPLAY specifies which display to ask about.
6403DISPLAY should be either a frame or a display name (a string). 6403DISPLAY should be either a frame or a display name (a string).
6404If omitted or nil, that stands for the selected frame's display. */) 6404If omitted or nil, that stands for the selected frame's display. */)
@@ -6411,7 +6411,7 @@ If omitted or nil, that stands for the selected frame's display. */)
6411DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, 6411DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
6412 doc: /* Returns the version numbers of the server of DISPLAY. 6412 doc: /* Returns the version numbers of the server of DISPLAY.
6413The value is a list of three integers: the major and minor 6413The value is a list of three integers: the major and minor
6414version numbers, and the vendor-specific release 6414version numbers of the X Protocol in use, and the distributor-specific release
6415number. See also the function `x-server-vendor'. 6415number. See also the function `x-server-vendor'.
6416 6416
6417The optional argument DISPLAY specifies which display to ask about. 6417The optional argument DISPLAY specifies which display to ask about.
diff --git a/src/xdisp.c b/src/xdisp.c
index 47b4bc1f06d..a5449c4db7c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4890,6 +4890,8 @@ get_next_display_element (it)
4890 translated to octal form. */ 4890 translated to octal form. */
4891 else if ((it->c < ' ' 4891 else if ((it->c < ' '
4892 && (it->area != TEXT_AREA 4892 && (it->area != TEXT_AREA
4893 /* In mode line, treat \n, \t like other crl chars. */
4894 || (it->glyph_row && it->glyph_row->mode_line_p)
4893 || (it->c != '\n' && it->c != '\t'))) 4895 || (it->c != '\n' && it->c != '\t')))
4894 || (it->multibyte_p 4896 || (it->multibyte_p
4895 ? ((it->c >= 127 4897 ? ((it->c >= 127
@@ -6364,7 +6366,7 @@ add_to_log (format, arg1, arg2)
6364 bcopy (SDATA (msg), buffer, len); 6366 bcopy (SDATA (msg), buffer, len);
6365 6367
6366 message_dolog (buffer, len - 1, 1, 0); 6368 message_dolog (buffer, len - 1, 1, 0);
6367 SAFE_FREE (len); 6369 SAFE_FREE ();
6368 6370
6369 UNGCPRO; 6371 UNGCPRO;
6370} 6372}
diff --git a/src/xfns.c b/src/xfns.c
index 97a55869a05..b11779da185 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1970,6 +1970,7 @@ xic_create_xfontset (f, base_fontname)
1970 struct frame *cf = XFRAME (frame); 1970 struct frame *cf = XFRAME (frame);
1971 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf) 1971 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
1972 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f) 1972 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
1973 && FRAME_XIC_BASE_FONTNAME (cf)
1973 && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname)) 1974 && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
1974 { 1975 {
1975 xfs = FRAME_XIC_FONTSET (cf); 1976 xfs = FRAME_XIC_FONTSET (cf);
@@ -3513,7 +3514,9 @@ If omitted or nil, that stands for the selected frame's display. */)
3513} 3514}
3514 3515
3515DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 3516DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
3516 doc: /* Returns the vendor ID string of the X server of display DISPLAY. 3517 doc: /* Returns the "vendor ID" string of the X server of display DISPLAY.
3518\(Labelling every distributor as a "vendor" embodies the false assumption
3519that operating systems cannot be developed and distributed noncommercially.)
3517The optional argument DISPLAY specifies which display to ask about. 3520The optional argument DISPLAY specifies which display to ask about.
3518DISPLAY should be either a frame or a display name (a string). 3521DISPLAY should be either a frame or a display name (a string).
3519If omitted or nil, that stands for the selected frame's display. */) 3522If omitted or nil, that stands for the selected frame's display. */)
@@ -3530,7 +3533,7 @@ If omitted or nil, that stands for the selected frame's display. */)
3530DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, 3533DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
3531 doc: /* Returns the version numbers of the X server of display DISPLAY. 3534 doc: /* Returns the version numbers of the X server of display DISPLAY.
3532The value is a list of three integers: the major and minor 3535The value is a list of three integers: the major and minor
3533version numbers of the X Protocol in use, and the vendor-specific release 3536version numbers of the X Protocol in use, and the distributor-specific release
3534number. See also the function `x-server-vendor'. 3537number. See also the function `x-server-vendor'.
3535 3538
3536The optional argument DISPLAY specifies which display to ask about. 3539The optional argument DISPLAY specifies which display to ask about.
diff --git a/src/xselect.c b/src/xselect.c
index 530bf060af4..65cb584410e 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -108,8 +108,8 @@ Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3,
108 QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7; 108 QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7;
109#endif 109#endif
110 110
111static Lisp_Object Vx_lost_selection_hooks; 111static Lisp_Object Vx_lost_selection_functions;
112static Lisp_Object Vx_sent_selection_hooks; 112static Lisp_Object Vx_sent_selection_functions;
113/* Coding system for communicating with other X clients via cutbuffer, 113/* Coding system for communicating with other X clients via cutbuffer,
114 selection, and clipboard. */ 114 selection, and clipboard. */
115static Lisp_Object Vselection_coding_system; 115static Lisp_Object Vselection_coding_system;
@@ -864,7 +864,7 @@ x_handle_selection_request (event)
864 /* Let random lisp code notice that the selection has been asked for. */ 864 /* Let random lisp code notice that the selection has been asked for. */
865 { 865 {
866 Lisp_Object rest; 866 Lisp_Object rest;
867 rest = Vx_sent_selection_hooks; 867 rest = Vx_sent_selection_functions;
868 if (!EQ (rest, Qunbound)) 868 if (!EQ (rest, Qunbound))
869 for (; CONSP (rest); rest = Fcdr (rest)) 869 for (; CONSP (rest); rest = Fcdr (rest))
870 call3 (Fcar (rest), selection_symbol, target_symbol, successful_p); 870 call3 (Fcar (rest), selection_symbol, target_symbol, successful_p);
@@ -947,7 +947,7 @@ x_handle_selection_clear (event)
947 947
948 { 948 {
949 Lisp_Object rest; 949 Lisp_Object rest;
950 rest = Vx_lost_selection_hooks; 950 rest = Vx_lost_selection_functions;
951 if (!EQ (rest, Qunbound)) 951 if (!EQ (rest, Qunbound))
952 { 952 {
953 for (; CONSP (rest); rest = Fcdr (rest)) 953 for (; CONSP (rest); rest = Fcdr (rest))
@@ -980,7 +980,7 @@ x_clear_frame_selections (f)
980 /* Let random Lisp code notice that the selection has been stolen. */ 980 /* Let random Lisp code notice that the selection has been stolen. */
981 Lisp_Object hooks, selection_symbol; 981 Lisp_Object hooks, selection_symbol;
982 982
983 hooks = Vx_lost_selection_hooks; 983 hooks = Vx_lost_selection_functions;
984 selection_symbol = Fcar (Fcar (Vselection_alist)); 984 selection_symbol = Fcar (Fcar (Vselection_alist));
985 985
986 if (!EQ (hooks, Qunbound)) 986 if (!EQ (hooks, Qunbound))
@@ -1004,7 +1004,7 @@ x_clear_frame_selections (f)
1004 /* Let random Lisp code notice that the selection has been stolen. */ 1004 /* Let random Lisp code notice that the selection has been stolen. */
1005 Lisp_Object hooks, selection_symbol; 1005 Lisp_Object hooks, selection_symbol;
1006 1006
1007 hooks = Vx_lost_selection_hooks; 1007 hooks = Vx_lost_selection_functions;
1008 selection_symbol = Fcar (Fcar (XCDR (rest))); 1008 selection_symbol = Fcar (Fcar (XCDR (rest)));
1009 1009
1010 if (!EQ (hooks, Qunbound)) 1010 if (!EQ (hooks, Qunbound))
@@ -2731,15 +2731,15 @@ means that a side-effect was executed,
2731and there is no meaningful selection value. */); 2731and there is no meaningful selection value. */);
2732 Vselection_converter_alist = Qnil; 2732 Vselection_converter_alist = Qnil;
2733 2733
2734 DEFVAR_LISP ("x-lost-selection-hooks", &Vx_lost_selection_hooks, 2734 DEFVAR_LISP ("x-lost-selection-functions", &Vx_lost_selection_functions,
2735 doc: /* A list of functions to be called when Emacs loses an X selection. 2735 doc: /* A list of functions to be called when Emacs loses an X selection.
2736\(This happens when some other X client makes its own selection 2736\(This happens when some other X client makes its own selection
2737or when a Lisp program explicitly clears the selection.) 2737or when a Lisp program explicitly clears the selection.)
2738The functions are called with one argument, the selection type 2738The functions are called with one argument, the selection type
2739\(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'). */); 2739\(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'). */);
2740 Vx_lost_selection_hooks = Qnil; 2740 Vx_lost_selection_functions = Qnil;
2741 2741
2742 DEFVAR_LISP ("x-sent-selection-hooks", &Vx_sent_selection_hooks, 2742 DEFVAR_LISP ("x-sent-selection-functions", &Vx_sent_selection_functions,
2743 doc: /* A list of functions to be called when Emacs answers a selection request. 2743 doc: /* A list of functions to be called when Emacs answers a selection request.
2744The functions are called with four arguments: 2744The functions are called with four arguments:
2745 - the selection name (typically `PRIMARY', `SECONDARY', or `CLIPBOARD'); 2745 - the selection name (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
@@ -2751,7 +2751,7 @@ including being asked for a selection that we no longer own, or being asked
2751to convert into a type that we don't know about or that is inappropriate. 2751to convert into a type that we don't know about or that is inappropriate.
2752This hook doesn't let you change the behavior of Emacs's selection replies, 2752This hook doesn't let you change the behavior of Emacs's selection replies,
2753it merely informs you that they have happened. */); 2753it merely informs you that they have happened. */);
2754 Vx_sent_selection_hooks = Qnil; 2754 Vx_sent_selection_functions = Qnil;
2755 2755
2756 DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system, 2756 DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
2757 doc: /* Coding system for communicating with other X clients. 2757 doc: /* Coding system for communicating with other X clients.
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 080f998e779..27ab90c5432 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -74,33 +74,35 @@ static int ice_fd = -1;
74 74
75static int doing_interact = False; 75static int doing_interact = False;
76 76
77/* The session manager object for the session manager connection */ 77/* The session manager object for the session manager connection. */
78 78
79static SmcConn smc_conn; 79static SmcConn smc_conn;
80 80
81/* The client session id for this session */ 81/* The client session id for this session. */
82
82static char *client_id; 83static char *client_id;
83 84
84/* The full path name to the Emacs program */ 85/* The full path name to the Emacs program. */
86
85static char *emacs_program; 87static char *emacs_program;
86 88
87/* The client session id for this session as a lisp object. */ 89/* The client session id for this session as a lisp object. */
88 90
89Lisp_Object Vx_session_id; 91Lisp_Object Vx_session_id;
90 92
91/* The id we had the previous session. This is only available if we 93/* The id we had the previous session. This is only available if we
92 have been started by the session manager with SMID_OPT. */ 94 have been started by the session manager with SMID_OPT. */
93 95
94Lisp_Object Vx_session_previous_id; 96Lisp_Object Vx_session_previous_id;
95 97
96/* The option we tell the session manager to start Emacs with when 98/* The option we tell the session manager to start Emacs with when
97 restarting Emacs. The client_id is appended. */ 99 restarting Emacs. The client_id is appended. */
98 100
99#define SMID_OPT "--smid=" 101#define SMID_OPT "--smid="
100 102
101 103
102/* The option to start Emacs without the splash screen when 104/* The option to start Emacs without the splash screen when
103 restarting Emacs. */ 105 restarting Emacs. */
104 106
105#define NOSPLASH_OPT "--no-splash" 107#define NOSPLASH_OPT "--no-splash"
106 108
@@ -108,6 +110,7 @@ Lisp_Object Vx_session_previous_id;
108/* Handle any messages from the session manager. If no connection is 110/* Handle any messages from the session manager. If no connection is
109 open to a session manager, just return 0. 111 open to a session manager, just return 0.
110 Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */ 112 Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */
113
111int 114int
112x_session_check_input (bufp) 115x_session_check_input (bufp)
113 struct input_event *bufp; 116 struct input_event *bufp;
@@ -126,7 +129,7 @@ x_session_check_input (bufp)
126 /* Reset this so wo can check kind after callbacks have been called by 129 /* Reset this so wo can check kind after callbacks have been called by
127 IceProcessMessages. The smc_interact_CB sets the kind to 130 IceProcessMessages. The smc_interact_CB sets the kind to
128 SAVE_SESSION_EVENT, but we don't know beforehand if that callback 131 SAVE_SESSION_EVENT, but we don't know beforehand if that callback
129 will be called. */ 132 will be called. */
130 emacs_event.kind = NO_EVENT; 133 emacs_event.kind = NO_EVENT;
131 134
132 if (select (ice_fd+1, &read_fds, 135 if (select (ice_fd+1, &read_fds,
@@ -143,7 +146,7 @@ x_session_check_input (bufp)
143 146
144 147
145 /* Check if smc_interact_CB was called and we shall generate a 148 /* Check if smc_interact_CB was called and we shall generate a
146 SAVE_SESSION_EVENT. */ 149 SAVE_SESSION_EVENT. */
147 if (emacs_event.kind == NO_EVENT) 150 if (emacs_event.kind == NO_EVENT)
148 return 0; 151 return 0;
149 152
@@ -151,7 +154,8 @@ x_session_check_input (bufp)
151 return 1; 154 return 1;
152} 155}
153 156
154/* Return non-zero if we have a connection to a session manager.*/ 157/* Return non-zero if we have a connection to a session manager. */
158
155int 159int
156x_session_have_connection () 160x_session_have_connection ()
157{ 161{
@@ -160,7 +164,8 @@ x_session_have_connection ()
160 164
161/* This is called when the session manager says it is OK to interact with the 165/* This is called when the session manager says it is OK to interact with the
162 user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated. 166 user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated.
163 Then lisp code can interact with the user. */ 167 Then lisp code can interact with the user. */
168
164static void 169static void
165smc_interact_CB (smcConn, clientData) 170smc_interact_CB (smcConn, clientData)
166 SmcConn smcConn; 171 SmcConn smcConn;
@@ -176,7 +181,8 @@ smc_interact_CB (smcConn, clientData)
176 are started in the correct directory. 181 are started in the correct directory.
177 182
178 If this is a shutdown and we can request to interact with the user, 183 If this is a shutdown and we can request to interact with the user,
179 we do so, because we don't know what the lisp code might do. */ 184 we do so, because we don't know what the lisp code might do. */
185
180static void 186static void
181smc_save_yourself_CB (smcConn, 187smc_save_yourself_CB (smcConn,
182 clientData, 188 clientData,
@@ -203,7 +209,7 @@ smc_save_yourself_CB (smcConn,
203 char cwd[MAXPATHLEN+1]; 209 char cwd[MAXPATHLEN+1];
204 char *smid_opt; 210 char *smid_opt;
205 211
206 /* How to start a new instance of Emacs */ 212 /* How to start a new instance of Emacs. */
207 props[props_idx] = &prop_ptr[props_idx]; 213 props[props_idx] = &prop_ptr[props_idx];
208 props[props_idx]->name = SmCloneCommand; 214 props[props_idx]->name = SmCloneCommand;
209 props[props_idx]->type = SmLISTofARRAY8; 215 props[props_idx]->type = SmLISTofARRAY8;
@@ -213,7 +219,7 @@ smc_save_yourself_CB (smcConn,
213 props[props_idx]->vals[0].value = emacs_program; 219 props[props_idx]->vals[0].value = emacs_program;
214 ++props_idx; 220 ++props_idx;
215 221
216 /* The name of the program */ 222 /* The name of the program. */
217 props[props_idx] = &prop_ptr[props_idx]; 223 props[props_idx] = &prop_ptr[props_idx];
218 props[props_idx]->name = SmProgram; 224 props[props_idx]->name = SmProgram;
219 props[props_idx]->type = SmARRAY8; 225 props[props_idx]->type = SmARRAY8;
@@ -223,11 +229,11 @@ smc_save_yourself_CB (smcConn,
223 props[props_idx]->vals[0].value = SDATA (Vinvocation_name); 229 props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
224 ++props_idx; 230 ++props_idx;
225 231
226 /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ 232 /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */
227 props[props_idx] = &prop_ptr[props_idx]; 233 props[props_idx] = &prop_ptr[props_idx];
228 props[props_idx]->name = SmRestartCommand; 234 props[props_idx]->name = SmRestartCommand;
229 props[props_idx]->type = SmLISTofARRAY8; 235 props[props_idx]->type = SmLISTofARRAY8;
230 props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ 236 props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */
231 props[props_idx]->vals = &values[val_idx]; 237 props[props_idx]->vals = &values[val_idx];
232 props[props_idx]->vals[0].length = strlen (emacs_program); 238 props[props_idx]->vals[0].length = strlen (emacs_program);
233 props[props_idx]->vals[0].value = emacs_program; 239 props[props_idx]->vals[0].value = emacs_program;
@@ -244,7 +250,7 @@ smc_save_yourself_CB (smcConn,
244 val_idx += 3; 250 val_idx += 3;
245 ++props_idx; 251 ++props_idx;
246 252
247 /* User id */ 253 /* User id. */
248 props[props_idx] = &prop_ptr[props_idx]; 254 props[props_idx] = &prop_ptr[props_idx];
249 props[props_idx]->name = SmUserID; 255 props[props_idx]->name = SmUserID;
250 props[props_idx]->type = SmARRAY8; 256 props[props_idx]->type = SmARRAY8;
@@ -254,7 +260,7 @@ smc_save_yourself_CB (smcConn,
254 props[props_idx]->vals[0].value = SDATA (Vuser_login_name); 260 props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
255 ++props_idx; 261 ++props_idx;
256 262
257 /* The current directory property, not mandatory */ 263 /* The current directory property, not mandatory. */
258#ifdef HAVE_GETCWD 264#ifdef HAVE_GETCWD
259 if (getcwd (cwd, MAXPATHLEN+1) != 0) 265 if (getcwd (cwd, MAXPATHLEN+1) != 0)
260#else 266#else
@@ -276,18 +282,19 @@ smc_save_yourself_CB (smcConn,
276 282
277 xfree (smid_opt); 283 xfree (smid_opt);
278 284
279 /* See if we maybe shall interact with the user. */ 285 /* See if we maybe shall interact with the user. */
280 if (interactStyle != SmInteractStyleAny 286 if (interactStyle != SmInteractStyleAny
281 || ! shutdown 287 || ! shutdown
282 || saveType == SmSaveLocal 288 || saveType == SmSaveLocal
283 || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0)) 289 || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0))
284 { 290 {
285 /* No interaction, we are done saving ourself. */ 291 /* No interaction, we are done saving ourself. */
286 SmcSaveYourselfDone (smcConn, True); 292 SmcSaveYourselfDone (smcConn, True);
287 } 293 }
288} 294}
289 295
290/* According to the SM specification, this shall close the connection */ 296/* According to the SM specification, this shall close the connection. */
297
291static void 298static void
292smc_die_CB (smcConn, clientData) 299smc_die_CB (smcConn, clientData)
293 SmcConn smcConn; 300 SmcConn smcConn;
@@ -301,7 +308,8 @@ smc_die_CB (smcConn, clientData)
301 According to the SM specification, we should not interact with the 308 According to the SM specification, we should not interact with the
302 user between smc_save_yourself_CB is called and until smc_save_complete_CB 309 user between smc_save_yourself_CB is called and until smc_save_complete_CB
303 is called. It seems like a lot of job to implement this and it doesn't 310 is called. It seems like a lot of job to implement this and it doesn't
304 even seem necessary. */ 311 even seem necessary. */
312
305static void 313static void
306smc_save_complete_CB (smcConn, clientData) 314smc_save_complete_CB (smcConn, clientData)
307 SmcConn smcConn; 315 SmcConn smcConn;
@@ -319,7 +327,8 @@ smc_shutdown_cancelled_CB (smcConn, clientData)
319} 327}
320 328
321/* Error handlers for SM and ICE. We don't want to exit Emacs just 329/* Error handlers for SM and ICE. We don't want to exit Emacs just
322 because there is some error in the session management. */ 330 because there is some error in the session management. */
331
323static void 332static void
324smc_error_handler (smcConn, 333smc_error_handler (smcConn,
325 swap, 334 swap,
@@ -336,7 +345,7 @@ smc_error_handler (smcConn,
336 int severity; 345 int severity;
337 SmPointer values; 346 SmPointer values;
338{ 347{
339 /* Empty */ 348 /* Empty */
340} 349}
341 350
342static void 351static void
@@ -355,7 +364,7 @@ ice_error_handler (iceConn,
355 int severity; 364 int severity;
356 IcePointer values; 365 IcePointer values;
357{ 366{
358 /* Empty */ 367 /* Empty */
359} 368}
360 369
361 370
@@ -363,12 +372,13 @@ static void
363ice_io_error_handler (iceConn) 372ice_io_error_handler (iceConn)
364 IceConn iceConn; 373 IceConn iceConn;
365{ 374{
366 /* Connection probably gone. */ 375 /* Connection probably gone. */
367 ice_fd = -1; 376 ice_fd = -1;
368} 377}
369 378
370/* This is called when the ICE connection is created or closed. The SM library 379/* This is called when the ICE connection is created or closed. The SM library
371 uses ICE as it transport protocol. */ 380 uses ICE as it transport protocol. */
381
372static void 382static void
373ice_conn_watch_CB (iceConn, clientData, opening, watchData) 383ice_conn_watch_CB (iceConn, clientData, opening, watchData)
374 IceConn iceConn; 384 IceConn iceConn;
@@ -401,6 +411,7 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData)
401} 411}
402 412
403/* Create the client leader window. */ 413/* Create the client leader window. */
414
404static void 415static void
405create_client_leader_window (dpyinfo, client_id) 416create_client_leader_window (dpyinfo, client_id)
406 struct x_display_info *dpyinfo; 417 struct x_display_info *dpyinfo;
@@ -427,7 +438,8 @@ create_client_leader_window (dpyinfo, client_id)
427 dpyinfo->client_leader_window = w; 438 dpyinfo->client_leader_window = w;
428} 439}
429 440
430/* Try to open a connection to the session manager. */ 441/* Try to open a connection to the session manager. */
442
431void 443void
432x_session_initialize (dpyinfo) 444x_session_initialize (dpyinfo)
433 struct x_display_info *dpyinfo; 445 struct x_display_info *dpyinfo;
@@ -439,17 +451,17 @@ x_session_initialize (dpyinfo)
439 int name_len = 0; 451 int name_len = 0;
440 452
441 /* Check if we where started by the session manager. If so, we will 453 /* Check if we where started by the session manager. If so, we will
442 have a previous id. */ 454 have a previous id. */
443 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) 455 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id))
444 previous_id = SDATA (Vx_session_previous_id); 456 previous_id = SDATA (Vx_session_previous_id);
445 457
446 /* Construct the path to the Emacs program. */ 458 /* Construct the path to the Emacs program. */
447 if (! EQ (Vinvocation_directory, Qnil)) 459 if (! EQ (Vinvocation_directory, Qnil))
448 name_len += strlen (SDATA (Vinvocation_directory)); 460 name_len += strlen (SDATA (Vinvocation_directory));
449 name_len += strlen (SDATA (Vinvocation_name)); 461 name_len += strlen (SDATA (Vinvocation_name));
450 462
451 /* This malloc will not be freed, but it is only done once, and hopefully 463 /* This malloc will not be freed, but it is only done once, and hopefully
452 not very large */ 464 not very large */
453 emacs_program = xmalloc (name_len + 1); 465 emacs_program = xmalloc (name_len + 1);
454 emacs_program[0] = '\0'; 466 emacs_program[0] = '\0';
455 467
@@ -458,7 +470,7 @@ x_session_initialize (dpyinfo)
458 strcat (emacs_program, SDATA (Vinvocation_name)); 470 strcat (emacs_program, SDATA (Vinvocation_name));
459 471
460 /* The SM protocol says all callbacks are mandatory, so set up all 472 /* The SM protocol says all callbacks are mandatory, so set up all
461 here and in the mask passed to SmcOpenConnection */ 473 here and in the mask passed to SmcOpenConnection. */
462 callbacks.save_yourself.callback = smc_save_yourself_CB; 474 callbacks.save_yourself.callback = smc_save_yourself_CB;
463 callbacks.save_yourself.client_data = 0; 475 callbacks.save_yourself.client_data = 0;
464 callbacks.die.callback = smc_die_CB; 476 callbacks.die.callback = smc_die_CB;
@@ -468,17 +480,17 @@ x_session_initialize (dpyinfo)
468 callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; 480 callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB;
469 callbacks.shutdown_cancelled.client_data = 0; 481 callbacks.shutdown_cancelled.client_data = 0;
470 482
471 /* Set error handlers. */ 483 /* Set error handlers. */
472 SmcSetErrorHandler (smc_error_handler); 484 SmcSetErrorHandler (smc_error_handler);
473 IceSetErrorHandler (ice_error_handler); 485 IceSetErrorHandler (ice_error_handler);
474 IceSetIOErrorHandler (ice_io_error_handler); 486 IceSetIOErrorHandler (ice_io_error_handler);
475 487
476 /* Install callback for when connection status changes. */ 488 /* Install callback for when connection status changes. */
477 IceAddConnectionWatch (ice_conn_watch_CB, 0); 489 IceAddConnectionWatch (ice_conn_watch_CB, 0);
478 490
479 /* Open the connection to the session manager. A failure is not 491 /* Open the connection to the session manager. A failure is not
480 critical, it usually means that no session manager is running. 492 critical, it usually means that no session manager is running.
481 The errorstring is here for debugging. */ 493 The errorstring is here for debugging. */
482 smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, 494 smc_conn = SmcOpenConnection (NULL, NULL, 1, 0,
483 (SmcSaveYourselfProcMask| 495 (SmcSaveYourselfProcMask|
484 SmcDieProcMask| 496 SmcDieProcMask|