reddit / emacs
What is the emacs equivalent of vim eunuch?
LowCom · 2022-06-16 02:58
Vim eunuch provides several vim versions of unix command line commands which can be executed directly from vim's command mode.
Egs:
:Remove: Delete a file on disk without E211: File no longer available.
:Delete: Delete a file on disk and the buffer too.
:Move: Rename a buffer and the file on disk simultaneously.
:Rename: Renames the current file without creating new copy.
:Copy:
:Chmod: Change the permissions of the current file.
:Mkdir: Create a directory, defaulting to the parent of the current file.
aaronemassey · 2022-06-16 03:21
Dired?
oantolin · 2022-06-16 03:32
These built-in commands: delete-file, rename-file, copy-file, make-directory, chmod (or set-file-modes), make-directory, delete-directory.
LowCom · 2022-06-16 04:10
> These built-in commands: delete-file, rename-file, copy-file, mak
Is there a way to make these act on the current file instead of prompting for the filename?
oantolin · 2022-06-16 04:12
If the current buffer happens to be associated to a file, then that file is the first element of the future history, so pressing `M-n` will insert it at the prompt.
_viz_ · 2022-06-16 04:24
Just RET also works here.
oantolin · 2022-06-16 04:25
Oh, that's right! Much better, thank you!
xtifr · 2022-06-16 04:32
Wow, even in vi I wouldn't do that! It's so much easier to type, e.g. `:!rm foo` than `:Remove foo`.
And, of course, the Emacs equivalent of *that* is `M-! rm foo`. You can also use the `delete-file` command that u/oantolin mentioned. But really, I'd probably use dired for such things.
oantolin · 2022-06-16 04:33
In Vim you can go `:!rm %`, which is pretty nice.
rajrdajr · 2022-06-16 04:59
[Dired mode (pronounced "dir ed" as in directory editor) info (aka help) pages](https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired.html)
takutekato · 2022-06-16 05:21
How about [https://github.com/bbatsov/crux](https://github.com/bbatsov/crux)?
:Delete `crux-delete-file-and-buffer`
:Move, :Rename `crux-rename-file-and-buffer`
:Copy `write-file (C-x C-w)` (built-in)
Not sure about :Remove and :Chmod, maybe you can use the built-in commands as other comments have suggested or `async-shell-command` and type the shell command there.
:Mkdir `M-x eval-expression (M-:)`, `(make-directory default-directory t)`
Or just simply save the file and Emacs will ask if you want to create the directory when it doesn't already exist.
Rotatop · 2022-06-16 18:37
Maybe wrote it yourself ?
I have copy pasted here https://github.com/Hettomei/dotfiles/blob/0f095115c0d4a40aa1acc3d9cf2069a387616f3c/default/doom.d/config.el#L772
What prostesilaos has done here : https://protesilaos.com/codelog/2021-07-24-emacs-misc-custom-commands/
LowCom · 2022-06-16 21:38
It's not the same. First of all you don't need to specify file name for Remove in vim. Also, you won't get an error deleting a file from within that file.
LowCom · 2022-06-17 05:17
How is write-file different from saving a file through C-x C-s?
Thanks for the crux package, seems very useful.
takutekato · 2022-06-17 05:29
It's equivalent to "Save As", I suppose that by `:Copy` you meant copying the currently editing file so that should be like "Save as" (I don't use Vim extensively, so excuse me if I interpreted those commands incorrectly).