aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2006-04-21 05:39:14 +0000
committerMiles Bader2006-04-21 05:39:14 +0000
commit7e635d0ed3c42e6e779821f5c0c1c62289f4c1ee (patch)
treedc3853824edd4a6d426ab69a584a70c53a230dd0 /src
parentcfc2051d0ed5a268528a647ab0911a2f5cc451de (diff)
parentf67d6742cb77a21087e40ae7ee4c84556ca18970 (diff)
downloademacs-7e635d0ed3c42e6e779821f5c0c1c62289f4c1ee.tar.gz
emacs-7e635d0ed3c42e6e779821f5c0c1c62289f4c1ee.zip
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-57
Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 226-238) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/progmodes/python.el (python-mode): Fix typo. * gnus--rel--5.10 (patch 86-90) - Update from CVS - Merge from emacs--devo--0
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog58
-rw-r--r--src/abbrev.c26
-rw-r--r--src/eval.c1
-rw-r--r--src/image.c4
-rw-r--r--src/keymap.c2
-rw-r--r--src/mac.c71
-rw-r--r--src/macselect.c47
-rw-r--r--src/macterm.c76
-rw-r--r--src/print.c1
-rw-r--r--src/textprop.c32
-rw-r--r--src/window.c43
-rw-r--r--src/xdisp.c33
-rw-r--r--src/xmenu.c66
13 files changed, 286 insertions, 174 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 88492417723..5c66a6b5c7d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,8 +1,66 @@
12006-04-21 Nick Roberts <nickrob@snap.net.nz>
2
3 * xdisp.c (note_mouse_highlight): Use build_string.
4
52006-04-20 Lars Hansen <larsh@soem.dk>
6
7 * textprop.c (Fremove_list_of_text_properties): Ensure
8 modify_region is called only when buffer is modified and that
9 signal_after_change is allways called in that case.
10
11 * print.c (PRINTFINISH): Call signal_after_change.
12
132006-04-20 Kim F. Storm <storm@cua.dk>
14
15 * xdisp.c (redisplay_window): Fix last change.
16
17 * xdisp.c (redisplay_window): If current window start is not at the
18 beginning of a line, select a new window start if buffer is modified
19 and window start is in the modified region, but the first change is
20 before window start.
21
222006-04-18 Richard Stallman <rms@gnu.org>
23
24 * xmenu.c (restore_menu_items, save_menu_items): New fns.
25 (set_frame_menubar): Use save_menu_items. Save updated vector in
26 the frame before unwinding it. Don't use unuse_menu_items. Don't
27 use discard_menu_items.
28 (digest_single_submenu): Abort if an item is not in a pane.
29 (init_menu_items): Put the error check at the top.
30
31 * keymap.c (describe_map): Make "shadowed" warning more verbose.
32
33 * window.c (adjust_window_trailing_edge): Correctly distinguish
34 series vs parallel cases, even when window has no parent.
35
36 * abbrev.c (record_symbol): New function.
37 (Finsert_abbrev_table_description): Sort the abbrevs alphabetically.
38
392006-04-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
40
41 * image.c (x_create_bitmap_from_data) [MAC_OS]: Don't check return
42 value of xmalloc.
43
44 * mac.c (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
45 (create_apple_event_from_event_ref, xrm_get_preference_database)
46 (cfstring_create_normalized): Don't check return value of xmalloc.
47
48 * macselect.c (get_scrap_target_type_list, defer_apple_events)
49 (copy_scrap_flavor_data, mac_handle_service_event): Don't check
50 return value of xmalloc/xrealloc.
51
52 * macterm.c (XCreateGC, x_per_char_metric, xlfdpat_create)
53 (init_font_name_table, init_font_name_table, mac_do_list_fonts)
54 (XLoadQueryFont, mac_store_apple_event): Don't check
55 return value of xmalloc.
56
12006-04-17 Kim F. Storm <storm@cua.dk> 572006-04-17 Kim F. Storm <storm@cua.dk>
2 58
3 * window.c (coordinates_in_window): On the vertical border, 59 * window.c (coordinates_in_window): On the vertical border,
4 calculate the row number measured from the top of the window, not 60 calculate the row number measured from the top of the window, not
5 the top of the frame. 61 the top of the frame.
62 (window_loop): Test w->dedicated with !NILP instead of EQ Qt.
63 (window_scroll_pixel_based): Fix off-by-one bug in 2002-12-23 change.
6 64
72006-04-16 Eli Zaretskii <eliz@gnu.org> 652006-04-16 Eli Zaretskii <eliz@gnu.org>
8 66
diff --git a/src/abbrev.c b/src/abbrev.c
index 13da66f5801..f47a83b0bfe 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -537,6 +537,13 @@ describe_abbrev (sym, stream)
537 Fterpri (stream); 537 Fterpri (stream);
538} 538}
539 539
540static void
541record_symbol (sym, list)
542 Lisp_Object sym, list;
543{
544 XSETCDR (list, Fcons (sym, XCDR (list)));
545}
546
540DEFUN ("insert-abbrev-table-description", Finsert_abbrev_table_description, 547DEFUN ("insert-abbrev-table-description", Finsert_abbrev_table_description,
541 Sinsert_abbrev_table_description, 1, 2, 0, 548 Sinsert_abbrev_table_description, 1, 2, 0,
542 doc: /* Insert before point a full description of abbrev table named NAME. 549 doc: /* Insert before point a full description of abbrev table named NAME.
@@ -552,6 +559,7 @@ READABLE is non-nil, they are listed. */)
552 Lisp_Object name, readable; 559 Lisp_Object name, readable;
553{ 560{
554 Lisp_Object table; 561 Lisp_Object table;
562 Lisp_Object symbols;
555 Lisp_Object stream; 563 Lisp_Object stream;
556 564
557 CHECK_SYMBOL (name); 565 CHECK_SYMBOL (name);
@@ -560,12 +568,22 @@ READABLE is non-nil, they are listed. */)
560 568
561 XSETBUFFER (stream, current_buffer); 569 XSETBUFFER (stream, current_buffer);
562 570
571 symbols = Fcons (Qnil, Qnil);
572 map_obarray (table, record_symbol, symbols);
573 symbols = XCDR (symbols);
574 symbols = Fsort (symbols, Qstring_lessp);
575
563 if (!NILP (readable)) 576 if (!NILP (readable))
564 { 577 {
565 insert_string ("("); 578 insert_string ("(");
566 Fprin1 (name, stream); 579 Fprin1 (name, stream);
567 insert_string (")\n\n"); 580 insert_string (")\n\n");
568 map_obarray (table, describe_abbrev, stream); 581 while (! NILP (symbols))
582 {
583 describe_abbrev (XCAR (symbols), stream);
584 symbols = XCDR (symbols);
585 }
586
569 insert_string ("\n\n"); 587 insert_string ("\n\n");
570 } 588 }
571 else 589 else
@@ -573,7 +591,11 @@ READABLE is non-nil, they are listed. */)
573 insert_string ("(define-abbrev-table '"); 591 insert_string ("(define-abbrev-table '");
574 Fprin1 (name, stream); 592 Fprin1 (name, stream);
575 insert_string (" '(\n"); 593 insert_string (" '(\n");
576 map_obarray (table, write_abbrev, stream); 594 while (! NILP (symbols))
595 {
596 write_abbrev (XCAR (symbols), stream);
597 symbols = XCDR (symbols);
598 }
577 insert_string (" ))\n\n"); 599 insert_string (" ))\n\n");
578 } 600 }
579 601
diff --git a/src/eval.c b/src/eval.c
index 86ee384896c..20f29b5f06b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -204,6 +204,7 @@ init_eval_once ()
204 specpdl_size = 50; 204 specpdl_size = 50;
205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); 205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding));
206 specpdl_ptr = specpdl; 206 specpdl_ptr = specpdl;
207 /* Don't forget to update docs (lispref node "Local Variables"). */
207 max_specpdl_size = 1000; 208 max_specpdl_size = 1000;
208 max_lisp_eval_depth = 300; 209 max_lisp_eval_depth = 300;
209 210
diff --git a/src/image.c b/src/image.c
index 91aa1198769..10c402be119 100644
--- a/src/image.c
+++ b/src/image.c
@@ -201,7 +201,7 @@ XPutPixel (ximage, x, y, pixel)
201 } 201 }
202 else 202 else
203#endif 203#endif
204 if (depth == 1) 204 if (depth == 1)
205 { 205 {
206 char *base_addr = GetPixBaseAddr (pixmap); 206 char *base_addr = GetPixBaseAddr (pixmap);
207 short row_bytes = GetPixRowBytes (pixmap); 207 short row_bytes = GetPixRowBytes (pixmap);
@@ -444,8 +444,6 @@ x_create_bitmap_from_data (f, bits, width, height)
444 id = x_allocate_bitmap_record (f); 444 id = x_allocate_bitmap_record (f);
445#ifdef MAC_OS 445#ifdef MAC_OS
446 dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); 446 dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width);
447 if (! dpyinfo->bitmaps[id - 1].bitmap_data)
448 return -1;
449 bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width); 447 bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width);
450#endif /* MAC_OS */ 448#endif /* MAC_OS */
451 449
diff --git a/src/keymap.c b/src/keymap.c
index e5122c84efc..6930ed08d8c 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3391,7 +3391,7 @@ describe_map (map, prefix, elt_describer, partial, shadow,
3391 if (vect[i].shadowed) 3391 if (vect[i].shadowed)
3392 { 3392 {
3393 SET_PT (PT - 1); 3393 SET_PT (PT - 1);
3394 insert_string (" (shadowed)"); 3394 insert_string ("\n (that binding is currently shadowed by another mode)");
3395 SET_PT (PT + 1); 3395 SET_PT (PT + 1);
3396 } 3396 }
3397 } 3397 }
diff --git a/src/mac.c b/src/mac.c
index 2b4e8dcbc64..7172301b6b0 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -453,15 +453,10 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
453 char *buf; 453 char *buf;
454 454
455 buf = xmalloc (data_size + 1); 455 buf = xmalloc (data_size + 1);
456 if (buf) 456 memcpy (buf, data_ptr, data_size);
457 { 457 buf[data_size] = '\0';
458 memcpy (buf, data_ptr, data_size); 458 err = posix_pathname_to_fsspec (buf, &fs);
459 buf[data_size] = '\0'; 459 xfree (buf);
460 err = posix_pathname_to_fsspec (buf, &fs);
461 xfree (buf);
462 }
463 else
464 err = memFullErr;
465 if (err == noErr) 460 if (err == noErr)
466 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result); 461 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result);
467#endif 462#endif
@@ -489,14 +484,11 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
489 { 484 {
490 size = AEGetDescDataSize (&desc); 485 size = AEGetDescDataSize (&desc);
491 buf = xmalloc (size); 486 buf = xmalloc (size);
492 if (buf) 487 err = AEGetDescData (&desc, buf, size);
493 { 488 if (err == noErr)
494 err = AEGetDescData (&desc, buf, size); 489 url = CFURLCreateWithBytes (NULL, buf, size,
495 if (err == noErr) 490 kCFStringEncodingUTF8, NULL);
496 url = CFURLCreateWithBytes (NULL, buf, size, 491 xfree (buf);
497 kCFStringEncodingUTF8, NULL);
498 xfree (buf);
499 }
500 AEDisposeDesc (&desc); 492 AEDisposeDesc (&desc);
501 } 493 }
502 } 494 }
@@ -581,21 +573,16 @@ mac_coerce_file_name_desc (from_desc, to_type, handler_refcon, result)
581 data_size = GetHandleSize (from_desc->dataHandle); 573 data_size = GetHandleSize (from_desc->dataHandle);
582#endif 574#endif
583 data_ptr = xmalloc (data_size); 575 data_ptr = xmalloc (data_size);
584 if (data_ptr)
585 {
586#if TARGET_API_MAC_CARBON 576#if TARGET_API_MAC_CARBON
587 err = AEGetDescData (from_desc, data_ptr, data_size); 577 err = AEGetDescData (from_desc, data_ptr, data_size);
588#else 578#else
589 memcpy (data_ptr, *(from_desc->dataHandle), data_size); 579 memcpy (data_ptr, *(from_desc->dataHandle), data_size);
590#endif 580#endif
591 if (err == noErr) 581 if (err == noErr)
592 err = mac_coerce_file_name_ptr (from_type, data_ptr, 582 err = mac_coerce_file_name_ptr (from_type, data_ptr,
593 data_size, to_type, 583 data_size, to_type,
594 handler_refcon, result); 584 handler_refcon, result);
595 xfree (data_ptr); 585 xfree (data_ptr);
596 }
597 else
598 err = memFullErr;
599 } 586 }
600 587
601 if (err != noErr) 588 if (err != noErr)
@@ -691,8 +678,6 @@ create_apple_event_from_event_ref (event, num_params, names, types, result)
691 if (err != noErr) 678 if (err != noErr)
692 break; 679 break;
693 buf = xmalloc (size); 680 buf = xmalloc (size);
694 if (buf == NULL)
695 break;
696 err = GetEventParameter (event, names[i], types[i], NULL, 681 err = GetEventParameter (event, names[i], types[i], NULL,
697 size, NULL, buf); 682 size, NULL, buf);
698 if (err == noErr) 683 if (err == noErr)
@@ -1596,8 +1581,6 @@ xrm_get_preference_database (application)
1596 1581
1597 count = CFSetGetCount (key_set); 1582 count = CFSetGetCount (key_set);
1598 keys = xmalloc (sizeof (CFStringRef) * count); 1583 keys = xmalloc (sizeof (CFStringRef) * count);
1599 if (keys == NULL)
1600 goto out;
1601 CFSetGetValues (key_set, (const void **)keys); 1584 CFSetGetValues (key_set, (const void **)keys);
1602 for (index = 0; index < count; index++) 1585 for (index = 0; index < count; index++)
1603 { 1586 {
@@ -4547,11 +4530,8 @@ cfstring_create_normalized (str, symbol)
4547 if (in_text == NULL) 4530 if (in_text == NULL)
4548 { 4531 {
4549 buffer = xmalloc (sizeof (UniChar) * length); 4532 buffer = xmalloc (sizeof (UniChar) * length);
4550 if (buffer) 4533 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4551 { 4534 in_text = buffer;
4552 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4553 in_text = buffer;
4554 }
4555 } 4535 }
4556 4536
4557 if (in_text) 4537 if (in_text)
@@ -4559,15 +4539,12 @@ cfstring_create_normalized (str, symbol)
4559 while (err == noErr) 4539 while (err == noErr)
4560 { 4540 {
4561 out_buf = xmalloc (out_size); 4541 out_buf = xmalloc (out_size);
4562 if (out_buf == NULL) 4542 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar),
4563 err = mFulErr; 4543 in_text,
4564 else 4544 kUnicodeDefaultDirectionMask,
4565 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), 4545 0, NULL, NULL, NULL,
4566 in_text, 4546 out_size, &out_read, &out_len,
4567 kUnicodeDefaultDirectionMask, 4547 out_buf);
4568 0, NULL, NULL, NULL,
4569 out_size, &out_read, &out_len,
4570 out_buf);
4571 if (err == noErr && out_read < length * sizeof (UniChar)) 4548 if (err == noErr && out_read < length * sizeof (UniChar))
4572 { 4549 {
4573 xfree (out_buf); 4550 xfree (out_buf);
diff --git a/src/macselect.c b/src/macselect.c
index 8312197181f..fe4a7c8eccc 100644
--- a/src/macselect.c
+++ b/src/macselect.c
@@ -373,14 +373,11 @@ get_scrap_target_type_list (scrap)
373 err = GetScrapFlavorCount (scrap, &count); 373 err = GetScrapFlavorCount (scrap, &count);
374 if (err == noErr) 374 if (err == noErr)
375 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count); 375 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
376 if (flavor_info) 376 err = GetScrapFlavorInfoList (scrap, &count, flavor_info);
377 if (err != noErr)
377 { 378 {
378 err = GetScrapFlavorInfoList (scrap, &count, flavor_info); 379 xfree (flavor_info);
379 if (err != noErr) 380 flavor_info = NULL;
380 {
381 xfree (flavor_info);
382 flavor_info = NULL;
383 }
384 } 381 }
385 if (flavor_info == NULL) 382 if (flavor_info == NULL)
386 count = 0; 383 count = 0;
@@ -1021,20 +1018,13 @@ defer_apple_events (apple_event, reply)
1021 deferred_apple_events.count = 0; 1018 deferred_apple_events.count = 0;
1022 deferred_apple_events.buf = 1019 deferred_apple_events.buf =
1023 xmalloc (sizeof (AppleEvent) * deferred_apple_events.size); 1020 xmalloc (sizeof (AppleEvent) * deferred_apple_events.size);
1024 if (deferred_apple_events.buf == NULL)
1025 err = memFullErr;
1026 } 1021 }
1027 else if (deferred_apple_events.count == deferred_apple_events.size) 1022 else if (deferred_apple_events.count == deferred_apple_events.size)
1028 { 1023 {
1029 AppleEvent *newbuf;
1030
1031 deferred_apple_events.size *= 2; 1024 deferred_apple_events.size *= 2;
1032 newbuf = xrealloc (deferred_apple_events.buf, 1025 deferred_apple_events.buf
1033 sizeof (AppleEvent) * deferred_apple_events.size); 1026 = xrealloc (deferred_apple_events.buf,
1034 if (newbuf) 1027 sizeof (AppleEvent) * deferred_apple_events.size);
1035 deferred_apple_events.buf = newbuf;
1036 else
1037 err = memFullErr;
1038 } 1028 }
1039 } 1029 }
1040 1030
@@ -1192,17 +1182,7 @@ copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type)
1192 buf = NULL; 1182 buf = NULL;
1193 } 1183 }
1194 else if (size_allocated < size) 1184 else if (size_allocated < size)
1195 { 1185 buf = xrealloc (buf, size);
1196 char *newbuf = xrealloc (buf, size);
1197
1198 if (newbuf)
1199 buf = newbuf;
1200 else
1201 {
1202 xfree (buf);
1203 buf = NULL;
1204 }
1205 }
1206 else 1186 else
1207 break; 1187 break;
1208 } 1188 }
@@ -1302,14 +1282,11 @@ mac_handle_service_event (call_ref, event, data)
1302 err = GetScrapFlavorCount (cur_scrap, &count); 1282 err = GetScrapFlavorCount (cur_scrap, &count);
1303 if (err == noErr) 1283 if (err == noErr)
1304 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count); 1284 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
1305 if (flavor_info) 1285 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info);
1286 if (err != noErr)
1306 { 1287 {
1307 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info); 1288 xfree (flavor_info);
1308 if (err != noErr) 1289 flavor_info = NULL;
1309 {
1310 xfree (flavor_info);
1311 flavor_info = NULL;
1312 }
1313 } 1290 }
1314 if (flavor_info == NULL) 1291 if (flavor_info == NULL)
1315 break; 1292 break;
diff --git a/src/macterm.c b/src/macterm.c
index 5c3787c2a51..b7a7fadeab2 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1510,11 +1510,8 @@ XCreateGC (display, window, mask, xgcv)
1510{ 1510{
1511 GC gc = xmalloc (sizeof (*gc)); 1511 GC gc = xmalloc (sizeof (*gc));
1512 1512
1513 if (gc) 1513 bzero (gc, sizeof (*gc));
1514 { 1514 XChangeGC (display, gc, mask, xgcv);
1515 bzero (gc, sizeof (*gc));
1516 XChangeGC (display, gc, mask, xgcv);
1517 }
1518 1515
1519 return gc; 1516 return gc;
1520} 1517}
@@ -2163,21 +2160,17 @@ x_per_char_metric (font, char2b)
2163 if (*row == NULL) 2160 if (*row == NULL)
2164 { 2161 {
2165 *row = xmalloc (sizeof (XCharStructRow)); 2162 *row = xmalloc (sizeof (XCharStructRow));
2166 if (*row) 2163 bzero (*row, sizeof (XCharStructRow));
2167 bzero (*row, sizeof (XCharStructRow));
2168 } 2164 }
2169 if (*row) 2165 pcm = (*row)->per_char + char2b->byte2;
2166 if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2))
2170 { 2167 {
2171 pcm = (*row)->per_char + char2b->byte2; 2168 BLOCK_INPUT;
2172 if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2)) 2169 mac_query_char_extents (font->mac_style,
2173 { 2170 (char2b->byte1 << 8) + char2b->byte2,
2174 BLOCK_INPUT; 2171 NULL, NULL, pcm, NULL);
2175 mac_query_char_extents (font->mac_style, 2172 UNBLOCK_INPUT;
2176 (char2b->byte1 << 8) + char2b->byte2, 2173 XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
2177 NULL, NULL, pcm, NULL);
2178 UNBLOCK_INPUT;
2179 XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
2180 }
2181 } 2174 }
2182 } 2175 }
2183 else 2176 else
@@ -6582,12 +6575,7 @@ xlfdpat_create (pattern)
6582 struct xlfdpat_block *blk; 6575 struct xlfdpat_block *blk;
6583 6576
6584 pat = xmalloc (sizeof (struct xlfdpat)); 6577 pat = xmalloc (sizeof (struct xlfdpat));
6585 if (pat == NULL)
6586 goto error;
6587
6588 pat->buf = xmalloc (strlen (pattern) + 1); 6578 pat->buf = xmalloc (strlen (pattern) + 1);
6589 if (pat->buf == NULL)
6590 goto error;
6591 6579
6592 /* Normalize the pattern string and store it to `pat->buf'. */ 6580 /* Normalize the pattern string and store it to `pat->buf'. */
6593 nblocks = 0; 6581 nblocks = 0;
@@ -6651,8 +6639,6 @@ xlfdpat_create (pattern)
6651 } 6639 }
6652 6640
6653 pat->blocks = xmalloc (sizeof (struct xlfdpat_block) * nblocks); 6641 pat->blocks = xmalloc (sizeof (struct xlfdpat_block) * nblocks);
6654 if (pat->blocks == NULL)
6655 goto error;
6656 6642
6657 /* Divide the normalized pattern into blocks. */ 6643 /* Divide the normalized pattern into blocks. */
6658 p = pat->buf; 6644 p = pat->buf;
@@ -7112,9 +7098,10 @@ init_font_name_table ()
7112 Qnil, Qnil, Qnil);; 7098 Qnil, Qnil, Qnil);;
7113 err = ATSUFontCount (&nfonts); 7099 err = ATSUFontCount (&nfonts);
7114 if (err == noErr) 7100 if (err == noErr)
7115 font_ids = xmalloc (sizeof (ATSUFontID) * nfonts); 7101 {
7116 if (font_ids) 7102 font_ids = xmalloc (sizeof (ATSUFontID) * nfonts);
7117 err = ATSUGetFontIDs (font_ids, nfonts, NULL); 7103 err = ATSUGetFontIDs (font_ids, nfonts, NULL);
7104 }
7118 if (err == noErr) 7105 if (err == noErr)
7119 for (i = 0; i < nfonts; i++) 7106 for (i = 0; i < nfonts; i++)
7120 { 7107 {
@@ -7124,8 +7111,6 @@ init_font_name_table ()
7124 if (err != noErr) 7111 if (err != noErr)
7125 continue; 7112 continue;
7126 name = xmalloc (name_len + 1); 7113 name = xmalloc (name_len + 1);
7127 if (name == NULL)
7128 continue;
7129 name[name_len] = '\0'; 7114 name[name_len] = '\0';
7130 err = ATSUFindFontName (font_ids[i], kFontFamilyName, 7115 err = ATSUFindFontName (font_ids[i], kFontFamilyName,
7131 kFontMacintoshPlatform, kFontNoScript, 7116 kFontMacintoshPlatform, kFontNoScript,
@@ -7455,8 +7440,6 @@ mac_do_list_fonts (pattern, maxnames)
7455 int former_len = ptr - font_name_table[i]; 7440 int former_len = ptr - font_name_table[i];
7456 7441
7457 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1); 7442 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1);
7458 if (scaled == NULL)
7459 continue;
7460 memcpy (scaled, font_name_table[i], former_len); 7443 memcpy (scaled, font_name_table[i], former_len);
7461 sprintf (scaled + former_len, 7444 sprintf (scaled + former_len,
7462 "-%d-%d-72-72-m-%d-%s", 7445 "-%d-%d-72-72-m-%d-%s",
@@ -7789,18 +7772,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
7789 font->max_char_or_byte2 = 0xff; 7772 font->max_char_or_byte2 = 0xff;
7790 7773
7791 font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100); 7774 font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100);
7792 if (font->bounds.rows == NULL)
7793 {
7794 mac_unload_font (&one_mac_display_info, font);
7795 return NULL;
7796 }
7797 bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100); 7775 bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100);
7798 font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow)); 7776 font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow));
7799 if (font->bounds.rows[0] == NULL)
7800 {
7801 mac_unload_font (&one_mac_display_info, font);
7802 return NULL;
7803 }
7804 bzero (font->bounds.rows[0], sizeof (XCharStructRow)); 7777 bzero (font->bounds.rows[0], sizeof (XCharStructRow));
7805 7778
7806#if USE_CG_TEXT_DRAWING 7779#if USE_CG_TEXT_DRAWING
@@ -7822,9 +7795,10 @@ XLoadQueryFont (Display *dpy, char *fontname)
7822 } 7795 }
7823 7796
7824 if (font->cg_font) 7797 if (font->cg_font)
7825 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100); 7798 {
7826 if (font->cg_glyphs) 7799 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
7827 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100); 7800 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
7801 }
7828#endif 7802#endif
7829 space_bounds = font->bounds.rows[0]->per_char + 0x20; 7803 space_bounds = font->bounds.rows[0]->per_char + 0x20;
7830 err = mac_query_char_extents (font->mac_style, 0x20, 7804 err = mac_query_char_extents (font->mac_style, 0x20,
@@ -7970,11 +7944,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
7970 7944
7971 font->bounds.per_char = 7945 font->bounds.per_char =
7972 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7946 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
7973 if (font->bounds.per_char == NULL)
7974 {
7975 mac_unload_font (&one_mac_display_info, font);
7976 return NULL;
7977 }
7978 bzero (font->bounds.per_char, 7947 bzero (font->bounds.per_char,
7979 sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7948 sizeof (XCharStruct) * (0xff - 0x20 + 1));
7980 7949
@@ -8979,15 +8948,12 @@ mac_store_apple_event (class, id, desc)
8979 Lisp_Object class, id; 8948 Lisp_Object class, id;
8980 const AEDesc *desc; 8949 const AEDesc *desc;
8981{ 8950{
8982 OSErr err = noErr; 8951 OSErr err;
8983 struct input_event buf; 8952 struct input_event buf;
8984 AEDesc *desc_copy; 8953 AEDesc *desc_copy;
8985 8954
8986 desc_copy = xmalloc (sizeof (AEDesc)); 8955 desc_copy = xmalloc (sizeof (AEDesc));
8987 if (desc_copy == NULL) 8956 err = AEDuplicateDesc (desc, desc_copy);
8988 err = memFullErr;
8989 else
8990 err = AEDuplicateDesc (desc, desc_copy);
8991 if (err == noErr) 8957 if (err == noErr)
8992 { 8958 {
8993 EVENT_INIT (buf); 8959 EVENT_INIT (buf);
diff --git a/src/print.c b/src/print.c
index 0eb82b663d6..0db9780e314 100644
--- a/src/print.c
+++ b/src/print.c
@@ -276,6 +276,7 @@ int print_output_debug_flag = 1;
276 else \ 276 else \
277 insert_1_both (print_buffer, print_buffer_pos, \ 277 insert_1_both (print_buffer, print_buffer_pos, \
278 print_buffer_pos_byte, 0, 1, 0); \ 278 print_buffer_pos_byte, 0, 1, 0); \
279 signal_after_change (PT - print_buffer_pos, 0, print_buffer_pos);\
279 } \ 280 } \
280 if (free_print_buffer) \ 281 if (free_print_buffer) \
281 { \ 282 { \
diff --git a/src/textprop.c b/src/textprop.c
index 65823d9fa3f..e2f9c531735 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1602,10 +1602,12 @@ Return t if any property was actually removed, nil otherwise. */)
1602 } 1602 }
1603 } 1603 }
1604 1604
1605 if (BUFFERP (object)) 1605 /* We are at the beginning of an interval, with len to scan.
1606 modify_region (XBUFFER (object), XINT (start), XINT (end)); 1606 The flag `modified' records if changes have been made.
1607 1607 When object is a buffer, we must call modify_region before changes are
1608 /* We are at the beginning of an interval, with len to scan */ 1608 made and signal_after_change when we are done.
1609 We call modify_region before calling remove_properties iff modified == 0,
1610 and we call signal_after_change before returning iff modified != 0. */
1609 for (;;) 1611 for (;;)
1610 { 1612 {
1611 if (i == 0) 1613 if (i == 0)
@@ -1614,10 +1616,20 @@ Return t if any property was actually removed, nil otherwise. */)
1614 if (LENGTH (i) >= len) 1616 if (LENGTH (i) >= len)
1615 { 1617 {
1616 if (! interval_has_some_properties_list (properties, i)) 1618 if (! interval_has_some_properties_list (properties, i))
1617 return modified ? Qt : Qnil; 1619 if (modified)
1620 {
1621 if (BUFFERP (object))
1622 signal_after_change (XINT (start), XINT (end) - XINT (start),
1623 XINT (end) - XINT (start));
1624 return Qt;
1625 }
1626 else
1627 return Qnil;
1618 1628
1619 if (LENGTH (i) == len) 1629 if (LENGTH (i) == len)
1620 { 1630 {
1631 if (!modified && BUFFERP (object))
1632 modify_region (XBUFFER (object), XINT (start), XINT (end));
1621 remove_properties (Qnil, properties, i, object); 1633 remove_properties (Qnil, properties, i, object);
1622 if (BUFFERP (object)) 1634 if (BUFFERP (object))
1623 signal_after_change (XINT (start), XINT (end) - XINT (start), 1635 signal_after_change (XINT (start), XINT (end) - XINT (start),
@@ -1629,6 +1641,8 @@ Return t if any property was actually removed, nil otherwise. */)
1629 unchanged = i; 1641 unchanged = i;
1630 i = split_interval_left (i, len); 1642 i = split_interval_left (i, len);
1631 copy_properties (unchanged, i); 1643 copy_properties (unchanged, i);
1644 if (!modified && BUFFERP (object))
1645 modify_region (XBUFFER (object), XINT (start), XINT (end));
1632 remove_properties (Qnil, properties, i, object); 1646 remove_properties (Qnil, properties, i, object);
1633 if (BUFFERP (object)) 1647 if (BUFFERP (object))
1634 signal_after_change (XINT (start), XINT (end) - XINT (start), 1648 signal_after_change (XINT (start), XINT (end) - XINT (start),
@@ -1636,8 +1650,14 @@ Return t if any property was actually removed, nil otherwise. */)
1636 return Qt; 1650 return Qt;
1637 } 1651 }
1638 1652
1653 if (interval_has_some_properties_list (properties, i))
1654 {
1655 if (!modified && BUFFERP (object))
1656 modify_region (XBUFFER (object), XINT (start), XINT (end));
1657 remove_properties (Qnil, properties, i, object);
1658 modified = 1;
1659 }
1639 len -= LENGTH (i); 1660 len -= LENGTH (i);
1640 modified += remove_properties (Qnil, properties, i, object);
1641 i = next_interval (i); 1661 i = next_interval (i);
1642 } 1662 }
1643} 1663}
diff --git a/src/window.c b/src/window.c
index d4e6ac3569f..1bd8c3924a1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -662,6 +662,8 @@ coordinates_in_window (w, x, y)
662 { 662 {
663 if (!WINDOW_LEFTMOST_P (w) && abs (*x - x0) < grabbable_width) 663 if (!WINDOW_LEFTMOST_P (w) && abs (*x - x0) < grabbable_width)
664 { 664 {
665 /* Convert X and Y to window relative coordinates.
666 Vertical border is at the left edge of window. */
665 *x = max (0, *x - x0); 667 *x = max (0, *x - x0);
666 *y -= top_y; 668 *y -= top_y;
667 return ON_VERTICAL_BORDER; 669 return ON_VERTICAL_BORDER;
@@ -671,6 +673,8 @@ coordinates_in_window (w, x, y)
671 { 673 {
672 if (abs (*x - x1) < grabbable_width) 674 if (abs (*x - x1) < grabbable_width)
673 { 675 {
676 /* Convert X and Y to window relative coordinates.
677 Vertical border is at the right edge of window. */
674 *x = min (x1, *x) - x0; 678 *x = min (x1, *x) - x0;
675 *y -= top_y; 679 *y -= top_y;
676 return ON_VERTICAL_BORDER; 680 return ON_VERTICAL_BORDER;
@@ -717,6 +721,8 @@ coordinates_in_window (w, x, y)
717 && !WINDOW_RIGHTMOST_P (w) 721 && !WINDOW_RIGHTMOST_P (w)
718 && (abs (*x - right_x) < grabbable_width)) 722 && (abs (*x - right_x) < grabbable_width))
719 { 723 {
724 /* Convert X and Y to window relative coordinates.
725 Vertical border is at the right edge of window. */
720 *x = min (right_x, *x) - left_x; 726 *x = min (right_x, *x) - left_x;
721 *y -= top_y; 727 *y -= top_y;
722 return ON_VERTICAL_BORDER; 728 return ON_VERTICAL_BORDER;
@@ -2027,7 +2033,7 @@ window_loop (type, obj, mini, frames)
2027 `obj & 1' means consider only full-width windows. 2033 `obj & 1' means consider only full-width windows.
2028 `obj & 2' means consider also dedicated windows. */ 2034 `obj & 2' means consider also dedicated windows. */
2029 if (((XINT (obj) & 1) && !WINDOW_FULL_WIDTH_P (w)) 2035 if (((XINT (obj) & 1) && !WINDOW_FULL_WIDTH_P (w))
2030 || (!(XINT (obj) & 2) && EQ (w->dedicated, Qt)) 2036 || (!(XINT (obj) & 2) && !NILP (w->dedicated))
2031 /* Minibuffer windows are always ignored. */ 2037 /* Minibuffer windows are always ignored. */
2032 || MINI_WINDOW_P (w)) 2038 || MINI_WINDOW_P (w))
2033 break; 2039 break;
@@ -2082,7 +2088,7 @@ window_loop (type, obj, mini, frames)
2082 case GET_LARGEST_WINDOW: 2088 case GET_LARGEST_WINDOW:
2083 { /* nil `obj' means to ignore dedicated windows. */ 2089 { /* nil `obj' means to ignore dedicated windows. */
2084 /* Ignore dedicated windows and minibuffers. */ 2090 /* Ignore dedicated windows and minibuffers. */
2085 if (MINI_WINDOW_P (w) || (NILP (obj) && EQ (w->dedicated, Qt))) 2091 if (MINI_WINDOW_P (w) || (NILP (obj) && !NILP (w->dedicated)))
2086 break; 2092 break;
2087 2093
2088 if (NILP (best_window)) 2094 if (NILP (best_window))
@@ -4269,18 +4275,30 @@ adjust_window_trailing_edge (window, delta, horiz_flag)
4269 4275
4270 while (1) 4276 while (1)
4271 { 4277 {
4278 Lisp_Object first_parallel = Qnil;
4279
4272 p = XWINDOW (window); 4280 p = XWINDOW (window);
4273 parent = p->parent; 4281 parent = p->parent;
4274 4282
4275 /* Make sure there is a following window. */ 4283 if (NILP (XWINDOW (window)->next))
4276 if (NILP (parent)
4277 && (horiz_flag ? 1
4278 : NILP (XWINDOW (window)->next)))
4279 { 4284 {
4280 Fset_window_configuration (old_config); 4285 Fset_window_configuration (old_config);
4281 error ("No other window following this one"); 4286 error ("No other window following this one");
4282 } 4287 }
4283 4288
4289 /* See if this level has windows in parallel in the specified
4290 direction. If so, set FIRST_PARALLEL to the first one. */
4291 if (horiz_flag)
4292 {
4293 if (! NILP (parent) && !NILP (XWINDOW (parent)->vchild))
4294 first_parallel = XWINDOW (parent)->vchild;
4295 }
4296 else
4297 {
4298 if (! NILP (parent) && !NILP (XWINDOW (parent)->hchild))
4299 first_parallel = XWINDOW (parent)->hchild;
4300 }
4301
4284 /* Don't make this window too small. */ 4302 /* Don't make this window too small. */
4285 if (XINT (CURSIZE (window)) + delta 4303 if (XINT (CURSIZE (window)) + delta
4286 < (horiz_flag ? window_min_width : window_min_height)) 4304 < (horiz_flag ? window_min_width : window_min_height))
@@ -4298,12 +4316,11 @@ adjust_window_trailing_edge (window, delta, horiz_flag)
4298 XINT (CURSIZE (window)) + delta); 4316 XINT (CURSIZE (window)) + delta);
4299 4317
4300 /* If this window has following siblings in the desired dimension, 4318 /* If this window has following siblings in the desired dimension,
4301 make them smaller. 4319 make them smaller, and exit the loop.
4320
4302 (If we reach the top of the tree and can never do this, 4321 (If we reach the top of the tree and can never do this,
4303 we will fail and report an error, above.) */ 4322 we will fail and report an error, above.) */
4304 if (horiz_flag 4323 if (NILP (first_parallel))
4305 ? !NILP (XWINDOW (parent)->hchild)
4306 : !NILP (XWINDOW (parent)->vchild))
4307 { 4324 {
4308 if (!NILP (XWINDOW (window)->next)) 4325 if (!NILP (XWINDOW (window)->next))
4309 { 4326 {
@@ -4325,9 +4342,7 @@ adjust_window_trailing_edge (window, delta, horiz_flag)
4325 else 4342 else
4326 /* Here we have a chain of parallel siblings, in the other dimension. 4343 /* Here we have a chain of parallel siblings, in the other dimension.
4327 Change the size of the other siblings. */ 4344 Change the size of the other siblings. */
4328 for (child = (horiz_flag 4345 for (child = first_parallel;
4329 ? XWINDOW (parent)->vchild
4330 : XWINDOW (parent)->hchild);
4331 ! NILP (child); 4346 ! NILP (child);
4332 child = XWINDOW (child)->next) 4347 child = XWINDOW (child)->next)
4333 if (! EQ (child, window)) 4348 if (! EQ (child, window))
@@ -4868,7 +4883,7 @@ window_scroll_pixel_based (window, n, whole, noerror)
4868 { 4883 {
4869 if (it.current_y < it.last_visible_y 4884 if (it.current_y < it.last_visible_y
4870 && (it.current_y + it.max_ascent + it.max_descent 4885 && (it.current_y + it.max_ascent + it.max_descent
4871 >= it.last_visible_y)) 4886 > it.last_visible_y))
4872 { 4887 {
4873 /* The last line was only partially visible, make it fully 4888 /* The last line was only partially visible, make it fully
4874 visible. */ 4889 visible. */
diff --git a/src/xdisp.c b/src/xdisp.c
index ca5137bb4ff..1689ec88be5 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12784,8 +12784,6 @@ redisplay_window (window, just_this_one_p)
12784 /* IT may overshoot PT if text at PT is invisible. */ 12784 /* IT may overshoot PT if text at PT is invisible. */
12785 else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT) 12785 else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT)
12786 w->force_start = Qt; 12786 w->force_start = Qt;
12787
12788
12789 } 12787 }
12790 12788
12791 /* Handle case where place to start displaying has been specified, 12789 /* Handle case where place to start displaying has been specified,
@@ -12955,6 +12953,35 @@ redisplay_window (window, just_this_one_p)
12955 || (XFASTINT (w->last_modified) >= MODIFF 12953 || (XFASTINT (w->last_modified) >= MODIFF
12956 && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF))) 12954 && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)))
12957 { 12955 {
12956
12957 /* If first window line is a continuation line, and window start
12958 is inside the modified region, but the first change is before
12959 current window start, we must select a new window start.*/
12960 if (NILP (w->start_at_line_beg))
12961 {
12962 /* Make sure beg_unchanged and end_unchanged are up to date.
12963 Do it only if buffer has really changed. This may or may
12964 not have been done by try_window_id (see which) already. */
12965 if (MODIFF > SAVE_MODIFF
12966 /* This seems to happen sometimes after saving a buffer. */
12967 || BEG_UNCHANGED + END_UNCHANGED > Z_BYTE)
12968 {
12969 if (GPT - BEG < BEG_UNCHANGED)
12970 BEG_UNCHANGED = GPT - BEG;
12971 if (Z - GPT < END_UNCHANGED)
12972 END_UNCHANGED = Z - GPT;
12973 }
12974
12975 if (CHARPOS (startp) > BEG + BEG_UNCHANGED
12976 && CHARPOS (startp) <= Z - END_UNCHANGED)
12977 {
12978 /* There doesn't seems to be a simple way to find a new
12979 window start that is near the old window start, so
12980 we just recenter. */
12981 goto recenter;
12982 }
12983 }
12984
12958#if GLYPH_DEBUG 12985#if GLYPH_DEBUG
12959 debug_method_add (w, "same window start"); 12986 debug_method_add (w, "same window start");
12960#endif 12987#endif
@@ -22535,7 +22562,7 @@ note_mouse_highlight (f, x, y)
22535 if (part == ON_VERTICAL_BORDER) 22562 if (part == ON_VERTICAL_BORDER)
22536 { 22563 {
22537 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor; 22564 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
22538 help_echo_string = make_string ("drag-mouse-1: resize", 20); 22565 help_echo_string = build_string ("drag-mouse-1: resize");
22539 } 22566 }
22540 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE 22567 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
22541 || part == ON_SCROLL_BAR) 22568 || part == ON_SCROLL_BAR)
diff --git a/src/xmenu.c b/src/xmenu.c
index 156c44c9bb0..8558e113863 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -266,14 +266,15 @@ menubar_id_to_frame (id)
266static void 266static void
267init_menu_items () 267init_menu_items ()
268{ 268{
269 if (!NILP (menu_items_inuse))
270 error ("Trying to use a menu from within a menu-entry");
271
269 if (NILP (menu_items)) 272 if (NILP (menu_items))
270 { 273 {
271 menu_items_allocated = 60; 274 menu_items_allocated = 60;
272 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); 275 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
273 } 276 }
274 277
275 if (!NILP (menu_items_inuse))
276 error ("Trying to use a menu from within a menu-entry");
277 menu_items_inuse = Qt; 278 menu_items_inuse = Qt;
278 menu_items_used = 0; 279 menu_items_used = 0;
279 menu_items_n_panes = 0; 280 menu_items_n_panes = 0;
@@ -310,6 +311,39 @@ discard_menu_items ()
310 xassert (NILP (menu_items_inuse)); 311 xassert (NILP (menu_items_inuse));
311} 312}
312 313
314/* This undoes save_menu_items, and it is called by the specpdl unwind
315 mechanism. */
316
317static Lisp_Object
318restore_menu_items (saved)
319 Lisp_Object saved;
320{
321 menu_items = XCAR (saved);
322 menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil);
323 menu_items_allocated = (VECTORP (menu_items) ? ASIZE (menu_items) : 0);
324 saved = XCDR (saved);
325 menu_items_used = XINT (XCAR (saved));
326 saved = XCDR (saved);
327 menu_items_n_panes = XINT (XCAR (saved));
328 saved = XCDR (saved);
329 menu_items_submenu_depth = XINT (XCAR (saved));
330}
331
332/* Push the whole state of menu_items processing onto the specpdl.
333 It will be restored when the specpdl is unwound. */
334
335static void
336save_menu_items ()
337{
338 Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil,
339 make_number (menu_items_used),
340 make_number (menu_items_n_panes),
341 make_number (menu_items_submenu_depth));
342 record_unwind_protect (restore_menu_items, saved);
343 menu_items_inuse = Qnil;
344 menu_items = Qnil;
345}
346
313/* Make the menu_items vector twice as large. */ 347/* Make the menu_items vector twice as large. */
314 348
315static void 349static void
@@ -320,6 +354,7 @@ grow_menu_items ()
320 old = menu_items; 354 old = menu_items;
321 355
322 menu_items_allocated *= 2; 356 menu_items_allocated *= 2;
357
323 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); 358 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
324 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, 359 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
325 old_size * sizeof (Lisp_Object)); 360 old_size * sizeof (Lisp_Object));
@@ -1728,6 +1763,7 @@ digest_single_submenu (start, end, top_level_items)
1728 int i; 1763 int i;
1729 int submenu_depth = 0; 1764 int submenu_depth = 0;
1730 widget_value **submenu_stack; 1765 widget_value **submenu_stack;
1766 int panes_seen = 0;
1731 1767
1732 submenu_stack 1768 submenu_stack
1733 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); 1769 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
@@ -1774,6 +1810,8 @@ digest_single_submenu (start, end, top_level_items)
1774 Lisp_Object pane_name, prefix; 1810 Lisp_Object pane_name, prefix;
1775 char *pane_string; 1811 char *pane_string;
1776 1812
1813 panes_seen++;
1814
1777 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 1815 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
1778 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 1816 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
1779 1817
@@ -1821,6 +1859,10 @@ digest_single_submenu (start, end, top_level_items)
1821 Lisp_Object item_name, enable, descrip, def, type, selected; 1859 Lisp_Object item_name, enable, descrip, def, type, selected;
1822 Lisp_Object help; 1860 Lisp_Object help;
1823 1861
1862 /* All items should be contained in panes. */
1863 if (panes_seen == 0)
1864 abort ();
1865
1824 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); 1866 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
1825 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); 1867 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
1826 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY); 1868 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
@@ -2046,7 +2088,6 @@ set_frame_menubar (f, first_time, deep_p)
2046 specbind (Qdebug_on_next_call, Qnil); 2088 specbind (Qdebug_on_next_call, Qnil);
2047 2089
2048 record_unwind_save_match_data (); 2090 record_unwind_save_match_data ();
2049 record_unwind_protect (unuse_menu_items, Qnil);
2050 if (NILP (Voverriding_local_map_menu_flag)) 2091 if (NILP (Voverriding_local_map_menu_flag))
2051 { 2092 {
2052 specbind (Qoverriding_terminal_local_map, Qnil); 2093 specbind (Qoverriding_terminal_local_map, Qnil);
@@ -2074,6 +2115,8 @@ set_frame_menubar (f, first_time, deep_p)
2074 2115
2075 /* Fill in menu_items with the current menu bar contents. 2116 /* Fill in menu_items with the current menu bar contents.
2076 This can evaluate Lisp code. */ 2117 This can evaluate Lisp code. */
2118 save_menu_items ();
2119
2077 menu_items = f->menu_bar_vector; 2120 menu_items = f->menu_bar_vector;
2078 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; 2121 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
2079 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); 2122 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
@@ -2133,23 +2176,33 @@ set_frame_menubar (f, first_time, deep_p)
2133 } 2176 }
2134 2177
2135 set_buffer_internal_1 (prev); 2178 set_buffer_internal_1 (prev);
2136 unbind_to (specpdl_count, Qnil);
2137 2179
2138 /* If there has been no change in the Lisp-level contents 2180 /* If there has been no change in the Lisp-level contents
2139 of the menu bar, skip redisplaying it. Just exit. */ 2181 of the menu bar, skip redisplaying it. Just exit. */
2140 2182
2183 /* Compare the new menu items with the ones computed last time. */
2141 for (i = 0; i < previous_menu_items_used; i++) 2184 for (i = 0; i < previous_menu_items_used; i++)
2142 if (menu_items_used == i 2185 if (menu_items_used == i
2143 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i]))) 2186 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i])))
2144 break; 2187 break;
2145 if (i == menu_items_used && i == previous_menu_items_used && i != 0) 2188 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
2146 { 2189 {
2190 /* The menu items have not changed. Don't bother updating
2191 the menus in any form, since it would be a no-op. */
2147 free_menubar_widget_value_tree (first_wv); 2192 free_menubar_widget_value_tree (first_wv);
2148 discard_menu_items (); 2193 discard_menu_items ();
2149 2194 unbind_to (specpdl_count, Qnil);
2150 return; 2195 return;
2151 } 2196 }
2152 2197
2198 /* The menu items are different, so store them in the frame. */
2199 f->menu_bar_vector = menu_items;
2200 f->menu_bar_items_used = menu_items_used;
2201
2202 /* This calls restore_menu_items to restore menu_items, etc.,
2203 as they were outside. */
2204 unbind_to (specpdl_count, Qnil);
2205
2153 /* Now GC cannot happen during the lifetime of the widget_value, 2206 /* Now GC cannot happen during the lifetime of the widget_value,
2154 so it's safe to store data from a Lisp_String. */ 2207 so it's safe to store data from a Lisp_String. */
2155 wv = first_wv->contents; 2208 wv = first_wv->contents;
@@ -2164,9 +2217,6 @@ set_frame_menubar (f, first_time, deep_p)
2164 wv = wv->next; 2217 wv = wv->next;
2165 } 2218 }
2166 2219
2167 f->menu_bar_vector = menu_items;
2168 f->menu_bar_items_used = menu_items_used;
2169 discard_menu_items ();
2170 } 2220 }
2171 else 2221 else
2172 { 2222 {