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.
Related
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
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.
I am new to Scheme, and using gosh running on emacs buffer, in MinGW on Windows. It seems that people use readline or rlwrap to use history and more, but I still cannot figure out to accomplish the setting. Though it may be easy to run one on Linux using virtual machine, I would stick to Windows for now. Any idea or alternative suggestion?
An Emacs buffer is not a real terminal, and rlwrap will not run in it. However, this is no tragedy: almost all of rlwraps goodness can be had directly from Emacs (you could use one of the existing scheme modes, or even Emacs-gosh-mode)
If you insist, Emacs can provide a terminal emulator for you (M-x term) in which rlwrap will feel right at home.
What is the correct workflow/pathway of usage of emacs/cider while developing
a compojure/ring-based clojure application?
I feel that I can "attach" to my running compojure/ring-process,
change its code, read/change its data, but I can't understand how do I do it right?
What is the correct way?
What I do?
lein new compojure my-project
cd my-project
lein ring server-headless
The development server runs now. If I change files in the projects they will be automatically reloaded. That is good. But what I'd like to have is that I attach
direct to the process and change its functions for example.
I understand that it is possible, but I can't understand how.
I don't know about correct but I'll throw in my 2 cents.
I start my ring project using immutant which starts a REPL at a specified port. I start cider with M-x cider and connect to the previously specified port. From there I can modify things from the REPL.
I've also seen other people start jetty from inside the REPL though I've never tried this.
There are two main ways of doing what you want. None of them are specific to ring servers, or even to webservers, they'll apply to any Clojure Project.
Both of the methods below should give you a fully functional REPL, with complete control to redefine the functions in your running server, and full CIDER functionality (like being able to debug web-requests to the server).
As usually with CIDER, you can reload changed files with C-c C-k, which will redefine any functions you've changed. There are plenty of other keys for more fine-tuned evaluations as well.
M-x cider-jack-in (or C-c M-j)
As documented on the manual this starts a process with your project and connects a REPL to it. This won't call any functions for you (CIDER doesn't do that), but you can easily start your webserver by calling the corresponding function in the REPL. If the function in question is the -main function, you can do M-x cider-run to call it (bind that to a key if you'd like).
M-x cider-connect
Also as documented on the manual, you can start your webserver from the terminal like you normally would, and then call M-x cider-connect to open a REPL in it. (This is what I used to do a while back).
A bit late to the party. But as I have just to deal with the same issue and found this unanswered question. The answer could be found at:
lein ring server with nrepl doesn't honour cider-nrepl
Basically, use the plugin version 0.9.2 of lein-ring and add to the :ring configuration on project.clj :nrepl {:start? true} and it works
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.