首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在tuareg-mode emacs中指定注释文件的自定义路径?

如何在tuareg-mode emacs中指定注释文件的自定义路径?
EN

Stack Overflow用户
提问于 2011-02-15 21:33:45
回答 2查看 382关注 0票数 5

在emacs中使用tuareg-mode时,有没有指定annot文件的路径?我试图找出我的函数的类型,但模式报告“不是注释文件”。

我的构建结构是:

代码语言:javascript
复制
lib 
 obj
  *.o
  *.cmi
  *.cmx
  *.annot
 src
  *.ml
  *.mli
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-02-15 23:01:49

我不认为您可以轻松地对此进行配置:查看ocaml安装的caml-types.el文件中的caml-types-locate-type-file函数。

这是搜索.annot文件的函数。您可能可以对其进行编辑,将"_build" ( ocamlbuild将生成的文件放在其中)替换为obj并完成此操作。

更好的选择是在.emacs.el中定义一个变量,并在caml-types.el文件中使用它。这样,你甚至可以向ocaml人推荐补丁。

票数 2
EN

Stack Overflow用户

发布于 2012-01-17 07:35:39

下面的代码对我来说就足够了:它创建一个新的自定义变量(我还没有绑定到自定义组,但如果您愿意,也可以),然后将该变量用作要搜索的目录列表。

代码语言:javascript
复制
(defcustom caml-types-annot-directories-search
  '("_build" "obj" "../obj")
  "List of directories to search for .annot files"
  :type '(repeat string)
)
(defun or-list (f lst)
  (if (null lst) nil
    (if (apply f (car lst) nil)
        (car lst)
        (or-list f (cdr lst)))))

(add-hook 'tuareg-mode-hook
          (lambda ()
            (defun caml-types-locate-type-file (target-path)
              (let ((sibling (concat (file-name-sans-extension target-path) ".annot")))
                (if (file-exists-p sibling)
                    sibling
                  (let ((project-dir (file-name-directory sibling))
                        (test-dir (lambda (prefix)
                                    (message "Prefix is %s" prefix)
                                    (setq type-path
                                          (expand-file-name
                                           (file-relative-name sibling project-dir)
                                           (expand-file-name prefix project-dir)))
                                    (message "Testing %s" type-path)
                                    (file-exists-p type-path)))
                        type-path)
                    (while (not (or-list test-dir caml-types-annot-directories-search))
                      (if (equal project-dir (caml-types-parent-dir project-dir))
                          (error (concat "No annotation file. "
                                         "You should compile with option \"-annot\".")))
                      (setq project-dir (caml-types-parent-dir project-dir)))
                    type-path))))))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5004293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档