diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-07-28 22:31:12 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-07-28 22:31:12 -0700 |
commit | 18ab493650d648ab8dca651ea2698861f926e895 (patch) | |
tree | b16ca478db1e96af8d0be9a20ff1361bea6d12ee /src | |
parent | 726e0ab18e84ce0df6b9dc1612bf4d92b9d1e52a (diff) | |
parent | 43dc9f5b0187276c24e1f63f2a23ba4b81c20e07 (diff) | |
download | emacs-18ab493650d648ab8dca651ea2698861f926e895.tar.gz |
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 170 | ||||
-rw-r--r-- | src/alloc.c | 6 | ||||
-rw-r--r-- | src/buffer.c | 2 | ||||
-rw-r--r-- | src/callproc.c | 2 | ||||
-rw-r--r-- | src/editfns.c | 7 | ||||
-rw-r--r-- | src/frame.c | 8 | ||||
-rw-r--r-- | src/gnutls.c | 3 | ||||
-rw-r--r-- | src/image.c | 12 | ||||
-rw-r--r-- | src/lread.c | 3 | ||||
-rw-r--r-- | src/nsfns.m | 13 | ||||
-rw-r--r-- | src/nsfont.m | 57 | ||||
-rw-r--r-- | src/nsmenu.m | 33 | ||||
-rw-r--r-- | src/nsterm.h | 8 | ||||
-rw-r--r-- | src/nsterm.m | 217 | ||||
-rw-r--r-- | src/print.c | 12 | ||||
-rw-r--r-- | src/regex.c | 34 | ||||
-rw-r--r-- | src/xdisp.c | 195 | ||||
-rw-r--r-- | src/xfaces.c | 3 | ||||
-rw-r--r-- | src/xfns.c | 2 | ||||
-rw-r--r-- | src/xml.c | 28 |
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 @@ (x_term_init): Don't assume length fits in int (sprintf is limited to int size). -2011-07-19 Paul Eggert <eggert@cs.ucla.edu> - Use ptrdiff_t for composition IDs. * character.c (lisp_string_width): * composite.c (composition_table_size, n_compositions) @@ -355,7 +353,78 @@ (gs_load): Use printmax_t to print the widest integers possible. Check for integer overflow when computing image height and width. -2011-07-19 Paul Eggert <eggert@cs.ucla.edu> +2011-07-28 Andreas Schwab <schwab@linux-m68k.org> + + * print.c (print_object): Print empty symbol as ##. + + * lread.c (read1): Read ## as empty symbol. + +2011-07-28 Alp Aker <alp.tekin.aker@gmail.com> + + * nsfns.m (x_set_foreground_color): Set f->foreground_pixel when + setting frame foreground color (Bug#9175). + (x_set_background_color): Likewise. + + * nsmenu.m (-setText): Size tooltip dimensions precisely to + contents (Bug#9176). + (EmacsTooltip -init): Remove bezels and add shadows to + tooltip windows. + + * nsterm.m (ns_dumpglyphs_stretch): Avoid overwriting left fringe + or scroll bar (Bug#8470). + + * nsfont.m (nsfont_open): Remove assignment to voffset and + unnecessary vars hshink, expand, hd, full_height, min_height. + (nsfont_draw): Use s->ybase as baseline for glyph drawing (Bug#8913). + + * nsterm.h (nsfont_info): Remove voffset field. + +2011-07-28 Alp Aker <alp.tekin.aker@gmail.com> + + Implement strike-through and overline on NextStep (Bug#8863). + + * nsfont.m (nsfont_open): Use underline position provided by font, + instead of hard-coded value of 2. + (nsfont_draw): Call ns_draw_text_decoration instead. + + * nsterm.h: Add declaration for ns_draw_text_decoration. + + * nsterm.m (ns_draw_text_decoration): New function for drawing + underline, overline, and strike-through. + (ns_dumpglyphs_image, ns_dumpglyphs_stretch): Add call to + ns_draw_text_decoration. Change treatment of cursor drawing to + accomodate underlining, etc. + +2011-07-28 Eli Zaretskii <eliz@gnu.org> + + * buffer.c (init_buffer_once): Set bidi-display-reordering to t by + default. + +2011-07-28 Paul Eggert <eggert@cs.ucla.edu> + + * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race. + Without this fix, if a signal arrives just after memory fills up, + 'malloc' might be invoked reentrantly. + + * image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1. + In other words, assume that every image size is allowed, on non-X + hosts. This assumption is probably wrong, but it lets Emacs compile. + +2011-07-28 Andreas Schwab <schwab@linux-m68k.org> + + * regex.c (re_iswctype): Convert return values to boolean. + +2011-07-28 Eli Zaretskii <eliz@fencepost.gnu.org> + + * xdisp.c (compute_display_string_pos): Don't use cached display + string position if the buffer had its restriction changed. + (Bug#9184) + +2011-07-28 Paul Eggert <eggert@cs.ucla.edu> + + * callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering. + +2011-07-28 Paul Eggert <eggert@cs.ucla.edu> Integer signedness and overflow and related fixes. (Bug#9079) @@ -554,6 +623,101 @@ Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally well either way, and we prefer signed to unsigned. +2011-07-27 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnutls.c (emacs_gnutls_read): Don't message anything if the peer + closes the connection while we're reading (bug#9182). + +2011-07-25 Jan Djärv <jan.h.d@swipnet.se> + + * nsmenu.m (ns_popup_dialog): Add an "ok" button if no buttons + are specified (Bug#9168). + +2011-07-25 Paul Eggert <eggert@cs.ucla.edu> + + * bidi.c (bidi_dump_cached_states): Fix printf format mismatch. + Found by GCC static checking and --with-wide-int on a 32-bit host. + +2011-07-25 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (compute_display_string_pos): Fix logic of caching + previous display string position. Initialize cached_prev_pos to + -1. Fixes slow-down at the beginning of a buffer. + +2011-07-24 Eli Zaretskii <eliz@gnu.org> + + * xfaces.c (check_lface_attrs) [HAVE_WINDOW_SYSTEM]: Allow `nil' + for attrs[LFACE_FONTSET_INDEX]. + +2011-07-23 Paul Eggert <eggert@cs.ucla.edu> + + * xml.c (parse_region): Remove unused local + that was recently introduced. + +2011-07-23 Eli Zaretskii <eliz@gnu.org> + + * xfns.c (unwind_create_frame) [GLYPH_DEBUG]: Adapt to changes in + 2008-02-22T17:42:09Z!monnier@iro.umontreal.ca. + + * xdisp.c (move_it_in_display_line_to): Record the best matching + position for TO_CHARPOS while scanning the line, and restore it on + exit if none of the characters scanned was an exact match. Fixes + vertical-motion and pos-visible-in-window-p under bidi redisplay + when exact match is impossible due to invisible text, and the + lines are truncated. + +2011-07-23 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (initFrameFromEmacs): Set NSTitledWindowMask in styleMask + for OSX >= 10.7. + +2011-07-22 Eli Zaretskii <eliz@gnu.org> + + Fix a significant slow-down of cursor motion with C-n, C-p, + C-f/C-b, and C-v/M-v that couldn't keep up with keyboard + auto-repeat under bidi redisplay in fontified buffers. + * xdisp.c (compute_stop_pos_backwards): New function. + (next_element_from_buffer): Call compute_stop_pos_backwards to + find a suitable prev_stop when we find ourselves before + base_level_stop. + (reseat): Don't look for prev_stop, as that could mean a very long + run. + <cached_disp_pos, cached_disp_buffer, cached_disp_modiff> + <cached_disp_overlay_modiff>: Cache for last found display string + position. + (compute_display_string_pos): Return the cached position if asked + about the same buffer in the same area of character positions, and + the buffer wasn't changed since the time the display string + position was cached. + +2011-07-22 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (rows_from_pos_range): Don't ignore glyphs whose object + is an integer, which is important for empty lines. (Bug#9149) + +2011-07-22 Chong Yidong <cyd@stupidchicken.com> + + * frame.c (Fmodify_frame_parameters): In tty case, update the + default face if necessary (Bug#4238). + +2011-07-21 Chong Yidong <cyd@stupidchicken.com> + + * editfns.c (Fstring_to_char): No need to explain what a character + is in the docstring (Bug#6576). + +2011-07-20 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c (parse_region): Make sure we always return a tree. + +2011-07-20 HAMANO Kiyoto <khiker.mail@gmail.com> + + * xml.c (parse_region): If a document contains only comments, + return that, too. + +2011-07-20 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c (make_dom): Return comments, too. + 2011-07-19 Paul Eggert <eggert@cs.ucla.edu> 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) int enough_free_memory = 0; if (SPARE_MEMORY < nbytes) { - void *p = malloc (SPARE_MEMORY); + void *p; + + MALLOC_BLOCK_INPUT; + p = malloc (SPARE_MEMORY); if (p) { free (p); enough_free_memory = 1; } + MALLOC_UNBLOCK_INPUT; } 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) BVAR (&buffer_defaults, truncate_lines) = Qnil; BVAR (&buffer_defaults, word_wrap) = Qnil; BVAR (&buffer_defaults, ctl_arrow) = Qt; - BVAR (&buffer_defaults, bidi_display_reordering) = Qnil; + BVAR (&buffer_defaults, bidi_display_reordering) = Qt; BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil; BVAR (&buffer_defaults, cursor_type) = Qt; 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) */) /* vfork, and prevent local vars from being clobbered by the vfork. */ { + int volatile fd1_volatile = fd1; int volatile fd_error_volatile = fd_error; int volatile fd_output_volatile = fd_output; int volatile output_to_buffer_volatile = output_to_buffer; @@ -610,6 +611,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) pid = vfork (); + fd1 = fd1_volatile; fd_error = fd_error_volatile; fd_output = fd_output_volatile; 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, } DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, - doc: /* Return the first character in STRING. -A multibyte character is handled correctly. -The value returned is a Unicode codepoint if it is below #x110000 (in -hex). Codepoints beyond that are Emacs extensions of Unicode. In -particular, eight-bit characters are returned as codepoints in the -range #x3FFF80 through #x3FFFFF, inclusive. */) + doc: /* Return the first character in STRING. */) (register Lisp_Object string) { 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. */) val = values[i]; store_frame_param (f, prop, val); - /* Changing the background color might change the background - mode, so that we have to load new defface specs. - Call frame-set-background-mode to do that. */ - if (EQ (prop, Qbackground_color)) - call1 (Qframe_set_background_mode, frame); + if (EQ (prop, Qforeground_color) + || EQ (prop, Qbackground_color)) + update_face_from_frame_parameter (f, prop, val); } } 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) rtnval = fn_gnutls_record_recv (state, buf, nbyte); if (rtnval >= 0) return rtnval; + else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) + /* The peer closed the connection. */ + return 0; else if (emacs_gnutls_handle_error (state, rtnval) == 0) /* non-fatal error */ 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, static void x_destroy_x_image (XImagePtr); static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int); -/* Return nonzero if XIMG's size WIDTH x HEIGHT doesn't break X. +/* Return nonzero if XIMG's size WIDTH x HEIGHT doesn't break the + windowing system. WIDTH and HEIGHT must both be positive. If XIMG is null, assume it is a bitmap. */ static int x_check_image_size (XImagePtr ximg, int width, int height) { +#ifdef HAVE_X_WINDOWS /* Respect Xlib's limits: it cannot deal with images that have more than INT_MAX (and/or UINT_MAX) bytes. And respect Emacs's limits - of PTRDIFF_MAX (and/or SIZE_MAX) bytes for any object. For now, - assume all windowing systems have the same limits that X does. */ + of PTRDIFF_MAX (and/or SIZE_MAX) bytes for any object. */ enum { XLIB_BYTES_MAX = min (INT_MAX, UINT_MAX), @@ -1940,6 +1941,11 @@ x_check_image_size (XImagePtr ximg, int width, int height) } return (width <= (INT_MAX - (bitmap_pad - 1)) / depth && height <= X_IMAGE_BYTES_MAX / bytes_per_line); +#else + /* FIXME: Implement this check for the HAVE_NS and HAVE_NTGUI cases. + For now, assume that every image size is allowed on these systems. */ + return 1; +#endif } /* 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) } goto read_symbol; } + /* ## is the empty symbol. */ + if (c == '#') + return Fintern (build_string (""), Qnil); /* Reader forms that can reuse previously read objects. */ if (c >= '0' && c <= '9') { 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 x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { NSColor *col; + CGFloat r, g, b, alpha; if (ns_lisp_to_color (arg, &col)) { @@ -332,6 +333,10 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) [f->output_data.ns->foreground_color release]; f->output_data.ns->foreground_color = col; + [col getRed: &r green: &g blue: &b alpha: &alpha]; + FRAME_FOREGROUND_PIXEL (f) = + ARGB_TO_ULONG ((int)(alpha*0xff), (int)(r*0xff), (int)(g*0xff), (int)(b*0xff)); + if (FRAME_NS_VIEW (f)) { 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) struct face *face; NSColor *col; NSView *view = FRAME_NS_VIEW (f); - float alpha; + CGFloat r, g, b, alpha; if (ns_lisp_to_color (arg, &col)) { @@ -364,10 +369,14 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) [col retain]; [f->output_data.ns->background_color release]; f->output_data.ns->background_color = col; + + [col getRed: &r green: &g blue: &b alpha: &alpha]; + FRAME_BACKGROUND_PIXEL (f) = + ARGB_TO_ULONG ((int)(alpha*0xff), (int)(r*0xff), (int)(g*0xff), (int)(b*0xff)); + if (view != nil) { [[view window] setBackgroundColor: col]; - alpha = [col alphaComponent]; if (alpha != 1.0) [[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) font->props[FONT_FILE_INDEX] = Qnil; { - double expand, hshrink; - float full_height, min_height, hd; const char *fontName = [[nsfont fontName] UTF8String]; int len = strlen (fontName); @@ -837,26 +835,16 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) [sfont maximumAdvancement].width : ns_char_width (sfont, '0'); brect = [sfont boundingRectForFont]; - full_height = brect.size.height; - min_height = [sfont ascender] - adjusted_descender; - hd = full_height - min_height; - /* standard height, similar to Carbon. Emacs.app: was 0.5 by default. */ - expand = 0.0; - hshrink = 1.0; - - font_info->underpos = 2; /*[sfont underlinePosition] is often clipped out */ + font_info->underpos = [sfont underlinePosition]; font_info->underwidth = [sfont underlineThickness]; font_info->size = font->pixel_size; - font_info->voffset = lrint (hshrink * [sfont ascender] + expand * hd / 2); /* max bounds */ - font_info->max_bounds.ascent = - lrint (hshrink * [sfont ascender] + expand * hd/2); + font_info->max_bounds.ascent = lrint ([sfont ascender]); /* Descender is usually negative. Use floor to avoid clipping descenders. */ - font_info->max_bounds.descent = - -lrint (floor(hshrink* adjusted_descender - expand*hd/2)); + font_info->max_bounds.descent = -lrint (floor(adjusted_descender)); font_info->height = font_info->max_bounds.ascent + font_info->max_bounds.descent; 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, /* set up for character rendering */ - r.origin.y += font->voffset + (s->height - font->height)/2; + r.origin.y = s->ybase; col = (NS_FACE_FOREGROUND (face) != 0 ? 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, /*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */ } - /* do underline */ - if (face->underline_p) - { - if (face->underline_color != 0) - [ns_lookup_indexed_color (face->underline_color, s->f) set]; - else - [col set]; - DPSmoveto (context, r.origin.x, r.origin.y + font->underpos); - DPSlineto (context, r.origin.x+r.size.width, r.origin.y+font->underpos); - if (face->underline_color != 0) - [col set]; - } - else - [col set]; + [col set]; /* draw with DPSxshow () */ 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, CGContextSetTextDrawingMode (gcontext, kCGTextFill); } - if (face->underline_p) - { - if (face->underline_color != 0) - [ns_lookup_indexed_color (face->underline_color, s->f) set]; - else - [col set]; - CGContextBeginPath (gcontext); - CGContextMoveToPoint (gcontext, - r.origin.x, r.origin.y + font->underpos); - CGContextAddLineToPoint (gcontext, r.origin.x + r.size.width, - r.origin.y + font->underpos); - CGContextStrokePath (gcontext); - if (face->underline_color != 0) - [col set]; - } - else - [col set]; + [col set]; CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); 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, CGContextRestoreGState (gcontext); } #endif /* NS_IMPL_COCOA */ + + /* Draw underline, overline, strike-through. */ + ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x); + return to-from; } 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) [textField setEditable: NO]; [textField setSelectable: NO]; - [textField setBordered: YES]; - [textField setBezeled: YES]; + [textField setBordered: NO]; + [textField setBezeled: NO]; [textField setDrawsBackground: YES]; win = [[NSWindow alloc] @@ -1237,6 +1237,7 @@ update_frame_tool_bar (FRAME_PTR f) styleMask: 0 backing: NSBackingStoreBuffered defer: YES]; + [win setHasShadow: YES]; [win setReleasedWhenClosed: NO]; [win setDelegate: self]; [[win contentView] addSubview: textField]; @@ -1257,17 +1258,15 @@ update_frame_tool_bar (FRAME_PTR f) - (void) setText: (char *)text { NSString *str = [NSString stringWithUTF8String: text]; - NSRect r = [textField frame]; - NSSize textSize = [str sizeWithAttributes: - [NSDictionary dictionaryWithObject: [[textField font] screenFont] - forKey: NSFontAttributeName]]; - NSSize padSize = [[[textField font] screenFont] - boundingRectForFont].size; - - r.size.width = textSize.width + padSize.width/2; - r.size.height = textSize.height + padSize.height/2; - [textField setFrame: r]; + NSRect r = [textField frame]; + NSSize tooltipDims; + [textField setStringValue: str]; + tooltipDims = [[textField cell] cellSize]; + + r.size.width = tooltipDims.width; + r.size.height = tooltipDims.height; + [textField setFrame: r]; } - (void) showAtX: (int)x Y: (int)y for: (int)seconds @@ -1340,7 +1339,7 @@ Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) { id dialog; - Lisp_Object window, tem; + Lisp_Object window, tem, title; struct frame *f; NSPoint p; BOOL isQ; @@ -1389,6 +1388,14 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2; p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; + title = Fcar (contents); + CHECK_STRING (title); + + if (NILP (Fcar (Fcdr (contents)))) + /* No buttons specified, add an "Ok" button so users can pop down + the dialog. */ + contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil)); + BLOCK_INPUT; dialog = [[EmacsDialogPanel alloc] initFromContents: contents 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 #endif char bold, ital; /* convenience flags */ char synthItal; - float voffset; /* mean of ascender/descender offsets */ XCharStruct max_bounds; /* we compute glyph codes and metrics on-demand in blocks of 256 indexed by hibyte, lobyte */ @@ -825,6 +824,13 @@ extern unsigned long ns_get_rgb_color (struct frame *f, float r, float g, float b, float a); extern NSPoint last_mouse_motion_position; +/* From nsterm.m, needed in nsfont.m. */ +#ifdef __OBJC__ +extern void +ns_draw_text_decoration (struct glyph_string *s, struct face *face, + NSColor *defaultCol, CGFloat width, CGFloat x); +#endif + #ifdef NS_IMPL_GNUSTEP extern char gnustep_base_version[]; /* version tracking */ #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); static void ns_judge_scroll_bars (struct frame *f); void x_set_frame_alpha (struct frame *f); -/* FIXME: figure out what to do with underline_minimum_offset. */ - /* ========================================================================== @@ -2604,6 +2602,107 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) return n; } +void +ns_draw_text_decoration (struct glyph_string *s, struct face *face, + NSColor *defaultCol, CGFloat width, CGFloat x) +/* -------------------------------------------------------------------------- + Draw underline, overline, and strike-through on glyph string s. + -------------------------------------------------------------------------- */ +{ + if (s->for_overlaps) + return; + + /* Do underline. */ + if (face->underline_p) + { + NSRect r; + unsigned long thickness, position; + + /* If the prev was underlined, match its appearance. */ + if (s->prev && s->prev->face->underline_p + && s->prev->underline_thickness > 0) + { + thickness = s->prev->underline_thickness; + position = s->prev->underline_position; + } + else + { + struct font *font; + unsigned long descent; + + font=s->font; + descent = s->y + s->height - s->ybase; + + /* Use underline thickness of font, defaulting to 1. */ + thickness = (font && font->underline_thickness > 0) + ? font->underline_thickness : 1; + + /* Determine the offset of underlining from the baseline. */ + if (x_underline_at_descent_line) + position = descent - thickness; + else if (x_use_underline_position_properties + && font && font->underline_position >= 0) + position = font->underline_position; + else if (font) + position = lround (font->descent / 2); + else + position = underline_minimum_offset; + + position = max (position, underline_minimum_offset); + + /* Ensure underlining is not cropped. */ + if (descent <= position) + { + position = descent - 1; + thickness = 1; + } + else if (descent < position + thickness) + thickness = 1; + } + + s->underline_thickness = thickness; + s->underline_position = position; + + r = NSMakeRect (x, s->ybase + position, width, thickness); + + if (face->underline_defaulted_p) + [defaultCol set]; + else + [ns_lookup_indexed_color (face->underline_color, s->f) set]; + NSRectFill (r); + } + + /* Do overline. We follow other terms in using a thickness of 1 + and ignoring overline_margin. */ + if (face->overline_p) + { + NSRect r; + r = NSMakeRect (x, s->y, width, 1); + + if (face->overline_color_defaulted_p) + [defaultCol set]; + else + [ns_lookup_indexed_color (face->overline_color, s->f) set]; + NSRectFill (r); + } + + /* Do strike-through. We follow other terms for thickness and + vertical position.*/ + if (face->strike_through_p) + { + NSRect r; + unsigned long dy; + + dy = lrint ((s->height - 1) / 2); + r = NSMakeRect (x, s->y + dy, width, 1); + + if (face->strike_through_color_defaulted_p) + [defaultCol set]; + else + [ns_lookup_indexed_color (face->strike_through_color, s->f) set]; + NSRectFill (r); + } +} static void ns_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) char raised_p; NSRect br; struct face *face; + NSColor *tdCol; NSTRACE (ns_dumpglyphs_image); @@ -2889,10 +2989,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r) else face = FACE_FROM_ID (s->f, s->first_glyph->face_id); - if (s->hl == DRAW_CURSOR) - [FRAME_CURSOR_COLOR (s->f) set]; - else - [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set]; + [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set]; if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin || 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) [img compositeToPoint: NSMakePoint (x, y + s->slice.height) operation: NSCompositeSourceOver]; + if (s->hl == DRAW_CURSOR) + { + [FRAME_CURSOR_COLOR (s->f) set]; + if (s->w->phys_cursor_type == FILLED_BOX_CURSOR) + tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f); + else + /* Currently on NS img->mask is always 0. Since + get_window_cursor_type specifies a hollow box cursor when on + a non-masked image we never reach this clause. But we put it + in in antipication of better support for image masks on + NS. */ + tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f); + } + else + { + tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f); + } + + /* Draw underline, overline, strike-through. */ + ns_draw_text_decoration (s, face, tdCol, br.size.width, br.origin.x); + /* Draw relief, if requested */ if (s->img->relief || s->hl ==DRAW_IMAGE_RAISED || s->hl ==DRAW_IMAGE_SUNKEN) { @@ -2974,22 +3092,49 @@ ns_dumpglyphs_stretch (struct glyph_string *s) NSRect r[2]; int n, i; struct face *face; + NSColor *fgCol, *bgCol; if (!s->background_filled_p) { n = ns_get_glyph_string_clip_rect (s, r); *r = NSMakeRect (s->x, s->y, s->background_width, s->height); + ns_focus (s->f, r, n); + + if (s->hl == DRAW_MOUSE_FACE) + { + face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + if (!face) + face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } + else + face = FACE_FROM_ID (s->f, s->first_glyph->face_id); + + bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f); + fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f); + for (i=0; i<n; i++) { if (!s->row->full_width_p) { + int overrun, leftoverrun; + /* truncate to avoid overwriting fringe and/or scrollbar */ - int overrun = max (0, (s->x + s->background_width) - - (WINDOW_BOX_RIGHT_EDGE_X (s->w) - - WINDOW_RIGHT_FRINGE_WIDTH (s->w))); + overrun = max (0, (s->x + s->background_width) + - (WINDOW_BOX_RIGHT_EDGE_X (s->w) + - WINDOW_RIGHT_FRINGE_WIDTH (s->w))); r[i].size.width -= overrun; + /* truncate to avoid overwriting to left of the window box */ + leftoverrun = (WINDOW_BOX_LEFT_EDGE_X (s->w) + + WINDOW_LEFT_FRINGE_WIDTH (s->w)) - s->x; + + if (leftoverrun > 0) + { + r[i].origin.x += leftoverrun; + r[i].size.width -= leftoverrun; + } + /* XXX: Try to work between problem where a stretch glyph on a partially-visible bottom row will clear part of the modeline, and another where list-buffers headers and similar @@ -3005,30 +3150,37 @@ ns_dumpglyphs_stretch (struct glyph_string *s) FRAME_PIXEL_WIDTH (s->f)); } + [bgCol set]; + /* NOTE: under NS this is NOT used to draw cursors, but we must avoid overwriting cursor (usually when cursor on a tab) */ if (s->hl == DRAW_CURSOR) { - r[i].origin.x += s->width; - r[i].size.width -= s->width; - } - } + CGFloat x, width; - ns_focus (s->f, r, n); + x = r[i].origin.x; + width = s->w->phys_cursor_width; + r[i].size.width -= width; + r[i].origin.x += width; - if (s->hl == DRAW_MOUSE_FACE) - { - face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); - if (!face) - face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); - } - else - face = FACE_FROM_ID (s->f, s->first_glyph->face_id); + NSRectFill (r[i]); - [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set]; + /* Draw overlining, etc. on the cursor. */ + if (s->w->phys_cursor_type == FILLED_BOX_CURSOR) + ns_draw_text_decoration (s, face, bgCol, width, x); + else + ns_draw_text_decoration (s, face, fgCol, width, x); + } + else + { + NSRectFill (r[i]); + } - NSRectFill (r[0]); - NSRectFill (r[1]); + /* Draw overlining, etc. on the stretch glyph (or the part + of the stretch glyph after the cursor). */ + ns_draw_text_decoration (s, face, fgCol, r[i].size.width, + r[i].origin.x); + } ns_unfocus (s->f); s->background_filled_p = 1; } @@ -5311,6 +5463,9 @@ ns_term_shutdown (int sig) win = [[EmacsWindow alloc] initWithContentRect: r styleMask: (NSResizableWindowMask | +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + NSTitledWindowMask | +#endif NSMiniaturizableWindowMask | NSClosableWindowMask) backing: NSBackingStoreBuffered @@ -6560,23 +6715,17 @@ Only works on OSX 10.6 or later. */); Vx_toolkit_scroll_bars = Qnil; #endif - /* these are unsupported but we need the declarations to avoid whining - messages from cus-start.el */ DEFVAR_BOOL ("x-use-underline-position-properties", x_use_underline_position_properties, - doc: /* NOT SUPPORTED UNDER NS. -*Non-nil means make use of UNDERLINE_POSITION font properties. + doc: /*Non-nil means make use of UNDERLINE_POSITION font properties. A value of nil means ignore them. If you encounter fonts with bogus UNDERLINE_POSITION font properties, for example 7x13 on XFree prior -to 4.1, set this to nil. - -NOTE: Not supported on Mac yet. */); +to 4.1, set this to nil. */); x_use_underline_position_properties = 0; DEFVAR_BOOL ("x-underline-at-descent-line", x_underline_at_descent_line, - doc: /* NOT SUPPORTED UNDER NS. -*Non-nil means to draw the underline at the same place as the descent line. + doc: /* Non-nil means to draw the underline at the same place as the descent line. A value of nil means to draw the underline according to the value of the variable `x-use-underline-position-properties', which is usually at the baseline 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 else confusing = 0; + size_byte = SBYTES (name); + if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj)) { PRINTCHAR ('#'); PRINTCHAR (':'); } - - size_byte = SBYTES (name); + else if (size_byte == 0) + { + PRINTCHAR ('#'); + PRINTCHAR ('#'); + break; + } for (i = 0, i_byte = 0; i_byte < size_byte;) { @@ -1555,7 +1561,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag { if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' || c == '(' || c == ')' - || c == ',' || c =='.' || c == '`' + || c == ',' || c == '.' || c == '`' || c == '[' || c == ']' || c == '?' || c <= 040 || confusing) 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) { switch (cc) { - case RECC_ALNUM: return ISALNUM (ch); - case RECC_ALPHA: return ISALPHA (ch); - case RECC_BLANK: return ISBLANK (ch); - case RECC_CNTRL: return ISCNTRL (ch); - case RECC_DIGIT: return ISDIGIT (ch); - case RECC_GRAPH: return ISGRAPH (ch); - case RECC_LOWER: return ISLOWER (ch); - case RECC_PRINT: return ISPRINT (ch); - case RECC_PUNCT: return ISPUNCT (ch); - case RECC_SPACE: return ISSPACE (ch); - case RECC_UPPER: return ISUPPER (ch); - case RECC_XDIGIT: return ISXDIGIT (ch); - case RECC_ASCII: return IS_REAL_ASCII (ch); - case RECC_NONASCII: return !IS_REAL_ASCII (ch); - case RECC_UNIBYTE: return ISUNIBYTE (ch); - case RECC_MULTIBYTE: return !ISUNIBYTE (ch); - case RECC_WORD: return ISWORD (ch); + case RECC_ALNUM: return ISALNUM (ch) != 0; + case RECC_ALPHA: return ISALPHA (ch) != 0; + case RECC_BLANK: return ISBLANK (ch) != 0; + case RECC_CNTRL: return ISCNTRL (ch) != 0; + case RECC_DIGIT: return ISDIGIT (ch) != 0; + case RECC_GRAPH: return ISGRAPH (ch) != 0; + case RECC_LOWER: return ISLOWER (ch) != 0; + case RECC_PRINT: return ISPRINT (ch) != 0; + case RECC_PUNCT: return ISPUNCT (ch) != 0; + case RECC_SPACE: return ISSPACE (ch) != 0; + case RECC_UPPER: return ISUPPER (ch) != 0; + case RECC_XDIGIT: return ISXDIGIT (ch) != 0; + case RECC_ASCII: return IS_REAL_ASCII (ch) != 0; + case RECC_NONASCII: return !IS_REAL_ASCII (ch) != 0; + case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; + case RECC_MULTIBYTE: return !ISUNIBYTE (ch) != 0; + case RECC_WORD: return ISWORD (ch) != 0; case RECC_ERROR: return false; default: 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) return endpos; } +/* Record one cached display string position found recently by + compute_display_string_pos. */ +static EMACS_INT cached_disp_pos; +static EMACS_INT cached_prev_pos = -1; +static struct buffer *cached_disp_buffer; +static int cached_disp_modiff; +static int cached_disp_overlay_modiff; + /* Return the character position of a display string at or after position specified by POSITION. If no display string exists at or after POSITION, return ZV. A display string is either an overlay @@ -3152,6 +3160,7 @@ compute_display_string_pos (struct text_pos *position, EMACS_INT begb = string_p ? 0 : BEGV; EMACS_INT bufpos, charpos = CHARPOS (*position); struct text_pos tpos; + struct buffer *b; if (charpos >= eob /* We don't support display properties whose values are strings @@ -3161,6 +3170,38 @@ compute_display_string_pos (struct text_pos *position, || (string->s && !STRINGP (object))) return eob; + /* Check the cached values. */ + if (!STRINGP (object)) + { + if (NILP (object)) + b = current_buffer; + else + b = XBUFFER (object); + if (b == cached_disp_buffer + && BUF_MODIFF (b) == cached_disp_modiff + && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff + && !b->clip_changed) + { + if (cached_prev_pos >= 0 + && cached_prev_pos < charpos && charpos <= cached_disp_pos) + return cached_disp_pos; + /* Handle overstepping either end of the known interval. */ + if (charpos > cached_disp_pos) + cached_prev_pos = cached_disp_pos; + else /* charpos <= cached_prev_pos */ + cached_prev_pos = max (charpos - 1, 0); + } + + /* Record new values in the cache. */ + if (b != cached_disp_buffer) + { + cached_disp_buffer = b; + cached_prev_pos = max (charpos - 1, 0); + } + cached_disp_modiff = BUF_MODIFF (b); + cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b); + } + /* If the character at CHARPOS is where the display string begins, return CHARPOS. */ pos = make_number (charpos); @@ -3176,7 +3217,11 @@ compute_display_string_pos (struct text_pos *position, spec)) && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, frame_window_p)) - return charpos; + { + if (!STRINGP (object)) + cached_disp_pos = charpos; + return charpos; + } /* Look forward for the first character with a `display' property that will replace the underlying text when displayed. */ @@ -3196,6 +3241,8 @@ compute_display_string_pos (struct text_pos *position, || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, frame_window_p)); + if (!STRINGP (object)) + cached_disp_pos = CHARPOS (tpos); return CHARPOS (tpos); } @@ -5728,17 +5775,19 @@ reseat (struct it *it, struct text_pos pos, int force_p) { /* For bidi iteration, we need to prime prev_stop and base_level_stop with our best estimations. */ - if (CHARPOS (pos) < it->prev_stop) - { - handle_stop_backwards (it, BEGV); - if (CHARPOS (pos) < it->base_level_stop) - it->base_level_stop = 0; - } - else if (CHARPOS (pos) > it->stop_charpos - && it->stop_charpos >= BEGV) - handle_stop_backwards (it, it->stop_charpos); - else /* force_p */ - handle_stop (it); + /* Implementation note: Of course, POS is not necessarily a + stop position, so assigning prev_pos to it is a lie; we + should have called compute_stop_backwards. However, if + the current buffer does not include any R2L characters, + that call would be a waste of cycles, because the + iterator will never move back, and thus never cross this + "fake" stop position. So we delay that backward search + until the time we really need it, in next_element_from_buffer. */ + if (CHARPOS (pos) != it->prev_stop) + it->prev_stop = CHARPOS (pos); + if (CHARPOS (pos) < it->base_level_stop) + it->base_level_stop = 0; /* meaning it's unknown */ + handle_stop (it); } else { @@ -7005,10 +7054,10 @@ next_element_from_string (struct it *it) embedding level, so test for that explicitly. */ && !BIDI_AT_BASE_LEVEL (it->bidi_it)) { - /* If we lost track of base_level_stop, we have no better place - for handle_stop_backwards to start from than BEGV. This - happens, e.g., when we were reseated to the previous - screenful of text by vertical-motion. */ + /* If we lost track of base_level_stop, we have no better + place for handle_stop_backwards to start from than string + beginning. This happens, e.g., when we were reseated to + the previous screenful of text by vertical-motion. */ if (it->base_level_stop <= 0 || IT_STRING_CHARPOS (*it) < it->base_level_stop) it->base_level_stop = 0; @@ -7196,6 +7245,50 @@ next_element_from_stretch (struct it *it) return 1; } +/* Scan backwards from IT's current position until we find a stop + position, or until BEGV. This is called when we find ourself + before both the last known prev_stop and base_level_stop while + reordering bidirectional text. */ + +static void +compute_stop_pos_backwards (struct it *it) +{ + const int SCAN_BACK_LIMIT = 1000; + struct text_pos pos; + struct display_pos save_current = it->current; + struct text_pos save_position = it->position; + EMACS_INT charpos = IT_CHARPOS (*it); + EMACS_INT where_we_are = charpos; + EMACS_INT save_stop_pos = it->stop_charpos; + EMACS_INT save_end_pos = it->end_charpos; + + xassert (NILP (it->string) && !it->s); + xassert (it->bidi_p); + it->bidi_p = 0; + do + { + it->end_charpos = min (charpos + 1, ZV); + charpos = max (charpos - SCAN_BACK_LIMIT, BEGV); + SET_TEXT_POS (pos, charpos, BYTE_TO_CHAR (charpos)); + reseat_1 (it, pos, 0); + compute_stop_pos (it); + /* We must advance forward, right? */ + if (it->stop_charpos <= charpos) + abort (); + } + while (charpos > BEGV && it->stop_charpos >= it->end_charpos); + + if (it->stop_charpos <= where_we_are) + it->prev_stop = it->stop_charpos; + else + it->prev_stop = BEGV; + it->bidi_p = 1; + it->current = save_current; + it->position = save_position; + it->stop_charpos = save_stop_pos; + it->end_charpos = save_end_pos; +} + /* Scan forward from CHARPOS in the current buffer/string, until we find a stop position > current IT's position. Then handle the stop 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) EMACS_INT next_stop; /* Scan in strict logical order. */ + xassert (it->bidi_p); it->bidi_p = 0; do { @@ -7234,11 +7328,11 @@ handle_stop_backwards (struct it *it, EMACS_INT charpos) } while (charpos <= where_we_are); - next_stop = it->stop_charpos; - it->stop_charpos = it->prev_stop; it->bidi_p = 1; it->current = save_current; it->position = save_position; + next_stop = it->stop_charpos; + it->stop_charpos = it->prev_stop; handle_stop (it); it->stop_charpos = next_stop; } @@ -7335,14 +7429,19 @@ next_element_from_buffer (struct it *it) embedding level, so test for that explicitly. */ && !BIDI_AT_BASE_LEVEL (it->bidi_it)) { - /* If we lost track of base_level_stop, we have no better place - for handle_stop_backwards to start from than BEGV. This - happens, e.g., when we were reseated to the previous - screenful of text by vertical-motion. */ if (it->base_level_stop <= 0 || IT_CHARPOS (*it) < it->base_level_stop) - it->base_level_stop = BEGV; - handle_stop_backwards (it, it->base_level_stop); + { + /* If we lost track of base_level_stop, we need to find + prev_stop by looking backwards. This happens, e.g., when + we were reseated to the previous screenful of text by + vertical-motion. */ + it->base_level_stop = BEGV; + compute_stop_pos_backwards (it); + handle_stop_backwards (it, it->prev_stop); + } + else + handle_stop_backwards (it, it->base_level_stop); return GET_NEXT_DISPLAY_ELEMENT (it); } else @@ -7544,8 +7643,9 @@ move_it_in_display_line_to (struct it *it, { enum move_it_result result = MOVE_UNDEFINED; struct glyph_row *saved_glyph_row; - struct it wrap_it, atpos_it, atx_it; + struct it wrap_it, atpos_it, atx_it, ppos_it; void *wrap_data = NULL, *atpos_data = NULL, *atx_data = NULL; + void *ppos_data = NULL; int may_wrap = 0; enum it_method prev_method = it->method; EMACS_INT prev_pos = IT_CHARPOS (*it); @@ -7564,6 +7664,19 @@ move_it_in_display_line_to (struct it *it, atpos_it.sp = -1; atx_it.sp = -1; + /* Use ppos_it under bidi reordering to save a copy of IT for the + position > CHARPOS that is the closest to CHARPOS. We restore + that position in IT when we have scanned the entire display line + without finding a match for CHARPOS and all the character + positions are greater than CHARPOS. */ + if (it->bidi_p) + { + SAVE_IT (ppos_it, *it, ppos_data); + SET_TEXT_POS (ppos_it.current.pos, ZV, ZV_BYTE); + if ((op & MOVE_TO_POS) && IT_CHARPOS (*it) >= to_charpos) + SAVE_IT (ppos_it, *it, ppos_data); + } + #define BUFFER_POS_REACHED_P() \ ((op & MOVE_TO_POS) != 0 \ && BUFFERP (it->object) \ @@ -7689,6 +7802,11 @@ move_it_in_display_line_to (struct it *it, if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos)) SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it)); + if (it->bidi_p + && (op & MOVE_TO_POS) + && IT_CHARPOS (*it) > to_charpos + && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it)) + SAVE_IT (ppos_it, *it, ppos_data); continue; } @@ -7899,7 +8017,11 @@ move_it_in_display_line_to (struct it *it, if ((op & MOVE_TO_POS) != 0 && !saw_smaller_pos && IT_CHARPOS (*it) > to_charpos) - result = MOVE_POS_MATCH_OR_ZV; + { + result = MOVE_POS_MATCH_OR_ZV; + if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV) + RESTORE_IT (it, &ppos_it, ppos_data); + } else result = MOVE_NEWLINE_OR_CR; break; @@ -7915,6 +8037,11 @@ move_it_in_display_line_to (struct it *it, SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it)); if (IT_CHARPOS (*it) < to_charpos) saw_smaller_pos = 1; + if (it->bidi_p + && (op & MOVE_TO_POS) + && IT_CHARPOS (*it) >= to_charpos + && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it)) + SAVE_IT (ppos_it, *it, ppos_data); /* Stop if lines are truncated and IT's current x-position is past the right edge of the window now. */ @@ -7924,7 +8051,9 @@ move_it_in_display_line_to (struct it *it, if (!FRAME_WINDOW_P (it->f) || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) { - if (!get_next_display_element (it) + int at_eob_p = 0; + + if ((at_eob_p = !get_next_display_element (it)) || BUFFER_POS_REACHED_P () /* If we are past TO_CHARPOS, but never saw any character positions smaller than TO_CHARPOS, @@ -7935,6 +8064,8 @@ move_it_in_display_line_to (struct it *it, && IT_CHARPOS (*it) > to_charpos)) { result = MOVE_POS_MATCH_OR_ZV; + if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV) + RESTORE_IT (it, &ppos_it, ppos_data); break; } if (ITERATOR_AT_END_OF_LINE_P (it)) @@ -7948,6 +8079,8 @@ move_it_in_display_line_to (struct it *it, && IT_CHARPOS (*it) > to_charpos) { result = MOVE_POS_MATCH_OR_ZV; + if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV) + RESTORE_IT (it, &ppos_it, ppos_data); break; } result = MOVE_LINE_TRUNCATED; @@ -7973,6 +8106,8 @@ move_it_in_display_line_to (struct it *it, xfree (atx_data); if (wrap_data) xfree (wrap_data); + if (ppos_data) + xfree (ppos_data); /* Restore the iterator settings altered at the beginning of this function. */ @@ -23127,7 +23262,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) base_width = font->average_width; /* Get a face ID for the glyph by utilizing a cache (the same way as - doen for `escape-glyph' in get_next_display_element). */ + done for `escape-glyph' in get_next_display_element). */ if (it->f == last_glyphless_glyph_frame && it->face_id == last_glyphless_glyph_face_id) { @@ -25030,7 +25165,7 @@ rows_from_pos_range (struct window *w, while (g < e) { - if (BUFFERP (g->object) + if ((BUFFERP (g->object) || INTEGERP (g->object)) && start_charpos <= g->charpos && g->charpos < end_charpos) *start = row; g++; @@ -25080,7 +25215,7 @@ rows_from_pos_range (struct window *w, while (g < e) { - if (BUFFERP (g->object) + if ((BUFFERP (g->object) || INTEGERP (g->object)) && start_charpos <= g->charpos && g->charpos < end_charpos) break; 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) || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX]) || FONTP (attrs[LFACE_FONT_INDEX])); xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX]) - || STRINGP (attrs[LFACE_FONTSET_INDEX])); + || STRINGP (attrs[LFACE_FONTSET_INDEX]) + || NILP (attrs[LFACE_FONTSET_INDEX])); #endif } 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) #if GLYPH_DEBUG /* Check that reference counts are indeed correct. */ xassert (dpyinfo->reference_count == dpyinfo_refcount); - xassert (dpyinfo->image_cache->refcount == image_cache_refcount); + xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount); #endif return Qt; } 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) else return Qnil; } + else if (node->type == XML_COMMENT_NODE) + { + if (node->content) + return list3 (intern ("comment"), Qnil, + build_string ((char *) node->content)); + else + return Qnil; + } else return Qnil; } @@ -79,7 +87,6 @@ static Lisp_Object parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp) { xmlDoc *doc; - xmlNode *node; Lisp_Object result = Qnil; const char *burl = ""; EMACS_INT bytes; @@ -117,9 +124,22 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html if (doc != NULL) { - node = xmlDocGetRootElement (doc); - if (node != NULL) - result = make_dom (node); + xmlNode *n = doc->children->next; + Lisp_Object r = Qnil; + + while (n) { + if (!NILP (r)) + result = Fcons (r, result); + r = make_dom (n); + n = n->next; + } + + if (NILP (result)) + result = r; + else + result = Fcons (intern ("top"), + Fcons (Qnil, Fnreverse (Fcons (r, result)))); + xmlFreeDoc (doc); xmlCleanupParser (); } |