欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2/Agda, C++/Lisp/Haskell
Emacs support for Ruby and Rails
来自开放百科 - 灰狐
(版本间的差异)
| 第5行: | 第5行: | ||
修改 /etc/emacs/site-start.el | 修改 /etc/emacs/site-start.el | ||
| − | + | (setq load-path (append load-path '("/usr/share/emacs/site-lisp/emacs-ruby-rails"))) | |
| − | ( | + | |
| + | ;;说明ruby-mode模式调用哪个函数块 | ||
| + | (autoload 'ruby-mode "ruby-mode" | ||
| + | "Mode for editing ruby source files" t) | ||
| + | ;;看到文件后缀为.rb的,对其使用ruby-mode模式,然后它会调用autoload中 | ||
| + | ;;指定的函数块 | ||
| + | (setq auto-mode-alist | ||
| + | (append '(("\\.rb$" . ruby-mode)) auto-mode-alist)) | ||
| + | ;;如果文件后缀名不为.rb,但是脚本第一行有#!ruby之类的说明 | ||
| + | ;;也相应调用此ruby模式 | ||
| + | (setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) | ||
| + | interpreter-mode-alist)) | ||
| + | ;;调用inf-ruby | ||
| + | (autoload 'run-ruby "inf-ruby" | ||
| + | "Run an inferior Ruby process") | ||
| + | (autoload 'inf-ruby-keys "inf-ruby" | ||
| + | "Set local key defs for inf-ruby in ruby-mode") | ||
| + | ;;加载钩子 | ||
| + | (add-hook 'ruby-mode-hook | ||
| + | '(lambda () | ||
| + | (inf-ruby-keys))) | ||
| + | ;;使用ruby-electric次模式 | ||
(require 'ruby-electric) | (require 'ruby-electric) | ||
| − | + | (defun try-complete-abbrev (old) | |
| − | + | (if (expand-abbrev) t nil)) | |
| − | + | ||
(setq hippie-expand-try-functions-list | (setq hippie-expand-try-functions-list | ||
| − | + | '(try-complete-abbrev | |
| − | + | try-complete-file-name | |
| − | + | try-expand-dabbrev)) | |
| + | ;;使用rails模式 | ||
| + | (require 'rails) | ||
| + | |||
| + | 使用C-h v load-path,看看是否载入了emacs-ruby-rails。默认情况下都会载入。 | ||
| + | |||
| + | M-x ruby-electric-mode | ||
| + | ruby-electric-mode的作用是有自动补全的功能,比如你输入一个",它会自动给你输入另一个"。 | ||
| − | ( | + | M-x run-ruby来打开irb |
| + | |||
| + | irb(main):001:0> def hello | ||
| + | def hello | ||
| + | puts "hello" | ||
| + | puts "hello" | ||
| + | end | ||
| + | end | ||
| + | nil | ||
2006年9月13日 (三) 15:15的版本
获得 modle
http://www.hyperionreactor.net/files/emacs-ruby-rails-1.0.zip cd /usr/share/emacs/site-lisp unzip emacs-ruby-rails-1.0.zip
修改 /etc/emacs/site-start.el
(setq load-path (append load-path '("/usr/share/emacs/site-lisp/emacs-ruby-rails")))
;;说明ruby-mode模式调用哪个函数块
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
;;看到文件后缀为.rb的,对其使用ruby-mode模式,然后它会调用autoload中
;;指定的函数块
(setq auto-mode-alist
(append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
;;如果文件后缀名不为.rb,但是脚本第一行有#!ruby之类的说明
;;也相应调用此ruby模式
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))
;;调用inf-ruby
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")
;;加载钩子
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)))
;;使用ruby-electric次模式
(require 'ruby-electric)
(defun try-complete-abbrev (old)
(if (expand-abbrev) t nil))
(setq hippie-expand-try-functions-list
'(try-complete-abbrev
try-complete-file-name
try-expand-dabbrev))
;;使用rails模式
(require 'rails)
使用C-h v load-path,看看是否载入了emacs-ruby-rails。默认情况下都会载入。
M-x ruby-electric-mode
ruby-electric-mode的作用是有自动补全的功能,比如你输入一个",它会自动给你输入另一个"。
M-x run-ruby来打开irb
irb(main):001:0> def hello
def hello
puts "hello"
puts "hello"
end
end
nil
分享您的观点