[Top][All Lists]

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

Re: map: major-mode --> font-lock-defaults

From: Sam Steingold
Subject: Re: map: major-mode --> font-lock-defaults
Date: 29 Jan 2001 18:35:51 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.97

> * In message <address@hidden>
> * On the subject of "Re: map: major-mode --> font-lock-defaults "
> * Sent on Mon, 29 Jan 2001 17:08:30 -0500
> * Honorable "Stefan Monnier" <monnier+gnu/address@hidden> writes:
> > wait a second: it was _not_ automatically inherited from c-mode to
> > d-mode (yes, you say the reason is administrative, not technical, but
> > the bottom line is: it is not _always_ automatically inherited!)
> Indeed, the font-lock-defaults-alist method does not automatically
> inherit, which is one of its disadvantages

let me try to repeat: there is a bug: `font-lock-defaults' is not
inherited from c-mode to d-mode.

Barring rewriting Emacs in an object-oriented way, can we hope that this
will ever be fixed?

> > what about `lisp-mode' and `emacs-lisp-mode'?
> > they are mentioned in `font-lock-defaults-alist', but they are
> > maintained by the FSF, right?
> Yes.  But note that the value there is "not used any more" since those
> modes now set font-lock-defaults themselves anyway.
> They are still mentioned in font-lock-defaults-alist for various reasons,
> mostly having to do with compatibility.

In the CVS font-lock.el, `font-lock-defaults-alist' has the correct
values for lisp modes (and it does not mention that these values are
It's interesting to see the same string like "+-*/.<>=!?$%_&~^:" in both
lisp-mode.el:146 and font-lock.el:518. :-)

(defun major-mode-font-lock-defaults (mode)
  (let* ((hook (intern (concat (symbol-name mode) "-hook")))
         (old-val (symbol-value hook))
    (set hook nil)
    (with-temp-buffer (funcall mode) (setq fld font-lock-defaults))
    (set hook old-val)

(major-mode-font-lock-defaults 'lisp-mode)
 ==> ((lisp-font-lock-keywords lisp-font-lock-keywords-1
      nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
      (font-lock-mark-block-function . mark-defun))

(major-mode-font-lock-defaults 'c-mode)
 ==> nil

so, the old question remains - how do I find out the
`font-lock-defaults' of a mode without using `font-lock-defaults-alist'?

Sam Steingold (http://www.podval.org/~sds)
Support Israel's right to defend herself! <http://www.i-charity.com/go/israel>
Read what the Arab leaders say to their people on <http://www.memri.org/>
Lisp suffers from being twenty or thirty years ahead of time.

reply via email to

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