       ipc.send('check-portable-home-writable', responseChannel)
 
     checkPortableHomeWritable()
+
+  attachSaveStateListeners: ->
+    debouncedSaveState = _.debounce((=> @saveState()), @saveStateDebounceInterval)
+    @document.addEventListener('mousedown', debouncedSaveState, true)
+    @document.addEventListener('keydown', debouncedSaveState, true)
+    @disposables.add new Disposable =>
+      @document.removeEventListener('mousedown', debouncedSaveState, true)
+      @document.removeEventListener('keydown', debouncedSaveState, true)
 
   setConfigSchema: ->
     @config.setSchema null, {type: 'object', properties: _.clone(require('./config-schema'))}

    @registerDefaultViewProviders()

    @installUncaughtErrorHandler()
    @installWindowEventHandler()

    @observeAutoHideMenuBar()


_ = require 'underscore-plus'
{deprecate} = require 'grim'
{CompositeDisposable, Disposable, Emitter} = require 'event-kit'
fs = require 'fs-plus'
{mapSourcePosition} = require 'source-map-support'
Model = require './model'
