From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Hansen Newsgroups: gmane.emacs.help Subject: Re: define multi-line comments Date: Sat, 21 Jun 2008 11:11:23 +0200 Organization: disorganized Message-ID: <87ej6rf8zo.fsf@localhorst.mine.nu> References: <87iqw4f9ki.fsf@literaturlatenight.de> <87tzfnur14.fsf@literaturlatenight.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214040249 21984 80.91.229.12 (21 Jun 2008 09:24:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Jun 2008 09:24:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 21 11:24:54 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K9zL3-0001AS-Ij for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jun 2008 11:24:53 +0200 Original-Received: from localhost ([127.0.0.1]:51291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K9zKE-0008RV-Dj for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jun 2008 05:24:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K9zJg-0008PE-Tr for help-gnu-emacs@gnu.org; Sat, 21 Jun 2008 05:23:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K9zJf-0008Ne-C5 for help-gnu-emacs@gnu.org; Sat, 21 Jun 2008 05:23:28 -0400 Original-Received: from [199.232.76.173] (port=52169 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K9zJf-0008NU-53 for help-gnu-emacs@gnu.org; Sat, 21 Jun 2008 05:23:27 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:41466 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K9zJe-0000Cn-RD for help-gnu-emacs@gnu.org; Sat, 21 Jun 2008 05:23:27 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K9zJU-0005xh-BB for help-gnu-emacs@gnu.org; Sat, 21 Jun 2008 09:23:16 +0000 Original-Received: from e178037032.adsl.alicedsl.de ([85.178.37.32]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Jun 2008 09:23:16 +0000 Original-Received: from david.hansen by e178037032.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Jun 2008 09:23:16 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 45 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178037032.adsl.alicedsl.de Mail-Copies-To: nobody User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:cYSMVNjHpCXEiRaT8G6bgUs7mHg= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:55022 Archived-At: On Sat, 21 Jun 2008 10:32:39 +0200 henry atting wrote: > David Hansen wrote: > >> On Fri, 20 Jun 2008 16:46:37 +0200 henry atting wrote: >> >>> I have my own text mode (derived from text-mode), which defines some >>> syntax highlighting. Defining keywords is no problem but as far as I see >>> keywords don't work on serveral lines, e.g. this >>> >>> (list "\".*\"" 0 'font-lock-variable-name-face t) >>> >>> only highlights words or phrases till the line break. >>> Can anyone give me a hint how to get it work multi-line. >> >> There are some words about this in the Elisp manual, lookup >> `font-lock-multiline'. But this is incredible complicated. > > Oh yes, you really might say this ;) > > In the meantime I found a way to do it. I looked into lua-mode.el where > mulit-line comments work and changed it according to my needs: > > (list > "\\(?:^\\|[^-]\\)\\(\"\\(=*\\)\\(?:.\\|\n\\)*?\"\\)" > '(1 'font-lock-string-face t)) Setting `font-lock-multiline' to `t' and using regexps that spawn more than one line works "a bit". If it's not to important to highlight always correctly and if the regexp "usually" matches only one line this is an option as well. > >> But in many circumstances you can use `font-lock-syntactic-keywords' to >> make some region a "string" or "comment" and then use >> `font-lock-syntactic-face-function' to give it another face. > > Now I will take a look at this. Thanks :) Someone should tell the lua-mode developers about it... This works perfectly well if you have one region and one face for the whole region. But it's not an option for regions with multiple faces (like e.g. long function declarations in C). David