开发者

Is it possible to use the font of tuareg in caml-mode under Emacs?

For Indentation of “if”, i have to use caml-mode under Emacs.

But I find the font of tuareg is more colorful than caml-font, so my question is whether it is possible to use the font of tuareg in caml-mode.

Also, with the current .emacs which requires caml-font, when I open a .ml file, some lines (especially in the beginning of the file) are not highlighted. If I go to those lines, modify them, they will change their color. Could anyone tell me how to fix that problem?

Also, do you have some better fonts for ocaml programs to suggest, besides the one of tuareg and caml开发者_JS百科-font?

Thank you very much!


Do you mean that you like the colors better or that their are more colors?

If the latter, it's probably difficult to use tuareg font-locking with caml-mode, though I only looked at the two a little bit.

If it's the former, you can simply customize the faces used by caml-mode to use better faces (by which I mean typeface or "color"). With a sufficiently new emacs, put your cursor on the face that you want to change and type M-x customize-face RET. It will suggest the name of the face that you are on, so hit return again. Then you can change the face in any way you want. As a first step you might keep tuareg.el open and check what faces are there, for example

(defface tuareg-font-lock-governing-face
  '((((background light)) (:foreground "blue" :bold t))
    (t (:foreground "orange" :bold t)))
  "Face description for governing/leading keywords."
  :group 'tuareg-faces)

is the definition of the face used for let, so you would just put your cursor on let, M-x customize-face RET RET, then change the foreground to blue and turn on bold (assuming you have a light background). Don't forget to save it.

Alternately, you can edit caml-font.el and change the caml-font-lock-keywords section to use the fonts you like (which could be from tuareg). If you want to add to your .emacs instead then you should change it to (setq caml-font-lock-keywords ...).

(defconst caml-font-lock-keywords
  (list
   ...
;definition
   (cons (concat
          "\\<\\(a\\(nd\\|s\\)\\|c\\(onstraint\\|lass\\)"
          "\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
          "\\|in\\(herit\\|itializer\\)?\\|let"
          "\\|m\\(ethod\\|utable\\|odule\\)"
          "\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
          "\\|v\\(al\\(ue\\)?\\|irtual\\)\\)\\>")
         ;; 'font-lock-type-face)
         'tuareg-font-lock-governing-face)
   ...
   ))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜