Haris Bogdanovich | 10 Apr 2012 00:38
Picon

onclick

Hi.
 
Why  doesn't this piece of code work:
 
(defpackage test (:use :cl :hunchentoot :cl-who :parenscript))
(in-package test)
 
(defun index ()
  (with-html-output-to-string (*standard-output* nil)
    (:html
     (:head)
     (:body
      (:p "click me" :onclick (ps (alert "hello")))))))
 
(push (create-prefix-dispatcher "/index" 'index) *dispatch-table*)
 
(start (make-instance 'easy-acceptor))
 
I loaded Edi's init file for Lispworks and I can't even autocomplete :onclick ?
When I click on "click me" nothing happens ?
 
Thanks

<div>
<div>Hi.</div>
<div>&nbsp;</div>
<div>Why&nbsp; doesn't this piece of code 
work:</div>
<div>&nbsp;</div>
<div>(defpackage test (:use :cl :hunchentoot :cl-who 
:parenscript))<br>(in-package test)</div>
<div>&nbsp;</div>
<div>(defun index ()<br>&nbsp; 
(with-html-output-to-string (*standard-output* nil)<br>&nbsp;&nbsp;&nbsp; 
(:html<br>&nbsp;&nbsp;&nbsp;&nbsp; (:head)<br>&nbsp;&nbsp;&nbsp;&nbsp; 
(:body<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (:p "click me" :onclick (ps (alert 
"hello")))))))</div>
<div>&nbsp;</div>
<div>(push (create-prefix-dispatcher "/index" 'index) 
*dispatch-table*)</div>
<div>&nbsp;</div>
<div>(start (make-instance 'easy-acceptor))</div>
<div>&nbsp;</div>
<div>I loaded Edi's init file for Lispworks and I can't 
even autocomplete :onclick ?</div>
<div>When&nbsp;I click on "click&nbsp;me" nothing 
happens ?</div>
<div>&nbsp;</div>
<div>Thanks</div>
<div><br></div>
</div>
Haris Bogdanovich | 12 Apr 2012 12:52
Picon

Re: onclick

I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
with the latest quicklisp but I can't still autocomplete :onclick.
If I just write it the program stilll doesn't work.
What could be the problem ?
<div>
<div>I installed all&nbsp;the libraries (cl-who, 
parenscript and hunchentoot) properlly</div>
<div>with the latest quicklisp but I can't still 
autocomplete :onclick.</div>
<div>If I just write it the program&nbsp;stilll doesn't 
work.</div>
<div>What could be the problem 
?</div>
</div>
Stas Boukarev | 12 Apr 2012 16:45
Picon

Re: onclick

"Haris Bogdanovich" <fbogdanovic <at> xnet.hr> writes:

> I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
> with the latest quicklisp but I can't still autocomplete :onclick.
You shouldn't be able to autocomplete :onclick. Autocomplete in slime
works only for interned symbols, once you compile the code it will be
interned and you would see it in the autocompletion. cl-who doesn't
intern symbols into keyword for it to work.

> If I just write it the program stilll doesn't work.
> What could be the problem ?
:onclick should come before the body of <p>, so,

(with-html-output-to-string (*standard-output* nil)
    (:html
     (:head)
     (:body
      (:p :onclick "alert(\"Hello\")"
          "click me"))))

I don't know how parenscript is supposed to work, but (ps (alert
"hello")) returns "alert('hello');", and cl-who uses #\' to quote
strings, so it becomes 'alert('hello');', which obviously doesn't work.

--

-- 
With best regards, Stas.

Stas Boukarev | 12 Apr 2012 16:47
Picon

Re: onclick

Stas Boukarev <stassats <at> gmail.com> writes:

> "Haris Bogdanovich" <fbogdanovic <at> xnet.hr> writes:
>
>> I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
>> with the latest quicklisp but I can't still autocomplete :onclick.
> You shouldn't be able to autocomplete :onclick. Autocomplete in slime
> works only for interned symbols, once you compile the code it will be
> interned and you would see it in the autocompletion. cl-who doesn't
> intern symbols into keyword for it to work.
>
>> If I just write it the program stilll doesn't work.
>> What could be the problem ?
> :onclick should come before the body of <p>, so,
>
> (with-html-output-to-string (*standard-output* nil)
>     (:html
>      (:head)
>      (:body
>       (:p :onclick "alert(\"Hello\")"
>           "click me"))))
>
> I don't know how parenscript is supposed to work, but (ps (alert
> "hello")) returns "alert('hello');", and cl-who uses #\' to quote
> strings, so it becomes 'alert('hello');', which obviously doesn't work.

(setf ps:*js-string-delimiter* #\") for

(:p :onclick (ps (alert "hello")) "click me")

to work.

--

-- 
With best regards, Stas.

Andy Peterson | 12 Apr 2012 17:55
Picon
Gravatar

Re: onclick

On Thu, Apr 12, 2012 at 10:47 AM, Stas Boukarev <stassats <at> gmail.com> wrote:
>
> Stas Boukarev <stassats <at> gmail.com> writes:
>
> > "Haris Bogdanovich" <fbogdanovic <at> xnet.hr> writes:
> >
> >> I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
> >> with the latest quicklisp but I can't still autocomplete :onclick.
> > You shouldn't be able to autocomplete :onclick. Autocomplete in slime
> > works only for interned symbols, once you compile the code it will be
> > interned and you would see it in the autocompletion. cl-who doesn't
> > intern symbols into keyword for it to work.
> >
> >> If I just write it the program stilll doesn't work.
> >> What could be the problem ?
> > :onclick should come before the body of <p>, so,
> >
> > (with-html-output-to-string (*standard-output* nil)
> >     (:html
> >      (:head)
> >      (:body
> >       (:p :onclick "alert(\"Hello\")"
> >           "click me"))))
> >
> > I don't know how parenscript is supposed to work, but (ps (alert
> > "hello")) returns "alert('hello');", and cl-who uses #\' to quote
> > strings, so it becomes 'alert('hello');', which obviously doesn't work.
>
> (setf ps:*js-string-delimiter* #\") for
>
> (:p :onclick (ps (alert "hello")) "click me")
>
> to work.
>
> --
> With best regards, Stas.
>

From the parenscript manual:
(PS-INLINE form &optional *JS-STRING-DELIMITER*)
(PS-INLINE* form &optional *JS-STRING-DELIMITER*)
PS-INLINE and PS-INLINE* take a single Parenscript form and output a
string starting with javascript: that can be used in HTML node
attributes. As well, they provide an argument to bind the value of
*JS-STRING-DELIMITER* to control the value of the JavaScript string
escape character to be compatible with whatever the HTML generation
mechanism is used (for example, if HTML strings are delimited using
#\', using #\" will avoid conflicts without requiring the output
JavaScript code to be escaped). By default the value is taken from
*JS-INLINE-STRING-DELIMITER*.

comment: the default value for  *JS-INLINE-STRING-DELIMITER* is #\"

Ala'a Mohammad | 19 Apr 2012 22:42
Picon

declarations placement issue

Hi,

Please, correct me If I'm wrong.

in the expansion of the following (using cl-who from quicklisp)

(with-html-output (var)
  (declare (special var)))
;=>
(LET ((VAR VAR))
   (PROGN
      (DECLARE (SPECIAL VAR))))

I think that the declaration is placed in the wrong place. CLHS does
not specify any declarations for PROGN entry. and in this declaration
provides information about the bindings of LET, thus I thought the
correct expansion should be:

(with-html-output (var)
  (declare (special var)))
;=>
(LET ((VAR VAR))
   (DECLARE (SPECIAL VAR))
   (PROGN))

the fix should should only affect with-html-output (since
with-html-output-to-string passes the declarations to the former
macro)

Regards,

Ala'a


Gmane