Skip to content
Newer
Older
100644 90 lines (70 sloc) 3.09 KB
5fcb34d @technomancy initial commit
authored Nov 18, 2008
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 Nov 19, 2008
5 (eval-after-load 'ruby-mode
6 '(progn
7 (require 'ruby-compilation)
680a6d6 @technomancy ruby-compilation cleanups.
authored Dec 10, 2008
8 (add-hook 'ruby-mode-hook 'inf-ruby-keys)
f821261 @technomancy Autoload and invoke paredit. Fix ruby-mode RET.
authored Dec 10, 2008
9 (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
1f6f58b @technomancy Extracted cleanup buffer function.
authored Dec 16, 2008
10 (define-key ruby-mode-map (kbd "C-M-h") 'backward-kill-word)
12ac2f0 @technomancy Rearrange lisp and ruby helpers.
authored Nov 20, 2008
11 (define-key ruby-mode-map (kbd "C-c l") "lambda")))
5fcb34d @technomancy initial commit
authored Nov 18, 2008
12
13 (global-set-key (kbd "C-h r") 'ri)
14
b4aa114 @technomancy Added some rake functions.
authored Dec 8, 2008
15 ;; Rake files are ruby, too.
16 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
17 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
18
5fcb34d @technomancy initial commit
authored Nov 18, 2008
19 ;; We never want to edit Rubinius bytecode
20 (add-to-list 'completion-ignored-extensions ".rbc")
21
b4aa114 @technomancy Added some rake functions.
authored Dec 8, 2008
22 ;;; Rake
23
24 (defun pcomplete/rake ()
25 "Completion rules for the `ssh' command."
26 (pcomplete-here (pcmpl-rake-tasks)))
27
28 (defun pcmpl-rake-tasks ()
29 "Return a list of all the rake tasks defined in the current
30 projects. I know this is a hack to put all the logic in the
31 exec-to-string command, but it works and seems fast"
32 (delq nil (mapcar '(lambda(line)
33 (if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))
34 (split-string (shell-command-to-string "rake -T") "[\n]"))))
35
36 (defun rake (task)
37 (interactive (list (completing-read "Rake (default: default): "
38 (pcmpl-rake-tasks))))
39 (shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
40
41
838e8f9 @technomancy Clear compilation buffer in between test runs.
authored Nov 26, 2008
42 ;; Clear the compilation buffer between test runs.
43 (eval-after-load 'ruby-compilation
44 '(progn
45 (defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist))
46 (let ((comp-buffer-name (format "*%s*" name)))
47 (when (get-buffer comp-buffer-name)
48 (with-current-buffer comp-buffer-name
49 (delete-region (point-min) (point-max))))))
50 (ad-activate 'ruby-do-run-w/compilation)))
51
d7bdec6 @technomancy Rename some functions; remove mention of nxhtml until it's in ELPA.
authored Dec 10, 2008
52 (add-hook 'ruby-mode-hook 'coding-hook)
38ac75b @technomancy Remove cheat binding, use coding-hook.
authored Dec 3, 2008
53
eb4d3d5 @technomancy Set up flymake for ruby files.
authored Dec 15, 2008
54 ;;; Flymake
55
56 (eval-after-load 'ruby-mode
57 '(progn
58 (require 'flymake)
59
60 ;; Invoke ruby with '-c' to get syntax checking
61 (defun flymake-ruby-init ()
62 (let* ((temp-file (flymake-init-create-temp-buffer-copy
63 'flymake-create-temp-inplace))
64 (local-file (file-relative-name
65 temp-file
66 (file-name-directory buffer-file-name))))
67 (list "ruby" (list "-c" local-file))))
68
69 (push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
70 (push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
71
72 (push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)
73 flymake-err-line-patterns)
74
75 (add-hook 'ruby-mode-hook
76 (lambda ()
77 (when (and buffer-file-name
78 (file-writable-p
79 (file-name-directory buffer-file-name))
80 (file-writable-p buffer-file-name))
81 (local-set-key (kbd "C-c d")
82 'flymake-display-err-menu-for-current-line)
83 (flymake-mode t))))))
84
5fcb34d @technomancy initial commit
authored Nov 18, 2008
85 ;; TODO: set up ri
86 ;; TODO: electric
87
88 (provide 'starter-kit-ruby)
beef2f9 @technomancy Oops; ruby-flymake needs to be done in eval-after-load.
authored Dec 15, 2008
89 ;; starter-kit-ruby.el ends here
Something went wrong with that request. Please try again.