From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Bowman Newsgroups: gmane.emacs.help Subject: Re: Separating // and /**/ comment fontification Date: Tue, 14 Jun 2005 13:10:21 -0700 (PDT) Message-ID: <20050614201021.91883.qmail@web51910.mail.yahoo.com> References: <20050614191348.10706.qmail@web51903.mail.yahoo.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1118779968 18426 80.91.229.2 (14 Jun 2005 20:12:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 14 Jun 2005 20:12:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 14 22:12:40 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DiHlC-0001T2-T3 for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Jun 2005 22:11:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DiHqH-0006Nu-8G for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Jun 2005 16:17:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DiHmc-0004xk-3l for help-gnu-emacs@gnu.org; Tue, 14 Jun 2005 16:13:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DiHmZ-0004uF-OW for help-gnu-emacs@gnu.org; Tue, 14 Jun 2005 16:13:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DiHmX-0004rQ-Hh for help-gnu-emacs@gnu.org; Tue, 14 Jun 2005 16:13:09 -0400 Original-Received: from [206.190.39.53] (helo=web51910.mail.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.34) id 1DiHlB-00049H-FY for help-gnu-emacs@gnu.org; Tue, 14 Jun 2005 16:11:45 -0400 Original-Received: (qmail 91885 invoked by uid 60001); 14 Jun 2005 20:10:21 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=SwjHhavkNJWXj4JMuzIjslM5IaTAx/Q3IxeJbLq8rP5hMmEpktovQVc6A5nbYOio/LffMG4RttLvqmk75vFvgwplsZ9SecsjSVBHy4pVgbFEGZ3ix+XnCL4XolQ5eT3k6zshooJC1PMQLT5TqbsWZ5jcHp1vco/yQqrLi5Zpzj4= ; Original-Received: from [208.11.76.5] by web51910.mail.yahoo.com via HTTP; Tue, 14 Jun 2005 13:10:21 PDT Original-To: help-gnu-emacs@gnu.org In-Reply-To: <20050614191348.10706.qmail@web51903.mail.yahoo.com> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:27472 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:27472 --- Ryan Bowman wrote: > > --- Stefan Monnier wrote: > > > > How can I change the fontification of one (or the > > > other) to use a different face? > > > > Try C-h v font-lock-syntactic-face-function. > > > > > > Stefan > > ;; from font-lock.el > (defvar font-lock-syntactic-face-function > (lambda (state) > (if (nth 3 state) font-lock-string-face > font-lock-comment-face)) > "Function to determine which face to use when > fontifying syntactically. > The function is called with a single parameter (the > state as returned by > `parse-partial-sexp' at the beginning of the region to > highlight) and > should return a face.") > > So as I understand it > font-lock-syntactic-face-function will return the face > with which to highlight something: -string-face if > it's a string, -comment-face otherwise. > > Following the link to parse-partial-sexp item #7 of > the return value looks somewhat helpful: > > 7. t if in a comment of style b; symbol > `syntax-table' if the comment > should be terminated by a generic comment > delimiter. > > but I don't quite understand it. What is a comment of > style b? I assume that if the symbol `syntax-table' > is returned it means that the comment must be > terminated by the comment delimiter defined in the > syntax table for the current mode, is that correct? > In Java would the latter then be '*/' and a comment of > style b be a comment started with '//'? > Apparently, I didn't follow my train of ignorance far enough. I dug up the syntax table chapter in the emacs lisp manual and found out what a 'b' style comment is - in c++ (and I assume by extension, java) a b-style comment is the line comment '//' that I was looking for. So, I could redefine font-lock-syntactic-face-function (setq font-lock-syntactic-face-function (lambda (state) (if (nth 3 state) font-lock-string-face (if (nth 7 state) font-lock-other-comment-face font-lock-comment-face)))) and that should do what I want. Though on first attempt it doesn't seem to. ---- Ryan Bowman There is no vi there is only Emacs ---- __________________________________ Discover Yahoo! Find restaurants, movies, travel and more fun for the weekend. Check it out! http://discover.yahoo.com/weekend.html