简体   繁体   English

我可以使用带有perl模式着色的cperl模式吗?

[英]Can I use cperl-mode with perl-mode colorization?

The Emacs cperl-mode seems to get confused less than perl-mode, but the Skittles effect makes the thing unusable for me. Emacs cperl-mode似乎比perl-mode更加困惑,但是Skittles效果使得这个东西对我来说无法使用。 Does anyone have or know of an example of a .emacs block that causes cperl-mode to use the colorization from perl-mode, ideally in a form readable enough that I can go back and turn back on the default colors one element at a time until I reach something I'm comfortable with? 有没有人知道或者知道一个.emacs块的例子,它导致cperl-mode使用perl-mode的着色,理想情况下是一个足够可读的形式,我可以返回并一次返回一个元素的默认颜色直到我达到一些我很舒服的东西?

In particular there is a hideously shade of light green used for some builtins that I find quite unreadable, and I prefer my variables to not have the leading $ and $$ and such tinted red along with the variable name. 特别是对于一些我觉得非常难以理解的内置物,有一种可怕的浅绿色阴影,我更喜欢我的变量没有前导的$$$以及这种有色红色和变量名称。 Most of the rest are merely distracting. 其余大多数只是分散注意力。

按Mx customize-group RET cperl-faces RET并根据自己的喜好更改颜色。

With colour themes, the problem is limited to arrays and hashes - and it turns out that that's because cperl-mode defines those faces as being bold-weight, which colour themes don't appear to affect ( Solarized doesn't). 对于颜色主题,问题仅限于数组和散列 - 事实证明这是因为cperl-mode将这些面定义为粗体,哪些颜色主题似乎不会影响( Solarized不会)。

In Emacs 23.3 on Mac OS, the following restored the colours to how the colour theme defined them: 在Mac OS上的Emacs 23.3中,以下内容将颜色恢复为颜色主题如何定义颜色:

(custom-set-faces
 '(cperl-array-face ((t (:weight normal))))
 '(cperl-hash-face ((t (:weight normal))))
)

You can also use the 'real' perl-mode coloring by overwriting font-lock settings with those of perl-mode. 您还可以通过使用perl-mode覆盖字体锁定设置来使用“真实”perl模式着色。

(require 'perl-mode)

(add-hook 'cperl-mode-hook
          (lambda ()
            (setq font-lock-defaults
                  '((perl-font-lock-keywords perl-font-lock-keywords-1 perl-font-lock-keywords-2)
                    nil nil ((?\_ . "w")) nil
                    (font-lock-syntactic-face-function . perl-font-lock-syntactic-face-function)))
            (font-lock-refresh-defaults)))

如果您不喜欢特定的默认颜色,可以更改颜色主题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM