From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: Emacs Lisp Programming Questions Date: Wed, 07 Oct 2009 10:40:23 +0200 Organization: Organization?!? Message-ID: <87d44zk360.fsf@lola.goethe.zz> References: <58e09c24-7598-4920-9318-dc21b9226023@a6g2000vbp.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1254908571 20465 80.91.229.12 (7 Oct 2009 09:42:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Oct 2009 09:42:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 07 11:42:41 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 1MvT2A-0005fe-RL for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Oct 2009 11:42:11 +0200 Original-Received: from localhost ([127.0.0.1]:44131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvT2A-00030K-4i for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Oct 2009 05:42:10 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!goblin1!goblin.stu.neva.ru!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:oMoyri6edMgX9P2hpagPAL9AlLg= Original-Lines: 32 Original-NNTP-Posting-Date: 07 Oct 2009 10:40:24 CEST Original-NNTP-Posting-Host: cc9fe635.newsspool1.arcor-online.net Original-X-Trace: DXC=iSQIQfJYVB8_A0jCfgHO6>ic==]BZ:af>4Fo<]lROoR1^YC2XCjHcb9[O 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:68718 Archived-At: "clint.laskowski" writes: > 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. > > BUT, I do not want the answer to this problem (i.e., I don't want an > Elisp answer) ... I want hints on how to program it. I want to learn > the answer myself, if possible. > > Any ideas or pointers? You can just walk through the buffer line and enter each line into a hashtable. If the respective puthash leads to a difference in hash-count, the line was not in the hashtable before. Otherwise, delete the line. You might want to do clrhash afterwards so that the strings can get garbage collected without waiting for the hashtable to get collected first. Not sure whether this really is necessary. -- David Kastrup