diff options
| author | Eli Zaretskii | 2015-11-28 11:23:02 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-11-28 11:23:02 +0200 |
| commit | 24703a0a89746feb3597d0ac2de65f0fabb7a2bc (patch) | |
| tree | 5c2d8461f5d9f6561b67d685a94e58511f65b8c0 | |
| parent | f32c79dd0ee40b882a12d58d51294356e844c4dd (diff) | |
| download | emacs-24703a0a89746feb3597d0ac2de65f0fabb7a2bc.tar.gz emacs-24703a0a89746feb3597d0ac2de65f0fabb7a2bc.zip | |
Improve documentation of search and replace commands
* doc/emacs/search.texi (Replacement and Lax Matches): Document
which commands are affected by 'replace-character-fold'.
(Lax Search): Add a cross reference to "Replacement and Lax
Matches". Improve wording. Fix lost extra whitespace.
(Search Customizations): Improve wording. (Bug#22036)
See also comments in
http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg02376.html.
* lisp/replace.el (query-replace, query-replace-regexp)
(query-replace-regexp-eval, replace-string, replace-regexp):
Mention 'replace-character-fold' in the doc strings.
| -rw-r--r-- | doc/emacs/search.texi | 86 | ||||
| -rw-r--r-- | lisp/replace.el | 14 |
2 files changed, 58 insertions, 42 deletions
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index 9da9226d3bf..665b7963750 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi | |||
| @@ -434,12 +434,12 @@ they are not themselves part of incremental search. | |||
| 434 | Normally, typing a command that is not bound by the incremental | 434 | Normally, typing a command that is not bound by the incremental |
| 435 | search exits the search before executing the command. Thus, the | 435 | search exits the search before executing the command. Thus, the |
| 436 | command operates on the buffer from which you invoked the search. | 436 | command operates on the buffer from which you invoked the search. |
| 437 | However, if you customize the variable @code{search-exit-option} to a | 437 | However, if you customize the variable @code{search-exit-option} to |
| 438 | @code{nil} value, the characters which you type that are not | 438 | @code{nil}, the characters which you type that are not interpreted by |
| 439 | interpreted by the incremental search are simply appended to the | 439 | the incremental search are simply appended to the search string. This |
| 440 | search string. This is so you could include in the search string | 440 | is so you could include in the search string control characters, such |
| 441 | control characters, such as @kbd{C-a}, that would normally exit the | 441 | as @kbd{C-a}, that would normally exit the search and invoke the |
| 442 | search and invoke the command bound to them on the buffer. | 442 | command bound to them on the buffer. |
| 443 | 443 | ||
| 444 | @table @asis | 444 | @table @asis |
| 445 | @item Prefix Arguments | 445 | @item Prefix Arguments |
| @@ -1138,7 +1138,7 @@ close-brackets, quotes, or parentheses, repeated zero or more times. | |||
| 1138 | Normally, you'd want search commands to disregard certain minor | 1138 | Normally, you'd want search commands to disregard certain minor |
| 1139 | differences between the search string you types and the text being | 1139 | differences between the search string you types and the text being |
| 1140 | searched. For example, sequences of whitespace characters of | 1140 | searched. For example, sequences of whitespace characters of |
| 1141 | different length are normally perceived as equivalent; letter-case | 1141 | different length are usually perceived as equivalent; letter-case |
| 1142 | differences usually don't matter; etc. This is known as | 1142 | differences usually don't matter; etc. This is known as |
| 1143 | @dfn{character equivalence}. | 1143 | @dfn{character equivalence}. |
| 1144 | 1144 | ||
| @@ -1154,8 +1154,8 @@ tailor them to your needs. | |||
| 1154 | each space, or sequence of spaces, matches any sequence of one or more | 1154 | each space, or sequence of spaces, matches any sequence of one or more |
| 1155 | whitespace characters in the text. (Incremental regexp search has a | 1155 | whitespace characters in the text. (Incremental regexp search has a |
| 1156 | separate default; see @ref{Regexp Search}.) Hence, @samp{foo bar} | 1156 | separate default; see @ref{Regexp Search}.) Hence, @samp{foo bar} |
| 1157 | matches @samp{foo bar}, @samp{foo@w{ }bar}, @samp{foo@w{ }bar}, and so | 1157 | matches @samp{foo bar}, @samp{foo@w{ }bar}, @samp{foo@w{ }bar}, and |
| 1158 | on (but not @samp{foobar}). More precisely, Emacs matches each | 1158 | so on (but not @samp{foobar}). More precisely, Emacs matches each |
| 1159 | sequence of space characters in the search string to a regular | 1159 | sequence of space characters in the search string to a regular |
| 1160 | expression specified by the variable @code{search-whitespace-regexp}. | 1160 | expression specified by the variable @code{search-whitespace-regexp}. |
| 1161 | For example, to make spaces match sequences of newlines as well as | 1161 | For example, to make spaces match sequences of newlines as well as |
| @@ -1164,16 +1164,16 @@ variable depends on the buffer's major mode; most major modes classify | |||
| 1164 | spaces, tabs, and formfeed characters as whitespace. | 1164 | spaces, tabs, and formfeed characters as whitespace. |
| 1165 | 1165 | ||
| 1166 | If you want whitespace characters to match exactly, you can turn lax | 1166 | If you want whitespace characters to match exactly, you can turn lax |
| 1167 | space matching by typing @kbd{M-s @key{SPC}} | 1167 | space matching off by typing @kbd{M-s @key{SPC}} |
| 1168 | (@code{isearch-toggle-lax-whitespace}) within an incremental search. | 1168 | (@code{isearch-toggle-lax-whitespace}) within an incremental search. |
| 1169 | Another @kbd{M-s @key{SPC}} turns lax space matching back on. To | 1169 | Another @kbd{M-s @key{SPC}} turns lax space matching back on. To |
| 1170 | disable this feature entirely, change @code{search-whitespace-regexp} | 1170 | disable lax whitespace matching for all searches, change |
| 1171 | to @code{nil}; then each space in the search string matches exactly | 1171 | @code{search-whitespace-regexp} to @code{nil}; then each space in the |
| 1172 | one space. | 1172 | search string matches exactly one space. |
| 1173 | 1173 | ||
| 1174 | @cindex case folding in search | 1174 | @cindex case folding in search |
| 1175 | @cindex case-sensitivity and search | 1175 | @cindex case-sensitivity and search |
| 1176 | Searches in Emacs normally ignore the case of the text they are | 1176 | Searches in Emacs by default ignore the case of the text they are |
| 1177 | searching through, if you specify the search string in lower case. | 1177 | searching through, if you specify the search string in lower case. |
| 1178 | Thus, if you specify searching for @samp{foo}, then @samp{Foo} and | 1178 | Thus, if you specify searching for @samp{foo}, then @samp{Foo} and |
| 1179 | @samp{foo} also match. Regexps, and in particular character sets, | 1179 | @samp{foo} also match. Regexps, and in particular character sets, |
| @@ -1185,8 +1185,8 @@ supported in both incremental and non-incremental search modes. | |||
| 1185 | An upper-case letter anywhere in the search string makes the search | 1185 | An upper-case letter anywhere in the search string makes the search |
| 1186 | case-sensitive. Thus, searching for @samp{Foo} does not find | 1186 | case-sensitive. Thus, searching for @samp{Foo} does not find |
| 1187 | @samp{foo} or @samp{FOO}. This applies to regular expression search | 1187 | @samp{foo} or @samp{FOO}. This applies to regular expression search |
| 1188 | as well as to string search. The effect ceases if you delete the | 1188 | as well as to literal string search. The effect ceases if you delete |
| 1189 | upper-case letter from the search string. The variable | 1189 | the upper-case letter from the search string. The variable |
| 1190 | @code{search-upper-case} controls this: if it is non-@code{nil} (the | 1190 | @code{search-upper-case} controls this: if it is non-@code{nil} (the |
| 1191 | default), an upper-case character in the search string make the search | 1191 | default), an upper-case character in the search string make the search |
| 1192 | case-sensitive; setting it to @code{nil} disables this effect of | 1192 | case-sensitive; setting it to @code{nil} disables this effect of |
| @@ -1207,8 +1207,8 @@ history matching commands (@pxref{Minibuffer History}). | |||
| 1207 | Typing @kbd{M-c} or @kbd{M-s c} (@code{isearch-toggle-case-fold}) | 1207 | Typing @kbd{M-c} or @kbd{M-s c} (@code{isearch-toggle-case-fold}) |
| 1208 | within an incremental search toggles the case sensitivity of that | 1208 | within an incremental search toggles the case sensitivity of that |
| 1209 | search. The effect does not extend beyond the current incremental | 1209 | search. The effect does not extend beyond the current incremental |
| 1210 | search to the next one, but it does override the effect of adding or | 1210 | search, but it does override the effect of adding or removing an |
| 1211 | removing an upper-case letter in the current search. | 1211 | upper-case letter in the current search. |
| 1212 | 1212 | ||
| 1213 | Several related variables control case-sensitivity of searching and | 1213 | Several related variables control case-sensitivity of searching and |
| 1214 | matching for specific commands or activities. For instance, | 1214 | matching for specific commands or activities. For instance, |
| @@ -1222,15 +1222,15 @@ apropos-variable @key{RET} case-fold-search @key{RET}}. | |||
| 1222 | upper-case characters match lower-case variants, and vice versa. A | 1222 | upper-case characters match lower-case variants, and vice versa. A |
| 1223 | generalization of case folding is @dfn{character folding}, which | 1223 | generalization of case folding is @dfn{character folding}, which |
| 1224 | disregards wider classes of distinctions between similar characters. | 1224 | disregards wider classes of distinctions between similar characters. |
| 1225 | For instance, under character folding the letter @code{a} will match | 1225 | For instance, under character folding the letter @code{a} matches all |
| 1226 | all of its accented cousins like @code{@"a} and @code{@'a}, i.e., the | 1226 | of its accented cousins like @code{@"a} and @code{@'a}, i.e., the |
| 1227 | match disregards the diacriticals that distinguish between these | 1227 | match disregards the diacriticals that distinguish between these |
| 1228 | variants. In addition, @code{a} will match other characters that | 1228 | variants. In addition, @code{a} matches other characters that |
| 1229 | resemble it, or have it as part of their graphical representation, | 1229 | resemble it, or have it as part of their graphical representation, |
| 1230 | such as @sc{u+249c parenthesized latin small letter a} and @sc{u+2100 | 1230 | such as @sc{u+249c parenthesized latin small letter a} and @sc{u+2100 |
| 1231 | account of} (which looks like a small @code{a} over @code{c}). | 1231 | account of} (which looks like a small @code{a} over @code{c}). |
| 1232 | Similarly, the @acronym{ASCII} double-quote character @code{"} will | 1232 | Similarly, the @acronym{ASCII} double-quote character @code{"} matches |
| 1233 | match all the other variants of double quotes defined by the Unicode | 1233 | all the other variants of double quotes defined by the Unicode |
| 1234 | standard. | 1234 | standard. |
| 1235 | @ignore @c FIXME: This doesn't work. Should it? | 1235 | @ignore @c FIXME: This doesn't work. Should it? |
| 1236 | Finally, character folding can make a sequence of one or | 1236 | Finally, character folding can make a sequence of one or |
| @@ -1239,17 +1239,18 @@ example, the sequence of two characters @code{ae} matches the ligature | |||
| 1239 | @code{@ae{}}. | 1239 | @code{@ae{}}. |
| 1240 | @end ignore | 1240 | @end ignore |
| 1241 | Character sequences that match under character folding are called | 1241 | Character sequences that match under character folding are called |
| 1242 | @dfn{equivalent}. | 1242 | @dfn{equivalent character sequences}. |
| 1243 | 1243 | ||
| 1244 | @kindex M-s ' @r{(Incremental Search)} | 1244 | @kindex M-s ' @r{(Incremental Search)} |
| 1245 | @findex isearch-toggle-character-fold | 1245 | @findex isearch-toggle-character-fold |
| 1246 | Searches in Emacs normally perform character folding, thus matching | 1246 | Searches in Emacs by default perform character folding, thus |
| 1247 | equivalent character sequences. You can disable this behavior by | 1247 | matching equivalent character sequences. You can disable this |
| 1248 | customizing the variable @code{search-default-regexp-mode} to the | 1248 | behavior by customizing the variable @code{search-default-regexp-mode} |
| 1249 | @code{nil} value. @xref{Search Customizations}. Within an | 1249 | to @code{nil}. @xref{Search Customizations}. Within an incremental |
| 1250 | incremental search, typing @kbd{M-s '} | 1250 | search, typing @kbd{M-s '} (@code{isearch-toggle-character-fold}) |
| 1251 | (@code{isearch-toggle-character-fold}) toggles character folding, but | 1251 | toggles character folding, but only for that search. (Replace |
| 1252 | only for that search. | 1252 | commands have a different default, controlled by a separate option; |
| 1253 | see @ref{Replacement and Lax Matches}.) | ||
| 1253 | 1254 | ||
| 1254 | Like with case folding, typing an explicit variant of a character, | 1255 | Like with case folding, typing an explicit variant of a character, |
| 1255 | such as @code{@"a}, as part of the search string disables character | 1256 | such as @code{@"a}, as part of the search string disables character |
| @@ -1455,10 +1456,11 @@ replacement is done without case conversion. | |||
| 1455 | @cindex character folding in replace commands | 1456 | @cindex character folding in replace commands |
| 1456 | The replacement commands by default do not use character folding | 1457 | The replacement commands by default do not use character folding |
| 1457 | (@pxref{Lax Search, character folding}) when looking for the text to | 1458 | (@pxref{Lax Search, character folding}) when looking for the text to |
| 1458 | replace. To enable character folding for matching, set the variable | 1459 | replace. To enable character folding for matching in |
| 1460 | @code{query-replace} and @code{replace-string}, set the variable | ||
| 1459 | @code{replace-character-fold} to a non-@code{nil} value. (This | 1461 | @code{replace-character-fold} to a non-@code{nil} value. (This |
| 1460 | setting does not affect the replacement text, only how Emacs finds the | 1462 | setting does not affect the replacement text, only how Emacs finds the |
| 1461 | text to replace.) | 1463 | text to replace. It also doesn't affect @code{replace-regexp}.) |
| 1462 | 1464 | ||
| 1463 | @node Query Replace | 1465 | @node Query Replace |
| 1464 | @subsection Query Replace | 1466 | @subsection Query Replace |
| @@ -1788,16 +1790,16 @@ case folding and lax-whitespace matching. | |||
| 1788 | @vindex search-highlight | 1790 | @vindex search-highlight |
| 1789 | The current match of an on-going incremental search is highlighted | 1791 | The current match of an on-going incremental search is highlighted |
| 1790 | using the @code{isearch} face. This highlighting can be disabled by | 1792 | using the @code{isearch} face. This highlighting can be disabled by |
| 1791 | setting the variable @code{search-highlight} to a @code{nil} value. | 1793 | setting the variable @code{search-highlight} to @code{nil}. |
| 1792 | 1794 | ||
| 1793 | @cindex lazy highlighting customizations | 1795 | @cindex lazy highlighting customizations |
| 1794 | @vindex isearch-lazy-highlight | 1796 | @vindex isearch-lazy-highlight |
| 1795 | @cindex lazy-highlight face | 1797 | @cindex lazy-highlight face |
| 1796 | The other matches for the search string that are visible on display | 1798 | The other matches for the search string that are visible on display |
| 1797 | are highlighted using the @code{lazy-highlight} face. Setting the | 1799 | are highlighted using the @code{lazy-highlight} face. Setting the |
| 1798 | variable @code{isearch-lazy-highlight} to a @code{nil} value disables | 1800 | variable @code{isearch-lazy-highlight} to @code{nil} disables this |
| 1799 | this highlighting. Here are some other variables that customize the | 1801 | highlighting. Here are some other variables that customize the lazy |
| 1800 | lazy highlighting: | 1802 | highlighting: |
| 1801 | 1803 | ||
| 1802 | @table @code | 1804 | @table @code |
| 1803 | @item lazy-highlight-initial-delay | 1805 | @item lazy-highlight-initial-delay |
| @@ -1819,16 +1821,16 @@ matches. Thus, smaller values make Emacs more responsive. | |||
| 1819 | search string is empty launches a nonincremental search. (Actually, | 1821 | search string is empty launches a nonincremental search. (Actually, |
| 1820 | it lets you edit the search string, and the next @key{RET} does the | 1822 | it lets you edit the search string, and the next @key{RET} does the |
| 1821 | search.) However, if you customize the variable | 1823 | search.) However, if you customize the variable |
| 1822 | @code{search-nonincremental-instead} to a @code{nil} value, typing | 1824 | @code{search-nonincremental-instead} to @code{nil}, typing @key{RET} |
| 1823 | @key{RET} will always exit the incremental search, even if the search | 1825 | will always exit the incremental search, even if the search string is |
| 1824 | string is empty. | 1826 | empty. |
| 1825 | 1827 | ||
| 1826 | @vindex isearch-hide-immediately | 1828 | @vindex isearch-hide-immediately |
| 1827 | By default, incremental search and query-replace commands match | 1829 | By default, incremental search and query-replace commands match |
| 1828 | invisible text, but hide any such matches as soon as the current match | 1830 | invisible text, but hide any such matches as soon as the current match |
| 1829 | moves off the invisible text. If you customize the variable | 1831 | moves off the invisible text. If you customize the variable |
| 1830 | @code{isearch-hide-immediately} to a @code{nil} value, any invisible | 1832 | @code{isearch-hide-immediately} to @code{nil}, any invisible text |
| 1831 | text where matches were found stays on display until the search or the | 1833 | where matches were found stays on display until the search or the |
| 1832 | replace command exits. | 1834 | replace command exits. |
| 1833 | 1835 | ||
| 1834 | @cindex search display on slow terminals | 1836 | @cindex search display on slow terminals |
diff --git a/lisp/replace.el b/lisp/replace.el index b0a14e3f44c..76f8d312c7c 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -317,6 +317,10 @@ If `replace-lax-whitespace' is non-nil, a space or spaces in the string | |||
| 317 | to be replaced will match a sequence of whitespace chars defined by the | 317 | to be replaced will match a sequence of whitespace chars defined by the |
| 318 | regexp in `search-whitespace-regexp'. | 318 | regexp in `search-whitespace-regexp'. |
| 319 | 319 | ||
| 320 | If `replace-character-fold' is non-nil, matching uses character folding, | ||
| 321 | i.e. it ignores diacriticals and other differences between equivalent | ||
| 322 | character strings. | ||
| 323 | |||
| 320 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace | 324 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
| 321 | only matches surrounded by word boundaries. A negative prefix arg means | 325 | only matches surrounded by word boundaries. A negative prefix arg means |
| 322 | replace backward. | 326 | replace backward. |
| @@ -375,6 +379,8 @@ If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp | |||
| 375 | to be replaced will match a sequence of whitespace chars defined by the | 379 | to be replaced will match a sequence of whitespace chars defined by the |
| 376 | regexp in `search-whitespace-regexp'. | 380 | regexp in `search-whitespace-regexp'. |
| 377 | 381 | ||
| 382 | This function is not affected by `replace-character-fold'. | ||
| 383 | |||
| 378 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace | 384 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
| 379 | only matches surrounded by word boundaries. A negative prefix arg means | 385 | only matches surrounded by word boundaries. A negative prefix arg means |
| 380 | replace backward. | 386 | replace backward. |
| @@ -463,6 +469,8 @@ If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp | |||
| 463 | to be replaced will match a sequence of whitespace chars defined by the | 469 | to be replaced will match a sequence of whitespace chars defined by the |
| 464 | regexp in `search-whitespace-regexp'. | 470 | regexp in `search-whitespace-regexp'. |
| 465 | 471 | ||
| 472 | This function is not affected by `replace-character-fold'. | ||
| 473 | |||
| 466 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace | 474 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
| 467 | only matches that are surrounded by word boundaries. | 475 | only matches that are surrounded by word boundaries. |
| 468 | Fourth and fifth arg START and END specify the region to operate on." | 476 | Fourth and fifth arg START and END specify the region to operate on." |
| @@ -554,6 +562,10 @@ If `replace-lax-whitespace' is non-nil, a space or spaces in the string | |||
| 554 | to be replaced will match a sequence of whitespace chars defined by the | 562 | to be replaced will match a sequence of whitespace chars defined by the |
| 555 | regexp in `search-whitespace-regexp'. | 563 | regexp in `search-whitespace-regexp'. |
| 556 | 564 | ||
| 565 | If `replace-character-fold' is non-nil, matching uses character folding, | ||
| 566 | i.e. it ignores diacriticals and other differences between equivalent | ||
| 567 | character strings. | ||
| 568 | |||
| 557 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace | 569 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
| 558 | only matches surrounded by word boundaries. A negative prefix arg means | 570 | only matches surrounded by word boundaries. A negative prefix arg means |
| 559 | replace backward. | 571 | replace backward. |
| @@ -605,6 +617,8 @@ If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp | |||
| 605 | to be replaced will match a sequence of whitespace chars defined by the | 617 | to be replaced will match a sequence of whitespace chars defined by the |
| 606 | regexp in `search-whitespace-regexp'. | 618 | regexp in `search-whitespace-regexp'. |
| 607 | 619 | ||
| 620 | This function is not affected by `replace-character-fold' | ||
| 621 | |||
| 608 | In Transient Mark mode, if the mark is active, operate on the contents | 622 | In Transient Mark mode, if the mark is active, operate on the contents |
| 609 | of the region. Otherwise, operate from point to the end of the buffer. | 623 | of the region. Otherwise, operate from point to the end of the buffer. |
| 610 | 624 | ||