giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.29k stars 457 forks source link

Sync ~/.config/cherrytree/config.cfg with Recent Documents list in CT session. #2512

Open gitvectors opened 1 month ago

gitvectors commented 1 month ago

Issue withdrawn since it relates to this writer's custom workflow across a corpus of CT documents. But it is the case that list of recent documents in config.cfg only changes when CT session quits.

giuspen commented 4 weeks ago

I'm not understanding why you need the list of recent documents updated in the config.cfg while your cherrytree window is still running. Can you describe better your use case?

gitvectors commented 3 weeks ago

My "use case" is as follows. I hope it does not give you indigestion.

Desktop Ubuntu 22.04 but Windows 10 can be dual booted (rarely use windows though). Adopted CherryTree as my main “container" for multiple processes (desktop and cloud). For example if I want to communicate with a cloud service (there are many) such as Azure I place all the “context notes” in a container - *ctd. Including scripts in CodeBoxes. If I want to run a desktop workflow I create a CherryTree container for that purpose. I do not put every workflow/process into a single CherryTree container. To manage this terrain I use Recoll as my indexing engine in Ubuntu. There is a Windows version of Recoll but developer requests a small reasonable donation for this added development. I stay in Ubuntu.

I index my entire desktop (takes long time on first indexing) but thereafter daily "update index" in Recoll.

Now in Recoll I have a GUI and I search ext:ctd. This means “list all files with extension *.ctd”. More complex queries can be seen from cheat sheet which shows when hovering cursor over query field.

In recoll GUI after searching ext:ctd I see every CherryTree document in my desktop, searchable by Date, Title. Filename etc.

Current *.ctd count is 698.

If I want to search for CherryTree files containing key words I add that to the Recoll Query Language form.

When I want to launch any of the (698) detected CherryTree documents I first setup Recoll > Preferences > GUI Configuration > Choose Editor Application

And in application/xml associate that with cherrytree %f

This ensures that instead of Desktop Default (which shows raw XML) the selected file launches in CherryTree. Now I can click on any CherryTree file in Recoll and a parallel CherryTree window opens.

I look at Docky bar and right click on CherryTree icon I can see all concurrent CherryTree windows open and I can switch between these.

BUT in addition to this window switching in docky bar I would like to be in any CherryTree window and leverage File > Recent Documents to give another dimension of toggling between the stack of recent sessions I have launched from Recoll as my launchpad.

My reported “issue” is that this dynamic list is out of sync. I cannot go back to a recent document since there is a lag of last document showing in syncing (because CherryTree is never shut down). The Recent Documents list is lagging behind this agile switching model I have devised.

HOWEVER, I realise that can add this “update config.cfg” during live session as discussed below. No need to change Cherrytree.


Recently ...

I have multiple Cherrytree documents in my Ubuntu desktop as described above. Version 1.1.2.

I use Recoll to index these and it has worked very well. Indeed as I explain above in my daily workflow I have several instances of Cherytree running at any time and I can switch. I use Recoll as the launcher for CherryTree documents

But recently I note that when launching CherryTree instances the previous Preferences are not preserved and the Recent Documents list is reset to a shorter list.

I inspect /Home/.config/cherrytree/config.cfg which shows default font settings.

[fonts] rt_font=Sans 11 pt_font=Sans 11 tree_font=Sans 10 code_font=Monospace 11 vte_font=Monospace 10

I don't yet know why this reset occurs. And why it worked previously. But it occurs to me that in the same way that CherryTree creates multiple backups, we might have multiple backups of config files.

     ~config.cfg
     ~~config.cfg
     ~~~config.cfg

And an ability to cycle through these backup configurations in the active CherryTree instance.

As a workaround I shall have to write a script to emulate this backup and dynamically toggle between config.cfg snapshots.

As an added thought I will use Meld so that i can compare changes between instances.

A workaround CodeBox Python script might follow this.

Open /HOME/.config/cherrytree/

Copy ~config.cfg to ~~config.cfg Copy config.cfg to ~config.cfg Copy ~config.cfg to ~~config.cfg Copy config.cfg to ~config.cfg

Meld config.cfg and ~config.cfg Meld ~config.cfg and ~~config.cfg Meld ~_config.cfg and ~~~config.cfg

Meld .ctd and .~ctd Meld .~ctd and .~~ctd Meld .~~ctd and .~~~ctd

giuspen commented 3 weeks ago

Since the config.cfg is getting larger and larger and an attempt to save it happens also if you shutdown your OS with cherrytree still running, it would make sense to support a safe backup (rotate an already successfully parsed config file) before saving the new one and restore from the latest backup in case of failure to parse.