0

before I sit down and reinvent the wheel for me:

I'm working with svn and git in different projects. Is there already an existing way to start svn-status or magit, depending on the vcs that is used for the file in the current buffer? Maybe some of the vc-* commands?

Thanks, Markus

Markus
  • 471
  • 2
  • 12

2 Answers2

2

Something like this:

(defun open-status ()
  (interactive)
  (if vc-mode
      (if (string-match "^ Git" (substring-no-properties vc-mode))
          (magit-status)
        (if (string-match "^ SVN" (substring-no-properties vc-mode))
            (call-interactively 'svn-status )
          (if (string-match "^ HG" (substring-no-properties vc-mode))
              (ahg-status)
            )))
    (message "not a project file")))
djangoliv
  • 3,169
  • 16
  • 31
1

I came up with something like this.

(defun vc-status ()
  (interactive)
  (let ((backend (vc-responsible-backend default-directory)))
    (cond ((equal 'Git backend) (magit-status))
          ((equal 'Hg backend) (ahg-status)))))
Tephra
  • 821
  • 5
  • 14