4

I wonder if it is possible to change the following functions:

  • dired-do-rename
  • dired-do-copy

such that when I operate on a single file, it prompts the selected file's name as the default target name.

Most of my files have long names, when I copy/rename a file, I usually copy/rename it to a similar name. It's painful to type the entire name or copy it from the original file.

Thanks a lot for any suggestions!

Greenonline
  • 161
  • 1
  • 3
  • 11
DataHungry
  • 247
  • 1
  • 7
  • Hm... tangent, but take a look at [`wdired-mode`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Wdired.html). It's awesome. – PythonNut Feb 17 '15 at 05:04
  • What about typing the first letter then TAB key, to auto insert the source name, then move your cursor wherever necessary for modifying the name? – Nsukami _ Feb 17 '15 at 05:16
  • Related: [Similar question about copy/rename when doing `C-x C-w`](http://emacs.stackexchange.com/q/2849/115). – Kaushal Modi Feb 17 '15 at 05:21
  • The first answer solves my problem. The function we need to call is M-n: (next-history-element) – DataHungry Feb 17 '15 at 05:28

1 Answers1

9

The ability to set the "copy to" or "rename/move to" name same as the original name is already built in.

  1. Initiate the copy or move (rename) in dired
  2. (only for ido users) C-f or C-x C-f - kick out of ido mode
  3. M-n - That will give you the current file/dir name

General tip that applies everywhere in emacs: Whenever you are hunting for a default that you think should be present, try out M-n or M-p.

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179