Looking at the "reload-settings" command

47 views
Skip to first unread message

Félix

unread,
Jun 7, 2022, 11:58:42 PM6/7/22
to leo-editor
I'm looking at the reload-settings command, which has the following doc string : "Reload settings for the selected outline, saving it if necessary." and i'm wondering why it tries to save all unsaved opened documents instead of only the currently active one?

I had to look at the code to understand why i was even prompted to save a file first while trying out this command...

    # Save any changes so they can be seen.
    for c2 in g.app.commanders():
        if c2.isChanged():
            c2.save()


What felt most weird, is that i got prompted to save a file for the new, untitled document that was almost empty and unrelated to the document I was working on and needed its settings to be reloaded (as I had just changed some headlines in child nodes of an @settings node)

If it is desired that it saves all unsaved files currently opened, would it make sense that it does so only for named files? therefore not interrupting the user with a save-file dialog (which btw didnt have title other than, 'save' so i didnt even know what i was saving, took me a while to understand it was some other new untitled document i happen to have in the Leo editor at the same time.) ?

--
Félix

Edward K. Ream

unread,
Jun 8, 2022, 9:11:37 AM6/8/22
to leo-editor
On Tue, Jun 7, 2022 at 10:58 PM Félix <felix...@gmail.com> wrote:
I'm looking at the reload-settings command, which has the following doc string : "Reload settings for the selected outline, saving it if necessary." and i'm wondering why it tries to save all unsaved opened documents instead of only the currently active one?

The unsaved outlines could include myLeoSettings.leo (and even leoSettings.leo), but yes, I suppose the code could just save those two (if changed) and the currently active outline.

I agree that trying to save an unnamed outline is unnecessary.

Please feel free to submit a PR :-)

Edward

tbp1...@gmail.com

unread,
Jun 8, 2022, 11:39:55 AM6/8/22
to leo-editor
Since reloading settings will not close Leo, I don't see any reason to save any files except for unsaved settings files.  Sometimes people leave unsaved files on purpose - in case they want to scrap their changes by closing an outline without saving - so let's not surprise those folks by saving their file unexpectedly.

Edward K. Ream

unread,
Jun 8, 2022, 12:16:29 PM6/8/22
to leo-editor
On Wed, Jun 8, 2022 at 10:39 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Since reloading settings will not close Leo, I don't see any reason to save any files except for unsaved settings files.  Sometimes people leave unsaved files on purpose - in case they want to scrap their changes by closing an outline without saving - so let's not surprise those folks by saving their file unexpectedly.

Does not saving a file on purpose include settings files?  Perhaps the reload-settings command shouldn't save any files!

Comments, please.

Edward

jkn

unread,
Jun 8, 2022, 1:51:47 PM6/8/22
to leo-editor
"reload settings" from where? From "settings file(s) from disk", or from "settings file(s) on disk, perhaps overridden by any held in memory"?

I would think the former. Perhaps saving files is a safety measure; I can see the command changing things underneath you in a way that might be ... surprising

J^n

Edward K. Ream

unread,
Jun 8, 2022, 2:53:42 PM6/8/22
to leo-editor
On Wed, Jun 8, 2022 at 12:51 PM jkn <jkn...@nicorp.f9.co.uk> wrote:
"reload settings" from where? From "settings file(s) from disk", or from "settings file(s) on disk, perhaps overridden by any held in memory"?

From disk, except for per-installation and per-machine settings as described here.  The per-installation and per-machine settings aren't going to change, and in any event they are last-ditch defaults.
 
I would think the former.

Yes. The point of reload-settings is to recompute all settings as necessary. There is no concept of (settings held in memory).
Perhaps saving files is a safety measure; I can see the command changing things underneath you in a way that might be ... surprising

Big sigh. What, exactly, is the least surprising option? Thomas seems to think that not saving settings files is less surprising, but I have some doubts.

I agree that reload-settings should (at most) save only myLeoSettings.leo, leoSettings.leo and the presently-selected (active) .leo file.

I'm starting to think the simplest thing that could possibly work would be to have reload-settings save no files. That gives the user the most "control". But dash it all, one could plausibly argue that it would be less surprising to "honor" the settings in all open files.

Imo, this is mostly a tempest in a teapot. I don't care much either way.

Edward

tbp1...@gmail.com

unread,
Jun 8, 2022, 4:48:44 PM6/8/22
to leo-editor
" Thomas seems to think that not saving settings files is less surprising, but I have some doubts."  No,  I think that settings files *should* be saved.  Not other files, though.  I suppose the risk is that you changed a setting in some other file and forgot to save it.  Then the new local setting won't take effect after reloading settings, which would be a surprise.

But wait, I've been assuming that settings could be reloaded from in-memory outlines. But that's not the case, is it?  They only get re-read as the outline gets opened.  In that case, I should cancel what I said: all files except an unnamed one should get saved first after all.   Or the local outline settings should get re-read from the outline as it is in memory, but that's probably too big a change.

Félix

unread,
Jun 8, 2022, 9:55:44 PM6/8/22
to leo-editor
What I intend to change in my next Leo PR for this precise issue is two-folds: 

1- prevent saving untitled changed documents, to remove surprise of being presented with a sudden 'save as' dialog. (while saving all other changed files as before, requiring no input from the user)

2- modify the doc string from  "Reload settings for the selected outline, saving it if necessary."  to something more like: "Reload settings for the selected outline, saving any modified files first." 

Félix



Edward K. Ream

unread,
Jun 9, 2022, 5:54:14 AM6/9/22
to leo-editor
On Wed, Jun 8, 2022 at 8:55 PM Félix <felix...@gmail.com> wrote:
What I intend to change in my next Leo PR for this precise issue is two-folds: 

1- prevent saving untitled changed documents, to remove surprise of being presented with a sudden 'save as' dialog. (while saving all other changed files as before, requiring no input from the user)

2- modify the doc string from  "Reload settings for the selected outline, saving it if necessary."  to something more like: "Reload settings for the selected outline, saving any modified files first." 

I agree. I was about to propose that we forget about principles such as "the simplest thing that could possibly work" or the "least surprising option" and instead do "the smallest change that could possibly work".  What you suggest is in line with my thinking.

Edward
Reply all
Reply to author
Forward
0 new messages