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: Re: query-replace-interactive not documented Date: Wed, 16 Jun 2004 11:02:32 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87vfhrexan.fsf@mail.jurta.org> References: <20040528.181649.25475113.wl@gnu.org> <200405291737.i4THbPJ06689@raven.dms.auburn.edu> <873c5jug73.fsf@mail.jurta.org> <87oenqa4lu.fsf@mail.jurta.org> <873c51w5rq.fsf@mail.jurta.org> <87659snbd8.fsf@mail.jurta.org> <878yeoadpd.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 1087373825 29853 80.91.224.253 (16 Jun 2004 08:17:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 16 Jun 2004 08:17:05 +0000 (UTC) Cc: David Kastrup , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Jun 16 10:16:51 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 1BaVbH-0004Sk-00 for ; Wed, 16 Jun 2004 10:16:51 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BaVbG-00078f-00 for ; Wed, 16 Jun 2004 10:16:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BaVcF-0007IB-F6 for emacs-devel@quimby.gnus.org; Wed, 16 Jun 2004 04:17:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BaVbi-0007Bz-4o for emacs-devel@gnu.org; Wed, 16 Jun 2004 04:17:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BaVbf-00079g-Aw for emacs-devel@gnu.org; Wed, 16 Jun 2004 04:17:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BaVbf-00079U-6g for emacs-devel@gnu.org; Wed, 16 Jun 2004 04:17:15 -0400 Original-Received: from [66.33.219.4] (helo=spork.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BaVaJ-0003El-Dr; Wed, 16 Jun 2004 04:15:51 -0400 Original-Received: from mail.jurta.org (80-235-33-203-dsl.mus.estpak.ee [80.235.33.203]) by spork.dreamhost.com (Postfix) with ESMTP id A133211DC0E; Wed, 16 Jun 2004 01:15:48 -0700 (PDT) Original-To: storm@cua.dk (Kim F. Storm) In-Reply-To: (Kim F. Storm's message of "16 Jun 2004 00:43:37 +0200") 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:25022 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25022 storm@cua.dk (Kim F. Storm) writes: > Also, \? could be used to ask the user for a string to insert at > that point in each replacement... Good idea! Below is an improved version. Index: replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.172 diff -c -r1.172 replace.el *** replace.el 10 Jun 2004 04:21:14 -0000 1.172 --- replace.el 15 Jun 2004 17:57:28 -0000 @@ -174,6 +183,23 @@ (if (and transient-mark-mode mark-active) (region-end))))) + (if (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[`?]" to-string) + (let (to expr sym) + (while (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\\\([`?]\\)" to-string) + (setq sym (match-string 3 to-string) + to (cons (substring to-string 0 (- (match-end 0) 2)) to) + to-string (substring to-string (match-end 0))) + (cond + ((equal sym "`") + (setq expr (read-from-string to-string) + to (cons `(format "%s" ,(car expr)) to) + to-string (substring to-string (cdr expr)))) + ((equal sym "?") + (setq to (cons `(read-string "Enter string: ") to))))) + (setq to (nreverse (delete "" (cons to-string to)))) + (replace-match-string-symbols to) + (setq to-string `(replace-eval-replacement concat ,@to)))) (perform-replace regexp to-string t t delimited nil nil start end)) (define-key esc-map [?\C-%] 'query-replace-regexp) -- Juri Linkov http://www.jurta.org/emacs/