countvajhula / mindstream

Start writing (or coding), stay focused, don't worry.
Other
31 stars 3 forks source link

always creating a new anonymous session #26

Closed dasoju closed 2 months ago

dasoju commented 3 months ago

Hi I am using mindstream-enter-anonymous-session from an org-mode buffer everytime i use the command it creates a new anonymous session

I thought it was supposed to use an existing session

following are the sessions i see in anon directory, i tried 5 times and it created 5 new directories 2024-06-20-0c792b136c4874da7b9ef2060e21a13af05ccf4c 2024-06-20-d3cc9a363c1e98afab4118e8ae6eabe9fb87e90f 2024-06-20-dddb260d3c66c5431e841c30691c7ca9b6bc2e3c 2024-06-20-18c1c26ae3d40fdb50127cd338bd0c093cab6234 2024-06-20-d96113261253fb3f30e03abb36aaf7ef8df7a84b

Can someone please help

countvajhula commented 3 months ago

Hi! Did you mean to close this issue? Were you able to get to the bottom of it? If not, please re-open and let's figure out what might be going on.

For the moment, I'm not able to reproduce this on my end, so any additional information you can provide about your setup and the exact steps you followed, would help.

My first thought is are you sure you're running mindstream-enter-anonymous-session (default binding: C-c , b) and not mindstream-new (default binding: C-c , n)? The latter starts a new session every time whereas the former will visit an existing one if present.

dasoju commented 3 months ago

Siddharth let me re-open iam always using mindstream-enter-anonymous-session sometimes it opens existing session, sometimes a new one. For example, there was a session i was using past three days and using the above command revisited existing session But, today it just created a new session

2024-06-21-48fb662b8088da6c0ad6de949bd34417591bc48b 2024-06-24-9ed139fdbbd2377c3c01ff5ddb4e7a6577202913

[image: image.png] image

On Thu, Jun 20, 2024 at 11:55 PM Siddhartha Kasivajhula < @.***> wrote:

Hi! Did you mean to close this issue? Were you able to get to the bottom of it? If not, please re-open and let's figure out what might be going on.

For the moment, I'm not able to reproduce this on my end, so any additional information you can provide about your setup and the exact steps you followed, would help.

My first thought is are you sure you're running mindstream-enter-anonymous-session (default binding: C-c , b) and not mindstream-new (default binding: C-c , n)? The latter starts a new session every time whereas the former will visit an existing one if present.

— Reply to this email directly, view it on GitHub https://github.com/countvajhula/mindstream/issues/26#issuecomment-2182122520, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBRMCLVQS2JKAJG724MSWTZIPE4NAVCNFSM6AAAAABJVD6EROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBSGEZDENJSGA . You are receiving this because you modified the open/close state.Message ID: @.***>

countvajhula commented 3 months ago

Two possibilities I can think of given the information so far:

  1. Did you happen to save the session at any point (via mindstream-save-session)? Once saved, sessions are no longer anonymous.
  2. Did you call enter-anonymous-session while in a non-org buffer? Anonymous sessions are currently unique per major mode. In order to be taken to the Org anonymous session, you need to call enter-anonymous-session while in an Org mode buffer. If you are, say, in a python buffer, you would be taken to the python anonymous session (creating one if not present - you can still visit the original org anonymous session from an org buffer).

If none of these applies, what steps exactly did you take for this to happen?

countvajhula commented 3 months ago

Another thought (unrelated to the present issue): if you are using a session for three days, that sounds like a session that has become something you want to keep around and revisit, so you probably want to save it by giving it a name (mindstream-save-session / C-c , s).

dasoju commented 3 months ago

I am using only one command mindstream-enter-anonymous-session i dont use any other commands as i dont see the need for my case

Also, I am always in org buffer

Main reason for using just one command(mindstream-enter-anonymous-session) is, i want mindstream to backup using git and i dont want to worry about saving or loading specific session, pretty much use scratch buffer for all my fleeting thoughts and let git take care of keeping the backups, also want to delete some content to keep scratch buffer more cleaner, but plan to use magit to go back to any old text that i might have deleted

But with this issue, mindstream-enter-anonymous-session sometimes just opens a new session eventhough there is an anonymous session that already exists

It happend just now again, my file list is now as below image image

dasoju commented 3 months ago

Another thought (unrelated to the present issue): if you are using a session for three days, that sounds like a session that has become something you want to keep around and revisit, so you probably want to save it by giving it a name (mindstream-save-session / C-c , s).

I dont want to do this because, i want to keep a buffer for fleeting thoughts, dont really want to save a session myself, remember the name and then search for it when needed.

dasoju commented 3 months ago

okay, i think i might have found the issue

I see that if i kill the buffer (one which anonymous session opened), either because i restarted emacs or saved the file and killed the buffer itself

I see mindstream-enter-anonymous-session opens a new session.

I was wondering if this can be fixed

The use case I am thinking is, i keep brainstorming on a topic for few days at a stretch, i want to comeback to anonymous buffer quickly and perhaps to keep the brainstorming more organized, keep clearing some notes in the anonymous buffer (since its all backed up in git, i can always delete text and still be fine as i can always retrieve). Once i think the brainstorming session is useful i can save the session eventually.

sometimes i have to close emacs or clean up buffers etc or emacs itself crashes, then i lose the anonymous buffer

i think its better to fix this

dasoju commented 3 months ago

i looked at the documentation and also the lisp code for following

image

I see that to determine if anonymous session already exists, its looking for buffer with name *scratch - \<mode>*

If the buffer doesn't exist, it creates a new session. I think, instead of this it shoud look at the anon directory and determine if the session already exists.

Mainly we need to handle case where emacs has crashed or it has been closed or computer has been restarted etc,

Currently mindstream assumes that anonymous buffer is always available unless mindstream-save-session is used, which is not true.

dasoju commented 3 months ago

I think the main issue, is even if i use it for few hours, if emacs crashes or i restart, then mindstream will create another anonymous session, which i think is what i was not expecting

On Mon, Jun 24, 2024 at 11:10 AM Siddhartha Kasivajhula < @.***> wrote:

Another thought: if you are using a session for three days, that sounds like a session that has become something you want to keep around and revisit, so you probably want to save it by giving it a name ( mindstream-save-session / C-c , s).

— Reply to this email directly, view it on GitHub https://github.com/countvajhula/mindstream/issues/26#issuecomment-2187135066, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBRMCNC2SK7TRKRYNY6QLLZJBOLDAVCNFSM6AAAAABJVD6EROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBXGEZTKMBWGY . You are receiving this because you modified the open/close state.Message ID: @.***>

countvajhula commented 3 months ago

Interesting, yes, that would indeed cause the behavior you're seeing.

Currently, there could be many anonymous sessions in that path that never lead anywhere. The design expects that the next time you open Emacs and enter a session for a particular major mode, which could be a long time after the fact, you are expecting to start tabula rasa and are not interested in seeing what you were last working on (which the design assumes you would have saved if you were).

To accommodate your usecase, we could introduce a defcustom to allow you to indicate that you want only one anonymous session for all time, per major mode, so that it would always be reopened as the "active" anonymous session even across Emacs restarts (until it is saved, at which point it would be removed from the anonymous path).

I'm curious about your thoughts. There are plans to support more than one anonymous session being active at the same time per major mode. This would be useful in cases where, for instance, we may be working in a text session for fleeting thoughts, when something comes up and we need to send an email to someone. We'd like to start on the email in an anonymous session, but the current design forces us to save the existing one first -- which we may not be ready to do. We'd like to start a second, concurrent, anonymous session for this purpose, and would like to have a way to know about all the active Mindstream sessions (including anonymous sessions) so that we can visit them without going through a full buffer search.

With the above proposed defcustom, if you indicate you want just one anonymous session across restarts, then I think that would disallow more than one concurrent anonymous session for you as well -- is that the behavior you'd expect?

dasoju commented 3 months ago

Siddharth Yes that's a good idea. Having a defcustom to make one anonymous session will work.

On the other hand, for multiple sessions idea that you have, I see usability issue. Currently let's say I have 10 anonymous sessions for a major mode, there is no way to know which anonymous session has what content especially since the directories are named by a random number.

Is there a way to quickly preview the sessions so that I can go back to right session.?

Currently the only way is to open all the files in each randomly named directory and search for the session you need, which seemed impractical to me.

Thanks again for all your help.

On Tue, Jun 25, 2024, 9:49 AM Siddhartha Kasivajhula < @.***> wrote:

Interesting, yes, that would indeed cause the behavior you're seeing.

Currently, there could be many anonymous sessions in that path that never lead anywhere. The design expects that the next time you open Emacs and enter a session for a particular major mode, which could be a long time after the fact, you are expecting to start tabula rasa and are not interested in seeing what you were last working on (which the design assumes you would have saved if you were).

To accommodate your usecase, we could introduce a defcustom to allow you to indicate that you want only one anonymous session for all time, per major mode, so that it would always be reopened as the "active" anonymous session even across Emacs restarts (until it is saved, at which point it would be removed from the anonymous path).

I'm curious about your thoughts. There are plans to support more than one anonymous session being active at the same time per major mode. This would be useful in cases where, for instance, we may be working in a text session for fleeting thoughts, when something comes up and we need to send an email to someone. We'd like to start on the email in an anonymous session, but the current design forces us to save the existing one first -- which we may not be ready to do. We'd like to start a second, concurrent, anonymous session for this purpose, and would like to have a way to know about all the active Mindstream sessions (including anonymous sessions) so that we can visit them without going through a full buffer search.

With the above proposed defcustom, if you indicate you want just one anonymous session across restarts, then I think that would disallow more than one concurrent anonymous session for you as well -- is that the behavior you'd expect?

— Reply to this email directly, view it on GitHub https://github.com/countvajhula/mindstream/issues/26#issuecomment-2189451122, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBRMCLLNGZUYW47QEM43X3ZJGNR7AVCNFSM6AAAAABJVD6EROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBZGQ2TCMJSGI . You are receiving this because you modified the open/close state.Message ID: @.***>

dasoju commented 3 months ago

Siddharth were you able to add the defcustom, please let me know

countvajhula commented 3 months ago

Hi, sorry for the delay. After some thought i concluded that a defcustom for core behavior doesn’t make sense, and came up with a design that I think you’ll like, which introduces two superficial defcustoms in place of the one deep one. Sorry to be vague at this stage as I’m recovering from an injury and trying to stay away from screens, per doctor’s recommendation. I will be back next week and plan to implement the new improvements then. Please stay tuned!Sent from my iPhoneOn Jul 3, 2024, at 11:30 AM, dasoju @.***> wrote: Siddharth were you able to add the defcustom, please let me know

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

dasoju commented 3 months ago

Siddharth Please take care of your health first, everything else in life can wait. Infact dont even spend any cycles on anything else until you recover fully.

Take complete rest. Let's not discuss anything else until you recover fully.

Best of luck and my prayers are with you.

On Wed, Jul 3, 2024, 10:03 PM Siddhartha Kasivajhula < @.***> wrote:

Hi, sorry for the delay. After some thought i concluded that a defcustom for core behavior doesn’t make sense, and came up with a design that I think you’ll like, which introduces two superficial defcustoms in place of the one deep one. Sorry to be vague at this stage as I’m recovering from an injury and trying to stay away from screens, per doctor’s recommendation. I will be back next week and plan to implement the new improvements then. Please stay tuned!Sent from my iPhoneOn Jul 3, 2024, at 11:30 AM, dasoju @.***> wrote: Siddharth were you able to add the defcustom, please let me know

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/countvajhula/mindstream/issues/26#issuecomment-2208123913, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBRMCL4ZC2LS3JQ5GKUUC3ZKTJRRAVCNFSM6AAAAABJVD6EROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBYGEZDGOJRGM . You are receiving this because you modified the open/close state.Message ID: @.***>

countvajhula commented 2 months ago

Thank you for your kind words @dasoju , and for your patience regarding this feature 🙂 I'm slowly getting back to things and there's a lot to catch up on!

I've started a PR implementing everything we talked about above. It proved to be a fairly substantial change to incorporate this functionality and also have it be compatible with non-unique anonymous sessions, and do it all in a way that kept the core functionality common while offering different superficial ways of using it. (Re: the usability issue with multiple anonymous sessions, yes, it would be great to provide previews or other conveniences down the line, or find ways to hook into existing previewing functionality provided by tools like Ivy - this PR just includes basic support / groundwork).

Please take a look! If you are using Straight.el (or Elpaca), you can install it from that branch directly and try it out, something like this:

(use-package mindstream
  :straight
  (mindstream
    :type git
    :host github
    :repo "countvajhula/mindstream"
    :branch "persistent-anonymous-session")
  :custom
  (mindstream-persist t))

Basically, with this config it should just work out of the box the way you envisioned. I'd appreciate any feedback / testing 👌

Otherwise if you are not able to test it, I will go ahead and merge it soon after a trial period to see if any bugs pop up in my usage.

dasoju commented 2 months ago

Siddhart, Glad that you recovered and back to contributing to emacs community !! Agree with you, implementing non-unique and unique sessions while handling all the corner cases is quite difficult. Thanks for your excellent effort

I tried your installation. I dont use straight.el mainly since its not on melpa/quelpa. I am a heavy user of emacs and worried that installing from other sources makes my installation unstable and halts my daily work.

Please go ahead and merge it, i will test it out once i see the updated package

Thanks again for your effort

On Fri, Jul 19, 2024 at 12:07 AM Siddhartha Kasivajhula < @.***> wrote:

Thank you for your kind words @dasoju https://github.com/dasoju , and for your patience regarding this feature 🙂 I'm slowly getting back to things and there's a lot to catch up on!

I've started a PR https://github.com/countvajhula/mindstream/pull/27 implementing everything we talked about above. It proved to be a fairly substantial change to incorporate this functionality and also have it be compatible with non-unique anonymous sessions, and do it all in a way that kept the core functionality common while offering different superficial ways of using it. (Re: the usability issue with multiple anonymous sessions, yes, it would be great to provide previews or other conveniences down the line, or find ways to hook into existing previewing functionality provided by tools like Ivy - this PR just includes basic support / groundwork).

Please take a look! If you are using Straight.el (or Elpaca), you can install it from that branch directly and try it out, something like this:

(use-package mindstream :straight (mindstream :type git :host github :repo "countvajhula/mindstream" :branch "persistent-anonymous-session") :custom (mindstream-persist t))

Basically, with this config it should just work out of the box the way you envisioned. I'd appreciate any feedback / testing 👌

Otherwise if you are not able to test it, I will go ahead and merge it soon after a trial period to see if any bugs pop up in my usage.

— Reply to this email directly, view it on GitHub https://github.com/countvajhula/mindstream/issues/26#issuecomment-2238516695, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBRMCPKVG6B7TSJ7WEAZ4LZNC3K5AVCNFSM6AAAAABJVD6EROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZYGUYTMNRZGU . You are receiving this because you were mentioned.Message ID: @.***>

countvajhula commented 2 months ago

I find that using Straight.el makes my Emacs config much more deterministic and stable.

countvajhula commented 2 months ago

The PR has been merged, so you should be able to update it via MELPA now. Please let me know if this issue has been addressed to your satisfaction @dasoju 🙂

countvajhula commented 2 months ago

Fixed by #27 .

countvajhula commented 4 weeks ago

I noticed that we don't open the active anonymous sessions on startup (if persist is set to true) so I've made that change in an upcoming PR. Each time Emacs restarts, all of the active sessions will be reopened.