diff options
| author | Eli Zaretskii | 2013-05-06 20:11:07 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-05-06 20:11:07 +0300 |
| commit | 05839b6affe3391dc6fb13e704927cb1815a22e9 (patch) | |
| tree | 81e9410f28baf7a54e1c0cda67c70dc3530d37b5 /src | |
| parent | e65500d969b8536773999b2ad4c377889ebb92a2 (diff) | |
| download | emacs-05839b6affe3391dc6fb13e704927cb1815a22e9.tar.gz emacs-05839b6affe3391dc6fb13e704927cb1815a22e9.zip | |
Fix bug #14241 with posn-at-point at the beginning of an image display prop.
src/xdisp.c (pos_visible_p): Use the special code for finding the
beginning of a display property or overlay for any "replacing"
display property, not just for display strings. This solves
incorrect reporting of position by posn-at-point.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/xdisp.c | 35 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b6ae117c8b2..5ac0f885d8e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-05-06 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (pos_visible_p): Use the special code for finding the | ||
| 4 | beginning of a display property or overlay for any "replacing" | ||
| 5 | display property, not just for display strings. This solves | ||
| 6 | incorrect reporting of position by posn-at-point. (Bug#14241) | ||
| 7 | |||
| 1 | 2013-05-06 Paul Eggert <eggert@cs.ucla.edu> | 8 | 2013-05-06 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 9 | ||
| 3 | * unexelf.c: Fix some 32-bit integer problems, notably when debugging. | 10 | * unexelf.c: Fix some 32-bit integer problems, notably when debugging. |
diff --git a/src/xdisp.c b/src/xdisp.c index 6900c35c07c..c7a25873272 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -1392,23 +1392,34 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1392 | Lisp_Object cpos = make_number (charpos); | 1392 | Lisp_Object cpos = make_number (charpos); |
| 1393 | Lisp_Object spec = Fget_char_property (cpos, Qdisplay, Qnil); | 1393 | Lisp_Object spec = Fget_char_property (cpos, Qdisplay, Qnil); |
| 1394 | Lisp_Object string = string_from_display_spec (spec); | 1394 | Lisp_Object string = string_from_display_spec (spec); |
| 1395 | struct text_pos tpos; | ||
| 1396 | int replacing_spec_p; | ||
| 1395 | bool newline_in_string | 1397 | bool newline_in_string |
| 1396 | = (STRINGP (string) | 1398 | = (STRINGP (string) |
| 1397 | && memchr (SDATA (string), '\n', SBYTES (string))); | 1399 | && memchr (SDATA (string), '\n', SBYTES (string))); |
| 1400 | |||
| 1401 | SET_TEXT_POS (tpos, charpos, CHAR_TO_BYTE (charpos)); | ||
| 1402 | replacing_spec_p | ||
| 1403 | = (!NILP (spec) | ||
| 1404 | && handle_display_spec (NULL, spec, Qnil, Qnil, &tpos, | ||
| 1405 | charpos, FRAME_WINDOW_P (it.f))); | ||
| 1398 | /* The tricky code below is needed because there's a | 1406 | /* The tricky code below is needed because there's a |
| 1399 | discrepancy between move_it_to and how we set cursor | 1407 | discrepancy between move_it_to and how we set cursor |
| 1400 | when the display line ends in a newline from a | 1408 | when PT is at the beginning of a portion of text |
| 1401 | display string. move_it_to will stop _after_ such | 1409 | covered by a display property or an overlay with a |
| 1402 | display strings, whereas set_cursor_from_row | 1410 | display property, or the display line ends in a |
| 1403 | conspires with cursor_row_p to place the cursor on | 1411 | newline from a display string. move_it_to will stop |
| 1404 | the first glyph produced from the display string. */ | 1412 | _after_ such display strings, whereas |
| 1413 | set_cursor_from_row conspires with cursor_row_p to | ||
| 1414 | place the cursor on the first glyph produced from the | ||
| 1415 | display string. */ | ||
| 1405 | 1416 | ||
| 1406 | /* We have overshoot PT because it is covered by a | 1417 | /* We have overshoot PT because it is covered by a |
| 1407 | display property whose value is a string. If the | 1418 | display property that replaces the text it covers. |
| 1408 | string includes embedded newlines, we are also in the | 1419 | If the string includes embedded newlines, we are also |
| 1409 | wrong display line. Backtrack to the correct line, | 1420 | in the wrong display line. Backtrack to the correct |
| 1410 | where the display string begins. */ | 1421 | line, where the display property begins. */ |
| 1411 | if (newline_in_string) | 1422 | if (replacing_spec_p) |
| 1412 | { | 1423 | { |
| 1413 | Lisp_Object startpos, endpos; | 1424 | Lisp_Object startpos, endpos; |
| 1414 | EMACS_INT start, end; | 1425 | EMACS_INT start, end; |
| @@ -1434,7 +1445,8 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1434 | rightmost character on a line that is | 1445 | rightmost character on a line that is |
| 1435 | continued or word-wrapped. */ | 1446 | continued or word-wrapped. */ |
| 1436 | if (it3.method == GET_FROM_BUFFER | 1447 | if (it3.method == GET_FROM_BUFFER |
| 1437 | && it3.c == '\n') | 1448 | && (it3.c == '\n' |
| 1449 | || FETCH_BYTE (IT_BYTEPOS (it3)) == '\n')) | ||
| 1438 | move_it_by_lines (&it3, 1); | 1450 | move_it_by_lines (&it3, 1); |
| 1439 | else if (move_it_in_display_line_to (&it3, -1, | 1451 | else if (move_it_in_display_line_to (&it3, -1, |
| 1440 | it3.current_x | 1452 | it3.current_x |
| @@ -1502,6 +1514,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1502 | produced from the string, until we find the | 1514 | produced from the string, until we find the |
| 1503 | rightmost glyph not from the string. */ | 1515 | rightmost glyph not from the string. */ |
| 1504 | if (it3_moved | 1516 | if (it3_moved |
| 1517 | && newline_in_string | ||
| 1505 | && IT_CHARPOS (it3) != charpos && EQ (it3.object, string)) | 1518 | && IT_CHARPOS (it3) != charpos && EQ (it3.object, string)) |
| 1506 | { | 1519 | { |
| 1507 | struct glyph *g = it3.glyph_row->glyphs[TEXT_AREA] | 1520 | struct glyph *g = it3.glyph_row->glyphs[TEXT_AREA] |