changeset 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 a0a41de51400
children 8d7fc70d3103
files src/search.c
diffstat 1 files changed, 27 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c	Sat Dec 12 15:36:50 1992 +0000
+++ b/src/search.c	Sat Dec 12 15:37:30 1992 +0000
@@ -345,29 +345,32 @@
   return (scan_buffer ('\n', from, cnt, (int *) 0));
 }
 
+Lisp_Object skip_chars ();
+
 DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0,
   "Move point forward, stopping before a char not in CHARS, or at position LIM.\n\
 CHARS is like the inside of a `[...]' in a regular expression\n\
 except that `]' is never special and `\\' quotes `^', `-' or `\\'.\n\
 Thus, with arg \"a-zA-Z\", this skips letters stopping before first nonletter.\n\
-With arg \"^a-zA-Z\", skips nonletters stopping before first letter.")
+With arg \"^a-zA-Z\", skips nonletters stopping before first letter.\n\
+Returns the distance traveled, either zero or positive.")
   (string, lim)
      Lisp_Object string, lim;
 {
-  skip_chars (1, string, lim);
-  return Qnil;
+  return skip_chars (1, string, lim);
 }
 
 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0,
   "Move point backward, stopping after a char not in CHARS, or at position LIM.\n\
-See `skip-chars-forward' for details.")
+See `skip-chars-forward' for details.\n\
+Returns the distance traveled, either zero or negative.")
   (string, lim)
      Lisp_Object string, lim;
 {
-  skip_chars (0, string, lim);
-  return Qnil;
+  return skip_chars (0, string, lim);
 }
 
+Lisp_Object
 skip_chars (forwardp, string, lim)
      int forwardp;
      Lisp_Object string, lim;
@@ -433,18 +436,24 @@
     for (i = 0; i < sizeof fastmap; i++)
       fastmap[i] ^= 1;
 
-  immediate_quit = 1;
-  if (forwardp)
-    {
-      while (point < XINT (lim) && fastmap[FETCH_CHAR (point)])
-	SET_PT (point + 1);
-    }
-  else
-    {
-      while (point > XINT (lim) && fastmap[FETCH_CHAR (point - 1)])
-	SET_PT (point - 1);
-    }
-  immediate_quit = 0;
+  {
+    int start_point = point;
+
+    immediate_quit = 1;
+    if (forwardp)
+      {
+	while (point < XINT (lim) && fastmap[FETCH_CHAR (point)])
+	  SET_PT (point + 1);
+      }
+    else
+      {
+	while (point > XINT (lim) && fastmap[FETCH_CHAR (point - 1)])
+	  SET_PT (point - 1);
+      }
+    immediate_quit = 0;
+
+    return make_number (point - start_point);
+  }
 }
 
 /* Subroutines of Lisp buffer search functions. */