diff options
| author | Karl Heuer | 1995-05-13 01:48:53 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-05-13 01:48:53 +0000 |
| commit | 99ce22d56c0dab6fb5b9f241b7f1dbc0b62277d9 (patch) | |
| tree | aba2b941cf0ab9f8ea337ff26da767a3b02e18ea /src | |
| parent | 210e752ffa1842aa04bc566482aaf67ed9563328 (diff) | |
| download | emacs-99ce22d56c0dab6fb5b9f241b7f1dbc0b62277d9.tar.gz emacs-99ce22d56c0dab6fb5b9f241b7f1dbc0b62277d9.zip | |
(vmotion): Simplify. Replace last three args with a single
struct window *. All callers changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 135 |
1 files changed, 63 insertions, 72 deletions
diff --git a/src/indent.c b/src/indent.c index 433105d4833..9c29d459870 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1068,11 +1068,12 @@ pos_tab_offset (w, pos) | |||
| 1068 | struct position val_vmotion; | 1068 | struct position val_vmotion; |
| 1069 | 1069 | ||
| 1070 | struct position * | 1070 | struct position * |
| 1071 | vmotion (from, vtarget, width, hscroll, window) | 1071 | vmotion (from, vtarget, w) |
| 1072 | register int from, vtarget, width; | 1072 | register int from, vtarget; |
| 1073 | int hscroll; | 1073 | struct window *w; |
| 1074 | Lisp_Object window; | ||
| 1075 | { | 1074 | { |
| 1075 | int width = window_internal_width (w) - 1; | ||
| 1076 | int hscroll = XINT (w->hscroll); | ||
| 1076 | struct position pos; | 1077 | struct position pos; |
| 1077 | /* vpos is cumulative vertical position, changed as from is changed */ | 1078 | /* vpos is cumulative vertical position, changed as from is changed */ |
| 1078 | register int vpos = 0; | 1079 | register int vpos = 0; |
| @@ -1083,12 +1084,15 @@ vmotion (from, vtarget, width, hscroll, window) | |||
| 1083 | = (INTEGERP (current_buffer->selective_display) | 1084 | = (INTEGERP (current_buffer->selective_display) |
| 1084 | ? XINT (current_buffer->selective_display) | 1085 | ? XINT (current_buffer->selective_display) |
| 1085 | : !NILP (current_buffer->selective_display) ? -1 : 0); | 1086 | : !NILP (current_buffer->selective_display) ? -1 : 0); |
| 1087 | Lisp_Object window; | ||
| 1088 | int start_hpos = 0; | ||
| 1089 | |||
| 1090 | XSETWINDOW (window, w); | ||
| 1091 | |||
| 1086 | /* The omission of the clause | 1092 | /* The omission of the clause |
| 1087 | && marker_position (XWINDOW (window)->start) == BEG | 1093 | && marker_position (w->start) == BEG |
| 1088 | here is deliberate; I think we want to measure from the prompt | 1094 | here is deliberate; I think we want to measure from the prompt |
| 1089 | position even if the minibuffer window has scrolled. */ | 1095 | position even if the minibuffer window has scrolled. */ |
| 1090 | int start_hpos = 0; | ||
| 1091 | |||
| 1092 | if (EQ (window, minibuf_window)) | 1096 | if (EQ (window, minibuf_window)) |
| 1093 | { | 1097 | { |
| 1094 | if (minibuf_prompt_width == 0) | 1098 | if (minibuf_prompt_width == 0) |
| @@ -1098,16 +1102,18 @@ vmotion (from, vtarget, width, hscroll, window) | |||
| 1098 | start_hpos = minibuf_prompt_width; | 1102 | start_hpos = minibuf_prompt_width; |
| 1099 | } | 1103 | } |
| 1100 | 1104 | ||
| 1101 | retry: | 1105 | if (vpos >= vtarget) |
| 1102 | if (vtarget > vpos) | ||
| 1103 | { | 1106 | { |
| 1104 | /* Moving downward is simple, but must calculate from beg of line | 1107 | /* To move upward, go a line at a time until |
| 1105 | to determine hpos of starting point */ | 1108 | we have gone at least far enough */ |
| 1106 | if (from > BEGV && FETCH_CHAR (from - 1) != '\n') | 1109 | |
| 1110 | first = 1; | ||
| 1111 | |||
| 1112 | while ((vpos > vtarget || first) && from > BEGV) | ||
| 1107 | { | 1113 | { |
| 1108 | Lisp_Object propval; | 1114 | Lisp_Object propval; |
| 1109 | 1115 | ||
| 1110 | XSETFASTINT (prevline, find_next_newline_no_quit (from, -1)); | 1116 | XSETFASTINT (prevline, find_next_newline_no_quit (from - 1, -1)); |
| 1111 | while (XFASTINT (prevline) > BEGV | 1117 | while (XFASTINT (prevline) > BEGV |
| 1112 | && ((selective > 0 | 1118 | && ((selective > 0 |
| 1113 | && indented_beyond_p (XFASTINT (prevline), selective)) | 1119 | && indented_beyond_p (XFASTINT (prevline), selective)) |
| @@ -1118,79 +1124,69 @@ vmotion (from, vtarget, width, hscroll, window) | |||
| 1118 | window), | 1124 | window), |
| 1119 | TEXT_PROP_MEANS_INVISIBLE (propval)) | 1125 | TEXT_PROP_MEANS_INVISIBLE (propval)) |
| 1120 | #endif | 1126 | #endif |
| 1121 | )) | 1127 | )) |
| 1122 | XSETFASTINT (prevline, | 1128 | XSETFASTINT (prevline, |
| 1123 | find_next_newline_no_quit (XFASTINT (prevline) - 1, | 1129 | find_next_newline_no_quit (XFASTINT (prevline) - 1, |
| 1124 | -1)); | 1130 | -1)); |
| 1125 | pos = *compute_motion (XFASTINT (prevline), 0, | 1131 | pos = *compute_motion (XFASTINT (prevline), 0, |
| 1126 | lmargin + (XFASTINT (prevline) == 1 | 1132 | lmargin + (XFASTINT (prevline) == BEG |
| 1127 | ? start_hpos : 0), | 1133 | ? start_hpos : 0), |
| 1128 | from, 1 << (INTBITS - 2), 0, | 1134 | from, 1 << (INTBITS - 2), 0, |
| 1129 | width, hscroll, 0, XWINDOW (window)); | 1135 | width, hscroll, 0, w); |
| 1136 | vpos -= pos.vpos; | ||
| 1137 | first = 0; | ||
| 1138 | from = XFASTINT (prevline); | ||
| 1130 | } | 1139 | } |
| 1131 | else | 1140 | |
| 1141 | /* If we made exactly the desired vertical distance, | ||
| 1142 | or if we hit beginning of buffer, | ||
| 1143 | return point found */ | ||
| 1144 | if (vpos >= vtarget) | ||
| 1132 | { | 1145 | { |
| 1133 | pos.hpos = lmargin + (from == 1 ? start_hpos : 0); | 1146 | val_vmotion.bufpos = from; |
| 1134 | pos.vpos = 0; | 1147 | val_vmotion.vpos = vpos; |
| 1148 | val_vmotion.hpos = lmargin; | ||
| 1149 | val_vmotion.contin = 0; | ||
| 1150 | val_vmotion.prevhpos = 0; | ||
| 1151 | return &val_vmotion; | ||
| 1135 | } | 1152 | } |
| 1136 | return compute_motion (from, vpos, pos.hpos, | ||
| 1137 | ZV, vtarget, - (1 << (INTBITS - 2)), | ||
| 1138 | width, hscroll, pos.vpos * width, | ||
| 1139 | XWINDOW (window)); | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | /* To move upward, go a line at a time until | ||
| 1143 | we have gone at least far enough */ | ||
| 1144 | 1153 | ||
| 1145 | first = 1; | 1154 | /* Otherwise find the correct spot by moving down */ |
| 1146 | 1155 | } | |
| 1147 | while ((vpos > vtarget || first) && from > BEGV) | 1156 | /* Moving downward is simple, but must calculate from beg of line |
| 1157 | to determine hpos of starting point */ | ||
| 1158 | if (from > BEGV && FETCH_CHAR (from - 1) != '\n') | ||
| 1148 | { | 1159 | { |
| 1149 | XSETFASTINT (prevline, from); | 1160 | Lisp_Object propval; |
| 1150 | while (1) | ||
| 1151 | { | ||
| 1152 | Lisp_Object propval; | ||
| 1153 | 1161 | ||
| 1154 | XSETFASTINT (prevline, | 1162 | XSETFASTINT (prevline, find_next_newline_no_quit (from, -1)); |
| 1155 | find_next_newline_no_quit (XFASTINT (prevline) - 1, | 1163 | while (XFASTINT (prevline) > BEGV |
| 1156 | -1)); | 1164 | && ((selective > 0 |
| 1157 | if (XFASTINT (prevline) == BEGV | 1165 | && indented_beyond_p (XFASTINT (prevline), selective)) |
| 1158 | || ((selective <= 0 | ||
| 1159 | || ! indented_beyond_p (XFASTINT (prevline), selective)) | ||
| 1160 | #ifdef USE_TEXT_PROPERTIES | 1166 | #ifdef USE_TEXT_PROPERTIES |
| 1161 | /* watch out for newlines with `invisible' property */ | 1167 | /* watch out for newlines with `invisible' property */ |
| 1162 | && (propval = Fget_char_property (prevline, Qinvisible, | 1168 | || (propval = Fget_char_property (prevline, Qinvisible, |
| 1163 | window), | 1169 | window), |
| 1164 | ! TEXT_PROP_MEANS_INVISIBLE (propval)) | 1170 | TEXT_PROP_MEANS_INVISIBLE (propval)) |
| 1165 | #endif | 1171 | #endif |
| 1166 | )) | 1172 | )) |
| 1167 | break; | 1173 | XSETFASTINT (prevline, |
| 1168 | } | 1174 | find_next_newline_no_quit (XFASTINT (prevline) - 1, |
| 1175 | -1)); | ||
| 1169 | pos = *compute_motion (XFASTINT (prevline), 0, | 1176 | pos = *compute_motion (XFASTINT (prevline), 0, |
| 1170 | lmargin + (XFASTINT (prevline) == 1 | 1177 | lmargin + (XFASTINT (prevline) == BEG |
| 1171 | ? start_hpos : 0), | 1178 | ? start_hpos : 0), |
| 1172 | from, 1 << (INTBITS - 2), 0, | 1179 | from, 1 << (INTBITS - 2), 0, |
| 1173 | width, hscroll, 0, XWINDOW (window)); | 1180 | width, hscroll, 0, w); |
| 1174 | vpos -= pos.vpos; | ||
| 1175 | first = 0; | ||
| 1176 | from = XFASTINT (prevline); | ||
| 1177 | } | 1181 | } |
| 1178 | 1182 | else | |
| 1179 | /* If we made exactly the desired vertical distance, | ||
| 1180 | or if we hit beginning of buffer, | ||
| 1181 | return point found */ | ||
| 1182 | if (vpos >= vtarget) | ||
| 1183 | { | 1183 | { |
| 1184 | val_vmotion.bufpos = from; | 1184 | pos.hpos = lmargin + (from == BEG ? start_hpos : 0); |
| 1185 | val_vmotion.vpos = vpos; | 1185 | pos.vpos = 0; |
| 1186 | val_vmotion.hpos = lmargin; | ||
| 1187 | val_vmotion.contin = 0; | ||
| 1188 | val_vmotion.prevhpos = 0; | ||
| 1189 | return &val_vmotion; | ||
| 1190 | } | 1186 | } |
| 1191 | 1187 | return compute_motion (from, vpos, pos.hpos, | |
| 1192 | /* Otherwise find the correct spot by moving down */ | 1188 | ZV, vtarget, - (1 << (INTBITS - 2)), |
| 1193 | goto retry; | 1189 | width, hscroll, pos.vpos * width, w); |
| 1194 | } | 1190 | } |
| 1195 | 1191 | ||
| 1196 | DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0, | 1192 | DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0, |
| @@ -1211,7 +1207,6 @@ if beginning or end of buffer was reached.") | |||
| 1211 | Lisp_Object lines, window; | 1207 | Lisp_Object lines, window; |
| 1212 | { | 1208 | { |
| 1213 | struct position pos; | 1209 | struct position pos; |
| 1214 | register struct window *w; | ||
| 1215 | 1210 | ||
| 1216 | CHECK_NUMBER (lines, 0); | 1211 | CHECK_NUMBER (lines, 0); |
| 1217 | if (! NILP (window)) | 1212 | if (! NILP (window)) |
| @@ -1219,11 +1214,7 @@ if beginning or end of buffer was reached.") | |||
| 1219 | else | 1214 | else |
| 1220 | window = selected_window; | 1215 | window = selected_window; |
| 1221 | 1216 | ||
| 1222 | w = XWINDOW (window); | 1217 | pos = *vmotion (point, XINT (lines), XWINDOW (window)); |
| 1223 | |||
| 1224 | pos = *vmotion (point, XINT (lines), window_internal_width (w) - 1, | ||
| 1225 | /* Not XFASTINT since perhaps could be negative */ | ||
| 1226 | XINT (w->hscroll), window); | ||
| 1227 | 1218 | ||
| 1228 | SET_PT (pos.bufpos); | 1219 | SET_PT (pos.bufpos); |
| 1229 | return make_number (pos.vpos); | 1220 | return make_number (pos.vpos); |