From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: a simple string manipulation Date: 06 Apr 2003 06:16:49 +0200 Organization: informatimago.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87vfxs8dla.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1049602843 4595 80.91.224.249 (6 Apr 2003 04:20:43 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 6 Apr 2003 04:20:43 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Sun Apr 06 06:20:40 2003 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 1921e4-0001Bk-00 for ; Sun, 06 Apr 2003 06:20:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 1921e7-0004xN-06 for gnu-help-gnu-emacs@m.gmane.org; Sat, 05 Apr 2003 23:20:43 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!feed.news.nacamar.de!fu-berlin.de!uni-berlin.de!thalassa.informatimago.COM!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-NNTP-Posting-Host: thalassa.informatimago.com (195.114.85.194) Original-X-Trace: fu-berlin.de 1049602618 7700806 195.114.85.194 (16 [41911]) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-Xref: shelby.stanford.edu gnu.emacs.help:111713 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:8214 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:8214 Luca Ferrari writes: > Hi to everyone, > I've got a simple problem (I think) that is related to a string manipulation. > I must write often strings like this: > MOVE A TO B > > and after it's opposite > MOVE B TO A > > Now I'd like to know if there's a way to set a key function so that > after I've got a group of strings I can simply copy and paste and > revert they. Can you shown me how? Thanks I would do: M-x replace-regexp MOVE \(.*\) TO \(.*\) MOVE \2 TO \1 You could put the equivalent into an interactive function: ;; untested code follows: (defun reverse-moves-region (start end) (interactive "*r") (goto-char end) (insert (buffer-substring start end)) (goto-char end) (while (re-search-forward "MOVE \\(.*\\) TO \\(.*\\)" nil t) (replace-match "MOVE \\2 TO \\1"))) -- __Pascal_Bourguignon__ http://www.informatimago.com/ ---------------------------------------------------------------------- Do not adjust your mind, there is a fault in reality.