diff options
| author | Jim Blandy | 1992-12-12 15:37:30 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-12-12 15:37:30 +0000 |
| commit | c1dc99a1852ddcc5aec69d0db43883ca1f4a08b8 (patch) | |
| tree | 485a668c9da0dd332165e0390eb28e5619e222fc /src | |
| parent | 1e30af705a70316d1e8bb12b1f5364abf97296cb (diff) | |
| download | emacs-c1dc99a1852ddcc5aec69d0db43883ca1f4a08b8.tar.gz emacs-c1dc99a1852ddcc5aec69d0db43883ca1f4a08b8.zip | |
* search.c (Fskip_chars_forward, Fskip_chars_backward): Return the
distance traveled.
(skip_chars): Return the distance traveled, as a Lisp_Object.
Diffstat (limited to 'src')
| -rw-r--r-- | src/search.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/search.c b/src/search.c index 8868d0aa537..9de9bece213 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -345,29 +345,32 @@ find_next_newline (from, cnt) | |||
| 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; | ||
| 369 | } | 371 | } |
| 370 | 372 | ||
| 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; |
| @@ -433,18 +436,24 @@ skip_chars (forwardp, string, lim) | |||
| 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. */ |