Skip to content

Comments

WIP - Configurable auto-backup files#10

Draft
martinlocklear wants to merge 1 commit intosysread:mainfrom
martinlocklear:martin/auto-delete-backup-files-by-config
Draft

WIP - Configurable auto-backup files#10
martinlocklear wants to merge 1 commit intosysread:mainfrom
martinlocklear:martin/auto-delete-backup-files-by-config

Conversation

@martinlocklear
Copy link
Contributor

@martinlocklear martinlocklear commented Jan 2, 2026

Working on making the auto-created backup files configurable.

Backup file behavior is controlled by the edit-mode.backup-file-handling setting in ~/.fnord/settings.json.

Valid values are:

  • never-create
  • auto-delete
  • ask-to-delete
  • create-and-ignore

Example:

{
  "edit-mode": {
    "backup-file-handling": "ask-to-delete"
  }
}

Default behavoir when edit-mode.backup-file-handling is not present is to keep the status quo: Create the backups and offer to delete them

@martinlocklear martinlocklear changed the title WIP WIP - Configurable auto-backup files Jan 2, 2026
Copy link
Owner

@sysread sysread left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial thoughts. I'm still thinking through the different modes and how they are represented in the code base, but as you said, this PR is still early stage.


defp backup_guidance do
if Settings.should_create_backup_files?() do
"If backup files are available to the user, you may revert changes by replacing the file with the latest `.bak` file."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"If backup files are available to the user, you may revert changes by replacing the file with the latest `.bak` file."
"You can revert changes by replacing the file with the latest `.bak` file."

Since it's conditionally injected, it doesn't need to hedge.


display_path =
case Store.get_project() do
{:ok, project} when is_binary(project.source_root) ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the is_binary guard. If you have backups, you are in an ask session, which requires a --project (or guesses it based on your cwd). And a project should always have a valid source_root.

Get the list of global configuration keys that should not be treated as project names.
"""
@spec global_config_keys() :: [binary]
def global_config_keys() do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section needs to be mix formated.

Comment on lines +426 to +429
{:ok, %{"name" => name}} ->
# Project exists but has no edit-mode map
_ = name
nil
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{:ok, %{"name" => name}} ->
# Project exists but has no edit-mode map
_ = name
nil
# Project exists but has no edit-mode map
{:ok, %{"name" => _}} ->
nil

is_binary(project_value) ->
project_value

is_map(Settings.get(settings, "edit-mode", nil)) and is_binary(Map.get(Settings.get(settings, "edit-mode", %{}), "backup-file-handling")) ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super hard to read and visually parse.

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.

2 participants