all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "John Rabkin" <yoni-r@actcom.com>
Subject: New to elisp, learning by doing
Date: Mon, 17 Feb 2003 00:45:24 +0200	[thread overview]
Message-ID: <pan.2003.02.16.22.45.23.976208@actcom.com> (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

             reply	other threads:[~2003-02-16 22:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-16 22:45 John Rabkin [this message]
2003-02-17  2:03 ` New to elisp, learning by doing 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pan.2003.02.16.22.45.23.976208@actcom.com \
    --to=yoni-r@actcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.