【问题标题】:Using shell versus eshell whenever an Emacs action needs to spawn a shell in a new buffer每当 Emacs 操作需要在新缓冲区中生成 shell 时,使用 shell 与 eshell
【发布时间】:2010-01-26 02:59:36
【问题描述】:

我在 Emacs 中使用 Rinari 进行 Rails 开发。 M-x shell 将为我的环境 (zsh) 打开一个正确 PATH 的新缓冲区。 M-x eshell 使用了所有不正确的 PATH,我无法让它与任何东西很好地配合。

Rinari 有一个函数可以为我正在编辑的 Rails 应用程序启动一个 Web 服务器实例,但是它使用服务器实例打开的缓冲区是 eshell。

我怎样才能最终让它使用 shell(或者用 M-x shell 打开什么)打开一个缓冲区?

下面是我尝试执行的命令的定义。

是否有一个我可以更改的设置或一个查找要打开的 shell 的变量?

(defun rinari-web-server (&optional edit-cmd-args)
  "Run script/server.  Dump output to a compilation buffer
   allowing jumping between errors and source code.  With optional
   prefix argument allows editing of the server command arguments."
  (interactive "P")
  (let* ((default-directory (rinari-root))
        (script (concat (expand-file-name "server"
                   (file-name-as-directory
                    (expand-file-name "script" (rinari-root))))
         (if rinari-rails-env (concat " -e " rinari-rails-env))))
 (command (if edit-cmd-args
          (read-string "Run Ruby: " (concat script " "))
        script)))
(ruby-compilation-run command)) (rinari-launch))

【问题讨论】:

    标签: ruby-on-rails shell emacs eshell rinari


    【解决方案1】:

    如果找不到要配置的内容,您可以随时尝试以下方法:

    (defun fooby ()
      ""
      (interactive)
      (eshell))
    
    (defadvice fooby (around fooby-replace-eshell-with-shell-around act)
      "Substitute `shell` for `eshell` for the duration of this call"
      (flet ((eshell () (shell)))
        ad-do-it))
    

    在调用fooby 期间,它会在任何时候调用shell 替换为调用eshell。您希望尽可能紧密地关注建议,因此如果您能找到实际调用eshell 的函数,那将是建议的函数。当然,如果你不想挖掘,你可以随时建议rinari-web-server。如果您从不想使用eshell,那么您可以使用fset 进行全局替换:

    (fset 'eshell 'shell)
    

    希望有帮助!

    【讨论】:

      【解决方案2】:

      我能够使用别名“emacs”来启动 Emacs.app,并且在我的终端环境中这样做,然后 Emacs 会在 eshell 中传递适当的 PATH。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-01-25
        • 1970-01-01
        • 2012-02-13
        • 2014-02-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-22
        相关资源
        最近更新 更多