From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Javier Oviedo" Newsgroups: gmane.emacs.help Subject: Re: font-lock question Date: Tue, 10 Feb 2004 08:49:36 -0500 Organization: Texas Instruments Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1076422242 27982 80.91.224.253 (10 Feb 2004 14:10:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 10 Feb 2004 14:10:42 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 10 15:10:36 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AqYax-0000tR-00 for ; Tue, 10 Feb 2004 15:10:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AqYSy-0004P0-DH for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Feb 2004 09:02:20 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!attdl1!ip.att.net!news.ti.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 126 Original-NNTP-Posting-Host: gt64v7121.telogy.design.ti.com Original-X-Trace: home.itg.ti.com 1076420959 8849 158.218.103.164 (10 Feb 2004 13:49:19 GMT) Original-X-Complaints-To: usenet@news.ti.com Original-NNTP-Posting-Date: 10 Feb 2004 13:49:19 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Original-Xref: shelby.stanford.edu gnu.emacs.help:120804 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:16753 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16753 I meant Alan, not Alex. Sorry. :-) -- Javier "Javier Oviedo" wrote in message news:c08rqv$e5f$1@home.itg.ti.com... > Hi Alex. > > Actually, I implemented something very similar to this exact code. My > motivation is that the occur mode buffer does not display the matches in the > original buffers faces. I was just curious if I could hack something and > decided to implement this myself...though an obviously vicious hack(see > below). I decided to do this more for fun then anything else...I just wanted > to see if I could figure it out. (Kevin Rogers suggests that I should submit > a bug report.) > > This little hack works when running occur on a emacs-lisp-mode buffer...I > was going to add highlighting using overlays next, assuming that I could > figure that out as well. :-) > > (defvar joviedo-occur-font-lock-default nil) > (defadvice occur (after joviedo-occur last activate) > (setq joviedo-occur-font-lock-default font-lock-defaults) > (pop-to-buffer "*Occur*") > (set (make-local-variable 'font-lock-defaults) > joviedo-occur-font-lock-default) > (font-lock-mode nil) > (font-lock-fontify-buffer) > > ;;;still need to add highlights using overlays. > > ) > > > One issue, however, is that this does not work for a c-mode buffer. I get > some sort of strange error that I can't figure out. I thought the principle > was relatively sound but I guess not. The error in the *Message* is the > following: > > Wrong type argument: stringp, nil > Error in post-command-hook: (wrong-type-argument stringp nil) > > When I examine the value for font-lock-defaults(after my defadvice runs) I > see the following: > > font-lock-defaults's value is > ((c-font-lock-keywords c-font-lock-keywords-1 c-font-lock-keywords-2 > c-font-lock-keywords-3) > nil nil > ((95 . "w") > (36 . "w")) > c-beginning-of-syntax > (font-lock-mark-block-function . c-mark-function)) > > > This is exactly what I get if I examine the value of font-lock-defaults > before ever running occur. For some reason, there is something wrong with > this value(list) but I can't figure it out. > > Any thoughts?????? help??? > > -- > Javier > > > "Alan Mackenzie" wrote in message > news:thi80c.q5.ln@acm.acm... > > Javier Oviedo 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: aacm@muuc.dee; to decode, wherever there is a repeated letter > > (like "aa"), remove half of them (leaving, say, "a"). > > > >