]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/searching.texi
* doc/lispref/searching.texi (Regexp Backslash): Add index entry.
[gnu-emacs] / doc / lispref / searching.texi
index 6cc7d451a6e08dbc15ece353b5d6bbb99e6011fc..5bda1940b511dfc10d06d59444830fbc7600d8f5 100644 (file)
@@ -1,7 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2012
 @c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../../info/searching
@@ -50,7 +49,6 @@ This function searches forward from point for an exact match for
 @var{string}.  If successful, it sets point to the end of the occurrence
 found, and returns the new value of point.  If no match is found, the
 value and side effects depend on @var{noerror} (see below).
-@c Emacs 19 feature
 
 In the following example, point is initially at the beginning of the
 line.  Then @code{(search-forward "fox")} moves point after the last
@@ -92,18 +90,21 @@ The argument @var{noerror} only affects valid searches which fail to
 find a match.  Invalid arguments cause errors regardless of
 @var{noerror}.
 
-If @var{repeat} is supplied (it must be a positive number), then the
-search is repeated that many times (each time starting at the end of the
-previous time's match).  If these successive searches succeed, the
-function succeeds, moving point and returning its new value.  Otherwise
-the search fails, with results depending on the value of
-@var{noerror}, as described above.
+If @var{repeat} is a positive number @var{n}, it serves as a repeat
+count: the search is repeated @var{n} times, each time starting at the
+end of the previous time's match.  If these successive searches
+succeed, the function succeeds, moving point and returning its new
+value.  Otherwise the search fails, with results depending on the
+value of @var{noerror}, as described above.  If @var{repeat} is a
+negative number -@var{n}, it serves as a repeat count of @var{n} for a
+search in the opposite (backward) direction.
 @end deffn
 
 @deffn Command search-backward string &optional limit noerror repeat
 This function searches backward from point for @var{string}.  It is
-just like @code{search-forward} except that it searches backwards and
-leaves point at the beginning of the match.
+like @code{search-forward}, except that it searches backwards rather
+than forwards.  Backward searches leave point at the beginning of the
+match.
 @end deffn
 
 @deffn Command word-search-forward string &optional limit noerror repeat
@@ -386,15 +387,6 @@ matches both @samp{]} and @samp{-}.
 To include @samp{^} in a character alternative, put it anywhere but at
 the beginning.
 
-The beginning and end of a range of multibyte characters must be in
-the same character set (@pxref{Character Sets}).  Thus,
-@code{"[\x8e0-\x97c]"} is invalid because character 0x8e0 (@samp{a}
-with grave accent) is in the Emacs character set for Latin-1 but the
-character 0x97c (@samp{u} with diaeresis) is in the Emacs character
-set for Latin-2.  (We use Lisp string syntax to write that example,
-and a few others in the next few paragraphs, in order to include hex
-escape sequences in them.)
-
 If a range starts with a unibyte character @var{c} and ends with a
 multibyte character @var{c2}, the range is divided into two parts: one
 is @samp{@var{c}..?\377}, the other is @samp{@var{c1}..@var{c2}}, where
@@ -567,6 +559,7 @@ through @samp{f} and @samp{A} through @samp{F}.
 
 @node Regexp Backslash
 @subsubsection Backslash Constructs in Regular Expressions
+@cindex backslash in regular expressions
 
   For the most part, @samp{\} followed by any character matches only
 that character.  However, there are several exceptions: certain
@@ -727,11 +720,15 @@ the characters that stand for them.
 @cindex @samp{\S} in regexp
 matches any character whose syntax is not @var{code}.
 
+@cindex category, regexp search for
 @item \c@var{c}
 matches any character whose category is @var{c}.  Here @var{c} is a
 character that represents a category: thus, @samp{c} for Chinese
 characters or @samp{g} for Greek characters in the standard category
-table.
+table.  You can see the list of all the currently defined categories
+with @kbd{M-x describe-categories @key{RET}}.  You can also define
+your own categories in addition to the standard ones using the
+@code{define-category} function (@pxref{Categories}).
 
 @item \C@var{c}
 matches any character whose category is not @var{c}.
@@ -1217,6 +1214,12 @@ search you wish to refer back to and the use of the match data.  If you
 can't avoid another intervening search, you must save and restore the
 match data around it, to prevent it from being overwritten.
 
+  Notice that all functions are allowed to overwrite the match data
+unless they're explicitly documented not to do so.  A consequence is
+that functions that are run implicitly in the background
+(@pxref{Timers}, and @ref{Idle Timers}) should likely save and restore
+the match data explicitly.
+
 @menu
 * Replacing Match::       Replacing a substring that was matched.
 * Simple Match Data::     Accessing single items of match data,
@@ -1831,7 +1834,3 @@ values of the variables @code{sentence-end-double-space}
 @code{sentence-end-without-period} and
 @code{sentence-end-without-space}.
 @end defun
-
-@ignore
-   arch-tag: c2573ca2-18aa-4839-93b8-924043ef831f
-@end ignore