Skip to content

Instantly share code, notes, and snippets.

Last active September 29, 2017 15:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
emacs slime livescript
(defun livescript-compile-region-emacs ()
(setq livescript-args-compile '("-c" "--no-header" "--bare"))
(if (equal mark-active nil) (mark-whole-buffer))
(livescript-compile-region (point) (mark))
(setq livescript-args-compile '("-c" "--no-header" "-m" "embedded")))
; slime
(defun slime-send-livescript (arg)
(interactive "P")
(let ((inhibit-read-only t))
(set-buffer "*slime-repl JS*")
(let ((dir (file-name-directory buffer-file-name)))
(set-buffer livescript-compiled-buffer-name)
; (goto-char (point-min))
; (while (re-search-forward "./" nil t)
; (replace-match (format "%s" dir)))
(goto-char (point-min))
(while (re-search-forward " require(" nil t)
(replace-match " importCwd("))
(goto-char (point-min))
(insert (format "process.chdir('%s')\nrequire('livescript')\nvar importCwd = require('import-cwd')\nvar clearRequire = require('clear-require')\n" dir))
(kill-buffer livescript-compiled-buffer-name)
(set-buffer "*slime-repl JS*")
(add-hook 'livescript-mode-hook
(lambda () (progn
(local-set-key (kbd "C-q C-e") 'slime-send-livescript))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment