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: Pascal J. Bourguignon
Subject: Re: how to reverse a region of several words?
Date: Wed, 30 Jul 2008 09:00:51 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux)

sunway <sunwayforever@gmail.com> writes:
>
> On Jul 29, 1:46 pm, p...@informatimago.com (Pascal J. Bourguignon)
> wrote:
>> sunway <sunwayfore...@gmail.com> writes:
>> > I want to transpose "one two" to " two one"
>>
>> put the cursor between one and two and type:
>> M-x transpose-words RET or M-t
>
> no, I want to transpose "one two three four" to "four three two one"

(defun reverse-words (start end)
  (interactive "r")
  (let ((words (reverse (split-string (buffer-substring start end)))))
    (delete-region start end)
    (dolist (word words)
      (insert word " "))
    (backward-char 1)
    (delete-char 1)))


-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
----------> http://www.netmeister.org/news/learn2quote.html <-----------
---> http://homepage.ntlworld.com/g.mccaughan/g/remarks/uquote.html <---

__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

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