From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: kai.grossjohann@uni-duisburg.de (Kai =?iso-8859-1?q?Gro=DFjohann?=) Newsgroups: gmane.emacs.help Subject: Re: New to elisp, learning by doing Date: Mon, 17 Feb 2003 08:16:51 +0100 Organization: University of Duisburg, Germany Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <84of5bidgc.fsf@lucy.is.informatik.uni-duisburg.de> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1045468874 16489 80.91.224.249 (17 Feb 2003 08:01:14 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 17 Feb 2003 08:01:14 +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 18kgDA-0004Hm-00 for ; Mon, 17 Feb 2003 09:01:12 +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 18kgCy-0000TI-0B for gnu-help-gnu-emacs@m.gmane.org; Mon, 17 Feb 2003 03:01:00 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!lucy.is.informatik.uni-duisburg.DE!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 24 Original-NNTP-Posting-Host: lucy.is.informatik.uni-duisburg.de (134.91.35.216) Original-X-Trace: fu-berlin.de 1045468675 49009116 134.91.35.216 (16 [73968]) User-Agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.3.50 Cancel-Lock: sha1:aa3ydnq0myMLcLswfb8zD/UBcvQ= Original-Xref: shelby.stanford.edu gnu.emacs.help:110262 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:6764 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6764 "John Rabkin" writes: > 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. I would collect the header tags and/or their contents in a list of strings, I think. Then, after reaching the end of the buffer, I'd write them out near the beginning of the buffer. (let ((toc nil)) (goto-char (point-max)) (while (re-search-backward REGEXP nil t) (setq toc (cons TOC-ENTRY toc))) INSERT-TOC) Note that I'm searching backwards because the entries are added to the beginning of the list. If searching backwards proves inconvenient, then you could reverse the list (using nreverse) after you're done. Or you implement a little queue. Queues are not a standard Lisp datatype, I'm afraid. (Or is there an Emacs Lisp package for this?) -- A turnip curses Elvis