| Subject: | Re: how to reverse a region of several words? |
|---|---|
| From: | Thierry Volpiatto <thierry.volpiatto@xxxxxxxxx> |
| Date: | Wed, 30 Jul 2008 09:43:56 +0200 |
| Newsgroups: | gnu.emacs.help |
sunway <sunwayforever@xxxxxxxxx> writes: > no, I want to transpose "one two three four" to "four three two one" ,---- | (defun reverse-sentence-region (&optional separator) | (interactive "P") | (let ((beg (point)) | (sentence) | (separator)) | (when current-prefix-arg | (setq separator (read-string "Separator: "))) | (kill-region beg (mark)) | (setq sentence (nth 0 kill-ring)) | (setq sentence (split-string sentence (if separator | separator))) | (setq sentence (reverse sentence)) | (setq sentence (mapconcat #'(lambda (x) x) | sentence | (if separator | separator | " "))) | (insert sentence))) `---- 1) Mark region 2) Run M-x reverse-sentence-region or C-u M-x reverse-sentence-region if the words in region are separated with something else than " " > On Jul 29, 1:46 pm, p...@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon) > wrote: >> sunway <sunwayfore...@xxxxxxxxx> 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 >> >> -- >> __Pascal Bourguignon__ http://www.informatimago.com/ >> >> NOTE: The most fundamental particles in this product are held >> together by a "gluing" force about which little is currently known >> and whose adhesive power can therefore not be permanently >> guaranteed. > -- A + Thierry Volpiatto Location: Saint-Cyr-Sur-Mer - France |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: how to reverse a region of several words?, Pascal J. Bourguignon |
|---|---|
| Next by Date: | Re: What does 'run' do in cperl-mode?, Andreas Eder |
| Previous by Thread: | Re: how to reverse a region of several words?, Pascal J. Bourguignon |
| Next by Thread: | Re: how to reverse a region of several words?, Pascal J. Bourguignon |
| Indexes: | [Date] [Thread] [Top] [All Lists] |