Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mindstream recipe #9000

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

countvajhula
Copy link
Contributor

Brief summary of what the package does

Mindstream allows you to enter freewriting sessions for writing or coding. It starts off like a simple scratch buffer that you don't even need to name, but the buffer is Git-versioned and committed every time it's saved, giving rise to robust sessions that remember everything you did, so that you never need to worry about losing anything even though it was so easy to get started (e.g. you didn't have to think of a filename, location on disk, or anything). When you're done, you can save these sessions to a permanent location and resume them at any time, or just close them and forget about them if their purpose has been served.

Example usage:

  • for quick prototyping in any programming language
  • learning a new programming concept
  • solving coding problems with a quick feedback loop
  • writing a blog post or even a book
  • drafting emails
  • really any writing task (like this description!)

Direct link to the package repository

https://github.com/countvajhula/mindstream

Your association with the package

Maintainer

Relevant communications with the upstream package maintainer

None needed

Checklist

@walseb
Copy link
Contributor

walseb commented Apr 18, 2024

Cool package!

It's great to see a package improving the backup functionality of Emacs beyond backup files and saved undo state. Great idea about marking major iterations with a tag!

Here are some thoughts unrelated to whether this should be on Melpa or not:

For the backup part, maybe you'd want to use the API provided by git-backup? https://melpa.org/#/git-backup
But that might be a lot of work.

I see that you are recommending git-timemachine to traverse the various iterations committed to the git repo. Last time I looked into it, it didn't show you a diff of the changes made compared to your current buffer, but just what the selected git commit looks like, which I found very confusing as it's hard to see sometimes what's changed.

I suspect also that restoring a commit destroys any overlays you have created, moves point, etc, which is very annoying.

I have been trying to fix this in my interface to git-backup, which I think does the backup part of this package, but globally. I have the live diff working well even for large changes (with some bugs), but haven't gotten the restoring part working. There's this package that I can't remember the name of that can restore markers and such, but it's made for formatters only. I have been working a bit on adapting it, but haven't gotten it to work.

In conclusion, would be great if we had a better git-timemachine that could do previews and restore git commits without moving around all the Emacs state in the buffer.

@countvajhula
Copy link
Contributor Author

Hi! From a quick look, git-backup isn't a good fit for the backend (though it's cool). Mindstream is not really about backups but about sessions. It's like:

  • Vim's undotree, except based on Git (with all the benefits that brings), and supporting more than one file
  • Persistent scratch buffers like persistent-scratch, except versioned and with an emphasis on scaling with your work rather than only on starting and for scratch notes
  • Like DreamPie, GroovyConsole, DrRacket -- and many other IDEs that offer an interactive scratch buffer for an integrated development feedback loop. Except that the scratch buffer becomes the project and you don't need to create new files for transitioning to "real work"

Emacs's tooling around Git (like Git-timemachine and Magit) is very handy and clever, and there's surely going to be a lot more over time (like your diff viewer!). That's a big reason I chose to implement the sessions using Git, so that any such common Git tools written in the community would be usable together with Mindstream sessions out of the box!

@riscy
Copy link
Member

riscy commented Apr 21, 2024

Thanks both - conversations like these make some PRs especially fun for me to look at.

At a glance, one thing I would change is to have mindstream-backend-initialize use shell-quote-argument on base-path just in case base-path could contain any shell control characters, which the user could introduce if they set e.g. mindstream-path to "riscy's stuff" or something similar.

Alternatively instead of shell-command-to-string you might want to use call-process, per the docs --

In Elisp, you will often be better served by calling ‘call-process’ or
‘start-process’ directly, since they offer more control and do not
impose the use of a shell (with its need to quote arguments).

@countvajhula
Copy link
Contributor Author

Have you considered broadening the scope of your tool outside a git-backups setting (e.g. as an addon to git-timemachine) so that it's usable with Git in general? That could make it even more useful.

Thanks for the feedback as always @riscy . I'm tied up for a couple of days, but I should be able to follow up here later this week.

@countvajhula
Copy link
Contributor Author

I've made the change you suggested @riscy . Now that I'm looking at it again, it would be nice to do this via standard Elisp bindings for Git here instead of using the CLI. Magit APIs are too user focused / interactive for use here, but libegit2 seemed promising. It doesn't look like that package is quite ready though.

@riscy
Copy link
Member

riscy commented Apr 28, 2024

Thank you! Here's the latest --

mindstream-backend.el with byte-compile using Emacs 29.3:

mindstream-backend.el:63:9: Warning: reference to free variable `mindstream-add-everything'

Package and license:

@countvajhula
Copy link
Contributor Author

Ah whoops, I've addressed the warning you found.

I also realized that I needed to make a change to how multiple files would be supported that would have been backwards incompatible, so I've gone ahead and preemptively made this change to avoid that. To summarize the change, formerly Mindstream was oriented around a version-controlled buffer. But with "sessions" being generalized to full Git repos with any files contained there, it was necessary to make templates into folders rather than files, and that involved a lot of rewiring. It was also necessary to eliminate the buffer-local mindstream-session-mode and instead have everything happen via the global mindstream-mode along with a registry of "active sessions" that are simply Git repo paths.

It should be good to go now, and ready for any further feedback!

re: the license format, if you don't mind, I prefer to retain the COPYING file that simply indicates that the package is public domain and there's no copyright. The reason is that blindly placing off-the-shelf licenses on software (as we've been taught to do) is a misguided habit that distracts from the real problems to be solved here -- which is to say, attribution of work, and consequent financial empowerment of the creators of value. Licenses based in outdated notions of ownership of software, in the form of copyright, are not going to get us there, but the simple use of public domain, together with fair attribution processes governed by sound economic principles -- and if we support one another -- will.

On this subject, I humbly urge you to watch my talk at EmacsConf 2022, if you have a moment. It is an important one on the subject of open source sustainability and the path to making economic processes function in an open and transparent way, retaining everything that's good about open source and gaining everything that's good about the traditional economic processes that actually work today. 🙏

@countvajhula
Copy link
Contributor Author

Hey @riscy , not to rush you, but JFYI I'm going to be demoing Mindstream at a meetup this coming Saturday. If you feel it's ready, it'd be convenient if it could be merged before then so that attendees could try it out -- but no pressure at all (and it would be valuable -- as always! -- to hear further feedback).

Re: the remaining byte compile warning from melpazoid that I see:

mindstream-session.el:76:[29](https://github.com/countvajhula/mindstream/actions/runs/8919607680/job/24496084851#step:5:30): Warning: `lax-plist-get' is an obsolete function (as of 29.1); use `plist-get' instead.

As it happens, I'm using Emacs 27.1 at the moment and it doesn't have the new predicate argument to plist-get that allows the use of equal instead of eq. Since Mindstream only depends on Emacs 25.1 at this point, it seems premature to transition to plist-get, but what do you think? I could also aim to make the change after I personally upgrade my Emacs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants