Is there way to run MIT scheme interpreter under emacs on Windows? - emacs

I am a newbie for Lisp, and trying to run MIT scheme interpreter under emacs on Windows. But info seems all indicate that this is impossible.
http://www.cs.rpi.edu/academics/courses/fall05/ai/scheme/starting.html
http://www.gnu.org/software/mit-scheme/
So I wonder if there is a way to do so. Thanks.

The following works for me. You'd obviously need to add your paths. If I omit the --library option, then upon startup mit-scheme complains about not finding it's runtime band.
(require 'cmuscheme)
(setq scheme-program-name "/usr/local/scheme/bin/mit-scheme --library /usr/local/scheme/lib/mit-scheme")
In the scheme buffer:
MIT/GNU Scheme running under MacOSX
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2011 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Tuesday November 8, 2011 at 10:45:46 PM
Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41
LIAR/x86-64 4.118 || Edwin 3.116
1 ]=>

I run on Linux emacs with xscheme:
https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/GNU-Emacs-Interface.html
It was rather easy to install. See this question about it's installation. He seemed to get it running OK:
running scheme from emacs
Good luck.

I had tried what you want on WINDOWS 7, independent terminal could be popped up outside emacs but with error info in REPL.
It seems that there was no official support for this feature on windows, Racket works fine with the geiser package, maybe you could try it.
https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/GNU-Emacs-Interface.html#GNU-Emacs-Interface
This interface works under unix only, because it requires unix signals for its operation.
Porting it to Windows would require reimplementing the interface to eliminate the use of
signals. We have no plans to do this.
To invoke Scheme from Emacs, load the xscheme library, then use M-x run-scheme. You
may give run-scheme a prefx argument, in which case it will allow you to edit the command
line that is used to invoke Scheme. Do not remove the --emacs option!

There are instructions for getting Chez Scheme working with Emacs on Windows. It might be possible to translate those instructions to MIT Scheme.
However, an alternative option is to use Racket with the SICP language mode. Once the package is installed, using Scheme is simple:
To use the sicp language simply use #lang sicp as the first line of your program.
This is what I'm currently using to edit SICP code on Windows.

You can use Emacs in Windows, together with Scheme in WSL2, and set scheme-program-name to wsl scheme:
(setq scheme-program-name "wsl scheme")
Then run run scheme will Enter into the Scheme.

Related

Spawning child processes returns invalid argument

I have a class this semester that requires a lisp dialect so I'm trying to get started with Clojure but I'm running into a lot of problems setting up my environment.
I'm on a Windows machine and am following the tutorial at http://www.braveclojure.com/basic-emacs/ to set up emacs which from my research seems like the best IDE for working with lisp. I had Cygwin installed before starting which supposedly has a lot of support for emacs but I'm not sure if I need to do more than just have it installed.
My problems is when I try to start a REPL in emacs with M-x cider-jack-in I get the response Spawning child process: invalid argument. If I do the M-x load-path command I get a list of every subfolder in my .emacs.d folder but not the .d folder itself but the folder where my cider package is installed is clearly listed.
I installed lein before I decided to try setting up emacs and I could open a REPL just fine with it but emacs seems like a much better way of working than just using the terminal.
Any advice is greatly appreciated but if there is a better/easier way to get started with Clojure on Windows than what I'm currently doing I'd love to hear about it.
Thanks in advance for any replies.
Yes, emacs is great, but if you haven't worked with it before then you will have a very steep learning curve, exacerbated by the fact you are running Windows. I myself use emacs with CIDER a lot, and I also use emacs on Windows quite a bit, but I don't mix it - I use emacs/CIDER only on Linux. It doesn't mean at all that it can't be made to work on Windows, it's just it has a lot of complexity of its own, which you might not have time or inclination to deal with right now. (By the way, I wouldn't recommend using emacs under Cygwin [1] , use a good native build instead. And if you still decide to go with emacs, by all means try Prelude - it comes from the author of CIDER by the way.)
If you want an option that is definitely smoother under the circumstances, download IntelliJ IDEA Community Edition and install Cursive. That will have its own learning curve for sure, but give it a try and see what you prefer. I use both, nothing beats IntelliJ/Cursive in Java interop projects.
Both emacs/CIDER and IntelliJ/Cursive are terrific and will repay for deeper learning.
[1] I am not even sure a combination of emacs on Cygwin and lein/clojure on Win32 can work, but I have no environment to test.
unset the SHELL env variable - taken from: http://tb-nguyen.blogspot.com/2010/05/how-to-fix-emacs-windows-error-spawning.html
It worked for me

Racket and Geiser on Windows, strange path error

When I try (run-racket) or (run-geiser) on my Windows 8.1 machine running GNU Emacs 24.3 and Racket v6.1 I get the following output:
Welcome to Racket v6.1.
default-load-handler: cannot open input file
path: f:/c/Users/James/AppData/Roaming/.emacs.d/el-get/geiser/scheme/racket/geiser/startup.rkt
system error: The system cannot find the path specified.; errno=3
>
Which is decidedly odd, but after browsing the backtrace I still don't have a good idea what's going on.
Indeed, since Racket starts up fine it seems to be some strangeness in the way paths are passed from Geiser to Racket. The only other time I see this kind of path strangeness is when MinGW bash is involved, and that /c/ makes me think that it probably is. In fact, that path would be perfectly valid if not for the leading f:.
I'm at a bit of a loss as to how to approach this problem, as I don't know how Geiser communicates with Racket (I just started trying to use it today), but I would really like to get it to work, as I'm quite invested in Emacs as my editor.
So my question is thus: What possible problem points should I investigate, given the above as clues?
After some digging through the Geiser source I found in geiser/elisp/geiser-load.el the line:
(setq geiser-scheme-dir "/c/Users/James/AppData/Roaming/.emacs.d/el-get/geiser/scheme")
Which was probably generated incorrectly by MinGW make.
I changed it to:
(setq geiser-scheme-dir "c:/Users/James/AppData/Roaming/.emacs.d/el-get/geiser/scheme")
After which everything works perfectly.
The problem was that Emacs' expand-file-name assumed that the /c/... path was a relative path due to the initial forward slash, and guessed that it should prepend the letter of the current drive to make it a proper Windows Emacs path.

Swank server startup failure

Emacs SLIME can't connect to swank, because apparently swank cannot initialize correctly.
It says some back end function not implemented. However, my swamp backend is SBCL, which is supported. I am using windows xp os.
A similar issue was found posted at the following link, but no solution.Link to similar issue
Am I missing any configuration file for Swank? Or perhaps emacs and SBCL versions I am using have compatibility issues? In that case, where can I get the correct compatibility matrix for windows?
I'm mostly using Linux, but it's very easy to run into conflicts if you have multiple versions of slime/swank code installed.
The best method is to use quicklisp and make sbcl/emacs not use any other code (at least in your first attempt):
sbcl --no-userinit --no-sysinit --load ~/quicklisp/setup.lisp
(asdf:initialize-source-registry '(:source-registry :ignore-inherited-configuration))
(ql:quickload "quicklisp-slime-helper")
(swank:create-server :port 4545 :dont-close t :coding-system "utf-8-unix")
Then start emacs as:
emacs -q -name SLIME -eval '(progn (load (expand-file-name "~/quicklisp/slime-helper.el")) (slime-connect "localhost" 4545))'
http://www.pchristensen.com/blog/articles/installing-sbcl-emacs-and-slime-on-windows-xp
Use this or any other manual, which describes how to install Emacs, sbcl and slime separately. But using the latest releases. Then it will be easier to find the problem than it is now.
This is not exactly an answer to the problem, more of an alternative.
I think some interfaces/ method definitions that Swank expects, need to be implemented by SBCL. I shifted the lisp implementation to CLisp from SBCL, and after some setup tweaking, got it to work. So, I think Swank is fine but SBCL is not.
Just for information, CLisp cannot work with short windows path, the ones that look like "Progra~1", while SBCL expects short paths. CLisp also gave some problem with the temp folder in Windows, for which a variable had to be added to the .emacs file, but after that was setup quickly.
There seem to be lots of differences between the various Lisp implementations' ports to Windows, which would not be a problem had better documentation been present. All this had to be gleaned from different blogs and mailing list.
As soon as a better answer to the original problem comes along, I'll accept that.

Emacs + Cygwin setup under windows !

I just downloaded Emacs and Cygwin for Windows(Vista in my case). Have no idea how to set them up.
Any help would be appreciated !
Thanks !
I use these libraries, in this order:
(require 'cygwin-mount)
(require 'setup-cygwin)
They are both available on EmacsWiki:
http://www.emacswiki.org/emacs/cygwin-mount.el
http://www.emacswiki.org/emacs/setup-cygwin.el
Step 1: Install libraries
http://www.emacswiki.org/emacs/cygwin-mount.el
http://www.emacswiki.org/emacs/setup-cygwin.el
Step 2: Install cygwin to C:\cygwin (This requirement is hardcoded in setup-cygwin.el, so just do it unless you are willing to modify setup-cygwin.el).
Step 3: Add following code into your .emacs or .emacs.d/init.el. Please note the variable cygwin-mount-cygwin-bin-directory is not set by default in cygwin-mount.el, I suggest using hard coded path (I mean "c:/cygwin/bin" actually) since the cygwin install path is already hardcoded by setup-cygwin.el.
(setq *win32* (eq system-type 'windows-nt) )
;; win32 auto configuration, assuming that cygwin is installed at "c:/cygwin"
(if *win32*
(progn
(setq cygwin-mount-cygwin-bin-directory "c:/cygwin/bin")
(require 'setup-cygwin)
;(setenv "HOME" "c:/cygwin/home/someuser") ;; better to set HOME env in GUI
))
Maybe try posting your question on http://superuser.com
But:
Installing Emacs on Windows 95/98/2K/NT/ME/XP/Vista/Windows 7
Quick Start Guide for those more experienced with Windows
Use cygwin-mount.el to integrate Cygwin with Emacs:
http://www.khngai.com/emacs/cygwin.php
You might also want to replace the DOS Shell with the Cygwin bash, that's also covered.
You can find instructions here.
There're several way to integrate emacs with cygwin as follows:
emacs-nox under cygwin. Not attractive!
emacs-X11 under cygwin. An X server is needed like XMing or Cygwin/X. A bit slow and heavy.
emacs-w32 under cygwin.
emacs under windows. You need some configuration to make emacs recognize the cygwin environment. Difficult for beginners.
I'd recommend using emacs-w32 with cygwin, which uses native Windows GUI so that you don't have to start an xserver just to run emacs and you don't need to write/download any tricky code to make emacs aware of cygwin env as other answers do.
Just install emacs-w32 and run it from mintty and here you go. FYI, if you want to start emacs "independently", write a .bat file with D:\cygwin\bin\run.exe /usr/bin/bash.exe --login -i -c /usr/bin/emacs-w32.exe inside or, as I do, write a .ahk script to start emacs with hotkey F12.

load a dynamic library from elisp

I need to use some native code and I would like to try elisp as a scripting language.
Is it possible to call native functions which are implemented in dynamic library (dll in windows)? Or the only possibility to do it is to implement native code, wrap it with DEFUN (...) macros and recompile emacs?
You can not dynamically load a library with Emacs Lisp code. To work around this people usually call out to an external program (process) and control it by sending commands to it and reading its output.
You can look at slime, tramp, gnuserv, movemail and some other similar hacks for examples.
GNU Emacs 23 has D-BUS support. While primarily a Unix thing, D-BUS is supported on Windows and provides an IPC system for user-level applications.
You could probably build what you want with that.
This feature exists only in SXEmacs, that doesn't has support for Windows, but in Unixes it works fine
This can be done with emacs in terminal and windowed on Linux using IELM REPL:
Launch repl with: M-x ielm
In repl run (load "<path_to_lisp_source>")
Now you should be able to run any functions or access data from this loaded source.