Show Ticket

Duplicates of this ticket: C767B8EF

Status: closed, reported by adam.q.salter on 2008-05-16 (other)

Unable save document using Applescript

Following is a ruby script which should strip document of whitespace and save document.
I've been fiddling/mucking around with it for quite some time and come to the conclusion that it is failing because TextMate is mishandling Applescript 'tell document to save in alias' commands.

Note: requires 'rb-appscript' gem

#!/usr/bin/env ruby -rjcode -KU

require 'rubygems'
require 'appscript'
class TextMate
  include Appscript
  def self.save_current
    doc = Application.by_name('TextMate').documents[0]
    if doc.modified.get
      doc_alias = MacTypes::Alias.path(doc.path.get) => doc_alias)

doc_text =
puts doc_text.gsub(/[\t ]+$/, '')

Note added by Allan Odgaard on 2008-05-16 19:05:29

Sorry, but current version of TextMate does not support AppleScript beyond _very_ few commands.