From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Using append to create a list from a line of text Date: Wed, 17 Apr 2013 12:27:58 -0400 Organization: A noiseless patient Spider Message-ID: References: <87ip3m6vyj.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1366218138 27817 80.91.229.3 (17 Apr 2013 17:02:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Apr 2013 17:02:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 17 19:02:22 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1USVkU-0002mP-17 for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Apr 2013 19:02:22 +0200 Original-Received: from localhost ([::1]:34250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USVkT-0001nM-Af for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Apr 2013 13:02:21 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Injection-Info: barmar.motzarella.org; posting-host="2be9e9f5dd9af768b8861af71b85fc28"; logging-data="29535"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VJhlZ18mNuc1/8Ubea0x6" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:9b5hoqxQKXgIVN9HRCz8JFRHIuo= Original-Xref: usenet.stanford.edu gnu.emacs.help:197944 X-Mailman-Approved-At: Wed, 17 Apr 2013 13:02:10 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90211 Archived-At: In article <87ip3m6vyj.fsf@kuiper.lan.informatimago.com>, "Pascal J. Bourguignon" wrote: > acomber writes: > > > I want to create a list of words from a line of text delimitted by tabs. I > > want to basically split the line into atoms, split by tab. > > > > The code below is sort of pseudocode but is this the best approach to do > > this type of thing? > > > > Here is my first attempt:- > > > > (defun get-hdr() > > ;obviously point must be positioned on correct line > > (let (mylist) > > while(not (end-of-line) > > while(re-search-forward ("[A-Za-z]+[^\t\n]" nil t) > > append (match-string 1) mylist > > ) > > ) > > ) > > ) > > Nice, but it's not formatted correctly. I'd avise you to use > paredit-mode. > > Adding and removing newlines where one should, and letting emacs indent > the sexp, we get this text: > > > (defun get-hdr() > ;; obviously point must be positioned on correct line > (let (mylist) > while > (not (end-of-line) > while > (re-search-forward ("[A-Za-z]+[^\t\n]" nil t) > append > (match-string 1) > mylist)))) > > Now, two obvious things: > > 1- undefined variable named `while'. Where does that variable come > from? > > 2- the function `not' is passed three arguments, when it expects only > one! I think you missed that he said this was pseudo-code, not valid Lisp code. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***