我正在尝试从 ede 对象获取项目的根目录。我读到了关于此的有趣讨论issue 。我使用了 David 的一个例子,它似乎工作得很好,除了它只适用于项目中打开文件的缓冲区。我希望从 dired 模式或我决定的任何其他模式返回项目的根目录。是否可以?这是我使用的代码:
(defun my-get-project-root ()
(interactive)
(let ((proj ede-object-root-project))
(if proj
(message "Project root: %s"
(ede-project-root-directory proj))
(message "No project for this buffer."))))
因此,例如从 dired 模式运行此程序时,我收到:“此缓冲区没有项目”消息。
我知道可以使用其他一些工具来实现这一目标,但我已经在使用 cedet 进行项目管理。
最佳答案
你可以使用类似的东西:
(defun get-project-root-dir ()
(interactive)
(let* ((fname (or (buffer-file-name (current-buffer)) default-directory))
(current-dir (file-name-directory fname))
(prj (ede-current-project current-dir)))
(when prj
(ede-project-root-directory prj))))
关于emacs - 从 ede 获取项目根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21884905/