* define multi-line comments
@ 2008-06-20 14:46 henry atting
2008-06-20 16:01 ` David Hansen
[not found] ` <mailman.13617.1213978108.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: henry atting @ 2008-06-20 14:46 UTC (permalink / raw)
To: help-gnu-emacs
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.
henry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define multi-line comments
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>
1 sibling, 0 replies; 7+ messages in thread
From: David Hansen @ 2008-06-20 16:01 UTC (permalink / raw)
To: help-gnu-emacs
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.
Good luck ;p
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.
David
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.13617.1213978108.18990.help-gnu-emacs@gnu.org>]
* Re: define multi-line comments
[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>
0 siblings, 2 replies; 7+ messages in thread
From: henry atting @ 2008-06-21 8:32 UTC (permalink / raw)
To: help-gnu-emacs
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))
> 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 :)
henry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define multi-line comments
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>
1 sibling, 0 replies; 7+ messages in thread
From: David Hansen @ 2008-06-21 9:11 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.13659.1214040211.18990.help-gnu-emacs@gnu.org>]
* Re: define multi-line comments
[not found] ` <mailman.13659.1214040211.18990.help-gnu-emacs@gnu.org>
@ 2008-06-22 7:51 ` henry atting
2008-06-22 10:15 ` David Hansen
[not found] ` <mailman.13696.1214130202.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: henry atting @ 2008-06-22 7:51 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define multi-line comments
2008-06-22 7:51 ` henry atting
@ 2008-06-22 10:15 ` David Hansen
[not found] ` <mailman.13696.1214130202.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: David Hansen @ 2008-06-22 10:15 UTC (permalink / raw)
To: help-gnu-emacs
On Sun, 22 Jun 2008 09:51:02 +0200 henry atting wrote:
> 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)
>>>>>
I should have noted that before... If that's the only case, you can
simply modify the syntax of a `"' (lookup `syntax tables' in the manual)
to highlight the region as a string. I don't think it's possible to
change the face here.
>>> 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.
Are you talking about setting `font-lock-multiline' to `t' and just
using regexps that may spawn several lines? If it works for you just
use it, it will save a lot of trouble. But be warned, it's not 100%
accurate.
> Mmh, with `font-lock-syntactic-keywords' I couldn't get very far. I
> found this in the manual:
If you describe your problems in a bit more detail someone might be able
to help.
> ,----
> | — 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.
Ignore the "esoteric" comment. Just pretend your constructs are
"strings of a programming language". It will work. If you run into
problems that `parse-partial-sexp' behaves weird, play around with
`parse-sexp-lookup-properties'. But i recommend to not care about this
right now.
If you grep the emacs sources for `syntactic-keywords' you'll find some
examples (every language that has comments or strings that can't be
described via syntax tables, e.g. html).
David
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.13696.1214130202.18990.help-gnu-emacs@gnu.org>]
* Re: define multi-line comments
[not found] ` <mailman.13696.1214130202.18990.help-gnu-emacs@gnu.org>
@ 2008-06-22 15:43 ` henry atting
0 siblings, 0 replies; 7+ messages in thread
From: henry atting @ 2008-06-22 15:43 UTC (permalink / raw)
To: help-gnu-emacs
David Hansen wrote:
> On Sun, 22 Jun 2008 09:51:02 +0200 henry atting wrote:
> [...]
>>
>> Because its only purpose is to highlight direct speech (in my
>> text-mode) it actually works very well.
>
> Are you talking about setting `font-lock-multiline' to `t' and just
> using regexps that may spawn several lines? If it works for you just
> use it, it will save a lot of trouble. But be warned, it's not 100%
> accurate.
With `lazy-lock-mode' it works fine. I can use it all the more it has
not to be 100% reliable.
>> Mmh, with `font-lock-syntactic-keywords' I couldn't get very far. I
>> found this in the manual:
>
> If you describe your problems in a bit more detail someone might be able
> to help.
Much more out of curiosity (or to learn a little) I took the following
example from an old php mode library:
(defconst mytext-font-lock-syntactic-keywords
(list
'("\\(\%\\)"
(1 (11 . nil)))
'("%.*\\([\n]\\)"
(1 (12 . nil)))
))
I expected it to start a comment with `%' and end it on a new line
with `%' But it doesn't work this way.
So as a result of my poor understanding of elisp it may be complete
nonsense.
henry
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-06-22 15:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.