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

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

Re: advice needed for font-lock-syntactic-face-function


From: Stefan Monnier
Subject: Re: advice needed for font-lock-syntactic-face-function
Date: Mon, 19 Jan 2004 22:54:12 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> I'm trying  to borrow the  function from tex-mode.el (CVS  version) to
> mark.  html tags and JSP/ASP/PHP blocks,  and I took the piece of code
> that matches \verb+ + blocks as example.

I did not understand what goes wrong with the code you posted: does it get
stuck in an infinite loop?  does it fail to highlight?  does it
highlight wrong?  does it signal an error?

>       (cond ((string-match "[a-zA-Z]" (char-to-string char))
>              ;; This is an HTML tag
>              (save-excursion
>                (unless (search-forward-regexp "[^%?]>" nil t)
>                  (goto-char (point-max)))
>                (html-helper-font-lock-last-char-helper))

I'd recommend (re-search-forward "[^%?]>" nil 'move).

>             ((eq ? char)

Since "? " is the first arg to `eq' above, that means there is no
separation betwen the two args, which is poor style.  I recommend
(eq char ?\ ) instead which makes the meaningful space much more visible.

>              ;; This is a server script block
>              (unless (search-forwardd "-->" nil t)
>                (save-excursion
>                  (goto-char (point-max))))
>              font-lock-comment-face))))))

This save-excursion block is a nop.

> Executing my function step by  step i verified that I successfully set
> up  font-lock-syntactic-keywords,

I.e. you checked with C-x = that the proper chars get assigned the proper
syntax-table property?

> I successfully  matched  a tag  but after leaving the save-excursion
> block I see that the program enters this sexp

Which save-excursion block?

> (set-syntax-table old-syntax-table)

I see no such sexp in your code.  Which code are you tracing?  font-lock's?
If you're tracing font-lock's code, you're better off turning off jit-lock
mode, otherwise it's a complete mess.

> and after some more steps (about 8) I get stuck in the

Are you using edebug?  Or which kind of stepping are you doing?


        Stefan


reply via email to

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