 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
 (require 'cl-lib)
 (require 'json)
 (require 'tabulated-list)
 (require 's)
 (require 'request)
+
+(defgroup wandbox nil
+  "Wandbox client for Emacs."
+  :prefix "wandbox-"
+  :group  'tools)
+
+(defcustom wandbox-response-keywords
+  '("compiler_message"
+    "program_message"
+    "status"
+    "signal"
+    "url")
+  "List of compile api response keywords."
+  :group 'wandbox
+  :type '(repeat (choice
+                  (const "status" :tag "Exit code")
+                  (const "signal" :tag "Signal message")
+                  (const "compiler_output"  :tag "stdout at compiling")
+                  (const "compiler_error"   :tag "stderr at compiling")
+                  (const "compiler_message" :tag "merged messages compiler_output and compiler_error")
+                  (const "program_output"  :tag "stdout at runtime")
+                  (const "program_error"   :tag "stderr at runtime")
+                  (const "program_message" :tag "merged messages program_output and program_error")
+                  (const "permlink" :tag "/permlink/:link")
+                  (const "url" :tag "URL to display on browser"))))
+
+(defcustom wandbox-profiles nil
+  "User-defined copmiler settings."
+  :group 'wandbox
+  :type  '(list (plist
+                 ;; FIXME: how to select key as `keyword'
+                 :key-type   (symbol :tag "Compile parameter")
+                 :value-type (choice (string)
+                                     (boolean :tag "(:save only)")))))
+
+(defcustom wandbox-precompiled-hook nil
+  "Hook run before post wandbox.
+Return value will be merged into the old profile."
+  :group 'wandbox
+  :type  'hook
+  :options '(wandbox-option-gist wandbox-option-code))
+
+(defcustom wandbox-permalink-action #'browse-url
+  "Function when you run `wandbox-compile' with permalink option (:save)."
+  :group 'wandbox
+  :type  'function)
+
+(defcustom wandbox-output-buffer "*Wandbox Output*"
+  "Output result buffer name."
+  :group 'wandbox
+  :type  'string)
 
 (cl-eval-when (compile load eval)
 


;;; Commentary:

;; wandbox.el is wandbox (online compiler) interface.
;; You can compile and run code snippets by using wandbox API.

;; Wandbox Home: http://melpon.org/wandbox/

                           (server-name wandbox-default-server-name)
                           &allow-other-keys
                           &aux (server (wandbox-find-server server-name :if-does-not-exist :error)))
  "Compile CODE as COMPILER's program code on Wandbox.

URL `http://melpon.org/wandbox' is online compiler service
for multi programming language (C/C++, Python, PHP, Common Lisp, etc).

Options:

* LANG is language name. (e.g. \"Ruby\")
* NAME is select compiler template from `wandbox-profiles' or default compiler settings.
* FILE is file contents instead of CODE.
* SYNC is synchronous mode. (debug)
* SERVER-NAME is server name. (default `wandbox-default-server-name')

List of available server values, see `wandbox-list-compilers'."
  (if (<= 1 (length profiles))
      (wandbox-post* server profile profiles)
      (wandbox-post server profile :sync sync :callback #'request-response-data)))
