1

I am using Emacs 24.3 and ESS 13.05 with the theme tangotango.el. While the theme is restful on the eyes, variable names in R don't appear to be highlighted. In tangotango-theme.el I can find the following line:

 `(font-lock-variable-name-face ((t (:foreground "tomato"))))

but this doesn't appear to have any effect. For example, in the screenshot below I would expect the variable orl to be highlighted in some shade of red. Instead it is the standard text colour for this theme.

tangotango theme

If I delve into ESS there is a file named ess-font-lock.el which contains a few references to the variable name face, like this one:

  (set-face-foreground 'font-lock-variable-name-face "Black"))

So it looks as if font-lock-variable-name-face has competing definitions. I don't understand the interaction between Emacs themes and these ESS definitions. Is ESS overriding the tangotango theme and if so, will changing the above line in ess-font-lock.el restore variable name highlighting? Or should I be looking somewhere else entirely?

Edit: note that Cperl mode does seem to respect the font lock:

perl

4

2 回答 2

2

你找错地方了。ess-font-lock 定义主题。大约 10 年前,这很有用。现在有像你的探戈探戈这样的通用主题,ESS 不会干扰它们。

问题是 ESS 没有定义您正在寻找的字体锁定关键字。原因是<-是赋值运算符,R中没有explisit变量定义语句。ESS只处理函数定义。也就是说,将突出显示函数的分配:

foo <- function(){}

信不信由你,但你真的不想突出你所有的任务。你可以尝试一下:

(defvar ess-R-fl-keyword:assign-vars
  (cons "\\(\\(?2:\\s\"\\).+\\2\\|\\sw+\\)\\s-*\\(<-\\)"
        '(1 font-lock-variable-name-face)))

(add-to-list 'ess-R-font-lock-keywords '(ess-R-fl-keyword:assign-vars . t) t)

ESS 在 emacs 字体锁定系统之上实现了灵活的字体锁定定制机制。请参阅 ESS>font-lock 子菜单。

在此处输入图像描述

于 2013-10-27T23:01:26.797 回答
0

是的,听起来像。如果您仅在该模式下看到问题,并且该模式明确改变了面部,那么这听起来像是罪魁祸首。但是,您不需要更改源代码。做这样的事情(未经测试):

 (add-hook 'ess-mode (lambda () (set-face-foreground "tomato")))

(我认为这是正确的模式名称;如果不是,请更正它。)

但这是一个丑陋的解决方法——你不应该这样做。ess-mode.el考虑针对代码提交错误。它不应该那样践踏用户设置,例如面部。如果它想默认更改外观,那么它应该为用户提供一个他们可以自定义的新面孔,而不是简单地以硬编码的方式与现有面孔搞砸。

于 2013-10-27T15:39:09.233 回答