Applescript Hooks everywhere?

A quick thought: why not wrap NSUndoManager to support adding scriptable hooks to almost any user action? Surely someone can think of a good scheme to let an application programmer support really thorough scriptability without tons of extra work...

I thought of this because I'd like a way to mark a To-do item for an email reply as completed once I'd sent the email, and a good way would be with an email-send hook in Apple Mail.

Okay that's it, thanks!

Mail message to iCal Todo script

After reading Merlin Mann's suggestion to live in iCal, I thought that even though I don't use kGTD, it might be a good idea to try to limit the number of places where things I have to do exist. Following on the idea of moving lines of text from VoodooPad to iCal todos, I just wrote a script to take the frontmost email message and add a todo that reminds me to reply to it. I'm getting a little closer to just having one place I need to check tasks.

tell application "Mail"
    set l to the selection as list
    set selMesg to item 1 of l
    set cont to content of selMesg as string
    set subj to subject of selMesg as string
    set person to sender of selMesg as string
    tell application "iCal"
        set theCal to (first calendar whose title is "Email")
        set theString to "reply to " & person & " about " & subj
        make todo at end of todos of theCal with properties {priority:0, summary:theString}
    end tell
end tell

This ends up with a todo that says something like "reply to michael_mccracken@mac.com about Locations for the party of the century"

Of course, it's best invoked with a twitch and Quicksilver, so just drop it in ~/Library/Scripts so it gets indexed. I called it "NewTodoFromEmail" and Quicksilver calls it "nte". Clever.

I based it on my NewEventFromEmail script, which I still use regularly. So nice!

Voodoopad lines to iCal todos

I take notes at meetings in VoodooPad, and as such I write a lot of to-do items in MeetingNotes pages. They tend to get buried in those pages unless I do something about it fast. Sometimes I put them somewhere more useful, like on my "TodoToday" page, but that page is getting more like a "TodoSomeday" page, and isn't fit for serious action items. Today I realized that I wanted a script to take line-items from VoodooPad pages and make them into Todo items in iCal, so I can track them easier.

I already have a Quicksilver plugin for creating new todos, so I repurposed it as a python plugin for VoodooPad to add a big list all at once. Check out Gus' post on python plugins for the enabler, and then check this sucker out:

VPScriptSuperMenuTitle = "Notes"
VPScriptMenuTitle = 'Create Todos in iCal'

import os

def main(windowController, *args, **kwargs):
    tv = windowController.textView()
    s = tv.string()
    ranges = tv.selectedRanges()

    scriptString = ""
    for r in ranges:
        rs = s.substringWithRange_(r.rangeValue())

        lines = rs.split("\n")
        for line in lines:
            if len(line) < 1: continue
            scriptString += "tell application \"iCal\"\n\
            set theCal to (first calendar whose title is \"Work\")\n\
            make todo at end of todos of theCal with properties\
            {priority:0, summary:\"%s\"}\n\
            end tell\n" % line

    f = os.popen("/usr/bin/osascript", 'w')
    f.write(scriptString)
    f.close()

Want to add to it? These and many things are easily imaginable:

  • Change priority based on the first character of each line
  • handle continuation lines better
  • change calendar to select based on some simple syntax, like " foo" is a line with text "foo" but "foo bar" is a line with text "bar" destined for calendar "foo"...
  • Another idea: a line starting with the words "email" or "mail" be made into a todo with the glyph ✉, and/or an actual email in Mail.app.
  • Any other ideas?

Locations and Travel Time in Calendar apps

Now that we've got Google Maps, I'd like to see my calendar program (iCal) extended to pay more attention to the location of events. Show me how long it'll take to get to events I've scheduled, based on where they are. Traffic estimates would make this really killer (at least here in So-Cal)

It might sound like you would need to tell the app where you will be at every point of the day for this to work, but you could avoid that by storing a 'coming from' location for each event - it could be the previous event, but you could also just pick it from a list of default places, like 'Home', 'Work', and 'Hockey Rink'.

In my dream world, they'd look like error bars on a plot, they'd even have data about variability of the traffic estimates, and they'd be in the next version of iCal.

Here's a quick visual, in case I didn't describe it well enough:

Assume home is south of the office and the basketball court is north. Traffic is bad going north around 6. What it's telling you now is you can go home fast, and have 30 minutes there before you have to leave again, go straight to the court, taking 45 minutes in traffic and getting there 45 minutes early, or have about an hour at the office, wait out traffic, and get to the court on time in about 25 minutes.

Update: I changed the example to be a little clearer - I added an option to show traffic choices, showed the times by the routes, and made one event appear selected, since you probably only want this extra info for the selected event.

I also made it a basketball game because everyone knows you'd need to go home to get your gear if you were going to the rink anyway. Seriously.

UCSD nixes Google Desktop

As a Mac user, I don't have Google Desktop, but this email from UCSD's Vice Chancellor was still interesting:

SUBJECT: Google Desktop Security Exposure

Google Desktop V.3 contains certain features that raise serious security and privacy concerns. Specifically, the "share across computers" feature that introduces the ability to search content from desktop to desktop greatly increases the risk to users' privacy. If Google Desktop V.3 is set to allow "Search Across Computers" files on an indexed computer are copied to Google's servers. We recommend that individuals seriously consider the potential for information stored on their computers to be accessed by others if they enable this feature of Google Desktop V. 3 on their computers.

Employees of the University (whether student, regular staff or faculty) who have confidential data on their work or home computers should not enable this feature. There are both privacy laws and university policies that could be violated through the installation of this feature, specifically, SB 1386, HIPPA, FERPA and GLBA.

While some of the features of Google Desktop V.3 are enticing to faculty, students, and staff, it is important to understand how information is collected, stored, and shared through this application, and the potential privacy risk to individuals.

Please review and share this information widely.

Helpful References:

Google Info

UCSD Policies about Protecting Data

For a good summary of the privacy concerns related to Google Desktop V.3, see:

Electronic Frontier Foundation press release

Technical Paper from University of Michigan's IT Security group

Introducing LENS

I've just put up the website for my current project (to be part of my Ph.D. dissertation work): LENS, a framework for program information manipulation that presents a uniform interface to selective user and automated queries about many types of program metrics, including success and diagnostic information about compiler optimizations and code generation.

I'm not sure how many readers of my weblog will be interested, but there's a link to a technical report on there if you want the gory details.

Feedback and questions are very welcome - the more opportunities I get to explain what I'm doing, the better I get at it.

NewerTech Battery

I replaced my stock powerbook battery recently with a NewerTech 53.3 Watt-Hour Battery, which is higher-capacity than the Apple originals, which are 46 Watt-Hour batteries.

My old battery was so spent by the time I finally gave in that it would give about 20 minutes on a full charge before forcing sleep. The battery warning would show up after about three minutes. So I can't compare the extended capacity directly to a fresh Apple battery, but the new one has been doing fine so far. I saw at least three hours from a charge yesterday, and it's letting me work at a coffee shop without worrying about finding a plug, and that's a nice change.

Jorge Cham and "The Power of Procrastination"

Just went to see Jorge Cham's talk "The Power of Procrastination" about grad school. There were plenty of good grad-school jokes and a general feeling of relief that comes with being in a big room full of people who laugh at the same old chestnuts about how nobody ever really feels like they fit in and always feel guilty about whatever it is you spend your free time doing - you know, when you should be doing research!

If you get a chance to see his talk, go for it, even if you've read all the comics, it'll make you feel better. And if you haven't seen the comics, go read them all first, then see the talk. Now I'm going to get back to work.