[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to sort words in a line
From: |
Rainer Stengele |
Subject: |
Re: how to sort words in a line |
Date: |
Tue, 17 Jul 2007 19:57:17 +0200 |
User-agent: |
Thunderbird 2.0.0.4 (Windows/20070604) |
Pascal Bourguignon schrieb:
> Rainer Stengele <rainer.stengele@diplan.de> writes:
>> I just couldn't find a fast solution to sort a line of words:
>>
>> zzz aaa hhhh
>>
>> -->
>>
>> aaa hhhh zzz
>>
>>
>> Did I miss a simple command?
>
> AFAIK, no.
>
> But it's rather simple a command to write:
>
> (defun sort-words-in-lines (start end)
> (interactive "r")
> (goto-char start)
> (beginning-of-line)
> (while (< (setq start (point)) end)
> (let ((words (sort (split-string (buffer-substring start
> (line-end-position)))
> (function string-lessp))))
> (delete-region start (line-end-position))
> (dolist (word words ) (insert word " ")))
> (beginning-of-line) (forward-line 1)))
>
>
thanx!
Wow! Thats quite a piece of code for a not-yet Lisp programmer.
Coming from perl this would be a simple one-liner doing the work.
Don't misunderstand me - I understand the power and flexibility of elisp
in emacs. I just wonder if there is not a built in solution.
Somebody?
rainer
- how to sort words in a line, Rainer Stengele, 2007/07/17
- Re: how to sort words in a line, Pascal Bourguignon, 2007/07/17
- Re: how to sort words in a line,
Rainer Stengele <=
- Re: how to sort words in a line, Thien-Thi Nguyen, 2007/07/17
- Re: how to sort words in a line, Nikolaj Schumacher, 2007/07/17
- Re: how to sort words in a line, Mathias Dahl, 2007/07/18
- Re: how to sort words in a line, Rainer Stengele, 2007/07/18