Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 911
Zed Avatar asked Nov 06 '08 23:11

Zed


3 Answers

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))))
)
like image 26
Sam Kington Avatar answered Sep 18 '22 07:09

Sam Kington


Press M-x customize-group RET cperl-faces RET and change coloring to your liking.

like image 113
Ilya Martynov Avatar answered Sep 22 '22 07:09

Ilya Martynov


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)))
like image 27
zk_phi Avatar answered Sep 21 '22 07:09

zk_phi