Trying to use the vc-root-dir function on Emacs gives the error message vc-root-dir is not a valid command name

On inspecting vc.elc as found by locate-library the function appears to exist as a defalias.

emacs-version is 26.1 FYI

  • Does it work if you evaluate the command with M-: aka M-x eval-expression RET (vc-root-dir) RET? If so, then the answer is that the function works correctly, but is not made for interactive use. If we type M-x find-function RET vc-root-dir RET we can inspect the function and see that it does not contain an (interactive ...) statement after the doc-string.
    – lawlist
    Jun 12 '19 at 21:42
  • What's the question?
    – Drew
    Jun 12 '19 at 22:33
  • @lawlist thanks that was indeed the problem - just not understanding debugging i suppose
    – navillus
    Jun 13 '19 at 7:43

The function vc-root-dir is a non-interactive function and Emacs will generate the error described by the original poster if said function is called interactively. It is often helpful to visit the function at issue to see what makes it tick, and this can be done with M-x find-function. Non-interactive functions can be evaluated in a variety of ways, such as M-x eval-expression aka M-:.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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