简体   繁体   中英

Using shell versus eshell whenever an Emacs action needs to spawn a shell in a new buffer

I'm using Rinari for Rails development in Emacs. Mx shell will open a new buffer that is correctly PATH'd for my environment (zsh). Mx eshell uses all the incorrect PATH's and I haven't been able to get it to play nicely with anything.

There's a function of Rinari that fires up an instance of a web server for the Rails app I'm editing, however, but the buffer it opens with the server instance is eshell.

How can I ultimately get this to open a buffer using shell (or what would open with Mx shell) instead?

Below is the defun for the command I'm trying to execute.

Is there simply a setting I can change or a variable that looks for what shell to open?

(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))

If you can't find anything to configure, you can always try something like the following:

(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))

For the duration of the call to fooby it will substitute a call to shell any time eshell is called. You want to focus the advice as tightly as possible, so if you can find the function that actually calls eshell , that would be the one to advise. Of course, if you don't feel like digging, you can always just advise rinari-web-server . If you never, ever want to use eshell , then you can use fset to do the substitution globally:

(fset 'eshell 'shell)

Hope that helps!

我能够对'emacs'进行别名以启动Emacs.app,并从终端环境中启动Emacs,然后Emacs继承了eshell中的相应PATH。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM