Emacs.app on Mac OS X Leopard

Update: I have another blog post for Mac OS X Snow Leopard.

I’ve been using Mac OS X Leopard for about a day now. The unfortunate thing that I discovered was that Leopard’s X11 support is not quite working yet. There are issues with Inkscape and Gimp, and I couldn’t get Emacs to work in X11. This encouraged me to find a better way to get Emacs into a windowed environment, and I ended up being able to create (uh, copy) an Emacs.app.

To create an Emacs.app, do the following:

Download the Emacs source code. Note: Leopard comes with emacs 22.1.1 (uses Carbon), so you want to download emacs-22.1.tar.gz. However, instead of downloading the entire source code, you can download just the Emacs.app from me here to save GNU 36MB of bandwidth.

Extract the files.

$ tar zxvf emacs-22.1.tar.gz

Go to the ‘emacs-22.1/mac’ directory

$ cd emacs-22.1/mac

Copy ‘Emacs.app’ to ‘/Applications/’

$ sudo cp -r Emacs.app /Applications/

Symlink /usr/bin/emacs to /Applications/Emacs.app/Contents/MacOS/emacs

$ ln -s /usr/bin/emacs /Applications/Emacs.app/Contents/MacOS/emacs

And, you may want to change the ownership on the Emacs.app

$ sudo chown -R root:admin /Applications/Emacs.app

That’s it. You should now be able to launch Emacs.app as a regular Mac application.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

31 Responses to “Emacs.app on Mac OS X Leopard”

  1. mrflip says:

    Incidentally — if you open files in Emacs.app using the

    open -a /Applications/Emacs.app "$@"

    method and you are annoyed by the fact that it opens a new frame (window) for each file — add

    (setq ns-pop-up-frames nil)

    to your .emacs and fixed.

  2. Abhijit Choudhury says:

    I did everything mentioned. But when I click on the icon nothing happens.
    Any thoughts on how to debug ? I'm a Mac newbie.

    Thanks,
    Abhijit

  3. Laurie says:

    Thank you! This worked great for me after I used sudo for the link.

  4. Anonymous says:

    Thanks a lot!
    This method works great and saved me a lot of frustration!
    Francesco

  5. Anonymous says:

    Can it be launched from a terminal? ‘m new to macs, just got my first (a macbook pro).

    Anyway, your instructions worked great and I can now just click the emacs icon and launch emacs in its own window. Woohoo!

    However, what I really want to do is from a terminal window, type “emacs filename” and have emacs pop up in its own window and open the file “filename”. Unfortunately, I can’t figure out how to launch emacs in its own window by typing a command at a prompt in a terminal window.

    Any advice?

    Thanks.

    -Jonathan

    • michael says:

      This worked for me:

      $ alias emacs=’open -a /Applications/Emacs.app’
      $ emacs [FILE]

      • Anonymous says:

        Two more problems. Yup, that works. Two more problems though:

        1. If I type “emacs filename” where filename doesn’t exist (which is how I’m used to creating a new file), it just prints an error that the file does not exist, instead of opening a blank buffer with the desired filename.

        2. Where/how can I set the default font and geometry? ~/.Xdefaults does not seem to be doing anything, and using “open”, I can’t seem specify that info as a command line argument.

        Thanks.

        -Jonathan

        • michael says:

          1. Hmmm. I rarely ever do that. I don’t know how to get `open` to do that. I almost always do C-x C-f and C-x C-w.

          2. Emacs.app uses Carbon instead of X11. That is why your ~/.Xdefaults don’t do anything. I haven’t changed the fonts from there default. I’m sure you can set them in your .emacs file. Also, SHIFT-Clicking opens a font menu.

          Sorry my response isn’t more helpful this time.

          • Anonymous says:

            Thanks.

            After a little searching on the internet for the syntax, I was able to get the font and size set in my .emacs file.

            As for #1, for the present, I just wrote a simple shell script that checks the input, and if it finds that any of the files don’t exist, it “touches” them, then calls “open”. This is not ideal, because it will pre-create the file that wouldn’t normally be created until a “write”, and therefore will leave an empty file lying around if I decide I don’t really want to save the file after all. But until I find a better solution, this will at least prevent my getting an error whenever I launch emacs in the way I am so used to doing.

            -Jonathan

            • Gabo says:

              He Jonathan,

              Well, I never ever have any problem with emacs. The thing, perhaps, is that I do not use “open whatever.app”. I have a little script called “MacEmacs” that contains the following two lines:

              #!/bin/sh
              /Applications/Emacs.app/Contents/MacOS/Emacs $@ &

              Why? Because I had to be able to use emacs on the terminal when working from home on my mac at the office, so having a different “emacs” for terminal orfor desktop was important for me. In any event, you can call the script anything you want (except perhaps “emacs”, because it might go into circles, eternal loops). Anyway, this would open your files, if new no errors will happen.

              Have fun!

    • Koet says:

      Hi Jonathan,
      use:
      open -a /Applications/Emacs.app <filename>
      ^^
      Cheers!

  6. mao says:

    even easier with emacs 22.2? I downloaded emacs version 22.2 and ran

    $ tar xvf emacs-22.2.tar
    $ cd emacs-22.2
    $ ./configure –enable-carbon-app
    $ make
    $ cd mac
    $ sudo cp -r Emacs.app /Applications/

    and it works like a charm.

    also, you can test it with:
    $ open Emacs.app
    before copying it over.

    link was unnecessary
    chown probably a good idea, though for some reason, I didn’t need to.

    thanks for the tip! I was going crazy, too, until I saw this page

  7. ateymura says:

    Did not work for me :( (. I got a new MacBook a week ago or so and just can’t stand to live without my emacs.
    But running it in a terminal is a pain.

    Unfortunately your procedure doesn’t seem to work on MacBook 4,1 :( (or at least it did not work for me)

    • michael says:

      Yeah, living without emacs can be quite painful.

      Do you have any error messages? Did you symlink /usr/bin/emacs to /Applications/Emacs.app/Contents/MacOS/emacs (or wherever you put the Emacs.app)?

      • Anonymous says:

        I have emacs in /usr/bin/emacs and /opt/local/bin/emacs. They seem to be the same version, however, the /opt/local/bin/emacs loads my ~/.emacs config file fine with the slime-autoload stuff, but the /usr/bin/emacs has an error loading slime-autoload. The problem is that when I link to /usr/bin/emacs, Emacs.app opens fine but with the slime-autoload error. Whereas, linking to /opt/local/bin/emacs results in Emacs.app not even opening. How can I get /usr/bin/emacs to recognize my slime-autoload in ~/.emacs ?

        • michael says:

          I haven’t tested using /opt/local/bin/emacs, which I’m assuming is the MacPorts version.

          This is how I have slime setup:

          ;;
          (add-to-list ‘load-path “~/elisp/slime”)
          (setq inferior-lisp-program “/Users/michael/local/bin/sbcl –core /Users/michael/local/lib/sbcl/sbcl.core”) ; your Lisp system

          (autoload ’slime “slime” “The Superior Lisp Interaction Mode for Emacs” t)
          (add-hook ‘lisp-mode-hook ’slime-lisp-mode-hook)
          ;;

          or

          ;;
          (add-to-list ‘load-path “~/elisp/slime”)
          (setq inferior-lisp-program “/Users/michael/local/bin/sbcl –core /Users/michael/local/lib/sbcl/sbcl.core”) ; your Lisp system

          (require ’slime)
          (slime-setup)
          ;;

          I had to set inferior-lisp-program to the full path, because emacs does not get your PATH settings unless it is launched from the Terminal. If you want to have slime autoload, the first option should work for you. If you want to have it load when emacs launches, which is the documented way, the second option should work for you. If someone has a better way, I’d be happy to hear it.

          I hope that helps.

          • Anonymous says:

            Thanks for the reply! A couple more questions: Should the config information you provided be placed in my ~/.emacs file? And, what does (add-to-list ‘load-path “~/elisp/slime”) do? I do not have a “~/elisp/slime” path on my machine, but I do have “~/.slime” which is an empty file. Any further suggestions are much appreciated.

            • michael says:

              Yes, the information should go in your .emacs file. (add-to-list ‘load-path “~/elisp/slime”) adds the slime lisp files to your elisp load path. I have a ~/elisp directory where I keep all my manually installed emacs modes and elisp. Some people use their ~/.emacs.d directory instead. As far as I know, you do not have to worry about your .slime directory. You can download slime from http://common-lisp.net/project/slime/. Extract the files somewhere (i.e. ~/elisp or wherever) and set your load-path.

              As a side note, I downloaded SBCL from http://sbcl.sourceforge.net/platform-table.html. Installed it and set my inferior-lisp-program to where I installed it.

              Good luck.

              • Anonymous says:

                I got it work now. For users with MacPorts installing to /opt folder, add:
                (add-to-list ‘load-path “/opt/local/share/emacs/site-lisp/slime”)
                at the beginning of ~/.emacs. This did the trick for me…thanks again.

  8. Deb says:

    It works…Thanks a lot.

  9. Anonymous says:

    Brilliant. Works great on MacBook Pro Intel Leopard 10.5.2 (AFTER creating the symlink–DON’T forget!). This is exactly what I was looking for.

  10. Deb Cameron says:

    Worked great. Thanks! I just installed Leopard and couldn’t live without Emacs running as an app for long. I had to sudo the ln. In case you want it, here’s a version of this procedure that works with your binary instead:

    Extract the files.

    $ tar zxvf /Users/user/Desktop/emacs-22.1-mac-app.tar.gz

    Copy ‘Emacs.app’ to ‘/Applications/’

    $ sudo cp -r Emacs.app /Applications/

    Symlink /usr/bin/emacs to /Applications/Emacs.app/Contents/MacOS/emacs

    $ sudo ln -s /usr/bin/emacs /Applications/Emacs.app/Contents/MacOS/emacs

    And, you may want to change the ownership on the Emacs.app

    $ sudo chown -R root:admin /Applications/Emacs.app

    That’s it. You should now be able to launch Emacs.app as a regular Mac application. (The beautiful GNU icon is in the Applications folder, soon to be in your dock.)

  11. Anonymous says:

    were do i find the ‘emacs-22.1/mac’ directory ?
    I have no idea?

    pretty new to all this stuff…

    Christopher

    • michael says:

      I’m guessing that you downloaded the file I provided instead of the file from GNU. If so, my file does not have an ‘emacs-22.1/mac’ directory, and you would begin by copying Emacs.app to ‘/Applications/’.

    • Matthias says:

      Works like a charm on a MacBook. Thanks!

  12. rob Nicholas says:

    Couldn’t get this to work for me — it seemed to think I was trying to run an application for a different architecture.

    When I try ‘open -a Emacs.app’ from the command line, I get ‘LSOpenFromURLSpec() failed with error -10661.’ When I double-click on the Emacs.app icon, I get a window that pops up saying ‘You can’t open the appication “Emacs{” because it is not supported on this architecture.”

    BTW, I’m running on an iBook G4 with a fresh, clean installation of Leopard.

    • michael says:

      That’s strange. I am running Leopard on a PowerBook G4, so there shouldn’t be an architecture issue with my instructions. Also, one of my friends who has an Intel architecture was able to get it working as well.

    • I have the same error with my PowerBook G4. I recompiled the Emacs.app for Tiger and works fine on 10.5 for me.

      Try this one:

      http://dicoalex.free.fr/Emacs.zip

      Alex

    • Mike Williams says:

      Did you create the symlink? I initially got the ‘not supported on this architecture’ error too, but it went away once I actually followed Michael’s instructions and created a symlink to /usr/bin/emacs.