It's too bad there's no obvious path forward. Maybe one will present itself eventually as we dwell here longer. Good that increased complication without clear gain has been avoided though!-matt
Is there anything a person of small dev skills like myself can do to help prove/isprove the approach is sound and beneficial?
-matt
After editing settings in the myLeoSettings.leo or any other settings outline, user should invoke a command to save settings. This command can be executed automatically on each save. This command would read settings from the outline and build settings dict as it is now done during the startup code. The result set of settings can be stored in g.app.db for the next run. During the startup settings can be retrieved from the g.app.db in one line. This would require the least changes in Leo's code. However there might be even a better scheme. Store each setting in the db table with the following columns:(name, level, filename, type, value) where primary key is (name, level, filename).Then c.config.get<type> can be changed to execute simple query from the database selecting the value at the highest level for this outline. Leo's defaults defined in leoSettings.leo should have level=0, myLeoSettings.leo - level=1 and all other outlines should have level=2.I remember an experiment to test whether accessing settings from db would slow down Leo and result was that sqlite3 database would outperform Leo's present config machinery.
After editing settings in the myLeoSettings.leo or any other settings outline, user should invoke a command to save settings. This command can be executed automatically on each save. This command would read settings from the outline and build settings dict as it is now done during the startup code. The result set of settings can be stored in g.app.db for the next run. During the startup settings can be retrieved from the g.app.db in one line.
Hang on, I've just described a cache. I don't think that is what you're pointing towards, because that wouldn't make finding and changing the setting currently of interest any easier.
Do you envision distributing the leoSettings.leo derived database with leo itself? Or do you have something else in mind? I was wondering how that first database of settings would be available at the time of leo first use.
Otherwise, as I'm conceiving of it, this scheme would then also need a mechanism to compare the saved state with the settings .leo files,
Do you envision distributing the leoSettings.leo derived database with leo itself? Or do you have something else in mind? I was wondering how that first database of settings would be available at the time of leo first use.Leo defaults contained in leoSettings.leo should be distributed in their "pre-compiled" form. For example it could be one python module containing one big tuple of tuples representing the initial content of db. On start if this db doesn't contain table settings, table will be created and populated with the default values from this python module. This action is executed only once and it takes negligible time. For new users the result would be exactly the same as if they installed Leo and run it for the first time before they created myLeoSettings.leo.
IMHO the real problem is the way Leo handles settings at the moment. I have suggested several times in the past to change this.
The way I see it is this. Leo handles settings using the very same functionality that is used to handle its primary data - outlines.
One might think it was a clever idea that saved some coding.
But if we honestly and without prejudices, look at the result of this idea, we can see that it caused numerous complications in several other parts of Leo. Initialization code is an excellent example.
But there is much more examples. One of the most extreme I can remember is that there is a call to c.endEditing very early before any gui element has any chance of being created.
By the way this call is spread throughout the code base, contaminating and entangling all Leo's modules. I am not very convinced that it is still necessary because there had been many changes since it was introduced. It would be good to look how to eliminate the need for this call. But this should go to another topic.
Let's continue with the way Leo handles settings. Let's first split this idea in two parts:
- editing settings as an ordinary outline
- loading settings from the outline
The two parts are not necessarily bound to one another. They can be changed separately without too much trouble. While I am not very interested in changing the first, the second one IMHO should be changed in order to simplify other parts of Leo, and I am pretty sure the simplifications would be significant.
If we ask users both newbies and seasoned are they satisfied with the way Leo handles settings, I guess we would find many more unsatisfied users than the satisfied ones.
I remember loosing many hours on more than one occasion while trying to solve some settings issue. I am afraid of touching any settings because of these bad memories.
QQQ
This search order offers almost too much flexibility. This can be confusing, even for power users. It’s important to choose the “simplest configuration scheme that could possibly work”. Something like:Many things are impossible or prohibited because of this. There is no way user can load and unload plugins without restart. Python is dynamic language and there should be no problem to allow this.
In almost all other editors plugins are downloaded from the internet, installed and switched on and off with the single click. Leo users can't possibly dream about such a feature mainly because of the way Leo handles its settings.
Switching the theme is impossible without restart.
What can we do about it?After editing settings in the myLeoSettings.leo or any other settings outline, user should invoke a command to save settings. This command can be executed automatically on each save. This command would read settings from the outline and build settings dict as it is now done during the startup code.
The result set of settings can be stored in g.app.db for the next run. During the startup settings can be retrieved from the g.app.db in one line. This would require the least changes in Leo's code.
However there might be even a better scheme.
Now, adjusting any setting would be as easy as executing a simple SQL command. Calling afterwards c.reloadSettings should apply new setting value immediately without any trouble.
SummaryIMHO your idea of having global settings is not bad at all.
The only thing I would change is not keeping it in an .ini file, but instead in the sqlite3 database, so we get parsing, querying, persistence for free.This idea conflicts with the way Leo handles settings now. To resolve the conflict, you should change the way Leo handles settings now and it would simplify many parts of Leo's code base.
notice how small menus and buttons become; almost invisible
I can see that your idea of using Leo's reading outline code twice both for reading outlines and for reading settings is too dear to you and you are not going to let it go.
You have pointed me to the page from the documentation that warns users about possible confusion when setting their preferences. I assure you that on more than one occasion I have spent hours trying to fix problem with my settings that was caused just by updating Leo, and I have always had only one myLeoSettings.leo.
Another example quite recent is introducing new dock layout. As you can see from the previous screenshots my preference is to have outline in the top left and log underneath, and body on the right. Recently when I updated Leo, docks were introduced and I couldn't find the way to layout the docks to look like the screenshot above. So, I had to change all my Leo launchers to add --no-dock argument.
My point is, you have many times introduced changes that required users to change their settings or to give up updating Leo.
You have argued that introducing a cache potentially can cause some confusion. Well I can agree that it is a possibility. But Leo already uses cache.
When it needs a value of some setting it doesn't read all those outlines again and doesn't parse them again to retrieve the value, but instead it retrieves the value from the cache that was built during the startup. The difference is when this cache is built.
In my idea it is built (and updated too) whenever user changes any setting, and not during the startup.
That is why if implemented my idea will help to make things easier for users and allow them to see the effect of their changes immediately and not after the next reload. It would remove a lot of confusions that Leo at the moment imposes on users.
My intention is not to impose my idea at any cost. I think this idea is a good one. It has several pros and all the cons you have pointed, I just don't see relevant.
- It will not bring any inconvenience to users,
- it will not remove any of Leo features,
- it is not introducing a new caching mechanism because cache is already there. It just changes the time when this cache is built.
The only reason to dismiss it, that I can still see, is that by accepting this idea you'd have to sacrifice one of your own, dear ideas and that is hard.
If you don't want to discuss this idea any further, I won't insist either. Let's move on to something else. But if you ever wish to discuss it again, I'll be glad.
Vitalije,Could you explain more on how using Leo's reading code for both reading outlines and reading settings is an obstacle to fixing some of your complaints (i.e. switching a theme can't be done without restarting leo)?
Your idea mentions "compiling" the settings to a simpler format at time of save. How does that help compared to "compiling" the settings to a simpler format during leo init? And isn't leo's reading of settings from outlines into some internal data structure also a form of "compiling" the settings to an alternate format? Is it that Leo's internal configuration structure doesn't match what you want or is the the reading from outlines alone which causes your complaint? Or both?
GUI code depends on settings and can't be instantiated without settings but some of the Leo reading code depends on GUI elements. That makes the initialization code very hard to understand and maintain. It is a bit like the question what comes before chicken or egg.
At the beginning of this thread Edward wrote about his idea of introducing global settings. The need for this was caused because there was an issue in the startup code. It is not clear to me what it was supposed to do: to read theme file before user settings or the other way around. But it is hard problem to solve mainly because startup code is so entangled and complex.
If, as you assert, the "user will notice nothing", then how can the new behavior possibly solve such problems?
> So I have chosen the BreezeDarkTheme for my preference and now I can't edit myLeoSettings without loosing my preferred look and feel.I don't have this problem. My copy of myLeoSettings.leo contains:@string theme-name = EKRWindowsDarkAm I correct in assuming your myLeoSettings.leo contains:@string theme-name = BreezeDarkTheme?
Another example quite recent is introducing new dock layout. As you can see from the previous screenshots my preference is to have outline in the top left and log underneath, and body on the right. Recently when I updated Leo, docks were introduced and I couldn't find the way to layout the docks to look like the screenshot above. So, I had to change all my Leo launchers to add --no-dock argument.You probably have to make the body pane the central widget:@string central-dock-widget = body
My point is, you have many times introduced changes that required users to change their settings or to give up updating Leo.Adding docks to Leo was a major change. --no-docks makes it possible to use Leo exactly as before. We spent weeks fixing bugs in the new code. You could have asked for help at any time during this process.
I'm not sure why you have such problems with your settings. It should be possible to fix them with Leo as it is.
You have argued that introducing a cache potentially can cause some confusion. Well I can agree that it is a possibility. But Leo already uses cache.Yes, Leo does use a cache. --trace=cache will show you what it contains. I've been looking at that a lot recently while I worked on the gui (global docks) branch. At present, his cache is relatively benign because:
When it needs a value of some setting it doesn't read all those outlines again and doesn't parse them again to retrieve the value, but instead it retrieves the value from the cache that was built during the startup. The difference is when this cache is built.I am not convinced that this is an improvement. See below.In my idea it is built (and updated too) whenever user changes any setting, and not during the startup.At present, the user "changes" a setting only when saving an outline (including leoSettings.leo and myLeoSettings.leo). As you imply, this does not immediately update Leo's internal settings data.
That is why if implemented my idea will help to make things easier for users and allow them to see the effect of their changes immediately and not after the next reload. It would remove a lot of confusions that Leo at the moment imposes on users.The reload-settings and reload-all-settings do (supposedly;-) update all settings data.
If settings were the only thing that mattered, then these commands should (in theory), suffice. Yes, in practice, there could be bugs.
However, settings are NOT the only things that matter. Settings, especially theme-related settings, and plugin-related settings, have side effects throughout Leo. Imo, your proposal has no chance of mitigating these side effects.
Imo, putting all of Leo's settings into the cache accomplishes virtually nothing. It will add code that must be debugged. Any discrepancy between the cache and settings in the various Leo file will lead to unbounded confusion.
The fundamental problem with this proposal is that no caching scheme can undo side effects arising Leo's myriad settings:- If reload settings doesn't work, neither will updating cached setting.
I have rejected them for the reasons stated. To summarize:- Caching settings creates the potential for serious confusion.
- I particularly want to minimize the size of the cache.
- Caching settings can not undo side effects.Leo's reload-settings command shows what is, and isn't, possible.The only way to be sure of the effects of changing a settings is to reload Leo fully.
Whoa. Edward, the strength of your reaction seems out of proportion.
Probably, but it would again require more of my time to tweak myLeoSettings.leo having to reload it all the time. I might do this, but I prefer to wait until it is stabilized.
My point is, you have many times introduced changes that required users to change their settings or to give up updating Leo.
I'm not sure why you have such problems with your settings. It should be possible to fix them with Leo as it is.I am not saying it is impossible. It just takes time and effort which I am not so eager to put into the tweaking my settings now.
If it was possible for me to change setting central-dock-widget with a menu or even through executing minibuffer command I would have tried this. If it was possible for me to change theme setting in the menu or executing minibuffer command I would have tried this.
Maybe it takes just to add two headlines to my settings file, but I am not sure. In my experience it might just turn into an hours long session of fixing some visual issues. That is the reason I rather choose not to follow this path.The real issue here is not my configuration problems. I am more concerned with the other users especially new ones.
I have just tested that reloading all settings won't change theme. You can say that is how it is supposed to work. But for me this is a bug.
If we just put aside question how Leo should handle settings for a moment. Telling user that it is impossible to change theme on the fly because it is technically impossible to achieve this is a bit awkward and false. The sizes, colors, and fonts can be easily changed and immediately visible in PyQt widgets. The fact that we, Leo developers, can't deliver that feature to the Leo users is something we should be ashamed of.
The reason why we can't deliver it lays in an inadequate way how Leo handles its own configuration.
Let's let newbies speak for themselves.
As an example, I have just opened my myLeoSettings.leo file to take a look (after more than a year of not doing so) and I've found there a node with just this:
@bool minibuffer_find_mode = False
But the node body is empty, so I don't know what that setting is about at all. So I've tried the "obvious" thing (though probably that's not what we can expect a newbie to do... so I'm probably moving away from the newbie "hat" here...): I've opened the leoSettings.leo file and did a search for "minibuffer_find_mode" to see what's this setting all about. Result: I've found nothing.
Then I've done something a newbie would (more) probably do: a search in leodeditor.com: https://leoeditor.com/search.html?q=minibuffer_find_mode&check_keywords=yes&area=default
Result: no results.
So I've "guessed" that I probably got that setting from someone else making a comment in this forum. And I've done the search: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!searchin/leo-editor/minibuffer_find_mode$20%7Csort:date
With success! There are several posts from Edward and others which include the setting, the most relevant one being this one from Edward stating that:
P.S. I recommend minibuffer-find mode for experts. Enable with @bool minibuffer_find_mode = True.
After a lot mooore digging into the issue, I've finally found within leoSettings.leo a node with header "Find/replace options" and as a child I've found a node with, guess what...:
@bool minibuffer-find-mode = False
So well: this story had a nice ending... but I would not call this a good UX for newbies (or anyone). And all the above is just for one only setting!
Yes, there's the "show-settings" command, I know that. But it shows you a long list of settings in a separate (text) pane, which for the example above happens to show that setting with yet another different "name":
[M] @bool minibufferfindmode = False
So although "in theory" the command should be "all you need to know"... I wouldn't qualify that as a nice UX.
I think there's great potential for simplifying init. code and settingsediting by using something simpler than full blown Leo outlines for thekey/value store needed for settings. Sqlite is certainly an option -if you're just using it for settings, it may not be necessary toinclude those files in VCS.
I think we are done discussing this topic.
Regarding the Leo settings "world": for a Leo newbie like me, settings in Leo are a complicated issue for sure. So it's something I try to avoid touching as much as I can... but just because the UX is really poor. Some of the problems I find:1) It's difficult to know what settings do I have "available" to tweak.As an example, I have just opened my myLeoSettings.leo file to take a look (after more than a year of not doing so) and I've found there a node with just this:@bool minibuffer_find_mode = FalseBut the node body is empty, so I don't know what that setting is about at all. So I've tried the "obvious" thing (though probably that's not what we can expect a newbie to do... so I'm probably moving away from the newbie "hat" here...): I've opened the leoSettings.leo file and did a search for "minibuffer_find_mode" to see what's this setting all about. Result: I've found nothing.