;; Copy-paste all this code to the bottom of ;; your .emacs file or include it: (load "~/configfile.el") ;; You need to run the function install-ruby once: ;; M-x install-ruby ;; Restart emacs (package-initialize) (defun install-ruby () (interactive) (let ((package-check-signature nil)) (package-refresh-contents nil) (package-install 'gnu-elpa-keyring-update)) (package-install 'flymake-ruby) (package-install 'inf-ruby) "Done") (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) (defun run-current-region () (interactive) (let ((min-pos (min (point) (mark))) (max-pos (max (point) (mark))) (c-buffer (current-buffer))) (if (get-buffer "*ruby*") (ruby-send-region-and-go min-pos max-pos) (progn (inf-ruby) (with-current-buffer c-buffer (ruby-send-region-and-go min-pos max-pos)) )) )) (defun my-ruby-hook () (require 'flymake-ruby) (flymake-ruby-load) (local-set-key (kbd "C-c e") 'flymake-goto-next-error) (setq ruby-align-chained-calls t) (flyspell-prog-mode) (require 'inf-ruby) (inf-ruby-minor-mode) (local-set-key (kbd "C-c r r") 'run-current-region) (global-linum-mode t) ) (autoload 'inf-ruby-minor-mode "inf-ruby" "Run an inferior Ruby process" t) (add-hook 'ruby-mode-hook 'my-ruby-hook)