* forward-sexp for strings
@ 2005-11-10 18:43 Roland Winkler
2005-11-10 20:01 ` Pascal Bourguignon
0 siblings, 1 reply; 6+ messages in thread
From: Roland Winkler @ 2005-11-10 18:43 UTC (permalink / raw)
The function forward-sexp requires a buffer. Is there something
similar for parsing strings? Of course, I can always use
with-temp-buffer.
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: forward-sexp for strings
2005-11-10 18:43 forward-sexp for strings Roland Winkler
@ 2005-11-10 20:01 ` Pascal Bourguignon
2005-11-10 20:51 ` Roland Winkler
2005-11-22 20:14 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Pascal Bourguignon @ 2005-11-10 20:01 UTC (permalink / raw)
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)))
(sexp 1)
(sexp 2)
"sexp 3"
sexp-4
nil
--
__Pascal Bourguignon__ http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: forward-sexp for strings
2005-11-10 20:01 ` Pascal Bourguignon
@ 2005-11-10 20:51 ` Roland Winkler
2005-11-10 21:04 ` Henrik Enberg
[not found] ` <mailman.14777.1131656654.20277.help-gnu-emacs@gnu.org>
2005-11-22 20:14 ` Stefan Monnier
1 sibling, 2 replies; 6+ messages in thread
From: Roland Winkler @ 2005-11-10 20:51 UTC (permalink / raw)
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.
Thanks!
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: forward-sexp for strings
2005-11-10 20:51 ` Roland Winkler
@ 2005-11-10 21:04 ` Henrik Enberg
[not found] ` <mailman.14777.1131656654.20277.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Henrik Enberg @ 2005-11-10 21:04 UTC (permalink / raw)
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: forward-sexp for strings
[not found] ` <mailman.14777.1131656654.20277.help-gnu-emacs@gnu.org>
@ 2005-11-10 21:16 ` Roland Winkler
0 siblings, 0 replies; 6+ messages in thread
From: Roland Winkler @ 2005-11-10 21:16 UTC (permalink / raw)
Henrik Enberg <henrik.enberg@telia.com> writes:
>>> (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.
If I strictly implement the above example, I'll need cl.el. But it
seems to me that `while' can do the job, too. (Haven't tried yet
what I want to do with this.)
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: forward-sexp for strings
2005-11-10 20:01 ` Pascal Bourguignon
2005-11-10 20:51 ` Roland Winkler
@ 2005-11-22 20:14 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-11-22 20:14 UTC (permalink / raw)
>> The function forward-sexp requires a buffer. Is there something
>> similar for parsing strings? Of course, I can always use
>> with-temp-buffer.
Use a buffer.
> for oe = (read-from-string s e)
read-from-string is indeed an alternative, but only to parse strings whose
content uses the elisp syntax.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-11-22 20:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-10 18:43 forward-sexp for strings Roland Winkler
2005-11-10 20:01 ` Pascal Bourguignon
2005-11-10 20:51 ` Roland Winkler
2005-11-10 21:04 ` Henrik Enberg
[not found] ` <mailman.14777.1131656654.20277.help-gnu-emacs@gnu.org>
2005-11-10 21:16 ` Roland Winkler
2005-11-22 20:14 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).