From: henry atting <nospam@literaturlatenight.de>
To: help-gnu-emacs@gnu.org
Subject: Re: define multi-line comments
Date: Sun, 22 Jun 2008 09:51:02 +0200 [thread overview]
Message-ID: <87r6apykk9.fsf@literaturlatenight.de> (raw)
In-Reply-To: mailman.13659.1214040211.18990.help-gnu-emacs@gnu.org
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
next prev parent reply other threads:[~2008-06-22 7:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-20 14:46 define multi-line comments henry atting
2008-06-20 16:01 ` David Hansen
[not found] ` <mailman.13617.1213978108.18990.help-gnu-emacs@gnu.org>
2008-06-21 8:32 ` henry atting
2008-06-21 9:11 ` David Hansen
[not found] ` <mailman.13659.1214040211.18990.help-gnu-emacs@gnu.org>
2008-06-22 7:51 ` henry atting [this message]
2008-06-22 10:15 ` David Hansen
[not found] ` <mailman.13696.1214130202.18990.help-gnu-emacs@gnu.org>
2008-06-22 15:43 ` henry atting
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r6apykk9.fsf@literaturlatenight.de \
--to=nospam@literaturlatenight.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.