From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "John Rabkin" Newsgroups: gmane.emacs.help Subject: New to elisp, learning by doing Date: Mon, 17 Feb 2003 00:45:24 +0200 Organization: Verio Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: main.gmane.org 1045435469 25709 80.91.224.249 (16 Feb 2003 22:44:29 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 16 Feb 2003 22:44:29 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18kXWN-0006gU-00 for ; Sun, 16 Feb 2003 23:44:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18kXXL-0003dB-01 for gnu-help-gnu-emacs@m.gmane.org; Sun, 16 Feb 2003 17:45:27 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!iad-peer.news.verio.net!dfw-peer!news.verio.net!iad-read.news.verio.net.POSTED!not-for-mail User-Agent: Pan/0.13.0 (The whole remains beautiful) Original-Newsgroups: gnu.emacs.help X-NNTP-Posting-Host: line134-129.adsl.actcom.co.il Original-Lines: 39 Original-NNTP-Posting-Host: 192.114.47.10 Original-X-Complaints-To: abuse@verio.net Original-X-Trace: iad-read.news.verio.net 1045435370 192.114.47.10 (Sun, 16 Feb 2003 22:42:50 GMT) Original-NNTP-Posting-Date: Sun, 16 Feb 2003 22:42:50 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:110254 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6756 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6756 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 "\") 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