2011-02-15 37 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 
相關問題