[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: |
Mon, 02 Nov 2009 17:29:30 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
dkcombs@panix.com (David Combs) writes:
> In article <mailman.8228.1254921577.2239.help-gnu-emacs@gnu.org>,
> Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote:
>>clint.laskowski wrote:
>>> 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?
>>
>>Start by writing a keyboard macro that does what you want. Then you
>>can translate the commands invoked interactively into function calls.
>
> It'd be cool to be able to get a regexp to extend past the
> end of the line, yes?
>
> BUT WAIT! THIS IS *EMACS* -- doesn't work by lines --
> whole buffer is just one huge long string, with newlines
> interspersed here and there. So, how to refer to a newline
> as a plain old ordinary character, not "end of line" via "$"?
>
> Yes, PLEASE, I'd REALLY like to see an example of such a regexp!
Uh, type C-q C-j to get a newline into a string at the search prompt.
That's not particularly magic.
--
David Kastrup