Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (45 sloc) 1.934 kB
5fcb34d @technomancy initial commit
authored
1 ;;; starter-kit-ruby.el --- Some helpful Ruby code
2 ;;
3 ;; Part of the Emacs Starter Kit
4
12ac2f0 @technomancy Rearrange lisp and ruby helpers.
authored
5 (eval-after-load 'ruby-mode
6 '(progn
7 (require 'ruby-compilation)
680a6d6 @technomancy ruby-compilation cleanups.
authored
8 (add-hook 'ruby-mode-hook 'inf-ruby-keys)
f821261 @technomancy Autoload and invoke paredit. Fix ruby-mode RET.
authored
9 (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
12ac2f0 @technomancy Rearrange lisp and ruby helpers.
authored
10 (define-key ruby-mode-map (kbd "C-c l") "lambda")))
5fcb34d @technomancy initial commit
authored
11
12 (global-set-key (kbd "C-h r") 'ri)
13
b4aa114 @technomancy Added some rake functions.
authored
14 ;; Rake files are ruby, too.
15 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
16 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
17
5fcb34d @technomancy initial commit
authored
18 ;; We never want to edit Rubinius bytecode
19 (add-to-list 'completion-ignored-extensions ".rbc")
20
b4aa114 @technomancy Added some rake functions.
authored
21 ;;; Rake
22
23 (defun pcomplete/rake ()
24 "Completion rules for the `ssh' command."
25 (pcomplete-here (pcmpl-rake-tasks)))
26
27 (defun pcmpl-rake-tasks ()
28 "Return a list of all the rake tasks defined in the current
29 projects. I know this is a hack to put all the logic in the
30 exec-to-string command, but it works and seems fast"
31 (delq nil (mapcar '(lambda(line)
32 (if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))
33 (split-string (shell-command-to-string "rake -T") "[\n]"))))
34
35 (defun rake (task)
36 (interactive (list (completing-read "Rake (default: default): "
37 (pcmpl-rake-tasks))))
38 (shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
39
40
838e8f9 @technomancy Clear compilation buffer in between test runs.
authored
41 ;; Clear the compilation buffer between test runs.
42 (eval-after-load 'ruby-compilation
43 '(progn
44 (defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist))
45 (let ((comp-buffer-name (format "*%s*" name)))
46 (when (get-buffer comp-buffer-name)
47 (with-current-buffer comp-buffer-name
48 (delete-region (point-min) (point-max))))))
49 (ad-activate 'ruby-do-run-w/compilation)))
50
d7bdec6 @technomancy Rename some functions; remove mention of nxhtml until it's in ELPA.
authored
51 (add-hook 'ruby-mode-hook 'coding-hook)
38ac75b @technomancy Remove cheat binding, use coding-hook.
authored
52
5fcb34d @technomancy initial commit
authored
53 ;; TODO: set up ri
54 ;; TODO: electric
55 ;; TODO: flymake
56
57 (provide 'starter-kit-ruby)
58 ;; starter-kit-ruby.el ends here
Something went wrong with that request. Please try again.