简体   繁体   中英

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. 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?

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

In Emacs 23.3 on Mac OS, the following restored the colours to how the colour theme defined them:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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