[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to reverse a region of several words?
From: |
tyler |
Subject: |
Re: how to reverse a region of several words? |
Date: |
Mon, 28 Jul 2008 12:00:44 -0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
sunway <sunwayforever@gmail.com> writes:
> e.g. the region contains words like "aaa bbb ccc ddd",I want to
> reverse it to "ddd ccc bbb aaa"
>
I think you probably want the words themselves to stay in the original
order, i.e., one two => two one? If not, if you want to completely
reverse the text, i.e., one two => owt eno, I use the following
function:
(defun reverse-string (beg1 end2)
"Reverse the order of characters in a region.
>From a program takes two point or marker arguments, BEG1 and END2."
(interactive "r")
(if (> beg1 end2)
(let (mid) (setq mid end2 end2 beg1 beg1 mid)))
(while (< beg1 (1- end2))
(let ((end1 (1+ beg1))
(beg2 (1- end2)))
(transpose-regions beg1 end1 beg2 end2))
(incf beg1)
(decf end2)))
Cheers,
Tyler
--
Philosophy of science is about as useful to scientists as ornithology is to
birds. --Richard Feynman
- how to reverse a region of several words?, sunway, 2008/07/28
- Re: how to reverse a region of several words?, Thierry Volpiatto, 2008/07/28
- Re: how to reverse a region of several words?,
tyler <=
- Re: how to reverse a region of several words?, Pascal J. Bourguignon, 2008/07/28
- Message not available
- Re: how to reverse a region of several words?, sunway, 2008/07/28
- Re: how to reverse a region of several words?, Thierry Volpiatto, 2008/07/29
- Re: how to reverse a region of several words?, Pascal J. Bourguignon, 2008/07/29
- Re: how to reverse a region of several words?, sunway, 2008/07/30
- Re: how to reverse a region of several words?, Pascal J. Bourguignon, 2008/07/30
- Re: how to reverse a region of several words?, Thierry Volpiatto, 2008/07/30