help-gnu-emacs
[Top][All Lists]
Advanced

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

New to elisp, learning by doing


From: John Rabkin
Subject: New to elisp, learning by doing
Date: Mon, 17 Feb 2003 00:45:24 +0200
User-agent: Pan/0.13.0 (The whole remains beautiful)

I've decided to learn some elisp to ease some of my work (I edit allot of
HTML and use emacs exclusively). I have a method for exploring new
languages: I set myself a simple goal such as a program that does a small
task and try to learn about the language through hacking that program.
If the simple program ends up being useful then I'm even happier.

My goal in elisp is a .el that writes a table of contents from HTML
headers. The program would search for header tags in the buffer beginning
at point and write them in order one under the other.

After fighting with elisp for a couple of weeks in my spare time I turn to
anyone who can give me a clue or a push in the right direction. This is
what I have:

 (defun html-yank-header ()
  "Copies and yanks HTML headers"
  (interactive)
  (save-excursion
    (setq start_p (- (re-search-forward "\<h[12345]*\>") 4)) 
    (setq end_p (re-search-forward "\<\/h[12345]\>")) 
    (copy-region-as-kill start_p end_p)
    )
  (yank)
  )

This grabs the header closest to point and copies it to point. Now I need
the program to recurse N times where N is the number of header tags in the
buffer.

I do not expect nor do I desire a solution. I would ideally like to be
pointed in the right direction. My experiments with while loops turn out
ungainly and to big to seem right.

Thank you in advance for anyone who took the time to read this.

-- 
"Cut your own wood and it will warm you twice"
        Regards, Yoni Rabkin



reply via email to

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