Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

pudge
  (email not shown publicly)
http://pudge.net/
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Monday April 03, 2006
08:09 PM

Stupid Mac::Glue Tricks: BBEdit Auto-Save

[ #29204 ]

Auto-save your BBEdit documents on a per-document basis. The script will keep looping every N seconds until the file is closed (or you kill the script manually).

#!/usr/bin/perl
# bb_autosave.plx - autosave for BBEdit
# save whatever is currently frontmost document when script first executes,
# every N seconds
 
use strict;
use warnings;
 
use Mac::Glue ':all';
 
my $bbedit   = new Mac::Glue 'BBEdit';
my $front_id = $bbedit->prop(id => document => 1, window => 1)->get;
my $front    = $bbedit->obj(document => obj_form(formUniqueID, typeLongInteger, $front_id));
 
my $name = $front->prop('name')->get;
print "Auto-saving document '$name'.\n";
 
my $sec = shift || 10;
 
while ($front->get) {
    $front->save;
    sleep $sec;
}
 
print "Document closed.\n";
exit;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.