有哪些最佳模式、配置设置或任何使在emacs中开发ruby on rails应用更好的东西。
有哪些最佳模式、配置设置或任何使在emacs中开发ruby on rails应用更好的东西。
你应该尝试所有的RoR并选择你最喜欢的。
首先,您应该查看Marshall Vandegrift的优秀录屏,使用ECB、ruby-mode、emacs-rails和其他一些东西。它能让你感受到在Emacs上编写RoR是多么酷。
简而言之,以下是您应该尝试的一些模式:
以下是其他有用的模式:
你可能还想尝试以下模式:
当然,你还需要ruby-mode,它是随ruby源代码一起提供的,并由Matz本人维护。
希望这有所帮助。
rspec-mode
(轻松运行单个或多个规范)
js2-mode
(JavaScript语法高亮显示)
ido
(在您的项目中快速查找文件/缓冲区)
由于我对Rails(和Emacs)还不熟悉,所以我不想立刻使用rinari。我发现如果一个工具对我来说做了太多的魔法,我就不能像我希望的那样快速学习细节。我认为我最终会使用它。但是,目前,我在Emacs中设置了一堆用于RAILS 3的shell,并且只需在它们之间切换即可完成我的工作。我用tmr作为前缀,以便我可以轻松地找到它们。
(defun tmr-spork-shell ()
"Invoke spork shell" ; Spork - love that name
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "spork")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "spork\n"))
(defun tmr-devlog-shell ()
"Tail the development log, shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "devlog")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "tail -f log/development.log\n"))
(defun tmr-testlog-shell ()
"Tail the test log, shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "testlog")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "tail -f log/test.log\n"))
(defun tmr-server-shell ()
"Invoke rails ui server shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "server")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "rails s\n"))
(defun tmr-db-shell ()
"Invoke rails dbconsole shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "dbconsole")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "rails dbconsole\n"))
(defun tmr-console-shell ()
"Invoke rails console shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "console")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "rails console\n"))
; I like to run all my tests in the same shell
(defun tmr-rspec-shell ()
"Invoke rspec shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "rspec")))
(shell (current-buffer))
(process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
(process-send-string nil "rspec spec\n")) ; This is debatable, since spork wont be up yet
; The shell where I do most of my work
(defun tmr-shell ()
"Invoke plain old shell"
(interactive)
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "sh")))
(shell (current-buffer))
(process-send-string nil "cd .\n")); makes sure rvm variables set with .rvmrc
; My everyday ide
(defun tmr-ide-lite ()
"Spawn several shells for a mini Rails IDE"
(interactive)
(progn (tmr-spork-shell)
(tmr-shell)
(tmr-server-shell)
(tmr-rspec-shell)))
; When I am doing a big debug session
(defun tmr-ide-full ()
"Spawn several shells for a full Rails IDE"
(interactive)
(progn (tmr-spork-shell)
(tmr-shell)
(tmr-server-shell)
(tmr-console-shell)
(tmr-db-shell)
(tmr-devlog-shell)
(tmr-testlog-shell)
(tmr-rspec-shell)))
鉴于这里的所有条目都已有8年以上,我想提一下 projectile-rails
(在此处找到)。它目前得到维护(截至本文撰写时的最后一次提交是2021年8月10日),并且与projectile-mode
提供的其他功能一起,足够实用于大多数Rails项目。 我发现只需使用几个别名就很容易使用:
(defalias 'gt 'projectile-rails-goto-file-at-point)
(defalias 'gtv 'projectile-rails-find-current-view)
除了之前提到的模式,我还发现一个有用的模式是web-mode
。它适用于编写视图,并且非常擅长处理.html.erb文件。它具有语法高亮和标签完成等功能。你可以在这里找到它。