Emacs Dired rename with alternative tool

2019-05-07 00:31发布

问题:

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.

回答1:

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...



回答2:

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

! hg mv ? target


标签: emacs dired