* a simple string manipulation
@ 2003-04-05 14:04 Luca Ferrari
0 siblings, 0 replies; 3+ messages in thread
From: Luca Ferrari @ 2003-04-05 14:04 UTC (permalink / raw)
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
--
Luca Ferrari,
fluca1978@libero.it
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: a simple string manipulation
[not found] <mailman.4152.1049555367.21513.help-gnu-emacs@gnu.org>
@ 2003-04-05 16:36 ` Kai Großjohann
2003-04-06 4:16 ` Pascal Bourguignon
1 sibling, 0 replies; 3+ messages in thread
From: Kai Großjohann @ 2003-04-05 16:36 UTC (permalink / raw)
Luca Ferrari <fluca1978@libero.it> writes:
> MOVE A TO B
> MOVE B TO A
Well, putting point between A and TO, then M-t M-t M-b M-t, does the
trick. Maybe better than nothing.
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: a simple string manipulation
[not found] <mailman.4152.1049555367.21513.help-gnu-emacs@gnu.org>
2003-04-05 16:36 ` a simple string manipulation Kai Großjohann
@ 2003-04-06 4:16 ` Pascal Bourguignon
1 sibling, 0 replies; 3+ messages in thread
From: Pascal Bourguignon @ 2003-04-06 4:16 UTC (permalink / raw)
Luca Ferrari <fluca1978@libero.it> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-06 4:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.4152.1049555367.21513.help-gnu-emacs@gnu.org>
2003-04-05 16:36 ` a simple string manipulation Kai Großjohann
2003-04-06 4:16 ` Pascal Bourguignon
2003-04-05 14:04 Luca Ferrari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).