help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font-lock and fontifying the few first nonempty lines in a buffer


From: Kevin Rodgers
Subject: Re: font-lock and fontifying the few first nonempty lines in a buffer
Date: Thu, 26 Jun 2003 17:26:29 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Ulf Andersson wrote:

> I'm trying to write a major mode for Emacs, that need to fontify the few
> first nonempty lines in the buffer. The mode do some other coloring in
> addition to this, and that works OK. So far I have experimented with
> `after-change-functions' and function matchers in `font-lock-keywords',
> but all I manage to do is sending my Emacs into an infinite loop deep
> down inside. I have to kill it from outside to get out of the lockup.
>
> I am using emacs 21.2.1 in a Windows 2000 environment.
>
> Has anyone already done somthing similar?
> Is there an `obvious canonical way' to do this?
> Is this downright impossible to do using `font-lock'?

If you need a regexp that matches 3 non-empty lines at the beginning of
the buffer:

interactively programatically ------------- ---------------
\`\(.+ C-q C-j \)\{3\}  "\\`\\(.+\n\\)\\{3\\}"

(If you need a regexp that matches the first 3 lines in the buffer,
replace + by *.)

If you need a regexp that matches the first 3 non-empty lines in the buffer:

interactively programatically ------------- --------------- M-< (goto-char (point-min))
\(^$\)*\(.+ C-q C-q \)\{3\}     "\\(^$\\)*\\(.+\n\\)\\{3\\}"

--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]