Nicholas Riley’s Weblog
Thoughts from a computer science graduate student,
medical student and Cocoa programmer (this week).

Skip over navigation
February 2002
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28    
Jan   Mar

made with
Click here to visit the Radio UserLand website.

Click on the coffee mug to add Nicholas Riley's Instant Outline to your Radio UserLand buddy list.

 

>
Monday, February 25, 2002
 
I need some snack food I can eat at the computer and not make a mess. I am forever picking crumbs out of my keyboard and its tray as I eat granola bars. At least, now I primarily drink water during the day, there aren't issues with sticky things stuck in the keyboard. Suggestions?

And after the previous post, I've been getting lots of great work done. Guess I should complain about not being able to work on here more often—erm, no, probably not, I'll lose a reader and cut my audience in half. 9:56:54 PM | reply []

I've been completely unable to focus on work all day. This is really annoying. Keep trying, I guess... 8:17:44 PM | reply []

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. 7:01:06 PM | reply []

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. 6:21:22 PM | reply []

Yes, it's snowing, for real! All I see outside is white. 4:42:53 PM | reply []

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.
1:52:14 PM | reply []

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? 3:20:08 AM | reply []

This is a sample test from the new RadioService v0.9a3 (yeah, I'm just catching up...) 2:17:34 AM | reply []

WIL WHEATON DOT NET: Wow, that is a gigantic Canadian flag. 1:30:01 AM | reply []

OSX, Radio and Upstreaming: How to use rsync to mirror your Radio site. I've got a sample mirror set up here. 1:04:38 AM | reply []


Looking for older (or newer) material? Click another date on the calendar at the top of this page.