Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (90 sloc) 4.097 kb
5fcb34d0 » technomancy
2008-11-18 initial commit
1 ;;; starter-kit-ruby.el --- Some helpful Ruby code
2 ;;
3 ;; Part of the Emacs Starter Kit
4
12ac2f0e » technomancy
2008-11-19 Rearrange lisp and ruby helpers.
5 (eval-after-load 'ruby-mode
6 '(progn
ad5705fe » technomancy
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 » technomancy
2009-01-21 Doc updates, textile-mode, and a haml fix.
9 (setq ruby-use-encoding-map nil)
680a6d61 » technomancy
2008-12-10 ruby-compilation cleanups.
10 (add-hook 'ruby-mode-hook 'inf-ruby-keys)
f8212611 » technomancy
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 » technomancy
2008-12-16 Extracted cleanup buffer function.
12 (define-key ruby-mode-map (kbd "C-M-h") 'backward-kill-word)
12ac2f0e » technomancy
2008-11-19 Rearrange lisp and ruby helpers.
13 (define-key ruby-mode-map (kbd "C-c l") "lambda")))
5fcb34d0 » technomancy
2008-11-18 initial commit
14
15 (global-set-key (kbd "C-h r") 'ri)
16
93f0fc48 » smerritt
2010-04-16 Use ruby-mode for Capfile
17 ;; Rake files are ruby, too, as are gemspecs, rackup files, etc.
b4aa1147 » technomancy
2008-12-08 Added some rake functions.
18 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
9eedd2e7 » technomancy
2008-12-24 Gemspecs are ruby code.
19 (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
36aae259 » smerritt
2009-10-08 Use ruby-mode for Gemfile and rackup files
20 (add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
61c70242 » technomancy
2010-05-02 Use ruby-mode for Vagrantfile.
21 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
36aae259 » smerritt
2009-10-08 Use ruby-mode for Gemfile and rackup files
22 (add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
93f0fc48 » smerritt
2010-04-16 Use ruby-mode for Capfile
23 (add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
61c70242 » technomancy
2010-05-02 Use ruby-mode for Vagrantfile.
24 (add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))
b4aa1147 » technomancy
2008-12-08 Added some rake functions.
25
5fcb34d0 » technomancy
2008-11-18 initial commit
26 ;; We never want to edit Rubinius bytecode
27 (add-to-list 'completion-ignored-extensions ".rbc")
28
b4aa1147 » technomancy
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 ()
455f5891 » technomancy
2010-06-23 Factor out ruby flymake functions so it's easier to disable.
36 "Return a list of all the rake tasks defined in the current
b4aa1147 » technomancy
2008-12-08 Added some rake functions.
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"
455f5891 » technomancy
2010-06-23 Factor out ruby flymake functions so it's easier to disable.
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]"))))
b4aa1147 » technomancy
2008-12-08 Added some rake functions.
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 » technomancy
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 » technomancy
2009-03-11 Make coding-hook a real hook instead of a defun.
59 (add-hook 'ruby-mode-hook 'run-coding-hook)
38ac75bf » technomancy
2008-12-03 Remove cheat binding, use coding-hook.
60
eb4d3d5c » technomancy
2008-12-15 Set up flymake for ruby files.
61 ;;; Flymake
62
455f5891 » technomancy
2010-06-23 Factor out ruby flymake functions so it's easier to disable.
63 (defun flymake-ruby-init ()
64 (let* ((temp-file (flymake-init-create-temp-buffer-copy
65 'flymake-create-temp-inplace))
66 (local-file (file-relative-name
67 temp-file
68 (file-name-directory buffer-file-name))))
69 ;; Invoke ruby with '-c' to get syntax checking
70 (list "ruby" (list "-c" local-file))))
71
72 (defun flymake-ruby-enable ()
73 (when (and buffer-file-name
74 (file-writable-p
75 (file-name-directory buffer-file-name))
76 (file-writable-p buffer-file-name)
77 (if (fboundp 'tramp-list-remote-buffers)
78 (not (subsetp
79 (list (current-buffer))
80 (tramp-list-remote-buffers)))
81 t))
82 (local-set-key (kbd "C-c d")
83 'flymake-display-err-menu-for-current-line)
84 (flymake-mode t)))
85
eb4d3d5c » technomancy
2008-12-15 Set up flymake for ruby files.
86 (eval-after-load 'ruby-mode
87 '(progn
88 (require 'flymake)
89 (push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
90 (push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
91 (push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)
92 flymake-err-line-patterns)
455f5891 » technomancy
2010-06-23 Factor out ruby flymake functions so it's easier to disable.
93 (add-hook 'ruby-mode-hook 'flymake-ruby-enable)))
eb4d3d5c » technomancy
2008-12-15 Set up flymake for ruby files.
94
6293b8de » eschulte
2009-01-28 Rinari working in starter-kit.el
95 ;; Rinari (Minor Mode for Ruby On Rails)
96 (setq rinari-major-modes
97 (list 'mumamo-after-change-major-mode-hook 'dired-mode-hook 'ruby-mode-hook
455f5891 » technomancy
2010-06-23 Factor out ruby flymake functions so it's easier to disable.
98 'css-mode-hook 'yaml-mode-hook 'javascript-mode-hook))
6293b8de » eschulte
2009-01-28 Rinari working in starter-kit.el
99
5fcb34d0 » technomancy
2008-11-18 initial commit
100 ;; TODO: set up ri
101 ;; TODO: electric
102
4e7ab6a0 » Frederic Jean
2009-06-17 Adding support for the feature-mode for editing cucumber features.
103 ;; Adding the cucumber mode
104
105 ;; Load bundle snippets
106 (yas/load-directory "~/.emacs.d/elpa-to-submit/snippets")
107
108 (add-to-list 'auto-mode-alist '("\\.feature" . feature-mode))
109
5fcb34d0 » technomancy
2008-11-18 initial commit
110 (provide 'starter-kit-ruby)
beef2f96 » technomancy
2008-12-15 Oops; ruby-flymake needs to be done in eval-after-load.
111 ;; starter-kit-ruby.el ends here
Something went wrong with that request. Please try again.