From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Francesco Potorti` Newsgroups: gmane.emacs.bugs Subject: Re: please implement query-exchange Date: 19 Nov 2002 23:10:51 +0100 Sender: bug-gnu-emacs-admin@gnu.org Message-ID: <87r8dhgqhg.fsf@pot.cnuce.cnr.it> References: <87isyynuk3.fsf@jidanni.org> <1438-Sat16Nov2002211425+0200-eliz@is.elta.co.il> <3405-Tue19Nov2002205907+0200-eliz@is.elta.co.il> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1037743791 10039 80.91.224.249 (19 Nov 2002 22:09:51 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 19 Nov 2002 22:09:51 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18EGYv-0002a3-00 for ; Tue, 19 Nov 2002 23:09:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18EGaP-0004La-00; Tue, 19 Nov 2002 17:11:13 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18EGa8-00047B-00 for bug-gnu-emacs@gnu.org; Tue, 19 Nov 2002 17:10:56 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18EGa5-000439-00 for bug-gnu-emacs@gnu.org; Tue, 19 Nov 2002 17:10:55 -0500 Original-Received: from pot.cnuce.cnr.it ([146.48.83.182]) by monty-python.gnu.org with esmtp (Exim 4.10) id 18EGa5-00042S-00 for bug-gnu-emacs@gnu.org; Tue, 19 Nov 2002 17:10:53 -0500 Original-Received: from pot by pot.cnuce.cnr.it with local (Exim 3.36 #1 (Debian)) id 18EGa3-00033H-00 for ; Tue, 19 Nov 2002 23:10:51 +0100 Original-To: bug-gnu-emacs@gnu.org In-Reply-To: Original-Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.92 Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:3913 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:3913 Untested: (defun query-exchange ( &optional fstr sstr ) "Exchanges all occurences of fstr with sstr and vice-versa in the region." (interactive) (if (interactive-p) (progn (setq fstr (read-from-minibuffer "First string: ")) (setq sstr (read-from-minibuffer "Second string: ")))) (save-excursion (goto-char (region-beginning) (while (re-search-forward (concat "\\(" fstr "\\)\\|\\(" sstr "\\)) (region-end) t) (if (nilp (match-beginning 1)) (replace-match fstr) (replace-match sstr)))))))