diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/search.c | 106 |
1 files changed, 45 insertions, 61 deletions
diff --git a/src/search.c b/src/search.c index 89bc7e91612..540e27a36dd 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -2206,24 +2206,10 @@ set_search_regs (ptrdiff_t beg_byte, ptrdiff_t nbytes) | |||
| 2206 | DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4, | 2206 | DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4, |
| 2207 | "MSearch backward: ", | 2207 | "MSearch backward: ", |
| 2208 | doc: /* Search backward from point for STRING. | 2208 | doc: /* Search backward from point for STRING. |
| 2209 | Set point to the beginning of the occurrence found, and return point. | 2209 | This function is almost identical to `search-forward', except that |
| 2210 | An optional second argument bounds the search; it is a buffer position. | 2210 | by default it searches backward instead of forward, and the sign of |
| 2211 | The match found must not begin before that position. A value of nil | 2211 | COUNT also indicates exactly the opposite searching direction. |
| 2212 | means search to the beginning of the accessible portion of the buffer. | 2212 | See `search-forward' for details. */) |
| 2213 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 2214 | If not nil and not t, position at limit of search and return nil. | ||
| 2215 | Optional fourth argument COUNT, if a positive number, means to search | ||
| 2216 | for COUNT successive occurrences. If COUNT is negative, search | ||
| 2217 | forward, instead of backward, for -COUNT occurrences. A value of | ||
| 2218 | nil means the same as 1. | ||
| 2219 | With COUNT positive, the match found is the COUNTth to last one (or | ||
| 2220 | last, if COUNT is 1 or nil) in the buffer located entirely before | ||
| 2221 | the origin of the search; correspondingly with COUNT negative. | ||
| 2222 | |||
| 2223 | Search case-sensitivity is determined by the value of the variable | ||
| 2224 | `case-fold-search', which see. | ||
| 2225 | |||
| 2226 | See also the functions `match-beginning', `match-end' and `replace-match'. */) | ||
| 2227 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | 2213 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) |
| 2228 | { | 2214 | { |
| 2229 | return search_command (string, bound, noerror, count, -1, false, false); | 2215 | return search_command (string, bound, noerror, count, -1, false, false); |
| @@ -2232,23 +2218,28 @@ See also the functions `match-beginning', `match-end' and `replace-match'. */) | |||
| 2232 | DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ", | 2218 | DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ", |
| 2233 | doc: /* Search forward from point for STRING. | 2219 | doc: /* Search forward from point for STRING. |
| 2234 | Set point to the end of the occurrence found, and return point. | 2220 | Set point to the end of the occurrence found, and return point. |
| 2235 | An optional second argument bounds the search; it is a buffer position. | 2221 | The optional second argument BOUND is a buffer position that bounds |
| 2236 | The match found must not end after that position. A value of nil | 2222 | the search. The match found must not end after that position. A |
| 2237 | means search to the end of the accessible portion of the buffer. | 2223 | value of nil means search to the end of the accessible portion of |
| 2238 | Optional third argument, if t, means if fail just return nil (no error). | 2224 | the buffer. |
| 2239 | If not nil and not t, move to limit of search and return nil. | 2225 | The optional third argument NOERROR indicates how errors are handled |
| 2240 | Optional fourth argument COUNT, if a positive number, means to search | 2226 | when the search fails: if it is nil or omitted, emit an error; if |
| 2241 | for COUNT successive occurrences. If COUNT is negative, search | 2227 | it is t, simply return nil and do nothing; if it is neither nil nor |
| 2242 | backward, instead of forward, for -COUNT occurrences. A value of | 2228 | t, move to the limit of search and return nil. |
| 2243 | nil means the same as 1. | 2229 | The optional fourth argument COUNT is a number that indicates the |
| 2244 | With COUNT positive, the match found is the COUNTth one (or first, | 2230 | search direction and the number of occurrences to search for. If it |
| 2245 | if COUNT is 1 or nil) in the buffer located entirely after the | 2231 | is positive, search forward for COUNT successive occurrences; if it |
| 2246 | origin of the search; correspondingly with COUNT negative. | 2232 | is negative, search backward, instead of forward, for -COUNT |
| 2233 | occurrences. A value of nil means the same as 1. | ||
| 2234 | With COUNT positive/negative, the match found is the COUNTth/-COUNTth | ||
| 2235 | one in the buffer located entirely after/before the origin of the | ||
| 2236 | search. | ||
| 2247 | 2237 | ||
| 2248 | Search case-sensitivity is determined by the value of the variable | 2238 | Search case-sensitivity is determined by the value of the variable |
| 2249 | `case-fold-search', which see. | 2239 | `case-fold-search', which see. |
| 2250 | 2240 | ||
| 2251 | See also the functions `match-beginning', `match-end' and `replace-match'. */) | 2241 | See also the functions `match-beginning', `match-end', `match-string', |
| 2242 | and `replace-match'. */) | ||
| 2252 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | 2243 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) |
| 2253 | { | 2244 | { |
| 2254 | return search_command (string, bound, noerror, count, 1, false, false); | 2245 | return search_command (string, bound, noerror, count, 1, false, false); |
| @@ -2305,25 +2296,14 @@ DEFUN ("posix-search-backward", Fposix_search_backward, Sposix_search_backward, | |||
| 2305 | "sPosix search backward: ", | 2296 | "sPosix search backward: ", |
| 2306 | doc: /* Search backward from point for match for REGEXP according to Posix rules. | 2297 | doc: /* Search backward from point for match for REGEXP according to Posix rules. |
| 2307 | Find the longest match in accord with Posix regular expression rules. | 2298 | Find the longest match in accord with Posix regular expression rules. |
| 2308 | Set point to the beginning of the occurrence found, and return point. | 2299 | This function is almost identical to `posix-search-forward', except that |
| 2309 | An optional second argument bounds the search; it is a buffer position. | 2300 | by default it searches backward instead of forward, and the sign of |
| 2310 | The match found must not begin before that position. A value of nil | 2301 | COUNT also indicates exactly the opposite searching direction. |
| 2311 | means search to the beginning of the accessible portion of the buffer. | 2302 | See `posix-search-forward' for details. |
| 2312 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 2313 | If not nil and not t, position at limit of search and return nil. | ||
| 2314 | Optional fourth argument COUNT, if a positive number, means to search | ||
| 2315 | for COUNT successive occurrences. If COUNT is negative, search | ||
| 2316 | forward, instead of backward, for -COUNT occurrences. A value of | ||
| 2317 | nil means the same as 1. | ||
| 2318 | With COUNT positive, the match found is the COUNTth to last one (or | ||
| 2319 | last, if COUNT is 1 or nil) in the buffer located entirely before | ||
| 2320 | the origin of the search; correspondingly with COUNT negative. | ||
| 2321 | |||
| 2322 | Search case-sensitivity is determined by the value of the variable | ||
| 2323 | `case-fold-search', which see. | ||
| 2324 | 2303 | ||
| 2325 | See also the functions `match-beginning', `match-end', `match-string', | 2304 | Note that searching backwards may give a shorter match than expected, |
| 2326 | and `replace-match'. */) | 2305 | because REGEXP is still matched in the forward direction. See Info |
| 2306 | anchor `(elisp) re-search-backward' for details. */) | ||
| 2327 | (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | 2307 | (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) |
| 2328 | { | 2308 | { |
| 2329 | return search_command (regexp, bound, noerror, count, -1, true, true); | 2309 | return search_command (regexp, bound, noerror, count, -1, true, true); |
| @@ -2334,18 +2314,22 @@ DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1, | |||
| 2334 | doc: /* Search forward from point for REGEXP according to Posix rules. | 2314 | doc: /* Search forward from point for REGEXP according to Posix rules. |
| 2335 | Find the longest match in accord with Posix regular expression rules. | 2315 | Find the longest match in accord with Posix regular expression rules. |
| 2336 | Set point to the end of the occurrence found, and return point. | 2316 | Set point to the end of the occurrence found, and return point. |
| 2337 | An optional second argument bounds the search; it is a buffer position. | 2317 | The optional second argument BOUND is a buffer position that bounds |
| 2338 | The match found must not end after that position. A value of nil | 2318 | the search. The match found must not end after that position. A |
| 2339 | means search to the end of the accessible portion of the buffer. | 2319 | value of nil means search to the end of the accessible portion of |
| 2340 | Optional third argument, if t, means if fail just return nil (no error). | 2320 | the buffer. |
| 2341 | If not nil and not t, move to limit of search and return nil. | 2321 | The optional third argument NOERROR indicates how errors are handled |
| 2342 | Optional fourth argument COUNT, if a positive number, means to search | 2322 | when the search fails: if it is nil or omitted, emit an error; if |
| 2343 | for COUNT successive occurrences. If COUNT is negative, search | 2323 | it is t, simply return nil and do nothing; if it is neither nil nor |
| 2344 | backward, instead of forward, for -COUNT occurrences. A value of | 2324 | t, move to the limit of search and return nil. |
| 2345 | nil means the same as 1. | 2325 | The optional fourth argument COUNT is a number that indicates the |
| 2346 | With COUNT positive, the match found is the COUNTth one (or first, | 2326 | search direction and the number of occurrences to search for. If it |
| 2347 | if COUNT is 1 or nil) in the buffer located entirely after the | 2327 | is positive, search forward for COUNT successive occurrences; if it |
| 2348 | origin of the search; correspondingly with COUNT negative. | 2328 | is negative, search backward, instead of forward, for -COUNT |
| 2329 | occurrences. A value of nil means the same as 1. | ||
| 2330 | With COUNT positive/negative, the match found is the COUNTth/-COUNTth | ||
| 2331 | one in the buffer located entirely after/before the origin of the | ||
| 2332 | search. | ||
| 2349 | 2333 | ||
| 2350 | Search case-sensitivity is determined by the value of the variable | 2334 | Search case-sensitivity is determined by the value of the variable |
| 2351 | `case-fold-search', which see. | 2335 | `case-fold-search', which see. |