diff options
| author | Eli Zaretskii | 2011-05-28 20:23:44 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-05-28 20:23:44 +0300 |
| commit | 0e14fe90d816f77788f1985ce853b473b9416d3b (patch) | |
| tree | 4f8c37497a507dbc356b0605d75cfaab29d5cb78 /src | |
| parent | c40e2fb22c6f1e21b63209574b75daaee853123f (diff) | |
| download | emacs-0e14fe90d816f77788f1985ce853b473b9416d3b.tar.gz emacs-0e14fe90d816f77788f1985ce853b473b9416d3b.zip | |
Fix cursor motion across display strings covering reordered text.
src/xdisp.c (set_cursor_from_row): Set start and stop points
according to the row's direction when priming the loop that looks
for the glyph on which to display cursor.
(single_display_spec_intangible_p): Function deleted.
(display_prop_intangible_p): Reimplement to call
handle_display_spec instead of single_display_spec_intangible_p.
Accept 3 additional arguments needed by handle_display_spec. This
fixes incorrect cursor motion across display property with complex
values: lists, `(when COND...)' forms, etc.
(single_display_spec_string_p): Support property values that are
lists with the argument STRING its top-level element.
(display_prop_string_p): Fix the condition for processing a
property that is a list to be consistent with handle_display_spec.
src/keyboard.c (adjust_point_for_property): Adjust the call to
display_prop_intangible_p to its new signature.
src/dispextern.h (display_prop_intangible_p): Adjust prototype.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 21 | ||||
| -rw-r--r-- | src/dispextern.h | 2 | ||||
| -rw-r--r-- | src/keyboard.c | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 95 |
4 files changed, 43 insertions, 77 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b651856f276..12c0bde290b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,8 +1,23 @@ | |||
| 1 | 2011-05-28 Eli Zaretskii <eliz@gnu.org> | 1 | 2011-05-28 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * xdisp.c (set_cursor_from_row): Set start and stop points of the | 3 | * xdisp.c (set_cursor_from_row): Set start and stop points |
| 4 | loop that looks for the glyph on which to display cursor according | 4 | according to the row's direction when priming the loop that looks |
| 5 | to the row's direction. | 5 | for the glyph on which to display cursor. |
| 6 | (single_display_spec_intangible_p): Function deleted. | ||
| 7 | (display_prop_intangible_p): Reimplement to call | ||
| 8 | handle_display_spec instead of single_display_spec_intangible_p. | ||
| 9 | Accept 3 additional arguments needed by handle_display_spec. This | ||
| 10 | fixes incorrect cursor motion across display property with complex | ||
| 11 | values: lists, `(when COND...)' forms, etc. | ||
| 12 | (single_display_spec_string_p): Support property values that are | ||
| 13 | lists with the argument STRING its top-level element. | ||
| 14 | (display_prop_string_p): Fix the condition for processing a | ||
| 15 | property that is a list to be consistent with handle_display_spec. | ||
| 16 | |||
| 17 | * keyboard.c (adjust_point_for_property): Adjust the call to | ||
| 18 | display_prop_intangible_p to its new signature. | ||
| 19 | |||
| 20 | * dispextern.h (display_prop_intangible_p): Adjust prototype. | ||
| 6 | 21 | ||
| 7 | 2011-05-21 Eli Zaretskii <eliz@gnu.org> | 22 | 2011-05-21 Eli Zaretskii <eliz@gnu.org> |
| 8 | 23 | ||
diff --git a/src/dispextern.h b/src/dispextern.h index 6c09f21a78f..7138c2225e8 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2957,7 +2957,7 @@ struct glyph_row *row_containing_pos (struct window *, EMACS_INT, | |||
| 2957 | struct glyph_row *, | 2957 | struct glyph_row *, |
| 2958 | struct glyph_row *, int); | 2958 | struct glyph_row *, int); |
| 2959 | int line_bottom_y (struct it *); | 2959 | int line_bottom_y (struct it *); |
| 2960 | int display_prop_intangible_p (Lisp_Object); | 2960 | int display_prop_intangible_p (Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT); |
| 2961 | void resize_echo_area_exactly (void); | 2961 | void resize_echo_area_exactly (void); |
| 2962 | int resize_mini_window (struct window *, int); | 2962 | int resize_mini_window (struct window *, int); |
| 2963 | #if defined USE_TOOLKIT_SCROLL_BARS && !defined USE_GTK | 2963 | #if defined USE_TOOLKIT_SCROLL_BARS && !defined USE_GTK |
diff --git a/src/keyboard.c b/src/keyboard.c index a94456fce2e..ad4fd079049 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1729,7 +1729,7 @@ adjust_point_for_property (EMACS_INT last_pt, int modified) | |||
| 1729 | && PT > BEGV && PT < ZV | 1729 | && PT > BEGV && PT < ZV |
| 1730 | && !NILP (val = get_char_property_and_overlay | 1730 | && !NILP (val = get_char_property_and_overlay |
| 1731 | (make_number (PT), Qdisplay, Qnil, &overlay)) | 1731 | (make_number (PT), Qdisplay, Qnil, &overlay)) |
| 1732 | && display_prop_intangible_p (val) | 1732 | && display_prop_intangible_p (val, overlay, PT, PT_BYTE) |
| 1733 | && (!OVERLAYP (overlay) | 1733 | && (!OVERLAYP (overlay) |
| 1734 | ? get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil) | 1734 | ? get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil) |
| 1735 | : (beg = OVERLAY_POSITION (OVERLAY_START (overlay)), | 1735 | : (beg = OVERLAY_POSITION (OVERLAY_START (overlay)), |
diff --git a/src/xdisp.c b/src/xdisp.c index 9d5ec9f1f60..714c18be466 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -4375,83 +4375,31 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4375 | return 0; | 4375 | return 0; |
| 4376 | } | 4376 | } |
| 4377 | 4377 | ||
| 4378 | |||
| 4379 | /* Check if SPEC is a display sub-property value whose text should be | ||
| 4380 | treated as intangible. */ | ||
| 4381 | |||
| 4382 | static int | ||
| 4383 | single_display_spec_intangible_p (Lisp_Object prop) | ||
| 4384 | { | ||
| 4385 | /* Skip over `when FORM'. */ | ||
| 4386 | if (CONSP (prop) && EQ (XCAR (prop), Qwhen)) | ||
| 4387 | { | ||
| 4388 | prop = XCDR (prop); | ||
| 4389 | if (!CONSP (prop)) | ||
| 4390 | return 0; | ||
| 4391 | prop = XCDR (prop); | ||
| 4392 | } | ||
| 4393 | |||
| 4394 | if (STRINGP (prop)) | ||
| 4395 | return 1; | ||
| 4396 | |||
| 4397 | if (!CONSP (prop)) | ||
| 4398 | return 0; | ||
| 4399 | |||
| 4400 | /* Skip over `margin LOCATION'. If LOCATION is in the margins, | ||
| 4401 | we don't need to treat text as intangible. */ | ||
| 4402 | if (EQ (XCAR (prop), Qmargin)) | ||
| 4403 | { | ||
| 4404 | prop = XCDR (prop); | ||
| 4405 | if (!CONSP (prop)) | ||
| 4406 | return 0; | ||
| 4407 | |||
| 4408 | prop = XCDR (prop); | ||
| 4409 | if (!CONSP (prop) | ||
| 4410 | || EQ (XCAR (prop), Qleft_margin) | ||
| 4411 | || EQ (XCAR (prop), Qright_margin)) | ||
| 4412 | return 0; | ||
| 4413 | } | ||
| 4414 | |||
| 4415 | return (CONSP (prop) | ||
| 4416 | && (EQ (XCAR (prop), Qimage) | ||
| 4417 | || EQ (XCAR (prop), Qspace))); | ||
| 4418 | } | ||
| 4419 | |||
| 4420 | |||
| 4421 | /* Check if PROP is a display property value whose text should be | 4378 | /* Check if PROP is a display property value whose text should be |
| 4422 | treated as intangible. */ | 4379 | treated as intangible. OVERLAY is the overlay from which PROP |
| 4380 | came, or nil if it came from a text property. CHARPOS and BYTEPOS | ||
| 4381 | specify the buffer position covered by PROP. */ | ||
| 4423 | 4382 | ||
| 4424 | int | 4383 | int |
| 4425 | display_prop_intangible_p (Lisp_Object prop) | 4384 | display_prop_intangible_p (Lisp_Object prop, Lisp_Object overlay, |
| 4385 | EMACS_INT charpos, EMACS_INT bytepos) | ||
| 4426 | { | 4386 | { |
| 4427 | if (CONSP (prop) | 4387 | int frame_window_p = FRAME_WINDOW_P (XFRAME (selected_frame)); |
| 4428 | && CONSP (XCAR (prop)) | 4388 | struct text_pos position; |
| 4429 | && !EQ (Qmargin, XCAR (XCAR (prop)))) | ||
| 4430 | { | ||
| 4431 | /* A list of sub-properties. */ | ||
| 4432 | while (CONSP (prop)) | ||
| 4433 | { | ||
| 4434 | if (single_display_spec_intangible_p (XCAR (prop))) | ||
| 4435 | return 1; | ||
| 4436 | prop = XCDR (prop); | ||
| 4437 | } | ||
| 4438 | } | ||
| 4439 | else if (VECTORP (prop)) | ||
| 4440 | { | ||
| 4441 | /* A vector of sub-properties. */ | ||
| 4442 | int i; | ||
| 4443 | for (i = 0; i < ASIZE (prop); ++i) | ||
| 4444 | if (single_display_spec_intangible_p (AREF (prop, i))) | ||
| 4445 | return 1; | ||
| 4446 | } | ||
| 4447 | else | ||
| 4448 | return single_display_spec_intangible_p (prop); | ||
| 4449 | 4389 | ||
| 4450 | return 0; | 4390 | SET_TEXT_POS (position, charpos, bytepos); |
| 4391 | return handle_display_spec (NULL, prop, Qnil, overlay, | ||
| 4392 | &position, charpos, frame_window_p); | ||
| 4451 | } | 4393 | } |
| 4452 | 4394 | ||
| 4453 | 4395 | ||
| 4454 | /* Return 1 if PROP is a display sub-property value containing STRING. */ | 4396 | /* Return 1 if PROP is a display sub-property value containing STRING. |
| 4397 | |||
| 4398 | Implementation note: this and the following function are really | ||
| 4399 | special cases of handle_display_spec and | ||
| 4400 | handle_single_display_spec, and should ideally use the same code. | ||
| 4401 | Until they do, these two pairs must be consistent and must be | ||
| 4402 | modified in sync. */ | ||
| 4455 | 4403 | ||
| 4456 | static int | 4404 | static int |
| 4457 | single_display_spec_string_p (Lisp_Object prop, Lisp_Object string) | 4405 | single_display_spec_string_p (Lisp_Object prop, Lisp_Object string) |
| @@ -4465,6 +4413,9 @@ single_display_spec_string_p (Lisp_Object prop, Lisp_Object string) | |||
| 4465 | prop = XCDR (prop); | 4413 | prop = XCDR (prop); |
| 4466 | if (!CONSP (prop)) | 4414 | if (!CONSP (prop)) |
| 4467 | return 0; | 4415 | return 0; |
| 4416 | /* FIXME: We should eval the condition following `when', like | ||
| 4417 | handle_single_display_spec does, and retrun zero if it | ||
| 4418 | evaluates to nil. */ | ||
| 4468 | prop = XCDR (prop); | 4419 | prop = XCDR (prop); |
| 4469 | } | 4420 | } |
| 4470 | 4421 | ||
| @@ -4481,7 +4432,7 @@ single_display_spec_string_p (Lisp_Object prop, Lisp_Object string) | |||
| 4481 | return 0; | 4432 | return 0; |
| 4482 | } | 4433 | } |
| 4483 | 4434 | ||
| 4484 | return CONSP (prop) && EQ (XCAR (prop), string); | 4435 | return EQ (prop, string) || (CONSP (prop) && EQ (XCAR (prop), string)); |
| 4485 | } | 4436 | } |
| 4486 | 4437 | ||
| 4487 | 4438 | ||
| @@ -4491,8 +4442,8 @@ static int | |||
| 4491 | display_prop_string_p (Lisp_Object prop, Lisp_Object string) | 4442 | display_prop_string_p (Lisp_Object prop, Lisp_Object string) |
| 4492 | { | 4443 | { |
| 4493 | if (CONSP (prop) | 4444 | if (CONSP (prop) |
| 4494 | && CONSP (XCAR (prop)) | 4445 | && !EQ (XCAR (prop), Qwhen) |
| 4495 | && !EQ (Qmargin, XCAR (XCAR (prop)))) | 4446 | && !(CONSP (XCAR (prop)) && EQ (Qmargin, XCAR (XCAR (prop))))) |
| 4496 | { | 4447 | { |
| 4497 | /* A list of sub-properties. */ | 4448 | /* A list of sub-properties. */ |
| 4498 | while (CONSP (prop)) | 4449 | while (CONSP (prop)) |