aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Berman2016-07-12 22:11:22 +0200
committerStephen Berman2016-07-12 22:11:22 +0200
commit069fc05bd5fabdd5971e2c5230a8586248fb7f38 (patch)
treed5481fa5874fa9c2a789e62cafefb72d4bef253d /src
parent0a0144a2e15a00b5c3272ad95e62d1d489b453c4 (diff)
downloademacs-069fc05bd5fabdd5971e2c5230a8586248fb7f38.tar.gz
emacs-069fc05bd5fabdd5971e2c5230a8586248fb7f38.zip
Improve documentation of search functions
Make the documentation of the search functions more accurate, complete, and uniform; in particular, extend the description of the effect when the 'count' parameter is a negative number to all of these functions. * src/search.c (Fsearch_backward, Fsearch_forward) (Fre_search_backward, Fre_search_forward) (Fposix_search_backward, Fposix_search_forward): * lisp/isearch.el (word-search-backward, word-search-forward) (word-search-backward-lax, word-search-forward-lax): Improve doc strings as described above. * doc/lispref/searching.texi (String Search, Regexp Search) (POSIX Regexps): Use 'count' instead of 'repeat' as the name of the fourth parameter of the *-search-{forward,backward} functions and improve documentation as described above.
Diffstat (limited to 'src')
-rw-r--r--src/search.c85
1 files changed, 59 insertions, 26 deletions
diff --git a/src/search.c b/src/search.c
index bcdd8f16d0b..5c949ad00a4 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2164,12 +2164,17 @@ DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4,
2164 doc: /* Search backward from point for STRING. 2164 doc: /* Search backward from point for STRING.
2165Set point to the beginning of the occurrence found, and return point. 2165Set point to the beginning of the occurrence found, and return point.
2166An optional second argument bounds the search; it is a buffer position. 2166An optional second argument bounds the search; it is a buffer position.
2167The match found must not extend before that position. 2167 The match found must not begin before that position. A value of nil
2168 means search to the beginning of the accessible portion of the buffer.
2168Optional third argument, if t, means if fail just return nil (no error). 2169Optional third argument, if t, means if fail just return nil (no error).
2169 If not nil and not t, position at limit of search and return nil. 2170 If not nil and not t, position at limit of search and return nil.
2170Optional fourth argument COUNT, if non-nil, means to search for COUNT 2171Optional fourth argument COUNT, if a positive number, means to search
2171 successive occurrences. If COUNT is negative, search forward, 2172 for COUNT successive occurrences. If COUNT is negative, search
2172 instead of backward, for -COUNT occurrences. 2173 forward, instead of backward, for -COUNT occurrences. A value of
2174 nil means the same as 1.
2175With COUNT positive, the match found is the COUNTth to last one (or
2176 last, if COUNT is 1 or nil) in the buffer located entirely before
2177 the origin of the search; correspondingly with COUNT negative.
2173 2178
2174Search case-sensitivity is determined by the value of the variable 2179Search case-sensitivity is determined by the value of the variable
2175`case-fold-search', which see. 2180`case-fold-search', which see.
@@ -2184,13 +2189,17 @@ DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ",
2184 doc: /* Search forward from point for STRING. 2189 doc: /* Search forward from point for STRING.
2185Set point to the end of the occurrence found, and return point. 2190Set point to the end of the occurrence found, and return point.
2186An optional second argument bounds the search; it is a buffer position. 2191An optional second argument bounds the search; it is a buffer position.
2187The match found must not extend after that position. A value of nil is 2192 The match found must not end after that position. A value of nil
2188 equivalent to (point-max). 2193 means search to the end of the accessible portion of the buffer.
2189Optional third argument, if t, means if fail just return nil (no error). 2194Optional third argument, if t, means if fail just return nil (no error).
2190 If not nil and not t, move to limit of search and return nil. 2195 If not nil and not t, move to limit of search and return nil.
2191Optional fourth argument COUNT, if non-nil, means to search for COUNT 2196Optional fourth argument COUNT, if a positive number, means to search
2192 successive occurrences. If COUNT is negative, search backward, 2197 for COUNT successive occurrences. If COUNT is negative, search
2193 instead of forward, for -COUNT occurrences. 2198 backward, instead of forward, for -COUNT occurrences. A value of
2199 nil means the same as 1.
2200With COUNT positive, the match found is the COUNTth one (or first,
2201 if COUNT is 1 or nil) in the buffer located entirely after the
2202 origin of the search; correspondingly with COUNT negative.
2194 2203
2195Search case-sensitivity is determined by the value of the variable 2204Search case-sensitivity is determined by the value of the variable
2196`case-fold-search', which see. 2205`case-fold-search', which see.
@@ -2204,14 +2213,19 @@ See also the functions `match-beginning', `match-end' and `replace-match'. */)
2204DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, 2213DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4,
2205 "sRE search backward: ", 2214 "sRE search backward: ",
2206 doc: /* Search backward from point for match for regular expression REGEXP. 2215 doc: /* Search backward from point for match for regular expression REGEXP.
2207Set point to the beginning of the match, and return point. 2216Set point to the beginning of the occurrence found, and return point.
2208The match found is the one starting last in the buffer
2209and yet ending before the origin of the search.
2210An optional second argument bounds the search; it is a buffer position. 2217An optional second argument bounds the search; it is a buffer position.
2211The match found must start at or after that position. 2218 The match found must not begin before that position. A value of nil
2219 means search to the beginning of the accessible portion of the buffer.
2212Optional 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).
2213 If not nil and not t, move to limit of search and return nil. 2221 If not nil and not t, position at limit of search and return nil.
2214Optional fourth argument is repeat count--search for successive occurrences. 2222Optional fourth argument COUNT, if a positive number, means to search
2223 for COUNT successive occurrences. If COUNT is negative, search
2224 forward, instead of backward, for -COUNT occurrences. A value of
2225 nil means the same as 1.
2226With COUNT positive, the match found is the COUNTth to last one (or
2227 last, if COUNT is 1 or nil) in the buffer located entirely before
2228 the origin of the search; correspondingly with COUNT negative.
2215 2229
2216Search case-sensitivity is determined by the value of the variable 2230Search case-sensitivity is determined by the value of the variable
2217`case-fold-search', which see. 2231`case-fold-search', which see.
@@ -2228,10 +2242,17 @@ DEFUN ("re-search-forward", Fre_search_forward, Sre_search_forward, 1, 4,
2228 doc: /* Search forward from point for regular expression REGEXP. 2242 doc: /* Search forward from point for regular expression REGEXP.
2229Set point to the end of the occurrence found, and return point. 2243Set point to the end of the occurrence found, and return point.
2230An optional second argument bounds the search; it is a buffer position. 2244An optional second argument bounds the search; it is a buffer position.
2231The match found must not extend after that position. 2245 The match found must not end after that position. A value of nil
2246 means search to the end of the accessible portion of the buffer.
2232Optional third argument, if t, means if fail just return nil (no error). 2247Optional 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. 2248 If not nil and not t, move to limit of search and return nil.
2234Optional fourth argument is repeat count--search for successive occurrences. 2249Optional fourth argument COUNT, if a positive number, means to search
2250 for COUNT successive occurrences. If COUNT is negative, search
2251 backward, instead of forward, for -COUNT occurrences. A value of
2252 nil means the same as 1.
2253With COUNT positive, the match found is the COUNTth one (or first,
2254 if COUNT is 1 or nil) in the buffer located entirely after the
2255 origin of the search; correspondingly with COUNT negative.
2235 2256
2236Search case-sensitivity is determined by the value of the variable 2257Search case-sensitivity is determined by the value of the variable
2237`case-fold-search', which see. 2258`case-fold-search', which see.
@@ -2247,14 +2268,19 @@ DEFUN ("posix-search-backward", Fposix_search_backward, Sposix_search_backward,
2247 "sPosix search backward: ", 2268 "sPosix search backward: ",
2248 doc: /* Search backward from point for match for regular expression REGEXP. 2269 doc: /* Search backward from point for match for regular expression REGEXP.
2249Find the longest match in accord with Posix regular expression rules. 2270Find the longest match in accord with Posix regular expression rules.
2250Set point to the beginning of the match, and return point. 2271Set point to the beginning of the occurrence found, and return point.
2251The match found is the one starting last in the buffer
2252and yet ending before the origin of the search.
2253An optional second argument bounds the search; it is a buffer position. 2272An optional second argument bounds the search; it is a buffer position.
2254The match found must start at or after that position. 2273 The match found must not begin before that position. A value of nil
2274 means search to the beginning of the accessible portion of the buffer.
2255Optional third argument, if t, means if fail just return nil (no error). 2275Optional third argument, if t, means if fail just return nil (no error).
2256 If not nil and not t, move to limit of search and return nil. 2276 If not nil and not t, position at limit of search and return nil.
2257Optional fourth argument is repeat count--search for successive occurrences. 2277Optional fourth argument COUNT, if a positive number, means to search
2278 for COUNT successive occurrences. If COUNT is negative, search
2279 forward, instead of backward, for -COUNT occurrences. A value of
2280 nil means the same as 1.
2281With COUNT positive, the match found is the COUNTth to last one (or
2282 last, if COUNT is 1 or nil) in the buffer located entirely before
2283 the origin of the search; correspondingly with COUNT negative.
2258 2284
2259Search case-sensitivity is determined by the value of the variable 2285Search case-sensitivity is determined by the value of the variable
2260`case-fold-search', which see. 2286`case-fold-search', which see.
@@ -2272,10 +2298,17 @@ DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1,
2272Find the longest match in accord with Posix regular expression rules. 2298Find the longest match in accord with Posix regular expression rules.
2273Set point to the end of the occurrence found, and return point. 2299Set point to the end of the occurrence found, and return point.
2274An optional second argument bounds the search; it is a buffer position. 2300An optional second argument bounds the search; it is a buffer position.
2275The match found must not extend after that position. 2301 The match found must not end after that position. A value of nil
2302 means search to the end of the accessible portion of the buffer.
2276Optional third argument, if t, means if fail just return nil (no error). 2303Optional third argument, if t, means if fail just return nil (no error).
2277 If not nil and not t, move to limit of search and return nil. 2304 If not nil and not t, move to limit of search and return nil.
2278Optional fourth argument is repeat count--search for successive occurrences. 2305Optional fourth argument COUNT, if a positive number, means to search
2306 for COUNT successive occurrences. If COUNT is negative, search
2307 backward, instead of forward, for -COUNT occurrences. A value of
2308 nil means the same as 1.
2309With COUNT positive, the match found is the COUNTth one (or first,
2310 if COUNT is 1 or nil) in the buffer located entirely after the
2311 origin of the search; correspondingly with COUNT negative.
2279 2312
2280Search case-sensitivity is determined by the value of the variable 2313Search case-sensitivity is determined by the value of the variable
2281`case-fold-search', which see. 2314`case-fold-search', which see.