* font-lock-number-face
@ 2010-11-04 18:19 Ritchie
2010-11-05 10:31 ` font-lock-number-face Sébastien Vauban
2010-12-17 22:24 ` font-lock-number-face Stefan Monnier
0 siblings, 2 replies; 5+ messages in thread
From: Ritchie @ 2010-11-04 18:19 UTC (permalink / raw)
To: help-gnu-emacs
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")
(setq font-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 0 font-lock-number-face))
(list (concat "\\<\\(" font-lock-
hexnumber "\\)\\>" )
(list 0 font-lock-number-face))
)))))
This works fine for most modes, except multi-term. When I startup
multi-term, the terminal text color will be all black and white. I can
turn terminal's color back to normal by turning off font-lock-mode
manually, but I couldn't find a way to turn it off automatically.
I tried this:
(add-hook 'term-mode-hook
#'(lambda ()
(font-lock-mode nil)))
it didn't work. I think I could try to add something in font-lock-mode-
hook to check if it is term-mode, but I don't know how to get current
mode name.
Anybody has any suggestions?
Thank you in advance
Ritchie
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: font-lock-number-face
2010-11-04 18:19 font-lock-number-face Ritchie
@ 2010-11-05 10:31 ` Sébastien Vauban
[not found] ` <6571e80e-43d2-4f68-9f78-be1d02d1dcab@o11g2000prf.googlegroups.com>
2010-12-17 9:14 ` font-lock-number-face Elena
2010-12-17 22:24 ` font-lock-number-face Stefan Monnier
1 sibling, 2 replies; 5+ messages in thread
From: Sébastien Vauban @ 2010-11-05 10:31 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
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")
> (setq font-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 0 font-lock-number-face))
> (list (concat "\\<\\(" font-lock-
> hexnumber "\\)\\>" )
> (list 0 font-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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: font-lock-number-face
[not found] ` <6571e80e-43d2-4f68-9f78-be1d02d1dcab@o11g2000prf.googlegroups.com>
@ 2010-12-17 4:56 ` Ritchie
0 siblings, 0 replies; 5+ messages in thread
From: Ritchie @ 2010-12-17 4:56 UTC (permalink / raw)
To: help-gnu-emacs
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))))))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: font-lock-number-face
2010-11-05 10:31 ` font-lock-number-face Sébastien Vauban
[not found] ` <6571e80e-43d2-4f68-9f78-be1d02d1dcab@o11g2000prf.googlegroups.com>
@ 2010-12-17 9:14 ` Elena
1 sibling, 0 replies; 5+ messages in thread
From: Elena @ 2010-12-17 9:14 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 5, 10: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")
> > (setq font-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 0 font-lock-number-face))
> > (list (concat "\\<\\(" font-lock-
> > hexnumber "\\)\\>" )
> > (list 0 font-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
You have to play with the HOW parameter of `font-lock-add-keywords'.
I have some highlighting which worked after setting HOW to t.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: font-lock-number-face
2010-11-04 18:19 font-lock-number-face Ritchie
2010-11-05 10:31 ` font-lock-number-face Sébastien Vauban
@ 2010-12-17 22:24 ` Stefan Monnier
1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2010-12-17 22:24 UTC (permalink / raw)
To: help-gnu-emacs
> (setq font-lock-keywords
> (append font-lock-keywords
Better use font-lock-add-keywords since font-lock-keywords is
manipulated internally by font-lock (it's "compiled" into some other
form).
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-12-17 22:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-04 18:19 font-lock-number-face Ritchie
2010-11-05 10:31 ` font-lock-number-face Sébastien Vauban
[not found] ` <6571e80e-43d2-4f68-9f78-be1d02d1dcab@o11g2000prf.googlegroups.com>
2010-12-17 4:56 ` font-lock-number-face Ritchie
2010-12-17 9:14 ` font-lock-number-face Elena
2010-12-17 22:24 ` font-lock-number-face Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).