Setting up Emacs for programming Erlang - emacs

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.

Related

How to Configure CIDER repl?

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

Install and use LISP on Mac

I've read many topics regarding this issue, but couldn't get it to an end. I want to be able to code in LISP on Mac, using Emacs and XLispStat.
So far, I've installed Emacs with HomeBrew but I got stuck when installing XLispStat. Can someone detail the steps for doing this? I'll appreciate!
P.S.: This is the required installation for Lisp. If there is something easier to achieve on Mac, I'll try that as well!
I posted a similar answer on this question. Short version: your options for an OS X Lisp environment are LispBox, LispWorks personal (crippleware warning) or Emacs+SLIME via quicklisp/ELPA.
Since your comments imply that you're casting a pretty wide net for workable Common Lisp tools, I'll also mention that CLISP seems to be supported via various OS X ports/package managers and has a fairly comfortable REPL (you can, of course get the same in SBCL with Linedit).
EDIT: As Rainer and Vsevolod mention below, Clozure and MCLIDE also exist. I've used neither myself, so I can't give you any details (though Clozure has been recommended to me on multiple occasions).
Oh, and is there a possibility to write the code is some normal text editor and compile it somehow in the terminal?
Not in the way that I think you mean, but yes, you can write a .lisp file with Sublime or whatever, then sbcl your-file-here.lisp. Note that sbcl your-file-here.lisp starts a running Lisp instance with a REPL, and incurs all the overhead that implies. If you're dead set against Emacs, what you could do is run a REPL separately from your project directory, then just (load "file-you-changed.lisp") or (ql:quickload :your-project-name) every so often.
xlispstat can be compiled on Mac OS 10.8 and works perfectly fine. It needs a couple of little edits for the nitpicking compiler but works perfectly with XQuartz. The people who are telling you to use other systems don't know how well integrated xlispstat is for people doing numerical work.

Where I can find the most popular Emacs settings?

While it is fun to customize, the Emacs has 100s of mode and there is lots of customization. I like to find popular choices, so it makes my life easier and I can spend time productively. It could be about hooks, registers, buffers, keybindings,bookmarks etc..
If such a thing does not exist, I am still happy to customize in my way.
Have a look at the Emacs Prelude.
A very popular compilation of popular default settings is the Emacs Starter Kit, originally developed by Phil Hagelberg, then by Eric Schulte and finally updated for emacs-24. It mentions:
The main advantage of this Emacs Starter Kit are
better default settings
inclusion of many useful libraries and configurations
"literate" customization embedded in Org-mode files
an organizational directory structure
git provides for version control, backup, and sharing
Then there are some specialized extensions of it:
the starter kit for social sciences
the emacs kicker
the emacs expert kick
For most popular "aha" settings, the Emacs NiftyTricks page from the emacs wiki has already been linked to in another question.
I don't know a single collection of settings, but Emacs nifty tricks can be a good starting place to pick up useful customizations and features you may not know.
It's not strictly customization, but this stackoverflow question list useful features of Emacs.
I personally advise:
Link - how to make Emacs settings compatible with modern conventions
Link - ergonomic keybinding scheme
There is also Emacs Prelude - a set of customization to make Emacs learning curve more gradual.
I also recommend going through Mastering Emacs - it has many of customizations, that may improve your productivity.
I tried the starter some time ago, but I found that I got better results by writing my own init.el so that I actually know what each line of cod e does. Emacs Fu is the best resource that I know, because it has blog posts about many different modes instead of just code: http://emacs-fu.blogspot.com/. And there is also sample .emacs based on the posts.
I think maintainer of Emacs rocks series ended up with a good .emacs settings and a useful start-up-kit for newbies to help them morph their finger habits quickly into Emacs'.
https://github.com/magnars/.emacs.d. The better-defaults package lives up to its title.

what are the code completetion systems available for emacs core (23.3 or 24)?

I use auto-completion mode which is not inbuilt. good but not the best IMO. So I was wondering is there inbuilt generic plugins for completion in emacs like you see in IDEs.
to name,
dabbrev
hippie expansion
I think these two are different from auto-completion mode kind which I am looking for.
EDIT:
I like to extend one of any completion system to support a scripting language which I use regularly for scientific data visualization.
There is CEDET package in GNU Emacs starting from version 23, but it slightly outdated, and it's better to use CEDET from its repository. I have an article on setting and use CEDET from repository.
Why don't you want to use external packages? With new packaging system in GNU Emacs (package.el) and with things, like el-get, it's very easy to install new packages into GNU Emacs...
CEDET's autocompletion is the only drop-down completion package provided in core Emacs. The core in-place completion packages are hippie-expand and dabbrev.
The primary non-core packages which provide drop-down completion are auto-complete and company; the former appears to be the most popular these days.
There's also anything, which is an interactive completion package. While it doesn't provide drop-down completion at the cursor position, the way it works is really rather nice, so it's worth investigating.
With a bit of tweaking, dabbrev and hippie-expand can be a lot more effective than you might expect, but if you want something more visual and interactive, my advice is to look beyond the core packages and go for auto-complete or perhaps anything.
(For what it's worth, I use both hippie-expand and auto-complete myself.)
As a C programmer I tried http://cx4a.org/software/gccsense.
I read an interview where the CEDET author said that this is actually better because it hooks directly into gcc. However its quite a hassle to install gccsense because I had to compile a modified gcc. Once this package is included in distributions I would use it.
You may also want to try out predictive mode. While not exactly a code completion package, it comes close to it by predicting your frequently used words, which in a coding platform is definitely a limited vocabulary.
http://www.dr-qubit.org/emacs.php
The emacs wiki has a good explanation too.
http://www.emacswiki.org/emacs/PredictiveMode

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.