aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-07-28 22:31:12 -0700
committerPaul Eggert2011-07-28 22:31:12 -0700
commit18ab493650d648ab8dca651ea2698861f926e895 (patch)
treeb16ca478db1e96af8d0be9a20ff1361bea6d12ee /src
parent726e0ab18e84ce0df6b9dc1612bf4d92b9d1e52a (diff)
parent43dc9f5b0187276c24e1f63f2a23ba4b81c20e07 (diff)
downloademacs-18ab493650d648ab8dca651ea2698861f926e895.tar.gz
emacs-18ab493650d648ab8dca651ea2698861f926e895.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog170
-rw-r--r--src/alloc.c6
-rw-r--r--src/buffer.c2
-rw-r--r--src/callproc.c2
-rw-r--r--src/editfns.c7
-rw-r--r--src/frame.c8
-rw-r--r--src/gnutls.c3
-rw-r--r--src/image.c12
-rw-r--r--src/lread.c3
-rw-r--r--src/nsfns.m13
-rw-r--r--src/nsfont.m57
-rw-r--r--src/nsmenu.m33
-rw-r--r--src/nsterm.h8
-rw-r--r--src/nsterm.m217
-rw-r--r--src/print.c12
-rw-r--r--src/regex.c34
-rw-r--r--src/xdisp.c195
-rw-r--r--src/xfaces.c3
-rw-r--r--src/xfns.c2
-rw-r--r--src/xml.c28
20 files changed, 643 insertions, 172 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1796455e557..a88e2e8e3cf 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -236,8 +236,6 @@
236 (x_term_init): Don't assume length fits in int (sprintf is limited 236 (x_term_init): Don't assume length fits in int (sprintf is limited
237 to int size). 237 to int size).
238 238
2392011-07-19 Paul Eggert <eggert@cs.ucla.edu>
240
241 Use ptrdiff_t for composition IDs. 239 Use ptrdiff_t for composition IDs.
242 * character.c (lisp_string_width): 240 * character.c (lisp_string_width):
243 * composite.c (composition_table_size, n_compositions) 241 * composite.c (composition_table_size, n_compositions)
@@ -355,7 +353,78 @@
355 (gs_load): Use printmax_t to print the widest integers possible. 353 (gs_load): Use printmax_t to print the widest integers possible.
356 Check for integer overflow when computing image height and width. 354 Check for integer overflow when computing image height and width.
357 355
3582011-07-19 Paul Eggert <eggert@cs.ucla.edu> 3562011-07-28 Andreas Schwab <schwab@linux-m68k.org>
357
358 * print.c (print_object): Print empty symbol as ##.
359
360 * lread.c (read1): Read ## as empty symbol.
361
3622011-07-28 Alp Aker <alp.tekin.aker@gmail.com>
363
364 * nsfns.m (x_set_foreground_color): Set f->foreground_pixel when
365 setting frame foreground color (Bug#9175).
366 (x_set_background_color): Likewise.
367
368 * nsmenu.m (-setText): Size tooltip dimensions precisely to
369 contents (Bug#9176).
370 (EmacsTooltip -init): Remove bezels and add shadows to
371 tooltip windows.
372
373 * nsterm.m (ns_dumpglyphs_stretch): Avoid overwriting left fringe
374 or scroll bar (Bug#8470).
375
376 * nsfont.m (nsfont_open): Remove assignment to voffset and
377 unnecessary vars hshink, expand, hd, full_height, min_height.
378 (nsfont_draw): Use s->ybase as baseline for glyph drawing (Bug#8913).
379
380 * nsterm.h (nsfont_info): Remove voffset field.
381
3822011-07-28 Alp Aker <alp.tekin.aker@gmail.com>
383
384 Implement strike-through and overline on NextStep (Bug#8863).
385
386 * nsfont.m (nsfont_open): Use underline position provided by font,
387 instead of hard-coded value of 2.
388 (nsfont_draw): Call ns_draw_text_decoration instead.
389
390 * nsterm.h: Add declaration for ns_draw_text_decoration.
391
392 * nsterm.m (ns_draw_text_decoration): New function for drawing
393 underline, overline, and strike-through.
394 (ns_dumpglyphs_image, ns_dumpglyphs_stretch): Add call to
395 ns_draw_text_decoration. Change treatment of cursor drawing to
396 accomodate underlining, etc.
397
3982011-07-28 Eli Zaretskii <eliz@gnu.org>
399
400 * buffer.c (init_buffer_once): Set bidi-display-reordering to t by
401 default.
402
4032011-07-28 Paul Eggert <eggert@cs.ucla.edu>
404
405 * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.
406 Without this fix, if a signal arrives just after memory fills up,
407 'malloc' might be invoked reentrantly.
408
409 * image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1.
410 In other words, assume that every image size is allowed, on non-X
411 hosts. This assumption is probably wrong, but it lets Emacs compile.
412
4132011-07-28 Andreas Schwab <schwab@linux-m68k.org>
414
415 * regex.c (re_iswctype): Convert return values to boolean.
416
4172011-07-28 Eli Zaretskii <eliz@fencepost.gnu.org>
418
419 * xdisp.c (compute_display_string_pos): Don't use cached display
420 string position if the buffer had its restriction changed.
421 (Bug#9184)
422
4232011-07-28 Paul Eggert <eggert@cs.ucla.edu>
424
425 * callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering.
426
4272011-07-28 Paul Eggert <eggert@cs.ucla.edu>
359 428
360 Integer signedness and overflow and related fixes. (Bug#9079) 429 Integer signedness and overflow and related fixes. (Bug#9079)
361 430
@@ -554,6 +623,101 @@
554 Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally 623 Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally
555 well either way, and we prefer signed to unsigned. 624 well either way, and we prefer signed to unsigned.
556 625
6262011-07-27 Lars Magne Ingebrigtsen <larsi@gnus.org>
627
628 * gnutls.c (emacs_gnutls_read): Don't message anything if the peer
629 closes the connection while we're reading (bug#9182).
630
6312011-07-25 Jan Djärv <jan.h.d@swipnet.se>
632
633 * nsmenu.m (ns_popup_dialog): Add an "ok" button if no buttons
634 are specified (Bug#9168).
635
6362011-07-25 Paul Eggert <eggert@cs.ucla.edu>
637
638 * bidi.c (bidi_dump_cached_states): Fix printf format mismatch.
639 Found by GCC static checking and --with-wide-int on a 32-bit host.
640
6412011-07-25 Eli Zaretskii <eliz@gnu.org>
642
643 * xdisp.c (compute_display_string_pos): Fix logic of caching
644 previous display string position. Initialize cached_prev_pos to
645 -1. Fixes slow-down at the beginning of a buffer.
646
6472011-07-24 Eli Zaretskii <eliz@gnu.org>
648
649 * xfaces.c (check_lface_attrs) [HAVE_WINDOW_SYSTEM]: Allow `nil'
650 for attrs[LFACE_FONTSET_INDEX].
651
6522011-07-23 Paul Eggert <eggert@cs.ucla.edu>
653
654 * xml.c (parse_region): Remove unused local
655 that was recently introduced.
656
6572011-07-23 Eli Zaretskii <eliz@gnu.org>
658
659 * xfns.c (unwind_create_frame) [GLYPH_DEBUG]: Adapt to changes in
660 2008-02-22T17:42:09Z!monnier@iro.umontreal.ca.
661
662 * xdisp.c (move_it_in_display_line_to): Record the best matching
663 position for TO_CHARPOS while scanning the line, and restore it on
664 exit if none of the characters scanned was an exact match. Fixes
665 vertical-motion and pos-visible-in-window-p under bidi redisplay
666 when exact match is impossible due to invisible text, and the
667 lines are truncated.
668
6692011-07-23 Jan Djärv <jan.h.d@swipnet.se>
670
671 * nsterm.m (initFrameFromEmacs): Set NSTitledWindowMask in styleMask
672 for OSX >= 10.7.
673
6742011-07-22 Eli Zaretskii <eliz@gnu.org>
675
676 Fix a significant slow-down of cursor motion with C-n, C-p,
677 C-f/C-b, and C-v/M-v that couldn't keep up with keyboard
678 auto-repeat under bidi redisplay in fontified buffers.
679 * xdisp.c (compute_stop_pos_backwards): New function.
680 (next_element_from_buffer): Call compute_stop_pos_backwards to
681 find a suitable prev_stop when we find ourselves before
682 base_level_stop.
683 (reseat): Don't look for prev_stop, as that could mean a very long
684 run.
685 <cached_disp_pos, cached_disp_buffer, cached_disp_modiff>
686 <cached_disp_overlay_modiff>: Cache for last found display string
687 position.
688 (compute_display_string_pos): Return the cached position if asked
689 about the same buffer in the same area of character positions, and
690 the buffer wasn't changed since the time the display string
691 position was cached.
692
6932011-07-22 Eli Zaretskii <eliz@gnu.org>
694
695 * xdisp.c (rows_from_pos_range): Don't ignore glyphs whose object
696 is an integer, which is important for empty lines. (Bug#9149)
697
6982011-07-22 Chong Yidong <cyd@stupidchicken.com>
699
700 * frame.c (Fmodify_frame_parameters): In tty case, update the
701 default face if necessary (Bug#4238).
702
7032011-07-21 Chong Yidong <cyd@stupidchicken.com>
704
705 * editfns.c (Fstring_to_char): No need to explain what a character
706 is in the docstring (Bug#6576).
707
7082011-07-20 Lars Magne Ingebrigtsen <larsi@gnus.org>
709
710 * xml.c (parse_region): Make sure we always return a tree.
711
7122011-07-20 HAMANO Kiyoto <khiker.mail@gmail.com>
713
714 * xml.c (parse_region): If a document contains only comments,
715 return that, too.
716
7172011-07-20 Lars Magne Ingebrigtsen <larsi@gnus.org>
718
719 * xml.c (make_dom): Return comments, too.
720
5572011-07-19 Paul Eggert <eggert@cs.ucla.edu> 7212011-07-19 Paul Eggert <eggert@cs.ucla.edu>
558 722
559 Port to OpenBSD. 723 Port to OpenBSD.
diff --git a/src/alloc.c b/src/alloc.c
index eb0185a8e35..b96fc1f0642 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3282,12 +3282,16 @@ memory_full (size_t nbytes)
3282 int enough_free_memory = 0; 3282 int enough_free_memory = 0;
3283 if (SPARE_MEMORY < nbytes) 3283 if (SPARE_MEMORY < nbytes)
3284 { 3284 {
3285 void *p = malloc (SPARE_MEMORY); 3285 void *p;
3286
3287 MALLOC_BLOCK_INPUT;
3288 p = malloc (SPARE_MEMORY);
3286 if (p) 3289 if (p)
3287 { 3290 {
3288 free (p); 3291 free (p);
3289 enough_free_memory = 1; 3292 enough_free_memory = 1;
3290 } 3293 }
3294 MALLOC_UNBLOCK_INPUT;
3291 } 3295 }
3292 3296
3293 if (! enough_free_memory) 3297 if (! enough_free_memory)
diff --git a/src/buffer.c b/src/buffer.c
index fc9d3b5bd40..cacc8a41339 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4923,7 +4923,7 @@ init_buffer_once (void)
4923 BVAR (&buffer_defaults, truncate_lines) = Qnil; 4923 BVAR (&buffer_defaults, truncate_lines) = Qnil;
4924 BVAR (&buffer_defaults, word_wrap) = Qnil; 4924 BVAR (&buffer_defaults, word_wrap) = Qnil;
4925 BVAR (&buffer_defaults, ctl_arrow) = Qt; 4925 BVAR (&buffer_defaults, ctl_arrow) = Qt;
4926 BVAR (&buffer_defaults, bidi_display_reordering) = Qnil; 4926 BVAR (&buffer_defaults, bidi_display_reordering) = Qt;
4927 BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil; 4927 BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil;
4928 BVAR (&buffer_defaults, cursor_type) = Qt; 4928 BVAR (&buffer_defaults, cursor_type) = Qt;
4929 BVAR (&buffer_defaults, extra_line_spacing) = Qnil; 4929 BVAR (&buffer_defaults, extra_line_spacing) = Qnil;
diff --git a/src/callproc.c b/src/callproc.c
index 13d1232a346..993d943e158 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -603,6 +603,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
603 603
604 /* vfork, and prevent local vars from being clobbered by the vfork. */ 604 /* vfork, and prevent local vars from being clobbered by the vfork. */
605 { 605 {
606 int volatile fd1_volatile = fd1;
606 int volatile fd_error_volatile = fd_error; 607 int volatile fd_error_volatile = fd_error;
607 int volatile fd_output_volatile = fd_output; 608 int volatile fd_output_volatile = fd_output;
608 int volatile output_to_buffer_volatile = output_to_buffer; 609 int volatile output_to_buffer_volatile = output_to_buffer;
@@ -610,6 +611,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
610 611
611 pid = vfork (); 612 pid = vfork ();
612 613
614 fd1 = fd1_volatile;
613 fd_error = fd_error_volatile; 615 fd_error = fd_error_volatile;
614 fd_output = fd_output_volatile; 616 fd_output = fd_output_volatile;
615 output_to_buffer = output_to_buffer_volatile; 617 output_to_buffer = output_to_buffer_volatile;
diff --git a/src/editfns.c b/src/editfns.c
index 1616305faa3..4e1b46b82c3 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -194,12 +194,7 @@ DEFUN ("byte-to-string", Fbyte_to_string, Sbyte_to_string, 1, 1, 0,
194} 194}
195 195
196DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, 196DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0,
197 doc: /* Return the first character in STRING. 197 doc: /* Return the first character in STRING. */)
198A multibyte character is handled correctly.
199The value returned is a Unicode codepoint if it is below #x110000 (in
200hex). Codepoints beyond that are Emacs extensions of Unicode. In
201particular, eight-bit characters are returned as codepoints in the
202range #x3FFF80 through #x3FFFFF, inclusive. */)
203 (register Lisp_Object string) 198 (register Lisp_Object string)
204{ 199{
205 register Lisp_Object val; 200 register Lisp_Object val;
diff --git a/src/frame.c b/src/frame.c
index ca3ca49577c..711109a70c6 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2437,11 +2437,9 @@ use is not recommended. Explicitly check for a frame-parameter instead. */)
2437 val = values[i]; 2437 val = values[i];
2438 store_frame_param (f, prop, val); 2438 store_frame_param (f, prop, val);
2439 2439
2440 /* Changing the background color might change the background 2440 if (EQ (prop, Qforeground_color)
2441 mode, so that we have to load new defface specs. 2441 || EQ (prop, Qbackground_color))
2442 Call frame-set-background-mode to do that. */ 2442 update_face_from_frame_parameter (f, prop, val);
2443 if (EQ (prop, Qbackground_color))
2444 call1 (Qframe_set_background_mode, frame);
2445 } 2443 }
2446 } 2444 }
2447 return Qnil; 2445 return Qnil;
diff --git a/src/gnutls.c b/src/gnutls.c
index 3175f55041d..fc651d2c7e4 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -382,6 +382,9 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, EMACS_INT nbyte)
382 rtnval = fn_gnutls_record_recv (state, buf, nbyte); 382 rtnval = fn_gnutls_record_recv (state, buf, nbyte);
383 if (rtnval >= 0) 383 if (rtnval >= 0)
384 return rtnval; 384 return rtnval;
385 else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
386 /* The peer closed the connection. */
387 return 0;
385 else if (emacs_gnutls_handle_error (state, rtnval) == 0) 388 else if (emacs_gnutls_handle_error (state, rtnval) == 0)
386 /* non-fatal error */ 389 /* non-fatal error */
387 return -1; 390 return -1;
diff --git a/src/image.c b/src/image.c
index 52fd945e32a..d2a71637fed 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1909,16 +1909,17 @@ static int x_create_x_image_and_pixmap (struct frame *, int, int, int,
1909static void x_destroy_x_image (XImagePtr); 1909static void x_destroy_x_image (XImagePtr);
1910static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int); 1910static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int);
1911 1911
1912/* Return nonzero if XIMG's size WIDTH x HEIGHT doesn't break X. 1912/* Return nonzero if XIMG's size WIDTH x HEIGHT doesn't break the
1913 windowing system.
1913 WIDTH and HEIGHT must both be positive. 1914 WIDTH and HEIGHT must both be positive.
1914 If XIMG is null, assume it is a bitmap. */ 1915 If XIMG is null, assume it is a bitmap. */
1915static int 1916static int
1916x_check_image_size (XImagePtr ximg, int width, int height) 1917x_check_image_size (XImagePtr ximg, int width, int height)
1917{ 1918{
1919#ifdef HAVE_X_WINDOWS
1918 /* Respect Xlib's limits: it cannot deal with images that have more 1920 /* Respect Xlib's limits: it cannot deal with images that have more
1919 than INT_MAX (and/or UINT_MAX) bytes. And respect Emacs's limits 1921 than INT_MAX (and/or UINT_MAX) bytes. And respect Emacs's limits
1920 of PTRDIFF_MAX (and/or SIZE_MAX) bytes for any object. For now, 1922 of PTRDIFF_MAX (and/or SIZE_MAX) bytes for any object. */
1921 assume all windowing systems have the same limits that X does. */
1922 enum 1923 enum
1923 { 1924 {
1924 XLIB_BYTES_MAX = min (INT_MAX, UINT_MAX), 1925 XLIB_BYTES_MAX = min (INT_MAX, UINT_MAX),
@@ -1940,6 +1941,11 @@ x_check_image_size (XImagePtr ximg, int width, int height)
1940 } 1941 }
1941 return (width <= (INT_MAX - (bitmap_pad - 1)) / depth 1942 return (width <= (INT_MAX - (bitmap_pad - 1)) / depth
1942 && height <= X_IMAGE_BYTES_MAX / bytes_per_line); 1943 && height <= X_IMAGE_BYTES_MAX / bytes_per_line);
1944#else
1945 /* FIXME: Implement this check for the HAVE_NS and HAVE_NTGUI cases.
1946 For now, assume that every image size is allowed on these systems. */
1947 return 1;
1948#endif
1943} 1949}
1944 1950
1945/* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on 1951/* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on
diff --git a/src/lread.c b/src/lread.c
index 3703fdf5d3e..f2a52780a0c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2670,6 +2670,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2670 } 2670 }
2671 goto read_symbol; 2671 goto read_symbol;
2672 } 2672 }
2673 /* ## is the empty symbol. */
2674 if (c == '#')
2675 return Fintern (build_string (""), Qnil);
2673 /* Reader forms that can reuse previously read objects. */ 2676 /* Reader forms that can reuse previously read objects. */
2674 if (c >= '0' && c <= '9') 2677 if (c >= '0' && c <= '9')
2675 { 2678 {
diff --git a/src/nsfns.m b/src/nsfns.m
index 0452086201e..85246a4c25f 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -321,6 +321,7 @@ static void
321x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 321x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
322{ 322{
323 NSColor *col; 323 NSColor *col;
324 CGFloat r, g, b, alpha;
324 325
325 if (ns_lisp_to_color (arg, &col)) 326 if (ns_lisp_to_color (arg, &col))
326 { 327 {
@@ -332,6 +333,10 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
332 [f->output_data.ns->foreground_color release]; 333 [f->output_data.ns->foreground_color release];
333 f->output_data.ns->foreground_color = col; 334 f->output_data.ns->foreground_color = col;
334 335
336 [col getRed: &r green: &g blue: &b alpha: &alpha];
337 FRAME_FOREGROUND_PIXEL (f) =
338 ARGB_TO_ULONG ((int)(alpha*0xff), (int)(r*0xff), (int)(g*0xff), (int)(b*0xff));
339
335 if (FRAME_NS_VIEW (f)) 340 if (FRAME_NS_VIEW (f))
336 { 341 {
337 update_face_from_frame_parameter (f, Qforeground_color, arg); 342 update_face_from_frame_parameter (f, Qforeground_color, arg);
@@ -348,7 +353,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
348 struct face *face; 353 struct face *face;
349 NSColor *col; 354 NSColor *col;
350 NSView *view = FRAME_NS_VIEW (f); 355 NSView *view = FRAME_NS_VIEW (f);
351 float alpha; 356 CGFloat r, g, b, alpha;
352 357
353 if (ns_lisp_to_color (arg, &col)) 358 if (ns_lisp_to_color (arg, &col))
354 { 359 {
@@ -364,10 +369,14 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
364 [col retain]; 369 [col retain];
365 [f->output_data.ns->background_color release]; 370 [f->output_data.ns->background_color release];
366 f->output_data.ns->background_color = col; 371 f->output_data.ns->background_color = col;
372
373 [col getRed: &r green: &g blue: &b alpha: &alpha];
374 FRAME_BACKGROUND_PIXEL (f) =
375 ARGB_TO_ULONG ((int)(alpha*0xff), (int)(r*0xff), (int)(g*0xff), (int)(b*0xff));
376
367 if (view != nil) 377 if (view != nil)
368 { 378 {
369 [[view window] setBackgroundColor: col]; 379 [[view window] setBackgroundColor: col];
370 alpha = [col alphaComponent];
371 380
372 if (alpha != 1.0) 381 if (alpha != 1.0)
373 [[view window] setOpaque: NO]; 382 [[view window] setOpaque: NO];
diff --git a/src/nsfont.m b/src/nsfont.m
index 76c70aadf9f..60f8c5321aa 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -804,8 +804,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
804 font->props[FONT_FILE_INDEX] = Qnil; 804 font->props[FONT_FILE_INDEX] = Qnil;
805 805
806 { 806 {
807 double expand, hshrink;
808 float full_height, min_height, hd;
809 const char *fontName = [[nsfont fontName] UTF8String]; 807 const char *fontName = [[nsfont fontName] UTF8String];
810 int len = strlen (fontName); 808 int len = strlen (fontName);
811 809
@@ -837,26 +835,16 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
837 [sfont maximumAdvancement].width : ns_char_width (sfont, '0'); 835 [sfont maximumAdvancement].width : ns_char_width (sfont, '0');
838 836
839 brect = [sfont boundingRectForFont]; 837 brect = [sfont boundingRectForFont];
840 full_height = brect.size.height;
841 min_height = [sfont ascender] - adjusted_descender;
842 hd = full_height - min_height;
843 838
844 /* standard height, similar to Carbon. Emacs.app: was 0.5 by default. */ 839 font_info->underpos = [sfont underlinePosition];
845 expand = 0.0;
846 hshrink = 1.0;
847
848 font_info->underpos = 2; /*[sfont underlinePosition] is often clipped out */
849 font_info->underwidth = [sfont underlineThickness]; 840 font_info->underwidth = [sfont underlineThickness];
850 font_info->size = font->pixel_size; 841 font_info->size = font->pixel_size;
851 font_info->voffset = lrint (hshrink * [sfont ascender] + expand * hd / 2);
852 842
853 /* max bounds */ 843 /* max bounds */
854 font_info->max_bounds.ascent = 844 font_info->max_bounds.ascent = lrint ([sfont ascender]);
855 lrint (hshrink * [sfont ascender] + expand * hd/2);
856 /* Descender is usually negative. Use floor to avoid 845 /* Descender is usually negative. Use floor to avoid
857 clipping descenders. */ 846 clipping descenders. */
858 font_info->max_bounds.descent = 847 font_info->max_bounds.descent = -lrint (floor(adjusted_descender));
859 -lrint (floor(hshrink* adjusted_descender - expand*hd/2));
860 font_info->height = 848 font_info->height =
861 font_info->max_bounds.ascent + font_info->max_bounds.descent; 849 font_info->max_bounds.ascent + font_info->max_bounds.descent;
862 font_info->max_bounds.width = lrint (font_info->width); 850 font_info->max_bounds.width = lrint (font_info->width);
@@ -1165,7 +1153,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1165 1153
1166 1154
1167 /* set up for character rendering */ 1155 /* set up for character rendering */
1168 r.origin.y += font->voffset + (s->height - font->height)/2; 1156 r.origin.y = s->ybase;
1169 1157
1170 col = (NS_FACE_FOREGROUND (face) != 0 1158 col = (NS_FACE_FOREGROUND (face) != 0
1171 ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f) 1159 ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f)
@@ -1196,20 +1184,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1196/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */ 1184/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
1197 } 1185 }
1198 1186
1199 /* do underline */ 1187 [col set];
1200 if (face->underline_p)
1201 {
1202 if (face->underline_color != 0)
1203 [ns_lookup_indexed_color (face->underline_color, s->f) set];
1204 else
1205 [col set];
1206 DPSmoveto (context, r.origin.x, r.origin.y + font->underpos);
1207 DPSlineto (context, r.origin.x+r.size.width, r.origin.y+font->underpos);
1208 if (face->underline_color != 0)
1209 [col set];
1210 }
1211 else
1212 [col set];
1213 1188
1214 /* draw with DPSxshow () */ 1189 /* draw with DPSxshow () */
1215 DPSmoveto (context, r.origin.x, r.origin.y); 1190 DPSmoveto (context, r.origin.x, r.origin.y);
@@ -1255,23 +1230,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1255 CGContextSetTextDrawingMode (gcontext, kCGTextFill); 1230 CGContextSetTextDrawingMode (gcontext, kCGTextFill);
1256 } 1231 }
1257 1232
1258 if (face->underline_p) 1233 [col set];
1259 {
1260 if (face->underline_color != 0)
1261 [ns_lookup_indexed_color (face->underline_color, s->f) set];
1262 else
1263 [col set];
1264 CGContextBeginPath (gcontext);
1265 CGContextMoveToPoint (gcontext,
1266 r.origin.x, r.origin.y + font->underpos);
1267 CGContextAddLineToPoint (gcontext, r.origin.x + r.size.width,
1268 r.origin.y + font->underpos);
1269 CGContextStrokePath (gcontext);
1270 if (face->underline_color != 0)
1271 [col set];
1272 }
1273 else
1274 [col set];
1275 1234
1276 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); 1235 CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y);
1277 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, 1236 CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from,
@@ -1287,6 +1246,10 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1287 CGContextRestoreGState (gcontext); 1246 CGContextRestoreGState (gcontext);
1288 } 1247 }
1289#endif /* NS_IMPL_COCOA */ 1248#endif /* NS_IMPL_COCOA */
1249
1250 /* Draw underline, overline, strike-through. */
1251 ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x);
1252
1290 return to-from; 1253 return to-from;
1291} 1254}
1292 1255
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 95e23ff6512..951282910ac 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1228,8 +1228,8 @@ update_frame_tool_bar (FRAME_PTR f)
1228 1228
1229 [textField setEditable: NO]; 1229 [textField setEditable: NO];
1230 [textField setSelectable: NO]; 1230 [textField setSelectable: NO];
1231 [textField setBordered: YES]; 1231 [textField setBordered: NO];
1232 [textField setBezeled: YES]; 1232 [textField setBezeled: NO];
1233 [textField setDrawsBackground: YES]; 1233 [textField setDrawsBackground: YES];
1234 1234
1235 win = [[NSWindow alloc] 1235 win = [[NSWindow alloc]
@@ -1237,6 +1237,7 @@ update_frame_tool_bar (FRAME_PTR f)
1237 styleMask: 0 1237 styleMask: 0
1238 backing: NSBackingStoreBuffered 1238 backing: NSBackingStoreBuffered
1239 defer: YES]; 1239 defer: YES];
1240 [win setHasShadow: YES];
1240 [win setReleasedWhenClosed: NO]; 1241 [win setReleasedWhenClosed: NO];
1241 [win setDelegate: self]; 1242 [win setDelegate: self];
1242 [[win contentView] addSubview: textField]; 1243 [[win contentView] addSubview: textField];
@@ -1257,17 +1258,15 @@ update_frame_tool_bar (FRAME_PTR f)
1257- (void) setText: (char *)text 1258- (void) setText: (char *)text
1258{ 1259{
1259 NSString *str = [NSString stringWithUTF8String: text]; 1260 NSString *str = [NSString stringWithUTF8String: text];
1260 NSRect r = [textField frame]; 1261 NSRect r = [textField frame];
1261 NSSize textSize = [str sizeWithAttributes: 1262 NSSize tooltipDims;
1262 [NSDictionary dictionaryWithObject: [[textField font] screenFont] 1263
1263 forKey: NSFontAttributeName]];
1264 NSSize padSize = [[[textField font] screenFont]
1265 boundingRectForFont].size;
1266
1267 r.size.width = textSize.width + padSize.width/2;
1268 r.size.height = textSize.height + padSize.height/2;
1269 [textField setFrame: r];
1270 [textField setStringValue: str]; 1264 [textField setStringValue: str];
1265 tooltipDims = [[textField cell] cellSize];
1266
1267 r.size.width = tooltipDims.width;
1268 r.size.height = tooltipDims.height;
1269 [textField setFrame: r];
1271} 1270}
1272 1271
1273- (void) showAtX: (int)x Y: (int)y for: (int)seconds 1272- (void) showAtX: (int)x Y: (int)y for: (int)seconds
@@ -1340,7 +1339,7 @@ Lisp_Object
1340ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) 1339ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1341{ 1340{
1342 id dialog; 1341 id dialog;
1343 Lisp_Object window, tem; 1342 Lisp_Object window, tem, title;
1344 struct frame *f; 1343 struct frame *f;
1345 NSPoint p; 1344 NSPoint p;
1346 BOOL isQ; 1345 BOOL isQ;
@@ -1389,6 +1388,14 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1389 p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2; 1388 p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2;
1390 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; 1389 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2;
1391 1390
1391 title = Fcar (contents);
1392 CHECK_STRING (title);
1393
1394 if (NILP (Fcar (Fcdr (contents))))
1395 /* No buttons specified, add an "Ok" button so users can pop down
1396 the dialog. */
1397 contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil));
1398
1392 BLOCK_INPUT; 1399 BLOCK_INPUT;
1393 dialog = [[EmacsDialogPanel alloc] initFromContents: contents 1400 dialog = [[EmacsDialogPanel alloc] initFromContents: contents
1394 isQuestion: isQ]; 1401 isQuestion: isQ];
diff --git a/src/nsterm.h b/src/nsterm.h
index 17003ac947b..5bbc5329aa2 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -467,7 +467,6 @@ struct nsfont_info
467#endif 467#endif
468 char bold, ital; /* convenience flags */ 468 char bold, ital; /* convenience flags */
469 char synthItal; 469 char synthItal;
470 float voffset; /* mean of ascender/descender offsets */
471 XCharStruct max_bounds; 470 XCharStruct max_bounds;
472 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed 471 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
473 by hibyte, lobyte */ 472 by hibyte, lobyte */
@@ -825,6 +824,13 @@ extern unsigned long ns_get_rgb_color (struct frame *f,
825 float r, float g, float b, float a); 824 float r, float g, float b, float a);
826extern NSPoint last_mouse_motion_position; 825extern NSPoint last_mouse_motion_position;
827 826
827/* From nsterm.m, needed in nsfont.m. */
828#ifdef __OBJC__
829extern void
830ns_draw_text_decoration (struct glyph_string *s, struct face *face,
831 NSColor *defaultCol, CGFloat width, CGFloat x);
832#endif
833
828#ifdef NS_IMPL_GNUSTEP 834#ifdef NS_IMPL_GNUSTEP
829extern char gnustep_base_version[]; /* version tracking */ 835extern char gnustep_base_version[]; /* version tracking */
830#endif 836#endif
diff --git a/src/nsterm.m b/src/nsterm.m
index 4fb9a8e8f61..2ce996dc82f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -263,8 +263,6 @@ static void ns_condemn_scroll_bars (struct frame *f);
263static void ns_judge_scroll_bars (struct frame *f); 263static void ns_judge_scroll_bars (struct frame *f);
264void x_set_frame_alpha (struct frame *f); 264void x_set_frame_alpha (struct frame *f);
265 265
266/* FIXME: figure out what to do with underline_minimum_offset. */
267
268 266
269/* ========================================================================== 267/* ==========================================================================
270 268
@@ -2604,6 +2602,107 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2604 return n; 2602 return n;
2605} 2603}
2606 2604
2605void
2606ns_draw_text_decoration (struct glyph_string *s, struct face *face,
2607 NSColor *defaultCol, CGFloat width, CGFloat x)
2608/* --------------------------------------------------------------------------
2609 Draw underline, overline, and strike-through on glyph string s.
2610 -------------------------------------------------------------------------- */
2611{
2612 if (s->for_overlaps)
2613 return;
2614
2615 /* Do underline. */
2616 if (face->underline_p)
2617 {
2618 NSRect r;
2619 unsigned long thickness, position;
2620
2621 /* If the prev was underlined, match its appearance. */
2622 if (s->prev && s->prev->face->underline_p
2623 && s->prev->underline_thickness > 0)
2624 {
2625 thickness = s->prev->underline_thickness;
2626 position = s->prev->underline_position;
2627 }
2628 else
2629 {
2630 struct font *font;
2631 unsigned long descent;
2632
2633 font=s->font;
2634 descent = s->y + s->height - s->ybase;
2635
2636 /* Use underline thickness of font, defaulting to 1. */
2637 thickness = (font && font->underline_thickness > 0)
2638 ? font->underline_thickness : 1;
2639
2640 /* Determine the offset of underlining from the baseline. */
2641 if (x_underline_at_descent_line)
2642 position = descent - thickness;
2643 else if (x_use_underline_position_properties
2644 && font && font->underline_position >= 0)
2645 position = font->underline_position;
2646 else if (font)
2647 position = lround (font->descent / 2);
2648 else
2649 position = underline_minimum_offset;
2650
2651 position = max (position, underline_minimum_offset);
2652
2653 /* Ensure underlining is not cropped. */
2654 if (descent <= position)
2655 {
2656 position = descent - 1;
2657 thickness = 1;
2658 }
2659 else if (descent < position + thickness)
2660 thickness = 1;
2661 }
2662
2663 s->underline_thickness = thickness;
2664 s->underline_position = position;
2665
2666 r = NSMakeRect (x, s->ybase + position, width, thickness);
2667
2668 if (face->underline_defaulted_p)
2669 [defaultCol set];
2670 else
2671 [ns_lookup_indexed_color (face->underline_color, s->f) set];
2672 NSRectFill (r);
2673 }
2674
2675 /* Do overline. We follow other terms in using a thickness of 1
2676 and ignoring overline_margin. */
2677 if (face->overline_p)
2678 {
2679 NSRect r;
2680 r = NSMakeRect (x, s->y, width, 1);
2681
2682 if (face->overline_color_defaulted_p)
2683 [defaultCol set];
2684 else
2685 [ns_lookup_indexed_color (face->overline_color, s->f) set];
2686 NSRectFill (r);
2687 }
2688
2689 /* Do strike-through. We follow other terms for thickness and
2690 vertical position.*/
2691 if (face->strike_through_p)
2692 {
2693 NSRect r;
2694 unsigned long dy;
2695
2696 dy = lrint ((s->height - 1) / 2);
2697 r = NSMakeRect (x, s->y + dy, width, 1);
2698
2699 if (face->strike_through_color_defaulted_p)
2700 [defaultCol set];
2701 else
2702 [ns_lookup_indexed_color (face->strike_through_color, s->f) set];
2703 NSRectFill (r);
2704 }
2705}
2607 2706
2608static void 2707static void
2609ns_draw_box (NSRect r, float thickness, NSColor *col, char left_p, char right_p) 2708ns_draw_box (NSRect r, float thickness, NSColor *col, char left_p, char right_p)
@@ -2861,6 +2960,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2861 char raised_p; 2960 char raised_p;
2862 NSRect br; 2961 NSRect br;
2863 struct face *face; 2962 struct face *face;
2963 NSColor *tdCol;
2864 2964
2865 NSTRACE (ns_dumpglyphs_image); 2965 NSTRACE (ns_dumpglyphs_image);
2866 2966
@@ -2889,10 +2989,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2889 else 2989 else
2890 face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 2990 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
2891 2991
2892 if (s->hl == DRAW_CURSOR) 2992 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set];
2893 [FRAME_CURSOR_COLOR (s->f) set];
2894 else
2895 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set];
2896 2993
2897 if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin 2994 if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
2898 || s->img->mask || s->img->pixmap == 0 || s->width != s->background_width) 2995 || s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
@@ -2930,6 +3027,27 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2930 [img compositeToPoint: NSMakePoint (x, y + s->slice.height) 3027 [img compositeToPoint: NSMakePoint (x, y + s->slice.height)
2931 operation: NSCompositeSourceOver]; 3028 operation: NSCompositeSourceOver];
2932 3029
3030 if (s->hl == DRAW_CURSOR)
3031 {
3032 [FRAME_CURSOR_COLOR (s->f) set];
3033 if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
3034 tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
3035 else
3036 /* Currently on NS img->mask is always 0. Since
3037 get_window_cursor_type specifies a hollow box cursor when on
3038 a non-masked image we never reach this clause. But we put it
3039 in in antipication of better support for image masks on
3040 NS. */
3041 tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3042 }
3043 else
3044 {
3045 tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3046 }
3047
3048 /* Draw underline, overline, strike-through. */
3049 ns_draw_text_decoration (s, face, tdCol, br.size.width, br.origin.x);
3050
2933 /* Draw relief, if requested */ 3051 /* Draw relief, if requested */
2934 if (s->img->relief || s->hl ==DRAW_IMAGE_RAISED || s->hl ==DRAW_IMAGE_SUNKEN) 3052 if (s->img->relief || s->hl ==DRAW_IMAGE_RAISED || s->hl ==DRAW_IMAGE_SUNKEN)
2935 { 3053 {
@@ -2974,22 +3092,49 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
2974 NSRect r[2]; 3092 NSRect r[2];
2975 int n, i; 3093 int n, i;
2976 struct face *face; 3094 struct face *face;
3095 NSColor *fgCol, *bgCol;
2977 3096
2978 if (!s->background_filled_p) 3097 if (!s->background_filled_p)
2979 { 3098 {
2980 n = ns_get_glyph_string_clip_rect (s, r); 3099 n = ns_get_glyph_string_clip_rect (s, r);
2981 *r = NSMakeRect (s->x, s->y, s->background_width, s->height); 3100 *r = NSMakeRect (s->x, s->y, s->background_width, s->height);
2982 3101
3102 ns_focus (s->f, r, n);
3103
3104 if (s->hl == DRAW_MOUSE_FACE)
3105 {
3106 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3107 if (!face)
3108 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3109 }
3110 else
3111 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
3112
3113 bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
3114 fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
3115
2983 for (i=0; i<n; i++) 3116 for (i=0; i<n; i++)
2984 { 3117 {
2985 if (!s->row->full_width_p) 3118 if (!s->row->full_width_p)
2986 { 3119 {
3120 int overrun, leftoverrun;
3121
2987 /* truncate to avoid overwriting fringe and/or scrollbar */ 3122 /* truncate to avoid overwriting fringe and/or scrollbar */
2988 int overrun = max (0, (s->x + s->background_width) 3123 overrun = max (0, (s->x + s->background_width)
2989 - (WINDOW_BOX_RIGHT_EDGE_X (s->w) 3124 - (WINDOW_BOX_RIGHT_EDGE_X (s->w)
2990 - WINDOW_RIGHT_FRINGE_WIDTH (s->w))); 3125 - WINDOW_RIGHT_FRINGE_WIDTH (s->w)));
2991 r[i].size.width -= overrun; 3126 r[i].size.width -= overrun;
2992 3127
3128 /* truncate to avoid overwriting to left of the window box */
3129 leftoverrun = (WINDOW_BOX_LEFT_EDGE_X (s->w)
3130 + WINDOW_LEFT_FRINGE_WIDTH (s->w)) - s->x;
3131
3132 if (leftoverrun > 0)
3133 {
3134 r[i].origin.x += leftoverrun;
3135 r[i].size.width -= leftoverrun;
3136 }
3137
2993 /* XXX: Try to work between problem where a stretch glyph on 3138 /* XXX: Try to work between problem where a stretch glyph on
2994 a partially-visible bottom row will clear part of the 3139 a partially-visible bottom row will clear part of the
2995 modeline, and another where list-buffers headers and similar 3140 modeline, and another where list-buffers headers and similar
@@ -3005,30 +3150,37 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3005 FRAME_PIXEL_WIDTH (s->f)); 3150 FRAME_PIXEL_WIDTH (s->f));
3006 } 3151 }
3007 3152
3153 [bgCol set];
3154
3008 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid 3155 /* NOTE: under NS this is NOT used to draw cursors, but we must avoid
3009 overwriting cursor (usually when cursor on a tab) */ 3156 overwriting cursor (usually when cursor on a tab) */
3010 if (s->hl == DRAW_CURSOR) 3157 if (s->hl == DRAW_CURSOR)
3011 { 3158 {
3012 r[i].origin.x += s->width; 3159 CGFloat x, width;
3013 r[i].size.width -= s->width;
3014 }
3015 }
3016 3160
3017 ns_focus (s->f, r, n); 3161 x = r[i].origin.x;
3162 width = s->w->phys_cursor_width;
3163 r[i].size.width -= width;
3164 r[i].origin.x += width;
3018 3165
3019 if (s->hl == DRAW_MOUSE_FACE) 3166 NSRectFill (r[i]);
3020 {
3021 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3022 if (!face)
3023 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3024 }
3025 else
3026 face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
3027 3167
3028 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set]; 3168 /* Draw overlining, etc. on the cursor. */
3169 if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
3170 ns_draw_text_decoration (s, face, bgCol, width, x);
3171 else
3172 ns_draw_text_decoration (s, face, fgCol, width, x);
3173 }
3174 else
3175 {
3176 NSRectFill (r[i]);
3177 }
3029 3178
3030 NSRectFill (r[0]); 3179 /* Draw overlining, etc. on the stretch glyph (or the part
3031 NSRectFill (r[1]); 3180 of the stretch glyph after the cursor). */
3181 ns_draw_text_decoration (s, face, fgCol, r[i].size.width,
3182 r[i].origin.x);
3183 }
3032 ns_unfocus (s->f); 3184 ns_unfocus (s->f);
3033 s->background_filled_p = 1; 3185 s->background_filled_p = 1;
3034 } 3186 }
@@ -5311,6 +5463,9 @@ ns_term_shutdown (int sig)
5311 win = [[EmacsWindow alloc] 5463 win = [[EmacsWindow alloc]
5312 initWithContentRect: r 5464 initWithContentRect: r
5313 styleMask: (NSResizableWindowMask | 5465 styleMask: (NSResizableWindowMask |
5466#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
5467 NSTitledWindowMask |
5468#endif
5314 NSMiniaturizableWindowMask | 5469 NSMiniaturizableWindowMask |
5315 NSClosableWindowMask) 5470 NSClosableWindowMask)
5316 backing: NSBackingStoreBuffered 5471 backing: NSBackingStoreBuffered
@@ -6560,23 +6715,17 @@ Only works on OSX 10.6 or later. */);
6560 Vx_toolkit_scroll_bars = Qnil; 6715 Vx_toolkit_scroll_bars = Qnil;
6561#endif 6716#endif
6562 6717
6563 /* these are unsupported but we need the declarations to avoid whining
6564 messages from cus-start.el */
6565 DEFVAR_BOOL ("x-use-underline-position-properties", 6718 DEFVAR_BOOL ("x-use-underline-position-properties",
6566 x_use_underline_position_properties, 6719 x_use_underline_position_properties,
6567 doc: /* NOT SUPPORTED UNDER NS. 6720 doc: /*Non-nil means make use of UNDERLINE_POSITION font properties.
6568*Non-nil means make use of UNDERLINE_POSITION font properties.
6569A value of nil means ignore them. If you encounter fonts with bogus 6721A value of nil means ignore them. If you encounter fonts with bogus
6570UNDERLINE_POSITION font properties, for example 7x13 on XFree prior 6722UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
6571to 4.1, set this to nil. 6723to 4.1, set this to nil. */);
6572
6573NOTE: Not supported on Mac yet. */);
6574 x_use_underline_position_properties = 0; 6724 x_use_underline_position_properties = 0;
6575 6725
6576 DEFVAR_BOOL ("x-underline-at-descent-line", 6726 DEFVAR_BOOL ("x-underline-at-descent-line",
6577 x_underline_at_descent_line, 6727 x_underline_at_descent_line,
6578 doc: /* NOT SUPPORTED UNDER NS. 6728 doc: /* Non-nil means to draw the underline at the same place as the descent line.
6579*Non-nil means to draw the underline at the same place as the descent line.
6580A value of nil means to draw the underline according to the value of the 6729A value of nil means to draw the underline according to the value of the
6581variable `x-use-underline-position-properties', which is usually at the 6730variable `x-use-underline-position-properties', which is usually at the
6582baseline level. The default value is nil. */); 6731baseline level. The default value is nil. */);
diff --git a/src/print.c b/src/print.c
index f1907a31465..35f89860843 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1536,13 +1536,19 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1536 else 1536 else
1537 confusing = 0; 1537 confusing = 0;
1538 1538
1539 size_byte = SBYTES (name);
1540
1539 if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj)) 1541 if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj))
1540 { 1542 {
1541 PRINTCHAR ('#'); 1543 PRINTCHAR ('#');
1542 PRINTCHAR (':'); 1544 PRINTCHAR (':');
1543 } 1545 }
1544 1546 else if (size_byte == 0)
1545 size_byte = SBYTES (name); 1547 {
1548 PRINTCHAR ('#');
1549 PRINTCHAR ('#');
1550 break;
1551 }
1546 1552
1547 for (i = 0, i_byte = 0; i_byte < size_byte;) 1553 for (i = 0, i_byte = 0; i_byte < size_byte;)
1548 { 1554 {
@@ -1555,7 +1561,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1555 { 1561 {
1556 if (c == '\"' || c == '\\' || c == '\'' 1562 if (c == '\"' || c == '\\' || c == '\''
1557 || c == ';' || c == '#' || c == '(' || c == ')' 1563 || c == ';' || c == '#' || c == '(' || c == ')'
1558 || c == ',' || c =='.' || c == '`' 1564 || c == ',' || c == '.' || c == '`'
1559 || c == '[' || c == ']' || c == '?' || c <= 040 1565 || c == '[' || c == ']' || c == '?' || c <= 040
1560 || confusing) 1566 || confusing)
1561 PRINTCHAR ('\\'), confusing = 0; 1567 PRINTCHAR ('\\'), confusing = 0;
diff --git a/src/regex.c b/src/regex.c
index 190d1d0fe21..862f848976c 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -2093,23 +2093,23 @@ re_iswctype (int ch, re_wctype_t cc)
2093{ 2093{
2094 switch (cc) 2094 switch (cc)
2095 { 2095 {
2096 case RECC_ALNUM: return ISALNUM (ch); 2096 case RECC_ALNUM: return ISALNUM (ch) != 0;
2097 case RECC_ALPHA: return ISALPHA (ch); 2097 case RECC_ALPHA: return ISALPHA (ch) != 0;
2098 case RECC_BLANK: return ISBLANK (ch); 2098 case RECC_BLANK: return ISBLANK (ch) != 0;
2099 case RECC_CNTRL: return ISCNTRL (ch); 2099 case RECC_CNTRL: return ISCNTRL (ch) != 0;
2100 case RECC_DIGIT: return ISDIGIT (ch); 2100 case RECC_DIGIT: return ISDIGIT (ch) != 0;
2101 case RECC_GRAPH: return ISGRAPH (ch); 2101 case RECC_GRAPH: return ISGRAPH (ch) != 0;
2102 case RECC_LOWER: return ISLOWER (ch); 2102 case RECC_LOWER: return ISLOWER (ch) != 0;
2103 case RECC_PRINT: return ISPRINT (ch); 2103 case RECC_PRINT: return ISPRINT (ch) != 0;
2104 case RECC_PUNCT: return ISPUNCT (ch); 2104 case RECC_PUNCT: return ISPUNCT (ch) != 0;
2105 case RECC_SPACE: return ISSPACE (ch); 2105 case RECC_SPACE: return ISSPACE (ch) != 0;
2106 case RECC_UPPER: return ISUPPER (ch); 2106 case RECC_UPPER: return ISUPPER (ch) != 0;
2107 case RECC_XDIGIT: return ISXDIGIT (ch); 2107 case RECC_XDIGIT: return ISXDIGIT (ch) != 0;
2108 case RECC_ASCII: return IS_REAL_ASCII (ch); 2108 case RECC_ASCII: return IS_REAL_ASCII (ch) != 0;
2109 case RECC_NONASCII: return !IS_REAL_ASCII (ch); 2109 case RECC_NONASCII: return !IS_REAL_ASCII (ch) != 0;
2110 case RECC_UNIBYTE: return ISUNIBYTE (ch); 2110 case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0;
2111 case RECC_MULTIBYTE: return !ISUNIBYTE (ch); 2111 case RECC_MULTIBYTE: return !ISUNIBYTE (ch) != 0;
2112 case RECC_WORD: return ISWORD (ch); 2112 case RECC_WORD: return ISWORD (ch) != 0;
2113 case RECC_ERROR: return false; 2113 case RECC_ERROR: return false;
2114 default: 2114 default:
2115 abort(); 2115 abort();
diff --git a/src/xdisp.c b/src/xdisp.c
index 92a7b200846..d44e677eeb7 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3131,6 +3131,14 @@ next_overlay_change (EMACS_INT pos)
3131 return endpos; 3131 return endpos;
3132} 3132}
3133 3133
3134/* Record one cached display string position found recently by
3135 compute_display_string_pos. */
3136static EMACS_INT cached_disp_pos;
3137static EMACS_INT cached_prev_pos = -1;
3138static struct buffer *cached_disp_buffer;
3139static int cached_disp_modiff;
3140static int cached_disp_overlay_modiff;
3141
3134/* Return the character position of a display string at or after 3142/* Return the character position of a display string at or after
3135 position specified by POSITION. If no display string exists at or 3143 position specified by POSITION. If no display string exists at or
3136 after POSITION, return ZV. A display string is either an overlay 3144 after POSITION, return ZV. A display string is either an overlay
@@ -3152,6 +3160,7 @@ compute_display_string_pos (struct text_pos *position,
3152 EMACS_INT begb = string_p ? 0 : BEGV; 3160 EMACS_INT begb = string_p ? 0 : BEGV;
3153 EMACS_INT bufpos, charpos = CHARPOS (*position); 3161 EMACS_INT bufpos, charpos = CHARPOS (*position);
3154 struct text_pos tpos; 3162 struct text_pos tpos;
3163 struct buffer *b;
3155 3164
3156 if (charpos >= eob 3165 if (charpos >= eob
3157 /* We don't support display properties whose values are strings 3166 /* We don't support display properties whose values are strings
@@ -3161,6 +3170,38 @@ compute_display_string_pos (struct text_pos *position,
3161 || (string->s && !STRINGP (object))) 3170 || (string->s && !STRINGP (object)))
3162 return eob; 3171 return eob;
3163 3172
3173 /* Check the cached values. */
3174 if (!STRINGP (object))
3175 {
3176 if (NILP (object))
3177 b = current_buffer;
3178 else
3179 b = XBUFFER (object);
3180 if (b == cached_disp_buffer
3181 && BUF_MODIFF (b) == cached_disp_modiff
3182 && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff
3183 && !b->clip_changed)
3184 {
3185 if (cached_prev_pos >= 0
3186 && cached_prev_pos < charpos && charpos <= cached_disp_pos)
3187 return cached_disp_pos;
3188 /* Handle overstepping either end of the known interval. */
3189 if (charpos > cached_disp_pos)
3190 cached_prev_pos = cached_disp_pos;
3191 else /* charpos <= cached_prev_pos */
3192 cached_prev_pos = max (charpos - 1, 0);
3193 }
3194
3195 /* Record new values in the cache. */
3196 if (b != cached_disp_buffer)
3197 {
3198 cached_disp_buffer = b;
3199 cached_prev_pos = max (charpos - 1, 0);
3200 }
3201 cached_disp_modiff = BUF_MODIFF (b);
3202 cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b);
3203 }
3204
3164 /* If the character at CHARPOS is where the display string begins, 3205 /* If the character at CHARPOS is where the display string begins,
3165 return CHARPOS. */ 3206 return CHARPOS. */
3166 pos = make_number (charpos); 3207 pos = make_number (charpos);
@@ -3176,7 +3217,11 @@ compute_display_string_pos (struct text_pos *position,
3176 spec)) 3217 spec))
3177 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, 3218 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3178 frame_window_p)) 3219 frame_window_p))
3179 return charpos; 3220 {
3221 if (!STRINGP (object))
3222 cached_disp_pos = charpos;
3223 return charpos;
3224 }
3180 3225
3181 /* Look forward for the first character with a `display' property 3226 /* Look forward for the first character with a `display' property
3182 that will replace the underlying text when displayed. */ 3227 that will replace the underlying text when displayed. */
@@ -3196,6 +3241,8 @@ compute_display_string_pos (struct text_pos *position,
3196 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, 3241 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3197 frame_window_p)); 3242 frame_window_p));
3198 3243
3244 if (!STRINGP (object))
3245 cached_disp_pos = CHARPOS (tpos);
3199 return CHARPOS (tpos); 3246 return CHARPOS (tpos);
3200} 3247}
3201 3248
@@ -5728,17 +5775,19 @@ reseat (struct it *it, struct text_pos pos, int force_p)
5728 { 5775 {
5729 /* For bidi iteration, we need to prime prev_stop and 5776 /* For bidi iteration, we need to prime prev_stop and
5730 base_level_stop with our best estimations. */ 5777 base_level_stop with our best estimations. */
5731 if (CHARPOS (pos) < it->prev_stop) 5778 /* Implementation note: Of course, POS is not necessarily a
5732 { 5779 stop position, so assigning prev_pos to it is a lie; we
5733 handle_stop_backwards (it, BEGV); 5780 should have called compute_stop_backwards. However, if
5734 if (CHARPOS (pos) < it->base_level_stop) 5781 the current buffer does not include any R2L characters,
5735 it->base_level_stop = 0; 5782 that call would be a waste of cycles, because the
5736 } 5783 iterator will never move back, and thus never cross this
5737 else if (CHARPOS (pos) > it->stop_charpos 5784 "fake" stop position. So we delay that backward search
5738 && it->stop_charpos >= BEGV) 5785 until the time we really need it, in next_element_from_buffer. */
5739 handle_stop_backwards (it, it->stop_charpos); 5786 if (CHARPOS (pos) != it->prev_stop)
5740 else /* force_p */ 5787 it->prev_stop = CHARPOS (pos);
5741 handle_stop (it); 5788 if (CHARPOS (pos) < it->base_level_stop)
5789 it->base_level_stop = 0; /* meaning it's unknown */
5790 handle_stop (it);
5742 } 5791 }
5743 else 5792 else
5744 { 5793 {
@@ -7005,10 +7054,10 @@ next_element_from_string (struct it *it)
7005 embedding level, so test for that explicitly. */ 7054 embedding level, so test for that explicitly. */
7006 && !BIDI_AT_BASE_LEVEL (it->bidi_it)) 7055 && !BIDI_AT_BASE_LEVEL (it->bidi_it))
7007 { 7056 {
7008 /* If we lost track of base_level_stop, we have no better place 7057 /* If we lost track of base_level_stop, we have no better
7009 for handle_stop_backwards to start from than BEGV. This 7058 place for handle_stop_backwards to start from than string
7010 happens, e.g., when we were reseated to the previous 7059 beginning. This happens, e.g., when we were reseated to
7011 screenful of text by vertical-motion. */ 7060 the previous screenful of text by vertical-motion. */
7012 if (it->base_level_stop <= 0 7061 if (it->base_level_stop <= 0
7013 || IT_STRING_CHARPOS (*it) < it->base_level_stop) 7062 || IT_STRING_CHARPOS (*it) < it->base_level_stop)
7014 it->base_level_stop = 0; 7063 it->base_level_stop = 0;
@@ -7196,6 +7245,50 @@ next_element_from_stretch (struct it *it)
7196 return 1; 7245 return 1;
7197} 7246}
7198 7247
7248/* Scan backwards from IT's current position until we find a stop
7249 position, or until BEGV. This is called when we find ourself
7250 before both the last known prev_stop and base_level_stop while
7251 reordering bidirectional text. */
7252
7253static void
7254compute_stop_pos_backwards (struct it *it)
7255{
7256 const int SCAN_BACK_LIMIT = 1000;
7257 struct text_pos pos;
7258 struct display_pos save_current = it->current;
7259 struct text_pos save_position = it->position;
7260 EMACS_INT charpos = IT_CHARPOS (*it);
7261 EMACS_INT where_we_are = charpos;
7262 EMACS_INT save_stop_pos = it->stop_charpos;
7263 EMACS_INT save_end_pos = it->end_charpos;
7264
7265 xassert (NILP (it->string) && !it->s);
7266 xassert (it->bidi_p);
7267 it->bidi_p = 0;
7268 do
7269 {
7270 it->end_charpos = min (charpos + 1, ZV);
7271 charpos = max (charpos - SCAN_BACK_LIMIT, BEGV);
7272 SET_TEXT_POS (pos, charpos, BYTE_TO_CHAR (charpos));
7273 reseat_1 (it, pos, 0);
7274 compute_stop_pos (it);
7275 /* We must advance forward, right? */
7276 if (it->stop_charpos <= charpos)
7277 abort ();
7278 }
7279 while (charpos > BEGV && it->stop_charpos >= it->end_charpos);
7280
7281 if (it->stop_charpos <= where_we_are)
7282 it->prev_stop = it->stop_charpos;
7283 else
7284 it->prev_stop = BEGV;
7285 it->bidi_p = 1;
7286 it->current = save_current;
7287 it->position = save_position;
7288 it->stop_charpos = save_stop_pos;
7289 it->end_charpos = save_end_pos;
7290}
7291
7199/* Scan forward from CHARPOS in the current buffer/string, until we 7292/* Scan forward from CHARPOS in the current buffer/string, until we
7200 find a stop position > current IT's position. Then handle the stop 7293 find a stop position > current IT's position. Then handle the stop
7201 position before that. This is called when we bump into a stop 7294 position before that. This is called when we bump into a stop
@@ -7215,6 +7308,7 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7215 EMACS_INT next_stop; 7308 EMACS_INT next_stop;
7216 7309
7217 /* Scan in strict logical order. */ 7310 /* Scan in strict logical order. */
7311 xassert (it->bidi_p);
7218 it->bidi_p = 0; 7312 it->bidi_p = 0;
7219 do 7313 do
7220 { 7314 {
@@ -7234,11 +7328,11 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos)
7234 } 7328 }
7235 while (charpos <= where_we_are); 7329 while (charpos <= where_we_are);
7236 7330
7237 next_stop = it->stop_charpos;
7238 it->stop_charpos = it->prev_stop;
7239 it->bidi_p = 1; 7331 it->bidi_p = 1;
7240 it->current = save_current; 7332 it->current = save_current;
7241 it->position = save_position; 7333 it->position = save_position;
7334 next_stop = it->stop_charpos;
7335 it->stop_charpos = it->prev_stop;
7242 handle_stop (it); 7336 handle_stop (it);
7243 it->stop_charpos = next_stop; 7337 it->stop_charpos = next_stop;
7244} 7338}
@@ -7335,14 +7429,19 @@ next_element_from_buffer (struct it *it)
7335 embedding level, so test for that explicitly. */ 7429 embedding level, so test for that explicitly. */
7336 && !BIDI_AT_BASE_LEVEL (it->bidi_it)) 7430 && !BIDI_AT_BASE_LEVEL (it->bidi_it))
7337 { 7431 {
7338 /* If we lost track of base_level_stop, we have no better place
7339 for handle_stop_backwards to start from than BEGV. This
7340 happens, e.g., when we were reseated to the previous
7341 screenful of text by vertical-motion. */
7342 if (it->base_level_stop <= 0 7432 if (it->base_level_stop <= 0
7343 || IT_CHARPOS (*it) < it->base_level_stop) 7433 || IT_CHARPOS (*it) < it->base_level_stop)
7344 it->base_level_stop = BEGV; 7434 {
7345 handle_stop_backwards (it, it->base_level_stop); 7435 /* If we lost track of base_level_stop, we need to find
7436 prev_stop by looking backwards. This happens, e.g., when
7437 we were reseated to the previous screenful of text by
7438 vertical-motion. */
7439 it->base_level_stop = BEGV;
7440 compute_stop_pos_backwards (it);
7441 handle_stop_backwards (it, it->prev_stop);
7442 }
7443 else
7444 handle_stop_backwards (it, it->base_level_stop);
7346 return GET_NEXT_DISPLAY_ELEMENT (it); 7445 return GET_NEXT_DISPLAY_ELEMENT (it);
7347 } 7446 }
7348 else 7447 else
@@ -7544,8 +7643,9 @@ move_it_in_display_line_to (struct it *it,
7544{ 7643{
7545 enum move_it_result result = MOVE_UNDEFINED; 7644 enum move_it_result result = MOVE_UNDEFINED;
7546 struct glyph_row *saved_glyph_row; 7645 struct glyph_row *saved_glyph_row;
7547 struct it wrap_it, atpos_it, atx_it; 7646 struct it wrap_it, atpos_it, atx_it, ppos_it;
7548 void *wrap_data = NULL, *atpos_data = NULL, *atx_data = NULL; 7647 void *wrap_data = NULL, *atpos_data = NULL, *atx_data = NULL;
7648 void *ppos_data = NULL;
7549 int may_wrap = 0; 7649 int may_wrap = 0;
7550 enum it_method prev_method = it->method; 7650 enum it_method prev_method = it->method;
7551 EMACS_INT prev_pos = IT_CHARPOS (*it); 7651 EMACS_INT prev_pos = IT_CHARPOS (*it);
@@ -7564,6 +7664,19 @@ move_it_in_display_line_to (struct it *it,
7564 atpos_it.sp = -1; 7664 atpos_it.sp = -1;
7565 atx_it.sp = -1; 7665 atx_it.sp = -1;
7566 7666
7667 /* Use ppos_it under bidi reordering to save a copy of IT for the
7668 position > CHARPOS that is the closest to CHARPOS. We restore
7669 that position in IT when we have scanned the entire display line
7670 without finding a match for CHARPOS and all the character
7671 positions are greater than CHARPOS. */
7672 if (it->bidi_p)
7673 {
7674 SAVE_IT (ppos_it, *it, ppos_data);
7675 SET_TEXT_POS (ppos_it.current.pos, ZV, ZV_BYTE);
7676 if ((op & MOVE_TO_POS) && IT_CHARPOS (*it) >= to_charpos)
7677 SAVE_IT (ppos_it, *it, ppos_data);
7678 }
7679
7567#define BUFFER_POS_REACHED_P() \ 7680#define BUFFER_POS_REACHED_P() \
7568 ((op & MOVE_TO_POS) != 0 \ 7681 ((op & MOVE_TO_POS) != 0 \
7569 && BUFFERP (it->object) \ 7682 && BUFFERP (it->object) \
@@ -7689,6 +7802,11 @@ move_it_in_display_line_to (struct it *it,
7689 if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos)) 7802 if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos))
7690 SET_TEXT_POS (this_line_min_pos, 7803 SET_TEXT_POS (this_line_min_pos,
7691 IT_CHARPOS (*it), IT_BYTEPOS (*it)); 7804 IT_CHARPOS (*it), IT_BYTEPOS (*it));
7805 if (it->bidi_p
7806 && (op & MOVE_TO_POS)
7807 && IT_CHARPOS (*it) > to_charpos
7808 && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it))
7809 SAVE_IT (ppos_it, *it, ppos_data);
7692 continue; 7810 continue;
7693 } 7811 }
7694 7812
@@ -7899,7 +8017,11 @@ move_it_in_display_line_to (struct it *it,
7899 if ((op & MOVE_TO_POS) != 0 8017 if ((op & MOVE_TO_POS) != 0
7900 && !saw_smaller_pos 8018 && !saw_smaller_pos
7901 && IT_CHARPOS (*it) > to_charpos) 8019 && IT_CHARPOS (*it) > to_charpos)
7902 result = MOVE_POS_MATCH_OR_ZV; 8020 {
8021 result = MOVE_POS_MATCH_OR_ZV;
8022 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8023 RESTORE_IT (it, &ppos_it, ppos_data);
8024 }
7903 else 8025 else
7904 result = MOVE_NEWLINE_OR_CR; 8026 result = MOVE_NEWLINE_OR_CR;
7905 break; 8027 break;
@@ -7915,6 +8037,11 @@ move_it_in_display_line_to (struct it *it,
7915 SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it)); 8037 SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it));
7916 if (IT_CHARPOS (*it) < to_charpos) 8038 if (IT_CHARPOS (*it) < to_charpos)
7917 saw_smaller_pos = 1; 8039 saw_smaller_pos = 1;
8040 if (it->bidi_p
8041 && (op & MOVE_TO_POS)
8042 && IT_CHARPOS (*it) >= to_charpos
8043 && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it))
8044 SAVE_IT (ppos_it, *it, ppos_data);
7918 8045
7919 /* Stop if lines are truncated and IT's current x-position is 8046 /* Stop if lines are truncated and IT's current x-position is
7920 past the right edge of the window now. */ 8047 past the right edge of the window now. */
@@ -7924,7 +8051,9 @@ move_it_in_display_line_to (struct it *it,
7924 if (!FRAME_WINDOW_P (it->f) 8051 if (!FRAME_WINDOW_P (it->f)
7925 || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 8052 || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
7926 { 8053 {
7927 if (!get_next_display_element (it) 8054 int at_eob_p = 0;
8055
8056 if ((at_eob_p = !get_next_display_element (it))
7928 || BUFFER_POS_REACHED_P () 8057 || BUFFER_POS_REACHED_P ()
7929 /* If we are past TO_CHARPOS, but never saw any 8058 /* If we are past TO_CHARPOS, but never saw any
7930 character positions smaller than TO_CHARPOS, 8059 character positions smaller than TO_CHARPOS,
@@ -7935,6 +8064,8 @@ move_it_in_display_line_to (struct it *it,
7935 && IT_CHARPOS (*it) > to_charpos)) 8064 && IT_CHARPOS (*it) > to_charpos))
7936 { 8065 {
7937 result = MOVE_POS_MATCH_OR_ZV; 8066 result = MOVE_POS_MATCH_OR_ZV;
8067 if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV)
8068 RESTORE_IT (it, &ppos_it, ppos_data);
7938 break; 8069 break;
7939 } 8070 }
7940 if (ITERATOR_AT_END_OF_LINE_P (it)) 8071 if (ITERATOR_AT_END_OF_LINE_P (it))
@@ -7948,6 +8079,8 @@ move_it_in_display_line_to (struct it *it,
7948 && IT_CHARPOS (*it) > to_charpos) 8079 && IT_CHARPOS (*it) > to_charpos)
7949 { 8080 {
7950 result = MOVE_POS_MATCH_OR_ZV; 8081 result = MOVE_POS_MATCH_OR_ZV;
8082 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8083 RESTORE_IT (it, &ppos_it, ppos_data);
7951 break; 8084 break;
7952 } 8085 }
7953 result = MOVE_LINE_TRUNCATED; 8086 result = MOVE_LINE_TRUNCATED;
@@ -7973,6 +8106,8 @@ move_it_in_display_line_to (struct it *it,
7973 xfree (atx_data); 8106 xfree (atx_data);
7974 if (wrap_data) 8107 if (wrap_data)
7975 xfree (wrap_data); 8108 xfree (wrap_data);
8109 if (ppos_data)
8110 xfree (ppos_data);
7976 8111
7977 /* Restore the iterator settings altered at the beginning of this 8112 /* Restore the iterator settings altered at the beginning of this
7978 function. */ 8113 function. */
@@ -23127,7 +23262,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
23127 base_width = font->average_width; 23262 base_width = font->average_width;
23128 23263
23129 /* Get a face ID for the glyph by utilizing a cache (the same way as 23264 /* Get a face ID for the glyph by utilizing a cache (the same way as
23130 doen for `escape-glyph' in get_next_display_element). */ 23265 done for `escape-glyph' in get_next_display_element). */
23131 if (it->f == last_glyphless_glyph_frame 23266 if (it->f == last_glyphless_glyph_frame
23132 && it->face_id == last_glyphless_glyph_face_id) 23267 && it->face_id == last_glyphless_glyph_face_id)
23133 { 23268 {
@@ -25030,7 +25165,7 @@ rows_from_pos_range (struct window *w,
25030 25165
25031 while (g < e) 25166 while (g < e)
25032 { 25167 {
25033 if (BUFFERP (g->object) 25168 if ((BUFFERP (g->object) || INTEGERP (g->object))
25034 && start_charpos <= g->charpos && g->charpos < end_charpos) 25169 && start_charpos <= g->charpos && g->charpos < end_charpos)
25035 *start = row; 25170 *start = row;
25036 g++; 25171 g++;
@@ -25080,7 +25215,7 @@ rows_from_pos_range (struct window *w,
25080 25215
25081 while (g < e) 25216 while (g < e)
25082 { 25217 {
25083 if (BUFFERP (g->object) 25218 if ((BUFFERP (g->object) || INTEGERP (g->object))
25084 && start_charpos <= g->charpos && g->charpos < end_charpos) 25219 && start_charpos <= g->charpos && g->charpos < end_charpos)
25085 break; 25220 break;
25086 g++; 25221 g++;
diff --git a/src/xfaces.c b/src/xfaces.c
index 996bcdaf6ad..352fdb4b082 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1920,7 +1920,8 @@ check_lface_attrs (Lisp_Object *attrs)
1920 || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX]) 1920 || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX])
1921 || FONTP (attrs[LFACE_FONT_INDEX])); 1921 || FONTP (attrs[LFACE_FONT_INDEX]));
1922 xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX]) 1922 xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
1923 || STRINGP (attrs[LFACE_FONTSET_INDEX])); 1923 || STRINGP (attrs[LFACE_FONTSET_INDEX])
1924 || NILP (attrs[LFACE_FONTSET_INDEX]));
1924#endif 1925#endif
1925} 1926}
1926 1927
diff --git a/src/xfns.c b/src/xfns.c
index 2751544d822..1169acb3cf5 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2942,7 +2942,7 @@ unwind_create_frame (Lisp_Object frame)
2942#if GLYPH_DEBUG 2942#if GLYPH_DEBUG
2943 /* Check that reference counts are indeed correct. */ 2943 /* Check that reference counts are indeed correct. */
2944 xassert (dpyinfo->reference_count == dpyinfo_refcount); 2944 xassert (dpyinfo->reference_count == dpyinfo_refcount);
2945 xassert (dpyinfo->image_cache->refcount == image_cache_refcount); 2945 xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
2946#endif 2946#endif
2947 return Qt; 2947 return Qt;
2948 } 2948 }
diff --git a/src/xml.c b/src/xml.c
index 63041c96b24..55352baae3a 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -71,6 +71,14 @@ make_dom (xmlNode *node)
71 else 71 else
72 return Qnil; 72 return Qnil;
73 } 73 }
74 else if (node->type == XML_COMMENT_NODE)
75 {
76 if (node->content)
77 return list3 (intern ("comment"), Qnil,
78 build_string ((char *) node->content));
79 else
80 return Qnil;
81 }
74 else 82 else
75 return Qnil; 83 return Qnil;
76} 84}
@@ -79,7 +87,6 @@ static Lisp_Object
79parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp) 87parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp)
80{ 88{
81 xmlDoc *doc; 89 xmlDoc *doc;
82 xmlNode *node;
83 Lisp_Object result = Qnil; 90 Lisp_Object result = Qnil;
84 const char *burl = ""; 91 const char *burl = "";
85 EMACS_INT bytes; 92 EMACS_INT bytes;
@@ -117,9 +124,22 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
117 124
118 if (doc != NULL) 125 if (doc != NULL)
119 { 126 {
120 node = xmlDocGetRootElement (doc); 127 xmlNode *n = doc->children->next;
121 if (node != NULL) 128 Lisp_Object r = Qnil;
122 result = make_dom (node); 129
130 while (n) {
131 if (!NILP (r))
132 result = Fcons (r, result);
133 r = make_dom (n);
134 n = n->next;
135 }
136
137 if (NILP (result))
138 result = r;
139 else
140 result = Fcons (intern ("top"),
141 Fcons (Qnil, Fnreverse (Fcons (r, result))));
142
123 xmlFreeDoc (doc); 143 xmlFreeDoc (doc);
124 xmlCleanupParser (); 144 xmlCleanupParser ();
125 } 145 }