Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.0 KiB

  1. ;;; prelude-ruby.el --- Emacs Prelude: A nice setup for Ruby (and Rails) devs.
  2. ;;
  3. ;; Copyright (c) 2011 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
  6. ;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Some basic configuration for Ruby and Rails development.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. ;; Rake files are ruby, too, as are gemspecs, rackup files, and gemfiles.
  29. (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
  30. (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
  31. (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
  32. (add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
  33. (add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
  34. (add-to-list 'auto-mode-alist '("Guardfile$" . ruby-mode))
  35. ;; We never want to edit Rubinius bytecode
  36. (add-to-list 'completion-ignored-extensions ".rbc")
  37. (autoload 'run-ruby "inf-ruby"
  38. "Run an inferior Ruby process")
  39. (autoload 'inf-ruby-keys "inf-ruby"
  40. "Set local key defs for inf-ruby in ruby-mode")
  41. ;; yari provides a nice Emacs interface to ri
  42. (require 'yari)
  43. ;; yaml-mode
  44. (require 'yaml-mode)
  45. (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
  46. ; TODO fix ruby-end and package ruby-block for marmalade
  47. (require 'ruby-block)
  48. (require 'ruby-end)
  49. (defun prelude-ruby-mode-defaults ()
  50. (inf-ruby-keys)
  51. ;; turn off the annoying input echo in irb
  52. (setq comint-process-echoes t)
  53. (ruby-block-mode t)
  54. (local-set-key (kbd "C-h r") 'yari))
  55. (setq prelude-ruby-mode-hook 'prelude-ruby-mode-defaults)
  56. (add-hook 'ruby-mode-hook (lambda () (run-hooks 'prelude-ruby-mode-hook)))
  57. (require 'haml-mode)
  58. (require 'scss-mode)
  59. (defun prelude-css-mode-defaults ()
  60. (setq css-indent-offset 2)
  61. (rainbow-mode +1))
  62. (setq prelude-css-mode-hook 'prelude-css-mode-defaults)
  63. (add-hook 'css-mode-hook (lambda () (run-hooks 'prelude-css-mode-hook)))
  64. (defun prelude-scss-mode-defaults ()
  65. (prelude-css-mode-hook)
  66. ;; turn off annoying auto-compile on save
  67. (setq scss-compile-at-save nil))
  68. (setq prelude-scss-mode-hook 'prelude-scss-mode-defaults)
  69. (add-hook 'scss-mode-hook (lambda () (run-hooks 'prelude-scss-mode-hook)))
  70. ;; cucumber support
  71. (require 'feature-mode)
  72. (add-to-list 'auto-mode-alist '("\.feature$" . feature-mode))
  73. (provide 'prelude-ruby)
  74. ;;; prelude-ruby.el ends here