summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-05-06 20:11:07 +0300
committerEli Zaretskii <eliz@gnu.org>2013-05-06 20:11:07 +0300
commit05839b6affe3391dc6fb13e704927cb1815a22e9 (patch)
tree81e9410f28baf7a54e1c0cda67c70dc3530d37b5
parente65500d969b8536773999b2ad4c377889ebb92a2 (diff)
downloademacs-05839b6affe3391dc6fb13e704927cb1815a22e9.tar.gz
emacs-05839b6affe3391dc6fb13e704927cb1815a22e9.tar.bz2
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.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/xdisp.c35
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 @@
+2013-05-06 Eli Zaretskii <eliz@gnu.org>
+
+ * 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. (Bug#14241)
+
2013-05-06 Paul Eggert <eggert@cs.ucla.edu>
* 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,
Lisp_Object cpos = make_number (charpos);
Lisp_Object spec = Fget_char_property (cpos, Qdisplay, Qnil);
Lisp_Object string = string_from_display_spec (spec);
+ struct text_pos tpos;
+ int replacing_spec_p;
bool newline_in_string
= (STRINGP (string)
&& memchr (SDATA (string), '\n', SBYTES (string)));
+
+ SET_TEXT_POS (tpos, charpos, CHAR_TO_BYTE (charpos));
+ replacing_spec_p
+ = (!NILP (spec)
+ && handle_display_spec (NULL, spec, Qnil, Qnil, &tpos,
+ charpos, FRAME_WINDOW_P (it.f)));
/* The tricky code below is needed because there's a
discrepancy between move_it_to and how we set cursor
- when the display line ends in a newline from a
- display string. move_it_to will stop _after_ such
- display strings, whereas set_cursor_from_row
- conspires with cursor_row_p to place the cursor on
- the first glyph produced from the display string. */
+ when PT is at the beginning of a portion of text
+ covered by a display property or an overlay with a
+ display property, or the display line ends in a
+ newline from a display string. move_it_to will stop
+ _after_ such display strings, whereas
+ set_cursor_from_row conspires with cursor_row_p to
+ place the cursor on the first glyph produced from the
+ display string. */
/* We have overshoot PT because it is covered by a
- display property whose value is a string. If the
- string includes embedded newlines, we are also in the
- wrong display line. Backtrack to the correct line,
- where the display string begins. */
- if (newline_in_string)
+ display property that replaces the text it covers.
+ If the string includes embedded newlines, we are also
+ in the wrong display line. Backtrack to the correct
+ line, where the display property begins. */
+ if (replacing_spec_p)
{
Lisp_Object startpos, endpos;
EMACS_INT start, end;
@@ -1434,7 +1445,8 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
rightmost character on a line that is
continued or word-wrapped. */
if (it3.method == GET_FROM_BUFFER
- && it3.c == '\n')
+ && (it3.c == '\n'
+ || FETCH_BYTE (IT_BYTEPOS (it3)) == '\n'))
move_it_by_lines (&it3, 1);
else if (move_it_in_display_line_to (&it3, -1,
it3.current_x
@@ -1502,6 +1514,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
produced from the string, until we find the
rightmost glyph not from the string. */
if (it3_moved
+ && newline_in_string
&& IT_CHARPOS (it3) != charpos && EQ (it3.object, string))
{
struct glyph *g = it3.glyph_row->glyphs[TEXT_AREA]