ENB: About session preferences

14 views
Skip to first unread message

Edward K. Ream

unread,
Jul 3, 2023, 5:52:17 AM7/3/23
to leo-editor

Thomas has convinced me not to change Leo's session-handling code significantly. I have closed #3417 and its related PR: Leo will retain its session-* commands and related documentation.


However, Leonistas disagree about when to write session data (a list outlines). Some say, "Always." Others say, "Only if the command line had no outlines."


We usually do not argue about preferences. However, a per-outline setting won't do. And I refuse to add a command-line option to resolve this minor question.


What to do? It's a puzzle.


When I awoke this morning, I saw the way forward. I'll add an Easter Egg to Leo's startup and shutdown code. A tiny new plugin, modify_sessions, will exploit the hidden code. Like this:


1: Restore the g.app.loaded_session ivar, inited (as before) to False.


2: Add the g.app.always_write_session_data ivar, inited to True.


3: Change the shutdown logic in two places:


if g.app.sessionManager and (

   g.app.loaded_session or g.app.always_write_session_data

):

     g.app.sessionManager.save_snapshot()


4: Create the modifiy_sessions plugin, containing (sans docstrings) only:


def init():

   g.app.always_write_session_data = False


Summary


Leo will retain its session-* commands and related documentation.


Leonistas disagree about when Leo should write session data. Some say, "Always." Others say, "Only if the command line had no outlines."


Neither a command-line option nor a per-outline setting can resolve this question.


I'll modify PR #3215 so that Leo always writes session data. Those who prefer otherwise can enable the modify_session plugin.


All your comments are welcome.


Edward

Edward K. Ream

unread,
Jul 3, 2023, 6:34:42 AM7/3/23
to leo-editor
On Monday, July 3, 2023 at 4:52:17 AM UTC-5 Edward K. Ream wrote:

> I'll modify PR #3215 so that Leo always writes session data.

> Those who prefer otherwise can enable the modify_session plugin.

Drat. My scheme is in ruins.

The only way to enable this plugin would be with a per-outline setting (@enabled-plugins).

And a startup script won't work either. Those scripts must always be per-outline scripts.

Edward

Edward K. Ream

unread,
Jul 3, 2023, 6:52:13 AM7/3/23
to leo-editor
On Monday, July 3, 2023 at 5:34:42 AM UTC-5 Edward K. Ream wrote:

> Drat. My scheme is in ruins. The only way to enable this plugin would be with a per-outline setting (@enabled-plugins).

I'm stuck. My plan, for now:

- Leo will always write session data. Sorry Thomas.
- A new command-line arg is out of the question.
- I'll retain the Easter Egg: the new/restored g.app ivars and associated logic.
- I'll retain the modify_sessions plugin while we debate what to do next.

Edward
Reply all
Reply to author
Forward
0 new messages