* help with font-lock-multiline
@ 2004-09-27 23:02 Raul Acevedo
0 siblings, 0 replies; 6+ messages in thread
From: Raul Acevedo @ 2004-09-27 23:02 UTC (permalink / raw)
I'm doing JSP development, and I want something very simple. I want to
fontify the text between <% and %> tags, even if spread across multiple
lines.
How do I do this? I've tried regular expressions such as:
<%.+%>
<%\(.+\n\)+%>
and many variations, but none work. With enough messing around I can
get some parts fontified, but it's not consistent. Yes, I have setq-
default font-lock-multiline to true.
Anyone gotten multiline fontification in any mode to work? How?
Raul
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.4324.1096326611.1998.help-gnu-emacs@gnu.org>]
* Re: help with font-lock-multiline
[not found] <mailman.4324.1096326611.1998.help-gnu-emacs@gnu.org>
@ 2004-09-28 2:12 ` Katsumi Yamaoka
2004-09-28 16:38 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Katsumi Yamaoka @ 2004-09-28 2:12 UTC (permalink / raw)
>>>>> In <mailman.4324.1096326611.1998.help-gnu-emacs@gnu.org>
>>>>> Raul Acevedo wrote:
> I'm doing JSP development, and I want something very simple. I want to
> fontify the text between <% and %> tags, even if spread across multiple
> lines.
You will need to use a function which searches for a range
larger than the range which font-lock usually searches for,
instead of a regexp. I tried it in the *scratch* buffer using
the following configuration:
(defun find-brackets (limit)
(or (re-search-forward "<%[^>]*%>" nil t)
(let ((start (point)))
(if (and (search-backward "<%" nil t)
(search-forward "%>" nil t))
(goto-char limit)
(goto-char start)
nil))))
(setq font-lock-keywords (append font-lock-keywords
'((find-brackets (0 'underline t))))
font-lock-multiline t)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with font-lock-multiline
[not found] <mailman.4324.1096326611.1998.help-gnu-emacs@gnu.org>
2004-09-28 2:12 ` Katsumi Yamaoka
@ 2004-09-28 16:38 ` Stefan Monnier
2004-09-28 17:01 ` Gian Uberto Lauri
` (2 more replies)
1 sibling, 3 replies; 6+ messages in thread
From: Stefan Monnier @ 2004-09-28 16:38 UTC (permalink / raw)
> I'm doing JSP development, and I want something very simple. I want to
> fontify the text between <% and %> tags, even if spread across multiple
> lines.
font-lock-multiline is probably not the right tool here (it works OK for
things that are "generally single line, but something spread over a couple
more lines", but for really long sections forget it).
Your best bet is to mark <% and %> as string (or comment) delimiters in
font-lock-syntactic-keywords. If you want to highlight them in a different
face that the string-face or comment-face, then use
font-lock-syntactic-face-function.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with font-lock-multiline
2004-09-28 16:38 ` Stefan Monnier
@ 2004-09-28 17:01 ` Gian Uberto Lauri
[not found] ` <mailman.103.1096391270.2017.help-gnu-emacs@gnu.org>
2004-09-30 12:36 ` Katsumi Yamaoka
2 siblings, 0 replies; 6+ messages in thread
From: Gian Uberto Lauri @ 2004-09-28 17:01 UTC (permalink / raw)
Cc: help-gnu-emacs
>>>>> "SM" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I'm doing JSP development, and I want something very simple. I want to
>> fontify the text between <% and %> tags, even if spread across multiple
>> lines.
SM> font-lock-multiline is probably not the right tool here (it works OK for
SM> things that are "generally single line, but something spread over a couple
SM> more lines", but for really long sections forget it).
SM> Your best bet is to mark <% and %> as string (or comment) delimiters in
SM> font-lock-syntactic-keywords. If you want to highlight them in a different
SM> face that the string-face or comment-face, then use
SM> font-lock-syntactic-face-function.
KA-BANG!!!!!!!!!!!!!!
I'm trying it in the beta version of the next version wannabe of
html-helper-mode - masochist can find it at the following url:
<http://savannah.nongnu.org/download/baol-hth/beta-html-helper-mode.el.gz>
but it falls one tag short (it seems it fails to decorate the last tag
- an html tag could span multiple lines)
Where can I learn how to write it properly ?
The tex-mode example was a too little help for my limited skills (and
intellect).
TIA!!!!
--
/\ ___
/___/\__|_|\_|__|___Gian Uberto Lauri_____________________
//--\ | | \| | Integralista GNUslamico e fancazzista
\/
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.103.1096391270.2017.help-gnu-emacs@gnu.org>]
* Re: help with font-lock-multiline
2004-09-28 16:38 ` Stefan Monnier
2004-09-28 17:01 ` Gian Uberto Lauri
[not found] ` <mailman.103.1096391270.2017.help-gnu-emacs@gnu.org>
@ 2004-09-30 12:36 ` Katsumi Yamaoka
2 siblings, 0 replies; 6+ messages in thread
From: Katsumi Yamaoka @ 2004-09-30 12:36 UTC (permalink / raw)
>>>>> In <jwvpt46xshc.fsf-monnier+gnu.emacs.help@gnu.org>
>>>>> Stefan Monnier wrote:
> Your best bet is to mark <% and %> as string (or comment) delimiters in
> font-lock-syntactic-keywords. If you want to highlight them in a different
> face that the string-face or comment-face, then use
> font-lock-syntactic-face-function.
I read the Syntax Tables section of the Elisp info manual and
found how do I highlight text between <% and %>. That the
simplest way to do that in the *scracth* buffer will be the
following:
(setq font-lock-syntactic-keywords '(("\\(<\\)%" 1 "< b")
("%\\(>\\)" 1 "> b")))
I will look for the way to highlight <%foo%> and <%bar%> by
different face. Thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-09-30 12:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-27 23:02 help with font-lock-multiline Raul Acevedo
[not found] <mailman.4324.1096326611.1998.help-gnu-emacs@gnu.org>
2004-09-28 2:12 ` Katsumi Yamaoka
2004-09-28 16:38 ` Stefan Monnier
2004-09-28 17:01 ` Gian Uberto Lauri
[not found] ` <mailman.103.1096391270.2017.help-gnu-emacs@gnu.org>
2004-09-28 19:41 ` Stefan Monnier
2004-09-30 12:36 ` Katsumi Yamaoka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).