[Top][All Lists]

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

(font-lock-mode 1) does not always force font-lock

From: Hrvoje Niksic
Subject: (font-lock-mode 1) does not always force font-lock
Date: Thu, 23 Oct 2003 01:52:11 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux)

I have code that needs to force fontification of a file loaded from
disk without affecting buffers visiting the file.  What I tried was:

  (insert-file-contents FILE)
  (let ((buffer-file-name FILE))  ; for normal-mode
    (font-lock-mode 1)
    ;; Here the buffer should be fontified and font-lock-mode turned
    ;; on.

This returns nil because `(font-lock-mode 1)' does not force
font-lock, contrary to the docstring which, in GNU Emacs 21.2.1,

    With arg, turn Font Lock mode off if and only if arg is a
    non-positive number; if arg is nil, toggle Font Lock mode;
    anything else turns Font Lock on.

I assume the problem is that the buffer is that the buffer in question
is temporary.  But `(font-lock-mode 1)' should IMHO still force
font-lock.  And if not, there should be a way to say, "yes, I know
what I'm doing and I really want to fontify this temporary buffer."

A workaround that works for me is to add:

  (unless font-lock-mode

but that kind of solution might not work elsewhere.

reply via email to

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