From fb69ecdc9b4b5c396752c3ac1ea7c5e409e950de Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 28 Sep 2016 13:07:05 -0400 Subject: [PATCH] Add 'autosave' option Closes #278 --- cmd/micro/micro.go | 17 ++++++++++++++++- cmd/micro/runtime.go | 2 +- cmd/micro/settings.go | 2 ++ cmd/micro/view.go | 8 +++++++- runtime/help/options.md | 7 +++++++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index fa46d9f2..af06d839 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -8,6 +8,7 @@ import ( "path/filepath" "runtime" "strings" + "time" "github.com/go-errors/errors" "github.com/layeh/gopher-luar" @@ -24,6 +25,7 @@ const ( synLinesDown = 75 // How many lines down to look to do syntax highlighting doubleClickThreshold = 400 // How many milliseconds to wait before a second click is not a double click undoThreshold = 500 // If two events are less than n milliseconds apart, undo both of them + autosaveTime = 8 // Number of seconds to wait before autosaving ) var ( @@ -61,7 +63,8 @@ var ( // Channel of jobs running in the background jobs chan JobFunction // Event channel - events chan tcell.Event + events chan tcell.Event + autosave chan bool ) // LoadInput determines which files should be loaded into buffers @@ -330,6 +333,7 @@ func main() { jobs = make(chan JobFunction, 100) events = make(chan tcell.Event, 100) + autosave = make(chan bool) LoadPlugins() @@ -360,6 +364,15 @@ func main() { } }() + go func() { + for { + time.Sleep(autosaveTime * time.Second) + if globalSettings["autosave"].(bool) { + autosave <- true + } + } + }() + for { // Display everything RedrawAll() @@ -372,6 +385,8 @@ func main() { // If a new job has finished while running in the background we should execute the callback f.function(f.output, f.args...) continue + case <-autosave: + CurView().Save(true) case event = <-events: } diff --git a/cmd/micro/runtime.go b/cmd/micro/runtime.go index f5c66d65..b67031cb 100644 --- a/cmd/micro/runtime.go +++ b/cmd/micro/runtime.go @@ -461,7 +461,7 @@ func runtimeHelpKeybindingsMd() (*asset, error) { return a, nil } -var _runtimeHelpOptionsMd = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x9c\x57\xdf\x8f\xdc\xb6\x11\x7e\x3e\xfe\x15\x83\x73\x80\xbb\x33\x74\xb2\x91\xfa\xa1\xd8\xb7\x43\xae\xbd\xb8\x48\xe2\x22\xbd\x87\x04\x45\x11\x52\xd2\x48\x62\x4d\x71\x54\x92\xda\xf5\x3a\x70\xff\xf6\x62\x48\x6a\xa5\xdd\x5b\x2f\x8a\xbc\x49\xfc\xf1\xcd\xf0\xe3\x37\x3f\xf8\xea\xd5\x2b\xf8\x30\x06\x4d\xd6\x0b\xf1\xa3\xae\x1d\x81\x0f\xe4\xd0\x83\x32\x06\xa8\x85\xd0\x23\x4c\x1e\x1d\xd4\x64\x5b\xdd\x4d\x4e\xf1\x62\xd0\x16\x74\xf0\x27\x83\x8d\x76\x58\x07\x72\xfb\x72\xc6\x9a\x3c\xfa\x08\x21\xbf\xf9\xe5\xf1\xe9\xb7\xef\x3e\xfc\xf4\xd7\xf7\x4f\xbf\x7d\xff\xe1\xc7\xbf\xbc\x19\x78\x81\x04\x95\xe6\xbf\x06\x04\x0f\x1e\x46\x74\x82\xd7\xfc\xf2\xf8\x04\x7e\xc4\xba\x00\xdd\xbe\x04\x94\xa0\x3d\x58\x0a\xe0\x31\x14\x20\xff\xfb\xa6\x4c\x98\xb3\x21\xed\xd9\x9b\x86\x0d\x8a\xc5\xe2\x91\xcf\xdf\xa3\x43\x50\x0e\xa3\x47\x94\x58\x81\xd0\xab\x00\x7b\x9a\xa0\x56\x96\xb1\x37\x42\xbc\x06\x59\x93\x21\xe7\xeb\x1e\x07\x94\x1b\x30\xa4\x9a\xf9\x1c\x87\xf1\x44\x64\xc3\x54\x09\x00\xf8\xe6\x36\x59\x7c\xd4\xee\xee\xcd\x6a\x99\x7f\x23\x93\x29\x59\x46\x4f\x79\xed\x73\xaf\x3d\xdb\x0a\xda\x76\xec\xb8\xec\x0c\x55\xca\x00\x59\xb3\x97\xa5\x10\x57\x0d\xb6\x6a\x32\x01\xb6\xca\x4c\xb8\x01\x99\xff\xa5\xb8\xfa\x89\x02\x26\x9f\xd9\x9d\x79\xdd\xda\x1e\xdc\xe6\xd1\x02\x3c\x19\xe5\xf4\x67\x6c\x0a\x50\xb6\x59\x7e\xef\x43\x7d\x27\xae\x98\x09\x26\xd4\x50\xad\x42\x3a\xc8\xe1\x08\x05\x54\x58\xab\xc9\x47\xae\xf6\x91\x34\x1c\x2a\x6c\x9a\xb4\x8e\x6d\xc7\xd3\x40\xa5\xad\x8a\xe4\x5e\x3d\x9f\xd0\xc3\x7c\x56\x08\x1e\x0d\xd6\x0c\xdf\x3a\x1a\xa2\xea\x78\x73\xab\x0d\xfa\x19\x49\x5c\x9d\xdc\xe6\x31\x7f\x6b\xb9\x24\xd9\xd5\xc4\xe7\xac\xf6\x87\xf3\xef\x74\xe8\x21\xf4\x0e\x51\x5c\xad\xf7\x6e\x04\xd3\x0d\xbf\xe6\xeb\x75\xa8\x1a\x18\x88\x55\x50\xd1\x14\xd2\x11\x6e\xfc\x31\x7d\xd9\xa9\x2c\x01\x09\x3d\x9a\x11\x02\x8d\xba\x8e\x58\xb7\x32\x0e\xe4\xd9\xbb\x72\x91\x4b\x4d\x66\x1a\xac\xdc\xb0\x7c\x03\xdf\xf0\x22\x58\x08\x04\x6f\x0b\xd0\xec\xa9\x31\xd0\x68\x3f\x1a\xb5\x07\x05\x69\x0f\xe4\xeb\x64\xf5\xeb\x56\x63\xc3\x96\xd2\x54\x99\xc4\x92\xd4\xdd\x4e\x86\xc1\x59\xad\x3b\x65\xc3\xbc\xfb\xcf\x6f\x19\xbf\x42\xe8\x75\xd7\x1b\xdd\xf5\x4c\x77\xc4\x52\x06\x5a\x72\x80\x9f\xd4\x30\x1a\x3c\xa7\xac\xb7\x32\x1e\x20\xa8\xca\xeb\xcf\xac\x75\x8f\x21\x49\x3d\xa8\x0a\x78\x8c\xb1\x67\x09\x9f\x01\x78\x97\x00\xb4\x6d\xd0\x86\xba\x57\x6e\x8d\x91\x46\x53\xd0\xf3\x9c\xaa\x03\xba\x33\x20\x30\x83\xb4\x54\x45\x04\xb4\xaa\x32\x39\xb7\x18\x6d\x71\x66\xa8\xa2\x10\x68\x98\x13\x17\x36\x3a\x90\x83\x5d\xcf\x81\x3d\xa0\xf7\xaa\xe3\xcc\xe6\x10\x46\xa7\x6d\xc0\xa6\x3c\x44\x5b\x3a\xc0\xff\x15\x6c\xf1\x9c\xaf\x41\xb2\x46\xc3\x7e\x3c\x22\x65\x1e\x8b\xb4\xc6\x84\x30\x39\x87\x36\x40\x35\xb5\x2d\xba\xf2\x65\x68\x73\x74\x65\x63\x49\x8c\x27\xe6\xa2\x52\xa2\x2a\x2a\x04\x35\x05\x1a\x54\xd0\xb5\x32\x66\x1f\x85\xd3\xe0\x88\xb6\x61\x30\xb2\x07\x0f\xa2\x02\x7a\xb5\xe5\x2c\x86\x36\x51\xd7\x59\x72\x58\x2b\xcf\xee\x8e\xe8\x5a\x72\x03\xf0\xef\xbd\xb6\x1e\xad\xd7\x41\x6f\x39\x18\x95\xab\x7b\xf4\xe7\x4e\xdd\xb6\xe9\xd8\x7e\x6f\x83\xfa\x24\x37\x10\x26\x67\x3d\xa4\x5f\xb6\x4e\x0e\xa8\x6d\x2f\x10\xc6\x22\x0a\xe4\x47\x55\xa3\x97\x1b\x16\x2c\xa4\x1f\xd0\xd6\x07\x8e\x3d\xbe\x37\x55\x5d\x34\xcf\x14\x24\xd9\xc8\x0d\xdf\xac\x85\xda\xa1\x8a\x74\x2a\xb0\xb8\x4b\x72\xc8\x99\x09\xbc\x1a\x8e\x55\x96\xeb\x0d\x33\x3d\x3a\xdc\x6a\x9a\x7c\xdc\x71\xc1\xed\x7a\x72\x9e\x1c\x2f\x92\x9b\x25\x84\x16\xe9\x1d\xb2\x6d\x5a\xc8\xb7\x9a\x2a\xa4\x82\x46\xf3\xad\xa3\xcd\x19\x98\xad\xde\x1e\xca\x04\x2f\x6c\xb0\xd5\x16\x1b\xce\x55\xa7\xe5\x83\xef\x90\xa5\x3a\x79\x6d\xbb\xbb\x0b\xfe\xb9\xc9\x20\xc7\xc4\x9c\x35\xa2\x53\x76\x1a\x2a\x74\x67\x99\xcc\xdb\x7c\x50\x61\xf2\xf9\x58\xf3\xde\xc8\x59\x9c\xb8\x10\x56\xbe\x76\xc8\xb2\xfa\x3a\xb4\xda\x62\x22\x43\x6e\xc0\xe1\xc0\xa5\x61\x0e\xc3\x15\x51\x3b\xe5\xc1\x28\x1f\x20\xe8\x01\x17\xf1\xf2\x30\xeb\x96\x8b\xb5\x8d\xa9\x6e\x9c\x02\xe7\xc6\x10\x01\xe2\x9d\x33\x39\xbc\x66\xd9\xa5\x3a\xa5\xcf\xfa\x74\xd0\xad\xda\xe2\x64\x1b\x9a\x65\x13\x8e\xc3\x9e\x6c\x01\x3c\xcd\xdf\xbc\xb4\x01\xdc\xa2\x05\xd5\x06\x74\xa9\xfe\x1b\xf2\x08\x2a\x5a\x63\xa7\x3c\xcd\xb9\x36\xcf\xd8\x06\x1c\x46\xa7\xd2\xa2\xe2\xd0\x36\x7c\x44\x1c\x23\xb8\xb6\xdd\x45\x17\x6b\x47\xc6\x0c\xca\x75\x9a\xeb\x84\x1a\x68\xb2\x81\x59\xe7\xbb\xf0\x29\xaf\xd3\x64\x1a\x30\xfa\x63\xcc\xbb\x1e\x63\xa9\xda\x26\xeb\x15\x1a\xda\xad\x08\x3e\x63\xea\x4f\x6b\x43\x7e\x44\x6c\xce\xd8\x61\xe0\xb8\x20\x66\x31\xb2\x38\xff\x32\x23\xe1\x0c\xea\xb7\x52\x88\xfb\xfb\x7b\x21\x1e\xf3\xc4\x68\xa6\x4e\xdb\xb9\x87\x4a\x2d\x93\xe1\x8c\xcb\x82\xe0\x0f\x30\xca\x76\x53\x4c\xc7\x64\x23\xdf\x70\xeb\xa7\x71\x24\xc7\xb5\x69\x99\xe4\x00\xf8\xae\x80\xc7\x02\x9e\xa8\x80\xbf\xa9\xad\x2a\x98\x7b\xfe\xf0\xb5\xd3\x63\x28\xe0\x87\x49\xdd\x95\xf0\x77\x47\x5b\xdd\x2c\x91\x34\x9b\xcb\xae\x5c\xca\xe3\x9c\x51\xe2\x15\xca\x0d\x3c\x1c\x25\xd8\x74\xb1\xf2\xf7\x2f\x12\xe4\xed\x9d\x04\xf9\xcf\x7f\x49\x90\xd7\xd7\x12\xe4\xcd\x8d\x3c\x63\x74\x81\xca\x76\x2f\x98\xed\x48\x0f\x7c\x5e\x4e\x85\x3f\x4f\x16\x0e\xff\x33\x23\x67\xf0\x3b\xba\x78\xa0\x59\x47\x1d\xb5\x43\x38\xc0\xb6\x43\xf8\xe3\x90\xec\xec\x83\xdd\xcf\x81\xc2\x12\xe4\xb2\x93\x9b\xa0\xb9\xc0\xe6\xf2\x94\xe2\x26\xd0\x12\x95\xe2\xb4\x73\xcb\xa5\xcf\x97\xff\xf6\xec\x13\x15\x0c\x85\x6d\x8b\x75\x88\xf1\x72\xfa\xd0\x48\x19\x21\xe3\x8b\x98\xea\xb9\x57\xa4\x18\x93\x25\xbc\x8f\x11\x78\xb3\x44\x44\x50\x1f\xf1\x1c\x4e\xec\x00\xd9\xfb\x40\xa0\x2c\x71\x2a\x11\x83\xaa\x7b\x6d\xb1\x00\xaf\x87\x91\xaf\x9b\xc6\x9c\x01\x8f\x9c\xcc\xe7\x89\x7b\x20\xef\x29\x85\x78\x05\x4f\xa9\x51\xe0\xd0\x4b\x55\x7c\xde\x27\xc4\xaf\xcb\x83\x81\x37\xfb\x05\x13\x50\x47\xa0\xd4\x65\x98\x3d\x97\xcd\xb8\xdb\xec\x4b\xf8\x21\x7d\xc0\x80\x6a\x7e\x7a\xac\xfc\x11\x3b\xb2\x37\xe1\x88\xe8\xd3\x77\xce\x31\xbf\x32\xfa\x16\x61\xe6\xd6\x92\x1b\x8d\xd4\x76\xf3\x25\x8a\x73\x2d\xca\x3f\x72\x77\xa2\xe6\x00\x5e\x7c\xd5\x7e\xfd\xac\x48\xaf\x86\x08\x9b\xcf\x99\x37\x08\x2e\x7e\x7c\x65\x11\xd1\x97\x42\x3c\x2f\x1d\x73\x7a\x34\xad\x32\xef\xaa\xdf\x2a\xb2\xc3\xb8\xea\xae\x56\x2b\x97\x5e\xa9\x84\x67\x12\x6c\x74\x71\x32\x93\x58\xc4\xda\x2f\x3d\x86\x38\x20\xd7\xbd\x05\x8f\x72\x4b\xf7\x3e\xb7\xf0\x27\x64\x1d\x5a\x27\xbe\x39\x65\x3c\xc5\xc2\xc3\x56\xe6\xc7\x60\xb6\xc1\xc1\x93\x7a\xf1\x7d\xea\x3b\xf8\x08\x65\x7a\x3f\x6a\xcf\x3e\xe5\x8e\x1a\x76\xbd\xae\x7b\xe8\x95\x3f\xe9\x7e\x38\x20\x59\xc4\xcc\x52\x7a\xeb\xe0\xa7\x1a\xc7\x00\x4f\x94\xfe\x23\x13\xe2\xd0\x77\xc3\xbb\xf3\xcb\x7f\x9e\xaa\x7d\x1a\xd9\x08\x21\xa5\xe4\x83\x88\xdf\x63\x1f\x79\xfd\xba\xec\xe8\x7a\x03\xe9\x2f\x8e\xac\x5d\xb8\xde\x40\xab\x8c\x8f\xa5\x0c\xbe\x14\xf3\x16\x57\xbd\xdc\xa2\x3f\xe3\xf5\x06\xbe\x3d\x5a\x79\x02\x15\xdc\x84\xab\x99\xb4\xe3\x9d\xf8\xc2\x3e\x09\xf1\xe0\x57\x2f\x68\x64\x2d\x6a\x0f\xff\x99\x74\x40\x40\xe5\xf7\xa9\x92\xbd\x64\x39\x76\x3e\x5f\xbd\xa9\x52\xfc\x2f\x00\x00\xff\xff\x54\x37\x83\x5a\xbd\x10\x00\x00") +var _runtimeHelpOptionsMd = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x9c\x58\x5b\x8f\xdc\xb6\x15\x7e\x5e\xfe\x8a\x83\x75\x80\xdd\x35\xb4\xb2\x91\xfa\x21\x98\x37\x37\xdb\x6e\x5c\x24\x71\x91\xfa\x21\x41\x51\x84\x47\xd2\x91\xc4\x2e\x45\xaa\x24\x35\xb3\xe3\xc0\xfd\xed\xc5\x21\xa9\x91\x66\x76\x32\x28\xf2\x36\xe2\xe5\x3b\xb7\xef\x5c\x38\xaf\x5e\xbd\x82\x8f\x63\x50\xd6\x78\x21\x7e\x50\xb5\xb3\xe0\x83\x75\xe4\x01\xb5\x06\xdb\x42\xe8\x09\x26\x4f\x0e\x6a\x6b\x5a\xd5\x4d\x0e\xf9\x30\x28\x03\x2a\xf8\x93\xc5\x46\x39\xaa\x83\x75\xfb\x72\xc6\x9a\x3c\xf9\x08\x21\xbf\xfa\xf9\xe1\xf1\xd7\x6f\x3f\xfe\xf8\xd7\x0f\x8f\xbf\x7e\xf7\xf1\x87\xbf\xbc\x19\xf8\x80\x04\x4c\xfb\xbf\x07\x04\xef\x3d\x8c\xe4\x04\x9f\xf9\xf9\xe1\x11\xfc\x48\x75\x01\xaa\x7d\x09\x28\x41\x79\x30\x36\x80\xa7\x50\x80\xfc\xef\x9b\x32\x61\xce\x82\x94\x67\x6d\x1a\x16\x28\x16\x89\x47\x3a\x7f\x47\x8e\x00\x1d\x45\x8d\x6c\xf2\x0a\x84\x1e\x03\xec\xed\x04\x35\x1a\xc6\xde\x08\xf1\x1a\x64\x6d\xb5\x75\xbe\xee\x69\x20\xb9\x01\x6d\xb1\x99\xed\x38\xac\x27\x47\x36\xec\x2a\x01\x00\x5f\xdd\x26\x89\x0f\xca\xdd\xbd\x59\x1d\xf3\x6f\x64\x12\x25\xcb\xa8\x29\x9f\xfd\xd4\x2b\xcf\xb2\x82\x32\x1d\x2b\x2e\x3b\x6d\x2b\xd4\x60\x8d\xde\xcb\x52\x88\xab\x86\x5a\x9c\x74\x80\x2d\xea\x89\x36\x20\xf3\xb7\x14\x57\x3f\xda\x40\x49\x67\x56\x67\x3e\xb7\x96\x07\xb7\x79\xb5\x00\x6f\x35\x3a\xf5\x99\x9a\x02\xd0\x34\xcb\xe7\x7d\xa8\xef\xc4\x15\x7b\x82\x1d\xaa\x6d\x8d\x21\x19\x72\x30\xa1\x80\x8a\x6a\x9c\x7c\xf4\xd5\x3e\x3a\x8d\x86\x8a\x9a\x26\x9d\x63\xd9\xd1\x1a\xa8\x94\xc1\xe8\xdc\xab\x4f\x27\xee\x61\x7f\x56\x04\x9e\x34\xd5\x0c\xdf\x3a\x3b\x44\xd6\xf1\xe5\x56\x69\xf2\x33\x92\xb8\x3a\x89\xe6\xb1\xff\xd6\x74\x49\xb4\xab\x2d\xdb\x59\xed\x0f\xf6\xef\x54\xe8\x21\xf4\x8e\x48\x5c\xad\xef\x6e\x04\xbb\x1b\x7e\xc9\xe1\x75\x84\x0d\x0c\x96\x59\x50\xd9\x29\x24\x13\x6e\xfc\xb1\xfb\xb2\x52\x99\x02\x12\x7a\xd2\x23\x04\x3b\xaa\x3a\x62\xdd\xca\xb8\x90\x77\xef\xca\x85\x2e\xb5\xd5\xd3\x60\xe4\x86\xe9\x1b\x38\xc2\x0b\x61\x21\x58\x78\x5b\x80\x62\x4d\xb5\x86\x46\xf9\x51\xe3\x1e\x10\xd2\x1d\xc8\xe1\x64\xf6\xab\x56\x51\xc3\x92\xd2\x56\x99\xc8\x92\xd8\xdd\x4e\x9a\xc1\x99\xad\x3b\x34\x61\xbe\xfd\xcd\x5b\xc6\xaf\x08\x7a\xd5\xf5\x5a\x75\x3d\xbb\x3b\x62\xa1\x86\xd6\x3a\xa0\x67\x1c\x46\x4d\xe7\x98\xf5\x56\x46\x03\x02\x56\x5e\x7d\x66\xae\x7b\x0a\x89\xea\x01\x2b\xe0\x35\xc6\x9e\x29\x7c\x06\xe0\x5d\x02\x50\xa6\x21\x13\xea\x1e\xdd\x1a\x23\xad\xa6\xa4\xe7\x3d\xac\x03\xb9\x33\x20\x30\x83\xb4\xb6\x8a\x08\x64\xb0\xd2\xb9\xb6\x68\x65\x68\xf6\x50\x65\x43\xb0\xc3\x5c\xb8\xa8\x51\xc1\x3a\xd8\xf5\x9c\xd8\x03\x79\x8f\x1d\x57\x36\x47\x30\x3a\x65\x02\x35\xe5\x21\xdb\x92\x01\xff\x57\xb2\x45\x3b\x5f\x83\x64\x8e\x86\xfd\x78\xe4\x94\x79\x2d\xba\x35\x16\x84\xc9\x39\x32\x01\xaa\xa9\x6d\xc9\x95\x2f\x53\x9b\xb3\x2b\x0b\x4b\x64\x3c\x11\x17\x99\x12\x59\x51\x11\xe0\x14\xec\x80\x41\xd5\xa8\xf5\x3e\x12\xa7\xa1\x91\x4c\xc3\x60\xd6\x1c\x34\x88\x0c\xe8\x71\xcb\x55\x8c\x4c\x72\x5d\x67\xac\xa3\x1a\x3d\xab\x3b\x92\x6b\xad\x1b\x80\x3f\xef\x95\xf1\x64\xbc\x0a\x6a\xcb\xc9\x88\xae\xee\xc9\x9f\xb3\xba\x6d\x93\xd9\x7e\x6f\x02\x3e\xcb\x0d\x84\xc9\x19\x0f\xe9\x93\xa5\x5b\x07\xb6\x6d\x2f\x38\x8c\x49\x14\xac\x1f\xb1\x26\x2f\x37\x4c\x58\x48\x1f\xa0\x8c\x0f\x9c\x7b\x1c\x37\xac\x2e\x8a\x67\x17\x24\xda\xc8\x0d\x47\xd6\x40\xed\x08\xa3\x3b\x11\x0c\xed\x12\x1d\x72\x65\x02\x8f\xc3\x31\xcb\x72\xbf\x61\x4f\x8f\x8e\xb6\xca\x4e\x3e\xde\xb8\xa0\x76\x3d\x39\x6f\x1d\x1f\x92\x9b\x25\x85\x16\xea\x1d\xaa\x6d\x3a\xc8\x51\x4d\x1d\x12\xa1\x51\x1c\x75\x32\xb9\x02\xb3\xd4\xdb\x43\x9b\xe0\x83\x0d\xb5\xca\x50\xc3\xb5\xea\xb4\x7d\x70\x0c\x99\xaa\x93\x57\xa6\xbb\xbb\xa0\x9f\x9b\x34\x71\x4e\xcc\x55\x23\x2a\x65\xa6\xa1\x22\x77\xd6\x93\xf9\x9a\x0f\x18\x26\x9f\xcd\x9a\xef\x46\x9f\xc5\x8d\x0b\x69\xe5\x6b\x47\x4c\xab\xdf\x87\xc6\x2d\x25\x67\xc8\x0d\x38\x1a\xb8\x35\xcc\x69\xb8\x72\xd4\x0e\x3d\x68\xf4\x01\x82\x1a\x68\x21\x2f\x2f\x33\x6f\xb9\x59\x9b\x58\xea\xc6\x29\x70\x6d\x0c\x11\x20\xc6\x9c\x9d\xc3\x67\x96\x5b\xd8\xa1\x3a\xab\xd3\x81\xb7\xb8\xa5\xc9\x34\x76\xa6\x4d\x38\x4e\x7b\x6b\x0a\xe0\x6d\xfe\xcd\x47\x1b\xa0\x2d\x19\xc0\x36\x90\x4b\xfd\x5f\x5b\x4f\x80\x51\x1a\x2b\xe5\xed\x5c\x6b\xf3\x8e\x69\xc0\x51\x54\x2a\x1d\x2a\x0e\x63\xc3\x13\xd1\x18\xc1\x95\xe9\x2e\xaa\x58\x3b\xab\xf5\x80\xae\x53\xdc\x27\x70\xb0\x93\x09\xec\x75\x8e\x85\x4f\x75\xdd\x4e\xba\x01\xad\x9e\x62\xdd\xf5\x14\x5b\xd5\x36\x49\xaf\x48\xdb\xdd\xca\xc1\x67\x44\xfd\x69\x2d\xc8\x8f\x44\xcd\x19\x39\x0c\x1c\x0f\xc4\x2a\x66\x0d\xcd\x9f\xec\x91\x70\x06\xf5\xeb\x25\x35\xd9\x75\x72\x93\x9b\x7f\x2c\x5b\xbc\x92\x48\x14\x4b\x20\x83\xb8\x3d\x7c\x03\x9e\x6a\x6b\x1a\x7f\x5c\xd3\xb8\x20\xa7\x1e\x8e\xda\x67\x80\x93\xa2\x87\xd9\xda\xff\x4c\xdc\x2e\x67\x32\xd0\xb3\x4a\x6d\x9e\xfb\x36\xfa\x27\x65\x3a\xc6\xfa\x33\xcf\x19\x2e\x36\xc6\x78\x34\x26\x53\x0a\x7d\x4b\x18\x26\x47\xcb\x24\xc3\x30\x43\x4c\x6d\xac\x6b\x15\x4b\xc6\x22\x30\x45\x54\x00\xd8\x2d\xb9\x9d\x53\xb1\xe0\xec\x38\xf3\x77\xa9\xa4\x38\x82\x8a\x5a\xeb\xce\x76\xd1\x14\xe1\xfb\xfb\x7b\x21\x1e\xf2\xd6\xa8\xa7\x4e\x99\x79\xcc\x4c\x53\xa5\xe6\xa6\xc4\x39\xc3\x3f\x40\xa3\xe9\xa6\xd8\xb1\xac\x49\x5a\xdc\xfa\x69\x1c\xad\xe3\xf6\xbd\x6c\x72\x8d\xf8\xb6\x80\x87\x02\x1e\x6d\x01\x7f\xc3\x2d\xb2\x9a\xf1\x87\xaf\x9d\x1a\x43\x01\xdf\x4f\x78\x57\xc2\xdf\x9d\xdd\xaa\x66\x29\x36\xb3\xb8\xac\xca\xa5\x56\xc7\x21\x88\x2c\x97\x1b\x78\x7f\x14\x8e\xc4\x7d\xf9\xdb\x17\x09\xf2\xf6\x4e\x82\xfc\xe7\xbf\x24\xc8\xeb\x6b\x09\xf2\xe6\x46\x9e\x11\xba\x40\x65\xb9\x17\xc4\x76\x56\x0d\x6c\x2f\x77\x8b\x9f\x26\x03\x87\xef\xd9\x23\x67\xf0\x3b\x7b\xd1\xa0\x39\xd5\x3a\xdb\x0e\xe1\x00\xdb\x0e\xe1\x8f\x43\xb2\xb2\xef\xcd\x7e\xae\x25\x4c\x23\xee\xcc\x79\x4e\x9c\x67\x90\xdc\xc1\x53\x69\x09\x76\x29\x5c\xe2\x74\xb8\xcd\xd3\x81\x2f\xff\xed\x59\x27\x5b\x30\x14\xb5\x2d\xd5\x21\x96\x94\xd3\xb7\x58\x2a\x9a\x19\x5f\xc4\x6e\xc8\xe3\xb4\x8d\x65\xab\x84\x0f\xb1\x48\xdd\x2c\x45\x23\xe0\x13\x9d\xc3\x89\x43\x32\x6b\x1f\x2c\xa0\xb1\xcc\x69\x31\x60\xdd\x2b\x43\x05\x78\x35\x8c\x1c\x6e\x3b\xe6\x26\x71\xa4\x64\xb6\x27\xde\x81\x7c\xa7\x14\xe2\x15\x3c\xa6\x59\x8a\xf3\x35\x0d\x3a\xf3\x3d\x21\x7e\x59\xde\x54\x7c\xd9\x2f\x98\x40\x2a\x02\xa5\x41\x4c\xef\x79\xb2\x88\xb7\xf5\xbe\x84\xef\xd3\x0f\x18\x08\xe7\xd7\xd9\x4a\x1f\xb1\xb3\xe6\x26\x1c\x39\xfa\xf4\x29\x78\xec\x5f\x19\x75\x8b\x30\xf3\xf4\xcd\xb3\x58\x7a\x99\x70\x10\xc5\xb9\x29\xee\x1f\x79\x80\xc3\x39\x81\x17\x5d\x95\x5f\xbf\xbc\xd2\xc3\x2a\xd5\xc1\x64\x67\xbe\x20\x78\x3e\xe0\x90\x45\x44\x5f\x0a\xf1\x69\x79\x54\xa4\x77\xe5\xaa\x39\xad\x46\xd2\x22\x2b\x4c\xab\x01\x74\x75\x72\x19\x27\x4b\xf8\x64\x05\x0b\x5d\x94\xcc\x4e\x2c\xe2\x78\x24\x3d\x85\xb8\x20\xd7\xe3\x17\xaf\xf2\xd4\xfb\x21\xbf\x72\x4e\x9c\x75\x98\x2e\x39\x72\xb1\x44\x73\x6f\x66\x29\xf3\x7b\x39\xcb\xe0\xe4\x49\xcf\x95\x7d\x1a\xcd\xd8\x84\x32\x3d\xb1\x95\x67\x9d\xf2\xa3\x03\x76\xbd\xaa\x7b\xe8\xd1\x9f\x0c\x88\x9c\x90\x4c\x62\xf6\x52\x7a\x0e\xd2\x73\x4d\x63\x80\x47\x9b\xbe\xa3\x27\xc4\xe1\x69\x02\xef\xce\x1f\xff\x69\xaa\xf6\x69\x65\x23\x84\x94\x92\x0d\x11\xbf\xc5\x51\xfb\xfa\x75\xd9\xd9\xeb\x0d\xa4\xaf\xb8\xb2\x56\xe1\x7a\x03\x2d\x6a\x1f\xbb\x3d\x7c\x29\xe6\x2b\xae\x7a\x79\x45\x7d\xa6\xeb\x0d\x7c\x7d\x74\xf2\x04\x2a\xb8\x89\x56\x3b\xe9\xc6\x3b\xf1\x85\x75\x12\xe2\xbd\x5f\xfd\xc9\x40\xcc\x45\xe5\x63\x8b\x23\x20\xf4\xfb\xd4\xec\x5f\x7a\x79\xee\x67\xe7\x23\x55\x8a\xff\x05\x00\x00\xff\xff\x1b\x69\x47\x74\xe0\x11\x00\x00") func runtimeHelpOptionsMdBytes() ([]byte, error) { return bindataRead( diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 518f91cf..9f95d177 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -176,6 +176,7 @@ func GetOption(name string) interface{} { func DefaultGlobalSettings() map[string]interface{} { return map[string]interface{}{ "autoindent": true, + "autosave": false, "colorcolumn": float64(0), "colorscheme": "zenburn", "cursorline": true, @@ -199,6 +200,7 @@ func DefaultGlobalSettings() map[string]interface{} { func DefaultLocalSettings() map[string]interface{} { return map[string]interface{}{ "autoindent": true, + "autosave": false, "colorcolumn": float64(0), "cursorline": true, "filetype": "Unknown", diff --git a/cmd/micro/view.go b/cmd/micro/view.go index dd01204e..2ab29ad6 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -194,7 +194,13 @@ func (v *View) ScrollDown(n int) { // causing them to lose the unsaved changes func (v *View) CanClose() bool { if v.Type == vtDefault && v.Buf.IsModified { - char, canceled := messenger.LetterPrompt("Save changes to "+v.Buf.Name+" before closing? (y,n,esc) ", 'y', 'n') + var char rune + var canceled bool + if v.Buf.Settings["autosave"].(bool) { + char = 'y' + } else { + char, canceled = messenger.LetterPrompt("Save changes to "+v.Buf.Name+" before closing? (y,n,esc) ", 'y', 'n') + } if !canceled { if char == 'y' { v.Save(true) diff --git a/runtime/help/options.md b/runtime/help/options.md index db91fd04..7acaba87 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -93,6 +93,13 @@ Here are the options that you can set: default value: `2` +* `autosave`: micro will save the buffer every 8 seconds automatically. + Micro also will automatically save and quit when you exit without asking. + Be careful when using this feature, because you might accidentally save a file, + overwriting what was there before. + + default value: `off` + --- Default plugin options: