font-lock, or: When is "require" required?

font-lock, or: When is "require" required?

Post by s172 » Sat, 17 Apr 2004 00:45:10


I just installed Emacs from CVS, 21.3.50.3. On startup, it complains:

----------------------------------------------------------------------
An error has occurred while loading `/home/s1726/.emacs':

error: Invalid face, font-lock-comment-face
----------------------------------------------------------------------

This comes from the following:

(set-face-foreground 'font-lock-comment-face "cadetblue")

A number of other font-lock-variables are being set in the same way,
and cause the same error.

This is something I've never seen before, no problems have been seen
for a number of versions up to Emacs 21.3.2.



My ~/.emacs has what I thought was necessary to use font-lock:

(global-font-lock-mode t)

Also, font-lock.el and font-lock.elc are here:

/usr/local/share/emacs/21.3.50/lisp/

This directory is indeed in the load-path, so I can't see where the
problem lies.


However, this doesn't happen if I also say:

(require 'font-lock)

Everything works smoothly.



Now, forgive me if this problem is due to something listed in some
changelog or NEWS file somewhere, but I haven't found it.

The first question is:

Has there been a change that makes the (require 'font-lock) necessary?
And is this the Right Way[tm] to do things?


The second, more important question is:

When is "require" required, and how does one know?

--
SB
 
 
 

font-lock, or: When is "require" required?

Post by Olve » Sat, 17 Apr 2004 23:59:38

> When is "require" required, and how does one know?

emacs loads "features" :
every package has somewhere the line (provide 'this-is-a-cool-feature).
Which means the file has been loaded (i.e. read).
The variables features or feature-list is the list of
all features loaded. When you write (require 'this-is-a-cool-feature)
emacs looks in the list features (or whatsisname): if it is there
it does nothing, else, it looks for a file that contains the
line (provide 'this-is-a-cool-feature), i.e. that provides this
feature. Now some features are loaded at the beginning, some are loaded
by your site-start.el, some in your .emacs.
Adding a require is almost ever a wrong thing to do since files won't be
loaded twice. An exception between highlight18 and font-lock who do not
cohabit smoothly. Anyway, highlight18 the imperialist is nowadays obsolete.

Hope this explanation explains things :-)
Best,
Amities,
Olivier

 
 
 

font-lock, or: When is "require" required?

Post by Kai Grossj » Sun, 18 Apr 2004 04:59:43

Olve < XXXX@XXXXX.COM > writes:


This would be the ideal, but it is not practical: Emacs would have to
search all accessible Lisp files to figure out which one of them
provided the feature in question.

Therefore, given (require 'foo), Emacs just loads foo.elc or foo.el.
But you can say (require 'foo "bar") which loads bar.elc or bar.el,
expecting to find (provide 'foo) there.

Kai
 
 
 

font-lock, or: When is "require" required?

Post by Olve » Sun, 18 Apr 2004 18:56:39

> This would be the ideal, but it is not practical: Emacs would have to

Yes, thanks ! I wanted to stress out that the name of the feature
and the one of the package didn't have to be linked ... and forgot
half of the argument :-(((

Best,
Amities,
Olivier