2011-02-15 36 views

回答

2

我不认为你可以轻松地配置这一点:在你的ocaml的安装看看caml-types-locate-type-file功能在caml-types.el文件。

这是搜索.annot文件的功能。您可以编辑它以替换"_build"(这是ocamlbuild将生成的文件放入)与obj并完成此操作。

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

+0

感谢托尼奥,你的建议非常完美。如果我有时间,也许我会擦亮解决方案并发送补丁。 – Calin 2011-02-16 17:40:30

0

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

(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

为什么这是低调?它实际上实现了接受的答案建议的补丁,而不必手动修改`caml-types.el` ... – 2014-03-19 01:33:05

0
 
# soft link .annot files so that Emacs' tuareg-mode can find them 
mkdir -p _build 
for f in `find lib/obj -name *.annot` ; do ln -s ../$f _build/ ; done 
相关问题