unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* New to elisp, learning by doing
@ 2003-02-16 22:45 John Rabkin
  2003-02-17  2:03 ` Christopher J. White
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: John Rabkin @ 2003-02-16 22:45 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-02-18 10:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-16 22:45 New to elisp, learning by doing John Rabkin
2003-02-17  2:03 ` Christopher J. White
2003-02-17  7:16 ` Kai Großjohann
2003-02-17  9:27   ` Hannu Koivisto
2003-02-18  8:02     ` Kai Großjohann
2003-02-17 18:24   ` Ehud Karni
     [not found]   ` <mailman.2034.1045507046.21513.help-gnu-emacs@gnu.org>
2003-02-17 19:50     ` Kai Großjohann
2003-02-18 10:26   ` Oliver Scholz
2003-02-17 18:47 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).