vc-p4 is an implementation of vc, the version control interface built in to Emacs, for Perforce, a proprietary centralised version control system. vc-p4 was originally developed by Jonathan Kamens, and I forked it and started adapting it to Emacs 23, notable additions being the vc-dir mode and commands acting on several files at once.

Downloading it

vc-p4 is hosted on the public Perforce depot at You can browse the web interface for vc-p4, or go directly for the two files:

Checking it out with Perforce

The adventurous may wish to follow development through Perforce. Since you probably want to use at least two different Perforce working directories (unless you use Perforce only to improve vc-p4), you need to set the P4CONFIG environment variable in your ~/.profile or other suitable file:

export P4CONFIG=.p4config

Then create a directory for vc-p4, put a .p4config file in it containing:

Run p4 client, which will use the editor specified by the EDITOR environment variable to let you edit your client specification. Check that Root names the directory where you want vc-p4, and under View at the very bottom delete all lines and enter this, substituting myclient for the actual client name:

//guest/magnus_henoch/vc-p4/... //myclient/...

Then run p4 sync, which should get you the latest version of the two files, vc-p4.el and p4-lowlevel.el. The same command is used to check for and update to new versions.

The wiki warns that client specifications belonging to unregistered users are periodically purged, so you may need to redo the p4 client step above.

Installing it

Now that you have the files, activate vc-p4 by adding this to your .emacs:

(add-to-list 'load-path "/path/to/vc-p4/")
(require 'vc-p4)

Using it

When you visit a file that is managed by Perforce, the mode line contains an indicator such as P4-42, 42 being the file's revision number. If you want to open it for editing, hit C-x v v, which will call p4 edit, make the buffer writable, and change the indicator to P4:42 to indicate that the file is opened.

Once you have edited the file as desired, hit C-x v = to see the diff against the file in the depot. If after inspecting it you want to commit, hit C-x v v again, which will give you a buffer where you can write a log message. Hit C-c C-c when done, and your changes will be submitted and the buffer will be read-only again.

To work with several files at the same time, you'll want VC Directory mode, which the manual describes better than I could do.


The discussion page is open. You can also contact me directly.