From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Search nodes in Emacs manual Date: Fri, 18 Jun 2004 22:35:37 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87acz01wxi.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1087588184 14497 80.91.224.253 (18 Jun 2004 19:49:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Jun 2004 19:49:44 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jun 18 21:49:28 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BbPMe-00076R-00 for ; Fri, 18 Jun 2004 21:49:28 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BbPMd-0005pp-00 for ; Fri, 18 Jun 2004 21:49:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BbPNk-0008B0-9Q for emacs-devel@quimby.gnus.org; Fri, 18 Jun 2004 15:50:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BbPNh-0008Av-Aq for emacs-devel@gnu.org; Fri, 18 Jun 2004 15:50:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BbPNg-0008A6-AR for emacs-devel@gnu.org; Fri, 18 Jun 2004 15:50:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BbPNg-00089u-5F for emacs-devel@gnu.org; Fri, 18 Jun 2004 15:50:32 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BbPM0-0001nK-Ta for emacs-devel@gnu.org; Fri, 18 Jun 2004 15:48:49 -0400 Original-Received: from mail.jurta.org (80-235-34-90-dsl.mus.estpak.ee [80.235.34.90]) by spatula.dreamhost.com (Postfix) with ESMTP id B41CA17D021 for ; Fri, 18 Jun 2004 12:48:43 -0700 (PDT) Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25089 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25089 I checked search and replace related nodes of the Emacs manual and found some omissions and inaccuracies. 1. (info "(emacs)Incremental Search") 1.1. This Info node doesn't mention the M-e key. It could be documented in the paragraph about the minibuffer in isearch mode. 1.2. M-s is listed among other keybindings, but currently is unbound in isearch mode. It can be replaced by other keybindings M-c and M-e. 2. (info "(emacs)Regexp Search") M-r is not documented as a key to switch to regexp mode in isearch invoked by C-s or C-r. 3. (info "(emacs)Replace") The first paragraph of this node: Global search-and-replace operations are not needed often in Emacs, but they are available. In addition to the simple `M-x replace-string' command which is like that found in most editors, there is a `M-x query-replace' command which finds each occurrence of the pattern and asks you whether to replace it. Why search-and-replace is not needed often in Emacs? The fact how often users use search-and-replace completely depends on needs of every user, so, no such generalization is possible. The whole paragraph looks like comparing Emacs with some ancient editors which have no interactive query-replace operations and where search-and-replace operations are the only convenient way to make changes. This looks very strange nowadays. 3. (info "(emacs)Unconditional Replace") This node describes the command `replace-string', but the example in the same node demonstrates the use of the `query-replace' command. This could be changed to: M-x replace-string x @TEMP@ M-x replace-string y x M-x replace-string @TEMP@ y But perhaps with the latest changes this example can be replaced with more advanced like this: M-x replace-regexp \(x\|y\) \,(if (equal \& "x") "y" "x") BTW, `replace-regexp' currently doesn't support evaluation of the replacement string as `query-replace-regexp' now does, but I think it should. Index: man/search.texi =================================================================== RCS file: /cvsroot/emacs/emacs/man/search.texi,v retrieving revision 1.44 diff -c -r1.44 search.texi *** man/search.texi 19 May 2004 18:50:38 -0000 1.44 --- man/search.texi 18 Jun 2004 18:03:02 -0000 *************** *** 78,84 **** @key{RET} is necessary only if the next command you want to type is a printing character, @key{DEL}, @key{RET}, or another character that is special within searches (@kbd{C-q}, @kbd{C-w}, @kbd{C-r}, @kbd{C-s}, ! @kbd{C-y}, @kbd{M-y}, @kbd{M-r}, @kbd{M-s}, and some other meta-characters). Sometimes you search for @samp{FOO} and find one, but not the one you --- 78,84 ---- @key{RET} is necessary only if the next command you want to type is a printing character, @key{DEL}, @key{RET}, or another character that is special within searches (@kbd{C-q}, @kbd{C-w}, @kbd{C-r}, @kbd{C-s}, ! @kbd{C-y}, @kbd{M-y}, @kbd{M-r}, @kbd{M-c}, @kbd{M-e}, and some other meta-characters). Sometimes you search for @samp{FOO} and find one, but not the one you *************** *** 95,102 **** To reuse earlier search strings, use the @dfn{search ring}. The commands @kbd{M-p} and @kbd{M-n} move through the ring to pick a search string to reuse. These commands leave the selected search ring element ! in the minibuffer, where you can edit it. Type @kbd{C-s} or @kbd{C-r} ! to terminate editing the string and search for it. If your string is not found at all, the echo area says @samp{Failing I-Search}. The cursor is after the place where Emacs found as much of your --- 95,104 ---- To reuse earlier search strings, use the @dfn{search ring}. The commands @kbd{M-p} and @kbd{M-n} move through the ring to pick a search string to reuse. These commands leave the selected search ring element ! in the minibuffer, where you can edit it. To edit the current search ! string in the minibuffer without replacing it with items from the ! search ring you can type @kbd{M-e}. Type @kbd{C-s} or @kbd{C-r} to ! terminate editing the string and search for it. If your string is not found at all, the echo area says @samp{Failing I-Search}. The cursor is after the place where Emacs found as much of your *************** *** 371,384 **** @kindex C-M-r @findex isearch-backward-regexp Incremental search for a regexp is done by typing @kbd{C-M-s} ! (@code{isearch-forward-regexp}), or by invoking @kbd{C-s} with a ! prefix argument (whose value does not matter). This command reads a search string incrementally just like @kbd{C-s}, but it treats the search string as a regexp rather than looking for an exact match against the text in the buffer. Each time you add text to the search string, you make the regexp longer, and the new regexp is searched for. To search backward for a regexp, use @kbd{C-M-r} ! (@code{isearch-backward-regexp}), or @kbd{C-r} with a prefix argument. All of the control characters that do special things within an ordinary incremental search have the same function in incremental regexp --- 381,396 ---- @kindex C-M-r @findex isearch-backward-regexp Incremental search for a regexp is done by typing @kbd{C-M-s} ! (@code{isearch-forward-regexp}), by invoking @kbd{C-s} with a ! prefix argument (whose value does not matter), or by typing @kbd{M-r} ! within an incremental search invoked by @kbd{C-s}. This command reads a search string incrementally just like @kbd{C-s}, but it treats the search string as a regexp rather than looking for an exact match against the text in the buffer. Each time you add text to the search string, you make the regexp longer, and the new regexp is searched for. To search backward for a regexp, use @kbd{C-M-r} ! (@code{isearch-backward-regexp}), @kbd{C-r} with a prefix argument, ! or @kbd{M-r} within an incremental search invoked by @kbd{C-r}. All of the control characters that do special things within an ordinary incremental search have the same function in incremental regexp *************** *** 923,933 **** @cindex string substitution @cindex global substitution ! Global search-and-replace operations are not needed often in Emacs, ! but they are available. In addition to the simple @kbd{M-x ! replace-string} command which is like that found in most editors, ! there is a @kbd{M-x query-replace} command which finds each occurrence ! of the pattern and asks you whether to replace it. The replace commands normally operate on the text from point to the end of the buffer; however, in Transient Mark mode (@pxref{Transient --- 935,945 ---- @cindex string substitution @cindex global substitution ! Global search-and-replace operations are sometimes needed in Emacs. ! In addition to the simple @kbd{M-x replace-string} command which ! replaces all occurrences, there is a @kbd{M-x query-replace} command ! which finds each occurrence of the pattern and asks you whether to ! replace it. The replace commands normally operate on the text from point to the end of the buffer; however, in Transient Mark mode (@pxref{Transient *************** *** 977,985 **** What if you want to exchange @samp{x} and @samp{y}: replace every @samp{x} with a @samp{y} and vice versa? You can do it this way: @example ! M-x query-replace @key{RET} x @key{RET} @@TEMP@@ @key{RET} ! M-x query-replace @key{RET} y @key{RET} x @key{RET} ! M-x query-replace @key{RET} @@TEMP@@ @key{RET} y @key{RET} @end example @noindent --- 989,997 ---- What if you want to exchange @samp{x} and @samp{y}: replace every @samp{x} with a @samp{y} and vice versa? You can do it this way: @example ! M-x replace-string @key{RET} x @key{RET} @@TEMP@@ @key{RET} ! M-x replace-string @key{RET} y @key{RET} x @key{RET} ! M-x replace-string @key{RET} @@TEMP@@ @key{RET} y @key{RET} @end example @noindent -- Juri Linkov http://www.jurta.org/emacs/