sagemath / sage-shell-mode

Emacs front end for SageMath
GNU General Public License v3.0
98 stars 16 forks source link

Doesn't work with the Gnu port of emacs for Windows. #38

Open EmmanuelCharpentier opened 6 years ago

EmmanuelCharpentier commented 6 years ago

What does work : using the cygwin port of emacs along with the cygwin version of sage.

What I tried :

I have been able to build a cmd.exe shell script that starts sage in cygwin (with any argument it needs), passes keyboard input to Sage and prints answers in the Windows console. But sage_shell_mode does not accept it, and asks me to set sage-shell-sage-root and sage-shell:sage-executable correctly.

I suppose that this function wants an executable, not a script. I tried to pass cmd.exe /c <my_path>\\sage.cmd to sage-shell-sage-executable, to no avail.

Do you see a workaround for this ? I don't. And the previous solution essentially amounts to running the whole thing (Sage + Emacs + AUCTeX) on top of a Cygwin machine : not fun, and not efficient.

Icing on this unappetizing cake : I have to do that on a machine where I have no admin rights (dont ask : my administration has reasons unknown to Reason...;-). That's why I have to recompile Sage : the marvelous installer of Erik M. Bray needs admin rights.

Suggestions ?

stakemori commented 6 years ago

Thank you for detailed report. To use GNU port of Emacs with Sage on Cygwin, I think I have to modify sage-shell-mode.el. And I would like to try your cmd.exe shell script that starts Sage. Is it possible to show it to me?

EmmanuelCharpentier commented 6 years ago

Sorry for the late answer (I wasn't available the last two days). Here is my script :

@echo off
rem Start Sage from Windows' console
rem Current directory, cmd.exe syntax
for /F "usebackq tokens=*" %%i in (`cd`) do set CPW=%%i
rem Translation to Cygwin's path syntax
for /F "usebackq tokens=*" %%i in (`C:\Users\121235\Cygwin64\bin\cygpath.exe %CPW%`) do set CurPath=%%i
rem path to Mozilla : necessary for notebook display (currently unoperative, see EB).
set Moz=/cygdrive/c/Users/121235/AppData/Local/Mozilla\ Firefox/firefox.exe
rem Sage invocation
C:\Users\121235\Cygwin64\bin\bash.exe -l -c "cd %CurPath% && BROWSER=%Moz% sage %*"

I switched back to Cygwin's emacs, which can be started from Windows' command line by a similar script and can successfully use Sage. However, in this setup, the Notebook does not really work : Jupyter starts ; one can use Sage's Python in an notebook, but the Sage interpreter crashes and restarts immediately ==> no usable Sage notebook.

So I think that having sage_shell_mode able to start Sage from the native Windows port of emacs is still useful.

stakemori commented 6 years ago

Thanks. I will try this with gnu port of Emacs.

stakemori commented 6 years ago

I have a trouble when trying to work sage-shell-mode with the gnu port of Emacs (NTEmacs). This seems to be related to a bug (see https://www.emacswiki.org/emacs/NTEmacsWithCygwin) of NTEmacs and I don't know how to avoid it. I'm afraid that I have to wait until the bug is fixed.