Open bartekpacia opened 6 months ago
@JoeKar So far I only updated the docs. Please let me know if such changes make sense, so I can start implementing them.
This isn't gonna be backwards compatible, is it?
I was thinking about it, but in the initial proposal I decided to omit this. But I definitely would like to make this change completely painless for everyone. Making anyone lose time over such a minor change would be unprofessional.
By "backward compatibility", do you mean that if ~/.config/micro/backups
and ~/.config/micro/buffers
exist, they should be used and whatever is in ~/.local/state/micro
should be ignored?
Another option would be to copy ~/.config/micro/backups
and ~/.config/micro/buffers
to ~/.local/state/micro
.
Dunno. Neither option seems perfect.
The backward compatibility will be a nasty thing.
Another option would be to copy
~/.config/micro/backups
and~/.config/micro/buffers
to~/.local/state/micro
.
In that case you will do this with every startup, right? Maybe it's better to move it then and maintain the new location only. :thinking:
Maybe it's better to move it then and maintain the new location only.
Yeah, it's also an option.
The situation where the change I'm planning to make would cause problems seems very rare: Micro would have to crash, the user would have update in the meantime, and then the backup would be missing.
Here is a patch to separate micro's state files from micro's config files. With this patch files that were previously searched for in $MICRO_CONFIG_HOME/buffers
or $MICRO_CONFIG_HOME/backups
are now searched for in $MICRO_STATE_HOME/buffers
or $MICRO_STATE_HOME/backups
respectively. If $MICRO_STATE_HOME/buffers
does not exist $XDG_STATE_HOME/micro/buffers
is used instead. If that doesn't exist either $HOME/.local/state/micro/buffers
is used. Ditto for $MICRO_STATE_HOME/backups
.
This patch simply adds a config.StateDir variable (alongside the existing config.ConfigDir) and uses it for state stuff. The patch will create the state directory if it doesn't already exist but does not touch the old location.
I don't do anything for migration because IMO it's not worth adding code that will sit in micro forever to address the minor one-time slight annoyance of history and cursor positions being reset. I think a small external migration script would be better for that (not included).
If anyone would like to test this without the hassle of building micro from source a statically linked binary for 64-bit Linux (x86_64) can be found here. It should work on any x86_64 Linux distribution. A statically linked binary for 64-bit Arm Linux (aarch64) can be found here for those of you using 64 bit ARM servers or Pis.
@clipcarl could you make the change as a Github pull request to make it easier to review?
@clipcarl could you make the change as a Github pull request to make it easier to review?
Honestly I've never used Github for development (I'm old-school) so I'm not sure how to do that!
?
This PR is targeted at #3176