Mercurial > emacs
comparison src/indent.c @ 73140:c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
being displayed contains newlines.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Tue, 26 Sep 2006 19:25:35 +0000 |
parents | 0e86882b32a9 |
children | 4cb12ab18c21 2d56e13fd23d bb0e318b7c53 |
comparison
equal
deleted
inserted
replaced
73139:1ae580684ad1 | 73140:c85ee72ad64b |
---|---|
2072 } | 2072 } |
2073 else | 2073 else |
2074 { | 2074 { |
2075 int it_start; | 2075 int it_start; |
2076 int oselective; | 2076 int oselective; |
2077 int start_on_image_or_stretch_or_string_p; | 2077 int it_overshoot_expected_p; |
2078 | 2078 |
2079 SET_TEXT_POS (pt, PT, PT_BYTE); | 2079 SET_TEXT_POS (pt, PT, PT_BYTE); |
2080 start_display (&it, w, pt); | 2080 start_display (&it, w, pt); |
2081 | 2081 |
2082 /* Scan from the start of the line containing PT. If we don't | 2082 /* Scan from the start of the line containing PT. If we don't |
2084 really at some x > 0. The effect is, in continuation lines, that | 2084 really at some x > 0. The effect is, in continuation lines, that |
2085 we end up with the iterator placed at where it thinks X is 0, | 2085 we end up with the iterator placed at where it thinks X is 0, |
2086 while the end position is really at some X > 0, the same X that | 2086 while the end position is really at some X > 0, the same X that |
2087 PT had. */ | 2087 PT had. */ |
2088 it_start = IT_CHARPOS (it); | 2088 it_start = IT_CHARPOS (it); |
2089 start_on_image_or_stretch_or_string_p = (it.method == GET_FROM_IMAGE | 2089 |
2090 || it.method == GET_FROM_STRETCH | 2090 /* We expect the call to move_it_to, further down, to overshoot |
2091 || it.method == GET_FROM_STRING); | 2091 if the starting point is on an image, stretch glyph, or Lisp |
2092 string. We won't need to backtrack in this situation, except | |
2093 for one corner case: when the Lisp string contains a | |
2094 newline. */ | |
2095 if (it.method == GET_FROM_STRING) | |
2096 { | |
2097 const char *s = SDATA (it.string); | |
2098 const char *e = s + SBYTES (it.string); | |
2099 | |
2100 while (s < e && *s != '\n') | |
2101 ++s; | |
2102 | |
2103 it_overshoot_expected_p = (s == e); | |
2104 } | |
2105 else | |
2106 it_overshoot_expected_p = (it.method == GET_FROM_IMAGE | |
2107 || it.method == GET_FROM_STRETCH); | |
2108 | |
2092 reseat_at_previous_visible_line_start (&it); | 2109 reseat_at_previous_visible_line_start (&it); |
2093 it.current_x = it.hpos = 0; | 2110 it.current_x = it.hpos = 0; |
2094 /* Temporarily disable selective display so we don't move too far */ | 2111 /* Temporarily disable selective display so we don't move too far */ |
2095 oselective = it.selective; | 2112 oselective = it.selective; |
2096 it.selective = 0; | 2113 it.selective = 0; |
2097 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); | 2114 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); |
2098 it.selective = oselective; | 2115 it.selective = oselective; |
2099 | 2116 |
2100 /* Move back if we got too far. This may happen if | 2117 /* Move back if we got too far. This may happen if |
2101 truncate-lines is on and PT is beyond right margin. | 2118 truncate-lines is on and PT is beyond right margin. |
2102 It may also happen if it_start is on an image, stretch | 2119 Don't go back if the overshoot is expected (see above). */ |
2103 glyph, or string -- in that case, don't go back. */ | |
2104 if (IT_CHARPOS (it) > it_start && XINT (lines) > 0 | 2120 if (IT_CHARPOS (it) > it_start && XINT (lines) > 0 |
2105 && !start_on_image_or_stretch_or_string_p) | 2121 && !it_overshoot_expected_p) |
2106 move_it_by_lines (&it, -1, 0); | 2122 move_it_by_lines (&it, -1, 0); |
2107 | 2123 |
2108 it.vpos = 0; | 2124 it.vpos = 0; |
2109 /* Do this even if LINES is 0, so that we move back | 2125 /* Do this even if LINES is 0, so that we move back |
2110 to the beginning of the current line as we ought. */ | 2126 to the beginning of the current line as we ought. */ |