Permalink
Browse files

Added a shortcut to open the Rails Gemfile (C-c og)

  • Loading branch information...
andrewtimberlake committed Jan 3, 2012
1 parent a5537f7 commit 144cc7c6f2c3f9b990418267ba33f16d3cc15ec4
Showing with 21 additions and 1 deletion.
  1. +21 −1 rails-mode.el
View
@@ -32,6 +32,7 @@
(define-key rails-mode-keymap (kbd "C-c oj") 'rails-find-javascript)
(define-key rails-mode-keymap (kbd "C-c os") 'rails-find-stylesheet)
(define-key rails-mode-keymap (kbd "C-c or") 'rails-visit-routes)
+(define-key rails-mode-keymap (kbd "C-c og") 'rails-visit-gemfile)
(defgroup rails-mode nil
"Rails minor mode.")
@@ -133,12 +134,31 @@
(interactive)
(find-file (concat (rails-directory(buffer-file-name)) "config/routes.rb")))
-;; Add rails-mode to ruby mode files that are part of a Rails project
+(defun rails-visit-gemfile ()
+ "Visits the Gemfile file"
+ (interactive)
+ (find-file (concat (rails-directory(buffer-file-name)) "Gemfile")))
+
+;; Add rails-mode to ruby files that are part of a Rails project
(eval-after-load 'ruby-mode
'(add-hook 'ruby-mode-hook
(lambda ()
(when (rails-directory(buffer-file-name))
(rails-mode)))))
+;; Add rails-mode to coffeescript files that are part of a Rails project
+(eval-after-load 'coffee-mode
+ '(add-hook 'coffee-mode-hook
+ (lambda ()
+ (when (rails-directory(buffer-file-name))
+ (rails-mode)))))
+
+;; Add rails-mode to haml files that are part of a Rails project
+(eval-after-load 'haml-mode
+ '(add-hook 'haml-mode-hook
+ (lambda ()
+ (when (rails-directory(buffer-file-name))
+ (rails-mode)))))
+
(provide 'rails-mode)
;;; rails-mode.el ends here

0 comments on commit 144cc7c

Please sign in to comment.