From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: Emacs Lisp Programming Questions Date: Thu, 08 Oct 2009 16:35:41 +0200 Message-ID: <87my42t0le.fsf@fh-trier.de> References: <58e09c24-7598-4920-9318-dc21b9226023@a6g2000vbp.googlegroups.com> <8f3a7482-bcbc-4d53-950a-b227d07ec175@m18g2000vbs.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1255013138 14145 80.91.229.12 (8 Oct 2009 14:45:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2009 14:45:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 08 16:45:26 2009 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 1MvuD6-0006Tn-HR for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Oct 2009 16:43:16 +0200 Original-Received: from localhost ([127.0.0.1]:35656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvuD6-0005al-4w for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Oct 2009 10:43:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mvu8W-0003Xr-S5 for help-gnu-emacs@gnu.org; Thu, 08 Oct 2009 10:38:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mvu8R-0003XC-Jc for help-gnu-emacs@gnu.org; Thu, 08 Oct 2009 10:38:31 -0400 Original-Received: from [199.232.76.173] (port=44379 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mvu8R-0003X9-Ba for help-gnu-emacs@gnu.org; Thu, 08 Oct 2009 10:38:27 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:55763) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mvu8Q-0001uh-JS for help-gnu-emacs@gnu.org; Thu, 08 Oct 2009 10:38:26 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1Mvu7g-0002Ev-8K for help-gnu-emacs@gnu.org; Thu, 08 Oct 2009 16:37:40 +0200 Original-Received: from dslb-088-068-210-160.pools.arcor-ip.net ([88.68.210.160]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Oct 2009 16:37:40 +0200 Original-Received: from politza by dslb-088-068-210-160.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Oct 2009 16:37:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-088-068-210-160.pools.arcor-ip.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:KGG/UMRLfQIXVP1H49XVmoQpg58= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:68768 Archived-At: "clint.laskowski" writes: > On Oct 6, 5:40 pm, "clint.laskowski" > wrote: > [...] > > I appreciate all the pointers and ideas. I ended up finding a solution > (instead of learning it myself, but that's okay - since I actually > learned more from the responses here) which is now in my .emacs file: > > (defun uniquify-region (beg end) > "remove duplicate adjacent lines in the given region" > (interactive "*r") > (goto-char beg) > (while (re-search-forward "^\\(.*\n\\)\\1+" end t) > (replace-match "\\1"))) > [...] But you still can improve it. Marking the first 4 lines of a's and doing `M-x uniquify-region' leaves the buffer with 2 lines left, instead of 3. aaa aaa aaa aaa bbb bbb -ap