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

From: Arnel L. <jalespring.att.gmail.com>
Date: Sun, 17 Jan 2016 14:42:01 +0800

On Sat, 16 Jan 2016 14:11:59 -0600, Carl Sturtivant <sturtivant.att.gmail.com> wrote:
> 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.

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)

I'm not completely sure if there are any downsides to it but it does silently reload the file without the dialog.

Hope that helps.

> 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.
> >
> >

----
Thanks,
Arnel
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-- 
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 Sun 17 Jan 2016 - 01:42:01 EST

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