]> git.eshelyaron.com Git - emacs.git/commitdiff
(Vsearch_whitespace_regexp): New variable.
authorRichard M. Stallman <rms@gnu.org>
Fri, 19 Nov 2004 19:40:32 +0000 (19:40 +0000)
committerRichard M. Stallman <rms@gnu.org>
Fri, 19 Nov 2004 19:40:32 +0000 (19:40 +0000)
(syms_of_search): Defvar it.
(compile_pattern_1): Call re_set_whitespace_regexp with it.
(search_buffer): No regexp is trivial if Vsearch_whitespace_regexp is non-nil.

src/ChangeLog
src/search.c

index d06a8d343dde9b9fcefc556507ab7d44cf398f19..dda9d1cc972f996b62f3515684116dbedd510bf3 100644 (file)
@@ -1,3 +1,16 @@
+2004-11-19  Richard M. Stallman  <rms@gnu.org>
+
+       * search.c (Vsearch_whitespace_regexp): New variable.
+       (syms_of_search): Defvar it.
+       (compile_pattern_1): Call re_set_whitespace_regexp with it.
+       (search_buffer): No regexp is trivial if Vsearch_whitespace_regexp
+       is non-nil.
+
+       * regex.c (regex_compile): Substitute whitespace_regexp
+       for spaces, if it is nonzero.
+       (whitespace_regexp): New variable.
+       (re_set_whitespace_regexp): New function.
+
 2004-11-19  Kim F. Storm  <storm@cua.dk>
 
        * indent.c (Fvertical_motion): Fix last change.
index 1742cfb08c2e7cbae8de9ef00d1d14b6358fa8d9..b73ed338791158f1cab665bafc7161862f8e966e 100644 (file)
@@ -83,6 +83,8 @@ static Lisp_Object last_thing_searched;
 
 Lisp_Object Qinvalid_regexp;
 
+Lisp_Object Vsearch_whitespace_regexp;
+
 static void set_search_regs ();
 static void save_search_regs ();
 static int simple_search ();
@@ -161,8 +163,15 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
   BLOCK_INPUT;
   old = re_set_syntax (RE_SYNTAX_EMACS
                       | (posix ? 0 : RE_NO_POSIX_BACKTRACKING));
+
+  re_set_whitespace_regexp (NILP (Vsearch_whitespace_regexp) ? NULL
+                           : SDATA (Vsearch_whitespace_regexp));
+
   val = (char *) re_compile_pattern ((char *)raw_pattern,
                                     raw_pattern_size, &cp->buf);
+
+  re_set_whitespace_regexp (NULL);
+
   re_set_syntax (old);
   UNBLOCK_INPUT;
   if (val)
@@ -1051,7 +1060,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
       return pos;
     }
 
-  if (RE && !trivial_regexp_p (string))
+  if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_whitespace_regexp)))
     {
       unsigned char *p1, *p2;
       int s1, s2;
@@ -2998,6 +3007,14 @@ syms_of_search ()
   saved_last_thing_searched = Qnil;
   staticpro (&saved_last_thing_searched);
 
+  DEFVAR_LISP ("search-whitespace-regexp", &Vsearch_whitespace_regexp,
+      /* doc: Regexp to substitute for bunches of spaces in regexp search.
+Some commands use this for user-specified regexps.
+Spaces that occur inside character classes or repetition operators
+or other such regexp constructs are not replaced with this.
+A value of nil (which is the normal value) means treat spaces literally.  */);
+  Vsearch_whitespace_regexp = Qnil;
+
   defsubr (&Slooking_at);
   defsubr (&Sposix_looking_at);
   defsubr (&Sstring_match);