Skip to content

kosh04/emacs-wandbox

Repository files navigation

Wandbox for Emacser

Build Status MELPA MELPA Stable

wandbox.el is Wandbox client tool.

README : Japanese / English

What is Wandbox ?

Wandbox is online compilation service. Developed by @melponn and @kikairoya.

You can try various programming language such as C, C++, D, Haskell, Perl, Python, Ruby, PHP, Erlang, Java, JavaScript, CoffeeScript Rust, Common Lisp, and more.

Installation

  1. Install wandbox.el into your load-path directory. or M-x package-install wandbox if Emacs 24+.
  2. and put (require 'wandbox) into your .emacs.
;; .emacs sample
(require 'wandbox)
(global-set-key (kbd "C-c w w") 'wandbox)
(global-set-key (kbd "C-c w e") 'wandbox-eval-last-sexp)
(global-set-key (kbd "C-c w i") 'wandbox-insert-template)
(global-set-key (kbd "C-c w l") 'wandbox-list-compilers)
;; prefer Clang to GCC
(custom-set-variables
 '(wandbox-user-profiles
   '((:lang "C" :compiler "clang-head-c" :ext "c")
     (:lang "C++" :compiler "clang-head" :ext "cc")
     (:lang "C++" :compiler "clang-head" :ext "cpp"))))

Usage

  1. Open some program source
  2. Type M-x wandbox to compile this buffer
  3. The result are display to "Wandbox Output" buffer

for more details, see following reference.

References

Command

  • wandbox - Alias of wandbox-compile-buffer
  • wandbox-compile-file (filename) - Compile with file contents
  • wandbox-compile-region (from to) - Compile marked region
  • wandbox-compile-buffer () - Compile with current buffer
  • wandbox-list-compilers () - Display available compilers
  • wandbox-insert-template (name) - Insert template snippet
  • wandbox-select-server (name) - Switch to selected NAME wandbox server

Function

  • wandbox - Alias of wandbox-compile

  • wandbox-compile (&rest profile &key compiler options code stdin compiler-option runtime-option lang name file save)

    Run wandbox compile with detailed options. arguments compiler, options, code, compiler-option, runtime-option, save is based on wandbox API.

  • wandbox-add-server (name location) - Register wandbox server the name as name

Variable

  • wandbox-profiles - List of wandbox compiler options.
  • wandbox-precompiled-hook - Hook run before post wandbox. Return value will be merged into the old profile.
  • wandbox-default-server - Wandbox server name to use by default. (default "melpon")

Example

;; Compile code with compiler name and options
(wandbox :compiler "gcc-head" :options "warning" :code "main(){}")
;; Compile as C source code (use wandbox-profiles)
(wandbox :lang "C" :code "main(){}")
;; Compile local file, and generate permalink
(wandbox :lang "C" :file "/path/to/prog.c" :save t)
;; Use standard-input
(wandbox :lang "Perl" :code "while (<>) { print uc($_); }" :stdin "hello")
;; Multiple compile
(wandbox :profiles [(:name "php HEAD") (:name "php")] :code "<? echo phpversion();")
;; Add user-profile
(add-to-list 'wandbox-profiles '(:name "ANSI C" :compiler "clang-head" :options "warning,c89"))
(wandbox :name "ANSI C" :file "/path/to/prog.c")
;; Compile gist snippet
;; sample: https://gist.github.com/219882
(wandbox :name "CLISP" :gist 219882 :stdin "Uryyb Jbeyq!")
;; Compile any url file (add :url keyword)
(defun* wandbox-option-url (&key url &allow-other-keys)
  (if url (plist-put nil :code (wandbox-fetch url))))
(add-to-list 'wandbox-precompiled-hook #'wandbox-option-url)

(wandbox :lang "C" :url "http://localhost/prog.c")
;; Use other server
(wandbox-add-server "fetus" "https://wandbox.fetus.jp")

(wandbox :code "<?php echo phpversion();"
         :profiles [(:name "HHVM") (:name "HippyVM") (:name "PHP")]
         :server-name "fetus")

;; switch default server
;; or M-x wandbox-select-server fetus
(setq wandbox-default-server-name "fetus")

Tips

Use new/latest compilers

The compiler list information available in Wandbox is saved as a cache at the time of byte-compile.

If you want to use latest compilers, recompile wandbox.el and restart Emacs.

License

This software is licensed under the MIT-License.