LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm playing around with different color themes for emacs like "zenburn" or "tango" and they generally look great. (far better than the standard emacs so called "fruit-salad" theme ;-)

Unfortunately cperl-mode is defining a special color code for arrays and hashes. ( cperl-hash-face , cperl-array-face , ...)

Any suggestion for a generic solution to solve this without needing to patch every single theme?

Maybe ... a a lisp code which reads the font-lock-variable-name-face and modifies it to a slightly other version , like bold if not already bold?

This involves a more general question:

How to represent sigil variables in a world where most languages can't distinguish between them.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

update

Face: cperl-hash-face

@sample

Documentation: Font Lock mode face used to highlight hash names. Defined in `cperl-mode.el'. Family: unspecified Foundry: unspecified Width: unspecified Height: unspecified Weight: bold Slant: italic Foreground: Red Background: navy Underline: unspecified Overline: unspecified Strike-through: unspecified Box: unspecified Inverse: unspecified Stipple: unspecified Font: unspecified Fontset: unspecified Inherit: unspecified

Replies are listed 'Best First'.
Re: Adjusting emacs color themes for cperl-mode
by Perlbotics (Archbishop) on Sep 22, 2015 at 18:06 UTC

    I had the same problem and used this snipped in my Emacs' config (you'll need to fine-tune the colours to meet your taste, though):

    (eval-after-load 'cperl-mode '(progn ;;-- @LanX - not related to your question, but perhaps useful? ;; (define-key cperl-mode-map (kbd "RET") 'reindent-then-newline +-and-indent) ;; (define-key cperl-mode-map (kbd "C-M-h") 'backward-kill-word) ;; (define-key 'help-command "P" 'cperl-perldoc-at-point) ;; experiment: ;; (setq cperl-dark-background "gray14") (set-face-attribute 'cperl-array-face nil :foreground "#ffff88" ;; "yello +w3" "#ffff88" :background 'unspecified :weight 'normal :slant 'normal ) (set-face-attribute 'cperl-hash-face nil :foreground "#e08020" ;; "DarkO +range3" "#e080202 :background 'unspecified :weight 'normal :slant 'normal ) ))

    The snipped above is an excerpt from my $HOME/.emacs.d/config/210-setup-cperl.el file that is part of my private Emacs configuration git repository.

    It is based on the fine stuff, I've found here: https://github.com/targzeta/emacs-modular-configuration and here: http://whattheemacsd.com

      Thanks!

      But my problem was rather that I wanted to have a generic solution which works with all themes which forgot to define the cperl-hash and array face. (some do)

      ATM I'm using M-x customize-face ² to derive array and hash face from the normal variable face.

      Customize face (default `all faces'): cperl-array-face

      Operate on all settings in this buffer: [Revert]... [Apply] [Apply and Save] Hide Cperl Array Face:[sample] State : EDITED, shown value does not take effect until you set or +save it. Font Lock mode face used to highlight array names. INS DEL Display: all [X] Weight: bold [X] Slant: italic [X] Inherit: [INS] [DEL] Face: font-lock-variable-name-face Show All Attributes INS
      (Note: Display:All is important)

      after hitting "Apply and Save" this will be executed at the end of all my configs.

      Seems to work well ATM and I don't need to fiddle with elisp... ;-)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

      ²) or click Options -> Customize Emacs -> Specific Face

      update

      that's the generated lisp code which "customize" wrote into my init.el

      (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:family "Courier New" :foundry "outline" :slant normal + :weight bold :height 113 :width normal)))) '(cperl-array-face ((t (:inherit font-lock-variable-name-face :slant +italic :weight bold)))) '(cperl-hash-face ((t (:inherit font-lock-variable-name-face :slant i +talic :weight bold)))))
Re: Adjusting emacs color themes for cperl-mode
by LanX (Saint) on Sep 22, 2015 at 08:41 UTC
    Actually it should be easier than I thought.

    Faces (emacs lingo for styles) can inherit from other faces.

    Albeit I might need to patch cperl-mode cause it already has logic to adapt to background color and terminals.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!