Mac Emacs (Aquamac)

Unfortunately enough this seems to be going to be a “text editor blog”, with BBEdit post, this post and almost finished post about TextMate.

In fact I already told Mac Emacs versions do seem to miss something, and this is the reason why I chose to buy TextMate (a cheap 39$ affair).

Right now I’m just trying to convince myself that TextMate was worth 39$. I mean, probably if I discovered Aquamacs earlier (the first version I tried long time ago were “new”) I would not have bought it (even if once I was a vi fan — and in fact I still am, for some things).

And not because I don’t like TextMate anymore… just because Aquamacs is free and is free software [ which is good ].

Aquamacs

You can download Aquamacs here.

I told how weird do seem Emacs key bindings on MacOS (in fact they look odd everywhere outside Emacs). Some of them are pretty standard, readline supports them by default (and so most command line applications do) and Cocoa controls also do (that is to say they work in any text editor.).

I’m talking about ctrl-a, ctrl-e, etc.

But you are never going to convince a Mac user he has to ctrl-x ctrl-s to save or ctrl-x ctrl-c to quit.

So Aquamacs uses standard Apple bindings. Command-C, Command-S, Command-Q. This way the command-key is not free. And meta has to be mapped on alt.

So if you have a not english keyboard, you may not be able to type square brackets, for example. And braces. In fact this is a serious design flaw, in my opinion.

In fact I found out the flaw was in the user (me) who did not read the wiki. Meta, Apple/Command, Option keys are fully configurable.

In my opinion if you are going to use Emacs, you expect to find Emacs key bindings. The more logical choice is to use Command for meta, and leave alt as alt, to enter braces (and on american keyboards accents.).

Still you may want (and it is my choice) to allow Command-key to be used for mac key shortcuts, but you want to pass option/alt to the OS (so that you can use [] and other characters). You do this with

(setq mac-pass-option-to-system t)

.

Should you have troubles with copying and pasting text from outside into Emacs or vice-versa, try to use

(setq x-select-enable-clipboard t)

In fact you can find lot of informations in the wiki:
Emacs wiki.

The nice thing was that you are able to use standard MacOS open and close dialogs, that is really nice.

But there is something even more beautiful features:

  • Frames are mapped to windows: when you open a file, you open it in a new window, and you can manage windows with Expose. Probably a hardcore Emacs user is not going to like this (but probably he will prefer some other more standard version).
  • Fonts: fonts are nice. It uses MacOS fonts and locales and unicode characters appear to be handled correctly (not sure for full unicode, for european >7bit characters, it works).
  • You also have transparencies. It’s just a little nifty feature.
  • Cut and paste works as you expected, so does deleting a text selection. This is probably one of the single features users that are not used to Emacs are going to hate, even if it makes perfectly sense in the Emacs way of working.
  • Last but not least, you can associate files with Emacs, so you can use it as a standard MacOS text editor to open files double clicking in the finder.

I’m really impressed by this project: in fact it’s enought Emacs you want get too confused if you are used to Emacs, but it’s also enought Mac you can use it along your other Mac applications, without having to rethink basic commands (if you don’t want to).

Right at the moment it is in my opinion the best Emacs version for the MacOS out there.

12 Responses to Mac Emacs (Aquamac)

  1. You can easily switch Option back to Mac-Option with an entry in the Options menu (or by pression Apple-;). Then, use ESC as Meta.
    Or map Meta to the Fn key (on laptops), or use the Command key (at the expense of the Mac functions).
    I currently don’t see a better solution (we’re working on Caps Lock -> Meta) – do you see any?

  2. rik0 says:

    Well, I have found the wiki, that is well made and plenty of informations.

    Right at the moment I found a quite usable configuration passing alt to the system and using ESC as meta. In fact ESC as meta is not my favourite, still it seems the best solution available right at the moment (and I had to use it in other situations, so it’s not that weird to me).
    I had not thought about using fn…
    would it be
    (setq mac-fn-modifier ‘meta)
    ?
    It seems a good idea. Probably the best one (in fact I don’t need fn in Emacs, if I need to mute the laptop, I can switch to another app and do it).
    Thank you very much for your solution!
    (May I ask how you discovered this blog? πŸ™‚ You have been really quick to answer!)

  3. i think it’s mac-function-modifier.
    i implemented that a while ago… it’s still experimental and may not work perfectly, especially on non-US/GB keyboards.

    CapsLock is going to be a much better solution – but that’ll take some time.

    Got here via Technorati…

    – D

  4. by the way. Quitting Emacs is C-x C-c …

  5. rik0 says:

    Thank you very much. mac-function-modifier works (and right now seems to work well, italian keyboard here — I hate it, it gave me more problems than everything else).

    Now I just have to train my fingers.

    I did not think I had some chance to get visible on Technorati writing about Aquamacs… πŸ™‚

    > by the way. Quitting Emacs is C-x C-c …
    Thanks.

  6. […] If you are interested in an Emacs version that is MacOS friendly, read this. […]

  7. David Reitter says:

    one last thing from me. I think you mean mac-option-modifier up there, not x-select-enable-keyboard. The latter does something else – it ties the Emacs killring to the system clipboard. If you type C-x h x-select-enable-keyboard, you’ll get a description. If it’s unclear in the Wiki (sorry!), maybe you’d like to correct it…

  8. rik0 says:

    It’s perfectly clear in the wiki. The point is I tend not to check what I write.

    I had to put in my .emacs since in one of the many configuration I tried before mac-function-modifier the kill ring was not synchronized. In fact when I yanked something in Emacs it wasnt available ouside and viceversa.

    (setq x-select-enable-clipboard t)
    fixed the problem…

    The correct s-expression was
    (setq mac-pass-option-to-system t)

    [Β since to avoid passing opt you had to set it to nil ]

  9. Emacs Keybindings weird ?

    I find Mac keybinding weird πŸ™‚ :). It mostly depends on what a person is used to.

    Emacs Keybinding are ancient. Emacs started ad TECO macro in the ’70 (1975 if I’m not wrong, and it had windows splitting the terminal real espace in areas, hence the “frames” when it comes to graphiic UI , no [IYFEG] invented CUA or HIG at that time, Unix tryed to suggest a standard for keybindings, but Emacs was ITS stuff and now is GNU stuff.

    There’s a logic behind Emacs keybinding. Let’s first say a thing. Notepad is always in Insert mode. vi has insert and command mode. Emacs is always in command mode. Every key you press invokes a function. The most obvious function is “insert the key I just typed” where expected.

    Then there are the “most common commands”. You access them with chords using Control and Meta. On some keyboards you can also use Super and Hyper. You can use more modifier at a time: usually Control-key (C-key) works on character scope, Meta-key (M-key)on word scope and Control-Meta-key (C-M-key) on paragraph/function scope. Key is always mnemonic (in English).

    Then there are the extended commands, C-x something, where something could be a simple key or a chord, i.e. .C-x s, C-x w, C-x C-c. If a Mac user can’t learn it, sorry, the problem is between chair and keyboard :).

    And then the mode specific C-c commands, with C-c (letter) left free for user customization.

    And finally, for the commands that people thinks you don’t use this much are invoked by name. M-x name-of-the-command.

    If you need that-very-useful-to-you-command just use (global-set-key ) or (local-set-key ) – the one that suites most your needings.

    Hoping this blabbering was of some usefulness.

  10. rik0 says:

    In fact I said that Emacs key bindings look weird on MacOS X, not that they are weird in general. Think about ctrl-q to quit. In GNU/Linux or another X11 based GUI it’s perfectly normal to quit something with ctrl-q, the same thing in you are working in windows.
    But if a MacOS applications closes with ctrl-q, this is weird. MacOS gave UI guidelines, and every Mac application follows at least the most basic ones. Quit on MacOS is Apple-Q.
    This is why I told “ctrl-x ctrl-c” looks weird. It is something you have to get used to, not something you “have in your fingers”.
    Your sentence “I find Mac keybindings weird” makes perfectly sense. You use a lot Emacs, you use more often Emacs than any other application. This makes Emacs bindings more natural to you.
    I dropped vim mostly because of keybindings. Basic text moving strokes are the same for Emacs, for most Cocoa applications and for most readline based applications. They come perfectly natural to me. I dropped vim because I had to keep in my “finger memory” more bindings.

    And the more you have to switch between “different” applications, the more you are gonna hate those incoherences!

    For example I get horribly frustrated everytime I get on someone else’s machine and I have to use Winword. F12 saves. This sucks. I’m typing ctrl-s all the time. Of course if you use Winword very often you probably dont Save documents, but you F12ave them. πŸ™‚

    Emacs needs loads of bindings, and “standard” ones are not sufficient (not that they were standard when Emacs started). It’s the most configurable thing I’ve ever seen (and this is good, I mean).

    In fact Emacs was created as a standardization of the whole different Teco’s macros. There was a time when since every hacker used his own macro set (and his own keybindings) switching terminals was almost impossible. There is an interesting page about it from here:
    http://www.oreilly.com/openbook/freedom/ch06.html

    (it appears that Emacs was not there in 1975, it was still called Teco: the “macro explosion” was possibile from 1976, then Emacs project started after a couple of years. So it should be 1978. Of course dates can be wrong, even if I don’t think so, since rms himself read that book)

    I had never thought about Emacs “always-command-mode”. In fact thinking about it’s Lisp philosophy it makes perfectly sense. Everything is a List. Everything is a command. Really interesting.

  11. Matt says:

    Hi πŸ™‚

    Juste a quick precision. Aquamacs provides the special shortcut C-; to enable/disable the binding of the Alt key with the “Meta”-key.

    I use Aquamacs to write code on a French Mac keyboard, and typing [] and {} requires using Alt.
    It was very annoying at first, but I got quite used to bouncing between emacs-mode and mac-mode with C-;

  12. Well, this post is kind of 6 years old. Back then, I’m not sure it had such key. Besides, I just could not bear to have to modes of operation.

    Right now things have improved: I do not have non U.S. keyboards anymore. That simplified my work a great deal.

    If you are interested, my new blog is here: enrico-franchi.org

Leave a reply to David Reitter Cancel reply