comparison src/cmds.c @ 44754:628a697e2315

(Fend_of_line): Handle intangible text in mid line.
author Richard M. Stallman <rms@gnu.org>
date Mon, 22 Apr 2002 22:33:36 +0000
parents a17c8b15ef1b
children 21c0392ac82a
comparison
equal deleted inserted replaced
44753:55f9c8874c01 44754:628a697e2315
177 177
178 DEFUN ("end-of-line", Fend_of_line, Send_of_line, 0, 1, "p", 178 DEFUN ("end-of-line", Fend_of_line, Send_of_line, 0, 1, "p",
179 doc: /* Move point to end of current line. 179 doc: /* Move point to end of current line.
180 With argument N not nil or 1, move forward N - 1 lines first. 180 With argument N not nil or 1, move forward N - 1 lines first.
181 If point reaches the beginning or end of buffer, it stops there. 181 If point reaches the beginning or end of buffer, it stops there.
182 To ignore intangibility, bind `inhibit-text-motion-hooks' to t.
182 183
183 This command does not move point across a field boundary unless doing so 184 This command does not move point across a field boundary unless doing so
184 would move beyond there to a different line; if N is nil or 1, and 185 would move beyond there to a different line; if N is nil or 1, and
185 point starts at a field boundary, point does not move. To ignore field 186 point starts at a field boundary, point does not move. To ignore field
186 boundaries bind `inhibit-field-text-motion' to t. */) 187 boundaries bind `inhibit-field-text-motion' to t. */)
187 (n) 188 (n)
188 Lisp_Object n; 189 Lisp_Object n;
189 { 190 {
191 int newpos;
192
190 if (NILP (n)) 193 if (NILP (n))
191 XSETFASTINT (n, 1); 194 XSETFASTINT (n, 1);
192 else 195 else
193 CHECK_NUMBER (n); 196 CHECK_NUMBER (n);
194 197
195 SET_PT (XINT (Fline_end_position (n))); 198 while (1)
199 {
200 newpos = XINT (Fline_end_position (n));
201 SET_PT (newpos);
202
203 if (PT > newpos
204 && FETCH_CHAR (PT - 1) == '\n')
205 {
206 /* If we skipped over a newline that follows
207 an invisible intangible run,
208 move back to the last tangible position
209 within the line. */
210
211 SET_PT (PT - 1);
212 break;
213 }
214 else if (PT > newpos && PT < ZV
215 && FETCH_CHAR (PT) != '\n')
216 /* If we skipped something intangible
217 and now we're not really at eol,
218 keep going. */
219 n = make_number (1);
220 else
221 break;
222 }
196 223
197 return Qnil; 224 return Qnil;
198 } 225 }
199 226
200 DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP", 227 DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP",