[Top][All Lists]

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

Re: define multi-line comments

From: henry atting
Subject: Re: define multi-line comments
Date: Sun, 22 Jun 2008 09:51:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

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. 


reply via email to

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