Mercurial > emacs
comparison src/search.c @ 1684:f4d848dea8ff
* search.c (Fskip_chars_forward, Fskip_chars_backward): Return the
distance traveled.
(skip_chars): Return the distance traveled, as a Lisp_Object.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 12 Dec 1992 15:37:30 +0000 |
parents | bd61aaa7828b |
children | 7786f61ec635 |
comparison
equal
deleted
inserted
replaced
1683:a0a41de51400 | 1684:f4d848dea8ff |
---|---|
343 register int from, cnt; | 343 register int from, cnt; |
344 { | 344 { |
345 return (scan_buffer ('\n', from, cnt, (int *) 0)); | 345 return (scan_buffer ('\n', from, cnt, (int *) 0)); |
346 } | 346 } |
347 | 347 |
348 Lisp_Object skip_chars (); | |
349 | |
348 DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, | 350 DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, |
349 "Move point forward, stopping before a char not in CHARS, or at position LIM.\n\ | 351 "Move point forward, stopping before a char not in CHARS, or at position LIM.\n\ |
350 CHARS is like the inside of a `[...]' in a regular expression\n\ | 352 CHARS is like the inside of a `[...]' in a regular expression\n\ |
351 except that `]' is never special and `\\' quotes `^', `-' or `\\'.\n\ | 353 except that `]' is never special and `\\' quotes `^', `-' or `\\'.\n\ |
352 Thus, with arg \"a-zA-Z\", this skips letters stopping before first nonletter.\n\ | 354 Thus, with arg \"a-zA-Z\", this skips letters stopping before first nonletter.\n\ |
353 With arg \"^a-zA-Z\", skips nonletters stopping before first letter.") | 355 With arg \"^a-zA-Z\", skips nonletters stopping before first letter.\n\ |
356 Returns the distance traveled, either zero or positive.") | |
354 (string, lim) | 357 (string, lim) |
355 Lisp_Object string, lim; | 358 Lisp_Object string, lim; |
356 { | 359 { |
357 skip_chars (1, string, lim); | 360 return skip_chars (1, string, lim); |
358 return Qnil; | |
359 } | 361 } |
360 | 362 |
361 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, | 363 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, |
362 "Move point backward, stopping after a char not in CHARS, or at position LIM.\n\ | 364 "Move point backward, stopping after a char not in CHARS, or at position LIM.\n\ |
363 See `skip-chars-forward' for details.") | 365 See `skip-chars-forward' for details.\n\ |
366 Returns the distance traveled, either zero or negative.") | |
364 (string, lim) | 367 (string, lim) |
365 Lisp_Object string, lim; | 368 Lisp_Object string, lim; |
366 { | 369 { |
367 skip_chars (0, string, lim); | 370 return skip_chars (0, string, lim); |
368 return Qnil; | 371 } |
369 } | 372 |
370 | 373 Lisp_Object |
371 skip_chars (forwardp, string, lim) | 374 skip_chars (forwardp, string, lim) |
372 int forwardp; | 375 int forwardp; |
373 Lisp_Object string, lim; | 376 Lisp_Object string, lim; |
374 { | 377 { |
375 register unsigned char *p, *pend; | 378 register unsigned char *p, *pend; |
431 | 434 |
432 if (negate) | 435 if (negate) |
433 for (i = 0; i < sizeof fastmap; i++) | 436 for (i = 0; i < sizeof fastmap; i++) |
434 fastmap[i] ^= 1; | 437 fastmap[i] ^= 1; |
435 | 438 |
436 immediate_quit = 1; | 439 { |
437 if (forwardp) | 440 int start_point = point; |
438 { | 441 |
439 while (point < XINT (lim) && fastmap[FETCH_CHAR (point)]) | 442 immediate_quit = 1; |
440 SET_PT (point + 1); | 443 if (forwardp) |
441 } | 444 { |
442 else | 445 while (point < XINT (lim) && fastmap[FETCH_CHAR (point)]) |
443 { | 446 SET_PT (point + 1); |
444 while (point > XINT (lim) && fastmap[FETCH_CHAR (point - 1)]) | 447 } |
445 SET_PT (point - 1); | 448 else |
446 } | 449 { |
447 immediate_quit = 0; | 450 while (point > XINT (lim) && fastmap[FETCH_CHAR (point - 1)]) |
451 SET_PT (point - 1); | |
452 } | |
453 immediate_quit = 0; | |
454 | |
455 return make_number (point - start_point); | |
456 } | |
448 } | 457 } |
449 | 458 |
450 /* Subroutines of Lisp buffer search functions. */ | 459 /* Subroutines of Lisp buffer search functions. */ |
451 | 460 |
452 static Lisp_Object | 461 static Lisp_Object |