sverrejoh
sverrejoh

Reputation: 16840

Emacs Dired rename with alternative tool

In dired you can rename files just by editing the directory listing and then saving it.

Is it possible to use use an alternative method for renaming when using dired for renaming? I want to use "svn mv", "bzr mv" or "git mv" instead of just renaming, so that I can register the extra metadata in the source control system.

Upvotes: 4

Views: 866

Answers (3)

Christoph Kuhnke
Christoph Kuhnke

Reputation: 1

Simply set variable dired-vc-rename-file to t in your file .emacs:

(setq dired-vc-rename-file t)

If the value of the variable is non-nil and the renamed files are under version control, then dired will rename them using ‘vc-rename-file’ which for git applies git mv.

Upvotes: 0

genehack
genehack

Reputation: 140688

Looking at the functions in dired-aux.el, it seems like the built-in rename-file is what is ultimately called by dired-rename-file (which is the function bound to 'R' in dired-mode).

What you could do is grab that function and replace the call to rename-file with a call to shell-command that runs the appropriate VCS command.

However, another (better/easier) option would be to use one of Emacs's VCS modes to rename your files in your revision control system directly -- have a look at magit or PSVN or MercurialMode, depending on your choice of poison...

Upvotes: 4

brendan
brendan

Reputation: 2743

I don't think dired provides any hook for that. You may be stuck doing something like

! hg mv ? target

Upvotes: 2

Related Questions