Scheme dialect of Lisp in Emacs [closed] - emacs

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I get the EMACS lisp interpreter use the Scheme dialect of LISP. I am going over the SICP book and am new to EMACS (just finished learning the navigation and file access commands)?

To do SICP, you should use an external scheme interpreter as Emacs Lisp is different from Scheme and no correct implementation of scheme has been created on top of Emacs Lisp. One other reason you should use an external scheme interpreter is for speed of execution.
The simple solution is to use PLT Scheme now called Racket :
Download and Install scheme from Racket site.
Then configure the variable scheme-program-name to the value mzscheme
Finally run the command run-scheme : it will run mzscheme process into a *scheme* buffer.
The *scheme* buffer use the inferior-scheme-mode major mode which defines the following keys :
C-c C-k scheme-compile-file
C-c C-l scheme-load-file
C-x C-e scheme-send-last-sexp
C-M-x scheme-send-definition

Jerome's answer is a good simple way to get started. If you plan on working through longer exercises in SICP, I strongly suggest installing Quack, which is an Emacs package that provides many useful features for formatting, editing, and running Scheme code. It's the de facto standard.
You'll still have to install your preferred dialect of Scheme (I also suggest Racket here) independently, and then use Emacs to communicate with it.
This page and this other page might help you with some other resources for setting up and using Emacs for this purpose.

You don't, at least not directly. What people generally do is spawn a scheme process and communicate directly with that.
See external-lisp documentation for how to do that, as well as the Emacs Wiki page for Scheme.
Ok, I was a little wrong, it looks as though a couple of people have written Scheme interpreters on top of Emacs Lisp (see the Wiki link above), though they are not fully featured Schemes.

You don't. GNU Emacs LISP is built into GNU Emacs, and much of GNU Emacs is written in GNU Emacs LISP. You can't change the built-in LISP interpreter without massively breaking Emacs.
GNU/MIT Scheme includes the Edwin editor, an Emacs-like editor written in Scheme. You might be able to use that instead of GNU Emacs.
The other guy's recommendation of spawing a scheme process and communicating with that seems like the better idea.

I found it was easiest to use MIT scheme in Emacs with M-x run-scheme - instructions for setting this up are here:
http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/

Related

Where can I find good examples of Emacs Lisp programming with indirect buffers?

The existing emacs mode for Noweb is very old and suffers from a lot of problems. To either fix the problems or write a new mode calls for knowledge of indirect buffers. I have found one example, the command org-mode-tree-to-indirect-buffer.
Where can I find other good examples for learning how to program Emacs features that use indirect buffers?
An interesting use-case should be here:
https://github.com/phillord/lentic

Emacs without Lisp [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
Should I learn to use Emacs with no intention to learn Lisp, if my other option is to get familiar with vi?
Yes. With all the resources out there (FAQ, Emacs wiki, and the Stack Exchange Emacs site) and custom (M-x custom). You don't need to know Lisp. You just cut/paste what you find.
You can drive a Ferrari/Yugo without knowing the internals of the combustion engine or how a Formula One transmission works...
Why not?
You can still learn vi (probably Vim or Elvis).
You can learn jEdit. Or nano and Pico. Or whatever other editor, environment, and language-host you fancy.
Why put such an arbitrary restriction on things? While your Emacs experience will be better if you learn at least basic Emacs Lisp (a .. derelict .. Lisp implementation), it's not required. But at the end of the day, it's a tool. Get as many useful tools as you can. "Useful" also really depends on context.
I have used Emacs for several years with next to no knowledge of Lisp and it served me well for all of the projects I used it for.
You can always simply assume that the configuration you're writing is not in Emacs Lisp and that it is just some funny configuration format - there a lot stranger examples out there (such as Sendmail).
I should warn you though that once I started learning Emacs Lisp my Emacs mastery expanded extremely rapidly - now that I understand the details of the language I can easily bend any configuration to my needs and more importantly I started writing my own extension to Emacs, which add to it even more capabilities.
If you decided to start with Emacs, I recommend to read first this great book - it taught me a lot of things for Emacs at the beginning and it assumes no Lisp knowledge. It won't teach you any Lisp either. Afterwards my advice would be read the official Emacs manual and start exploring the Emacs Wiki and #emacs on Freenode.
Learning Emacs truly is a journey that is not for the faint of heart, but it is journey that is most certainly worth it...
Configuring Emacs is a journey, and it's something that you're going to want to do. Being able to customize your developing environment is one of Emacs' greatest strengths. It's almost unavoidable. You pick up bits and pieces just by looking at other people's .emacs files.
Knowing just a little bit of Lisp goes a long way in Emacs.
You don't need to learn Lisp to use Emacs. Even basic customization of Emacs works fine without Lisp knowledge. If you need something beyond your capabilities, there are many helpful Emacs users.
Learning a bit Emacs Lisp will later enhance your understanding of Emacs.
Emacs Lisp is a relatively simple Lisp dialect. Basic Emacs Lisp is not that difficult to learn. As an experienced Lisp user I have to say that Emacs is available quite some time and the users have written some amazing things in Emacs (like Org-mode). Some of the Emacs extensions are very very well written and it is a pleasure to read the code.
Well, if you don't want to customize your Emacs, you won't need Lisp, either. And you can also do some basic modifications using the build-in customize functionality and by copy&pasting code of others. But truth being: I have written several hundreds of lines of code to customize Emacs to suit my needs. On the other side, as far as I know, vi is not as customizable as Emacs, so in the end it is probably more about what editor you like more and you should try both.
I know little Lisp and use Emacs to edit my C and OCaml programs on Windows and Linux.
I've been using Emacs for a year and a half, and really only picked up whatever Emacs Lisp came without trying. I have a heavily extended set of configurations (first in a .emacs file, and now in ~/.emacs.d/init.el and friends), which are totally a result of cutting and pasting from the excellent resources found online.
Aside from, of course, the EmacsWiki, you should see the fine Emacs Starters Kit and subscribe to Planet Emacsen --- preferably in a feed reader. It's prettier.
Having said that, after you have a working setup you might yield to the temptation to learn a little Emacs Lisp. I've just started the free Introduction to Programming In Emacs Lisp, which comes with Emacs and is best read from within Emacs Info. It assumes neither programming ability nor Lisp knowledge, and is a friendly introduction to the 'vibe' of Emacs Lisp which I find to be well-written in the extreme, friendly and concise, and worth 10x every minute I have spent with it.

Guile and Emacs?

I'm learning Emacs Lisp and I came across this decade old post saying that at some point Guile (Scheme) will replace Emacs Lisp, or Emacs will be rewritten with Guile.
https://web.archive.org/web/20081201143448/http://sanpietro.red-bean.com/guile/guile/old/3114.html
I was wondering if this is still a possibility, and if developers should be trying to write Elisp with this in mind? The original goal was for Guile to be backwards compatible with Elisp, but it seems like developing Scheme is the better choice.
It should be possible after Guile 2.0 is released to use Guile with Emacs. The current pre-release supports ecmascript as well as scheme and there is apparently an elisp branch also but I haven't looked into it. Once Guile fully supports elisp it shouldn't be too hard to replace the current elisp interpreter with Guile. The real question is whether or not people are going to rewrite their customizations and add-ons in scheme or just continue to use elisp. Regardless, Guile 2.0 should make the possibility of a Guile Emacs much closer to reality than any other development in the past 10 years.
Guile 2.0.0 (released 2011-02-06) supports Emacs Lisp.
You can switch at the repl like so:
scheme#(guile-user)> ,language elisp
Happy hacking with Emacs Lisp! To switch back, type `,L scheme'.
elisp#(guile-user)> (eq 1 2)
$1 = #nil
As to if/when someone is going to do some surgery on Emacs to extract elisp and drop in Guile-in-elisp-mode: the Guile 2.0.2 reference manual suggests this is the plan but it's not ready yet:
We hope that eventually Guile's
implementation of Elisp will be good
enough to replace Emacs' own
implementation of Elisp.
guile and emacs, again - updated Emacs src, using non-hacked Guile, 23 Aug 2009
PS: I was noticing recently that my first
commit to the Emacs source tree
relating to this project was on
1999-08-28, just shy of ten years ago.
I'm not sure if I should celebrate or
be depressed on Friday.
http://lists.gnu.org/archive/html/guile-devel/2009-08/msg00163.html
There have been some interesting discussions on this topic in recent times:
http://lists.gnu.org/archive/html/emacs-devel/2010-04/msg00665.html
http://wingolog.org/archives/2010/04/02/recent-developments-in-guile
I wouldn't worry too much about it. There are a couple of projects to use Guile with Emacs, but I sense that they're not mainline supported. As one of the developers of one of the projects observed, no one will switch unless all their existing elisp runs flawlessly in the new engine, which is a pretty tall task.
Not that it will never happen, it's just been 'in the clouds' for a few years.
Using a VM like parrot seems more interesting for the future than Guile as Parrot VM can handle many different dynamic languages and each language can reuse what has been developed in another language.
The work left to be done is :
adding emacs low-level concepts and functions to Parrot VM (basic elisp types like the buffer type, window, frame...)
creating an elisp language port to Parrot VM.
With such functionalities you could have all legacy elisp code running on Parrot VM without any porting issues, and new code could be developed and reused by any language supported by Parrot VM.

Resources for learning Emacs [duplicate]

This question already has answers here:
Good Resources For Emacs [closed]
(9 answers)
What to teach a beginner in Emacs? [closed]
(13 answers)
Closed 9 years ago.
I'd like to learn Emacs, and was wondering if anyone had any good resources (free or otherwise) to recommend. I'm mostly interested in programming Emacs, starting from the basics, and lots of "exercises". I have used Emacs and most of its editing features, although I'm a bit rusty so a very quick refresher on that would be useful as well.
Thanks
Edit: Thanks for the suggestions. I'll have a look and update with what I liked...
GNU Emacs manual
GNU Emacs lisp reference
emacswiki
Programming in Emacs Lisp (Second Edition) - free online book
One thing to bear in mind is that all emacs configuration is programming.
PlanetEmacsen is a good RSS feed with lots of tips.
Xah Lee although he is apparently considered a bad troll, has some great emacs programming stuff.
Also whenever there's a function or keyboard shortcut you're not sure of, try C-h f and C-h k respectively, then follow the link to the source code for that command.
For exercises, Lair of the DustBunny did a very long series on rewriting python mode from scratch.
You could also try writing the PLEAC elisp section. That's a very good way to compare elisp to your favourite language.
Emacs itself includes a tutorial with exercises that guides you through the basic features and editing commands. You can find it in the Menu under 'Help' or by pressing C-h t (i.e. press Control and 'h' together and then 't' alone).
Last week I purchased this Peepcode screencast and really liked it. It walks you through the basic features (editing, loading saving, buffers) but also dives into some advances topics, like programming emacs lisp:
http://peepcode.com/products/meet-emacs
Definitely the best book about Emacs is Bob Glickstein's "Writing GNU Emacs Extensions".
Really informative. Really good examples. And, for a technical book a pleasure to read. It is one of the best computer books I have. (Thereunder are such treasures like my "VIC-20 Technical Manual" from 1982 :-)
Some PDFs are available online, but for the full fun I suggest purchasing a hard-copy.
Emacs's own help system is your friend --- ask Emacs. Learn the main C-h keys and apropos.
These too can help:
http://www.emacswiki.org/emacs/HelpPlus
http://www.emacswiki.org/emacs/EmacsNewbieWithIcicles

Writing Emacs extensions in languages other than Lisp

I'd like to take an existing application (written in OCaml) and create an Emacs "interface" for it (like, for example, the Emacs GDB mode). I would prefer to do this without writing a ton of Lisp code. In MVC terms, I'd like for the View to be Emacs, but for the Model and Controller to remain (primarily) OCaml.
Does anybody know of a way to write Emacs extensions in a language other than Lisp? This could either take the form of bindings to the Emacs extension API in some other language (e.g., making OCaml a first-class Emacs extension language) or an Emacs interaction mode where, for example, the extension has a pipe into which it can write Emacs Lisp expressions and read out result values.
http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage is a list of all non-Elisp extension languages you can use.
It does appear to be dynamic language centric.
http://common-lisp.net/project/slime/ is missing from that list, as it is not quite an extension language, but an Elisp-Common Lisp bridge. Its source code would show how to communicate back and forth over sockets.
A similar IDE for Erlang is Distel, at http://fresh.homeunix.net/~luke/distel/ (currently down) and https://github.com/massemanet/distel.
Good luck!
I don't know if this will work for your particular problem, but I have been doing something similar using the shell-command-to-string function:
(shell-command-to-string
"bash -c \"script-to-exec args\"")
So for example, we have existing scripts written in python which will mangle a file, so the above lets me invoke the script via emacs lisp.
A quick google search found this page describing a system to write extensions in Python, so it seems feasible to do what you want... you will just have to see if anyone has written a similar framework for OCaml.
Some Extension Api is now possible with the incoming emacs 25.1 and dynamic modules
A Library, emacs-ffi offer a foreign function interface based on libffi.
Check out complete documentation on the README.
Try PyMacs, which allows extending Emacs in Python.
edit: updated link.
From the statically typed languages side, there is something that looks quite performant and well featured for Haskell:
https://github.com/knupfer/haskell-emacs
there is also probably something useful for Scala to be reused from the Ensime project (has a bridge for both Emacs and Vim):
https://github.com/ensime/ensime-server
Furthermore, a quick google search revealed another potential candidate for extending Emacs with a classic FP language, OCaml; the project has a lot of .ml source files so there's got to be an Emacs-OCaml bridge somewhere:
https://github.com/the-lambda-church/merlin
There is no "Extension API". Emacs Lisp is way in there, and it ain't moving.
You can run Emacs commands from your other process. Have a look at Gnuserv.
There are plenty of applications where Emacs is the View for a Model/Controller in a separate process. The Emacs GDB interface is a good example. I'm not sure of a simpler example, maybe sql-postgresql?