-
Notifications
You must be signed in to change notification settings - Fork 9
Using emacs as your JRubyArt Ide
Jeremy Laviole edited this page May 1, 2018
·
11 revisions
Emacs looks like an old editor, but is has loads of very good features. And as it is based on an interpreted language (ELisp) it is quite good for interpreted languages.
(setq auto-mode-alist (cons '("\\.pde$" . java-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.pde\\w?" . java-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.vert\\w?" . c-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.glsl\\w?" . c-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.frag\\w?" . c-mode) auto-mode-alist))
(add-to-list 'auto-mode-alist
'("\\.\\(?:gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" . ruby-mode))
(add-to-list 'auto-mode-alist
'("\\(Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" . ruby-mode))
;; Get the Packages for emacs24.
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
## command to load JRuby
(defun jruby ()
(interactive)
(inf-ruby "jruby"))
## F7 is my personnal choice.
(global-set-key [f7] 'jruby)
## If you use RVM, uncomment this.
##(require 'rvm)
##(rvm-use-default) ;; use rvm's default ruby for the current Emacs session
A reminder of the commands to install the packages :
- package-refresh-contents
- package install all of this one by one: inf-ruby, rvm
- Launch emacs, open k9_samples/contributed/jwishy.rb
- Add this at the beginning of the file :
require 'jruby_art'
require 'jruby_art/app'
Processing::App::SKETCH_PATH = __FILE__
class MyApp < Processing::App
Add this at the end of the file :
end
MyApp.new unless (Processing.app != nil)
The sketch is ready.
- Hit [F7] to start Ruby.
- you can send buffers to the REPL with [C-c][C-l], or the selected code with [C-c][C-r]
- Go to the jwishy.rb buffer and do [C-c][C-l] i.e. (control + c, control + l).
- Have fun with the sketch ! You can change @x_wiggle or @y_wiggle and hit [C-c][C-l] to update in real time.
- If you have PRY, you can also interact easily with the sketch values...
cd $app # go in the sketch
@x_wiggle # get the wiggle value
@x_wiggle = 400 # set the value
@y_wiggle = 300
Edit the file ~/.irbrc and put this in it:
require 'rubygems'
require 'pry'
Pry.start
exit
Edit files with emacs with Pry, put this in ~/.pryrc
Pry.editor = "emacs"