在Emacs Lisp中获取VC根 [英] Get the VC root in Emacs Lisp
问题描述
(magit-get-top-dir dir-name)
。 我尝试使用(vc-deduce-backend)
和'root命令,但vc-deduce-backend检查的变量似乎只能在现有的vc模式下设置(例如日志浏览模式)缓冲区。
有没有一个简单的方法来将其从VC中获取?
查看您自己的 vc-print-root-log
的示例,以下内容似乎是您之后:
(require'vc)
(let((path〜/ .emacs .d / el-get /))
(vc-call-backend(vc-responsible-backend path)'root path))
In an Emacs Lisp function, I want to know the VC root of an arbitrary folder (if under source control), the same as something like vc-print-root-log does it. I'm trying to do it from outside the VC file/folder (though creating a temporary buffer to do this would be fine). I currently have a git-only solution through magit - (magit-get-top-dir dir-name)
.
I tried using (vc-deduce-backend)
and the 'root command, but the variables that vc-deduce-backend checks seems to only be set in existing vc mode (e.g. log-view-mode) buffers.
Is there a simple way to get this out of VC?
Looking at your own example of vc-print-root-log
, the following seems to be what you're after:
(require 'vc)
(let ((path "~/.emacs.d/el-get/"))
(vc-call-backend (vc-responsible-backend path) 'root path))
这篇关于在Emacs Lisp中获取VC根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!