aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-11-28 11:23:02 +0200
committerEli Zaretskii2015-11-28 11:23:02 +0200
commit24703a0a89746feb3597d0ac2de65f0fabb7a2bc (patch)
tree5c2d8461f5d9f6561b67d685a94e58511f65b8c0
parentf32c79dd0ee40b882a12d58d51294356e844c4dd (diff)
downloademacs-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.texi86
-rw-r--r--lisp/replace.el14
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
435search exits the search before executing the command. Thus, the 435search exits the search before executing the command. Thus, the
436command operates on the buffer from which you invoked the search. 436command operates on the buffer from which you invoked the search.
437However, if you customize the variable @code{search-exit-option} to a 437However, 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
439interpreted by the incremental search are simply appended to the 439the incremental search are simply appended to the search string. This
440search string. This is so you could include in the search string 440is so you could include in the search string control characters, such
441control characters, such as @kbd{C-a}, that would normally exit the 441as @kbd{C-a}, that would normally exit the search and invoke the
442search and invoke the command bound to them on the buffer. 442command 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
1139differences between the search string you types and the text being 1139differences between the search string you types and the text being
1140searched. For example, sequences of whitespace characters of 1140searched. For example, sequences of whitespace characters of
1141different length are normally perceived as equivalent; letter-case 1141different length are usually perceived as equivalent; letter-case
1142differences usually don't matter; etc. This is known as 1142differences 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.
1154each space, or sequence of spaces, matches any sequence of one or more 1154each space, or sequence of spaces, matches any sequence of one or more
1155whitespace characters in the text. (Incremental regexp search has a 1155whitespace characters in the text. (Incremental regexp search has a
1156separate default; see @ref{Regexp Search}.) Hence, @samp{foo bar} 1156separate default; see @ref{Regexp Search}.) Hence, @samp{foo bar}
1157matches @samp{foo bar}, @samp{foo@w{ }bar}, @samp{foo@w{ }bar}, and so 1157matches @samp{foo bar}, @samp{foo@w{ }bar}, @samp{foo@w{ }bar}, and
1158on (but not @samp{foobar}). More precisely, Emacs matches each 1158so on (but not @samp{foobar}). More precisely, Emacs matches each
1159sequence of space characters in the search string to a regular 1159sequence of space characters in the search string to a regular
1160expression specified by the variable @code{search-whitespace-regexp}. 1160expression specified by the variable @code{search-whitespace-regexp}.
1161For example, to make spaces match sequences of newlines as well as 1161For 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
1164spaces, tabs, and formfeed characters as whitespace. 1164spaces, 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
1167space matching by typing @kbd{M-s @key{SPC}} 1167space 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.
1169Another @kbd{M-s @key{SPC}} turns lax space matching back on. To 1169Another @kbd{M-s @key{SPC}} turns lax space matching back on. To
1170disable this feature entirely, change @code{search-whitespace-regexp} 1170disable lax whitespace matching for all searches, change
1171to @code{nil}; then each space in the search string matches exactly 1171@code{search-whitespace-regexp} to @code{nil}; then each space in the
1172one space. 1172search 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
1177searching through, if you specify the search string in lower case. 1177searching through, if you specify the search string in lower case.
1178Thus, if you specify searching for @samp{foo}, then @samp{Foo} and 1178Thus, 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
1186case-sensitive. Thus, searching for @samp{Foo} does not find 1186case-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
1188as well as to string search. The effect ceases if you delete the 1188as well as to literal string search. The effect ceases if you delete
1189upper-case letter from the search string. The variable 1189the 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
1191default), an upper-case character in the search string make the search 1191default), an upper-case character in the search string make the search
1192case-sensitive; setting it to @code{nil} disables this effect of 1192case-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})
1208within an incremental search toggles the case sensitivity of that 1208within an incremental search toggles the case sensitivity of that
1209search. The effect does not extend beyond the current incremental 1209search. The effect does not extend beyond the current incremental
1210search to the next one, but it does override the effect of adding or 1210search, but it does override the effect of adding or removing an
1211removing an upper-case letter in the current search. 1211upper-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
1214matching for specific commands or activities. For instance, 1214matching for specific commands or activities. For instance,
@@ -1222,15 +1222,15 @@ apropos-variable @key{RET} case-fold-search @key{RET}}.
1222upper-case characters match lower-case variants, and vice versa. A 1222upper-case characters match lower-case variants, and vice versa. A
1223generalization of case folding is @dfn{character folding}, which 1223generalization of case folding is @dfn{character folding}, which
1224disregards wider classes of distinctions between similar characters. 1224disregards wider classes of distinctions between similar characters.
1225For instance, under character folding the letter @code{a} will match 1225For instance, under character folding the letter @code{a} matches all
1226all of its accented cousins like @code{@"a} and @code{@'a}, i.e., the 1226of its accented cousins like @code{@"a} and @code{@'a}, i.e., the
1227match disregards the diacriticals that distinguish between these 1227match disregards the diacriticals that distinguish between these
1228variants. In addition, @code{a} will match other characters that 1228variants. In addition, @code{a} matches other characters that
1229resemble it, or have it as part of their graphical representation, 1229resemble it, or have it as part of their graphical representation,
1230such as @sc{u+249c parenthesized latin small letter a} and @sc{u+2100 1230such as @sc{u+249c parenthesized latin small letter a} and @sc{u+2100
1231account of} (which looks like a small @code{a} over @code{c}). 1231account of} (which looks like a small @code{a} over @code{c}).
1232Similarly, the @acronym{ASCII} double-quote character @code{"} will 1232Similarly, the @acronym{ASCII} double-quote character @code{"} matches
1233match all the other variants of double quotes defined by the Unicode 1233all the other variants of double quotes defined by the Unicode
1234standard. 1234standard.
1235@ignore @c FIXME: This doesn't work. Should it? 1235@ignore @c FIXME: This doesn't work. Should it?
1236Finally, character folding can make a sequence of one or 1236Finally, 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
1241Character sequences that match under character folding are called 1241Character 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
1247equivalent character sequences. You can disable this behavior by 1247matching equivalent character sequences. You can disable this
1248customizing the variable @code{search-default-regexp-mode} to the 1248behavior by customizing the variable @code{search-default-regexp-mode}
1249@code{nil} value. @xref{Search Customizations}. Within an 1249to @code{nil}. @xref{Search Customizations}. Within an incremental
1250incremental search, typing @kbd{M-s '} 1250search, typing @kbd{M-s '} (@code{isearch-toggle-character-fold})
1251(@code{isearch-toggle-character-fold}) toggles character folding, but 1251toggles character folding, but only for that search. (Replace
1252only for that search. 1252commands have a different default, controlled by a separate option;
1253see @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,
1255such as @code{@"a}, as part of the search string disables character 1256such 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
1458replace. To enable character folding for matching, set the variable 1459replace. 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
1460setting does not affect the replacement text, only how Emacs finds the 1462setting does not affect the replacement text, only how Emacs finds the
1461text to replace.) 1463text 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
1790using the @code{isearch} face. This highlighting can be disabled by 1792using the @code{isearch} face. This highlighting can be disabled by
1791setting the variable @code{search-highlight} to a @code{nil} value. 1793setting 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
1797are highlighted using the @code{lazy-highlight} face. Setting the 1799are highlighted using the @code{lazy-highlight} face. Setting the
1798variable @code{isearch-lazy-highlight} to a @code{nil} value disables 1800variable @code{isearch-lazy-highlight} to @code{nil} disables this
1799this highlighting. Here are some other variables that customize the 1801highlighting. Here are some other variables that customize the lazy
1800lazy highlighting: 1802highlighting:
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.
1819search string is empty launches a nonincremental search. (Actually, 1821search string is empty launches a nonincremental search. (Actually,
1820it lets you edit the search string, and the next @key{RET} does the 1822it lets you edit the search string, and the next @key{RET} does the
1821search.) However, if you customize the variable 1823search.) 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 1825will always exit the incremental search, even if the search string is
1824string is empty. 1826empty.
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
1828invisible text, but hide any such matches as soon as the current match 1830invisible text, but hide any such matches as soon as the current match
1829moves off the invisible text. If you customize the variable 1831moves 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
1831text where matches were found stays on display until the search or the 1833where matches were found stays on display until the search or the
1832replace command exits. 1834replace 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
317to be replaced will match a sequence of whitespace chars defined by the 317to be replaced will match a sequence of whitespace chars defined by the
318regexp in `search-whitespace-regexp'. 318regexp in `search-whitespace-regexp'.
319 319
320If `replace-character-fold' is non-nil, matching uses character folding,
321i.e. it ignores diacriticals and other differences between equivalent
322character strings.
323
320Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace 324Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
321only matches surrounded by word boundaries. A negative prefix arg means 325only matches surrounded by word boundaries. A negative prefix arg means
322replace backward. 326replace backward.
@@ -375,6 +379,8 @@ If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
375to be replaced will match a sequence of whitespace chars defined by the 379to be replaced will match a sequence of whitespace chars defined by the
376regexp in `search-whitespace-regexp'. 380regexp in `search-whitespace-regexp'.
377 381
382This function is not affected by `replace-character-fold'.
383
378Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace 384Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
379only matches surrounded by word boundaries. A negative prefix arg means 385only matches surrounded by word boundaries. A negative prefix arg means
380replace backward. 386replace backward.
@@ -463,6 +469,8 @@ If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
463to be replaced will match a sequence of whitespace chars defined by the 469to be replaced will match a sequence of whitespace chars defined by the
464regexp in `search-whitespace-regexp'. 470regexp in `search-whitespace-regexp'.
465 471
472This function is not affected by `replace-character-fold'.
473
466Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace 474Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
467only matches that are surrounded by word boundaries. 475only matches that are surrounded by word boundaries.
468Fourth and fifth arg START and END specify the region to operate on." 476Fourth 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
554to be replaced will match a sequence of whitespace chars defined by the 562to be replaced will match a sequence of whitespace chars defined by the
555regexp in `search-whitespace-regexp'. 563regexp in `search-whitespace-regexp'.
556 564
565If `replace-character-fold' is non-nil, matching uses character folding,
566i.e. it ignores diacriticals and other differences between equivalent
567character strings.
568
557Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace 569Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
558only matches surrounded by word boundaries. A negative prefix arg means 570only matches surrounded by word boundaries. A negative prefix arg means
559replace backward. 571replace backward.
@@ -605,6 +617,8 @@ If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
605to be replaced will match a sequence of whitespace chars defined by the 617to be replaced will match a sequence of whitespace chars defined by the
606regexp in `search-whitespace-regexp'. 618regexp in `search-whitespace-regexp'.
607 619
620This function is not affected by `replace-character-fold'
621
608In Transient Mark mode, if the mark is active, operate on the contents 622In Transient Mark mode, if the mark is active, operate on the contents
609of the region. Otherwise, operate from point to the end of the buffer. 623of the region. Otherwise, operate from point to the end of the buffer.
610 624