【问题标题】:What are useful Emacs features for Rails development哪些 Emacs 功能对 Rails 开发有用
【发布时间】:2010-05-04 15:15:47
【问题描述】:

哪些 Emacs 功能、包、附加组件等可以帮助您进行日常 Ruby On Rails 开发?

【问题讨论】:

  • 逗号太多了。它是正确命名法中的 C-x C-c

标签: ruby-on-rails ruby emacs


【解决方案1】:

emacs-rails 模式和Rinari(Rails 开发中最流行的两种模式)的早期版本功能非常丰富,但臃肿且笨重。为了保持一个小巧、干净、可靠、实用且可破解的核心,Rinari 将避开许多“花里胡哨”类型的功能。然而,这并不是说这些额外的好东西可能没有用。

这个页面应该作为链接到其他一些工具/包的链接点,这些工具/包通常可以很好地与 Rinari 和 Rails 一起工作。如果您对添加到此列表或 Rinari 新功能有任何想法,请通过 http://groups.google.com/group/emacs-on-rails 告诉我们。

使用 Rails 的基本主要模式

大部分内容都是从 Rinari 的文档中复制而来的。正如您可能已经猜到的那样,我更喜欢 Rinary 而不是 emacs-rails。查看这两个项目的活动 - emacs-rails 大约一年没有任何变化,而 rinary 仍在开发中。

【讨论】:

  • 根据它的描述,Rinari 听起来就像我正在寻找的东西,但是托管在 Github 上的当前版本已损坏,正如我在 this comment 中指出的那样。
  • 我个人使用Emacs Prelude 进行Rails 开发。捆绑的 projectile 扩展为我提供了我需要的项目导航功能,而我并不真正关心 Rinari 的其余功能。
  • 我添加了一个关于 projectile 的答案。顺便说一句,你太谦虚了,没有提到这是你的工作。 :)
【解决方案2】:

我使用emacs-rails 和一些模式来编辑 css、js (espresso-mode)、haml、sass、yaml 和 sn-p 模式 (yas-snippet)。有关概览,请查看 emacs wiki pages on Ruby on Rails.

【讨论】:

  • 那是 YASnippet,不是 yas-sn-p
【解决方案3】:

我尝试了处理 Rails 项目的 Aptana Studio IDE(开源)。我发现我主要使用它在 Rails 项目的文件中导航,而且由于我更喜欢​​使用 Emacs 来编辑文件,所以我暂时将 Aptana 放在一边。 (但它可能会在稍后进行调试时派上用场,所以我并没有完全忽略它。)

我最近尝试了不同的 Emacs 扩展来帮助 Rails 开发:ECB(Emacs 代码浏览器)、Rinari 以及我忘记的其他一些东西,但没有一个我完全满意,或者无法正常工作。但是,我现在很高兴使用 Bozhidar Batsov 在上面的评论中提到的 projectile。它增加了在项目中查找文件并在其中查找文件的便利。它也不仅仅针对 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)

【讨论】:

    猜你喜欢
    • 2010-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2011-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多