aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJuri Linkov2011-12-02 12:19:49 +0200
committerJuri Linkov2011-12-02 12:19:49 +0200
commit02b16839f5242e93a234e7ebb0578d5aebb529ca (patch)
tree7436dcb7526068d6f501a63bda883a5d8dda4367 /src
parent71c90957bf6d537092d057b743d31e1fd2992f75 (diff)
downloademacs-02b16839f5242e93a234e7ebb0578d5aebb529ca.tar.gz
emacs-02b16839f5242e93a234e7ebb0578d5aebb529ca.zip
Change `wordify' to `word-search-regexp'.
* lisp/isearch.el (isearch-occur): Use `word-search-regexp' for `isearch-word'. (isearch-search-and-update): Add condition for `isearch-word' and call `word-search-regexp'. * src/search.c (Fword_search_regexp): New Lisp function created from `wordify'. Change type of arg `lax' from `int' to `Lisp_Object'. (Fword_search_backward, Fword_search_forward) (Fword_search_backward_lax, Fword_search_forward_lax): Use `Fword_search_regexp' instead of `wordify'. Doc fix. (syms_of_search): Define `Sword_search_regexp'. Fixes: debbugs:10145
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/search.c59
2 files changed, 48 insertions, 20 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 75f62ad6fbd..ed47da2caa1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12011-12-02 Juri Linkov <juri@jurta.org>
2
3 * search.c (Fword_search_regexp): New Lisp function created from
4 `wordify'. Change type of arg `lax' from `int' to `Lisp_Object'.
5 (Fword_search_backward, Fword_search_forward)
6 (Fword_search_backward_lax, Fword_search_forward_lax):
7 Use `Fword_search_regexp' instead of `wordify'. Doc fix.
8 (syms_of_search): Define `Sword_search_regexp'. (Bug#10145)
9
12011-12-01 Stefan Monnier <monnier@iro.umontreal.ca> 102011-12-01 Stefan Monnier <monnier@iro.umontreal.ca>
2 11
3 * fileio.c (Finsert_file_contents): Move after-change-function call 12 * fileio.c (Finsert_file_contents): Move after-change-function call
diff --git a/src/search.c b/src/search.c
index fe4ce534b0b..811ac74e194 100644
--- a/src/search.c
+++ b/src/search.c
@@ -83,11 +83,10 @@ static struct re_registers search_regs;
83 Qnil if no searching has been done yet. */ 83 Qnil if no searching has been done yet. */
84static Lisp_Object last_thing_searched; 84static Lisp_Object last_thing_searched;
85 85
86/* error condition signaled when regexp compile_pattern fails */ 86/* Error condition signaled when regexp compile_pattern fails. */
87
88static Lisp_Object Qinvalid_regexp; 87static Lisp_Object Qinvalid_regexp;
89 88
90/* Error condition used for failing searches */ 89/* Error condition used for failing searches. */
91static Lisp_Object Qsearch_failed; 90static Lisp_Object Qsearch_failed;
92 91
93static void set_search_regs (EMACS_INT, EMACS_INT); 92static void set_search_regs (EMACS_INT, EMACS_INT);
@@ -2078,13 +2077,16 @@ set_search_regs (EMACS_INT beg_byte, EMACS_INT nbytes)
2078 XSETBUFFER (last_thing_searched, current_buffer); 2077 XSETBUFFER (last_thing_searched, current_buffer);
2079} 2078}
2080 2079
2081/* Given STRING, a string of words separated by word delimiters, 2080DEFUN ("word-search-regexp", Fword_search_regexp, Sword_search_regexp, 1, 2, 0,
2082 compute a regexp that matches those exact words separated by 2081 doc: /* Return a regexp which matches words, ignoring punctuation.
2083 arbitrary punctuation. If LAX is nonzero, the end of the string 2082Given STRING, a string of words separated by word delimiters,
2084 need not match a word boundary unless it ends in whitespace. */ 2083compute a regexp that matches those exact words separated by
2085 2084arbitrary punctuation. If LAX is non-nil, the end of the string
2086static Lisp_Object 2085need not match a word boundary unless it ends in whitespace.
2087wordify (Lisp_Object string, int lax) 2086
2087Used in `word-search-forward', `word-search-backward',
2088`word-search-forward-lax', `word-search-backward-lax'. */)
2089 (Lisp_Object string, Lisp_Object lax)
2088{ 2090{
2089 register unsigned char *o; 2091 register unsigned char *o;
2090 register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0; 2092 register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0;
@@ -2125,7 +2127,7 @@ wordify (Lisp_Object string, int lax)
2125 } 2127 }
2126 2128
2127 adjust = - punct_count + 5 * (word_count - 1) 2129 adjust = - punct_count + 5 * (word_count - 1)
2128 + ((lax && !whitespace_at_end) ? 2 : 4); 2130 + ((!NILP (lax) && !whitespace_at_end) ? 2 : 4);
2129 if (STRING_MULTIBYTE (string)) 2131 if (STRING_MULTIBYTE (string))
2130 val = make_uninit_multibyte_string (len + adjust, 2132 val = make_uninit_multibyte_string (len + adjust,
2131 SBYTES (string) 2133 SBYTES (string)
@@ -2162,7 +2164,7 @@ wordify (Lisp_Object string, int lax)
2162 prev_c = c; 2164 prev_c = c;
2163 } 2165 }
2164 2166
2165 if (!lax || whitespace_at_end) 2167 if (NILP (lax) || whitespace_at_end)
2166 { 2168 {
2167 *o++ = '\\'; 2169 *o++ = '\\';
2168 *o++ = 'b'; 2170 *o++ = 'b';
@@ -2217,10 +2219,14 @@ An optional second argument bounds the search; it is a buffer position.
2217The match found must not extend before that position. 2219The match found must not extend before that position.
2218Optional third argument, if t, means if fail just return nil (no error). 2220Optional third argument, if t, means if fail just return nil (no error).
2219 If not nil and not t, move to limit of search and return nil. 2221 If not nil and not t, move to limit of search and return nil.
2220Optional fourth argument is repeat count--search for successive occurrences. */) 2222Optional fourth argument is repeat count--search for successive occurrences.
2223
2224Relies on the function `word-search-regexp' to convert a sequence
2225of words in STRING to a regexp used to search words without regard
2226to punctuation. */)
2221 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) 2227 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count)
2222{ 2228{
2223 return search_command (wordify (string, 0), bound, noerror, count, -1, 1, 0); 2229 return search_command (Fword_search_regexp (string, Qnil), bound, noerror, count, -1, 1, 0);
2224} 2230}
2225 2231
2226DEFUN ("word-search-forward", Fword_search_forward, Sword_search_forward, 1, 4, 2232DEFUN ("word-search-forward", Fword_search_forward, Sword_search_forward, 1, 4,
@@ -2231,10 +2237,14 @@ An optional second argument bounds the search; it is a buffer position.
2231The match found must not extend after that position. 2237The match found must not extend after that position.
2232Optional third argument, if t, means if fail just return nil (no error). 2238Optional third argument, if t, means if fail just return nil (no error).
2233 If not nil and not t, move to limit of search and return nil. 2239 If not nil and not t, move to limit of search and return nil.
2234Optional fourth argument is repeat count--search for successive occurrences. */) 2240Optional fourth argument is repeat count--search for successive occurrences.
2241
2242Relies on the function `word-search-regexp' to convert a sequence
2243of words in STRING to a regexp used to search words without regard
2244to punctuation. */)
2235 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) 2245 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count)
2236{ 2246{
2237 return search_command (wordify (string, 0), bound, noerror, count, 1, 1, 0); 2247 return search_command (Fword_search_regexp (string, Qnil), bound, noerror, count, 1, 1, 0);
2238} 2248}
2239 2249
2240DEFUN ("word-search-backward-lax", Fword_search_backward_lax, Sword_search_backward_lax, 1, 4, 2250DEFUN ("word-search-backward-lax", Fword_search_backward_lax, Sword_search_backward_lax, 1, 4,
@@ -2249,10 +2259,14 @@ An optional second argument bounds the search; it is a buffer position.
2249The match found must not extend before that position. 2259The match found must not extend before that position.
2250Optional third argument, if t, means if fail just return nil (no error). 2260Optional third argument, if t, means if fail just return nil (no error).
2251 If not nil and not t, move to limit of search and return nil. 2261 If not nil and not t, move to limit of search and return nil.
2252Optional fourth argument is repeat count--search for successive occurrences. */) 2262Optional fourth argument is repeat count--search for successive occurrences.
2263
2264Relies on the function `word-search-regexp' to convert a sequence
2265of words in STRING to a regexp used to search words without regard
2266to punctuation. */)
2253 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) 2267 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count)
2254{ 2268{
2255 return search_command (wordify (string, 1), bound, noerror, count, -1, 1, 0); 2269 return search_command (Fword_search_regexp (string, Qt), bound, noerror, count, -1, 1, 0);
2256} 2270}
2257 2271
2258DEFUN ("word-search-forward-lax", Fword_search_forward_lax, Sword_search_forward_lax, 1, 4, 2272DEFUN ("word-search-forward-lax", Fword_search_forward_lax, Sword_search_forward_lax, 1, 4,
@@ -2267,10 +2281,14 @@ An optional second argument bounds the search; it is a buffer position.
2267The match found must not extend after that position. 2281The match found must not extend after that position.
2268Optional third argument, if t, means if fail just return nil (no error). 2282Optional third argument, if t, means if fail just return nil (no error).
2269 If not nil and not t, move to limit of search and return nil. 2283 If not nil and not t, move to limit of search and return nil.
2270Optional fourth argument is repeat count--search for successive occurrences. */) 2284Optional fourth argument is repeat count--search for successive occurrences.
2285
2286Relies on the function `word-search-regexp' to convert a sequence
2287of words in STRING to a regexp used to search words without regard
2288to punctuation. */)
2271 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) 2289 (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count)
2272{ 2290{
2273 return search_command (wordify (string, 1), bound, noerror, count, 1, 1, 0); 2291 return search_command (Fword_search_regexp (string, Qt), bound, noerror, count, 1, 1, 0);
2274} 2292}
2275 2293
2276DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, 2294DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4,
@@ -3229,6 +3247,7 @@ is to bind it with `let' around a small expression. */);
3229 defsubr (&Sposix_string_match); 3247 defsubr (&Sposix_string_match);
3230 defsubr (&Ssearch_forward); 3248 defsubr (&Ssearch_forward);
3231 defsubr (&Ssearch_backward); 3249 defsubr (&Ssearch_backward);
3250 defsubr (&Sword_search_regexp);
3232 defsubr (&Sword_search_forward); 3251 defsubr (&Sword_search_forward);
3233 defsubr (&Sword_search_backward); 3252 defsubr (&Sword_search_backward);
3234 defsubr (&Sword_search_forward_lax); 3253 defsubr (&Sword_search_forward_lax);