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

Close buffer and delete underlying file #4592

Open
tobiaskohlbau opened this issue Nov 4, 2022 · 6 comments
Open

Close buffer and delete underlying file #4592

tobiaskohlbau opened this issue Nov 4, 2022 · 6 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@tobiaskohlbau
Copy link
Contributor

I would like to have an option to delete files from within helix itself. AFAIK there is only the option to use the shell command to rm a file.

Lets assume I've a file called hello.world and I want to delete it. I imagine something like the following to delete the current open file and close the buffer.

  1. f -> hello.world
  2. :delete

Would this something be considered worth adding into helix?

@tobiaskohlbau tobiaskohlbau added the C-enhancement Category: Improvements label Nov 4, 2022
@tobiaskohlbau tobiaskohlbau changed the title Close buffer and delte underlying file Close buffer and delete underlying file Nov 4, 2022
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Nov 5, 2022
@Omnikar
Copy link
Contributor

Omnikar commented Nov 5, 2022

I'm not sure I like the idea of being able to really easily rm a file from Helix (and closing the buffer means that there's no way to recover it using Helix), especially since it would be a command that could potentially be accidentally autocompleted; if we were to add this, I'd want it to utilize the system's "trash" mechanism, rather than rm-ing the file.

@tobiaskohlbau
Copy link
Contributor Author

I strongly agree that this implementation should be aware of system specific trash mechanism.

Any ideas around that, does linux have a general trash mechanism or is it distro specific? I know for Windows and MacOs there are unified trash directories. I will try to research this for linux.

@tobiaskohlbau
Copy link
Contributor Author

tobiaskohlbau commented Nov 6, 2022

Looks like the answer was quiet simple to find there exists a The FreeDesktop.org Trash specification which stated by https://github.com/Byron/trash-rs/blob/fcf6bb5eded49de4fedb40513c949f11c6da0b12/src/freedesktop.rs#L1-L7 is implemented by all common distros and DE.

I'm not aware about the dependency guidelines for this repo. Would it be okay to add the dependency on something like Byron/trash-rs (https://crates.io/crates/trash) or should this be implemented within the project itself?

@the-mikedavis
Copy link
Member

IMO file management bumps with the idea of a text editor. I think supporting file management through :sh and a file variable in a custom keymap would be ok (so #3134 plus #2757 to solve this use-case) but I don't like the idea of building file-management in.

@tobiaskohlbau
Copy link
Contributor Author

That would be a feasible solution for me, too. I can unterstand the desire to keep file-management out from the editor. Command substitutions would be really nice. Maybe it's worth contributing to #3134.Feel free to close this issue as not relevant within the core.

I think #4393 should be getting the same information about command substitutions being a better option instead ab baking in file-management as it's quiet similar to this issue.

@QiBaobin
Copy link
Contributor

QiBaobin commented Nov 16, 2022

We can use archive this by :cmds sh rm %val {filename} && buffer-close once #3393 and #4773 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

5 participants