From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: query-replace-interactive not documented Date: Sun, 20 Jun 2004 15:18:21 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20040528.181649.25475113.wl@gnu.org> <873c5jug73.fsf@mail.jurta.org> <87oenqa4lu.fsf@mail.jurta.org> <873c51w5rq.fsf@mail.jurta.org> <87659snbd8.fsf@mail.jurta.org> <87llin98sc.fsf@mail.jurta.org> <87hdtbtnsg.fsf@mail.jurta.org> <87brjhwe2c.fsf@mail.jurta.org> Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1087759158 21313 80.91.224.253 (20 Jun 2004 19:19:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 20 Jun 2004 19:19:18 +0000 (UTC) Cc: juri@jurta.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Jun 20 21:19:09 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 1Bc7qP-0005cX-00 for ; Sun, 20 Jun 2004 21:19:09 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bc7qP-00032c-00 for ; Sun, 20 Jun 2004 21:19:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bc7rc-000304-27 for emacs-devel@quimby.gnus.org; Sun, 20 Jun 2004 15:20:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bc7rF-0002mS-Re for emacs-devel@gnu.org; Sun, 20 Jun 2004 15:20:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bc7rD-0002lU-KC for emacs-devel@gnu.org; Sun, 20 Jun 2004 15:20:00 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bc7rD-0002lE-By for emacs-devel@gnu.org; Sun, 20 Jun 2004 15:19:59 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bc7pe-0003mn-Ea for emacs-devel@gnu.org; Sun, 20 Jun 2004 15:18:22 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1Bc7pd-0007iu-Oq; Sun, 20 Jun 2004 15:18:21 -0400 Original-To: David Kastrup In-reply-to: (message from David Kastrup on 19 Jun 2004 09:00:22 +0200) 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:25127 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25127 Wel, optional spaces in the middle of regexp are something that needs extra explaining....Actually, I can't think about much except symbols here, and maybe forms like 'symbol which end up as a list. I think that is simple enough to explain. It does feel somewhat strange that the replacement expression x + \,(1+ \#) + y; would swallow a space, It would not swallow a space; the reader would stop after the close paren. Have you taken a look at the DOC-string of the currently checked-in version of query-replace-regexp? No. Did you check something in that doesn't agree with what I've said? These two paragraphs of doc string When this function is called interactively, the replacement text can also contain `\\,' followed by a Lisp expression. The escaped shorthands for `query-replace-regexp-eval' are also valid here: within the Lisp expression, you can use `\\&' for the whole match string, `\\N' for partial matches, `\\#&' and `\\#N' for the respective numeric values, and `\\#' for `replace-count'. If your Lisp expression is an identifier and the next letter in the replacement string would be interpreted as part of it, you can wrap it with an expression like `\\,(or \\#)'. Incidentally, for this particular case you may also enter `\\#' in the replacement text directly. would be clearer as follows: When this function is called interactively, the replacement text can also contain `\\,' followed by a Lisp expression. Each replacement evaluates that expression to compute the replacement string. In the expression, you can use `\\&' for the whole match string, `\\N' for partial matches, and `\\#' for the sequence number (origin-zero) of this replacement. If the replacement expression is a symbol, write a space after it to terminate it. I left out the part about `\\#&' and `\\#N' because I don't understand what they do. I am not sure what "respective numeric values" means. When I tried \#&, it seemed to insert the replacement count followed by an &. *** replace.el 17 Jun 2004 19:28:37 -0400 1.173 --- replace.el 19 Jun 2004 21:26:16 -0400 *************** *** 165,181 **** whatever what matched the Nth `\\(...\\)' in REGEXP. When this function is called interactively, the replacement text ! can also contain `\\,' followed by a Lisp expression. The escaped ! shorthands for `query-replace-regexp-eval' are also valid ! here: within the Lisp expression, you can use `\\&' for the whole ! match string, `\\N' for partial matches, `\\#&' and `\\#N' for ! the respective numeric values, and `\\#' for `replace-count'. ! If your Lisp expression is an identifier and the next ! letter in the replacement string would be interpreted as part of it, ! you can wrap it with an expression like `\\,(or \\#)'. Incidentally, ! for this particular case you may also enter `\\#' in the replacement ! text directly. When you use `\\,' or `\\#' in the replacement, TO-STRING actually becomes a list with expanded shorthands. --- 165,178 ---- whatever what matched the Nth `\\(...\\)' in REGEXP. When this function is called interactively, the replacement text ! can also contain `\\,' followed by a Lisp expression. Each ! replacement evaluates that expression to compute the replacement ! string. In the expression, you can use `\\&' for the whole ! match string, `\\N' for partial matches, and `\\#' for the ! sequence number (origin-zero) of this replacement. ! If the replacement expression is a symbol, write a space after it ! to terminate it. When you use `\\,' or `\\#' in the replacement, TO-STRING actually becomes a list with expanded shorthands. *************** *** 200,206 **** ((eq char ?\,) (setq pos (read-from-string to-string)) (push `(replace-quote ,(car pos)) to-expr) ! (setq to-string (substring to-string (cdr pos)))))) (setq to-expr (nreverse (delete "" (cons to-string to-expr)))) (replace-match-string-symbols to-expr) (cons 'replace-eval-replacement --- 197,211 ---- ((eq char ?\,) (setq pos (read-from-string to-string)) (push `(replace-quote ,(car pos)) to-expr) ! (let ((end ! ;; Swallow a space after a symbol ! ;; if there is a space. ! (if (and (symbolp (car pos)) ! (equal " " (substring to-string (cdr pos) ! (1+ (cdr pos))))) ! (1+ (cdr pos)) ! (cdr pos)))) ! (setq to-string (substring to-string end)))))) (setq to-expr (nreverse (delete "" (cons to-string to-expr)))) (replace-match-string-symbols to-expr) (cons 'replace-eval-replacement