emacs-devel
[Top][All Lists]
Advanced

[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 12:09:53 -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 09:12:08 -0500
> * Honorable "Stefan Monnier" <monnier+gnu/address@hidden> writes:
>
> > How do I determine font locking scheme of a major mode?
> > font-lock-defaults-alist is now deprecated, so
> > 
> >         (assq 'c-mode font-lock-defaults-alist)
> > 
> > is wrong (I used it in e20).
> > Do I have to use something like this:
> > 
> >         (with-temp-buffer (c-mode) font-lock-defaults)
> > 
> > (I want my derived move to inherit font-lock-defaults too)
> 
> It's inherited automatically since it's a buffer-local variable.
> 
>       (define-derived-mode new-mode old-mode "New"
>         "A New major mode"
>         ...)

Unfortunately, I do not observe this.
The following:

(define-derived-mode d-mode c-mode "D"
  "Major mode for editing CLISP source code.
Special commands:
\\{d-mode-map}
Turning on D mode calls the value of the variable `d-mode-hook',
if that value is non-nil.
If you are using Emacs 20.2 or earlier (including XEmacs) and want to
use fontifications, you have to (require 'font-lock) first.  Sorry."
  (when (and (> 21 emacs-major-version)
             (null (assq 'd-mode font-lock-defaults-alist)))
    (set (make-local-variable 'font-lock-defaults)
         (cdr (assq 'c-mode font-lock-defaults-alist)))))
(when window-system
  (if sds-xemacs
      (put 'd-mode 'font-lock-defaults (get 'c-mode 'font-lock-defaults))
      (when (and (> 21 emacs-major-version)
                 (null (assq 'd-mode font-lock-defaults-alist)))
        (setq font-lock-defaults-alist
              (cons (cons 'd-mode
                          (cdr (assq 'c-mode font-lock-defaults-alist)))
                    font-lock-defaults-alist)))))

gives many more fontifications in emacs 20.7 than in emacs 21.
(which probably should not be too surprising since derived.el does not
mention font-lock at all).

Still, if I wished to add to the c-mode fontifications, I would have to
do

        (with-temp-buffer (c-mode) font-lock-defaults)

right?!

why not have something more readily accessible?

Thanks.

-- 
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/>
Winners never quit; quitters never win; idiots neither win nor quit.




reply via email to

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