TeXShop autosave

My laptop overheated today, failed to wake from sleep, and eventually shut down. I lost some work in TeXShop. If it would auto-save this wouldn’t have been a problem. I’m sure this filthy hack has numerous problems, so please feel free to tell me about them in the comments.

$ defaults write TeXShop KeepBackup YES

- (void)mySaveTimer: (NSNotification *)aNotification;

//At the end of init,
[NSTimer scheduledTimerWithTimeInterval:300.0 // 300 seconds = 5 mins

// At the end of the file
- (void)mySaveTimer: (NSNotification *)aNotification
// [GARETH] Just copy/pasted the content of -saveDocument, and replaced "sender" with "self" in this first line,
[super saveDocument: self];

// if CommandCompletion list is being saved, reload it.
if (!fileIsTex && [[self fileName] isEqualToString:
[CommandCompletionPath stringByStandardizingPath]])
[[NSApp delegate] finishCommandCompletionConfigure];

For reference,

“Configuring Run Loop Sources – Configuring Timer Sources”

“NSTimer Class Reference”



3 thoughts on “TeXShop autosave

  1. Far too complicated, this is all that’s needed,

    //Inside -init()
    [self setAutosavingDelay:300.0]; // 300 sec = 5 mins

    For reference,

    By default the file is saved with the same path, but with ” (Autosaved)” added before the file extension.
    ~/Library/Autosave Information/TeXShop.plist contains data that records which files were autosaved.
    Note also that auto-saved files are automatically restored when the application’s reopened.

    • This could probably be implemented as a “hidden” preference flag, just like keepBackupFile, but with a floating point number to specify the delay in seconds (rather than being hardcoded to 300s = 5 min as posted here.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s