[Top][All Lists]

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

Re: Emacs Lisp Programming Questions

From: Andreas Röhler
Subject: Re: Emacs Lisp Programming Questions
Date: Wed, 04 Nov 2009 10:24:39 +0100
User-agent: Thunderbird (X11/20081227)

David Combs wrote:
> In article <address@hidden>,
> Kevin Rodgers  <address@hidden> wrote:
>> clint.laskowski wrote:
>>> Hello, 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)
                   (t (point-min))))
        (end (cond (end (copy-marker end))
                    (copy-marker (region-end)))
                   (t (copy-marker (point-max))))))
        (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)))



reply via email to

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