[p4] P4 emacs mode -- how do I turn off backup files?

Peter Stephenson pws at csr.com
Wed Mar 28 01:20:01 PST 2007


Roy Smith wrote:
> I'm using Emacs-P4 Integration v10.5 and GNU Emacs 21.3.1.  How do I  
> convince emacs to NOT make backup (~) files when editing a file under  
> p4 control?  With CVS, the emacs VC mode knew to do this automatically.
> 
> I'm sure the answer has something to do with writing a p4-hook  
> function which sets make-backup-files to nil, but I can't quite get  
> the right incantation, especially with regard to making sure that  
> backups are only turned off in buffers which contain P4 files.

I have this code in my .emacs, which seems to do the trick.
backup-inhibited is sort of an opposite to make-backup-files which,
the documentation says, is intended to be made buffer-local, so that's
what I've done.


;; If the file is handled by Perforce, don't make backup files.
;; We need to append this to find-file-hooks (last t) because it
;; must run after p4-find-file-hook.
;;
;; This would be obsolete if we use the vc package for Perforce.
(add-hook 'find-file-hooks
	  (function (lambda ()
		      (and (featurep 'p4)
			   (p4-is-vc)
			   (set (make-local-variable 'backup-inhibited)
				t))))
	  t)


-- 
Peter Stephenson <pws at csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


More information about the perforce-user mailing list