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

2 Answers 2

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")))
2
  • 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
    Oct 13, 2017 at 9:36
  • True, much better... edit my answer
    – djangoliv
    Oct 13, 2017 at 10:01
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)))))
1
  • Nice, getting the backend like this looks a bit "cleaner"...
    – Markus
    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.