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

From: Carl Sturtivant <sturtivant.att.gmail.com>
Date: Sat, 16 Jan 2016 14:11:59 -0600

Hello Robert,

Thanks for the important clues!

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.

Carl.

On Fri, Jan 15, 2016 at 3:44 PM, Robert Gieseke <rob.g.att.web.de> wrote:

> Hi Carl,
>
> Am 15/01/16 um 22:01 schrieb Carl Sturtivant:
> > OK, I understand the meaning of the code you indicated; thanks for
> > pointing out where it resides.
> >
> > Can I attach my new handler in my .textadept/init.lua file or in some
> > other file in .textadept, so I can keep my textadept installation pure?
> > Can I perhaps make .textadept/core/file_io.lua in fact, and put the code
> > to replace the handler in there?
>
> It's not advisable to overwrite stuff in core (and I don't think it's
> possible, but you can overwrite complete `modules/textadept/*.lua`
> modules in your `~/.textadept` directory -- this means however tracking
> changes and bugfixes in Textadept, so it's much better to just overwrite
> and extend what you want to change). So doing it in
> `~/.textadept/init.lua` is the way to go.
>
> > In fact how do I need to organize this? The actual coding looks simple,
> > just not these administrative matters.
>
> Yeah, and as usual there are multiple ways to do it. If your `init.lua`
> grows bigger you might want to start creating sub-modules.
>
> For a start
>
> events.connect(events.FILE_CHANGED, update_file, 1)
>
> in your `init.lua` with an `update_file` function returning true to
> prevent handling of further events is probably all you need. The
> challenge is probably not to overwrite any changes inadvertently (when
> you edit something and a change outside of Textadept occurs).
>
> Cheers,
> Robert
>
> > Thank you,
> > Carl.
> >
> >
> >
> >
> > On 1/15/2016 11:12 AM, Robert Gieseke wrote:
> >> Hi Carl,
> >>
> >> in Textadept's /core/file_io.lua, lines 290ff you can see how this
> >> currently handled.
> >>
> >> I think you could write your own events.FILE_CHANGED handler (which
> >> needs to be inserted before the current one or you remove this handler),
> >> which would just do a `io.reload_file`.
> >>
> >> Maybe some notification that the file has been updated by writing a
> >> statusbar update is also useful.
> >>
> >> Let us know if you need more details on how to write your own event
> handler.
> >>
> >> Cheers,
> >> Robert
> >>
> >>
> >> Am 15/01/16 um 16:30 schrieb Carl Sturtivant:
> >>> Hello,
> >>>
> >>> Can you point me to how to arrange that files modified outside of
> >>> Textadept while open in Textadept can be silently reloaded without the
> >>> "Reload modified file?" dialog appearing when Textadept is moved to the
> >>> foreground after such an modification?
> >>>
> >>> I write a lot of programs that write other programs, and this is a
> >>> nuisance when engaged in so doing.
> >>>
> >>> Carl.
> >>>
> >>
> >
>
> --
> You are subscribed to code.att.foicica.com.
> To change subscription settings, send an e-mail to code+help.att.foicica.com.
> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>
>

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sat 16 Jan 2016 - 15:11:59 EST

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