StokeBloke.com

emacs p4 edit integration

I have been using perforce for some time and I wrote this little function to perform a p4 edit when I press the F9 key.

(defun p4-edit ()
  "does a p4 edit on the current file"
  (interactive)
  (let* (
         (filename (buffer-file-name))
         (cmd)
         (result)
         )
    (setf cmd (concat "p4 " "edit " filename))
    (setf result (shell-command-to-string cmd))
    (message (substring result 0 (- (length result) 1)))
    ;; reload the file
    (revert-buffer t t t)
    )
  ) 

(global-set-key [f9] 'p4-edit)

I know there are lots of other perforce integrations to emacs, but I wrote this and tried to keep it small and simple.

Leave a Reply