Archives / Search ›

Emacs 21.1 for Mac OS X is a great port; I've been using it for a few months. Like everything else on Mac OS X, it suffers from glacial startup speed. If you have a lot of RAM, the best solution I've found is to leave frequently-used programs open all the time.

Then you need some way of communicating with those programs from the command line. My launch tool is a help for most applications, and some, such as BBEdit, provide their own command-line tools with additional functionality.

But Emacs isn't really a Mac app, so it doesn't respond to Apple Events. You can't drop files on top of it or use launch.

One alternative is to live in Emacs, so finding a file is always a keystroke away, but I don't work that way. Another is to run a server inside Emacs, which you can ask to open files and execute commands. You can run this server with (server-start) in GNU Emacs, or (gnuserv-start) in XEmacs. No, I didn't get those commands mixed up, the usual convoluted heritage of the programs is responsible.

Next up are the client-side programs: XEmacs has 'gnuclient', and GNU Emacs has 'emacsclient'. Much like BBEdit's command-line bbedit tool, these behave like an editor, in that they take command-line arguments of files, but instead of opening a new Emacs process, they instruct the already-running Emacs to open the files.

With Carbon Emacs, emacsclient does not cause Emacs to come to the front, and you can't pass command-line arguments to the Carbon Emacs when it's running in a window. On any platform, emacsclient gives an error message if Emacs is not yet running. By default, emacsclient pauses until the editor exits: good for using Emacs as an external editor, but not so good when calling it directly from the command line.

So, I wrote a quick script to make emacsclient like bbedit. First, make sure you include (server-start) in your .emacs file or equivalent. Then put this alias in your .zshrc file, or adapt it for tcsh/bash/scsh/whatever you use.

if [[ ! -z $TERM_PROGRAM ]] {
  e() {
    ( emacsclient -n $@ >&/dev/null && \
      osascript -e 'tell application "Emacs" to activate' ) || \
    ( launch -a Emacs && sleep 2 && emacsclient -n $@ )
  }
}

If $TERM_PROGRAM is set (you're running inside Terminal), this script creates an alias called e which tries to invoke emacsclient with the -n option (don't wait around) and bring Emacs to the front. If that fails, Emacs is probably not running, so it opens Emacs, waits a couple of seconds for Emacs to finish launching (if you have a slower machine you may need to change the number 2 to something bigger), then invokes emacsclient.

Mac OS X .pkg files don't work if you rename them. What a mess.

Please just bring back the Apple Installer! It's years and years of work on easy-to-use, user-friendly installers, just thrown out the window all because the NeXT installer worked with a recompile. No amount of shell script wrappers are going to save it.

Yes, it's snowing, for real! All I see outside is white.

Looks like it's going to snow tonight! Finally!

From here:

      TONIGHT:
      [snow] Lo: 23    Cloudy, windy, and colder with snow and blowing
      SNOW             snow. Around 4 to 6 inches should accumulate
                       overnight. The low 23. Winds northwesterly at 15
                       to 25 miles per hour.
      TOMORROW:
      [snow] Hi: 23    Cloudy and windy with periods of snow. Another
      BLOWING SNOW     couple inches of accumulation is likely, making
                       the storm total accumulation 6 to 8 inches.
                       Considerable blowing and drifting snow will cause
                       hazardous travel, especially in rural locations
                       where blizzard conditions are likely. The high 23.
                       Winds northwesterly at 25 to 35 miles per hour
                       with higher gusts of over 50 miles per hour.

Here's how I set up rsync to work automatically from Radio. The problem was in getting SSH authorization to a process executed with sys.unixShellCommand. Radio just executes commands, it doesn't provide any way of connecting standard input. Standard output is returned as the result of the command, and standard error goes to the console log (open Console.app to see it).

Install SSHPassKey. This program will prompt you for a SSH passphrase once, then save it in the Keychain subsequently. It essentially replaces ssh-agent with the Keychain, but it can coexist with ssh-agent. I use both.

I had been using a similar program called SSHAskPassword, but SSHPassKey is better.

The OpenSSH client (ssh) can be configured to use an external password request program with the SSH_ASKPASS environment variable. However, it only does so if the DISPLAY variable is set, and there is no stdin connected. So, from Radio, you can fake the DISPLAY variable like this:

sys.unixShellCommand ("DISPLAY=' ' ~/scripts/sync-weblog.sh")

where the contents of sync-weblog.sh are:

#!/bin/zsh
export SSH_ASKPASS=/Applications/Utilities/SSHPassKey.app/Contents/MacOS/SSHPassKey
export RSYNC_RSH=ssh
rsync -az ~/Sites/sabi.net/log ainaz:web/

If you use SSHPassKey's “configure login environment” option, you don't need to set SSH_ASKPASS, but you still need to set RSYNC_RSH.

One thing I can't seem to do is to get Radio to execute the shell script asynchronously. I don't care about the return value, I just don't want to hang Radio while it's happening. Anyone?

‹ Newer Posts  •  Older Posts ›