micro icon indicating copy to clipboard operation
micro copied to clipboard

Request: improve conformance with the XDG Base Directory Specification

Open jwatt opened this issue 4 years ago • 5 comments
trafficstars

micro appears to create the file ~/.config/micro/buffers/history, which is not a configuration file. Data generated from the use of an app should be put under ${XDG_DATA_HOME:-~/.local/share}, so it seems like the buffers directory should live at ${XDG_DATA_HOME:-~/.local/share/micro/buffers}. Would you mind updating micro to use that path?

Many thanks for micro, it's awesome. 😄

Commit hash: cfcb2e4 OS: Fedora 33 Terminal: Konsole/bash

jwatt avatar Jan 23 '21 19:01 jwatt

This would be great, especially with config/dotfile management systems. With the current behaviour, it's impossible to just track ~/.config/micro/, one has to individually track each config files (settings.json, bindings.json, colorschemes/, etc).

There is already an option to use a custom directory for backups, so this could be implemented similarly for the other things.

0x5c avatar Mar 02 '21 08:03 0x5c

Also ~/.config/micro/backups should probably be on ~/.cache/micro/backups instead

adrianinsaval avatar Jun 27 '22 21:06 adrianinsaval

Either of data home (.local/share) or state home (.local/state) would seem more appropriate for the backups, especially state since it is defined in the spec at the place for command history, undo history, etc The current version of the spec is here

0x5c avatar Jun 27 '22 22:06 0x5c

Also ~/.config/micro/backups should probably be on ~/.cache/micro/backups instead

The ./backup/* directory is configurable (backupdir). However, it does belong in the $XDG_CACHE_HOME directory rather than $XDG_CONFIG_HOME as-is the current default.

The ./buffers/history file belongs in the $XDG_STATE_HOME/micro/ directory.

The ./buffers/* directory belongs in the $XDG_CACHE_HOME/micro/ directory. (It, arguably, belongs in $XDG_STATE_HOME/micro/ when the savecursor option is enabled (off by default). However, overall it’s closer to cache data than state data.)


#3 Migration strategy

Option A:

  1. Check if the lastmigration option in the in settings.json file.
    1. If not present or matches a version number lower than the current version number:
      1. Move the ${XDG_CONFIG_HOME:-$HOME/.config}/micro/buffers/history file to ${XDG_STATE_HOME:-$HOME/.local/state}/micro/history. (Skip if the source file doesn’t already exist.)
      2. Move the ${XDG_CONFIG_HOME:-$HOME/.config}/micro/buffers/ directory to ${XDG_CACHE_HOME:-$HOME/.cache}/micro/buffers/. (Skip if the source directory doesn’t already exist.)
      3. Move the ${XDG_CONFIG_HOME:-$HOME/.config}/micro/backups/ directory to ${XDG_CACHE_HOME:-$HOME/.cache}/micro/buffers/. (Skip if the source directory doesn’t already exist.)
      4. Add "lastmigration": $current_version_number to the settings file.
    2. If present and equal to the current or a higher version number, then abort.

Option B:

Just leave the old files in their current location and begin using the new locations. You’ll still likely get 99.8 % user-satisfaction.


Alternative approaches

  1. Leave the ./buffers and ./backup directories inside $XDG_CONFIG_HOME. When these folders are created (no migration strategy), mark them as cachy/trashy directories. Automatically add a CACHEDIR.TAG file into each directory. Also, set the extended attributes com.apple.metadata:com_apple_backup_excludeItem with a value of [empty] (MacOS) and xdg.robots.backup with a value of false (Linux) on each directory. Lots of backup and search utilities will know to ignore them by default. There’s nothing equivalent on Windows.
  2. Add buffersdir and historyfile configuration options but leave the current defaults (or take the opportunity to adjust their defaults with the implementation of these options).

da2x avatar Aug 07 '22 07:08 da2x