diff options
| author | Richard M. Stallman | 2004-11-19 19:40:32 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-11-19 19:40:32 +0000 |
| commit | f31a9a68db58d34497ed79d2acfd4815eb1f2c30 (patch) | |
| tree | 9d140ec1eb4de3f76e6908f416e2efbd10e41bf4 /src | |
| parent | f9b0fd9964ef94bce907db72a826df1347a9ffed (diff) | |
| download | emacs-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/ChangeLog | 13 | ||||
| -rw-r--r-- | src/search.c | 19 |
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 @@ | |||
| 1 | 2004-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 | |||
| 1 | 2004-11-19 Kim F. Storm <storm@cua.dk> | 14 | 2004-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 | ||
| 84 | Lisp_Object Qinvalid_regexp; | 84 | Lisp_Object Qinvalid_regexp; |
| 85 | 85 | ||
| 86 | Lisp_Object Vsearch_whitespace_regexp; | ||
| 87 | |||
| 86 | static void set_search_regs (); | 88 | static void set_search_regs (); |
| 87 | static void save_search_regs (); | 89 | static void save_search_regs (); |
| 88 | static int simple_search (); | 90 | static 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. | ||
| 3012 | Some commands use this for user-specified regexps. | ||
| 3013 | Spaces that occur inside character classes or repetition operators | ||
| 3014 | or other such regexp constructs are not replaced with this. | ||
| 3015 | A 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); |