I am tring to setup an environment for editing clojure in emacs. I'm relatively new to emacs
(only 1 yr) and totally new to clojure (2 weeks). I've found lots of tutorial online about how to setup most of which talk about lein, swank-clojure, slime and nrepl.
It seems that swank-clojure and slime need to work together but swank-clojure is deprecated, so what left is nrepl and some built in lisp repl mode.
I tried inferior lisp mode first because it is the default for clojure-mode and it looks fine to me. But I can't seem tp find a way to switch namespace easily within it.
I then tried emacs-live which is like a kit for emacs newbie that comes with nrepl.
I can then do "nrepl-jack-in" to get a repl even though it is very slow..
It can switch namespace easily with "C-C M-n". Howevre, sometime after switching, a buffer called nrepl error would pop up and won't let me close. I have to force close emacs instead. Also, nrepl does not have much of syntax highlight.
To sum up:
after swank-clojure been deprecated, which repl should I use? slime-repl? nrepl? or others?
I don't know much about clojure now so I'm not sure bwhat feature is important to a repl but it would be nice to at least have syntax highlight and can easily switch between namespace like "C-C M-n" in nrepl, and maybe a debugger.
I heartily recommend nREPL.el for various reasons:
swank-clojure is dead officially, but has been dead for a long while. While it was getting some job done, nothing much has changed or improved in it after its initial inception. The development of swank-clojure required significant expertise in Common Lisp, which Clojure developers generally lack and are unwilling to attain.
clojure-mode 2.0.0 doesn't support swank-clojure + SLIME at all. This move was hugely beneficial to both clojure-mode (which dropped a lot of legacy code) and nrepl.el (which's development pace was increased after the announcement).
nrepl.el is picking up features really FAST. I'm one of its contributors so I should know :-) Recently a lot of cool things like macroexpansion, compilation error highlighting and multiple connections support were added, just to name a few. Many more features and refinements are in the pipeline. nrepl.el's architecture is much simpler than SLIME's and it's much easier for regular Clojure hackers to extend nrepl.el.
SLIME syntax highlighting? The REPL has the same font-locking in both SLIME and nrepl.el and the source buffers are using clojure-mode's font locking. It other words - syntax highlighting's the same in both.
Emacs Live relies on vendorized git submodules and generally the versions of the extensions it ships are lagging behind the upstream a bit. You might want to try as an alternative Emacs Prelude, which also ships with Clojure support, but always uses the latest packages available in MELPA.
There is no slime-repl (outside SLIME that is). At this point it's just swank-clojure + SLIME or nrepl.el. Given that nrepl.el even now implements most of what SLIME has - you'd better get used to using nrepl.el.
Update
nREPL.el was renamed to CIDER after version 0.2.0.
nREPL is probably your best bet. It's the officially suggested replacement for swank-clojure, and it's really easy to set up. (As for SLIME, swank-clojure is SLIME support for Clojure. SWANK is the backend communications channel for SLIME. If you want to use SLIME, you'll want swank-clojure — but of course that's been abandoned in favor of nREPL.)
My experience at the moment is that nrepl.el is somewhat less usuable than SWANK was; it is however picking up fast, both in terms of features and in terms of stability.
Installing Swank is now a bit harder because Clojure-mode has dropped it, so you'd need an older version. So, my advice would be, if you already have a working swank setup, then don't change anything for a couple of months; on the other hand, if you don't have a working setup, go for nrepl because it's going to happen so or later, and Swank is going to involve old versions.
If you end up with nrepl, as I say, it's not perfect yet, but keep the knowledge that, to coin a phrase, things can only get better.
Related
I'm aware of of C-h b to look at the Clojure-Mode bindings, but I don't really see anything there that's all that useful. I use paredit and there are a ton of useful things provided by that mode for editing Clojure, but that stuff is just basic Lisp Parens editing.
When I bring up the bindings for Clojure itself I don't really see must haves. Aside from syntax highlighting. I'm thinking I'm missing something. What does Clojure-Mode provide?
According to its GitHub page, Clojure Mode
Provides Emacs font-lock, indentation, and navigation for the Clojure programming language.
You may want to look into CIDER, which does more:
CIDER (formerly nrepl.el) is the Clojure IDE and REPL for Emacs, built on top of nREPL, the Clojure networked REPL server.
Some specific features:
Powerful REPL
Interactive code evaluation
Compilation notes (error and warning highlighting)
Human-friendly stacktraces
Smart code completion
Definition lookup
Documentation lookup
Resource lookup
Apropos
Value inspector
Function tracing
Interactive macroexpansion
Grimoire integration
clojure.test integration
Classpath browser
Namespace browser
nREPL session management
Scratchpad
Minibuffer code evaluation
Integration with company-mode and auto-complete-mode
The following link:
"Bozhidar Batsov - The evolution of the Emacs tooling for Clojure"
https://www.youtube.com/watch?v=4X-1fJm25Ww
gives a good overview of emacs Cider, which is the most popular development environment for clojure developers (at least according to the survey presented by the speaker).
He gives a good overview of what Cider can do, where he wants to take it, and discusses some of the competing environments as well (e.g lightTable, Cursive) .
I picked up on some good pointers on how to more effecitvely use clojure in emacs by watching it.
Bozhidar Batsov is the main developer of emacs Cider.
The markdown for CIDER about configuring the CIDER repl starts off by saying:
You can certainly use CIDER without configuring it any further, but here are some ways other folks are adjusting their CIDER experience.
And then list several expressions like (setq nrepl-log-messages t). But where do those expressions need to be written to??
If you're using CIDER (maintained by Bozhidar Batsov), then also check out his own project for setting up emacs called Prelude. It's an alternative to emacs live (as pointed out by Arthur).
I've used both, but switched to Prelude as the CIDER updates tend to be more tightly matched as versions change due to it being the same author.
These examples go in a file called (assuming linux or mac)
~/.emacs.d/init.el
It's also worth knowing about the emacs live starter package which already includes a decently configured cider amongst a bunch of other stuff. I publish my much smaller config here if you're interested in something closer to the defaults or just want more examples.
Another good 'canned' configuration is Purcell's emacs.d. It has a good initial cider and clojure configuration. I also found it was easier to modify/update and (for me anyway) I found it easier to understand, which means easier to fix when something doesn't quite work the way you want. One of the big drawbacks with some of these canned emacs configurations is that you don't get to understand how they work and then when they break, your lost until the author or someone else fixes it. I found Purcell's version was a nice complete setup, but one I was able to easily modify to better fit my needs. Tweaking emacs to fit your needs rather than tweaking yourself to meet the needs of the editor is possibly the greatest strength of emacs and why people end up loving it. Unfortunately, it can also be a PITA when all you want to do is start coding!
See http://www.github.com/purcell/emacs.d.git
Emacs is the IDE of choice for programming Erlang.
There are plenty of good modes (distel, erlware-mode, the default erlang mode,...), but what are your recommendations for setting up Emacs for professional Erlang development?
Set up erlang-mode as described in the README, and then activate Flymake:
(require 'erlang-flymake)
That gives you highlighting of warnings and errors as you type.
I'd recommend using erlang-mode from the latest Erlang/OTP release (R14A as I type this), regardless of what release you normally use, as it evolves quite rapidly and is now just as good as erlware-mode, IMHO.
If you're using Emacs 24 or later, I recommend installing erlang-mode from MELPA. The 'erlang' package tracks the 'maint' branch of the Erlang/OTP Git repository, so it is always reasonably up-to-date.
If you want more than erlang-mode offers, a possible alternative to Distel is EDTS, the Erlang Development Tool Suite. To quote the readme file:
EDTS is meant to be a able to replace Distel but only provides part of the most
commonly used of Distel's features, specifically the equivalents of
erl-find-module, erl-find-source-under-point, erl-who-calls and
erl-refactor-subfunction. As far as I know, those are the only Distel features
that 98% of people use, but if there is anything from Distel that you are
missing in EDTS, please let me know.
If you are using EDTS, please remove Distel from your configuration, since
running both can create some confusion.
Look onto this article about different packages for work with Erlang from Emacs. I personally use erlware-mode + distel
erlang.el (for indentation and font-locking) and Distel (debugger, M-. etc.) are essential. ESense, I've never used, and I've no idea what the erlware mode does. You may want to use some of the standard Emacs utilities (flymake, interface to version control, and so forth) when writing Erlang.
I've found erlang-mode ok but it doesn't support kerl (which is a useful thing, kinda like rvm for erlang, except it works).
So I started this:
https://github.com/nicferrier/emacs-erlang-extras
which supports multiple erlangs.
I'm intending that it will support rebar as well:
https://github.com/rebar/rebar/wiki/Getting-started
I found out ESense on emacswiki. Might worth a try.
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.
I noticed how SLIME (lisp development package for Emacs) does not come with a frame-source-location function for CLISP, so you can't automagically jump to a source location when inside the debugger. Given that, I figured CLISP users must be using some other IDE (though I guess IDE is a little bit misleading here, maybe they're just using a different Emacs package).
So what IDE/Emacs package are CLISP programmers using?
I think Emacs and SLIME is still what those people use.