aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman2004-11-19 19:40:32 +0000
committerRichard M. Stallman2004-11-19 19:40:32 +0000
commitf31a9a68db58d34497ed79d2acfd4815eb1f2c30 (patch)
tree9d140ec1eb4de3f76e6908f416e2efbd10e41bf4 /src
parentf9b0fd9964ef94bce907db72a826df1347a9ffed (diff)
downloademacs-f31a9a68db58d34497ed79d2acfd4815eb1f2c30.tar.gz
emacs-f31a9a68db58d34497ed79d2acfd4815eb1f2c30.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/search.c19
2 files changed, 31 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d06a8d343dd..dda9d1cc972 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
12004-11-19 Richard M. Stallman <rms@gnu.org>
2
3 * search.c (Vsearch_whitespace_regexp): New variable.
4 (syms_of_search): Defvar it.
5 (compile_pattern_1): Call re_set_whitespace_regexp with it.
6 (search_buffer): No regexp is trivial if Vsearch_whitespace_regexp
7 is non-nil.
8
9 * regex.c (regex_compile): Substitute whitespace_regexp
10 for spaces, if it is nonzero.
11 (whitespace_regexp): New variable.
12 (re_set_whitespace_regexp): New function.
13
12004-11-19 Kim F. Storm <storm@cua.dk> 142004-11-19 Kim F. Storm <storm@cua.dk>
2 15
3 * indent.c (Fvertical_motion): Fix last change. 16 * indent.c (Fvertical_motion): Fix last change.
diff --git a/src/search.c b/src/search.c
index 1742cfb08c2..b73ed338791 100644
--- a/src/search.c
+++ b/src/search.c
@@ -83,6 +83,8 @@ static Lisp_Object last_thing_searched;
83 83
84Lisp_Object Qinvalid_regexp; 84Lisp_Object Qinvalid_regexp;
85 85
86Lisp_Object Vsearch_whitespace_regexp;
87
86static void set_search_regs (); 88static void set_search_regs ();
87static void save_search_regs (); 89static void save_search_regs ();
88static int simple_search (); 90static int simple_search ();
@@ -161,8 +163,15 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
161 BLOCK_INPUT; 163 BLOCK_INPUT;
162 old = re_set_syntax (RE_SYNTAX_EMACS 164 old = re_set_syntax (RE_SYNTAX_EMACS
163 | (posix ? 0 : RE_NO_POSIX_BACKTRACKING)); 165 | (posix ? 0 : RE_NO_POSIX_BACKTRACKING));
166
167 re_set_whitespace_regexp (NILP (Vsearch_whitespace_regexp) ? NULL
168 : SDATA (Vsearch_whitespace_regexp));
169
164 val = (char *) re_compile_pattern ((char *)raw_pattern, 170 val = (char *) re_compile_pattern ((char *)raw_pattern,
165 raw_pattern_size, &cp->buf); 171 raw_pattern_size, &cp->buf);
172
173 re_set_whitespace_regexp (NULL);
174
166 re_set_syntax (old); 175 re_set_syntax (old);
167 UNBLOCK_INPUT; 176 UNBLOCK_INPUT;
168 if (val) 177 if (val)
@@ -1051,7 +1060,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1051 return pos; 1060 return pos;
1052 } 1061 }
1053 1062
1054 if (RE && !trivial_regexp_p (string)) 1063 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_whitespace_regexp)))
1055 { 1064 {
1056 unsigned char *p1, *p2; 1065 unsigned char *p1, *p2;
1057 int s1, s2; 1066 int s1, s2;
@@ -2998,6 +3007,14 @@ syms_of_search ()
2998 saved_last_thing_searched = Qnil; 3007 saved_last_thing_searched = Qnil;
2999 staticpro (&saved_last_thing_searched); 3008 staticpro (&saved_last_thing_searched);
3000 3009
3010 DEFVAR_LISP ("search-whitespace-regexp", &Vsearch_whitespace_regexp,
3011 /* doc: Regexp to substitute for bunches of spaces in regexp search.
3012Some commands use this for user-specified regexps.
3013Spaces that occur inside character classes or repetition operators
3014or other such regexp constructs are not replaced with this.
3015A value of nil (which is the normal value) means treat spaces literally. */);
3016 Vsearch_whitespace_regexp = Qnil;
3017
3001 defsubr (&Slooking_at); 3018 defsubr (&Slooking_at);
3002 defsubr (&Sposix_looking_at); 3019 defsubr (&Sposix_looking_at);
3003 defsubr (&Sstring_match); 3020 defsubr (&Sstring_match);