12

In the macOS Finder, I can rename a file or directory by pressing RET and the current value becomes the default for the new file name. This helps if I make a small change, such as adding a date at the beginning of the filename.

In Emacs with dired, I can rename with R but I don't have the previous value as the default, so I auto-complete it. This becomes dangerous if I make a mistake in the auto-completion and overwrite another file.

Can Emacs dired rename files incrementally as in the Finder?

1 Answer 1

20

Pressing R in dired queries the new file name in the minibuffer. There you can access the current file name by pressing the key.

Note that this is a general convention when querying text input from the minibuffer. Pressing the key gives you the default value(s), pressing the key gives you the input history elements.

That way multiple default values become possible.

3
  • 5
    ↓ runs the command next-history-element, so does M-n.
    – xuchunyang
    Commented Feb 14, 2020 at 13:58
  • 1
    @xuchunyang Yes, for me it is next-line-or-history-element. Nevertheless, what I said is true. Just try (completing-read "Test: " '("first" "second" "third") nil nil nil nil '("DEF")). The arg DEF of completing-read is the list of default values. You get the default value(s) when you press ↓ right after running the command.
    – Tobias
    Commented Feb 14, 2020 at 14:05
  • It's great to come here looking to learn something, and learn something else in addition to it. Commented Oct 3, 2021 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.