all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (font-lock-mode 1) does not always force font-lock
@ 2003-10-22 23:52 Hrvoje Niksic
  2003-10-23 18:38 ` Richard Stallman
  0 siblings, 1 reply; 15+ messages in thread
From: Hrvoje Niksic @ 2003-10-22 23:52 UTC (permalink / raw)


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

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

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

    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
    (font-lock-fontify-buffer))

but that kind of solution might not work elsewhere.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2003-11-18 21:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-22 23:52 (font-lock-mode 1) does not always force font-lock Hrvoje Niksic
2003-10-23 18:38 ` Richard Stallman
2003-10-23 22:30   ` Hrvoje Niksic
2003-10-24  5:22     ` Alexander Pohoyda
2003-10-24  9:49       ` Hrvoje Niksic
2003-10-24 19:12         ` Alexander Pohoyda
2003-10-24 20:15           ` Hrvoje Niksic
2003-10-25  7:35             ` Alexander Pohoyda
2003-10-25  9:52               ` Hrvoje Niksic
2003-10-26 11:32                 ` Alexander Pohoyda
2003-10-26 16:56                   ` Hrvoje Niksic
2003-10-26 19:07                     ` Stefan Monnier
2003-10-27 23:44                       ` Richard Stallman
2003-10-28 22:09                         ` Alexander Pohoyda
2003-11-18 21:13                         ` Alexander Pohoyda

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.