aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/emacs/search.texi12
-rw-r--r--doc/lispref/searching.texi74
-rw-r--r--lisp/emacs-lisp/lisp-mode.el2
-rw-r--r--lisp/textmodes/picture.el2
4 files changed, 45 insertions, 45 deletions
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index 45378d95f65..2a816221235 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -950,8 +950,8 @@ features used mainly in Lisp programs.
950@dfn{special constructs} and the rest are @dfn{ordinary}. An ordinary 950@dfn{special constructs} and the rest are @dfn{ordinary}. An ordinary
951character matches that same character and nothing else. The special 951character matches that same character and nothing else. The special
952characters are @samp{$^.*+?[\}. The character @samp{]} is special if 952characters are @samp{$^.*+?[\}. The character @samp{]} is special if
953it ends a character alternative (see below). The character @samp{-} 953it ends a bracket expression (see below). The character @samp{-}
954is special inside a character alternative. Any other character 954is special inside a bracket expression. Any other character
955appearing in a regular expression is ordinary, unless a @samp{\} 955appearing in a regular expression is ordinary, unless a @samp{\}
956precedes it. (When you use regular expressions in a Lisp program, 956precedes it. (When you use regular expressions in a Lisp program,
957each @samp{\} must be doubled, see the example near the end of this 957each @samp{\} must be doubled, see the example near the end of this
@@ -1033,11 +1033,11 @@ you search for @samp{a.*?$} against the text @samp{abbab} followed by
1033a newline, it matches the whole string. Since it @emph{can} match 1033a newline, it matches the whole string. Since it @emph{can} match
1034starting at the first @samp{a}, it does. 1034starting at the first @samp{a}, it does.
1035 1035
1036@cindex bracket expression
1036@cindex set of alternative characters, in regular expressions 1037@cindex set of alternative characters, in regular expressions
1037@cindex character set, in regular expressions 1038@cindex character set, in regular expressions
1038@item @kbd{[ @dots{} ]} 1039@item @kbd{[ @dots{} ]}
1039is a @dfn{set of alternative characters}, or a @dfn{character set}, 1040is a @dfn{bracket expression}, which matches one of a set of characters.
1040beginning with @samp{[} and terminated by @samp{]}.
1041 1041
1042In the simplest case, the characters between the two brackets are what 1042In the simplest case, the characters between the two brackets are what
1043this set can match. Thus, @samp{[ad]} matches either one @samp{a} or 1043this set can match. Thus, @samp{[ad]} matches either one @samp{a} or
@@ -1057,7 +1057,7 @@ Greek letters.
1057@cindex character classes, in regular expressions 1057@cindex character classes, in regular expressions
1058You can also include certain special @dfn{character classes} in a 1058You can also include certain special @dfn{character classes} in a
1059character set. A @samp{[:} and balancing @samp{:]} enclose a 1059character set. A @samp{[:} and balancing @samp{:]} enclose a
1060character class inside a set of alternative characters. For instance, 1060character class inside a bracket expression. For instance,
1061@samp{[[:alnum:]]} matches any letter or digit. @xref{Char Classes,,, 1061@samp{[[:alnum:]]} matches any letter or digit. @xref{Char Classes,,,
1062elisp, The Emacs Lisp Reference Manual}, for a list of character 1062elisp, The Emacs Lisp Reference Manual}, for a list of character
1063classes. 1063classes.
@@ -1125,7 +1125,7 @@ no preceding expression on which the @samp{*} can act. It is poor practice
1125to depend on this behavior; it is better to quote the special character anyway, 1125to depend on this behavior; it is better to quote the special character anyway,
1126regardless of where it appears. 1126regardless of where it appears.
1127 1127
1128As a @samp{\} is not special inside a set of alternative characters, it can 1128As a @samp{\} is not special inside a bracket expression, it can
1129never remove the special meaning of @samp{-}, @samp{^} or @samp{]}. 1129never remove the special meaning of @samp{-}, @samp{^} or @samp{]}.
1130You should not quote these characters when they have no special 1130You should not quote these characters when they have no special
1131meaning. This would not clarify anything, since backslashes 1131meaning. This would not clarify anything, since backslashes
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index 608abae762c..28230cea643 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -278,10 +278,10 @@ character is a simple regular expression that matches that character
278and nothing else. The special characters are @samp{.}, @samp{*}, 278and nothing else. The special characters are @samp{.}, @samp{*},
279@samp{+}, @samp{?}, @samp{[}, @samp{^}, @samp{$}, and @samp{\}; no new 279@samp{+}, @samp{?}, @samp{[}, @samp{^}, @samp{$}, and @samp{\}; no new
280special characters will be defined in the future. The character 280special characters will be defined in the future. The character
281@samp{]} is special if it ends a character alternative (see later). 281@samp{]} is special if it ends a bracket expression (see later).
282The character @samp{-} is special inside a character alternative. A 282The character @samp{-} is special inside a bracket expression. A
283@samp{[:} and balancing @samp{:]} enclose a character class inside a 283@samp{[:} and balancing @samp{:]} enclose a character class inside a
284character alternative. Any other character appearing in a regular 284bracket expression. Any other character appearing in a regular
285expression is ordinary, unless a @samp{\} precedes it. 285expression is ordinary, unless a @samp{\} precedes it.
286 286
287 For example, @samp{f} is not a special character, so it is ordinary, and 287 For example, @samp{f} is not a special character, so it is ordinary, and
@@ -374,19 +374,19 @@ expression @samp{c[ad]*?a}, applied to that same string, matches just
374permits the whole expression to match is @samp{d}.) 374permits the whole expression to match is @samp{d}.)
375 375
376@item @samp{[ @dots{} ]} 376@item @samp{[ @dots{} ]}
377@cindex character alternative (in regexp) 377@cindex bracket expression (in regexp)
378@cindex @samp{[} in regexp 378@cindex @samp{[} in regexp
379@cindex @samp{]} in regexp 379@cindex @samp{]} in regexp
380is a @dfn{character alternative}, which begins with @samp{[} and is 380is a @dfn{bracket expression}, which begins with @samp{[} and is
381terminated by @samp{]}. In the simplest case, the characters between 381terminated by @samp{]}. In the simplest case, the characters between
382the two brackets are what this character alternative can match. 382the two brackets are what this bracket expression can match.
383 383
384Thus, @samp{[ad]} matches either one @samp{a} or one @samp{d}, and 384Thus, @samp{[ad]} matches either one @samp{a} or one @samp{d}, and
385@samp{[ad]*} matches any string composed of just @samp{a}s and @samp{d}s 385@samp{[ad]*} matches any string composed of just @samp{a}s and @samp{d}s
386(including the empty string). It follows that @samp{c[ad]*r} 386(including the empty string). It follows that @samp{c[ad]*r}
387matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc. 387matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc.
388 388
389You can also include character ranges in a character alternative, by 389You can also include character ranges in a bracket expression, by
390writing the starting and ending characters with a @samp{-} between them. 390writing the starting and ending characters with a @samp{-} between them.
391Thus, @samp{[a-z]} matches any lower-case @acronym{ASCII} letter. 391Thus, @samp{[a-z]} matches any lower-case @acronym{ASCII} letter.
392Ranges may be intermixed freely with individual characters, as in 392Ranges may be intermixed freely with individual characters, as in
@@ -395,7 +395,7 @@ or @samp{$}, @samp{%} or period. However, the ending character of one
395range should not be the starting point of another one; for example, 395range should not be the starting point of another one; for example,
396@samp{[a-m-z]} should be avoided. 396@samp{[a-m-z]} should be avoided.
397 397
398A character alternative can also specify named character classes 398A bracket expression can also specify named character classes
399(@pxref{Char Classes}). For example, @samp{[[:ascii:]]} matches any 399(@pxref{Char Classes}). For example, @samp{[[:ascii:]]} matches any
400@acronym{ASCII} character. Using a character class is equivalent to 400@acronym{ASCII} character. Using a character class is equivalent to
401mentioning each of the characters in that class; but the latter is not 401mentioning each of the characters in that class; but the latter is not
@@ -404,9 +404,9 @@ different characters. A character class should not appear as the
404lower or upper bound of a range. 404lower or upper bound of a range.
405 405
406The usual regexp special characters are not special inside a 406The usual regexp special characters are not special inside a
407character alternative. A completely different set of characters is 407bracket expression. A completely different set of characters is
408special: @samp{]}, @samp{-} and @samp{^}. 408special: @samp{]}, @samp{-} and @samp{^}.
409To include @samp{]} in a character alternative, put it at the 409To include @samp{]} in a bracket expression, put it at the
410beginning. To include @samp{^}, put it anywhere but at the beginning. 410beginning. To include @samp{^}, put it anywhere but at the beginning.
411To include @samp{-}, put it at the end. Thus, @samp{[]^-]} matches 411To include @samp{-}, put it at the end. Thus, @samp{[]^-]} matches
412all three of these special characters. You cannot use @samp{\} to 412all three of these special characters. You cannot use @samp{\} to
@@ -444,7 +444,7 @@ characters and raw 8-bit bytes, but not non-ASCII characters. This
444feature is intended for searching text in unibyte buffers and strings. 444feature is intended for searching text in unibyte buffers and strings.
445@end enumerate 445@end enumerate
446 446
447Some kinds of character alternatives are not the best style even 447Some kinds of bracket expressions are not the best style even
448though they have a well-defined meaning in Emacs. They include: 448though they have a well-defined meaning in Emacs. They include:
449 449
450@enumerate 450@enumerate
@@ -458,7 +458,7 @@ Unicode character escapes can help here; for example, for most programmers
458@samp{[ก-ฺ฿-๛]} is less clear than @samp{[\u0E01-\u0E3A\u0E3F-\u0E5B]}. 458@samp{[ก-ฺ฿-๛]} is less clear than @samp{[\u0E01-\u0E3A\u0E3F-\u0E5B]}.
459 459
460@item 460@item
461Although a character alternative can include duplicates, it is better 461Although a bracket expression can include duplicates, it is better
462style to avoid them. For example, @samp{[XYa-yYb-zX]} is less clear 462style to avoid them. For example, @samp{[XYa-yYb-zX]} is less clear
463than @samp{[XYa-z]}. 463than @samp{[XYa-z]}.
464 464
@@ -469,30 +469,30 @@ is simpler to list the characters. For example,
469than @samp{[ij]}, and @samp{[i-k]} is less clear than @samp{[ijk]}. 469than @samp{[ij]}, and @samp{[i-k]} is less clear than @samp{[ijk]}.
470 470
471@item 471@item
472Although a @samp{-} can appear at the beginning of a character 472Although a @samp{-} can appear at the beginning of a bracket
473alternative or as the upper bound of a range, it is better style to 473expression or as the upper bound of a range, it is better style to
474put @samp{-} by itself at the end of a character alternative. For 474put @samp{-} by itself at the end of a bracket expression. For
475example, although @samp{[-a-z]} is valid, @samp{[a-z-]} is better 475example, although @samp{[-a-z]} is valid, @samp{[a-z-]} is better
476style; and although @samp{[*--]} is valid, @samp{[*+,-]} is clearer. 476style; and although @samp{[*--]} is valid, @samp{[*+,-]} is clearer.
477@end enumerate 477@end enumerate
478 478
479@item @samp{[^ @dots{} ]} 479@item @samp{[^ @dots{} ]}
480@cindex @samp{^} in regexp 480@cindex @samp{^} in regexp
481@samp{[^} begins a @dfn{complemented character alternative}. This 481@samp{[^} begins a @dfn{complemented bracket expression}. This
482matches any character except the ones specified. Thus, 482matches any character except the ones specified. Thus,
483@samp{[^a-z0-9A-Z]} matches all characters @emph{except} ASCII letters and 483@samp{[^a-z0-9A-Z]} matches all characters @emph{except} ASCII letters and
484digits. 484digits.
485 485
486@samp{^} is not special in a character alternative unless it is the first 486@samp{^} is not special in a bracket expression unless it is the first
487character. The character following the @samp{^} is treated as if it 487character. The character following the @samp{^} is treated as if it
488were first (in other words, @samp{-} and @samp{]} are not special there). 488were first (in other words, @samp{-} and @samp{]} are not special there).
489 489
490A complemented character alternative can match a newline, unless newline is 490A complemented bracket expression can match a newline, unless newline is
491mentioned as one of the characters not to match. This is in contrast to 491mentioned as one of the characters not to match. This is in contrast to
492the handling of regexps in programs such as @code{grep}. 492the handling of regexps in programs such as @code{grep}.
493 493
494You can specify named character classes, just like in character 494You can specify named character classes, just like in bracket
495alternatives. For instance, @samp{[^[:ascii:]]} matches any 495expressions. For instance, @samp{[^[:ascii:]]} matches any
496non-@acronym{ASCII} character. @xref{Char Classes}. 496non-@acronym{ASCII} character. @xref{Char Classes}.
497 497
498@item @samp{^} 498@item @samp{^}
@@ -556,7 +556,7 @@ that matches only empty strings, as Emacs has bugs in this area.
556For example, it is unwise to use @samp{\b*}, which can be omitted 556For example, it is unwise to use @samp{\b*}, which can be omitted
557without changing the documented meaning of the regular expression. 557without changing the documented meaning of the regular expression.
558 558
559As a @samp{\} is not special inside a character alternative, it can 559As a @samp{\} is not special inside a bracket expression, it can
560never remove the special meaning of @samp{-}, @samp{^} or @samp{]}. 560never remove the special meaning of @samp{-}, @samp{^} or @samp{]}.
561You should not quote these characters when they have no special 561You should not quote these characters when they have no special
562meaning. This would not clarify anything, since backslashes 562meaning. This would not clarify anything, since backslashes
@@ -565,23 +565,23 @@ special meaning, as in @samp{[^\]} (@code{"[^\\]"} for Lisp string
565syntax), which matches any single character except a backslash. 565syntax), which matches any single character except a backslash.
566 566
567In practice, most @samp{]} that occur in regular expressions close a 567In practice, most @samp{]} that occur in regular expressions close a
568character alternative and hence are special. However, occasionally a 568bracket expression and hence are special. However, occasionally a
569regular expression may try to match a complex pattern of literal 569regular expression may try to match a complex pattern of literal
570@samp{[} and @samp{]}. In such situations, it sometimes may be 570@samp{[} and @samp{]}. In such situations, it sometimes may be
571necessary to carefully parse the regexp from the start to determine 571necessary to carefully parse the regexp from the start to determine
572which square brackets enclose a character alternative. For example, 572which square brackets enclose a bracket expression. For example,
573@samp{[^][]]} consists of the complemented character alternative 573@samp{[^][]]} consists of the complemented bracket expression
574@samp{[^][]} (which matches any single character that is not a square 574@samp{[^][]} (which matches any single character that is not a square
575bracket), followed by a literal @samp{]}. 575bracket), followed by a literal @samp{]}.
576 576
577The exact rules are that at the beginning of a regexp, @samp{[} is 577The exact rules are that at the beginning of a regexp, @samp{[} is
578special and @samp{]} not. This lasts until the first unquoted 578special and @samp{]} not. This lasts until the first unquoted
579@samp{[}, after which we are in a character alternative; @samp{[} is 579@samp{[}, after which we are in a bracket expression; @samp{[} is
580no longer special (except when it starts a character class) but @samp{]} 580no longer special (except when it starts a character class) but @samp{]}
581is special, unless it immediately follows the special @samp{[} or that 581is special, unless it immediately follows the special @samp{[} or that
582@samp{[} followed by a @samp{^}. This lasts until the next special 582@samp{[} followed by a @samp{^}. This lasts until the next special
583@samp{]} that does not end a character class. This ends the character 583@samp{]} that does not end a character class. This ends the bracket
584alternative and restores the ordinary syntax of regular expressions; 584expression and restores the ordinary syntax of regular expressions;
585an unquoted @samp{[} is special again and a @samp{]} not. 585an unquoted @samp{[} is special again and a @samp{]} not.
586 586
587@node Char Classes 587@node Char Classes
@@ -592,8 +592,8 @@ an unquoted @samp{[} is special again and a @samp{]} not.
592@cindex alpha character class, regexp 592@cindex alpha character class, regexp
593@cindex xdigit character class, regexp 593@cindex xdigit character class, regexp
594 594
595 Below is a table of the classes you can use in a character 595 Below is a table of the classes you can use in a bracket
596alternative, and what they mean. Note that the @samp{[} and @samp{]} 596expression, and what they mean. Note that the @samp{[} and @samp{]}
597characters that enclose the class name are part of the name, so a 597characters that enclose the class name are part of the name, so a
598regular expression using these classes needs one more pair of 598regular expression using these classes needs one more pair of
599brackets. For example, a regular expression matching a sequence of 599brackets. For example, a regular expression matching a sequence of
@@ -920,7 +920,7 @@ with a symbol-constituent character.
920 920
921@kindex invalid-regexp 921@kindex invalid-regexp
922 Not every string is a valid regular expression. For example, a string 922 Not every string is a valid regular expression. For example, a string
923that ends inside a character alternative without a terminating @samp{]} 923that ends inside a bracket expression without a terminating @samp{]}
924is invalid, and so is a string that ends with a single @samp{\}. If 924is invalid, and so is a string that ends with a single @samp{\}. If
925an invalid regular expression is passed to any of the search functions, 925an invalid regular expression is passed to any of the search functions,
926an @code{invalid-regexp} error is signaled. 926an @code{invalid-regexp} error is signaled.
@@ -957,7 +957,7 @@ deciphered as follows:
957 957
958@table @code 958@table @code
959@item [.?!] 959@item [.?!]
960The first part of the pattern is a character alternative that matches 960The first part of the pattern is a bracket expression that matches
961any one of three characters: period, question mark, and exclamation 961any one of three characters: period, question mark, and exclamation
962mark. The match must begin with one of these three characters. (This 962mark. The match must begin with one of these three characters. (This
963is one point where the new default regexp used by Emacs differs from 963is one point where the new default regexp used by Emacs differs from
@@ -969,7 +969,7 @@ The second part of the pattern matches any closing braces and quotation
969marks, zero or more of them, that may follow the period, question mark 969marks, zero or more of them, that may follow the period, question mark
970or exclamation mark. The @code{\"} is Lisp syntax for a double-quote in 970or exclamation mark. The @code{\"} is Lisp syntax for a double-quote in
971a string. The @samp{*} at the end indicates that the immediately 971a string. The @samp{*} at the end indicates that the immediately
972preceding regular expression (a character alternative, in this case) may be 972preceding regular expression (a bracket expression, in this case) may be
973repeated zero or more times. 973repeated zero or more times.
974 974
975@item \\($\\|@ $\\|\t\\|@ @ \\) 975@item \\($\\|@ $\\|\t\\|@ @ \\)
@@ -1920,7 +1920,7 @@ attempts. Other zero-width assertions may also bring benefits by
1920causing a match to fail early. 1920causing a match to fail early.
1921 1921
1922@item 1922@item
1923Avoid or-patterns in favor of character alternatives: write 1923Avoid or-patterns in favor of bracket expressions: write
1924@samp{[ab]} instead of @samp{a\|b}. Recall that @samp{\s-} and @samp{\sw} 1924@samp{[ab]} instead of @samp{a\|b}. Recall that @samp{\s-} and @samp{\sw}
1925are equivalent to @samp{[[:space:]]} and @samp{[[:word:]]}, respectively. 1925are equivalent to @samp{[[:space:]]} and @samp{[[:word:]]}, respectively.
1926 1926
@@ -3012,7 +3012,7 @@ but does not support all the Emacs escapes.
3012@item 3012@item
3013In POSIX BREs, it is an implementation option whether @samp{^} is special 3013In POSIX BREs, it is an implementation option whether @samp{^} is special
3014after @samp{\(}; GNU @command{grep} treats it like Emacs does. 3014after @samp{\(}; GNU @command{grep} treats it like Emacs does.
3015In POSIX EREs, @samp{^} is always special outside of character alternatives, 3015In POSIX EREs, @samp{^} is always special outside of bracket expressions,
3016which means the ERE @samp{x^} never matches. 3016which means the ERE @samp{x^} never matches.
3017In Emacs regular expressions, @samp{^} is special only at the 3017In Emacs regular expressions, @samp{^} is special only at the
3018beginning of the regular expression, or after @samp{\(}, @samp{\(?:} 3018beginning of the regular expression, or after @samp{\(}, @samp{\(?:}
@@ -3021,7 +3021,7 @@ or @samp{\|}.
3021@item 3021@item
3022In POSIX BREs, it is an implementation option whether @samp{$} is special 3022In POSIX BREs, it is an implementation option whether @samp{$} is special
3023before @samp{\)}; GNU @command{grep} treats it like Emacs does. 3023before @samp{\)}; GNU @command{grep} treats it like Emacs does.
3024In POSIX EREs, @samp{$} is always special outside of character alternatives, 3024In POSIX EREs, @samp{$} is always special outside of bracket expressions,
3025which means the ERE @samp{$x} never matches. 3025which means the ERE @samp{$x} never matches.
3026In Emacs regular expressions, @samp{$} is special only at the 3026In Emacs regular expressions, @samp{$} is special only at the
3027end of the regular expression, or before @samp{\)} or @samp{\|}. 3027end of the regular expression, or before @samp{\)} or @samp{\|}.
@@ -3049,8 +3049,8 @@ character classes @samp{[:ascii:]}, @samp{[:multibyte:]},
3049@samp{[:nonascii:]}, @samp{[:unibyte:]}, and @samp{[:word:]}. 3049@samp{[:nonascii:]}, @samp{[:unibyte:]}, and @samp{[:word:]}.
3050 3050
3051@item 3051@item
3052BRE and ERE alternatives can contain collating symbols and equivalence 3052BREs and EREs can contain collating symbols and equivalence
3053class expressions, e.g., @samp{[[.ch.]d[=a=]]}. 3053class expressions within bracket expressions, e.g., @samp{[[.ch.]d[=a=]]}.
3054Emacs regular expressions do not support this. 3054Emacs regular expressions do not support this.
3055 3055
3056@item 3056@item
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 9914ededb85..1990630608d 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1453,7 +1453,7 @@ and initial semicolons."
1453 ;; are buffer-local, but we avoid changing them so that they can be set 1453 ;; are buffer-local, but we avoid changing them so that they can be set
1454 ;; to make `forward-paragraph' and friends do something the user wants. 1454 ;; to make `forward-paragraph' and friends do something the user wants.
1455 ;; 1455 ;;
1456 ;; `paragraph-start': The `(' in the character alternative and the 1456 ;; `paragraph-start': The `(' in the bracket expression and the
1457 ;; left-singlequote plus `(' sequence after the \\| alternative prevent 1457 ;; left-singlequote plus `(' sequence after the \\| alternative prevent
1458 ;; sexps and backquoted sexps that follow a docstring from being filled 1458 ;; sexps and backquoted sexps that follow a docstring from being filled
1459 ;; with the docstring. This setting has the consequence of inhibiting 1459 ;; with the docstring. This setting has the consequence of inhibiting
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index 9aa9b72c513..f98c3963b6f 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -383,7 +383,7 @@ Interactively, ARG is the numeric argument, and defaults to 1."
383The syntax for this variable is like the syntax used inside of `[...]' 383The syntax for this variable is like the syntax used inside of `[...]'
384in a regular expression--but without the `[' and the `]'. 384in a regular expression--but without the `[' and the `]'.
385It is NOT a regular expression, and should follow the usual 385It is NOT a regular expression, and should follow the usual
386rules for the contents of a character alternative. 386rules for the contents of a bracket expression.
387It defines a set of \"interesting characters\" to look for when setting 387It defines a set of \"interesting characters\" to look for when setting
388\(or searching for) tab stops, initially \"!-~\" (all printing characters). 388\(or searching for) tab stops, initially \"!-~\" (all printing characters).
389For example, suppose that you are editing a table which is formatted thus: 389For example, suppose that you are editing a table which is formatted thus: