Trying to deduce a project root, using vc I'm getting errors, involving strange non-ASCII characters. I.e. invoking

(vc-find-root (expand-file-name (buffer-file-name (get-buffer "fname"))))

I get

eval: Wrong number of arguments: #[(file witness) 
" ...several non-ASCII characters ..."
)" [vc-ignore-dir-regexp locate-dominating-stop-dir-regexp file witness locate-dominating-file] 3 2751734], 1

in the Message buffer. I'm not sure if this is a problem related only to vc.el or more generally to my setup/machine.


Wrong number of arguments

vc-find-root must be invoked with two arguments: (vc-find-root FILE WITNESS).

To get vc root use vc-root-dir instead:

vc-root-dir is an autoloaded compiled Lisp function in vc.el.

Return the root directory for the current VC tree.

Return nil if the root directory cannot be identified.

And if you need the vc root of specified buffer:

(let ((buffer (get-buffer "fname")))
  (when buffer
    (with-current-buffer buffer
  • Where WITNESS could be something like ".git"? Ok.?
    – Mark
    May 30 '19 at 15:03
  • @Mark Yes. .git or .hg. vc-find-root is used by vc backends and each backend pass it's own WITNESS.
    – muffinmad
    May 30 '19 at 15:22

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.