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: Andreas Politz
Subject: Re: Emacs Lisp Programming Questions
Date: Thu, 08 Oct 2009 16:35:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

"clint.laskowski" <clint.laskowski@gmail.com> writes:

> On Oct 6, 5:40 pm, "clint.laskowski" <clint.laskow...@gmail.com>
> 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





reply via email to

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