views:

281

answers:

1

Having recently purchased Windows 7 Ultimate in order to gain access to the SUA - http://www.suacommunity.com - subsystem, I have been struggling to get SUA's bash utility (/usr/local/bin/bash) working with EmacsW32. SUA comes with ksh and csh by default, so I installed a community bundle to obtain the bash process.

M-x shell normally invokes a shell process and pipes stdio through an Emacs buffer. This works well with Cygwin. I have tried adjusting emacs variables like w32-shell-* to point it at the SUA bash executable, and also tried invoking bash via the posix.exe tool provided with SUA. I often see that the file descriptors associated with the bash process are deleted as soon as the process is created by EmacsW32.

Cygwin is very slow compared to SUA, so I am very keen to get this facility working with the EmacsW32 + SUA combo. Any tips, experience, solutions would be appreciated.

+1  A: 

I don't know the w32-shell-* variables. Maybe you could show some code to illustrate what you mean.

I also don't know SUA. I use GNU emacs v22 on Windows, and I run powershell as an inferior shell. I had some difficulties initially, similar to yours, and solved them with a better understanding of how to start the shell. Maybe this will help you.

I use these variables:

(setq explicit-shell-file-name 
      "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe")  
(setq explicit-powershell.exe-args 
      '("-Command" "-" )) ;; interactive, but no command prompt

I had difficulty until I realized two things:

  1. if you don't specify command-line arguments for the shell process, emacs silently defaults to using -i. In the case of powershell, that argument was either not supported or it did something other than what I wanted (I forget). So I had to explicitly set the arguments to invoke the shell.

  2. the name of the variable for specifying arguments to the shell, depends on the name of the program used to start the shell. This isn't documented as far as I know (unless you consider the source code to be documentation!). If you're on Linux and running sh, then the variable is explicit-sh-args. If bsh, then explicit-bsh-args. If you're on Windows, you need to use the proper name of the exe, including the .exe suffix. It makes for a strange looking variable name, but it works.

The full code to start powershell as an inferior emacs shell is like this:

;; get a name for the buffer
(setq buffer (get-buffer-create "*PowerShell*"))

(let ((tmp-shellfile explicit-shell-file-name))
  (setq explicit-shell-file-name 
        "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe")  
  (setq explicit-powershell.exe-args 
        '("-Command" "-" )) ; interactive, but no command prompt

  ;; launch the shell
  (shell buffer)

  ; restore the original shell
  (if tmp-shellfile
    (setq explicit-shell-file-name tmp-shellfile)))

Maybe something like that would work for you.

Cheeso
Thanks for the suggestions. I will give them a try and report back if I have any success in establishing a SUA bash interior shell with my EmacsW32 installation - cheers!
landstatic