From edi at agharta.de Sat Aug 9 20:31:46 2008 From: edi at agharta.de (Edi Weitz) Date: Sat, 09 Aug 2008 22:31:46 +0200 Subject: [cl-who-devel] with-html-output-to-string (str) In-Reply-To: (Edi Weitz's message of "Thu, 07 Feb 2008 00:35:40 +0100") References: Message-ID: On Thu, 07 Feb 2008 00:35:40 +0100, Edi Weitz wrote: > On Thu, 31 Jan 2008 01:36:11 -0600, "Victor Kryukov" wrote: > >> The following code produces errors on two of my systems (Linux and >> Mac) for both CLISP and SBCL: >> >> (require 'asdf) >> (asdf:oos 'asdf:load-op :cl-who) >> >> (defpackage :test >> (:use :cl :cl-who)) >> >> (in-package :test) >> >> (with-html-output-to-string (str) >> (:html (:title "test"))) >> >> It looks like a bug, macro variable capture, to me, but it may well >> be my misunderstanding/misuse of CL-WHO. >> >> I'd appreciate your comments, as usual. > > Sorry for the delay. Just a confirmation that this seems to be a > bug. Will be fixed in the next days when I find some time. I didn't have much time to look at CL-WHO in the last months, but as an update let me say that with the current behaviour this isn't really a bug (as in variable capture) but rather a result of how CL-WHO is implemented. I'm currently working on changing this. In the meantime, don't use STR (or ESC etc.) as a variable name... :) Edi. From lispercat at gmail.com Tue Aug 12 22:07:46 2008 From: lispercat at gmail.com (Andrei Stebakov) Date: Tue, 12 Aug 2008 18:07:46 -0400 Subject: [cl-who-devel] Changing *attribute-quote-char* Message-ID: By default the variable is initialized to #\' If I want to change it to #\" via local binding I still get the single quotes in the resulting string. (let ((*attribute-quote-char* #\")) (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil) (:html (:head (:title "title") (:meta :name "DESCRIPTION" :content "description") (:meta :name "KEYWORDS" :content "keywords"))))) I get: "title" Is it possible to make a local new binding or I should change it only globally? Thank you, Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at jensteich.de Tue Aug 12 22:21:11 2008 From: info at jensteich.de (Jens Teich) Date: Wed, 13 Aug 2008 00:21:11 +0200 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: References: Message-ID: <48A20CD7.6010502@jensteich.de> Andrei Stebakov schrieb: > By default the variable is initialized to #\' > If I want to change it to #\" via local binding I still get the single > quotes in the resulting string. > > (let ((*attribute-quote-char* #\")) > (with-html-output-to-string (*standard-output* nil :prologue nil > :indent nil) > (:html > (:head > (:title "title") > (:meta :name "DESCRIPTION" :content "description") > (:meta :name "KEYWORDS" :content "keywords"))))) > > I get: > "title content='description' /> />" I get the correct result evaluating exactly your form: CL-WHO 507 > (let ((*attribute-quote-char* #\")) (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil) (:html (:head (:title "title") (:meta :name "DESCRIPTION" :content "description") (:meta :name "KEYWORDS" :content "keywords"))))) "title" LW 5.1 cl-who 0.11.0 Mac OS X 10.5 Jens From lispercat at gmail.com Tue Aug 12 22:40:03 2008 From: lispercat at gmail.com (Andrei Stebakov) Date: Tue, 12 Aug 2008 18:40:03 -0400 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: <48A20CD7.6010502@jensteich.de> References: <48A20CD7.6010502@jensteich.de> Message-ID: It should work, I am quite baffled that it doesn't... It's Ubuntu with sbcl 1.0.18, cl-who 0.11.0 What's funny is that even when I set it to #\" globally and evaluate it in the lisp, it's not enough for hunchentoot to pick it up. I have to evaluate it in the lisp image + put the (setf *attribute-quote-char* #\") in the body of the hunchentoot handler! I tried to put the cl-who prefix to the variable, but it doesn't make any difference. Andrew On Tue, Aug 12, 2008 at 6:21 PM, Jens Teich wrote: > Andrei Stebakov schrieb: > >> By default the variable is initialized to #\' >> If I want to change it to #\" via local binding I still get the single >> quotes in the resulting string. >> >> (let ((*attribute-quote-char* #\")) >> (with-html-output-to-string (*standard-output* nil :prologue nil :indent >> nil) >> (:html >> (:head >> (:title "title") >> (:meta :name "DESCRIPTION" :content "description") >> (:meta :name "KEYWORDS" :content "keywords"))))) >> >> I get: >> "title> content='description' />> />" >> > > > I get the correct result evaluating exactly your form: > > CL-WHO 507 > > (let ((*attribute-quote-char* #\")) > (with-html-output-to-string (*standard-output* nil :prologue nil :indent > nil) > (:html > (:head > (:title "title") > (:meta :name "DESCRIPTION" :content "description") > (:meta :name "KEYWORDS" :content "keywords"))))) > "title content=\"description\" /> />" > > LW 5.1 > cl-who 0.11.0 > Mac OS X 10.5 > > Jens > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at jensteich.de Tue Aug 12 23:01:39 2008 From: info at jensteich.de (Jens Teich) Date: Wed, 13 Aug 2008 01:01:39 +0200 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: References: <48A20CD7.6010502@jensteich.de> Message-ID: <48A21653.1060904@jensteich.de> Andrei Stebakov schrieb: > It should work, I am quite baffled that it doesn't... > It's Ubuntu with sbcl 1.0.18, cl-who 0.11.0 > What's funny is that even when I set it to #\" globally and evaluate it > in the lisp, it's not enough for hunchentoot to pick it up. > I have to evaluate it in the lisp image + put the (setf > *attribute-quote-char* #\") in the body of the hunchentoot handler! > I tried to put the cl-who prefix to the variable, but it doesn't make > any difference. > > Andrew Ah, with SBCL 1.0.15 I see the same: WHO> (let ((*attribute-quote-char* #\")) (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil) (:html (:head (:title "title") (:meta :name "DESCRIPTION" :content "description") (:meta :name "KEYWORDS" :content "keywords"))))) "title" Unfortunately Edi is on vacation ... Jens From info at jensteich.de Tue Aug 12 23:32:13 2008 From: info at jensteich.de (Jens Teich) Date: Wed, 13 Aug 2008 01:32:13 +0200 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: <48A21653.1060904@jensteich.de> References: <48A20CD7.6010502@jensteich.de> <48A21653.1060904@jensteich.de> Message-ID: <48A21D7D.3000701@jensteich.de> Changing in specials.lisp helps of course: (defparameter *attribute-quote-char* #\" "Quote character for attributes.") But then you can't switch back to #\'. Jens From lispercat at gmail.com Tue Aug 12 23:38:33 2008 From: lispercat at gmail.com (Andrei Stebakov) Date: Tue, 12 Aug 2008 19:38:33 -0400 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: <48A21D7D.3000701@jensteich.de> References: <48A20CD7.6010502@jensteich.de> <48A21653.1060904@jensteich.de> <48A21D7D.3000701@jensteich.de> Message-ID: This is what I did for now. Not the cleanest solution but it works ;) On Tue, Aug 12, 2008 at 7:32 PM, Jens Teich wrote: > Changing in specials.lisp helps of course: > > (defparameter *attribute-quote-char* #\" > "Quote character for attributes.") > > But then you can't switch back to #\'. > > > Jens > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From edi at agharta.de Wed Aug 13 11:16:05 2008 From: edi at agharta.de (Edi Weitz) Date: Wed, 13 Aug 2008 13:16:05 +0200 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: (Andrei Stebakov's message of "Tue, 12 Aug 2008 18:07:46 -0400") References: Message-ID: On Tue, 12 Aug 2008 18:07:46 -0400, "Andrei Stebakov" wrote: > By default the variable is initialized to #\' If I want to change it > to #\" via local binding I still get the single quotes in the > resulting string. WITH-HTML-OUTPUT is a macro, so what is relevant is the value of *ATTRIBUTE-QUOTE-CHAR* at macro expansion time. If you play around in the REPL, this is obviously different for Lisps which always compile everything (like SBCL) and Lisps which use an interpreter for REPL forms (like LispWorks). See chapter 3 of the CLHS for details. Edi (still on vacation). From lispercat at gmail.com Fri Aug 15 19:47:54 2008 From: lispercat at gmail.com (Andrei Stebakov) Date: Fri, 15 Aug 2008 15:47:54 -0400 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: References: Message-ID: I was not just playing with REPL, I tried to compile the code and reloaded the image (let ((*attribute-quote-char* #\")) (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil) (:html (:head (:title "title") (:meta :name "DESCRIPTION" :content "description") (:meta :name "KEYWORDS" :content "keywords"))))) but I still had a single quote in the resulting code. Andrew On Wed, Aug 13, 2008 at 7:16 AM, Edi Weitz wrote: > On Tue, 12 Aug 2008 18:07:46 -0400, "Andrei Stebakov" > wrote: > > > By default the variable is initialized to #\' If I want to change it > > to #\" via local binding I still get the single quotes in the > > resulting string. > > WITH-HTML-OUTPUT is a macro, so what is relevant is the value of > *ATTRIBUTE-QUOTE-CHAR* at macro expansion time. If you play around in > the REPL, this is obviously different for Lisps which always compile > everything (like SBCL) and Lisps which use an interpreter for REPL > forms (like LispWorks). See chapter 3 of the CLHS for details. > > Edi (still on vacation). > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lispercat at gmail.com Fri Aug 15 21:09:35 2008 From: lispercat at gmail.com (Andrei Stebakov) Date: Fri, 15 Aug 2008 17:09:35 -0400 Subject: [cl-who-devel] Macro expansion... Message-ID: I am trying to incorporate parenscript into cl-who tree. I tried to insert a small macro but for some reasons I get various errors linke "cl-who:fmt not defined" or ":script not defined". I guess I need help to figure out the way macros work with cl-who... (defmacro js-body (&rest body) `(:script :type "text/javascript" (fmt (ps , at body)))) (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil) (:html (:head (:title "Some title")) (js-body (defun some-func () (alert "Hello!"))))) I think parenscript is not really relevant to the task, so I am looking for some help to figure out why I have these expansion errors. BTW, when I run (macroexpand '(with-html-output-to-string (*standard-output* nil :prologue nil :indent nil) (:html (:head (:title "Some title")) (js-body (defun some-func () (alert "Hello!")))))) I get: (LET ((*STANDARD-OUTPUT* (MAKE-STRING-OUTPUT-STREAM :ELEMENT-TYPE 'CHARACTER))) (UNWIND-PROTECT (PROGN (WITH-HTML-OUTPUT (*STANDARD-OUTPUT* NIL :PROLOGUE NIL :INDENT NIL) (:HTML (:HEAD (:TITLE "Some title")) (JS-BODY (DEFUN SOME-FUNC () (ALERT "Hello!")))))) (CLOSE *STANDARD-OUTPUT*)) (GET-OUTPUT-STREAM-STRING *STANDARD-OUTPUT*)) The HyperSpec says: "*macroexpand* <#macroexpand> repeatedly expands *form*until it is no longer a *macro form"* <26_glo_m.htm#macro_form> Why js-body or with-html-output doesn't get expanded in this case? I am using sbcl 1.0.18 on Ubuntu. Thank you! Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From edi at agharta.de Fri Aug 15 22:31:45 2008 From: edi at agharta.de (Edi Weitz) Date: Sat, 16 Aug 2008 00:31:45 +0200 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: (Andrei Stebakov's message of "Fri, 15 Aug 2008 15:47:54 -0400") References: Message-ID: On Fri, 15 Aug 2008 15:47:54 -0400, "Andrei Stebakov" wrote: > I was not just playing with REPL, I tried to compile the code and > reloaded the image I don't understand. What do you mean when you say "reloaded the image"? Could you provide a detailed explanation of what you've done? Can you check if this works differently for other Lisps like LispWorks? From edi at agharta.de Fri Aug 15 22:38:26 2008 From: edi at agharta.de (Edi Weitz) Date: Sat, 16 Aug 2008 00:38:26 +0200 Subject: [cl-who-devel] Macro expansion... In-Reply-To: (Andrei Stebakov's message of "Fri, 15 Aug 2008 17:09:35 -0400") References: Message-ID: On Fri, 15 Aug 2008 17:09:35 -0400, "Andrei Stebakov" wrote: > I am trying to incorporate parenscript into cl-who tree. I tried to > insert a small macro but for some reasons I get various errors linke > "cl-who:fmt not defined" or ":script not defined". I guess I need > help to figure out the way macros work with cl-who... > > (defmacro js-body (&rest body) > `(:script :type "text/javascript" > (fmt > (ps > , at body)))) This won't work and has been discussed before. Search the CL-WHO mailing list for previous discussion of the same topic. Basically, CL-WHO (like all the other HTML generators I'm aware of) transforms its body, but it doesn't expand all macros in the body first. You'd need a full code walker for that. (Google for "Lisp Code Walker".) > (LET ((*STANDARD-OUTPUT* (MAKE-STRING-OUTPUT-STREAM :ELEMENT-TYPE > 'CHARACTER))) > (UNWIND-PROTECT > (PROGN > (WITH-HTML-OUTPUT (*STANDARD-OUTPUT* NIL :PROLOGUE NIL :INDENT NIL) > (:HTML (:HEAD (:TITLE "Some title")) > (JS-BODY (DEFUN SOME-FUNC () (ALERT "Hello!")))))) > (CLOSE *STANDARD-OUTPUT*)) > (GET-OUTPUT-STREAM-STRING *STANDARD-OUTPUT*)) > > The HyperSpec says: "*macroexpand* <#macroexpand> repeatedly expands > *form*until it is no longer a *macro form"* > <26_glo_m.htm#macro_form> Right. (LET ...) is not a macro form. > Why js-body or with-html-output doesn't get expanded in this case? Again, for what you want, you will need a full code walker. Try something like "Walk Form" in LispWorks or slime-macroexpand-all (I think that's how it's called) in SLIME. Edi. From lispercat at gmail.com Fri Aug 15 23:52:44 2008 From: lispercat at gmail.com (Andrei Stebakov) Date: Fri, 15 Aug 2008 19:52:44 -0400 Subject: [cl-who-devel] Changing *attribute-quote-char* In-Reply-To: References: Message-ID: I have a lisp image that I load with detachtty. What I do is call sb-ext:save-lisp-and-die and then reload the image with detachtty. I don't have any other lisps installed. I can only refer to Jens who tried it with LispWorks on Mac. When I have a chance I'll check it with CLisp. Thank you, Andrew On Fri, Aug 15, 2008 at 6:31 PM, Edi Weitz wrote: > On Fri, 15 Aug 2008 15:47:54 -0400, "Andrei Stebakov" > wrote: > > > I was not just playing with REPL, I tried to compile the code and > > reloaded the image > > I don't understand. What do you mean when you say "reloaded the > image"? Could you provide a detailed explanation of what you've done? > Can you check if this works differently for other Lisps like > LispWorks? > _______________________________________________ > cl-who-devel site list > cl-who-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-who-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.buechel at gmail.com Mon Aug 25 23:42:08 2008 From: olivier.buechel at gmail.com (olivier buechel) Date: Tue, 26 Aug 2008 01:42:08 +0200 Subject: [cl-who-devel] strange behaviour: package and/or macro relevant? Message-ID: This works: (in-package :cl-user) (let* ((txt1 "hallo") (txt2 "yellow")) (cl-who:show-html-expansion (str nil :indent t) ((:a) txt1 txt2))) This does not work and hell breaks out when compiling: (defpackage :dummy-package (:use :cl :cl-user :cl-who)) (in-package :dummy-package) (let* ((txt1 "hallo") (txt2 "yellow")) (cl-who:show-html-expansion (str nil :indent t) ((:a) txt1 txt2))) ==> (LET ((STR STR)) (PROGN (WRITE-STRING " " LET ((#:G1 NIL)) (WHEN #:G1 (PRINC #:G1 STR))) TXT1 (WRITE-STRING " " LET ((#:G2 NIL)) (WHEN #:G2 (PRINC #:G2 STR))) TXT2 (WRITE-STRING " " LET ((#:G3 NIL)) (WHEN #:G3 (PRINC #:G3 STR))))) Well, I really don't get it with packages, so I just tried around and found that this code here works: (defpackage :dummy-package (:use :cl :cl-user :cl-who)) (in-package :dummy-package) (let* ((txt1 "hallo") (txt2 "yellow")) (cl-who:show-html-expansion (s nil :indent t) ((:a) txt1 txt2))) So kind-of it's not the package alone the problem, somehow it's the combination of package and using str in macro Ha, just tried with fmt instead of str: same problem Hint: Maybe no protection with gensym? And why does it work in cl-user?!? Using cl-who-0.11.1 And yes, I was in hell... And now (after changing str to s) I want just to understand what happend to me. thanks olli -------------- next part -------------- An HTML attachment was scrubbed... URL: From edi at agharta.de Mon Aug 25 23:52:09 2008 From: edi at agharta.de (Edi Weitz) Date: Mon, 25 Aug 2008 19:52:09 -0400 Subject: [cl-who-devel] strange behaviour: package and/or macro relevant? In-Reply-To: (olivier buechel's message of "Tue, 26 Aug 2008 01:42:08 +0200") References: Message-ID: http://common-lisp.net/pipermail/cl-who-devel/2008-August/000167.html Edi.