WriteRoom-like fullscreen editing mode

As of version 1.4, Aquamacs includes a fullscreen mode which fills the screen concealing the dock, the menubar, and other applications. This is great for writing without distractions. With a few lines of lisp, you can define a function which uses this feature to reproduce the large font, black background style of WriteRoom, the free application which first popularized this feature:

Iconify from Aquamacs' fullscreen-mode

I get the error message “Cannot notify window manager of iconification” when pressing C-z in the new fullscreen mode, so I made my own that first checks for fullscreen mode and if so, exits (I guess this is a bug):

Uncomment the seventh line if you want to protect your buffer from input when iconified. I use this since if you iconify an Aquamacs frame, it’ll still let you type in the open buffer; I always switch to scratch to make sure none of my important stuff is changed (this also lets you type things without anyone seeing what you’re typing, if you have a use for that…)

Restoring classic emacs selection mode

To provide more common selection behavior, Aquamacs uses cua-mode (not pending-delete-mode or pc-selection-mode). To restore the classic Emacs behavior set in your startup files:

(cua-mode 0)

Note that, if you’d like to disable cua-mode and enable transient-mark-mode in Aquamacs, the above (cua-mode 0) must execute before you enable transient-mark-mode, e.g.:

(cua-mode 0)
(transient-mark-mode 1)

Working the Mouse - mouse button functions in Aquamacs

Because Macs usually have mice with one or maybe two buttons [Note: this is no longer true; most macs have trackpads that recognize presses with anywhere between one and four fingers. However, Emacs does not recognize the difference in number of fingers for a trackpad press.], Aquamacs emulates the emacs-specfic mouse buttons as follows:

mouse button (left) is mouse-1: use to set the point or select text.

command-click (left) is mouse-2: use to yank from the kill-ring (or follow certain links)

mouse button (right) or control-click (left) is mouse-3: use for a context menu

Usually, the right mouse button or control-click will bring up some sort of context menu, just like in other applications. There are some other functions:

Option-drag (left): use to draw up a secondary selection (which is not overwritten by typing). You will be able to copy the selected text with Shift-Command-C.

Shift-click (left): extend selection (as known from other apps)

Help, I want my Emacs mouse functions back!

If you’re a seasoned Emacs user, chances are that you want to use mouse clicks together with some modifier keys such as Control. You may have a five-button mouse that produces all the mouse clicks necessary for successful Emacs magic. In that case, try the following setting:

(setq mac-emulate-three-button-mouse nil)

Note that mouse functions will differ from is described in the Aquamacs documentation.

Replacing your /usr/bin/emacs with Aquamacs

To be able to launch files in Aquamacs from the command line, just select “Install Command Line Tools” from the Tools menu and follow through with the installation. It will ask for the password of a user with administrator privileges. You can then use the command ‘aquamacs’ from a shell to start Aquamacs. Use the ‘alias’ command of your shell to map it to something shorter such as ‘a’.

Some users have not had good luck with the script that is being installed this way. An alternative is create an alias in your shell’s *rc file. For example, in .bash_profile or .tcshrc

alias aquamacs='open /Applications/Aquamacs.app/'

This alias can either open Aquamacs:

>aquamacs

or open Aquamacs with a file:

>aquamacs script.pl

This solution won’t support opening Emacs via “sudo” because the “open” command is equivalent to a click on the application icon. In order to get aquamacs on root just type:

> sudo /Applications/Aquamacs.app/Contents/MacOS/Aquamacs "$@"

A better alternative on the previous open command is

alias aquamacs='open -b org.gnu.Aquamacs'

This allows emacs to open files which have a file-association to a different application.

When a file doesn’t already exist, `aquamacs file.txt` will fail since open says “File does not exist” rather than passing the filename as an argument to Aquamacs. Put the following function in ~/.bashrc; then `amacs file.txt` will behave more like its command-line emacs cousin (which only creates the files when they are saved).

function amacs
{
# Create the files as needed -- not as good as raw emacs, but acceptable
for f in "$@"
do
test -e "$f" || touch "$f"
done
open -a /Applications/Aquamacs.app "$@"
}

Note also that the ‘open’ command returns immediately. This makes it a poor option for the EDITOR shell variable and other use cases that expect the command to be synchronous and not return until you’ve finished editing. For these purposes, it can be useful to use the direct alias as shown for sudo. The direct version will open a new Aquamacs instance, and the command will not terminate until that instance of Aquamacs terminates.

Opening Files In Same Frame, but keep Apple-N functionality the same

If you’re coming from Emacs, you may prefer the Emacs-behavior over the Aquamacs default. Uncheck the “Open Buffers in Separate Frames” option in the Options menu and then “Save Options”. Alternatively, add this to your emacs preferences file:

(one-buffer-one-frame-mode 0)

Some people might want Aquamacs to use the classic Emacs-behavior most of the time, but would still like to have the option to spawn new frames. This command will spawn a new frame:

Aquamacs 1.5 has made this the default behavior. To get the old behavior back and make Apple-w close the current buffer, not the whole window, do:

(define-key osx-key-mode-map (kbd "A-w") 'kill-this-buffer)

Set Aquamacs Icon

Some users have complained about the new icon. If you prefer the standard FSF icon or something else, you can simply click on another application whose icon you’d like to copy in Finder and hit Apple-I. In the window that pops up, click the icon and copy it to the clipboard with Apple-C.

Then, you do the same with Aquamacs Emacs.app, except that you just paste the copied icon with Apple-V over the old one. Voila!

Use "Open" command in Dired Mode

Mac OS X offers “open” command using which you can open every file by default associated application. That is typing in “open foo.pdf” in terminals will make Preview.app open foo.pdf. Add following lines to your InitFile or ~/Library/Preferences/Aquamacs Emacs/Preferences.el will let you bind “open” command to “o”, the key:

Changing Aquamacs Frame Properties (Size, Color)

Modify aquamacs-mode-specific-default-themes. You will have to change the entry for the particular mode you wish to edit. If you would like to modify general settings, change default-frame-alist (and special-display-frame-alist) with the frame parameters you want, just like on any standard Emacs. (Note that mode-specific theme parameters will override the default-frame-alist settings. You can just de-select “Frame Appearance Themes” in the Option menu in order to turn off mode-specific themes alltogether.)

To change the initial frame, you can modify initial-frame-alist as follows. Create a file ~/Library/Preferences/Aquamacs Emacs/Preferences.el (if necessary) and insert the following customizations:

It can happen that new windows are smaller nevertheless. This might be the result of an Aquamacs feature called smart frame positioning. It ensures that new windows aren’t covered by the dock etc. If that results in windows you consider too small, you can add

Filename completion using the space key

Customizing Aquamacs for use with Mutt

I use the mutt mail program running in the mac terminal. I just finally converted to using Aquamacs as my editor in mutt. Along the way I had to deal with a number of small glitches which I detail on my website.

These notes aren’t all directly related to Aquamacs but a number of them are relevant even if you don’t use mutt on the mac. In particular I provide a solution to the issue of Aquamacs emacsclient frames displaying behind terminal windows (thanks to the mailing list for that answer).

To be moved to a more relevant page

flyspell trick: flyspell-check-previous-highlighted-word

Flyspell has a surprisingly underutilized function called flyspell-check-previous-highlighted-word . Imagine that you’re typing a long sentence and, oops, flyspell gives you the red-line for misspelling a word, but you don’t want to interupt your thought to fix it right now. Most people would mouse over to the misspell once they’ve finished the sentence. How MS Word! Instead, call flyspell-check-previous-highlighted-word , and a list of suggestions will appear on the top of the screen, pick one, and then continue right from where you left off. I have mine bound to “C-c j” in my InitFile:

Upon start, Aquamacs (from version 0.9.4) automatically loads all files named site-start.el (or site-start.elc) residing in any of the aforementioned paths or their subdirectories. If you want to distribute a plugin that gets installed automatically, just install a subfolder into the user’s ~/Library/Application Support/Aquamacs Emacs directory (or the system-wide equivalent) and have a site-start.el file in that subfolder which loads up your package. That way, the user doesn’t need to add a (require ‘yourplugin) to his Preferences file. Make sure that you don’t change things irreversibly. Better offer a mode that can be turned on.

German Logitech Keyboards

Here my hack for German Logitech Keyboards. This should be configurable in user preferences, but you can also add this to your Preferences.el:

Turning off version check

Short version:

(setq aquamacs-version-check-url nil)

Long version:

If you’d like to turn off the regular online check that Aquamacs does in order to see if there is a new version available, enter M-x aquamacs-check-version-information RET and follow instructions. Version checking allows the Aquamacs project to collect some statistical data, because the check - like any internet transaction - leaves a trace on the server.

You can get documentation about the information sent back to the Aquamacs server using M-x aquamacs-check-version-information RET, and it is easy to disable the version check. This check isn’t done upon every startup, but, more precisely, every three days. We don’t keep any information relating to the user’s documents, or information that would allow for the identification of a specific user (beyond the IP address, which is necessarily logged due to the server access). The kind of information we generate is transparently shared here. There are two primary purposes for this “market research”: I want to make sure that Aquamacs actually gets used (otherwise I would spend my time on other pursuits), and I want to see whether there are some default settings that are changed by a large number of people. I rather use empirical data than complaints coming in on the mailing list, which are biased towards those who are unhappy and/or specifically vocal. DavidReitter

How to cleanly uninstall Aquamacs?

I’d recommend AppCleaner, just as I would for uninstalling any other application on OS X.

Ringing the bell, visible bell, sound, etc.

By default, Aquamacs won’t make a sound when a search fails or when you try to move beyond the top or bottom of the buffer. To cause Aquamacs to make a sound, put the following in ~/Library/Preferences/Aquamacs Emacs/Preferences.el or your .emacs file:

(setq ring-bell-function nil)

If you find an audible bell to be irritating, consider using a “visible bell”, which is a momentary flash on the screen to notify you that something happened. Aquamacs implements a visible bell as a large white square that appears in the center of the screen. To turn on the visible bell, use

(setq visible-bell t)

The two variables interact in a way that may be confusing. For example, you can’t have a visible bell and an audible bell at the same time. Here’s a table that shows some settings the variables can take, and the resulting effect.

Starting Aquamacs with multiple files in tabs

I have a minor annoyance with the way Aquamacs handles tabbed buffers. It seems that until a new tab has been opened, new files are not opened in tabs. This means that I have to press ‘Apple-T’ first, then open the file, then close the untitled tab. After that new files are automatically put in tabs. Also, if opening multiple files from the command-line, the window is split horizontally in two - I’d like to specify that it puts the files in separate tabs. Is there a way to do this?

Opening multiple tabs from the command line works for me with the latest release (1.8). Maybe you need to enable tabs in the Options menu. This gets turned on automatically when you press Command-T. See the support mailing list (Emacs on OSX) for more assistance. – DavidReitter

Thanks, that improves things somewhat (I selected Options/Show Tabs, then Save Options). Now it works as expected when I open Aquamacs with only one (or no) file. However, when I specify two files on the command line, it opens with two panes, with the top pane containing the first file and another tab for the *scratch* buffer, and the bottom pane containing the second file.

Total Newbie Question: Where Do The Aquamacs .el Files Live?

Hi, I’m just getting started with Aquamacs on OS X 10.6 and I’m not sure where I’m supposed to add customizations. For example, I’m trying to install a markdown mode (http://jblevins.org/projects/markdown-mode/) but I don’t know where to put the actual .el file. Also, I’m just putting my .emacs files in my home directory. Is that the best place for it?

Thank you for your help.

in Library/Application Support. You’ll find the answer in the manual. – DavidReitter

Turn off scratch buffer when Aquamacs starts

I installed Aquamacs 2.0 on my mac and I can’t get rid of the scratch buffer. I tried setting the option in Preferences>Aquamacs>Aquamacs Scratch File to “nil” and nil without quotations, but it just changed the file path of the scratch buffer if you want to save it. In the Aquamacs-Scratch-File option it does not give me a toggle option as to turn it on or off. Please tell me a way to stop opening up the scratch buffer when Aquamacs starts.

Windows-style Editing Keys Under Aquamacs

Aquamacs is a nicely polished package. Thanks. One thing I’m looking for is editing keyes for page up/down, home/end on my MacBook Pro. Any ideas?

This is a general Mac question. Press Fn-up/down etc on your MBP keyboard.

This work is licensed to you under version 2 of the
GNUGeneral Public License.
Alternatively, you may choose to receive this work under any other
license that grants the right to use, copy, modify, and/or distribute
the work, as long as that license imposes the restriction that
derivative works have to grant the same rights and impose the same
restriction. For example, you may choose to receive this work under
the
GNUFree Documentation License, the
CreativeCommonsShareAlike
License, the XEmacs manual license, or
similar licenses.