Geany: automatically 'Reload the current file from disk' upon external modificati颅on

Created on 9 Jul 2014  路  12Comments  路  Source: geany/geany

Currently Geany will pop-up a dialogue:
"The file 'gWidgets2-filter.R' on the disk is more recent than
the current buffer.

Do you want to reload it?"

when the same file has been modified externally. When working on a file using two different editors at the same time (and saving frequently; e.g. see http://wiki.geany.org/howtos/using_geany_with_r#combining_geany_with_rstudio ), the workflow would be nicer if the file were automatically reloaded from disk upon external modification.

Please add a hidden option that would disable the confirmation dialogue when 'Reloading the current file from disk' upon external modification.

enhancement preference

Most helpful comment

The original Issue is somewhat invalidated now that document messages are shown in a non-modal infobar. If the focus is setup correctly, it should be a matter of tabbing to a document and pressing Enter (or the mnemonic, or Ctrl + R).

Perhaps it would be more appropriate to add a "Reload All" command instead?

All 12 comments

If I recall correctly, in SublimeText it will automatically reload unless there are unsaved changes, in which case it pops up a dialog. It seems like a reasonable thing to do, even enough for a first class preference maybe (as opposed to hidden/various pref).

Yes, another example of IDE that behaves like this is RStudio: it will automatically reload unless there are unsaved changes. When there _are_ unsaved changes, it does pop-up the following dialogue:
"The file gWidgets2-filter.R has changed on disk. Do you want to reload the file from disk and discard your unsaved changes?"

This feature should be trivial to add

Is there any activity on this? I was about to create a new issue for this when I saw this 1 year old thread.
Use case: git rebase touches many files that I would like to be reloaded automatically.)

Git checkout also causes this for many files, at least for the branches I work with.

@BenWiederhake it doesn't appear that anyone has needed or wanted it enough to make a pull request.

Hmm, that doesn't look as trivial as I hoped for. Here are some observations:

  • The best position would probably be right below the "Disk check timeout" option, probably named "Automatic reload".
  • That GUI element is defined in data/geany.glade:4596, so for a new property, this file would need to be touched. HACKING seems to recommend Glade 3.8.5, so I'll go with that.
  • The correlation to internal keys seems to be done in src/keyfile.c:222, so for a new property, this file would need to be touched.
  • When a file is deemed reload-necessary, monitor_reload_file in src/document.c:3606 seems to be called to trigger the notification. So for the new property, this function would need to be touched.
  • Apparently, this uses the "new 'simple' prefs", as src/prefs.c puts it, so this file would need no changes.

Does this so far sound like a good idea? I'm new to the project, so I'd like to hear feedback whether a PR changing these places would have hopes of being accepted.

The original Issue is somewhat invalidated now that document messages are shown in a non-modal infobar. If the focus is setup correctly, it should be a matter of tabbing to a document and pressing Enter (or the mnemonic, or Ctrl + R).

Perhaps it would be more appropriate to add a "Reload All" command instead?

There was an attempt at "reload all" in #54.

My PR https://github.com/geany/geany/pull/1246 for this issue is looking for suitably qualified testers.
Details here in paragraph 2 & 3: https://github.com/geany/geany/pull/1246#issuecomment-290047712

HI shiftee,
I made a different version of 'reload all' feature than you. You can show it and try it from the #1471 pull request.
My plan was an icon on toolbar and a command in the file menu with shortcut key. If many files has opened and must reload them, just click on the icon or press Alt+r, and voila!
cheers

There is now an option to autoreload files which change on disk if they have no changes in the buffer, #1246 should close this unless I misunderstand.

Was this page helpful?
0 / 5 - 0 ratings