From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: delete double lines Date: Fri, 11 Aug 2006 17:05:04 +0200 Organization: Informatimago Message-ID: <87bqqr5n4v.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1155310882 6192 80.91.229.2 (11 Aug 2006 15:41:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 11 Aug 2006 15:41:22 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 11 17:41:20 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GBZ8E-0007aG-Rq for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Aug 2006 17:41:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GBZ84-0006F2-Ok for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Aug 2006 11:40:56 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 71 Original-X-Trace: individual.net KKYnTqaufCd5tm1Kncrt4AfdDHUxGTsHdhIbJNNRhslJD69cyA Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:1ta+BC0T89yfb71lT7tw9/gQ7LU= Original-Xref: shelby.stanford.edu gnu.emacs.help:140978 Original-To: help-gnu-emacs@gnu.org 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:36603 Archived-At: writes: > hello all, > >   > > is there any solution for delete double lines with emacs commands (or macros)? > >   > > f.g. > >   > > line1 > > line1 > > line2 > > line1 > > line2 > >   > > shall be processed to > >   > > line1 > > line2 > >   > >   > > thanks and greetings from munich >>From emacs, I would select the range of lines, then type: C-u M-| sort -u | sed -n -e p -e 's/.*//p' RET If you want a pure emacs solution: (require 'cl) (defun sort-unique-lines-with-double-spacing (start end) (interactive "r") (save-excursion (goto-char start) (let ((lines '())) (while (and (< (point) end) (re-search-forward "^\\(.*\\)$" end t)) (push (buffer-substring (match-beginning 0) (match-end 0)) lines)) (message "%S" lines) (delete-region start end) (dolist (line (sort (delete-duplicates lines :test (function string=)) (function string-lessp))) (insert (format "%s\n\n" line)))))) Then you can select the range of lines, and type M-x sort-unique-lines-with-double-spacing RET -- __Pascal Bourguignon__ http://www.informatimago.com/ HEALTH WARNING: Care should be taken when lifting this product, since its mass, and thus its weight, is dependent on its velocity relative to the user.