alphapapa / activities.el

Activities for Emacs (suspend and resume activities, i.e. frames/tabs and their windows, buffers)
GNU General Public License v3.0
208 stars 12 forks source link

Why persist? #6

Closed minad closed 6 months ago

minad commented 8 months ago

On 29.1 we have multisession. Would that work too?

alphapapa commented 8 months ago

No, I spent several hours trying to make it work before I filed this bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68482

minad commented 8 months ago

Thanks, I see. That's unfortunate. Hopefully this could be fixed in multisession. Or is persist better than multisession in every aspect? Would it make sense to propose replacing multisession with persist inside the Emacs core?

alphapapa commented 8 months ago

I don't know. multisession has some functionality to sync values between simultaneous sessions (without conflict resolution), which persist doesn't do. And the APIs are a bit different.

I already asked this question on emacs-devel a year or so ago, supposedly while Lars was still around, but my question was never answered. It didn't seem like anyone was interested enough to investigate or decide.

At this moment, it seems that persist is more usable, since certain values just don't work with multisession, without warning or error or explanation (i.e. a map gets saved the first time, but then doesn't get updated on disk when the value is changed). So AFAICT I couldn't recommend that anyone use multisession until that bug is fixed. If it gets fixed, I suppose it could be up to the user to use whichever API he prefers.

yrns commented 8 months ago

I read your bug report. I don't think multisession writes to storage if you update elements of a map. You have to update the root value. It seems something like "multisession-write", analogous to persist-save, would be nice for this case.

Incidentally, it looks like you are writing activities to disk once per activity with the default configuration (and once again via persist--save-all) on quit. I didn't test this, was just skimming.

alphapapa commented 8 months ago

I read your bug report. I don't think multisession writes to storage if you update elements of a map. You have to update the root value. It seems something like "multisession-write", analogous to persist-save, would be nice for this case.

Yes, IIRC I tried to do something hacky like that, e.g.:

(setf (map-elt (multisession-value activity-activities) name) activity
      (multisession-value activity-activities) (multisession-value activity-activities))

But that didn't work to force multisession to write the new value. And with an alist, I don't know if that even could be enough, because if the first cons cell didn't change... So it might be required to copy-sequence to make it write the new value. But persist "just works" here, until multisession is fixed.

Incidentally, it looks like you are writing activities to disk once per activity with the default configuration (and once again via persist--save-all) on quit. I didn't test this, was just skimming.

I think you're right. I'll fix that. Thanks.