How do I get SLIME + Emacs set up? - emacs

According to this answer, Emacs + Slime already has much advanced functionality. So how can I get syntax coloring, auto-completion, and perhaps even version control management, set up and running in my copy of Lispbox?
If it's of any help, I have installed Lispbox on Mac OS Lion.

Syntax highlighting should already be working as soon as you load a lisp file in Emacs, regardless of whether you've got SLIME installed or not. If it's not, try doing M-x font-lock-mode and see if that turns it on.
Version control isn't provided by Emacs or SLIME, but Emacs can integrate with pretty much any version control system you care to use. I recommend Mercurial or Git. Emacs should start vc-mode automatically when you open a file that is in one of the supported version control systems. The manual includes extensive documentation, do M-: (info "(emacs)Version Control") to jump right to it.
Auto-completion is more complicated. There is more than one way to skin this cat, but for Lisp SLIME's default method should be good enough. Use M-TAB to complete the symbol at point.

Related

Editing a lisp file in emacs with SBCL

Ok so i am trying to get started with lisp and slime and i am running into some problems. I have correctly installed emacs and slime and SBCL but i run into problems when trying to edit files. I am doing this all on mac osx lion though i dont think that makes a difference. So this maybe stupid but when i first enter the terminal i enter
$ emacs <myfile.lisp>
and then it opens up my file but then slime is not running so i do..
M-x: slime
but when i do that is now gone and all i see is the "REPL" (i think) anyway it just shows me
*
and then i can enter things like
*15
15
but now i can't get back to my file so that i can compile it. Could somone please hlep me through this? Thank you!
Try C-x← and C-x→, that switches the current window's buffer to the previous or next buffer.
For a more interactive approach, split the screen vertically C-x2 (or horizontally C-x3), so you may see your code and try something out on the REPL. You may switch windows with C-xo (remember, O as in Other). You may close a window (not the buffer) with C-x0.
However, you'd better search for an Emacs tutorial, as all of this is very basic. I also recommend you start with a graphical Emacs, such as Emacs for Mac OS X. Some people prefer other versions, which integrate better with Mac OS X but also have lots of different keybindings and come with extra packages. I personally prefer having similar installations and keybindings in whatever OS I'm using.

Emacs (Multi)Term vs Xterm vs Console & TMUX

I'm an Emacs user trying to learn a software tool that is best run from a terminal. The default set-up to get the most out of that tool is to use xterm for interaction and call Vim for editing. One could simply replace Vim with Emacs in this setup, but then one would spend most of the time working outside of Emacs in an Xterm.
I figured out there is (Multi)Term-mode in Emacs, but it is really hard to find out about its pros and cons. So I have the following questions:
[Without X11]: Why or when would anybody use Emacs (Mutli)Term instead of Console & TMUX (or GNU Screen)?
[With X11] How does Emacs (Multi)Term compare to Xterm?
Obviously speed is one criteria for comparison, but I'm sure there are other.
You'd use Emacs term over tmux/screen if you're more familiar with Emacs and already use it for many other things and/or if you spend more time in Emacs than in the terminal.
Emacs's Term is much less sophisticated and much less reliable than xterm. But it works within Emacs so if you live in Emacs, it might be a good option.
Note that you may also prefer to use Emacs's M-x shell functionality, which gives you a command line without giving you an actual terminal emulator. That means that the commands are edited in Emacs before being sent to the underlying command-line program, so all the usual Emacs editing can be used there (and the history manipulation as well as command completion is performed by Emacs as well, which can be great, or can be disappointing (e.g. if the completion needs info which Emacs does not have)).

LESS syntax highlighting for emacs

Does anyone know of a syntax file to get LESS working in emacs?
You are probably looking for a less-css emacs mode, which is an elisp file that can be loaded in your emacs environment. Another version is also available in github.

Better control over where windows with cscope buffers in Emacs

Emacs is my editor of choice, and I use the cscope intergration xcscope.el provides. Recently I had a flirt with Vim. I decided to stay with Emacs, but one of the things I really liked in Vim was how I could control where my cscope windows should appear. Using cscope_maps.vim (http://cscope.sourceforge.net/cscope_maps.vim) I get shortcuts that let Vim open search results in the same buffer, a new horizontal or a new vertical split.
In Emacs a the cscope buffer just pops up in a window somewhere, according to some rules I don't know. My guess: A new window is opened if I have only one. If I have more, the one I've been away from for the longest time is used.
Pin Emacs buffers to windows (for cscope) is the only related topic I've found that helps a bit, but that doesn't make it near as flexible as the key bindings in Vim.
Anyone got a better cscope setup in Emacs than what xcscope.el provides? I don't know lisp, so I have no idea how hard it would be to make this work the way it does in Vim.
Emacs 24 (not yet released) changes radically how it is decided which buffers are displayed in which windows. In principle it should give you more fine-grained control. In any case, how you solve the problem for Emacs 24 will be different from how you solve it for older versions.
Consider filing an Emacs enhancement request to specifically get behavior more like what you had with Vim. To do that, use M-x report-emacs-bug.

How to do automatic expansion or autocomplete of functions and variables in a Clojure repl

Is there a way to expand the current command at the Clojure repl like I'd be able to do in Common Lisp?
For example say I have typed:
Math/
I would like the tab key to expand to all the available variables and functions in that namespace.
I'm using Clojure as inferior-lisp would like to know how to do this from the plain vanilla repl in Clojure, and through swank slime.
Another vote in favour of clojure-mode and slime under Emacs. In particular, if you set up auto-complete, then you can use my ac-slime package to get context-aware tab completion in a dropdown list. Here's a screencast showing it in action.
And, further to technomancy's comment about hippie-expand, here's how to tie slime completion into hippie-expand.
Update: as of 2012, nrepl, nrepl.el and ac-nrepl are replacing slime and ac-slime; same functionality, smaller and cleaner codebase.
Update2: as of Oct 2013 nrepl.el is renamed to cider and it and ac-nrepl have moved to the clojure-emacs organisation on github. nrepl remains as the server component
Have you tried Clojure mode for Emacs? It has autocomplete (suggestions are shown in new window, and if there's only one possible option, it is used to expand name), highlighting and many other nice features (not more then for CL, but not less too).
It is available via ELPA. After installing ELPA type M-x package-list-packages, set cursor near needed package and press i (already installed packages are in red). You'll need packages clojure-mode, slime, slime-repl and swank-clojure. When you're done with i-marks, press x to complete installation. Finally, press M-x slime - Emacs will tell, that Clojure is not installed and propose to download and use latest version. Just agree.
You can also integrate Emacs with Leiningen.
The vanilla repl in Clojure is pretty crippled; it doesn't even have history. Avoid it for anything but the most primitive of tasks. I don't think you can get this in inferior-lisp, but in the slime repl you can just use TAB to complete things like this. In clojure-mode buffers with slime activated it's M-TAB, or you can tie it into your hippie-expand functions.