help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: font-lock question


From: Alan Mackenzie
Subject: Re: font-lock question
Date: Mon, 9 Feb 2004 18:12:13 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

Javier Oviedo <address@hidden> wrote on Mon, 9 Feb 2004 11:18:00
-0500:
> Hello all:

> This will probably sound like a rather bizarre question but here goes...

Bizarre indeed!

> Is there a way to fontify a buffer based on a different mode but still
> retain all of the original/base modes attributes(expect for the face
> attributes, of course)?

Yes.  The answer is _always_ yes in Emacs.  :-)

> Example:  I have c-file open in emacs and the buffer is using c-mode.
> I'd like to use the faces for emacs-lisp-mode(this just an example, so
> please humor me) but keep every other attribute of the c-mode. Can this
> be done? Is there some other way I could accomplish this? Perhaps using
> a minor mode and it's faces but keeping the attributes of the major
> mode? I'm open to any and all suggestions.

How about something like this (not tested):

(defun jo-funny-font ()
  (font-lock-mode -1)
;; The next line is taken from lisp-mode-variables in lisp-mode.el
  (setq font-lock-defaults
        '((lisp-font-lock-keywords
           lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
          nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
          (font-lock-mark-block-function . mark-defun)))
  (font-lock-mode 1))
(add-hook 'c-mode-hook 'jo-funny-font)

But why do you want to do this?

> Thanks in advance!

> Javier

-- 
Alan Mackenzie (Munich, Germany)
Email: address@hidden; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").



reply via email to

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