Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 227
cristobalito Avatar asked Aug 25 '10 10:08

cristobalito


2 Answers

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)
like image 193
Oleg Pavliv Avatar answered Sep 20 '22 18:09

Oleg Pavliv


I've started a new fork of p4.el at https://github.com/gareth-rees/p4.el, and if you're a brave Emacs user who doesn't mind the occasional bug, you might want to give it a go. (Send me pull requests with your bug fixes!) I've been working on responsiveness in situations where the Perforce server might be intermittently available, such as when working over a mobile data connection. In particular, I've made the majority of user operations asynchronous, so that work is rarely blocked waiting for the Perforce server to respond.

I'm also adding support for new Perforce features like p4 status and p4 annotate, fixing bugs, and modernizing the code. Here's a blog about what I've achieved so far.

like image 28
Gareth Rees Avatar answered Sep 19 '22 18:09

Gareth Rees