2

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?

6

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

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

That way multiple default values become possible.

| improve this answer | |
  • 3
    ↓ runs the command next-history-element, so does M-n. – xuchunyang Feb 14 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 Feb 14 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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