Skip to content

Commit

Permalink
Merge remote branch 'jonnay/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan4th committed Feb 21, 2012
2 parents bcadda5 + 38a11d4 commit aae2628
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 26 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -261,6 +261,16 @@ the document URL for that page. When `node swank.js` is running embed

and you are ready to go!

### Swank js as a bookmarklet ###

Now as easy as running a bookmarklet! Just add a bookmark, and set this as the url:

javascript:%28function%28%29%20%7Bvar%20head%3D%20document.getElementsByTagName%28%27head%27%29%5B0%5D%3Bvar%20script%3D%20document.createElement%28%27script%27%29%3Bscript.type%3D%20%27text/javascript%27%3Bscript.src%3D%20%27http%3A//localhost%3A8009/swank-js/swank-js-inject.js%27%3Bhead.appendChild%28script%29%3B%7D%29%28%29%3B

To disconnect you can use this bookmarklet:

javascript:(function()%7BSwankJS.socket.disconnect();%20SwankJS.stopPing();%20clearInterval(SwankJS.reconnectIntervalId);%7D)();


Troubleshooting
---------------
Expand Down
83 changes: 57 additions & 26 deletions slime-js.el
@@ -1,29 +1,52 @@
;;;
;;; Copyright (c) 2010 Ivan Shvedunov. All rights reserved.
;;;
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;;
;;; * Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;;
;;; * Redistributions in binary form must reproduce the above
;;; copyright notice, this list of conditions and the following
;;; disclaimer in the documentation and/or other materials
;;; provided with the distribution.
;;;
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; slime-js.el --- Slime extension for swank-js.

;; Author: Ivan Shvedunov
;; Adapted-by: Irakli Gozalishvili
;; URL: http://github.com/gozala/slime-js
;; Version: 0.0.1
;; Keywords: js, languages, lisp, slime
;; Package-Requires: ((slime-repl "20100404") (slime "20100404"))

;;; Licence:
;; Copyright (c) 2010 Ivan Shvedunov. All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; * Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; * Redistributions in binary form must reproduce the above
;; copyright notice, this list of conditions and the following
;; disclaimer in the documentation and/or other materials
;; provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

(defgroup slime-js nil "Slime Extension for Swank.js"
:group 'slime-js)

(defcustom slime-js-swank-command "npm"
"Command for running the swank-js server from node.js"
:type 'string
:group 'slime-js)

(defcustom slime-js-swank-args '("run" "swank")
"Command arguments for running the swank-js server from node.js.
Note that file paths need to be complete file paths, i.e. ~ to /home/you or /Uesrs/you."
:type '(repeat (string :tag "Arg"))
:group 'slime-js)

(define-slime-contrib slime-js
"Emacs-side support for Swank-JS."
Expand All @@ -46,6 +69,14 @@
(when (plusp previouse-point)
(goto-char (+ previouse-point slime-repl-input-start-mark)))))))

(defvar slime-js-swank-buffer 'nil)

; Just the bare-simplest thing that can be done for now.
(defun slime-js-run-swank ()
"Runs the swank side of the equation."
(interactive)
(setq slime-js-swank-buffer (apply #'make-comint "swank-js" (expand-file-name slime-js-swank-command) nil slime-js-swank-args)))

(defun slime-js-event-hook-function (event)
(when (equal "JS" (slime-lisp-implementation-type))
(destructure-case event
Expand Down

0 comments on commit aae2628

Please sign in to comment.