aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2025-09-06 12:06:28 +0200
committerMattias EngdegÄrd2025-09-07 14:39:07 +0200
commit11b3af64251a899c697b685cf7b311274be8dc6d (patch)
treef40b1ff1038de319ba18d0e2bb937827b5491d64 /src
parentadc9c43306e29340823797ebe4cca1989af68710 (diff)
downloademacs-11b3af64251a899c697b685cf7b311274be8dc6d.tar.gz
emacs-11b3af64251a899c697b685cf7b311274be8dc6d.zip
Harmonise doc strings for {re-,posix-,}search-{forward,backward}
The doc strings for re-search-forward and re-search-backward have been improved (bug#25193, bug#31584) but the corresponding posix- and non-regexp search functions still have the original text, despite describing the exact same mechanism. There is no reason for them to differ, so we make them all use the updated version which also is more readable. Any future doc string improvements should be made to all of them in the same way for consistency. * src/search.c (Fsearch_backward, Fsearch_forward) (Fposix_search_backward, Fposix_search_forward): Use text from Fre_search_forward and Fre_search_backward.
Diffstat (limited to 'src')
-rw-r--r--src/search.c106
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)
2206DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4, 2206DEFUN ("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.
2209Set point to the beginning of the occurrence found, and return point. 2209This function is almost identical to `search-forward', except that
2210An optional second argument bounds the search; it is a buffer position. 2210by 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 2211COUNT also indicates exactly the opposite searching direction.
2212 means search to the beginning of the accessible portion of the buffer. 2212See `search-forward' for details. */)
2213Optional 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.
2215Optional 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.
2219With 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
2223Search case-sensitivity is determined by the value of the variable
2224`case-fold-search', which see.
2225
2226See 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'. */)
2232DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ", 2218DEFUN ("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.
2234Set point to the end of the occurrence found, and return point. 2220Set point to the end of the occurrence found, and return point.
2235An optional second argument bounds the search; it is a buffer position. 2221The 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
2238Optional 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. 2225The optional third argument NOERROR indicates how errors are handled
2240Optional 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. 2229The optional fourth argument COUNT is a number that indicates the
2244With 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.
2234With 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
2248Search case-sensitivity is determined by the value of the variable 2238Search case-sensitivity is determined by the value of the variable
2249`case-fold-search', which see. 2239`case-fold-search', which see.
2250 2240
2251See also the functions `match-beginning', `match-end' and `replace-match'. */) 2241See also the functions `match-beginning', `match-end', `match-string',
2242and `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.
2307Find the longest match in accord with Posix regular expression rules. 2298Find the longest match in accord with Posix regular expression rules.
2308Set point to the beginning of the occurrence found, and return point. 2299This function is almost identical to `posix-search-forward', except that
2309An optional second argument bounds the search; it is a buffer position. 2300by 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 2301COUNT also indicates exactly the opposite searching direction.
2311 means search to the beginning of the accessible portion of the buffer. 2302See `posix-search-forward' for details.
2312Optional 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.
2314Optional 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.
2318With 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
2322Search case-sensitivity is determined by the value of the variable
2323`case-fold-search', which see.
2324 2303
2325See also the functions `match-beginning', `match-end', `match-string', 2304Note that searching backwards may give a shorter match than expected,
2326and `replace-match'. */) 2305because REGEXP is still matched in the forward direction. See Info
2306anchor `(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.
2335Find the longest match in accord with Posix regular expression rules. 2315Find the longest match in accord with Posix regular expression rules.
2336Set point to the end of the occurrence found, and return point. 2316Set point to the end of the occurrence found, and return point.
2337An optional second argument bounds the search; it is a buffer position. 2317The 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
2340Optional 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. 2321The optional third argument NOERROR indicates how errors are handled
2342Optional 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. 2325The optional fourth argument COUNT is a number that indicates the
2346With 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.
2330With 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
2350Search case-sensitivity is determined by the value of the variable 2334Search case-sensitivity is determined by the value of the variable
2351`case-fold-search', which see. 2335`case-fold-search', which see.