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

Backup or trash conflict file instead of remove #6

Open
felixwiemuth opened this issue Jun 7, 2021 · 3 comments
Open

Backup or trash conflict file instead of remove #6

felixwiemuth opened this issue Jun 7, 2021 · 3 comments

Comments

@felixwiemuth
Copy link

Thank you for this very useful tool!

I have a suggestion regarding the deletion of conflict files.
As it can easily happen that one does a mistake when resolving a conflict and first notices it a bit later, I find it problematic to delete the conflict file right-away. Currently, emacs-conflict-resolve-conflicts asks whether to delete after quitting ediff. If one doesn't delete it, it will of course be presented again for resolving, which one doesn't want either.

My suggestion would be that in addition to delete or not delete there is another option, "archive" or "trash" (or both). It would move the conflict file to the trash or to a configurable directory.
Or it renames myfile.sync-conflict-xxx.org to myfile.sync-conflict-xxx-resolvedYYYYMMDD-HHMMSS.org, which has the advantage that the file can be kept in the same directory without being recognized as a conflict (when adapting the regex accordingly).

With this, after resolving a conflict, the function could ask for (a)rchive, (t)rash, (d)elete, (k)eep.
There should also be a variable where one can set the choice permanently, where I can imagine that "trash" or "archive" would be the preferable choices.

Now if one messed up a resolving and the file is in the archive or the trash, one can simply use ediff manually with it, or in the case of renamed files, there could be a special function that searches for "resolved" conflict files instead of new conflict files.

As a bonus, there would be a cleanup function which deletes (or trashes) archived/resolved conflict files when they become too old or exceed a certain number per file. This function could be called (optionally) after each call to emacs-conflict-resolve-conflicts.

@ibizaman
Copy link
Owner

ibizaman commented Jun 8, 2021

That’s a good idea! I don’t know when I’ll have time to work on all this but I’ll try to at least take a pass at having an archive / trash / rename feature.

@felixwiemuth
Copy link
Author

Thanks that would be really nice!
Maybe for the beginning changing delete for trash would be a quick first step.

@felixwiemuth
Copy link
Author

I also noticed that conflict files deleted by emacs-conflict-resolve-conflicts still show up under recent buffers, which is not the case for files deleted with spacemacs/delete-file, which I otherwise use. If I execute delete-file (as used by this script) interactively, it asks whether to trash but then just clears the file content, keeping the empty file, which again is another behaviour.

Looking at the documentation for delete-file, I discovered that it has a trash argument, which might be useful here:

(delete-file FILENAME &optional TRASH)

Probably introduced at or before Emacs version 1.6.

This function has :before advice: ‘delete-file-projectile-remove-from-cache’.

Delete file named FILENAME. If it is a symlink, remove the symlink.
If file has multiple names, it continues to exist with the other names.
TRASH non-nil means to trash the file instead of deleting, provided
‘delete-by-moving-to-trash’ is non-nil.

When called interactively, TRASH is t if no prefix argument is given.
With a prefix argument, TRASH is nil.

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

No branches or pull requests

2 participants