Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to *completely* disable font-lock mode in my .emacs?

929 views
Skip to first unread message

Eric Smith

unread,
Apr 11, 2004, 9:07:35 PM4/11/04
to
I'm sick of seeing light colored text on a light grey background, which
I cannot read. I don't really want to customize the colors, I just want
them gone. And I'm sick of manually turning off font lock mode all the
time. I've tried in vain to figure out what I can put in my .emacs that
will prevent font lock mode from ever being used.

Any suggestions will be much appreciated!

Thanks,
Eric

[If you want to reply by email, please remove the obvious spam-proofing
from my email address.]

Henrik Enberg

unread,
Apr 11, 2004, 9:30:48 PM4/11/04
to
Eric Smith <eric-no-s...@brouhaha.com> writes:

> I'm sick of seeing light colored text on a light grey background, which
> I cannot read. I don't really want to customize the colors, I just want
> them gone. And I'm sick of manually turning off font lock mode all the
> time. I've tried in vain to figure out what I can put in my .emacs that
> will prevent font lock mode from ever being used.

(global-font-lock-mode -1)

Note however that it is off by default, so you probably should remove
the code that turns it on. (Which will probably be the above snippet
with a "1" as an arg)

Michael Schierl

unread,
Apr 12, 2004, 3:24:25 PM4/12/04
to
Henrik Enberg <henrik...@telia.com> writes:

> Eric Smith <eric-no-s...@brouhaha.com> writes:
>
>> I'm sick of seeing light colored text on a light grey background, which
>> I cannot read. I don't really want to customize the colors, I just want
>> them gone. And I'm sick of manually turning off font lock mode all the
>> time. I've tried in vain to figure out what I can put in my .emacs that
>> will prevent font lock mode from ever being used.
>
> (global-font-lock-mode -1)

If you still see too many colors you don't like (there are several
places that use colors even when font-lock-mode is off) you could do
(I won't do that however...)

(mapatoms (lambda (fce) (if (facep fce) (copy-face 'default fce))))

which will set *all* loaded faces to the default face.

Michael

Stefan Monnier

unread,
Apr 12, 2004, 6:35:57 PM4/12/04
to
> I'm sick of seeing light colored text on a light grey background, which
> I cannot read.

This should never happen and is a bug. Please report it.
The only known cases where it can happen is if you're running under a text
terminal in which case there's no way for Emacs to figure out whether your
background is dark or light, so it might guess wrong, in which case you
should customize frame-background-mode manually.


Stefan

Eric Smith

unread,
Apr 27, 2004, 7:15:28 PM4/27/04
to
I wrote:
> I'm sick of seeing light colored text on a light grey background, which
> I cannot read.


Stefan Monnier <mon...@iro.umontreal.ca> writes:
> The only known cases where it can happen is if you're running under a text
> terminal

Exactly.

> in which case there's no way for Emacs to figure out whether your
> background is dark or light, so it might guess wrong, in which case you
> should customize frame-background-mode manually.

s/it might guess wrong/it does guess wrong/

Why does it guess? When it guesses wrong, it renders the text
unreadable, so the default assumption on a text terminal should be that
the user does NOT want color. (Or maybe that is the default, but my
Linux distribution (Red Hat 9) has changed it?)

If I set frame-background-mode to light, won't that screw up my X frames
which have a dark background? Is there an easy way to set
frame-background-mode to light only if Emacs can't figure out whether
the background is dark or light, as in the text terminal case? Or, better
yet, to simply not use color on text terminals?

Thanks!
Eric Smith

Eric Smith

unread,
Apr 27, 2004, 7:26:01 PM4/27/04
to
I wrote:
> I've tried in vain to figure out what I can put in my .emacs that
> will prevent font lock mode from ever being used.

Henrik Enberg <henrik...@telia.com> writes:
> (global-font-lock-mode -1)

I'm not sure what was turning font-lock-mode on, but this has taken care
of it. I had previously tried (global-font-lock-mode nil), which did
not have the desired effect. It never occurred to me to use -1.

Thanks!
Eric

Matthieu Moy

unread,
Apr 27, 2004, 7:36:09 PM4/27/04
to
Eric Smith <eric-no-s...@brouhaha.com> writes:

> If I set frame-background-mode to light, won't that screw up my X frames
> which have a dark background?

(unless window-system
(setq frame-background-mode 'light))

Won't do so.

--
Matthieu

Eli Zaretskii

unread,
Apr 28, 2004, 1:39:11 AM4/28/04
to help-gn...@gnu.org
> From: Eric Smith <eric-no-s...@brouhaha.com>
> Newsgroups: gnu.emacs.help
> Date: 27 Apr 2004 16:15:28 -0700

>
> > in which case there's no way for Emacs to figure out whether your
> > background is dark or light, so it might guess wrong, in which case you
> > should customize frame-background-mode manually.
>
> s/it might guess wrong/it does guess wrong/

In your case, perhaps. In general, it does guess correctly in quite a
few cases. If you still think Emacs _always_ guesses wrong, please
describe your reasons; one specific case---yours---is not enough to
justify a general claim.

> Why does it guess?

Because there's no method known to Emacs developers to query the
terminal about its default background color.

> the default assumption on a text terminal should be that the user
> does NOT want color.

That would be a bad default, since most Emacs users do want color on
the text terminal.

Kevin Rodgers

unread,
Apr 28, 2004, 11:12:11 AM4/28/04
to
Eric Smith wrote:
> Henrik Enberg <henrik...@telia.com> writes:
>>(global-font-lock-mode -1)
>
> I'm not sure what was turning font-lock-mode on, but this has taken care
> of it. I had previously tried (global-font-lock-mode nil), which did
> not have the desired effect. It never occurred to me to use -1.

Did it occur to you to read the function's doc string with `C-h f'?

--
Kevin Rodgers

Eric Smith

unread,
Apr 28, 2004, 6:06:16 PM4/28/04
to
Eli Zaretskii <el...@gnu.org> writes:
> That would be a bad default, since most Emacs users do want color on
> the text terminal.

No, most Emacs users want text they can read. If guessing colors
can commonly render unreadable text (and it can), the default should be
no color. There is very little downside to not having color, and it
can be manually enabled. But having unreadable colors is relatively
difficult to disable, because one can't read the help information in order
to find out how to disable it.

Eric Smith

unread,
Apr 28, 2004, 6:08:35 PM4/28/04
to
Eli Zaretskii <el...@gnu.org> writes:
> In your case, perhaps. In general, it does guess correctly in quite a
> few cases. If you still think Emacs _always_ guesses wrong, please
> describe your reasons; one specific case---yours---is not enough to
> justify a general claim.

I didn't say that it *always* guesses wrong. I just said that it *does*
guess wrong. The nature of a guess is that it is sometimes wrong. In
this case, I think it is frequently wrong, since in my experience most
of the modern virtual terminal software (both under Linux/Posix systems
and on Windows) defaults to a light background.

Guessing wrong is *much* worse than having only B&W text.

jasonr

unread,
Apr 28, 2004, 6:46:03 PM4/28/04
to
Eric Smith <eric-no-s...@brouhaha.com> writes:

> I'm sick of seeing light colored text on a light grey background, which
> I cannot read. I don't really want to customize the colors, I just want
> them gone. And I'm sick of manually turning off font lock mode all the
> time. I've tried in vain to figure out what I can put in my .emacs that
> will prevent font lock mode from ever being used.

You don't need to put something in your .emacs, you need to take
something out. font-lock-mode is disabled by default.

OTOH, you might want to look at using a different terminal emulator
if your current one is not working correctly. You mention Windows in
another post - PuTTY works fine with either light or dark background,
and is a better terminal emulator in general than most of the
alternatives on Windows.

Thien-Thi Nguyen

unread,
Apr 28, 2004, 8:25:23 PM4/28/04
to
Eric Smith <eric-no-s...@brouhaha.com> writes:

> Guessing wrong is *much* worse than having only B&W text.

disabling the guessing is much worse than improving it.
to improve it, the people who implement the guessing need to
learn the precise environment in which triggers the mis-guess.
the easier this environment is communicated, the easier the
people who implement the guessing can improve it.

thi

Eli Zaretskii

unread,
Apr 29, 2004, 2:08:51 AM4/29/04
to help-gn...@gnu.org
> From: Eric Smith <eric-no-s...@brouhaha.com>
> Newsgroups: gnu.emacs.help
> Date: 28 Apr 2004 15:06:16 -0700

>
> Eli Zaretskii <el...@gnu.org> writes:
> > That would be a bad default, since most Emacs users do want color on
> > the text terminal.
>
> No, most Emacs users want text they can read.

Obviously, having the text readable is higher priority than having
colors. Nevertheless, having colors is also a high priority, as
anyone who read this forum back when Emacs didn't support that would
tell you.

> If guessing colors can commonly render unreadable text (and it can),
> the default should be no color.

I don't think it guesses wrong ``commonly'', but in any case I agree
with what someone else said here: improving the guesswork is better
than disabling it, when the feature is wanted by many users.

> There is very little downside to not having color

See, this is where many (most?) Emacs users disagree with you.

> and it can be manually enabled

Well, it's off by default, so what you ask is already there.

Eli Zaretskii

unread,
Apr 29, 2004, 2:11:18 AM4/29/04
to help-gn...@gnu.org
> From: Eric Smith <eric-no-s...@brouhaha.com>
> Newsgroups: gnu.emacs.help
> Date: 28 Apr 2004 15:08:35 -0700

>
> I didn't say that it *always* guesses wrong. I just said that it *does*
> guess wrong. The nature of a guess is that it is sometimes wrong. In
> this case, I think it is frequently wrong, since in my experience most
> of the modern virtual terminal software (both under Linux/Posix systems
> and on Windows) defaults to a light background.

On a virtual terminal (i.e. a terminal emulator), Emacs should have
defaulted to a bright background. The code to do that is part of the
guesswork that is the subject of discussions in this thread. If in
your case that didn't work, it might be a bug worth reporting.

Joe Corneli

unread,
Apr 29, 2004, 1:29:31 PM4/29/04
to help-gn...@gnu.org
You can specify all the faces and so on directly, and this seems a
less drastic measure than disabling font-lock. The configuration I
use which has pretty nice results both on a black rxvt and under x
follows.

Xdefaults like so:

Emacs*Background: black
Emacs*Foreground: white
Emacs*Font: -misc-fixed-medium-r-*-*-13-*-*-*-*-*-*-*
Emacs*MenuBar: off
Emacs*ToolBar: 0
Emacs*ScrollBars: off
Emacs*internalBorder: 2


Custom faces like so:

(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.
'(bold ((nil (:foreground "light blue"))))
'(book-result ((t (:background "darkviolet" :foreground "white" :slant normal :weight bold :height 150 :width normal :family "misc-fixed"))) t)
'(cursor ((nil (:background "DeepPink1"))) t)
'(diary-face ((((class color) (background dark)) (:foreground "green"))))
'(diff-file-header-face ((((class color) (background dark)) (:background "forestgreen" :weight bold))))
'(diff-header-face ((((class color) (background dark)) (:background "maroon"))))
'(font-lock-builtin-face ((nil (:foreground "orange"))))
'(font-lock-comment-face ((nil (:foreground "red"))))
'(font-lock-function-name-face ((((type tty) (class color)) (:foreground "yellow" :weight bold))))
'(font-lock-string-face ((((class color) (background dark)) (:foreground "goldenrod1"))))
'(font-lock-variable-name-face ((nil (:foreground "tan"))))
'(gnus-group-mail-3-empty-face ((((class color) (background dark)) (:foreground "chartreuse3"))))
'(gnus-group-mail-3-face ((t (:foreground "chartreuse1" :weight bold))))
'(holiday-face ((((class color) (background dark)) (:background "grey15"))))
'(italic ((nil (:foreground "green"))))
'(km-nonanon-face ((t (:foreground "purple"))))
'(minibuffer-prompt ((t (:foreground "yellow"))))
'(mode-line ((t (:background "pink" :foreground "black" :weight bold))))
'(mode-line-inactive ((t (:background "grey30" :foreground "peachpuff"))))
'(region ((((class color) (background dark)) (:background "blue4"))))
'(w3-style-face-00005 ((t (:foreground "red" :underline nil :weight normal :family "fixed"))) t)
'(w3-style-face-00009 ((t (:foreground "cadetblue" :underline nil :weight normal :family "fixed"))) t)
'(w3-style-face-00010 ((t (:foreground "grey77" :underline t :weight normal :family "fixed"))) t)
'(w3-style-face-00011 ((t (:foreground "navajowhite" :underline nil :weight normal :family "fixed"))) t)
'(w3-style-face-00012 ((t (:foreground "cadetblue" :underline t :weight normal :family "fixed"))) t)
'(w3-style-face-00013 ((t (:foreground "cadetblue" :underline nil :weight normal :family "fixed"))) t)
'(w3-style-face-00014 ((t (:foreground "plum" :underline t :weight normal :family "fixed"))) t)
'(w3-style-face-00015 ((t (:foreground "goldenrod" :underline nil :weight bold :family "fixed"))) t)
'(w3-style-face-00017 ((t (:foreground "darkgreen" :underline nil :weight normal :height 100 :family "fixed"))) t)
'(w3-style-face-00018 ((t (:foreground "plum" :underline nil :weight normal :height 100 :family "fixed"))) t)
'(w3-style-face-00019 ((t (:foreground "alicewhite" :underline nil :weight normal :family "fixed"))) t)
'(w3-style-face-00021 ((t (:foreground "darkgreen" :underline nil :weight normal :height 100 :family "fixed"))) t)
'(w3-style-face-00030 ((t (:background "darkred" :underline nil :weight normal :family "fixed"))) t))


Eric Smith

unread,
Apr 29, 2004, 8:20:58 PM4/29/04
to
Joe Corneli <jcor...@math.utexas.edu> writes:
> You can specify all the faces and so on directly, and this seems a
> less drastic measure than disabling font-lock. The configuration I
> use which has pretty nice results both on a black rxvt and under x
> follows.

Having to find all the things in emacs that use distinct faces and
come up with new settings for all of them is exactly what I did not
want to do.

I'm still not sure why font-lock seemed to be on by default on my
system, but now that my .emacs is disabling it thanks to the help
people have provided here, I'm much happier.

But thanks for posting you configuration, and I may try it in the
future.

Eric Smith

unread,
Apr 29, 2004, 8:23:47 PM4/29/04
to
I wrote:
> I had previously tried (global-font-lock-mode nil), which did
> not have the desired effect. It never occurred to me to use -1.

Kevin Rodgers <ihs_...@yahoo.com> writes:
> Did it occur to you to read the function's doc string with `C-h f'?

I thought I had done that, but apparently not. I must have found mention
of the function elsewhere.

So either nil is positive (which seems somewhat unlikely), or the
documentation for the function is incorrect.

Eric Smith

unread,
Apr 29, 2004, 8:26:28 PM4/29/04
to
Eli Zaretskii <el...@gnu.org> writes:
> Well, it's off by default, so what you ask is already there.

OK, I stand corrected. That is exactly what I wanted (off by default).

There must be something on my system that was turning it on, but I have
not found it yet. Anyhow, turning it off in my .emacs using
(global-font-lock-mode -1) has solved the problem.

Thanks,
Eric

LEE Sau Dan

unread,
Apr 29, 2004, 4:01:00 PM4/29/04
to
>>>>> "Eli" == Eli Zaretskii <el...@gnu.org> writes:

Eli> Obviously, having the text readable is higher priority than
Eli> having colors. Nevertheless, having colors is also a high
Eli> priority, as anyone who read this forum back when Emacs
Eli> didn't support that would tell you.

Why not add a menu entry (if there isn't one yet) and add a sentence
on the welcome screen to tell the clueless people how to activate that
menu item?


--
Lee Sau Dan 李守敦 ~{@nJX6X~}

E-mail: dan...@informatik.uni-freiburg.de
Home page: http://www.informatik.uni-freiburg.de/~danlee

Kevin Rodgers

unread,
Apr 30, 2004, 2:32:22 PM4/30/04
to
Eric Smith wrote:
> Joe Corneli <jcor...@math.utexas.edu> writes:
>
>>You can specify all the faces and so on directly, and this seems a
>>less drastic measure than disabling font-lock. The configuration I
>>use which has pretty nice results both on a black rxvt and under x
>>follows.
>
> Having to find all the things in emacs that use distinct faces and
> come up with new settings for all of them is exactly what I did not
> want to do.
...

> But thanks for posting you configuration, and I may try it in the
> future.

I think Joe's point was that a few X resource definitions can cover all
the cases so that you don't have to enumerate them all. Note in
particular his use of class (vs. instance) names and an asterisk (vs. A
dot) to separate the program from its resource.

Besides those he listed, you might need these to override all the faces'
colors:

Emacs*attributeForeground: white
Emacs*attributeBackground: black

--
Kevin Rodgers

Kevin Rodgers

unread,
Apr 30, 2004, 2:40:07 PM4/30/04
to
Eric Smith wrote:
> I wrote:
>>I had previously tried (global-font-lock-mode nil), which did
>>not have the desired effect. It never occurred to me to use -1.
>
> Kevin Rodgers <ihs_...@yahoo.com> writes:
>>Did it occur to you to read the function's doc string with `C-h f'?
>
> I thought I had done that, but apparently not. I must have found
> mention of the function elsewhere.

Trust, but verify.

> So either nil is positive (which seems somewhat unlikely), or the
> documentation for the function is incorrect.

Here is the actual doc string:

| global-font-lock-mode is an interactive compiled Lisp function in `font-lock'.
| (global-font-lock-mode &optional ARG DUMMY)
|
| Toggle Font-Lock mode in every buffer.
| With prefix ARG, turn Global-Font-Lock mode on if and only if ARG is positive.
| Font-Lock mode is actually not turned on in every buffer but only in those
| in which `turn-on-font-lock-if-enabled' turns it on.

Note that the argument is optional; when it is not specified, the mode
is toggled; and a nil value for an optional arg is the same thing as
leaving it unspecified.

--
Kevin Rodgers

Stefan Monnier

unread,
Apr 30, 2004, 4:37:10 PM4/30/04
to
> Besides those he listed, you might need these to override all the faces'
> colors:

> Emacs*attributeForeground: white
> Emacs*attributeBackground: black

AFAIK, X resources aren't used on a text-terminal.


Stefan

Joe Corneli

unread,
Apr 30, 2004, 8:51:24 PM4/30/04
to help-gn...@gnu.org

AFAIK, X resources aren't used on a text-terminal.

Hm, well I nevertheless have good results both under X and on a
terminal, and moreover, in the case of a terminal, the background
can be either dark or light background, and Emacs adjusts the
*default* face accordingly. The font lock setup I use is optimized
for a dark background, including plenty of yellow etc., so I don't
really advise using it on a terminal with a light background unless
you have to.

I should probably have posted this little .emacs snippet too, which
is useful in combination with the .Xdefaults config. This is only
relevant under X; its purpose is to keep flickering at startup time
down to a minimum.

(Cf. http://mail.gnu.org/archive/html/help-gnu-emacs/2004-02/msg00757.html)


(cond (window-system
(setq default-frame-alist
'((internal-border-width . 2)
(border-width . 2)
(left-fringe . 0)
(right-fringe . 0)
(menu-bar-lines . 0)
(tool-bar-lines . 0)
(tool-bar-lines . 0)
(modeline . t)
(width . 85)
(height . 32)
(background-mode . dark)
(display-type . color)
(cursor-color . "DeepPink1")
(background-color . "black")
(foreground-color . "white")
(border-width . 2)
(font
. "-misc-fixed-medium-r-*-*-13-*-*-*-*-*-*-*")))
(set-scroll-bar-mode nil)
(blink-cursor-mode -1)
(tooltip-mode -1)))


Eli Zaretskii

unread,
May 2, 2004, 10:04:58 AM5/2/04
to help-gn...@gnu.org
> From: LEE Sau Dan <dan...@informatik.uni-freiburg.de>
> Newsgroups: gnu.emacs.help
> Date: 29 Apr 2004 22:01:00 +0200

>
> Why not add a menu entry (if there isn't one yet) and add a sentence
> on the welcome screen to tell the clueless people how to activate that
> menu item?

The menu item is already there.


Eli Zaretskii

unread,
May 2, 2004, 10:01:49 AM5/2/04
to help-gn...@gnu.org
> From: Eric Smith <eric-no-s...@brouhaha.com>
> Newsgroups: gnu.emacs.help
> Date: 29 Apr 2004 17:23:47 -0700

>
> So either nil is positive (which seems somewhat unlikely), or the
> documentation for the function is incorrect.

What global-font-lock-mode looks at is the _numerical_value_ of the
prefix arg (see the doc string of prefix-numeric-value). You can try
that function with nil and see that

(prefix-numeric-value nil)
=> 1


Stefan Monnier

unread,
May 3, 2004, 10:14:33 AM5/3/04
to
>> So either nil is positive (which seems somewhat unlikely), or the
>> documentation for the function is incorrect.

> What global-font-lock-mode looks at is the _numerical_value_ of the
> prefix arg (see the doc string of prefix-numeric-value). You can try
> that function with nil and see that

> (prefix-numeric-value nil)
> => 1

I wish that was the reason. Sadly, nil is treated specially as a toggle.


Stefan

0 new messages