Emacs的哪些功能、包、插件等帮助你日常进行Ruby On Rails开发?
Emacs的哪些功能、包、插件等帮助你日常进行Ruby On Rails开发?
Ruby Mode和其他一些与Ruby相关的好东西可以在你的ruby发行版的/misc目录中找到,也可以在http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/misc/找到(它也默认捆绑在Emacs 23.1中)
CSS Mode http://www.emacswiki.org/cgi-bin/emacs/css-mode-simple.el
JavaScript Mode http://www.emacswiki.org/cgi-bin/wiki/JavaScriptMode#toc1 其他工具
Rhtml Mode是用于编辑rhtml文件的小模式(没有MMM-Mode),请参见rhtml-Mode
Snippets http://code.google.com/p/yasnippet/ 和Rails snippets http://github.com/eschulte/yasnippets-rails/tree/master
ruby-debug支持 http://groups.google.com/group/emacs-on-rails/browse_thread/thread/dfaa224905b51487
ido Mode http://www.emacswiki.org/cgi-bin/wiki/InteractivelyDoThings
nxhtml-mode - Emacs中用于Web开发的最佳模式 - 是编辑erb文件等许多其他事情的极佳替代品。
projectile
扩展为我提供了所需的项目导航功能,而且我并不太关心 Rinari 的其余功能。 - Bozhidar Batsov我使用emacs-rails
和一些模式来编辑css、js (espresso-mode)、haml、sass、yaml以及一个片段模式(yas-snippet)。如果需要了解概述,请查看emacs Ruby on Rails的维基页面。
我尝试了开源的Aptana Studio IDE,它可以处理Rails项目。我发现我主要用它来在Rails项目文件之间导航,而且由于我更喜欢使用Emacs编辑文件,所以我暂时放弃了Aptana。(但是当进行调试时,它可能会派上用场,所以我并没有完全排除它。)
最近,我尝试了不同的Emacs扩展来帮助Rails开发:ECB(Emacs Code Browser)、Rinari和其他一些我忘记了的东西,但我对它们都不是很满意,或者无法让它们正常工作。然而,我现在很高兴地使用projectile
,这是Bozhidar Batsov在上面的评论中提到的。它方便了在项目中查找文件和在其中进行grep。它也不仅限于Rails项目。
我最近发现的另一个非常有用的Emacs插件是tabbar
扩展,它的工作方式有点像浏览器的选项卡栏。我将打开选项卡之间的导航绑定到我的M-leftarrow和M-rightarrow键上,这使得在缓冲区之间切换比以前更加方便。
继续使用Emcas,还有bubble-buffer
(下面的代码),我可以只按一下键(在我的情况下是F5)即可将缓冲区内容切换到最近访问的文件--虽然tabbar
使这有点多余。我还包括了立即使用C-DEL杀死缓冲区的代码,以及一些不错的小函数,使得在保持点不离开屏幕的情况下向上或向下滚动缓冲区成为可能;这里的代码将它们绑定到数字键盘的*
和/
。(这些都不是我自己的工作。)
;; Use F5 to switch between buffers. Use C-DEL to remove the current buffer
;; from the stack and retrieve the next buffer. The most-frequented buffers are
;; always on the top of the stack. (Copied, with changes and a bugfix, from
;; http://geosoft.no/development/emacs.html.)
(defvar LIMIT 1)
(defvar time 0)
(defvar mylist nil)
(defun time-now ()
(car (cdr (current-time))))
(defun bubble-buffer ()
(interactive)
(if (or (> (- (time-now) time) LIMIT) (null mylist))
(progn (setq mylist (copy-alist (buffer-list)))
(delq (get-buffer " *Minibuf-0*") mylist)
(delq (get-buffer " *Minibuf-1*") mylist)))
(bury-buffer (car mylist))
(setq mylist (cdr mylist))
(setq newtop (car mylist))
(switch-to-buffer (car mylist))
(setq rest (cdr (copy-alist mylist)))
(while rest
(bury-buffer (car rest))
(setq rest (cdr rest)))
(setq time (time-now)))
(global-set-key [f5] 'bubble-buffer)
(defun kill-buffer-without-questions ()
;; Kill default buffer without the extra emacs questions
(interactive)
(kill-buffer (buffer-name)))
(global-set-key [C-delete] 'kill-buffer-without-questions)
;; Scroll up and down without moving the cursor by pressing the numeric keypad's
;; "/" and "*" keys.
(defun scroll-down-keep-cursor ()
;; Scroll the text one line down while keeping the cursor
(interactive)
(scroll-down 1))
(defun scroll-up-keep-cursor ()
;; Scroll the text one line up while keeping the cursor
(interactive)
(scroll-up 1))
(global-set-key [kp-divide] 'scroll-down-keep-cursor)
(global-set-key [kp-multiply] 'scroll-up-keep-cursor)