[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
- Emacs Lisp Programming Questions, clint.laskowski, 2009/10/06
- Re: Emacs Lisp Programming Questions, Pascal J. Bourguignon, 2009/10/06
- Re: Emacs Lisp Programming Questions, David Kastrup, 2009/10/07
- Re: Emacs Lisp Programming Questions, djc, 2009/10/07
- Re: Emacs Lisp Programming Questions, Kevin Rodgers, 2009/10/07
- Re: Emacs Lisp Programming Questions, mdj, 2009/10/07
- Re: Emacs Lisp Programming Questions, Xah Lee, 2009/10/07
- Re: Emacs Lisp Programming Questions, clint.laskowski, 2009/10/08
- Re: Emacs Lisp Programming Questions,
Andreas Politz <=