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?

miguelmorin
  • 1,907
  • 12
  • 33

1 Answers1

18

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.

Tobias
  • 33,167
  • 1
  • 37
  • 77
  • 4
    ↓ runs the command next-history-element, so does M-n. – xuchunyang Feb 14 '20 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 '20 at 14:05
  • It's great to come here looking to learn something, and learn something else in addition to it. – Jeffrey Benjamin Brown Oct 03 '21 at 21:40