Skip to content
This repository
Newer
Older
100644 107 lines (87 sloc) 4.12 kb
5fcb34d0 »
2008-11-18 initial commit
1 ;;; starter-kit-ruby.el --- Some helpful Ruby code
2 ;;
3 ;; Part of the Emacs Starter Kit
4
12ac2f0e »
2008-11-19 Rearrange lisp and ruby helpers.
5 (eval-after-load 'ruby-mode
6 '(progn
ad5705fe »
2009-02-26 Instructions for how to work around ELPA upgrade problems.
7 ;; work around possible elpa bug
8 (ignore-errors (require 'ruby-compilation))
b95c6322 »
2009-01-21 Doc updates, textile-mode, and a haml fix.
9 (setq ruby-use-encoding-map nil)
680a6d61 »
2008-12-10 ruby-compilation cleanups.
10 (add-hook 'ruby-mode-hook 'inf-ruby-keys)
f8212611 »
2008-12-10 Autoload and invoke paredit. Fix ruby-mode RET.
11 (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
1f6f58b4 »
2008-12-16 Extracted cleanup buffer function.
12 (define-key ruby-mode-map (kbd "C-M-h") 'backward-kill-word)
12ac2f0e »
2008-11-19 Rearrange lisp and ruby helpers.
13 (define-key ruby-mode-map (kbd "C-c l") "lambda")))
5fcb34d0 »
2008-11-18 initial commit
14
15 (global-set-key (kbd "C-h r") 'ri)
16
ada2ac98 » smerritt
2010-04-16 Use ruby-mode for Capfile
17 ;; Rake files are ruby, too, as are gemspecs, rackup files, etc.
b4aa1147 »
2008-12-08 Added some rake functions.
18 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
9eedd2e7 »
2008-12-24 Gemspecs are ruby code.
19 (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
d7439fe9 » smerritt
2009-10-08 Use ruby-mode for Gemfile and rackup files
20 (add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
6b38e16e »
2010-05-02 Use ruby-mode for Vagrantfile.
21 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
d7439fe9 » smerritt
2009-10-08 Use ruby-mode for Gemfile and rackup files
22 (add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
ada2ac98 » smerritt
2010-04-16 Use ruby-mode for Capfile
23 (add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
6b38e16e »
2010-05-02 Use ruby-mode for Vagrantfile.
24 (add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))
b4aa1147 »
2008-12-08 Added some rake functions.
25
5fcb34d0 »
2008-11-18 initial commit
26 ;; We never want to edit Rubinius bytecode
27 (add-to-list 'completion-ignored-extensions ".rbc")
28
b4aa1147 »
2008-12-08 Added some rake functions.
29 ;;; Rake
30
31 (defun pcomplete/rake ()
32 "Completion rules for the `ssh' command."
33 (pcomplete-here (pcmpl-rake-tasks)))
34
35 (defun pcmpl-rake-tasks ()
36 "Return a list of all the rake tasks defined in the current
37 projects. I know this is a hack to put all the logic in the
38 exec-to-string command, but it works and seems fast"
39 (delq nil (mapcar '(lambda(line)
40 (if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))
41 (split-string (shell-command-to-string "rake -T") "[\n]"))))
42
43 (defun rake (task)
44 (interactive (list (completing-read "Rake (default: default): "
45 (pcmpl-rake-tasks))))
46 (shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
47
48
838e8f93 »
2008-11-26 Clear compilation buffer in between test runs.
49 ;; Clear the compilation buffer between test runs.
50 (eval-after-load 'ruby-compilation
51 '(progn
52 (defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist))
53 (let ((comp-buffer-name (format "*%s*" name)))
54 (when (get-buffer comp-buffer-name)
55 (with-current-buffer comp-buffer-name
56 (delete-region (point-min) (point-max))))))
57 (ad-activate 'ruby-do-run-w/compilation)))
58
b2ffdf12 »
2009-03-11 Make coding-hook a real hook instead of a defun.
59 (add-hook 'ruby-mode-hook 'run-coding-hook)
60 (add-hook 'ruby-mode-hook 'idle-highlight)
38ac75bf »
2008-12-03 Remove cheat binding, use coding-hook.
61
eb4d3d5c »
2008-12-15 Set up flymake for ruby files.
62 ;;; Flymake
63
64 (eval-after-load 'ruby-mode
65 '(progn
66 (require 'flymake)
67
68 ;; Invoke ruby with '-c' to get syntax checking
69 (defun flymake-ruby-init ()
70 (let* ((temp-file (flymake-init-create-temp-buffer-copy
71 'flymake-create-temp-inplace))
72 (local-file (file-relative-name
73 temp-file
74 (file-name-directory buffer-file-name))))
75 (list "ruby" (list "-c" local-file))))
76
77 (push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
78 (push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
79
80 (push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)
81 flymake-err-line-patterns)
82
83 (add-hook 'ruby-mode-hook
84 (lambda ()
85 (when (and buffer-file-name
86 (file-writable-p
87 (file-name-directory buffer-file-name))
803737f5 » smerritt
2009-09-15 Turn off flymake for TRAMP-edited files.
88 (file-writable-p buffer-file-name)
e66f72df » jadeforrest
2009-12-29 Allow for tramp-list-remote-buffers-to-not-exist
89 (if (fboundp 'tramp-list-remote-buffers)
90 (not (subsetp
91 (list (current-buffer))
92 (tramp-list-remote-buffers)))
93 t))
eb4d3d5c »
2008-12-15 Set up flymake for ruby files.
94 (local-set-key (kbd "C-c d")
95 'flymake-display-err-menu-for-current-line)
96 (flymake-mode t))))))
97
6293b8de » eschulte
2009-01-28 Rinari working in starter-kit.el
98 ;; Rinari (Minor Mode for Ruby On Rails)
99 (setq rinari-major-modes
100 (list 'mumamo-after-change-major-mode-hook 'dired-mode-hook 'ruby-mode-hook
101 'css-mode-hook 'yaml-mode-hook 'javascript-mode-hook))
102
5fcb34d0 »
2008-11-18 initial commit
103 ;; TODO: set up ri
104 ;; TODO: electric
105
106 (provide 'starter-kit-ruby)
beef2f96 »
2008-12-15 Oops; ruby-flymake needs to be done in eval-after-load.
107 ;; starter-kit-ruby.el ends here
Something went wrong with that request. Please try again.