help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs Lisp Programming Questions


From: David Kastrup
Subject: Re: Emacs Lisp Programming Questions
Date: Wed, 07 Oct 2009 10:40:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

"clint.laskowski" <clint.laskowski@gmail.com> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]