[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs Lisp Programming Questions
From: |
clint.laskowski |
Subject: |
Re: Emacs Lisp Programming Questions |
Date: |
Thu, 8 Oct 2009 06:36:23 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Oct 6, 5:40 pm, "clint.laskowski" <clint.laskow...@gmail.com>
wrote:
> 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.
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")))
(defun uniquify-buffer ()
(interactive)
(uniquify-region (point-min) (point-max)))
Thanks again for the help!
-- Clint
- 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 <=