From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Emacs Lisp Programming Questions Date: Wed, 04 Nov 2009 10:24:39 +0100 Message-ID: <4AF14857.5040209@easy-emacs.de> References: <58e09c24-7598-4920-9318-dc21b9226023@a6g2000vbp.googlegroups.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: ger.gmane.org 1257323129 16113 80.91.229.12 (4 Nov 2009 08:25:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Nov 2009 08:25:29 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: David Combs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 04 09:25:22 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 1N5bBB-0005v9-6S for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Nov 2009 09:25:21 +0100 Original-Received: from localhost ([127.0.0.1]:34717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N5bBA-0005Ia-O0 for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Nov 2009 03:25:20 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N5bAi-0005Hj-K6 for help-gnu-emacs@gnu.org; Wed, 04 Nov 2009 03:24:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N5bAe-0005Ea-2M for help-gnu-emacs@gnu.org; Wed, 04 Nov 2009 03:24:52 -0500 Original-Received: from [199.232.76.173] (port=45707 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N5bAd-0005ES-TW for help-gnu-emacs@gnu.org; Wed, 04 Nov 2009 03:24:47 -0500 Original-Received: from moutng.kundenserver.de ([212.227.17.10]:65257) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N5bAd-0004JL-8x for help-gnu-emacs@gnu.org; Wed, 04 Nov 2009 03:24:47 -0500 Original-Received: from [192.168.178.27] (p54BE8E37.dip0.t-ipconnect.de [84.190.142.55]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0Ls7Kh-1M9kCC3Uy7-013mht; Wed, 04 Nov 2009 09:24:44 +0100 User-Agent: Thunderbird 2.0.0.19 (X11/20081227) In-Reply-To: X-Provags-ID: V01U2FsdGVkX1+tAdRzeAVb/uy26M0bYTTjnIqw9PJ0HpE5vuY P5DZo0QiAxJmFGhul2v+ZQkuMbA2A+wGvwAF0bWo1ZrDYyve9f li1an59i9t6iRUdil/t2PF66yN81SKFwTWmE36FXeI= X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:69466 Archived-At: David Combs wrote: > In article , > Kevin Rodgers wrote: >> clint.laskowski wrote: >>> Hello, gnu.emacs.help. I have a few questions about programming in >>> Emacs Lisp. I hope you can help. Here they are: >>> >>> 1. Is this a good place to ask questions about programming in Emacs >>> Lisp, especially with regards to text processing? If there's a better >>> place, I'd appreciate knowing. >>> >>> 2. I want to write an interactive Elisp program to remove sequential >>> duplicate lines from a buffer. This buffer is not sorted, and it >>> should not be sorted. The program should simply look for two >>> sequential lines that are identical, delete one, and then move on to >>> the next line and do it over until it reaches the end of the buffer. >>> ... In use here (defun just-one-empty-line (&optional beg end) "Delete consecutive empty lines, retain just one. " (interactive "*") (let ((beg (cond (beg beg) ((region-active-p) (region-beginning)) (t (point-min)))) (end (cond (end (copy-marker end)) ((region-active-p) (copy-marker (region-end))) (t (copy-marker (point-max)))))) (save-excursion (save-restriction (narrow-to-region beg end) (goto-char beg) (while (not (eobp)) (while (looking-at "^\\([ \t]*\n\\)[ \t]*$") (delete-region (match-beginning 1) (match-end 1))) (forward-line 1))) (widen)))) Andreas -- https://code.launchpad.net/s-x-emacs-werkstatt/ http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/