From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: henry atting Newsgroups: gmane.emacs.help Subject: Re: define multi-line comments Date: Sun, 22 Jun 2008 09:51:02 +0200 Organization: LiteraturLateNight Message-ID: <87r6apykk9.fsf@literaturlatenight.de> References: <87iqw4f9ki.fsf@literaturlatenight.de> <87tzfnur14.fsf@literaturlatenight.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1214124095 23247 80.91.229.12 (22 Jun 2008 08:41:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Jun 2008 08:41:35 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 22 10:42:20 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 1KAL9P-00045Z-Ug for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Jun 2008 10:42:20 +0200 Original-Received: from localhost ([127.0.0.1]:43641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KAL8a-0000Ep-Gf for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Jun 2008 04:41:28 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 64 Original-NNTP-Posting-Host: port-92-195-52-27.dynamic.qsc.de Original-X-Trace: online.de 1214121062 32299 92.195.52.27 (22 Jun 2008 07:51:02 GMT) Original-X-Complaints-To: abuse@einsundeins.com Original-NNTP-Posting-Date: Sun, 22 Jun 2008 07:51:02 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:3q5sGgoDCy9jV+wLAPK5gO7rs0s= Original-Xref: news.stanford.edu gnu.emacs.help:159674 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:55028 Archived-At: David Hansen wrote: > 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). Because its only purpose is to highlight direct speech (in my text-mode) it actually works very well. Mmh, with `font-lock-syntactic-keywords' I couldn't get very far. I found this in the manual: ,---- | — Variable: font-lock-syntactic-face-function | [...] | This can be used to highlighting different kinds of strings or comments | differently. It is also sometimes abused together with | font-lock-syntactic-keywords to highlight constructs that span multiple | lines, but this is too esoteric to document here. `---- which is not too encouraging. henry