views:

66

answers:

1
+3  Q: 

Perforce and Emacs

I'm looking to setup emacs to allow me to use perforce without having to use p4v.

I've had a look at the emacs wiki and a search on the site but there only seems to be two options out there - both of which are pretty old. First option is p4.el which was last updated in 2004. The second option is the integration with emacs VC component, last updated in August 2007.

The second link above from SO seems to suggest using p4.el. Is that still the recommended advice? Does anyone have any tips or tricks they can share?

Any help \ advice much appreciated.

Chris

+2  A: 

Yes, p4.el is still a recommended way to integrate perforce into emacs. It was well implemented which explains why it hasn't been updated since 2004.

I customized a couple of things, mostly to add and disable some shortcuts.

I added a possibility to call some p4v commands from emacs as well

(defun invoke-p4v-cmd (cmd)
  (let ((file (if (equal major-mode 'dired-mode)
                  (dired-get-file-for-visit)
                (buffer-file-name))))
    (when file
      (shell-command (concat "\"c:/Program Files/Perforce/p4v.exe\" -cmd \"" cmd " " file "\" &")))))

(defun op:p4v-timelapse ()
  "show revision tree"
  (interactive)
  (invoke-p4v-cmd "annotate"))

(define-key p4-prefix-map "T" 'op:p4v-timelapse)


(defun op:p4v-tree ()
  "show revision tree"
  (interactive)
  (invoke-p4v-cmd "tree"))

(define-key p4-prefix-map "g" 'op:p4v-tree)

(defun op:p4v-history ()
  "Show history"
  (interactive)
  (invoke-p4v-cmd "history"))

(define-key p4-prefix-map "x" 'op:p4v-history)
Oleg Pavliv
Thanks for the answer. Just out of interest, I'm assuming there's no support for stashing in p4.el (stashing came way after)?
cristobalito
I'm still new to Perforce, but it seems that p4 shelve is similar to git stash. You can easily implement a p4-shelve emacs function based on p4.el
Oleg Pavliv