From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rainer Stengele Newsgroups: gmane.emacs.help Subject: Re: how to sort words in a line Date: Tue, 17 Jul 2007 19:57:17 +0200 Organization: A noiseless patient Spider Message-ID: References: <87r6n7l41m.fsf@thalassa.lan.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1184697702 8991 80.91.229.12 (17 Jul 2007 18:41:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 17 Jul 2007 18:41:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 17 20:41:40 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IArzO-0007m8-52 for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Jul 2007 20:41:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IArzN-0003X4-Np for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Jul 2007 14:41:37 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!xs4all!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-X-Trace: tomate.motzarella.org U2FsdGVkX194Ca5TcJkd0AuuQ1XU0LKtLVlXri+oxWiJqnhlN7H7NS3KPjsYy91YTWb9JDwrQOne9w4qZ2Ji9HoAmWnFPKyWwTZJA8Qf1S0aKH6WOETDpATSjUUwZ2LkvK/Gmye2cVpqUXMtC8E5kw== Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Tue, 17 Jul 2007 17:57:14 +0000 (UTC) In-Reply-To: <87r6n7l41m.fsf@thalassa.lan.informatimago.com> X-Auth-Sender: U2FsdGVkX1+gE5sF7TjunemcOBrhNrDK7JCz9YZBtGhZxmbeaKqMJ8IlJkufOwsh User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) Original-Xref: shelby.stanford.edu gnu.emacs.help:150176 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:45762 Archived-At: Pascal Bourguignon schrieb: > Rainer Stengele 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