help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to reverse a region of several words?


From: Thierry Volpiatto
Subject: Re: how to reverse a region of several words?
Date: Mon, 28 Jul 2008 11:03:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

sunway <address@hidden> writes:

> e.g. the region contains words like "aaa bbb ccc ddd",I want to
> reverse it to "ddd ccc bbb aaa"
>
kill your region with some kill func (check elisp man)
and store it (A)
Be sure to remember the position of your text.
,----
| ELISP> (setq A "aaa bbb ccc ddd")
| "aaa bbb ccc ddd"
| ELISP> (setq A (split-string A))
| ("aaa" "bbb" "ccc" "ddd")
| 
| ELISP> (setq A (reverse A))
| ("ddd" "ccc" "bbb" "aaa")
| 
| ELISP> (mapconcat #'(lambda (x) x) A " ")
| "ddd ccc bbb aaa"
`----
And now insert the new text at the saved position.
-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




reply via email to

[Prev in Thread] Current Thread [Next in Thread]