在Emacs Lisp中获取VC根 [英] Get the VC root in Emacs Lisp

查看:144
本文介绍了在Emacs Lisp中获取VC根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个Emacs Lisp函数中,我想知道一个任意文件夹的VC根(如果在源代码控制下),与vc-print-root-log一样。我正在尝试从VC文件/文件夹外面(尽管创建一个临时缓冲区,这样做会很好)。我目前有一个通过magit的git-only解决方案 - (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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆