Issues with installing clojure-mode on Mac in Emacs

378 views
Skip to first unread message

James

unread,
May 27, 2012, 11:09:18 AM5/27/12
to Clojure
Hi, I have GNU Emacs v 23.4 installed on Mac OS X 10.7.4. I've
followed the installation instructions for clojure-mode but get stuck
at the point where I have to issue the following in Emacs:

M-x eval-buffer
M-x package-refresh-contents

The second line gives me [No match].

I have package.el under ~/.emacs.d/packages/. Under ~/.emacs.d/, I
have:

auto-save-list/
clojure-test-mode.el
init.el
clojure-mode.el
clojurescript-mode.el
packages/

Here's my init.el:

(add-to-list 'load-path "~/.emacs.d/")
(require 'clojure-mode)

(add-to-list 'load-path "~/.emacs.d/packages/")

(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)

What am I doing wrong?

Thanks beforehand,
James

Phil Hagelberg

unread,
May 27, 2012, 11:23:13 AM5/27/12
to clo...@googlegroups.com

If you are installing .el files by hand you don't need package.el.

-Phil

James

unread,
May 27, 2012, 11:40:02 AM5/27/12
to Clojure
I've removed package.el now, but am getting the same:

M-x eval-buffer
M-x package-refresh-contents [No match]

/ James

Moritz Ulrich

unread,
May 27, 2012, 12:15:11 PM5/27/12
to clo...@googlegroups.com
You don't need eval-buffer and package-refresh-contents. Why refresh
package.el's index when you don't use it?
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



--
Moritz Ulrich

Lars Nilsson

unread,
May 27, 2012, 12:17:02 PM5/27/12
to clo...@googlegroups.com
On Sun, May 27, 2012 at 11:09 AM, James <abbo...@gmail.com> wrote:
> Here's my init.el:
>
> (add-to-list 'load-path "~/.emacs.d/")
> (require 'clojure-mode)
>
> (add-to-list 'load-path "~/.emacs.d/packages/")

Perhaps you could try the following?

(add-to-list 'load-path (expand-file-name ".emacs.d" "~"))
(add-to-list 'load-path (expand-file-name ".emacs.d/packages" "~"))

Lars Nilsson

Sam Aaron

unread,
May 27, 2012, 12:26:50 PM5/27/12
to clo...@googlegroups.com
Take a look at the guts of Emacs Live:

http://github.com/overtone/emacs-live

in particular, check out the Clojure pack:

https://github.com/overtone/emacs-live/tree/master/packs/live/clojure-pack

It doesn't use the Emacs package manager either, opting to put external files in a lib directory. The config dir contains all the config files for the various associated Clojure goodies the Clojure pack pulls in.

Sam

--
http://sam.aaron.name


On Sunday, 27 May 2012 at 17:17, Lars Nilsson wrote:

> On Sun, May 27, 2012 at 11:09 AM, James <abbo...@gmail.com (mailto:abbo...@gmail.com)> wrote:
> > Here's my init.el:
> >
> > (add-to-list 'load-path "~/.emacs.d/")
> > (require 'clojure-mode)
> >
> > (add-to-list 'load-path "~/.emacs.d/packages/")
>
> Perhaps you could try the following?
>
> (add-to-list 'load-path (expand-file-name ".emacs.d" "~"))
> (add-to-list 'load-path (expand-file-name ".emacs.d/packages" "~"))
>
> Lars Nilsson
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com (mailto:clo...@googlegroups.com)
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com (mailto:clojure+u...@googlegroups.com)

Sean Neilan

unread,
May 27, 2012, 12:45:35 PM5/27/12
to clo...@googlegroups.com
You must use emacs 24! Do not use emacs 23.4!

Use the cutting edge version of aquamacs

Aquamacs 24 works with emacs prelude with no sweat. Just delete all the stuff in your .emacs.d folder after installing aquamacs and try again.

James

unread,
May 27, 2012, 12:48:31 PM5/27/12
to Clojure
Hi Sam, Emacs Live looks seriously cool, however I have doubts about
this:

"Emacs live has only been tested with a terminal hosted Emacs
24.1.50.2 (pre-release). Issues and pull-requests for this and later
versions will be happily accepted."

This version isn't stable, should I go ahead and install it instead of
the one I have (23.4)?

Cheers,
James


On May 27, 6:26 pm, Sam Aaron <samaa...@gmail.com> wrote:
> Take a look at the guts of Emacs Live:
>
> http://github.com/overtone/emacs-live
>
> in particular, check out the Clojure pack:
>
> https://github.com/overtone/emacs-live/tree/master/packs/live/clojure...
>
> It doesn't use the Emacs package manager either, opting to put external files in a lib directory. The config dir contains all the config files for the various associated Clojure goodies the Clojure pack pulls in.
>
> Sam
>
> --http://sam.aaron.name
>
>
>
>
>
>
>
> On Sunday, 27 May 2012 at 17:17, Lars Nilsson wrote:

James

unread,
May 27, 2012, 12:57:34 PM5/27/12
to Clojure
@Sean: All right, will give a shot. Thanks.

/ James

On May 27, 6:45 pm, Sean Neilan <s...@seanneilan.com> wrote:
> You must use emacs 24! Do not use emacs 23.4!
>
> Use the cutting edge version of aquamacshttp://aquamacs.org/nightlies.shtml
>
> Aquamacs 24 works with emacs prelude with no sweat. Just delete all the
> stuff in your .emacs.d folder after installing aquamacs and try again.
>
>
>
>
>
>
>
> On Sun, May 27, 2012 at 11:26 AM, Sam Aaron <samaa...@gmail.com> wrote:
> > Take a look at the guts of Emacs Live:
>
> >http://github.com/overtone/emacs-live
>
> > in particular, check out the Clojure pack:
>
> >https://github.com/overtone/emacs-live/tree/master/packs/live/clojure...
>
> > It doesn't use the Emacs package manager either, opting to put external
> > files in a lib directory. The config dir contains all the config files for
> > the various associated Clojure goodies the Clojure pack pulls in.
>
> > Sam
>
> > --
> >http://sam.aaron.name
>
> > On Sunday, 27 May 2012 at 17:17, Lars Nilsson wrote:
>

Sean Neilan

unread,
May 27, 2012, 1:09:00 PM5/27/12
to clo...@googlegroups.com
NP!

Also, it says in the guide
to run emacs from the command line. Obviously, run Aquamacs instead of the command line emacs.

Moritz Ulrich

unread,
May 27, 2012, 1:49:41 PM5/27/12
to clo...@googlegroups.com
I wouldn't recommend Aquamacs for GUI-Stuff on OS X. Instead, use
Emacs.app from [1]. The bundle there is a vanilla build of Emacs
without patches etc. that can break things.

[1]: http://emacsformacosx.com/
Moritz Ulrich

Sam Aaron

unread,
May 27, 2012, 5:14:48 PM5/27/12
to clo...@googlegroups.com

On Sunday, 27 May 2012 at 17:48, James wrote:

> Hi Sam, Emacs Live looks seriously cool,

wonderful! Thanks for the kind words

> however I have doubts about this:
>
> "Emacs live has only been tested with a terminal hosted Emacs
> 24.1.50.2 (pre-release). Issues and pull-requests for this and later
> versions will be happily accepted."
>
> This version isn't stable, should I go ahead and install it instead of
> the one I have (23.4)?

I only write that because that's the version I use and I've got no real drive to maintain Emacs Live for all versions of Emacs. However, it *should* work with Emacs 23, and I'll be happy to help out by answering questions if there are issues, but it's nothing I'm going to actively work on to ensure compatibility.



TL;DR My Emacs setup:

If you're interested, I happen to run a terminal hosted Emacs which I installed via homebrew:

brew install emacs --use-git-head --HEAD

Also, I run Emacs as a server and then connect to it via emacsclient. This allows me to use Emacs as a commit editor when I use the git command on the console. For example:

git commit -v

will open up Emacs as the editor to write the commit message and to also view the diff. If I wasn't running Emacs as a server, then this would have to load up a new Emacs instance which isn't the speediest thing in the world. With a server already running, it's as fast as vim to load up :-)

To run Emacs as a server you need to pass the daemon flag:

/usr/local/bin/emacs --daemon

I then alias emacsclient to emacs in my zsh profile:

alias emacs="/usr/local/bin/emacsclient -ct"

Now, if you want to edit a specific file, you can type:

emacs foo.clj

and it will open up via emacsclient in an instant.

In order to use the emacsclient as a shell editor for tools like git, you need to bind emacsclient to the EDITOR variable:

export EDITOR='emacsclient -ct'

Hope this helps,

Sam


--
http://sam.aaron.name






john

unread,
May 28, 2012, 6:08:29 AM5/28/12
to clo...@googlegroups.com
Hi Sam,
I just tried "Emacs live". I'm running  MAC OSX and emacs in  a Terminal with the Option "use option as Meta" 
I have a German Keyboard Layout so I added this to init.el:

(global-set-key "\M-4" '(lambda () (interactive) (insert "\\")))
(global-set-key "\M-5" '(lambda () (interactive) (insert "[")))
(global-set-key "\M-6" '(lambda () (interactive) (insert "]")))
(global-set-key "\M-7" '(lambda () (interactive) (insert "|")))
(global-set-key "\M-8" '(lambda () (interactive) (insert "{")))
(global-set-key "\M-9" '(lambda () (interactive) (insert "}")))

But after restarting emacs the above has no effect?
Would you know why?

James

unread,
May 28, 2012, 7:28:23 AM5/28/12
to Clojure
Thanks Sam, that was very detailed and helpful. I've installed Emacs
24.0.7 and Emacs Live. It's not a smooth experience though - I don't
know whether this is due to the Emacs version or something else.

For one, it doesn't play very well with the OS windowing system. When
I click on Emacs it doesn't always change the window focus from the
previous app to Emacs.

Secondly, when I type several commands in succession quickly, a
smallish white square keeps flashing in the middle of the Emacs
screen, then disappears.

Thirdly, when I try M-x slime I get: "Searching for program: no such
file or directory, lisp". (I have installed Leiningen2).

Quite frustrating that an editor takes so much tinkering to just set
up properly.

Cheers,
James

Moritz Ulrich

unread,
May 28, 2012, 7:52:35 AM5/28/12
to clo...@googlegroups.com
On Mon, May 28, 2012 at 1:28 PM, James <abbo...@gmail.com> wrote:
> Thirdly, when I try M-x slime I get: "Searching for program: no such
> file or directory, lisp". (I have installed Leiningen2).

That's expected. Slime tries to start some random Common Lisp. M-x
slime isn't used for Clojure. If you've got clojure-mode installed,
follow 'Usage' in [1].

[1]: https://github.com/technomancy/swank-clojure

--
Moritz Ulrich

Sam Aaron

unread,
May 28, 2012, 8:38:56 AM5/28/12
to clo...@googlegroups.com
Hey James,

feedback like this is invaluable - thanks very much for taking the time to write it.

It is true - using Emacs is *not* a smooth experience. I've tried to bake in a good number of years experience getting Emacs to work smoothly into Emacs Live, and whilst I don't claim it to be 'smooth' I still think it's a lot better than the vanilla experience.

Let me address your points individually:

> For one, it doesn't play very well with the OS windowing system. When
> I click on Emacs it doesn't always change the window focus from the
> previous app to Emacs.

I've never seen or heard of this before. Do you get this behaviour with a vanilla Emacs (i.e. not using the Emacs Live config)?

>
> Secondly, when I type several commands in succession quickly, a
> smallish white square keeps flashing in the middle of the Emacs
> screen, then disappears.

That smallish white square is the 'visual bell'. It comes up when Emacs wishes to communicate that something isn't quite right.

As a temporary measure, try adding this to the end of ~/.emacs.d/init.el

(setq ring-bell-function 'ignore)

and let me know if that fixes things for you

> Thirdly, when I try M-x slime I get: "Searching for program: no such
> file or directory, lisp". (I have installed Leiningen2).

This is because you need to start a separate swank server and connect to it with slime. See:

https://github.com/overtone/emacs-live#clojure-hacking

>
> Quite frustrating that an editor takes so much tinkering to just set
> up properly.



Just try to imagine the power you'll wield when you do get it working properly :-) I have found the experience definitely worthwhile.

Sam


--
http://sam.aaron.name






Sam Aaron

unread,
May 28, 2012, 8:46:15 AM5/28/12
to clo...@googlegroups.com
Hi John,

first of all, you probably should create your own user pack for this stuff, rather than forking Emacs Live itself - that way you get to take advantage of updates with ease.

Secondly, terminals, options keys, meta, OS X, is a tricksy mix. I use command key happy https://github.com/aim-stuff/cmd-key-happy to allow the cmd key to be a meta key specifically for iTerm2.

Thirdly, you might find it easier to use the kbd macro when globally setting keys i.e.:

(define-key global-map (kbd "C-+") 'text-scale-increase)

Finally, the M-[0-9] keys are used for jumping to the associated numbered buffer via the window-number mode (https://github.com/overtone/emacs-live/blob/master/packs/live/foundation-pack/lib/window-number.el)

You can turn off this behaviour with:

(window-number-meta-mode 0)

(You can still jump to windows with C-x C-j [0-9])

Your global bindings should now work:

(global-set-key (kbd "M-5") '(lambda () (interactive) (insert "[")))

I hope that this helps,

Sam

--
http://sam.aaron.name

James

unread,
May 28, 2012, 12:59:20 PM5/28/12
to Clojure

> feedback like this is invaluable - thanks very much for taking the time to write it.

Always happy to help.

> It is true - using Emacs is *not* a smooth experience. I've tried to bake in a good number of years >experience getting Emacs to work smoothly into Emacs Live, and whilst I don't claim it to be 'smooth' I still
> think it's a lot better than the vanilla experience.

It definitely feels very slick. I've gotten rid of the 'visual bell'
now using your instructions, and things feel better. That flashing
white square in the middle of the screen didn't really convey any
valuable (or even comprehensible) information as to *what* I was doing
wrong.

> > For one, it doesn't play very well with the OS windowing system. When
> > I click on Emacs it doesn't always change the window focus from the
> > previous app to Emacs.
>
> I've never seen or heard of this before. Do you get this behaviour with a vanilla Emacs (i.e. not using the Emacs Live config)?

I got this experience only once, and having already installed Emacs
Live. It may have been caused by a file that hadn't been saved or a
buffer session that hadn't been exited. I'll keep an eye for this
behavior and will ping you if it comes up again.

Regarding Slime and Swank: I guess I don't yet understand the Clojure
distinction between "project" and "file". I've got an absolutely
trivial file that I want to test out, but it looks like Swank expects
there to be a "project.clj". (I opened the file in Emacs, then went M-
x clojure-jack-in, then got "Could not start swank server: Couldn't
find project.clj").

Also, I don't understand this:

"Simply start swank in a Clojure project with lein2 swank".

Is "lein2 swank" a shell command issued from inside a Clojure project
folder?

Thanks, James.

PS. I tweeted your copy / intro for Emacs Live earlier today:
https://twitter.com/abbottjam/status/207049371727036417

Sam Aaron

unread,
May 28, 2012, 4:58:44 PM5/28/12
to clo...@googlegroups.com

On Monday, 28 May 2012 at 17:59, James wrote:


> Regarding Slime and Swank: I guess I don't yet understand the Clojure
> distinction between "project" and "file". I've got an absolutely
> trivial file that I want to test out, but it looks like Swank expects
> there to be a "project.clj". (I opened the file in Emacs, then went M-
> x clojure-jack-in, then got "Could not start swank server: Couldn't
> find project.clj").

Slime is the Emacs client application. Swank is the server which the Slime client communicates with. In Clojure's case, the Swank server runs on the JVM and therefore needs the classpath to be set up correctly. Leiningen is a tool that will set up the classpath for you (amongst many other things). I believe that clojure-jack-in requires Leiningen to work. I have never used it, so can't be sure. I tend to use the swank jar directly from Leiningen:
>
> Also, I don't understand this:
>
> "Simply start swank in a Clojure project with lein2 swank".
>
> Is "lein2 swank" a shell command issued from inside a Clojure project
> folder?


This is what I mean by using the swank jar directly from Leiningen. In this case I'm using Leiningen 2.x (hence lein2) and I'm asking it to run the swank task. I do this from the command line, outside of Emacs.

Sam

--
http://sam.aaron.name


john

unread,
May 28, 2012, 5:05:56 PM5/28/12
to clo...@googlegroups.com
HI Sam,
just wondering what does  https://github.com/aim-stuff/cmd-key-happy  buy you since xterm2 allows you two switch cmd-key to alt-key?
many greetings
John
> To post to this group, send email to clo...@googlegroups.com (mailto:clojure@googlegroups.com)
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to

Sam Aaron

unread,
May 28, 2012, 6:19:41 PM5/28/12
to clo...@googlegroups.com
On Monday, 28 May 2012 at 22:05, john wrote:
> just wondering what does https://github.com/aim-stuff/cmd-key-happy buy you since xterm2 allows you two switch cmd-key to alt-key?

cmd-key-happy allows you to redefine key behaviour for arbitrary apps, so you can swap keys for Terminal.app, Emacs.app in addition to iTerm.app. Also, it allows you to exclude certain key combinations, so you can keep combinations such as cmd-tab to switch apps.

Sam

--
http://sam.aaron.name

James

unread,
May 29, 2012, 5:11:13 AM5/29/12
to Clojure
Hi Sam,-

I've got everything working now (Swank, Slime, the lein2 command).
Many thanks for your comments. I'll get back to you if I have more
feedback on Emacs Live.

Cheers,
James
Reply all
Reply to author
Forward
0 new messages