unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* line continuation and font-lock
@ 2006-02-06  8:20 Werner LEMBERG
  2006-02-06  8:37 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Werner LEMBERG @ 2006-02-06  8:20 UTC (permalink / raw)



I wonder how I can handle the line continuation character of groff in
font-lock.  Contrary to other languages, a trailing `\' is handled on
the input level, before anything else.  For example

  This is a \
  .test

is equal to

  This is a .test

Similarly,

  .foo "This is a \
  test"

Is equal to

  .foo "This is a test"

Consequently, for proper fontification, I have to handle trailing
backslashes earlier than anything else, too.  Looking into the
documentation I wasn't able to find a method to do that.  The nearest
thing I can find is font-lock-syntactic keywords, but I have the
feeling that this a)comes too late and b)is not appropriate, since
backslashes are not limited to any synctical element.

A possible solution might be to call a function which assigns a
special text property to the newline character if preceded by `\'
(basically an `ignore me' or `neutral' category) while doing
fontification.  Unfortunately, regular expressions don't have access
to text properties...

Any ideas?


    Werner

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: line continuation and font-lock
  2006-02-06  8:20 line continuation and font-lock Werner LEMBERG
@ 2006-02-06  8:37 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2006-02-06  8:37 UTC (permalink / raw)
  Cc: emacs-devel

> I wonder how I can handle the line continuation character of groff in
> font-lock.  Contrary to other languages, a trailing `\' is handled on
> the input level, before anything else.

Actually, C does the same thing (the \+LF is removed by cpp).

> Consequently, for proper fontification, I have to handle trailing
> backslashes earlier than anything else, too.  Looking into the
> documentation I wasn't able to find a method to do that.

Probably your best bet is to deifne a function (groff-bolp POS) which
when called at BOL returns t only if the previous line doesn't end with \.
Then use "^" in your regexps but filter out the false positives by using

     (if (groff-bolp (match-beginning 0)) font-lock-foo-face)

as the FACE expression.


        Stefan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-06  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-06  8:20 line continuation and font-lock Werner LEMBERG
2006-02-06  8:37 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).