[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: forward-sexp for strings
From: |
Henrik Enberg |
Subject: |
Re: forward-sexp for strings |
Date: |
Thu, 10 Nov 2005 22:04:09 +0100 (CET) |
> From: Roland Winkler <winkler@tfkp07.physik.uni-erlangen.de>
> Date: Thu, 10 Nov 2005 21:51:29 +0100
> Pascal Bourguignon <spam@mouse-potato.com> writes:
>> Roland Winkler <roland.winkler@physik.uni-erlangen.de> writes:
>>
>>> The function forward-sexp requires a buffer. Is there something
>>> similar for parsing strings? Of course, I can always use
>>> with-temp-buffer.
>>
>> (require 'cl)
>> (loop with s = "(sexp 1) (sexp 2) \"sexp 3\" sexp-4"
>> with e = 0
>> for oe = (read-from-string s e)
>> do (print (car oe))
>> while (< (setf e (cdr oe)) (length s)))
> Do I need here the (require 'cl)? It seems to me that
> read-from-string is really the important thing in your example. And
> if this function obeys the current syntax-table (the doc string
> doesn't say anything about that) it should be exactly what I am
> looking for.
the `loop' macro is defined in cl.el, so you'll need it. Personally,
I'd just use with-temp-buffer. It's far more straightforward.