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

2 Answers 2


Something like this:

(defun open-status ()
  (if vc-mode
      (if (string-match "^ Git" (substring-no-properties vc-mode))
        (if (string-match "^ SVN" (substring-no-properties vc-mode))
            (call-interactively 'svn-status )
          (if (string-match "^ HG" (substring-no-properties vc-mode))
    (message "not a project file")))
  • Perfect, thank you! (svn-status ".") didn't match my needs, so I replaced it with ( call-interactively 'svn-status ) and now I have just what I needed :)
    – Markus
    Commented Oct 13, 2017 at 9:36
  • True, much better... edit my answer
    – djangoliv
    Commented Oct 13, 2017 at 10:01

I came up with something like this.

(defun vc-status ()
  (let ((backend (vc-responsible-backend default-directory)))
    (cond ((equal 'Git backend) (magit-status))
          ((equal 'Hg backend) (ahg-status)))))
  • Nice, getting the backend like this looks a bit "cleaner"...
    – Markus
    Commented Oct 16, 2017 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.