<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>60578</integer>
    </number>
    <user>
      <string>aks44</string>
    </user>
    <title>
      <string>patch?</string>
    </title>
    <contents>
      <string>{
hunk ./javascript/sw/sw-ajax.js 59
-  [_$_]
+
+  $.swRun = function(code_id, async, json, func)
+  {
+    try
+    {
+      if (async)
+        func();
+      else
+        $.swReturnValue(code_id, json, func);
+    }
+    catch(exception)
+    {
+      $.swReturnFail(code_id, exception);
+    }
+  }
+
+
hunk ./src/ajax.lisp 41
-                     (post-parameter &quot;exception-str&quot;)))))
+                     (sw-decode-json (post-parameter &quot;exception-str&quot;))))))
hunk ./src/code.lisp 24
-(defun js-ack (code-id code json)
-  (if *async*
-      code
-      (concatenate 'string &quot;
-$.swReturnValue(\&quot;&quot; code-id &quot;\&quot;,&quot; (if json &quot;true&quot; &quot;false&quot;) &quot;, function(){
-&quot; code &quot;
-});&quot;)))
-
-
-(defun js-fail (code-id)
-  &quot;This can only be executed in a context where the variable `exception' exist.&quot;
-  (concatenate 'string &quot;
-$.swReturnFail(\&quot;&quot; code-id &quot;\&quot;, exception);&quot;))
-
-
hunk ./src/code.lisp 45
-          (run-js (concatenate 'string &quot;
-try{
-&quot; (js-ack (code-id-of code) (code-of code) json) &quot;
-} catch(exception){
-&quot; (js-fail (code-id-of code)) &quot;
-}&quot;))
+          (run-js (concatenate 'string &quot;$.swRun(\&quot;&quot; (code-id-of code) &quot;\&quot;,&quot;
+                               (if *async* &quot;1&quot; &quot;0&quot;) &quot;,&quot;
+                               (if json &quot;1&quot; &quot;0&quot;)
+                               &quot;,function(){&quot; (code-of code) &quot;})&quot;))
}
</string>
    </contents>
    <universal-time>
      <integer>3419495520</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string>Common Lisp</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>aks44</string>
    </user>
    <title>
      <string>with-options macro</string>
    </title>
    <contents>
      <string>(defun %with-options-error (context)
  (wotstr context &quot;: ~A option ~S.&quot;))


(defun %with-options-parse (options assocs context)
  (let ((options (mkprlist options)))
    (dolist (option options)
      (block option-found
        (dolist (assoc assocs)
          (let ((kw (car assoc))
                (value (cdr assoc)))
            (when (eq option kw)
              (ensure (not (car value))
                      (%with-options-error context) &quot;duplicate&quot; kw context)
              (setf (car value) t)
              (return-from option-found))))
          (error (%with-options-error context) &quot;incorrect&quot; option context)))))


(defmacro with-options (((&amp;rest allowed-options) options &amp;key (prefix &quot;&quot;) (context &quot;WITH-OPTIONS&quot;)) &amp;body body)
  &quot;Check a list of OPTIONS (keywords) against the ALLOWED-OPTIONS, and generate bindings accordingly.
Each keyword in OPTIONS generates a T binding, each missing keyword generates a NIL binding.
Bindings are named according to the keyword, optionally PREFIX'ed.&quot;
  (when-safe-compilation
    (%check nempty-keywords-list allowed-options 'with-options))
  (let ((symbols (loop :for option :in allowed-options
                    :collect (cons option (read-from-string (catstr prefix (symbol-name option)))))))
    `(let ,(loop :for symbol :in symbols :collect `(,(cdr symbol) (cons nil nil)))
       (%with-options-parse ,options
                            (list ,@(loop :for symbol :in symbols :collect `(cons ,(car symbol) ,(cdr symbol))))
                            ,context)
       (let ,(loop :for symbol :in symbols :collect `(,(cdr symbol) (car ,(cdr symbol))))
         ,@body))))



(defun test (arg &amp;rest options)
  (with-options ((:a :b :c) options :prefix &quot;OPT-&quot;)
    (list arg opt-a opt-b opt-c)))


(test 0)       =&gt; (0 NIL NIL NIL)
(test 1 :b)    =&gt; (1 NIL T NIL)
(test 2 :a :c) =&gt; (2 T NIL T)
(test 0 :x)    =&gt; ERROR, :X NOT AN ALLOWED OPTION

</string>
    </contents>
    <universal-time>
      <integer>3419499107</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
  </annotation>
</paste-with-annotations>