help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font-lock-number-face


From: Ritchie
Subject: Re: font-lock-number-face
Date: Thu, 16 Dec 2010 20:56:56 -0800 (PST)
User-agent: G2/1.0

On Nov 27, 12:05 pm, Ritchie <ritchie...@gmail.com> wrote:
> On Nov 5, 2:31 am, Sébastien Vauban <wxhgmqzgw...@spammotel.com>
> wrote:
>
>
>
>
>
>
>
>
>
> > Hi Ritchie,
>
> > Ritchie wrote:
> > > I'm trying to add a new face in my config file so that all the numbers
> > > will have different color. Here is what I have:
>
> > > (make-face 'font-lock-number-face)
> > > (set-face-foreground 'font-lock-number-face"DodgerBlue4")
> > > (setqfont-lock-number-face'font-lock-number-face)
> > > (defvar font-lock-number "[0-9]+\\([eE][+-]?[0-9]*\\)?")
> > > (defvar font-lock-hexnumber "0[xX][0-9a-fA-F]+")
>
> > > (add-hook 'font-lock-mode-hook
> > >           #'(lambda ()
> > >               (setq font-lock-keywords
> > >                     (append font-lock-keywords
> > >                             (list
> > >                              (list (concat "\\<\\(" font-lock-number "\
> > > \)\\>" )
> > >                                    (list 0font-lock-number-face))
> > >                              (list (concat "\\<\\(" font-lock-
> > > hexnumber "\\)\\>" )
> > >                                    (list 0font-lock-number-face))
> > >                              )))))
>
> > > This works fine for most modes, except multi-term.
>
> > This looks really nice. But, when enabling it, my Gnus buffer become black 
> > and
> > white only. Not true: I see your blue face for the numbers, but every other
> > color customization is gone.
>
> > Some sort of conflict between the color-theme and this?  Priority?  Not
> > cumulative?
>
> > Best regards,
> >   Seb
>
> > --
> > Sébastien Vauban
>
> Yeah, it looks pretty nice in most modes, e.g. cc-mode, python-mode,
> etc., except multi-term, which I think uses term-mode. I'm just trying
> to turnfont-lock-number-faceto default automatically, while running
> multi-term. Not sure how to do  that yet.
>
> regards
>
> Ritchie

I think this way it is much cleaner:


(make-face 'font-lock-number-face)
(set-face-foreground 'font-lock-number-face "DodgerBlue4")
(setq font-lock-number-face 'font-lock-number-face)

(setq number-mode-list '(c-mode-hook
                         c++-mode-hook
                         lisp-mode-hook
                         emacs-lisp-mode-hook
                         python-mode-hook
                         cperl-mode-hook))

(dolist (mode number-mode-list)
  (add-hook mode
            '(lambda ()
              (font-lock-add-keywords nil
               '(("\\<\\([0-9]+\\([eE][+-]?[0-9]*\\)?\\|0[xX][0-9a-fA-
F]+\\)\\>" .
                  font-lock-number-face))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]