From 069fc05bd5fabdd5971e2c5230a8586248fb7f38 Mon Sep 17 00:00:00 2001 From: Stephen Berman Date: Tue, 12 Jul 2016 22:11:22 +0200 Subject: 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. --- src/search.c | 85 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 26 deletions(-) (limited to 'src/search.c') 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, doc: /* Search backward from point for STRING. Set point to the beginning of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. -The match found must not extend before that position. + The match found must not begin before that position. A value of nil + means search to the beginning of the accessible portion of the buffer. Optional third argument, if t, means if fail just return nil (no error). - If not nil and not t, position at limit of search and return nil. -Optional fourth argument COUNT, if non-nil, means to search for COUNT - successive occurrences. If COUNT is negative, search forward, - instead of backward, for -COUNT occurrences. + If not nil and not t, position at limit of search and return nil. +Optional fourth argument COUNT, if a positive number, means to search + for COUNT successive occurrences. If COUNT is negative, search + forward, instead of backward, for -COUNT occurrences. A value of + nil means the same as 1. +With COUNT positive, the match found is the COUNTth to last one (or + last, if COUNT is 1 or nil) in the buffer located entirely before + the origin of the search; correspondingly with COUNT negative. Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. @@ -2184,13 +2189,17 @@ DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ", doc: /* Search forward from point for STRING. Set point to the end of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. -The match found must not extend after that position. A value of nil is - equivalent to (point-max). + The match found must not end after that position. A value of nil + means search to the end of the accessible portion of the buffer. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. -Optional fourth argument COUNT, if non-nil, means to search for COUNT - successive occurrences. If COUNT is negative, search backward, - instead of forward, for -COUNT occurrences. +Optional fourth argument COUNT, if a positive number, means to search + for COUNT successive occurrences. If COUNT is negative, search + backward, instead of forward, for -COUNT occurrences. A value of + nil means the same as 1. +With COUNT positive, the match found is the COUNTth one (or first, + if COUNT is 1 or nil) in the buffer located entirely after the + origin of the search; correspondingly with COUNT negative. Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. @@ -2204,14 +2213,19 @@ See also the functions `match-beginning', `match-end' and `replace-match'. */) DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, "sRE search backward: ", doc: /* Search backward from point for match for regular expression REGEXP. -Set point to the beginning of the match, and return point. -The match found is the one starting last in the buffer -and yet ending before the origin of the search. +Set point to the beginning of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. -The match found must start at or after that position. + The match found must not begin before that position. A value of nil + means search to the beginning of the accessible portion of the buffer. Optional third argument, if t, means if fail just return nil (no error). - If not nil and not t, move to limit of search and return nil. -Optional fourth argument is repeat count--search for successive occurrences. + If not nil and not t, position at limit of search and return nil. +Optional fourth argument COUNT, if a positive number, means to search + for COUNT successive occurrences. If COUNT is negative, search + forward, instead of backward, for -COUNT occurrences. A value of + nil means the same as 1. +With COUNT positive, the match found is the COUNTth to last one (or + last, if COUNT is 1 or nil) in the buffer located entirely before + the origin of the search; correspondingly with COUNT negative. Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. @@ -2228,10 +2242,17 @@ DEFUN ("re-search-forward", Fre_search_forward, Sre_search_forward, 1, 4, doc: /* Search forward from point for regular expression REGEXP. Set point to the end of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. -The match found must not extend after that position. + The match found must not end after that position. A value of nil + means search to the end of the accessible portion of the buffer. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. -Optional fourth argument is repeat count--search for successive occurrences. +Optional fourth argument COUNT, if a positive number, means to search + for COUNT successive occurrences. If COUNT is negative, search + backward, instead of forward, for -COUNT occurrences. A value of + nil means the same as 1. +With COUNT positive, the match found is the COUNTth one (or first, + if COUNT is 1 or nil) in the buffer located entirely after the + origin of the search; correspondingly with COUNT negative. Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. @@ -2247,14 +2268,19 @@ DEFUN ("posix-search-backward", Fposix_search_backward, Sposix_search_backward, "sPosix search backward: ", doc: /* Search backward from point for match for regular expression REGEXP. Find the longest match in accord with Posix regular expression rules. -Set point to the beginning of the match, and return point. -The match found is the one starting last in the buffer -and yet ending before the origin of the search. +Set point to the beginning of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. -The match found must start at or after that position. + The match found must not begin before that position. A value of nil + means search to the beginning of the accessible portion of the buffer. Optional third argument, if t, means if fail just return nil (no error). - If not nil and not t, move to limit of search and return nil. -Optional fourth argument is repeat count--search for successive occurrences. + If not nil and not t, position at limit of search and return nil. +Optional fourth argument COUNT, if a positive number, means to search + for COUNT successive occurrences. If COUNT is negative, search + forward, instead of backward, for -COUNT occurrences. A value of + nil means the same as 1. +With COUNT positive, the match found is the COUNTth to last one (or + last, if COUNT is 1 or nil) in the buffer located entirely before + the origin of the search; correspondingly with COUNT negative. Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. @@ -2272,10 +2298,17 @@ DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1, Find the longest match in accord with Posix regular expression rules. Set point to the end of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. -The match found must not extend after that position. + The match found must not end after that position. A value of nil + means search to the end of the accessible portion of the buffer. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. -Optional fourth argument is repeat count--search for successive occurrences. +Optional fourth argument COUNT, if a positive number, means to search + for COUNT successive occurrences. If COUNT is negative, search + backward, instead of forward, for -COUNT occurrences. A value of + nil means the same as 1. +With COUNT positive, the match found is the COUNTth one (or first, + if COUNT is 1 or nil) in the buffer located entirely after the + origin of the search; correspondingly with COUNT negative. Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. -- cgit v1.2.1