From: David Abrahams <dave@boost-consulting.com>
Subject: Re: Multiline font lock questions
Date: Fri, 17 Nov 2006 17:44:07 -0500 [thread overview]
Message-ID: <87u00xd77s.fsf@pereiro.luannocracy.com> (raw)
In-Reply-To: 1163794554.336332.297920@k70g2000cwa.googlegroups.com
"rgb" <rbielaws@i1.net> writes:
> David Abrahams wrote:
>> "rgb" <rbielaws@i1.net> writes:
>>
>> >> * Place a `font-lock-multiline' property on the construct when it is
>> >> added to the buffer.
>> >>
>> >> I don't understand how that can help. If I start with
>> >>
>> >> +------------+
>> >> |This [is |
>> >> |paragraph 1 |
>> >> | |
>> >> |This is |
>> >> |paragraph] 2|
>> >> +------------+
>> >>
>> >> then presumably nothing is marked with the `font-lock-multiline'
>> >> property, because there are no multiline constructs. If I then kill
>> >> the blank line, how is it going to know to start identification at the
>> >> beginning of the newly-formed paragraph?
>> >
>> > Look at the SYNTAX-BEGIN argument of font-lock-defaults.
>>
>> IIUC that is only for `syntactic fontification,' which apparently
>> refers just to fontifying comments and strings. Did I misinterpret
>> the doc?
>
> AFAIK font-lock does ALL fontification
I know that.
> (outside of any you do yourself of course).
"Do yourself?" That might be just what I need, actually. How do I do
that?
> Not just comments and strings. Moreover it takes several passes
> across the text to accomplish fontification.
>
> font-lock-syntactic-keywords allows you to pick and choose
> which characters have begin string fence syntax, comment end
> syntax etc. before a pass marks strings and comments.
> Only then can keywords be fontified so as to avoid words
> in comments or strings.
Right.
However, the docs for font-lock-defaults say:
If SYNTAX-BEGIN is non-nil, it should be a function with no args
used to move backwards outside any enclosing syntactic block,
for syntactic fontification.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Maybe "syntactic fontification" means something different from the
"just comments and strings" meaning of "syntactic"...?
Typical values are `beginning-of-line'
(i.e., the start of the line is known to be outside a syntactic
block), or `beginning-of-defun' for programming modes or
`backward-paragraph' for textual modes (i.e., the mode-dependent
function is known to move outside a syntactic block). If nil, the
beginning of the buffer is used as a position outside of a syntactic
block, in the worst case.
> So it depends on how you plan to apply font-lock-multiline.
> If it were me, I'd be using the fontification routines
Sorry, which are those?
> to apply the font-lock-multiline property to the text. But to do
> that I would need to insure that, as in your example, when something
> like a blank line is deleted, fontification starts at the beginning
> of the paragraph; which now is 2 lines prior to the deleted line. I
> believe syntax-begin defaults to beginning-of-line.
In my case, it's already nil, which according to the above should mean
that it goes all the way back to the beginning of the buffer ("in the
worst case," whatever that means) so it doesn't seem like this is the
right lever to pull.
> So by default the multi-line construct would not get recognized.
>
> I've never actually had to change syntax-begin for my own
> modes but I've written font-lock support for some fairly unusual
> syntax. Leading me to diluded myself into thinking I know
> how it works.
Well, I am really stumped. I am also, it seems, getting some
combinatoric regexp evaluation. Whoopee!
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
next prev parent reply other threads:[~2006-11-17 22:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.748.1163772550.2155.help-gnu-emacs@gnu.org>
2006-11-17 17:02 ` Multiline font lock questions rgb
2006-11-17 18:26 ` David Abrahams
[not found] ` <mailman.758.1163787985.2155.help-gnu-emacs@gnu.org>
2006-11-17 20:15 ` rgb
2006-11-17 22:44 ` David Abrahams [this message]
2006-11-19 19:21 ` Stefan Monnier
2006-11-21 20:07 ` David Abrahams
2006-11-21 20:35 ` Stefan Monnier
2006-11-17 14:08 David Abrahams
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87u00xd77s.fsf@pereiro.luannocracy.com \
--to=dave@boost-consulting.com \
/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.
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).