【问题标题】:Is it possible to use the font of tuareg in caml-mode under Emacs?Emacs下caml-mode可以使用tuareg的字体吗?
【发布时间】:2011-07-20 13:47:46
【问题描述】:

对于Indentation of “if”,我必须在Emacs下使用caml-mode

但是我发现tuareg的字体比caml-font的颜色更丰富,所以我的问题是caml-mode中是否可以使用tuareg的字体。

另外,对于当前需要caml-font.emacs,当我打开.ml 文件时,某些行(尤其是文件开头的行)不会突出显示。如果我去那些行,修改它们,它们会改变它们的颜色。谁能告诉我如何解决这个问题?

另外,除了tuaregcaml-font 中的一种之外,你还有一些更好的ocaml 程序字体可以推荐吗?

非常感谢!

【问题讨论】:

    标签: emacs fonts ocaml tuareg


    【解决方案1】:

    你的意思是你更喜欢这些颜色还是他们的颜色更多?

    如果是后者,可能很难将 tuareg 字体锁定与 caml-mode 一起使用,虽然我只是稍微看了一下两者。

    如果是前者,您可以简单地自定义caml-mode 使用的面孔以使用更好的面孔(我的意思是字体或“颜色”)。使用足够新的 emacs,将光标放在要更改的面上并输入 M-x customize-face RET。它会提示你所在的脸的名字,所以再次点击返回。然后你可以用任何你想要的方式改变脸。作为第一步,您可以保持tuareg.el 处于打开状态并检查那里有哪些面孔,例如

    (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)
    

    是用于 let 的面的定义,因此您只需将光标放在 let,M-x customize-face RET RET,然后将前景更改为蓝色并打开粗体(假设您有浅色背景)。不要忘记保存它。

    或者,您可以编辑caml-font.el 并更改caml-font-lock-keywords 部分以使用您喜欢的字体(可能来自图阿雷格)。如果您想添加到 .emacs,则应将其更改为 (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)
       ...
       ))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 1970-01-01
      • 2010-10-06
      • 1970-01-01
      • 1970-01-01
      • 2010-10-26
      • 2011-02-16
      相关资源
      最近更新 更多