diff .elisp/settings/50.localfuncs.el @ 295:026344f083ef

af-generic-diff-repo: use monky or magit if available
author Augie Fackler <raf@durin42.com>
date Mon, 12 Nov 2012 16:27:49 -0600
parents 3d5c595c229e
children
line wrap: on
line diff
--- a/.elisp/settings/50.localfuncs.el
+++ b/.elisp/settings/50.localfuncs.el
@@ -17,20 +17,26 @@ spends an eternity in a regex if you mak
     ad-do-it))
 
 ;; Generic repository differ. Requires textmate.el and mercurial.el.
+;; Will use monky or magit if either one is present.
 (defun af-generic-diff-repo ()
   (interactive)
   (let ((root (textmate-project-root)))
-    (cd root)
-    (hg-view-output
-        ((format "project diff for %s" root))
-      (call-process (textmate-project-root-type root) nil t nil "diff")
-      (diff-mode)
-      (setq diff (not (= (point-min) (point-max))))
-      (font-lock-fontify-buffer)
-      (cd root))))
+    (cond ((and (string= (textmate-project-root-type root) "hg") (fboundp 'monky-status)) (monky-status))
+          ((and (string= (textmate-project-root-type root) "git") (fboundp 'magit-status)) (magit-status root))
+          (t (progn
+               (cd root)
+               (hg-view-output
+                   ((format "project diff for %s" root))
+                 (call-process (textmate-project-root-type root) nil t nil "diff")
+                 (diff-mode)
+                 (setq diff (not (= (point-min) (point-max))))
+                 (font-lock-fontify-buffer)
+                 (cd root)))))))
+
 (global-set-key [(control c)(t)(=)] 'af-generic-diff-repo)
 (global-set-key [(control c)(d)] 'af-generic-diff-repo)
 
+
 (defun af-rotate-list (l)
   "Move the head of l to the end of the list."
   (append (cdr l) (list (car l))))