Re: [code] Re: disable "Reload modified file?" dialog

From: Robert Gieseke <>
Date: Sun, 17 Jan 2016 08:50:45 +0100

Am 17/01/16 um 07:42 schrieb Arnel L.:
> On Sat, 16 Jan 2016 14:11:59 -0600, Carl Sturtivant <> wrote:
>> OK, winged it as a first attempt, and in my init.lua I wrote update_file to
>> run io.reload() and return 1 followed by the line
>> events.connect(events.FILE_CHANGED, update_file, 1)
>> yet when I start Textadept afresh and test I still get the dialog I'm
>> trying to avoid. However, it's clear that the file has reloaded before the
>> dialog pops up, so update_file is being called. So it seems returning 1 is
>> not preventing further handling.
> Hi Carl,
> Would this bit help? I have this in my one of my own modules for Textadept:
> -- Force reload of file contents after 'gofmt'/'goimports' change.
> -- The reload prompt is then disabled.
> events.connect(events.FILE_CHANGED, function()
> io.reload_file()
> return true
> end, 1)

Returning "true" is the key to stop propagation, as "1" is not truthy in
Lua. ("False" would work as well[1].)

The only downside/risk is losing changes, so if your buffer is not saved
yet, these changes would be lost.
You could add other checks in your handlers, for example only
auto-reload when the buffer is not dirty, has clean version control
status (branch switching can also cause reload dialogs) ... depends on
the use case.



You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sun 17 Jan 2016 - 02:50:45 EST

This archive was generated by hypermail 2.2.0 : Sun 17 Jan 2016 - 06:47:14 EST