Mercurial > emacs
comparison man/search.texi @ 37235:a60e4b9d5ba3
Mention there are other search-terminating Meta chars.
Add xref for baud-rate.
Explain why ^ in set must not be first.
Clarify complemented set example.
Clarify \s syntax characters and add xref.
Update sentence-end example.
Document M-c in isearch.
Clarify query-replace preserving case.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 06 Apr 2001 08:29:10 +0000 |
parents | 6dee6cc113a5 |
children | 2f80188cbbd6 |
comparison
equal
deleted
inserted
replaced
37234:d293251ba14e | 37235:a60e4b9d5ba3 |
---|---|
68 @kbd{C-g} as described below. | 68 @kbd{C-g} as described below. |
69 | 69 |
70 When you are satisfied with the place you have reached, you can type | 70 When you are satisfied with the place you have reached, you can type |
71 @key{RET}, which stops searching, leaving the cursor where the search | 71 @key{RET}, which stops searching, leaving the cursor where the search |
72 brought it. Also, any command not specially meaningful in searches | 72 brought it. Also, any command not specially meaningful in searches |
73 stops the searching and is then executed. Thus, typing @kbd{C-a} would | 73 stops the searching and is then executed. Thus, typing @kbd{C-a} |
74 exit the search and then move to the beginning of the line. @key{RET} | 74 would exit the search and then move to the beginning of the line. |
75 is necessary only if the next command you want to type is a printing | 75 @key{RET} is necessary only if the next command you want to type is a |
76 character, @key{DEL}, @key{RET}, or another control character that is | 76 printing character, @key{DEL}, @key{RET}, or another character that is |
77 special within searches (@kbd{C-q}, @kbd{C-w}, @kbd{C-r}, @kbd{C-s}, | 77 special within searches (@kbd{C-q}, @kbd{C-w}, @kbd{C-r}, @kbd{C-s}, |
78 @kbd{C-y}, @kbd{M-y}, @kbd{M-r}, or @kbd{M-s}). | 78 @kbd{C-y}, @kbd{M-y}, @kbd{M-r}, @kbd{M-s}, and some other |
79 meta-characters). | |
79 | 80 |
80 Sometimes you search for @samp{FOO} and find it, but not the one you | 81 Sometimes you search for @samp{FOO} and find it, but not the one you |
81 expected to find. There was a second @samp{FOO} that you forgot | 82 expected to find. There was a second @samp{FOO} that you forgot |
82 about, before the one you were aiming for. In this event, type | 83 about, before the one you were aiming for. In this event, type |
83 another @kbd{C-s} to move to the next occurrence of the search string. | 84 another @kbd{C-s} to move to the next occurrence of the search string. |
234 its new position of point. | 235 its new position of point. |
235 | 236 |
236 @vindex search-slow-speed | 237 @vindex search-slow-speed |
237 The slow terminal style of display is used when the terminal baud rate is | 238 The slow terminal style of display is used when the terminal baud rate is |
238 less than or equal to the value of the variable @code{search-slow-speed}, | 239 less than or equal to the value of the variable @code{search-slow-speed}, |
239 initially 1200. | 240 initially 1200. See @code{baud-rate} in @ref{Display Custom}. |
240 | 241 |
241 @vindex search-slow-window-lines | 242 @vindex search-slow-window-lines |
242 The number of lines to use in slow terminal search display is controlled | 243 The number of lines to use in slow terminal search display is controlled |
243 by the variable @code{search-slow-window-lines}. Its normal value is 1. | 244 by the variable @code{search-slow-window-lines}. Its normal value is 1. |
244 | 245 |
501 include a @samp{-}, write @samp{-} as the first or last character of the | 502 include a @samp{-}, write @samp{-} as the first or last character of the |
502 set, or put it after a range. Thus, @samp{[]-]} matches both @samp{]} | 503 set, or put it after a range. Thus, @samp{[]-]} matches both @samp{]} |
503 and @samp{-}. | 504 and @samp{-}. |
504 | 505 |
505 To include @samp{^} in a set, put it anywhere but at the beginning of | 506 To include @samp{^} in a set, put it anywhere but at the beginning of |
506 the set. | 507 the set. (At the beginning, it complements the set---see below.) |
507 | 508 |
508 When you use a range in case-insensitive search, you should write both | 509 When you use a range in case-insensitive search, you should write both |
509 ends of the range in upper case, or both in lower case, or both should | 510 ends of the range in upper case, or both in lower case, or both should |
510 be non-letters. The behavior of a mixed-case range such as @samp{A-z} | 511 be non-letters. The behavior of a mixed-case range such as @samp{A-z} |
511 is somewhat ill-defined, and it may change in future Emacs versions. | 512 is somewhat ill-defined, and it may change in future Emacs versions. |
512 | 513 |
513 @item [^ @dots{} ] | 514 @item [^ @dots{} ] |
514 @samp{[^} begins a @dfn{complemented character set}, which matches any | 515 @samp{[^} begins a @dfn{complemented character set}, which matches any |
515 character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches | 516 character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches |
516 all characters @emph{except} letters and digits. | 517 all characters @emph{except} ASCII letters and digits. |
517 | 518 |
518 @samp{^} is not special in a character set unless it is the first | 519 @samp{^} is not special in a character set unless it is the first |
519 character. The character following the @samp{^} is treated as if it | 520 character. The character following the @samp{^} is treated as if it |
520 were first (in other words, @samp{-} and @samp{]} are not special there). | 521 were first (in other words, @samp{-} and @samp{]} are not special there). |
521 | 522 |
669 @item \W | 670 @item \W |
670 matches any character that is not a word-constituent. | 671 matches any character that is not a word-constituent. |
671 | 672 |
672 @item \s@var{c} | 673 @item \s@var{c} |
673 matches any character whose syntax is @var{c}. Here @var{c} is a | 674 matches any character whose syntax is @var{c}. Here @var{c} is a |
674 character that represents a syntax code: thus, @samp{w} for word | 675 character that designates a particular syntax class: thus, @samp{w} |
675 constituent, @samp{-} for whitespace, @samp{(} for open parenthesis, | 676 for word constituent, @samp{-} or @samp{ } for whitespace, @samp{.} |
676 etc. Represent a character of whitespace (which can be a newline) by | 677 for ordinary punctuation, etc. @xref{Syntax}. |
677 either @samp{-} or a space character. | |
678 | 678 |
679 @item \S@var{c} | 679 @item \S@var{c} |
680 matches any character whose syntax is not @var{c}. | 680 matches any character whose syntax is not @var{c}. |
681 | 681 |
682 @cindex categories of characters | 682 @cindex categories of characters |
694 @end table | 694 @end table |
695 | 695 |
696 The constructs that pertain to words and syntax are controlled by the | 696 The constructs that pertain to words and syntax are controlled by the |
697 setting of the syntax table (@pxref{Syntax}). | 697 setting of the syntax table (@pxref{Syntax}). |
698 | 698 |
699 Here is a complicated regexp, used by Emacs to recognize the end of a | 699 Here is a complicated regexp, stored in @code{sentence-end} and used |
700 sentence together with any whitespace that follows. It is given in Lisp | 700 by Emacs to recognize the end of a sentence together with any |
701 syntax to enable you to distinguish the spaces from the tab characters. In | 701 whitespace that follows. We show it Lisp syntax to distinguish the |
702 Lisp syntax, the string constant begins and ends with a double-quote. | 702 spaces from the tab characters. In Lisp syntax, the string constant |
703 @samp{\"} stands for a double-quote as part of the regexp, @samp{\\} for a | 703 begins and ends with a double-quote. @samp{\"} stands for a |
704 backslash as part of the regexp, @samp{\t} for a tab and @samp{\n} for a | 704 double-quote as part of the regexp, @samp{\\} for a backslash as part |
705 newline. | 705 of the regexp, @samp{\t} for a tab, and @samp{\n} for a newline. |
706 | 706 |
707 @example | 707 @example |
708 "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*" | 708 "[.?!][]\"')]*\\($\\| $\\|\t\\| \\)[ \t\n]*" |
709 @end example | 709 @end example |
710 | 710 |
711 @noindent | 711 @noindent |
712 This contains four parts in succession: a character set matching period, | 712 This contains four parts in succession: a character set matching |
713 @samp{?}, or @samp{!}; a character set matching close-brackets, quotes, | 713 period, @samp{?}, or @samp{!}; a character set matching |
714 or parentheses, repeated any number of times; an alternative in | 714 close-brackets, quotes, or parentheses, repeated zero or more times; a |
715 backslash-parentheses that matches end-of-line, a tab, or two spaces; | 715 set of alternatives within backslash-parentheses that matches either |
716 and a character set matching whitespace characters, repeated any number | 716 end-of-line, a space at the end of a line, a tab, or two spaces; and a |
717 of times. | 717 character set matching whitespace characters, repeated any number of |
718 times. | |
718 | 719 |
719 To enter the same regexp interactively, you would type @key{TAB} to | 720 To enter the same regexp interactively, you would type @key{TAB} to |
720 enter a tab, and @kbd{C-j} to enter a newline. You would also type | 721 enter a tab, and @kbd{C-j} to enter a newline. You would also type |
721 single backslashes as themselves, instead of doubling them for Lisp syntax. | 722 single backslashes as themselves, instead of doubling them for Lisp syntax. |
722 | 723 |
742 @end ignore | 743 @end ignore |
743 | 744 |
744 @node Search Case, Replace, Regexps, Search | 745 @node Search Case, Replace, Regexps, Search |
745 @section Searching and Case | 746 @section Searching and Case |
746 | 747 |
747 @vindex case-fold-search | |
748 Incremental searches in Emacs normally ignore the case of the text | 748 Incremental searches in Emacs normally ignore the case of the text |
749 they are searching through, if you specify the text in lower case. | 749 they are searching through, if you specify the text in lower case. |
750 Thus, if you specify searching for @samp{foo}, then @samp{Foo} and | 750 Thus, if you specify searching for @samp{foo}, then @samp{Foo} and |
751 @samp{foo} are also considered a match. Regexps, and in particular | 751 @samp{foo} are also considered a match. Regexps, and in particular |
752 character sets, are included: @samp{[ab]} would match @samp{a} or | 752 character sets, are included: @samp{[ab]} would match @samp{a} or |
756 the search case-sensitive. Thus, searching for @samp{Foo} does not find | 756 the search case-sensitive. Thus, searching for @samp{Foo} does not find |
757 @samp{foo} or @samp{FOO}. This applies to regular expression search as | 757 @samp{foo} or @samp{FOO}. This applies to regular expression search as |
758 well as to string search. The effect ceases if you delete the | 758 well as to string search. The effect ceases if you delete the |
759 upper-case letter from the search string. | 759 upper-case letter from the search string. |
760 | 760 |
761 Typing @kbd{M-c} within an incremental search toggles the case | |
762 sensitivity of that search. The effect does not extend beyond the | |
763 current incremental search to the next one, but it does override the | |
764 effect of including an upper-case letter in the current search. | |
765 | |
766 @vindex case-fold-search | |
761 If you set the variable @code{case-fold-search} to @code{nil}, then | 767 If you set the variable @code{case-fold-search} to @code{nil}, then |
762 all letters must match exactly, including case. This is a per-buffer | 768 all letters must match exactly, including case. This is a per-buffer |
763 variable; altering the variable affects only the current buffer, but | 769 variable; altering the variable affects only the current buffer, but |
764 there is a default value which you can change as well. @xref{Locals}. | 770 there is a default value which you can change as well. @xref{Locals}. |
765 This variable applies to nonincremental searches also, including those | 771 This variable applies to nonincremental searches also, including those |
904 @findex query-replace | 910 @findex query-replace |
905 If you want to change only some of the occurrences of @samp{foo} to | 911 If you want to change only some of the occurrences of @samp{foo} to |
906 @samp{bar}, not all of them, then you cannot use an ordinary | 912 @samp{bar}, not all of them, then you cannot use an ordinary |
907 @code{replace-string}. Instead, use @kbd{M-%} (@code{query-replace}). | 913 @code{replace-string}. Instead, use @kbd{M-%} (@code{query-replace}). |
908 This command finds occurrences of @samp{foo} one by one, displays each | 914 This command finds occurrences of @samp{foo} one by one, displays each |
909 occurrence and asks you whether to replace it. A numeric argument to | 915 occurrence and asks you whether to replace it. Aside from querying, |
910 @code{query-replace} tells it to consider only occurrences that are | 916 @code{query-replace} works just like @code{replace-string}. It |
911 bounded by word-delimiter characters. This preserves case, just like | 917 preserves case, like @code{replace-string}, provided |
912 @code{replace-string}, provided @code{case-replace} is non-@code{nil}, | 918 @code{case-replace} is non-@code{nil}, as it normally is. A numeric |
913 as it normally is. | 919 argument means consider only occurrences that are bounded by |
920 word-delimiter characters. | |
914 | 921 |
915 @kindex C-M-% | 922 @kindex C-M-% |
916 @findex query-replace-regexp | 923 @findex query-replace-regexp |
917 Aside from querying, @code{query-replace} works just like | 924 @kbd{C-M-%} performs regexp search and replace (@code{query-replace-regexp}). |
918 @code{replace-string}, and @code{query-replace-regexp} works just like | 925 |
919 @code{replace-regexp}. This command is run by @kbd{C-M-%}. | 926 The characters you can type when you are shown a match for the string |
920 | 927 or regexp are: |
921 The things you can type when you are shown an occurrence of @var{string} | |
922 or a match for @var{regexp} are: | |
923 | 928 |
924 @ignore @c Not worth it. | 929 @ignore @c Not worth it. |
925 @kindex SPC @r{(query-replace)} | 930 @kindex SPC @r{(query-replace)} |
926 @kindex DEL @r{(query-replace)} | 931 @kindex DEL @r{(query-replace)} |
927 @kindex , @r{(query-replace)} | 932 @kindex , @r{(query-replace)} |