diff options
| author | Richard M. Stallman | 2001-04-06 08:29:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-04-06 08:29:10 +0000 |
| commit | b20a1c885b9ea585bc30a25eab56f6639cb80768 (patch) | |
| tree | 160afe1072281661cc02f5d69bfc0cfa6f74a4f3 | |
| parent | 0b9ad3522081d0d847fe4afd40dc7176d4cd669b (diff) | |
| download | emacs-b20a1c885b9ea585bc30a25eab56f6639cb80768.tar.gz emacs-b20a1c885b9ea585bc30a25eab56f6639cb80768.zip | |
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.
| -rw-r--r-- | man/search.texi | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/man/search.texi b/man/search.texi index 56b5f37710f..5ce8617f2ad 100644 --- a/man/search.texi +++ b/man/search.texi | |||
| @@ -70,12 +70,13 @@ you want to erase. If you do not want to wait for this to happen, use | |||
| 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 |
| @@ -236,7 +237,7 @@ its new position of point. | |||
| 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 |
| @@ -503,7 +504,7 @@ 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 |
| @@ -513,7 +514,7 @@ is somewhat ill-defined, and it may change in future Emacs versions. | |||
| 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 |
| @@ -671,10 +672,9 @@ 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}. |
| @@ -696,25 +696,26 @@ matches any character that does @emph{not} belong to category | |||
| 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 |
| @@ -744,7 +745,6 @@ for matching parens.) | |||
| 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 |
| @@ -758,6 +758,12 @@ the search case-sensitive. Thus, searching for @samp{Foo} does not find | |||
| 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 |
| @@ -906,20 +912,19 @@ Replace some matches for @var{regexp} with @var{newstring}. | |||
| 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 | ||
| 919 | @code{replace-regexp}. This command is run by @kbd{C-M-%}. | ||
| 920 | 925 | ||
| 921 | The things you can type when you are shown an occurrence of @var{string} | 926 | The characters you can type when you are shown a match for the string |
| 922 | or a match for @var{regexp} are: | 927 | or 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)} |