Jeff Mincy <jeff(a)delphioutpost.com> wrote:
On 18 Feb 2002, chris(a)void.printf.net wrote:
>>>>>> "jpw" == John Paul Wallington
<jpw(a)shootybangbang.com> writes:
>
> jpw> How does an XEmacs user get font-lock automatically for modes
> jpw> that don't visit files (eg: M-x ielm) ?
>
> The same method as for other modes; enable it globally. The incantation
> you're looking for is probably "(setq global-font-lock-mode t)".
I think john might be asking a different question. Or if he isn't
asking a different question I will:
I've noticed that several functions (pcl-cvs log, pcl-cvs diff) have
done everything necessary for font locking, except enable it. I think
font locking should just come on in all buffers. So, I was going to
send in some patches. But first.
What is the proper way to check if font-lock is enabled, and if
enabled globally to make sure that font locking is enabled for that mode.
GNU Emacs has global-font-lock-mode. It automagically turns on
fontification [*]. I think the closest XEmacs has is
font-lock-auto-fontify, but this variable is concerned with turning on
font-lock when visiting a file and doesn't turn on font-lock for ielm
or ibuffer or modes which use font-lock but aren't about visiting
files.
* from the sources:
;; In a previous discussion the following hack came to mind. It is a gross
;; hack, but it generally works. We use the convention that major modes start
;; by calling the function `kill-all-local-variables', which in turn runs
;; functions on the hook variable `change-major-mode-hook'. We attach our
;; function `font-lock-change-major-mode' to that hook. Of course, when this
;; hook is run, the major mode is in the process of being changed and we do not
;; know what the final major mode will be. So, `font-lock-change-major-mode'
;; only (a) notes the name of the current buffer, and (b) adds our function
;; `turn-on-font-lock-if-enabled' to the hook variables `find-file-hooks' and
;; `post-command-hook' (for buffers that are not visiting files). By the time
;; the functions on the first of these hooks to be run are run, the new major
;; mode is assumed to be in place. This way we get a Font Lock function run
;; when a major mode is turned on, without knowing major modes or their hooks.
;;
;; Naturally this requires that (a) major modes run `kill-all-local-variables',
;; as they are supposed to do, and (b) the major mode is in place after the
;; file is visited or the command that ran `kill-all-local-variables' has
;; finished, whichever the sooner. Arguably, any major mode that does not
;; follow the convension (a) is broken, and I can't think of any reason why (b)
;; would not be met (except `gnudoit' on non-files). However, it is not clean.
--
John Paul Wallington